Employee and applicant frontend and backend
This commit is contained in:
@@ -1,6 +1,56 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
from .DbManager import DbManager
|
||||
import json
|
||||
import mariadb
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
|
||||
|
||||
|
||||
class EmployeeDAO:
|
||||
class EmployeeDAO(QObject):
|
||||
newEmployeeAdded = Signal()
|
||||
|
||||
__cur = None
|
||||
__all_cols = None
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
super().__init__()
|
||||
self.__con = DbManager().getConnection()
|
||||
if self.__con:
|
||||
self.__cur = self.__con.cursor()
|
||||
|
||||
def getEmployees(self, enc_key, criterion = "Alle", appli_emp = 0, processed = False):
|
||||
'''
|
||||
appli_emp:
|
||||
0 = applicants and employees
|
||||
1 = applicants only
|
||||
2 = employees only
|
||||
'''
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployeesView", (appli_emp, processed, criterion, enc_key, ))
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
else:
|
||||
return None, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def getEmployee(self, employee_id, enc_key = None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
|
||||
#self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() #, self.__all_cols
|
||||
else:
|
||||
return None #, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def addEmployee(self, data, enc_key, employee = False):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), employee, enc_key,))
|
||||
self.__con.commit()
|
||||
self.newEmployeeAdded.emit()
|
||||
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
Reference in New Issue
Block a user