| Home | Trees | Indices | Help |
|
|---|
|
|
1 """GNUmed staff management widgets."""
2 #=========================================================================
3 # $Source: /home/ncq/Projekte/cvs2git/vcs-mirror/gnumed/gnumed/client/wxpython/gmStaffWidgets.py,v $
4 # $Id: gmStaffWidgets.py,v 1.27 2010-01-31 18:20:03 ncq Exp $
5 __version__ = "$Revision: 1.27 $"
6 __author__ = "K. Hilbert <Karsten.Hilbert@gmx.net>"
7 __license__ = "GPL v2 or later (details at http://www.gnu.org)"
8
9 import logging
10
11 import wx
12
13 from Gnumed.pycommon import gmPG2, gmTools, gmI18N
14 from Gnumed.business import gmPerson
15 from Gnumed.wxpython import gmGuiHelpers, gmAuthWidgets
16 from Gnumed.wxGladeWidgets import wxgAddPatientAsStaffDlg, wxgEditStaffListDlg
17
18 _log = logging.getLogger('gm.ui')
19 _log.info(__version__)
20 #==========================================================================
22
24 wxgEditStaffListDlg.wxgEditStaffListDlg.__init__(self, *args, **kwds)
25
26 self._LCTRL_staff.InsertColumn(0, _('Alias'))
27 self._LCTRL_staff.InsertColumn(1, _('DB account'))
28 self._LCTRL_staff.InsertColumn(2, _('Role'))
29 self._LCTRL_staff.InsertColumn(3, _('Name'))
30 self._LCTRL_staff.InsertColumn(4, _('Comment'))
31 self._LCTRL_staff.InsertColumn(5, _('Status'))
32
33 self.__init_ui_data()
34 #--------------------------------------------------------
35 # internal API
36 #--------------------------------------------------------
38 lbl_active = {True: _('active'), False: _('inactive')}
39 lbl_login = {True: _('can login'), False: _('can not login')}
40
41 self._LCTRL_staff.DeleteAllItems()
42 staff_list = gmPerson.get_staff_list()
43 pos = len(staff_list) + 1
44 for staff in staff_list:
45 row_num = self._LCTRL_staff.InsertStringItem(pos, label=staff['short_alias'])
46 self._LCTRL_staff.SetStringItem(index = row_num, col = 1, label = staff['db_user'])
47 self._LCTRL_staff.SetStringItem(index = row_num, col = 2, label = staff['l10n_role'])
48 title = gmTools.coalesce(staff['title'], '')
49 self._LCTRL_staff.SetStringItem(index = row_num, col = 3, label = '%s %s, %s' % (title, staff['lastnames'], staff['firstnames']))
50 self._LCTRL_staff.SetStringItem(index = row_num, col = 4, label = gmTools.coalesce(staff['comment'], ''))
51 self._LCTRL_staff.SetStringItem(index = row_num, col = 5, label = '%s / %s' % (lbl_active[bool(staff['is_active'])], lbl_login[bool(staff['can_login'])]))
52 # color
53 if staff['is_active'] and staff['can_login']:
54 #self._LCTRL_staff.SetItemTextColour(row_num, col=wx.NamedColour('BLUE'))
55 pass
56 elif not staff['is_active'] and not staff['can_login']:
57 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.LIGHT_GREY)
58 else:
59 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.NamedColour('RED'))
60 # data
61 self._LCTRL_staff.SetItemData(item = row_num, data = staff['pk_staff'])
62
63 if len(staff_list) > 0:
64 self._LCTRL_staff.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE)
65 self._LCTRL_staff.SetColumnWidth(col=1, width=wx.LIST_AUTOSIZE_USEHEADER)
66 self._LCTRL_staff.SetColumnWidth(col=2, width=wx.LIST_AUTOSIZE)
67 self._LCTRL_staff.SetColumnWidth(col=3, width=wx.LIST_AUTOSIZE)
68 self._LCTRL_staff.SetColumnWidth(col=4, width=wx.LIST_AUTOSIZE)
69 self._LCTRL_staff.SetColumnWidth(col=5, width=wx.LIST_AUTOSIZE)
70
71 # disable buttons
72 self._btn_save.Enable(False)
73 self._btn_delete.Enable(False)
74 self._btn_deactivate.Enable(False)
75 self._btn_activate.Enable(False)
76 # clear editor
77 self._TCTRL_name.SetValue('')
78 self._TCTRL_alias.SetValue('')
79 self._TCTRL_account.SetValue('')
80 self._TCTRL_comment.SetValue('')
81 #--------------------------------------------------------
82 # event handlers
83 #--------------------------------------------------------
85 self._btn_save.Enable(True)
86 self._btn_delete.Enable(True)
87 self._btn_deactivate.Enable(True)
88 self._btn_activate.Enable(True)
89 # fill editor
90 pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected())
91 staff = gmPerson.cStaff(aPK_obj=pk_staff)
92 self._TCTRL_name.SetValue('%s.%s %s' % (staff['title'], staff['firstnames'], staff['lastnames']))
93 self._TCTRL_alias.SetValue(staff['short_alias'])
94 self._TCTRL_account.SetValue(staff['db_user'])
95 self._TCTRL_comment.SetValue(gmTools.coalesce(staff['comment'], ''))
96 #--------------------------------------------------------
98 self._btn_save.Enable(False)
99 self._btn_delete.Enable(False)
100 self._btn_deactivate.Enable(False)
101 self._btn_activate.Enable(False)
102 # clear editor
103 self._TCTRL_name.SetValue('')
104 self._TCTRL_alias.SetValue('')
105 self._TCTRL_account.SetValue('')
106 self._TCTRL_comment.SetValue('')
107 #--------------------------------------------------------
129 #--------------------------------------------------------
151 #--------------------------------------------------------
152 # def _on_delete_button_pressed(self, event):
153 #--------------------------------------------------------
176 #==========================================================================
178
180 wxgAddPatientAsStaffDlg.wxgAddPatientAsStaffDlg.__init__(self, *args, **kwds)
181 self.__init_ui_data()
182 #--------------------------------------------------------
183 # internal API
184 #--------------------------------------------------------
186 pat = gmPerson.gmCurrentPatient()
187 name = pat.get_active_name()
188 txt = _("""
189 %s "%s" %s
190 born: %s""") % (name['firstnames'], name['preferred'], name['lastnames'], pat.get_formatted_dob(format = '%x', encoding = gmI18N.get_encoding()))
191 self._TXT_person.SetValue(txt)
192 txt = name['firstnames'][:2] + name['lastnames'][:2]
193 self._TXT_short_alias.SetValue(txt)
194 self._TXT_account.SetValue(txt.lower())
195 #--------------------------------------------------------
196 # event handlers
197 #--------------------------------------------------------
200 #--------------------------------------------------------
266 #==========================================================================
267
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Oct 18 04:00:35 2011 | http://epydoc.sourceforge.net |