From b57e7e4128f00bedc243923771f43906c1ccfb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Enrique=20G=C3=B3mez=20G=C3=B3mez?= Date: Tue, 14 Mar 2023 17:08:03 +0000 Subject: [PATCH] main[ADD]attendance_flask:Codigos QR para asistencias --- get_query.py | 7 +++---- main.py | 8 +++++++- templates/thanks.html | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/get_query.py b/get_query.py index 6c76385..c2a48ec 100644 --- a/get_query.py +++ b/get_query.py @@ -11,7 +11,6 @@ def get_db_connection(): conn = get_db_connection() data = conn.execute('SELECT user, datein, dateout, ip_branch, id, inspein, inspeout FROM hits WHERE datein != ? AND inspein = ? OR dateout != ? AND inspeout = ? ', ('', '', '', '')).fetchall() - for d in data: params ={ 'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy', @@ -20,9 +19,9 @@ for d in data: 'check_out': d[2], 'ip_branch': d[3], } - response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() - print(response) - if response["message"]: + # response = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() + response = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json() + if response["message"] == "Attendance successfully": time = datetime.now(pytz.timezone('America/Bogota')).strftime("%Y-%m-%d %H:%M:%S") if d[1] != '' and d[5] == '': conn.execute("UPDATE hits SET inspein = ? WHERE id = ?", (time, d[4])) diff --git a/main.py b/main.py index e8f582d..965c126 100755 --- a/main.py +++ b/main.py @@ -67,7 +67,8 @@ def generate_next_url(type, ip_branch): @app.route('/') def show_qr_and_list(): # TODO: reject direct connections to server; allow access only via proxy - get_list = requests.get('https://erp.agofer.com/hr_attendance_extended/public/attendance/').json() + # get_list = requests.get('https://erp.agofer.com/hr_attendance_extended/public/attendance/').json() + get_list = requests.get('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/').json() list_ips = get_list["list_ips"] ip_branch = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) if ip_branch in list_ips: @@ -91,6 +92,9 @@ def catch_uuids(id, hashed, type, ip_branch): 'SELECT * FROM hits WHERE uuid1 = ?', (str(id),)).fetchone() existing2 = conn.execute( 'SELECT * FROM hits WHERE uuid2 = ?', (str(id),)).fetchone() + params ={'access': 'YXR0ZW5kYW5jZXMvYWdvZmVy','employee_id': user,'check_in': '','check_out': '','ip_branch': '',} + # employee = requests.post('https://erp.agofer.com/hr_attendance_extended/public/attendance/', json = params).json() + employee = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json() if not user: error = 'NO_USERNAME' elif existing1: @@ -99,6 +103,8 @@ def catch_uuids(id, hashed, type, ip_branch): error = 'ALREADY_USED' elif not check_hash(str(id), str(hashed)): error = 'DIFFERENT_NODE' + elif employee["message"] == "Not registered": + error = 'NO_EMPLOYEE' else: if type_check == 'mistake': error = 'DIFFERENT_TYPE' diff --git a/templates/thanks.html b/templates/thanks.html index 70a321d..f022f4a 100644 --- a/templates/thanks.html +++ b/templates/thanks.html @@ -57,6 +57,9 @@

Error

No se encontró el tipo de entrada.

inténteta de nuevo AQUI.

+ {% elif error == 'NO_EMPLOYEE' %} +

Error

+

No se encontró el empleado.
Comuniquese con area de Software y Automatización para resolver el error.

{% elif error == 'MISSING_EXIT' %}

!Olvidaste la Salida!

Para registrar la entrada es necesario terminar la jornada de trabajo anterior.