main[ADD]attendance_flask:Codigos QR para asistencias

This commit is contained in:
Jorge Enrique Gómez Gómez 2023-03-14 17:08:03 +00:00
parent 9852f162d4
commit b57e7e4128
3 changed files with 13 additions and 5 deletions

View File

@ -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]))

View File

@ -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'

View File

@ -57,6 +57,9 @@
<h1>Error</h1>
<p>No se encontró el tipo de entrada.<br /><br /><a href='https://attendance.agofer.net'>inténteta de nuevo
AQUI</a>.</p>
{% elif error == 'NO_EMPLOYEE' %}
<h1>Error</h1>
<p>No se encontró el empleado.<br /> Comuniquese con area de Software y Automatización para resolver el error.<br /></p>
{% elif error == 'MISSING_EXIT' %}
<h1>!Olvidaste la Salida!</h1>
<p>Para registrar la entrada es necesario terminar la jornada de trabajo anterior.<br /><br /><a