29 lines
874 B
Python
29 lines
874 B
Python
import sqlite3
|
|
from datetime import datetime
|
|
import pytz
|
|
import requests
|
|
|
|
|
|
def get_db_connection():
|
|
conn = sqlite3.connect('database.db')
|
|
conn.row_factory = sqlite3.Row
|
|
return conn
|
|
|
|
conn = get_db_connection()
|
|
data = conn.execute('SELECT user, datein, dateout, ip_branch, id FROM hits WHERE dateout != ? AND dateinspe = ? ', ('', '')).fetchall()
|
|
|
|
for d in data:
|
|
params ={
|
|
'employee_id': d[0],
|
|
'check_in': d[1],
|
|
'check_out': d[2],
|
|
'ip_branch': d[3],
|
|
}
|
|
response = requests.post('http://137.184.126.24:8080/hr_attendance_extended/public/attendance/', json = params).json()
|
|
if response["message"]:
|
|
time = datetime.now(pytz.timezone('America/Bogota')).strftime("%Y-%m-%d %H:%M:%S")
|
|
conn.execute("UPDATE hits SET dateinspe = ? WHERE id = ?", (time, d[4]))
|
|
conn.commit()
|
|
else:
|
|
continue
|