1 """GNUmed staff management widgets.
2
3 This source code is protected by the GPL licensing scheme.
4 Details regarding the GPL are available at http://www.gnu.org
5 You may use and share it as long as you don't deny this right
6 to anybody else.
7 """
8
9
10
11 __version__ = "$Revision: 1.27 $"
12 __author__ = "K. Hilbert <Karsten.Hilbert@gmx.net>"
13 __license__ = "GPL (details at http://www.gnu.org)"
14
15 import logging
16
17 import wx
18
19 from Gnumed.pycommon import gmPG2, gmTools, gmI18N
20 from Gnumed.business import gmPerson
21 from Gnumed.wxpython import gmGuiHelpers, gmAuthWidgets
22 from Gnumed.wxGladeWidgets import wxgAddPatientAsStaffDlg, wxgEditStaffListDlg
23
24 _log = logging.getLogger('gm.ui')
25 _log.info(__version__)
26
28
30 wxgEditStaffListDlg.wxgEditStaffListDlg.__init__(self, *args, **kwds)
31
32 self._LCTRL_staff.InsertColumn(0, _('Alias'))
33 self._LCTRL_staff.InsertColumn(1, _('DB account'))
34 self._LCTRL_staff.InsertColumn(2, _('Role'))
35 self._LCTRL_staff.InsertColumn(3, _('Name'))
36 self._LCTRL_staff.InsertColumn(4, _('Comment'))
37 self._LCTRL_staff.InsertColumn(5, _('Status'))
38
39 self.__init_ui_data()
40
41
42
44 lbl_active = {True: _('active'), False: _('inactive')}
45 lbl_login = {True: _('can login'), False: _('can not login')}
46
47 self._LCTRL_staff.DeleteAllItems()
48 staff_list = gmPerson.get_staff_list()
49 pos = len(staff_list) + 1
50 for staff in staff_list:
51 row_num = self._LCTRL_staff.InsertStringItem(pos, label=staff['short_alias'])
52 self._LCTRL_staff.SetStringItem(index = row_num, col = 1, label = staff['db_user'])
53 self._LCTRL_staff.SetStringItem(index = row_num, col = 2, label = staff['role'])
54 title = gmTools.coalesce(staff['title'], '')
55 self._LCTRL_staff.SetStringItem(index = row_num, col = 3, label = '%s %s, %s' % (title, staff['lastnames'], staff['firstnames']))
56 self._LCTRL_staff.SetStringItem(index = row_num, col = 4, label = gmTools.coalesce(staff['comment'], ''))
57 self._LCTRL_staff.SetStringItem(index = row_num, col = 5, label = '%s / %s' % (lbl_active[bool(staff['is_active'])], lbl_login[bool(staff['can_login'])]))
58
59 if staff['is_active'] and staff['can_login']:
60
61 pass
62 elif not staff['is_active'] and not staff['can_login']:
63 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.LIGHT_GREY)
64 else:
65 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.NamedColour('RED'))
66
67 self._LCTRL_staff.SetItemData(item = row_num, data = staff['pk_staff'])
68
69 if len(staff_list) > 0:
70 self._LCTRL_staff.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE)
71 self._LCTRL_staff.SetColumnWidth(col=1, width=wx.LIST_AUTOSIZE_USEHEADER)
72 self._LCTRL_staff.SetColumnWidth(col=2, width=wx.LIST_AUTOSIZE)
73 self._LCTRL_staff.SetColumnWidth(col=3, width=wx.LIST_AUTOSIZE)
74 self._LCTRL_staff.SetColumnWidth(col=4, width=wx.LIST_AUTOSIZE)
75 self._LCTRL_staff.SetColumnWidth(col=5, width=wx.LIST_AUTOSIZE)
76
77
78 self._btn_save.Enable(False)
79 self._btn_delete.Enable(False)
80 self._btn_deactivate.Enable(False)
81 self._btn_activate.Enable(False)
82
83 self._TCTRL_name.SetValue('')
84 self._TCTRL_alias.SetValue('')
85 self._TCTRL_account.SetValue('')
86 self._TCTRL_comment.SetValue('')
87
88
89
91 self._btn_save.Enable(True)
92 self._btn_delete.Enable(True)
93 self._btn_deactivate.Enable(True)
94 self._btn_activate.Enable(True)
95
96 pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected())
97 staff = gmPerson.cStaff(aPK_obj=pk_staff)
98 self._TCTRL_name.SetValue('%s.%s %s' % (staff['title'], staff['firstnames'], staff['lastnames']))
99 self._TCTRL_alias.SetValue(staff['short_alias'])
100 self._TCTRL_account.SetValue(staff['db_user'])
101 self._TCTRL_comment.SetValue(gmTools.coalesce(staff['comment'], ''))
102
104 self._btn_save.Enable(False)
105 self._btn_delete.Enable(False)
106 self._btn_deactivate.Enable(False)
107 self._btn_activate.Enable(False)
108
109 self._TCTRL_name.SetValue('')
110 self._TCTRL_alias.SetValue('')
111 self._TCTRL_account.SetValue('')
112 self._TCTRL_comment.SetValue('')
113
135
157
158
159
182
184
186 wxgAddPatientAsStaffDlg.wxgAddPatientAsStaffDlg.__init__(self, *args, **kwds)
187 self.__init_ui_data()
188
189
190
201
202
203
206
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