Employee/Applicant GUI and DB
This commit is contained in:
@@ -8,6 +8,9 @@ ColumnLayout
|
||||
{
|
||||
id: colPar
|
||||
anchors.fill: parent
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
implicitWidth: parent.width
|
||||
Label
|
||||
{
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
@@ -29,7 +32,7 @@ ColumnLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
id: radio
|
||||
Layout.columnSpan: 2
|
||||
//Layout.columnSpan: 2
|
||||
RadioButton
|
||||
{
|
||||
checked: true
|
||||
@@ -40,15 +43,30 @@ ColumnLayout
|
||||
text: qsTr("Mitarbeiter")
|
||||
}
|
||||
}
|
||||
|
||||
// ScrollView
|
||||
// {
|
||||
// Layout.fillHeight: true
|
||||
// Layout.fillWidth: true
|
||||
// implicitWidth: parent.width
|
||||
|
||||
// ColumnLayout
|
||||
// {
|
||||
// anchors.fill: parent
|
||||
// //implicitWidth: parent.width
|
||||
// //width: parent.width
|
||||
// //height: parent.height
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
//implicitWidth: parent.width
|
||||
spacing: 50
|
||||
|
||||
Frame
|
||||
{
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.fillWidth: true
|
||||
//implicitWidth: parent.width
|
||||
ApplicantPersonalData
|
||||
{
|
||||
id: personalData
|
||||
@@ -64,7 +82,7 @@ ColumnLayout
|
||||
ColumnLayout
|
||||
{
|
||||
Layout.alignment: Qt.AlignTop
|
||||
width: parent.width
|
||||
implicitWidth: parent.width
|
||||
|
||||
ApplicantBankData
|
||||
{
|
||||
@@ -84,9 +102,14 @@ ColumnLayout
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignRight
|
||||
Button
|
||||
{
|
||||
@@ -105,7 +128,7 @@ ColumnLayout
|
||||
{
|
||||
// Ein Bewerber
|
||||
new_applicant = JsLib.parseForm(personalData)
|
||||
employee_model.addEmployee(new_applicant, false)
|
||||
employee_model.addEmployee(new_applicant, true)
|
||||
// appLoader.source = "EmployeeTable.qml"
|
||||
// console.log(JSON.stringify (new_applicant))
|
||||
}
|
||||
@@ -114,7 +137,7 @@ ColumnLayout
|
||||
// Ein Mitarbeiter
|
||||
// console.log(personalData, bankAccount, nationalInsurance, applicantVarious)
|
||||
new_applicant = JsLib.parseForm(personalData, bankAccount, nationalInsurance, applicantVarious)
|
||||
employee_model.addEmployee(new_applicant, true)
|
||||
employee_model.addEmployee(new_applicant, false)
|
||||
// var new_contact = JsLib.addApplicant(addContactLayout)
|
||||
// contact_model.addContact(new_contact)
|
||||
// console.log(JSON.stringify (new_applicant))
|
||||
@@ -122,10 +145,9 @@ ColumnLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
// }
|
||||
// } // ScrollView
|
||||
|
||||
function checkFields()
|
||||
{
|
||||
if(radio.children[1].checked)
|
||||
|
||||
@@ -114,6 +114,19 @@ GridLayout
|
||||
property string name: "idexpiry"
|
||||
id: idexpiry
|
||||
Layout.fillWidth: true
|
||||
validator: RegularExpressionValidator
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = idexpiry.length
|
||||
var bd = idexpiry.text
|
||||
if (len === 2 || len === 5) idexpiry.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
@@ -137,6 +150,19 @@ GridLayout
|
||||
property string name: "idissued"
|
||||
id: idissued
|
||||
Layout.fillWidth: true
|
||||
validator: RegularExpressionValidator
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = idissued.length
|
||||
var bd = idissued.text
|
||||
if (len === 2 || len === 5) idissued.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckBox
|
||||
{
|
||||
@@ -191,6 +217,19 @@ GridLayout
|
||||
id: residenceissued
|
||||
visible: residencetype.checked
|
||||
Layout.fillWidth: true
|
||||
validator: RegularExpressionValidator
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = residenceissued.length
|
||||
var bd = residenceissued.text
|
||||
if (len === 2 || len === 5) residenceissued.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
@@ -204,6 +243,19 @@ GridLayout
|
||||
id: residenceexpiry
|
||||
visible: residencetype.checked
|
||||
Layout.fillWidth: true
|
||||
validator: RegularExpressionValidator
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = residenceexpiry.length
|
||||
var bd = residenceexpiry.text
|
||||
if (len === 2 || len === 5) residenceexpiry.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ GridLayout
|
||||
{
|
||||
id: personalData
|
||||
columns: 4
|
||||
|
||||
Label
|
||||
{
|
||||
text: qsTr("Anrede")
|
||||
@@ -336,6 +335,15 @@ GridLayout
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = contractstart.length
|
||||
var bd = contractstart.text
|
||||
if (len === 2 || len === 5) contractstart.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
@@ -356,6 +364,15 @@ GridLayout
|
||||
{
|
||||
regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/
|
||||
}
|
||||
Keys.onPressed: (event)=>
|
||||
{
|
||||
if (event.key !== Qt.Key_Backspace)
|
||||
{
|
||||
var len = contractend.length
|
||||
var bd = contractend.text
|
||||
if (len === 2 || len === 5) contractend.text = bd + "."
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
|
||||
@@ -101,16 +101,17 @@ Item
|
||||
id: customerTable
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
ScrollBar.vertical: ScrollBar
|
||||
{
|
||||
policy: customerTable.contentHeight > customerTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
||||
}
|
||||
columnSpacing: 1
|
||||
rowSpacing: 2
|
||||
model: business_model
|
||||
alternatingRows: true
|
||||
resizableColumns: true
|
||||
selectionBehavior: TableView.SelectRows
|
||||
ScrollBar.vertical: ScrollBar
|
||||
{
|
||||
policy: customerTable.contentHeight > customerTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
||||
}
|
||||
|
||||
selectionModel: ItemSelectionModel
|
||||
{
|
||||
id: selModel
|
||||
|
||||
@@ -22,6 +22,6 @@ Item
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
business_model.onRowClicked(selectedEmployee)
|
||||
employee_model.onRowClicked(selectedEmployee)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,16 @@ Item
|
||||
onClicked: appLoader.source = "AddApplicant.qml"
|
||||
}
|
||||
|
||||
ButtonGroup
|
||||
{
|
||||
id: criterion
|
||||
// buttons: criterion.children
|
||||
onClicked:
|
||||
{
|
||||
viewEmployees(criterion.checkedButton.text)
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors
|
||||
@@ -32,50 +42,74 @@ Item
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
//id: criterion
|
||||
|
||||
RadioButton
|
||||
{
|
||||
|
||||
//id: showAll
|
||||
checked: true
|
||||
text: qsTr("Alle")
|
||||
ButtonGroup.group: criterion
|
||||
//onClicked: viewEmployees(showAll)
|
||||
}
|
||||
RadioButton
|
||||
{
|
||||
|
||||
//id: showApplicant
|
||||
text: qsTr("Bewerber")
|
||||
ButtonGroup.group: criterion
|
||||
//onClicked: viewEmployees(showApplicant)
|
||||
}
|
||||
RadioButton
|
||||
{
|
||||
|
||||
//id: showEmployee
|
||||
text: qsTr("Mitarbeiter")
|
||||
ButtonGroup.group: criterion
|
||||
//onClicked: viewEmployees(showEmployee)
|
||||
}
|
||||
RadioButton
|
||||
CheckBox
|
||||
{
|
||||
|
||||
id: showProcessed
|
||||
text: qsTr("Erledigt")
|
||||
onClicked: viewEmployees(criterion.checkedButton.text)
|
||||
}
|
||||
RadioButton
|
||||
CheckBox
|
||||
{
|
||||
|
||||
id: showFired
|
||||
text: qsTr("Ausgeschieden")
|
||||
onClicked: viewEmployees(criterion.checkedButton.text)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HorizontalHeaderView
|
||||
{
|
||||
id: horizontalHeader
|
||||
id: employeeTableHeader
|
||||
Layout.fillWidth: true
|
||||
syncView: appliEmpTable
|
||||
implicitHeight: 40
|
||||
visible: false
|
||||
movableColumns: true //@disable-check M16
|
||||
|
||||
delegate: Rectangle
|
||||
{
|
||||
color: addEmployeeBtn.palette.alternateBase
|
||||
border.color: palette.base
|
||||
implicitHeight: 40
|
||||
Layout.fillWidth: true
|
||||
implicitWidth: 1
|
||||
Text
|
||||
{
|
||||
text: model.display
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: palette.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableView
|
||||
@@ -85,6 +119,8 @@ Item
|
||||
Layout.fillWidth: true
|
||||
columnSpacing: 1
|
||||
rowSpacing: 2
|
||||
alternatingRows: true
|
||||
resizableColumns: true
|
||||
model: employee_model
|
||||
selectionBehavior: TableView.SelectRows
|
||||
|
||||
@@ -104,13 +140,13 @@ Item
|
||||
{
|
||||
required property bool selected
|
||||
required property bool current
|
||||
//implicitWidth: 200
|
||||
implicitWidth: appliEmpTable.width / appliEmpTable.columns
|
||||
implicitHeight: 25
|
||||
color: selected
|
||||
? palette.highlight //palette.highlight
|
||||
: (objectTable.alternatingRows && row % 2 !== 0
|
||||
? palette.base // palette.base
|
||||
: palette.alternateBase) //palette.alternateBase)
|
||||
? addEmployeeBtn.palette.highlight //palette.highlight
|
||||
: (appliEmpTable.alternatingRows && row % 2 !== 0
|
||||
? addEmployeeBtn.palette.base // palette.base
|
||||
: addEmployeeBtn.palette.alternateBase) //palette.alternateBase)
|
||||
|
||||
Text
|
||||
{
|
||||
@@ -152,5 +188,9 @@ Item
|
||||
}
|
||||
}
|
||||
|
||||
function viewEmployees(criterion)
|
||||
{
|
||||
employee_model.viewCriterion(criterion, showProcessed.checked, showFired.checked)
|
||||
}
|
||||
Component.onCompleted: employeesStack.pop()
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ ApplicationWindow
|
||||
Loader
|
||||
{
|
||||
id: appLoader
|
||||
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
|
||||
@@ -132,6 +132,7 @@ class BusinessModel(QAbstractTableModel):
|
||||
|
||||
@Slot(int)
|
||||
def onRowClicked(self, row):
|
||||
#print(self.__data)
|
||||
#print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
if not self.__business_dict['business'] or self.__data[row][0] != self.__business_dict['business']['id']:
|
||||
self.__business = self.__business_dao.getOneBusiness(self.__data[row][0], self.__key)
|
||||
|
||||
@@ -17,16 +17,10 @@ class EmployeeDAO(QObject):
|
||||
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
|
||||
'''
|
||||
def getEmployees(self, enc_key, criterion = "Alle", processed = False, fired = False):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployeesView", (appli_emp, processed, criterion, enc_key, ))
|
||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, enc_key, ))
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
else:
|
||||
@@ -45,10 +39,10 @@ class EmployeeDAO(QObject):
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def addEmployee(self, data, enc_key, employee = False):
|
||||
def addEmployee(self, data, enc_key, applicant = True):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), employee, enc_key,))
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self.__con.commit()
|
||||
self.newEmployeeAdded.emit()
|
||||
|
||||
|
||||
@@ -21,21 +21,22 @@ class EmployeeModel(QAbstractTableModel):
|
||||
self.__getData()
|
||||
|
||||
@Slot(dict, bool)
|
||||
def addEmployee(self, new_employee, employee = False):
|
||||
print(new_employee)
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, employee)
|
||||
def addEmployee(self, new_employee, applicant = True):
|
||||
new_employee['worklicense'] = int(new_employee['worklicense'])
|
||||
new_employee['residencetype'] = int(new_employee['residencetype'])
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, applicant)
|
||||
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion):
|
||||
self.__getData(criterion)
|
||||
def viewCriterion(self, criterion, processed = False, fired = False):
|
||||
self.__getData(criterion, processed, fired)
|
||||
|
||||
@Slot()
|
||||
def __refreshView(self):
|
||||
self.__getData()
|
||||
|
||||
def __getData(self, criterion = "Alle", processed = False):
|
||||
def __getData(self, criterion = "Alle", processed = False, fired = False):
|
||||
self.beginResetModel()
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, 0, processed)
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired)
|
||||
self.__data = rows
|
||||
self.endResetModel()
|
||||
|
||||
@@ -45,10 +46,17 @@ class EmployeeModel(QAbstractTableModel):
|
||||
def columnCount(self, parent= QModelIndex()):
|
||||
return len(self.__visible_columns) - 2
|
||||
|
||||
@Slot(str, bool, bool)
|
||||
def viewCriterion(self, criterion, processed, fired):
|
||||
self.__getData(criterion, processed, fired)
|
||||
|
||||
def data(self, index, role= Qt.DisplayRole):
|
||||
if role == Qt.DisplayRole:
|
||||
row = self.__data[index.row()]
|
||||
return row[index.column() + 2]
|
||||
tr = row[index.column() + 2] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
|
||||
#print(f"Data: {tr}")
|
||||
# return row[index.column() + 2]
|
||||
return tr
|
||||
return None
|
||||
|
||||
def headerData(self, section, orientation, role = Qt.DisplayRole):
|
||||
@@ -56,3 +64,14 @@ class EmployeeModel(QAbstractTableModel):
|
||||
self.__col_name = self.__visible_columns[section + 2]
|
||||
return self.__col_name
|
||||
return super().headerData(section, orientation, role)
|
||||
|
||||
@Slot(int)
|
||||
def onRowClicked(self, row):
|
||||
#print(self.__data)
|
||||
print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
#if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
|
||||
#self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
|
||||
#print(self.__business)
|
||||
#self.__getEmployeeInfo()
|
||||
# self.__getContactInfo()
|
||||
# print(self.__business_dict)
|
||||
|
||||
Reference in New Issue
Block a user