Skip to content

Commit

Permalink
Merge pull request #2 from navariltd/develop2
Browse files Browse the repository at this point in the history
Develop2
  • Loading branch information
maniamartial authored Jul 25, 2024
2 parents a4103c7 + 6ed3617 commit 759622f
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 19 deletions.
49 changes: 32 additions & 17 deletions navari_cams_biometric/cams_biometric/controllers/cams_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,43 @@ def handle_attendance_log(stgid, rawdata):
log_time_dt = parser.parse(log_time)
formatted_log_time = log_time_dt.strftime("%Y-%m-%d %H:%M:%S")

# Storing the values in Employee Checking doctype
employee_checking = frappe.get_doc({
"doctype": "Employee Checkin",
# Check if the employee check-in already exists
existing_checkin = frappe.db.exists("Employee Checkin", {
"employee": request_data["RealTime"]["PunchLog"]["UserId"],
"time": formatted_log_time,
"log_type": log_type,
"custom_input_type":request_data["RealTime"]["PunchLog"]["InputType"]
"log_type": log_type
})

employee_checking.insert(ignore_permissions=True)
frappe.db.commit()
if not existing_checkin:
# Storing the values in Employee Checking doctype
employee_checking = frappe.get_doc({
"doctype": "Employee Checkin",
"employee": request_data["RealTime"]["PunchLog"]["UserId"],
"time": formatted_log_time,
"log_type": log_type,
"custom_input_type": request_data["RealTime"]["PunchLog"]["InputType"]
})

employee_checking.insert(ignore_permissions=True)
frappe.db.commit()

return "done"

'''I dont see the need to write to a file'''
# content = f'ServiceTagId: {stgid},\t'
# content += f'UserId: {request_data["RealTime"]["PunchLog"]["UserId"]},\t'
# content += f'AttendanceTime: {request_data["RealTime"]["PunchLog"]["LogTime"]},\t'
# content += f'AttendanceType: {request_data["RealTime"]["PunchLog"]["Type"]},\t'
# content += f'InputType: {request_data["RealTime"]["PunchLog"]["InputType"]},\t'
# content += f'Operation: RealTime->PunchLog,\t'
# content += f'AuthToken: {request_data["RealTime"]["AuthToken"]}\n'

# with open("cams-attendance-record.txt", "a") as file:
# file.write(content)
def add_user():
first_name=frappe.form_dict.get('first_name')
last_name=frappe.form_dict.get('last_name')
user_id=frappe.form_dict.get('user_id')
user_type=frappe.form_dict.get('user_type')

def delete_user():
user_id=frappe.form_dict.get('user_id')
user_type=frappe.form_dict.get('user_type')

def add_photo():
user_id=frappe.form_dict.get('user_id')
user_type=frappe.form_dict.get('user_type')
photo=frappe.form_dict.get('photo')

def load_punch_logs():
pass
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2024, Navari Limited and contributors
// For license information, please see license.txt

frappe.ui.form.on("Cams Biometric Settings", {
refresh(frm) {

frm.add_custom_button(__('Load Punchlog'), function() {
let d = new frappe.ui.Dialog({
title: 'Load Punchlog',
fields: [
{
label: 'Biometric ID',
fieldname: 'user_id',
fieldtype: 'Data',
reqd: 1
},
{
label: 'Start Date',
fieldname: 'start_date',
fieldtype: 'Date',
reqd: 1
},
{
label: 'End Date',
fieldname: 'end_date',
fieldtype: 'Date',
reqd: 1
}
],
primary_action_label: 'Load Punchlogs',
primary_action: function(data) {
d.hide();
loader.style.display = "block";
frappe.call({
method: 'navari_frappehr_biostar.controllers.cams_call.load_punch_logs',
args: {
user_id: data.user_id,
start_date: data.start_date,
end_date: data.end_date
},
callback: function(r) {
loader.style.display = "none";
if (r.message) {
frappe.msgprint(r.message);
}
}
});
}
});
d.show();
}).addClass("btn-primary");
},


});

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-07-24 13:06:10.572066",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"auth_token",
"bulk_punchlog_section",
"start_date",
"column_break_jipe",
"end_date"
],
"fields": [
{
"fieldname": "auth_token",
"fieldtype": "Data",
"label": "Auth Token"
},
{
"fieldname": "bulk_punchlog_section",
"fieldtype": "Section Break",
"label": "Bulk Punchlog"
},
{
"fieldname": "start_date",
"fieldtype": "Date",
"label": "Start Date"
},
{
"fieldname": "column_break_jipe",
"fieldtype": "Column Break"
},
{
"fieldname": "end_date",
"fieldtype": "Date",
"label": "End Date"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-07-24 13:08:05.909310",
"modified_by": "Administrator",
"module": "Cams Biometric",
"name": "Cams Biometric Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Navari Limited and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class CamsBiometricSettings(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Navari Limited and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestCamsBiometricSettings(FrappeTestCase):
pass
114 changes: 114 additions & 0 deletions navari_cams_biometric/fixtures/custom_field.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": "Fingerprint",
"depends_on": null,
"description": null,
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Employee Checkin",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "custom_input_type",
"fieldtype": "Select",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "shift",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Input Type",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2024-07-23 17:33:52.761315",
"module": null,
"name": "Employee Checkin-custom_input_type",
"no_copy": 0,
"non_negative": 0,
"options": "\nFingerprint\nFace\nPassword\nCard\nPalm\nFingerVein\nIris\nRetina\nPalm",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 1,
"unique": 0,
"width": null
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"doctype": "Custom Field",
"dt": "Employee",
"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "custom_biometric_registered",
"fieldtype": "Check",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "attendance_device_id",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Biometric Registered",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2024-07-24 12:00:04.414127",
"module": null,
"name": "Employee-custom_biometric_registered",
"no_copy": 0,
"non_negative": 0,
"options": null,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
}
]
4 changes: 2 additions & 2 deletions navari_cams_biometric/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"in",
(
"Employee Checkin-custom_input_type",

"Employee-custom_biometric_registered"
),
]
],
Expand Down Expand Up @@ -45,7 +45,7 @@
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
doctype_js = {"Employee" : "public/js/employee.js"}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
Expand Down
Loading

0 comments on commit 759622f

Please sign in to comment.