-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_garde.py
149 lines (123 loc) · 5.83 KB
/
export_garde.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
from calendar import monthrange
from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFileDialog, QMessageBox
import app
from threads import ThreadGuard, ThreadGuardUrgenceInf, ThreadGuardUrgenceSurv
from tools import create_garde_page, create_garde_inf_page
class ExportGardeUi(QtWidgets.QMainWindow):
def __init__(self, service, month, year):
super(ExportGardeUi, self).__init__()
uic.loadUi("./user_interfaces/export.ui", self)
self.month = month
self.year = year
self.service = service
self.ttl = self.findChild(QtWidgets.QLabel, "label")
self.progress = self.findChild(QtWidgets.QProgressBar, "progressBar")
self.progress.setValue(0)
self.status = self.findChild(QtWidgets.QLabel, "label_2")
self.export = self.findChild(QtWidgets.QPushButton, "pushButton")
self.export.setEnabled(False)
self.export.setIcon(QIcon("./asstes/images/download2.png"))
self.preview = self.findChild(QtWidgets.QPushButton, "pushButton_2")
self.preview.setEnabled(False)
self.preview.setIcon(QIcon("./asstes/images/eye.png"))
self.export.clicked.connect(self.export_pdf)
self.preview.clicked.connect(self.preview_pdf)
self.status.setText("Preparation des données")
self.num_days = monthrange(self.year, self.month)[1]
if self.month == 1:
m = "janvier"
elif self.month == 2:
m = "février"
elif self.month == 3:
m = "mars"
elif self.month == 4:
m = "avril"
elif self.month == 5:
m = "mai"
elif self.month == 6:
m = "juin"
elif self.month == 7:
m = "juillet"
elif self.month == 8:
m = "août"
elif self.month == 9:
m = "septembre"
elif self.month == 10:
m = "octobre"
elif self.month == 11:
m = "novembre"
elif self.month == 12:
m = "décembre"
if self.service == "urgence":
self.ttl.setText("Imprimer planing de garde urgence mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "dentiste":
self.ttl.setText("Imprimer planing de garde chirurgie dentaire mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "labo":
self.ttl.setText("Imprimer planing de garde laboratoire mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "radio":
self.ttl.setText("Imprimer planing de garde radiologie mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "admin":
self.ttl.setText("Imprimer planing de garde administration mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "dentiste_inf":
self.ttl.setText("Imprimer planing de garde infirmiers dentaire mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "inf":
self.ttl.setText("EPSP Djanet ( Infirmiers d'urgences )")
self.ttl.setText("Imprimer planing de garde infirmiers d'urgences mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "surv":
self.ttl.setText("EPSP Djanet ( Surveillants d'urgences )")
self.ttl.setText("Imprimer planing de garde infirmiers surveillants mois " + str(m) + "/" + str(self.year) + ":")
elif self.service == "pharm":
self.ttl.setText("Imprimer planing de garde pharmacie mois " + str(m) + "/" + str(self.year) + ":")
if self.service == "inf":
self.thr = ThreadGuardUrgenceInf(self.num_days, self.month, self.year)
self.thr._signal.connect(self.signal_accept)
self.thr._signal_result.connect(self.signal_accept)
self.thr._signal_groupes.connect(self.signal_accept_groupes)
self.thr.start()
elif self.service == "surv":
self.thr = ThreadGuardUrgenceSurv(self.num_days, self.month, self.year)
self.thr._signal.connect(self.signal_accept)
self.thr._signal_result.connect(self.signal_accept)
self.thr._signal_groupes.connect(self.signal_accept_groupes)
self.thr.start()
else:
self.thr = ThreadGuard(self.service, self.num_days, self.month, self.year)
self.thr._signal.connect(self.signal_accept)
self.thr._signal_result.connect(self.signal_accept)
self.thr.start()
def export_pdf(self):
print(self.data)
filePath, _ = QFileDialog.getSaveFileName(self, "Save garde", "",
"PDF(*.pdf);;All Files(*.*) ")
# if file path is blank return back
if filePath == "":
message = "destination untrouvable"
self.alert_(message)
else:
if not self.service == "inf" and not self.service == "surv":
create_garde_page(self.service, self.month, self.year, self.data, filePath)
self.close()
else:
create_garde_inf_page(self.service, self.month, self.year, self.data, self.groupes, filePath)
self.close()
def signal_accept(self, progress):
if type(progress) == int:
self.progress.setValue(progress)
elif type(progress) == list:
self.progress.setValue(100)
self.data = progress
self.status.setText("complete")
self.export.setEnabled(True)
self.preview.setEnabled(True)
def signal_accept_groupes(self, progress):
if type(progress) == list:
self.groupes = progress
def alert_(self, message):
alert = QMessageBox()
alert.setWindowTitle("alert")
alert.setText(message)
alert.exec_()
def preview_pdf(self):
print("ok")