-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwijzLoontabel.py
427 lines (345 loc) · 16.9 KB
/
wijzLoontabel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
from login import hoofdMenu
import datetime
from PyQt5.QtWidgets import QLabel, QLineEdit, QGridLayout, QPushButton, QComboBox,\
QDialog, QMessageBox, QWidget, QTableView
from PyQt5.QtGui import QFont, QIcon, QRegExpValidator, QPixmap
from PyQt5.QtCore import Qt, QRegExp, QAbstractTableModel
from sqlalchemy import (Table, Column, Integer, String, Float, Boolean,\
MetaData, create_engine)
from sqlalchemy.sql import select, update
def refresh(keuze, m_email, self):
self.close()
loonTabellen(keuze, m_email)
def windowSluit(self, m_email):
self.close()
hoofdMenu(m_email)
def ongInvoer():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Warning)
msg.setText('Foutieve invoer\nzoekterm opnieuw invoeren s.v.p.!')
msg.setWindowTitle('Loontabel wijzigen')
msg.exec_()
def geenRecord():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Warning)
msg.setText('Geen record gevonden\nmaak een andere selektie s.v.p.!')
msg.setWindowTitle('Loontabel wijzigen')
msg.exec_()
def invoerOK():
msg = QMessageBox()
msg.setStyleSheet("color: black; background-color: gainsboro")
msg.setIcon(QMessageBox.Information)
msg.setText('Invoer gelukt!')
msg.setWindowTitle('Loontabel wijzigen')
msg.exec_()
def zoeken(m_email):
class Widget(QDialog):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.setWindowTitle("Wijzigen Loontabel")
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setFont(QFont('Arial', 10))
self.Keuze = QLabel()
k0Edit = QComboBox()
k0Edit.setFixedWidth(210)
k0Edit.setStyleSheet("color: black; background-color: gainsboro")
k0Edit.setFont(QFont("Arial",10))
k0Edit.addItem(' Sorteersleutel zoeken')
k0Edit.addItem('1. Looontabel intern')
k0Edit.addItem('2. Loontabel extern')
k0Edit.addItem('3. Loontabel indirekt')
k0Edit.activated[str].connect(self.k0Changed)
grid = QGridLayout()
grid.setSpacing(20)
lbl = QLabel()
pixmap = QPixmap('./images/logos/verbinding.jpg')
lbl.setPixmap(pixmap)
grid.addWidget(lbl , 0, 0, 1, 2)
grid.addWidget(k0Edit, 1, 1)
self.setLayout(grid)
self.setGeometry(500, 300, 150, 150)
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 4, 0, 1 , 2, Qt.AlignCenter)
logo = QLabel()
pixmap = QPixmap('./images/logos/logo.jpg')
logo.setPixmap(pixmap)
grid.addWidget(logo , 0, 1, 1 ,1, Qt.AlignRight)
applyBtn = QPushButton('Zoeken')
applyBtn.clicked.connect(self.accept)
grid.addWidget(applyBtn, 3, 1, 1, 1, Qt.AlignRight)
applyBtn.setFont(QFont("Arial",10))
applyBtn.setFixedWidth(100)
applyBtn.setStyleSheet("color: black; background-color: gainsboro")
cancelBtn = QPushButton('Sluiten')
cancelBtn.clicked.connect(lambda: windowSluit(self,m_email))
grid.addWidget(cancelBtn, 3, 1)
cancelBtn.setFont(QFont("Arial",10))
cancelBtn.setFixedWidth(100)
cancelBtn.setStyleSheet("color: black; background-color: gainsboro")
def k0Changed(self, text):
self.Keuze.setText(text)
def returnk0(self):
return self.Keuze.text()
@staticmethod
def getData(parent=None):
dialog = Widget(parent)
dialog.exec_()
return [dialog.returnk0()]
window = Widget()
data = window.getData()
if not data[0] or data[0][0] == ' ':
keuze = 0
elif data[0]:
keuze = int(data[0][0])
else:
keuze = 0
loonTabellen(keuze, m_email)
def loonTabellen(keuze, m_email):
class MyWindow(QDialog):
def __init__(self, data_list, header, *args):
QWidget.__init__(self, *args,)
self.setWindowTitle('Loonbetalingen opvragen')
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setWindowFlags(self.windowFlags()| Qt.WindowSystemMenuHint |
Qt.WindowMinMaxButtonsHint)
self.setFont(QFont('Arial', 10))
grid = QGridLayout()
grid.setSpacing(20)
table_model = MyTableModel(self, data_list, header)
table_view = QTableView()
table_view.setModel(table_model)
table_view.resizeColumnsToContents()
table_view.setSelectionBehavior(QTableView.SelectRows)
font = QFont("Arial", 10)
table_view.setFont(font)
table_view.resizeColumnsToContents()
#table_view.clicked.connect(selectRow)
table_view.clicked.connect(wijzLoonschaal)
grid.addWidget(table_view, 0, 0, 1, 7)
lbl = QLabel()
pixmap = QPixmap('./images/logos/verbinding.jpg')
lbl.setPixmap(pixmap)
grid.addWidget(lbl, 1, 0, 1, 2)
logo = QLabel()
pixmap = QPixmap('./images/logos/logo.jpg')
logo.setPixmap(pixmap)
grid.addWidget(logo , 1, 6, 1, 1, Qt.AlignRight)
freshBtn = QPushButton('Verversen')
freshBtn.clicked.connect(lambda: refresh(keuze, m_email, self))
freshBtn.setFont(QFont("Arial",10))
freshBtn.setFixedWidth(100)
freshBtn.setStyleSheet("color: black; background-color: gainsboro")
grid.addWidget(freshBtn, 1, 5, 1, 1, Qt.AlignRight |Qt.AlignTop)
sluitBtn = QPushButton('Sluiten')
sluitBtn.clicked.connect(self.close)
sluitBtn.setFont(QFont("Arial",10))
sluitBtn.setFixedWidth(100)
sluitBtn.setStyleSheet("color: black; background-color: gainsboro")
grid.addWidget(sluitBtn, 1, 4, 1, 1, Qt.AlignTop)
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 1, 0, 1, 7, Qt.AlignCenter | Qt.AlignBottom)
self.setLayout(grid)
self.setGeometry(500, 100, 850, 800)
self.setLayout(grid)
class MyTableModel(QAbstractTableModel):
def __init__(self, parent, mylist, header, *args):
QAbstractTableModel.__init__(self, parent, *args)
self.mylist = mylist
self.header = header
def rowCount(self, parent):
return len(self.mylist)
def columnCount(self, parent):
return len(self.mylist[0])
def data(self, index, role):
if not index.isValid():
return None
elif role != Qt.DisplayRole:
return None
return str(self.mylist[index.row()][index.column()])
def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return self.header[col]
return None
header = ['LoonID', 'Tabeluurloon', 'Werkuurloon', 'Reisuurloon', 'Direct',\
'Maandloon','Functieomschrijving', 'Wijzigingsdatum']
metadata = MetaData()
lonen = Table('lonen', metadata,
Column('loonID', Integer(), primary_key=True),
Column('tabelloon', Float),
Column('werkuur',Float),
Column('reisuur', Float),
Column('direct', Boolean),
Column('maandloon', Float),
Column('functieomschr', String),
Column('boekdatum', String))
engine = create_engine('postgresql+psycopg2://postgres@localhost/bisystem')
con = engine.connect()
if keuze == 1:
sellon = select([lonen]).where(lonen.c.loonID > 52).order_by(lonen.c.loonID)
elif keuze == 2:
sellon = select([lonen]).where(lonen.c.loonID < 37).order_by(lonen.c.loonID)
elif keuze == 3:
sellon = select([lonen]).where(lonen.c.loonID.between(37,52)).order_by(lonen.c.loonID)
else:
ongInvoer()
zoeken(m_email)
if con.execute(sellon).fetchone():
rplon = con.execute(sellon)
else:
geenRecord()
zoeken(m_email)
data_list=[]
for row in rplon:
data_list += [(row)]
def wijzLoonschaal(idx):
mloonnr = idx.data()
if idx.column() == 0:
engine = create_engine('postgresql+psycopg2://postgres@localhost/bisystem')
con = engine.connect()
sellon = select([lonen]).where(lonen.c.loonID == mloonnr)
rplon = con.execute(sellon).first()
class Widget(QDialog):
def __init__(self):
QDialog.__init__(self)
grid = QGridLayout()
grid.setSpacing(12)
self.setWindowTitle("Opvragen / wijzigen loontabellen")
self.setWindowIcon(QIcon('./images/logos/logo.jpg'))
self.setFont(QFont('Arial', 10))
self.lbl = QLabel()
self.pixmap = QPixmap('./images/logos/verbinding.jpg')
self.lbl.setPixmap(self.pixmap)
grid.addWidget(self.lbl , 0, 0)
self.logo = QLabel()
self.pixmap = QPixmap('./images/logos/logo.jpg')
self.logo.setPixmap(self.pixmap)
grid.addWidget(self.logo , 0, 1, 1, 2, Qt.AlignRight)
grid.addWidget(QLabel('Opvragen / wijzigen loontabellen'), 0, 1)
self.Loontabelnummer = QLabel()
q1Edit = QLineEdit(str(rplon[0]))
q1Edit.setFixedWidth(100)
q1Edit.setDisabled(True)
q1Edit.setFont(QFont("Arial",10))
self.Omschrijving = QLabel()
q2Edit = QLineEdit(rplon[6])
q2Edit.setFixedWidth(320)
q2Edit.setFont(QFont("Arial",10))
q2Edit.textChanged.connect(self.q2Changed)
q2Edit.setDisabled(True)
self.Maandloon = QLabel()
q3Edit = QLineEdit(str(rplon[5]))
q3Edit.setFixedWidth(100)
q3Edit.setFont(QFont("Arial",10))
q3Edit.textChanged.connect(self.q3Changed)
reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
input_validator = QRegExpValidator(reg_ex, q3Edit)
q3Edit.setValidator(input_validator)
self.Tabelloon = QLabel()
q4Edit = QLineEdit(str(rplon[1]))
q4Edit.setFixedWidth(100)
q4Edit.setFont(QFont("Arial",10))
q4Edit.textChanged.connect(self.q4Changed)
reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
input_validator = QRegExpValidator(reg_ex, q4Edit)
q4Edit.setValidator(input_validator)
self.Werkuurloon = QLabel()
q5Edit = QLineEdit(str(rplon[2]))
q5Edit.setFixedWidth(100)
q5Edit.setFont(QFont("Arial",10))
q5Edit.setDisabled(True)
self.Reisuurloon = QLabel()
q6Edit = QLineEdit(str(rplon[3]))
q6Edit.setFixedWidth(100)
q6Edit.setFont(QFont("Arial",10))
q6Edit.textChanged.connect(self.q6Changed)
reg_ex = QRegExp('^[0-9]{1,10}[.0-9]{0,3}$')
input_validator = QRegExpValidator(reg_ex, q6Edit)
q6Edit.setValidator(input_validator)
lbl1 = QLabel('Loontabelnummer')
grid.addWidget(lbl1, 1, 0)
grid.addWidget(q1Edit, 1, 1)
lbl2 = QLabel('Functieomschrijving')
grid.addWidget(lbl2, 2, 0)
grid.addWidget(q2Edit, 2, 1, 1, 2)
lbl3 = QLabel('Maandloon')
grid.addWidget(lbl3, 3, 0)
grid.addWidget(q3Edit, 3, 1)
lbl5 = QLabel('Tabeluurloon')
grid.addWidget(lbl5, 4, 0)
grid.addWidget(q4Edit, 4, 1)
lbl6 = QLabel('Werkuurloon begroot')
grid.addWidget(lbl6, 5, 0)
grid.addWidget(q5Edit, 5, 1)
lbl7 = QLabel('Reisuurloon begroot')
grid.addWidget(lbl7, 6, 0)
grid.addWidget(q6Edit, 6, 1)
lbl8 = QLabel('Wijzigingsdatum')
lbl9 = QLabel(str(rplon[7]))
grid.addWidget(lbl8, 7 ,0)
grid.addWidget(lbl9, 7, 1)
wijzig = QPushButton('Wijzig')
wijzig.clicked.connect(self.accept)
grid.addWidget(wijzig, 8, 1, 1 , 2, Qt.AlignRight)
wijzig.setFont(QFont("Arial",10))
wijzig.setFixedWidth(100)
sluit = QPushButton('Sluiten')
sluit.clicked.connect(self.close)
grid.addWidget(sluit, 8, 1, 1, 2, Qt.AlignCenter)
sluit.setFont(QFont("Arial",10))
sluit.setFixedWidth(100)
grid.addWidget(QLabel('\u00A9 2017 all rights reserved [email protected]'), 9, 0, 1, 3, Qt.AlignCenter)
self.setLayout(grid)
self.setGeometry(600, 250, 150, 150)
def q2Changed(self,text):
self.Omschrijving.setText(text)
def q3Changed(self,text):
self.Maandloon.setText(text)
def q4Changed(self,text):
self.Tabelloon.setText(text)
def q6Changed(self,text):
self.Reisuurloon.setText(text)
def returnq2(self):
return self.Omschrijving.text()
def returnq3(self):
return self.Maandloon.text()
def returnq4(self):
return self.Tabelloon.text()
def returnq6(self):
return self.Reisuurloon.text()
@staticmethod
def getData(parent=None):
dialog = Widget()
dialog.exec_()
return [dialog.returnq2(), dialog.returnq3(), dialog.returnq4(),\
dialog.returnq6()]
window = Widget()
data = window.getData()
if data[0] == '' and data[1]== '' and data[2] == '' and data[3] =='':
return()
if data[0]:
momschr = data[0]
else:
momschr = rplon[6]
if data[1]:
mmndloon = float(data[1])
else:
mmndloon = rplon[5]
if data[2]:
mtabelloon = float(data[2])
else:
mtabelloon = rplon[1]
if data[3]:
mreisuurloon = float(data[3])
else:
mreisuurloon = rplon[3]
mboekd = str(datetime.datetime.now())[0:10]
updlon = update(lonen).where(lonen.c.loonID==mloonnr)\
.values(functieomschr=momschr, maandloon = mmndloon, tabelloon = mtabelloon,\
reisuur = mreisuurloon, boekdatum = mboekd)
con.execute(updlon)
invoerOK()
win = MyWindow(data_list, header)
win.exec_()
zoeken(m_email)