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