ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Trunk/MCP_ViewEdit_UI.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/MCP/MCP_ViewEdit_UI.py
File size: 18012 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 """
2    
3     MCP_ViewEdit_UI
4    
5     Created by
6     Emanuel Borges
7     03.17.2011
8    
9     This is the UI for viewing or editing case info
10    
11     """
12    
13    
14     import wx, MCP_Lib, MCP_Console,os,CurrentProductionsDialog,CaseUploadsDialog,AddDocumentProductionDialog,NinoGenTools
15    
16     class MyFrame(wx.Frame):
17     def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
18     self.console = MCP_Console.MainConsole()
19    
20     wx.Frame.__init__(self, parent, ID, title, pos, size =(550,580))
21     self.panel = wx.Panel(self,-1)
22    
23     #self.panel.SetBackgroundColour("yellow green")
24     casesListStaticText = wx.StaticText(self.panel, -1, "Select Case: ",wx.DefaultPosition)
25     casesList,casesDir = MCP_Lib.GetCaseList()
26     self.casesListChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=casesList)
27     self.casesListChoice.SetSelection(0)
28     self.chargeableCheckBox = wx.CheckBox(self.panel,-1,"Chargeable?")
29     responsibleAttnyStaticText = wx.StaticText(self.panel, -1, "Responsible Attorney: ",wx.DefaultPosition)
30     self.responsibleAttnyTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (110,-1))
31     responsibleParalegalStaticText = wx.StaticText(self.panel, -1, "Responsible Paralegal: ",wx.DefaultPosition)
32     self.responsibleParalegalTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (110,-1))
33     platformChoicesList = ["",'Concordance DIS','Concordance LN','Relativity']
34     reviewPlatformStaticText = wx.StaticText(self.panel, -1, "Platform: ",wx.DefaultPosition)
35     self.reviewPlatformChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=platformChoicesList)
36     responsibleProcessingVendorStaticText = wx.StaticText(self.panel, -1, "Processing Vendor: ",wx.DefaultPosition)
37     self.responsibleProcessingVendorTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (150,-1))
38     responsibleScanningVendorStaticText = wx.StaticText(self.panel, -1, "Scanning Vendor: ",wx.DefaultPosition)
39     self.responsibleScanningVendorTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (150,-1))
40     responsibleHostingVendorStaticText = wx.StaticText(self.panel, -1, "Hosting Vendor: ",wx.DefaultPosition)
41     self.responsibleHostingVendorTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (150,-1))
42     responsibleTPMStaticText = wx.StaticText(self.panel, -1, "TPM: ",wx.DefaultPosition)
43     self.responsibleTPMTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (110,-1))
44     responsibleOfficeStaticText = wx.StaticText(self.panel, -1, "Office: ",wx.DefaultPosition)
45     self.responsibleOfficeTextCtrl = wx.TextCtrl(self.panel, -1, "", wx.DefaultPosition, (110,-1))
46     caseStatusStaticText = wx.StaticText(self.panel, -1, "Case Status: ",wx.DefaultPosition)
47     statusChoicesList = ['Active','Dormant','Closed','Archived']## Selecting archived automatically unchecks chareable.
48     self.caseStatusChoice = wx.Choice(self.panel, -1, wx.DefaultPosition, choices=statusChoicesList)
49    
50    
51     self.SetFields(casesList[0])
52    
53     self.CreateBoxesSection()
54    
55     casesSizer = wx.BoxSizer(wx.HORIZONTAL)
56     casesSizer.Add(casesListStaticText,0,wx.ALL,5)
57     casesSizer.Add(self.casesListChoice,0,wx.ALL,5)
58    
59     secondHalfSizer = wx.GridBagSizer(5,5)
60     secondHalfSizer.Add(reviewPlatformStaticText, pos=(0,0))
61     secondHalfSizer.Add(self.reviewPlatformChoice, pos=(0,1))
62     secondHalfSizer.Add(self.chargeableCheckBox,pos=(0,3))
63     #secondHalfSizer.Add(self.chargeableCheckBox,pos=(0,2), span=(1,2), flag = wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL)
64     secondHalfSizer.Add(responsibleAttnyStaticText, pos=(1,0))
65     secondHalfSizer.Add(self.responsibleAttnyTextCtrl, pos=(1,1))
66     secondHalfSizer.Add(responsibleTPMStaticText, pos = (1,2))
67     secondHalfSizer.Add(self.responsibleTPMTextCtrl, pos = (1,3))
68     secondHalfSizer.Add(responsibleParalegalStaticText, pos=(2,0))
69     secondHalfSizer.Add(self.responsibleParalegalTextCtrl, pos=(2,1))
70     secondHalfSizer.Add(responsibleOfficeStaticText, pos=(2,2))
71     secondHalfSizer.Add(self.responsibleOfficeTextCtrl, pos=(2,3))
72     secondHalfSizer.Add(caseStatusStaticText, pos=(3,0))
73     secondHalfSizer.Add(self.caseStatusChoice, pos=(3,1))
74    
75     respVendorsStaticBox = wx.StaticBox(self.panel, -1, 'Responsible Vendors:')
76     respVendorsStaticBoxSizer = wx.StaticBoxSizer(respVendorsStaticBox, wx.VERTICAL)
77     respVendorsFlexGridSizer = wx.FlexGridSizer(3,2,10,10)
78     respVendorsFlexGridSizer.Add(responsibleProcessingVendorStaticText,5)
79     respVendorsFlexGridSizer.Add(self.responsibleProcessingVendorTextCtrl,5)
80     respVendorsFlexGridSizer.Add(responsibleScanningVendorStaticText,5)
81     respVendorsFlexGridSizer.Add(self.responsibleScanningVendorTextCtrl,5)
82     respVendorsFlexGridSizer.Add(responsibleHostingVendorStaticText,5)
83     respVendorsFlexGridSizer.Add(self.responsibleHostingVendorTextCtrl,5)
84     respVendorsStaticBoxSizer.Add(respVendorsFlexGridSizer,0,wx.ALL,20)
85    
86     mainSizer = wx.BoxSizer(wx.VERTICAL)
87     mainSizer.Add(casesSizer,0,wx.ALL, 20)
88     mainSizer.Add(secondHalfSizer,0,wx.ALL,20)
89     mainSizer.Add(respVendorsStaticBoxSizer,0,wx.ALL,20)
90     #mainSizer.Add(self.chargeableCheckBox,0,wx.ALL,5)
91     #mainSizer.Add(self.reviewPlatformChoice,0,wx.ALL,5)
92     #mainSizer.Add(self.responsibleAttnyTextCtrl,0,wx.ALL,5)
93     #mainSizer.Add(self.responsibleParalegalTextCtrl,0,wx.ALL,5)
94     #mainSizer.Add(self.responsibleProcessingVendorTextCtrl,0,wx.ALL,5)
95     #mainSizer.Add(self.responsibleScanningVendorTextCtrl,0,wx.ALL,5)
96     #mainSizer.Add(self.responsibleHostingVendorTextCtrl,0,wx.ALL,5)
97     #mainSizer.Add(workDirSizer,0,wx.ALL, 10)
98     #mainSizer.Add(copyUpTypeStaticBoxSizer, 0, wx.ALL, 10)
99     mainSizer.Add(self.buttonSizer,0, wx.ALL|wx.ALIGN_BOTTOM|wx.ALIGN_CENTER, 10)
100    
101     self.oKButton.Disable()
102    
103     #self.chargeableCheckBox.Disable() ## Remove me.
104    
105     self.panel.SetSizer(mainSizer)
106    
107     self.CreateStatusBar()
108     self.SetStatusText("Ready.")
109     self.CreateMenuBar()
110    
111     self.Bind(wx.EVT_CHOICE, self.OnSetFields, self.casesListChoice)
112     self.Bind(wx.EVT_CHOICE, self.OnFormChanged, self.reviewPlatformChoice)
113     self.Bind(wx.EVT_CHOICE, self.OnFormChanged, self.caseStatusChoice)
114     self.Bind(wx.EVT_CHECKBOX, self.OnFormChanged, self.chargeableCheckBox)
115     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleAttnyTextCtrl)
116     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleTPMTextCtrl)
117     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleParalegalTextCtrl)
118     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleOfficeTextCtrl)
119     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleProcessingVendorTextCtrl)
120     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleScanningVendorTextCtrl)
121     self.Bind(wx.EVT_TEXT, self.OnFormChanged, self.responsibleHostingVendorTextCtrl)
122    
123     self.Bind(wx.EVT_BUTTON, self.OnProcess, self.oKButton)
124     self.Bind(wx.EVT_BUTTON, self.CloseWindow, self.cancelButton)
125    
126     def NothingYet(self,event):
127     """ A simple place holder function that is used to be a PASS statment when I'm creating controls"""
128     diag = wx.MessageDialog(self,"Nothing here yet!", "Disabled...",wx.OK | wx.ICON_INFORMATION)
129     diag.ShowModal()
130     diag.Destroy()
131    
132     def MenuData(self):
133     return(("View",
134     ("Case &Uploads", "Displays the Case Uploads for this case.",self.OnViewCaseUploads),
135     ("&Production History", "Displays the Production History for this case.",self.OnViewDocProduction),
136     ("Open Case &Folder","Opens the case folder for the current selected case.",self.OnOpenCaseFolder)),
137     ("Production",
138     ("&Add Production Entry","Adds a new production to the matter database.",self.OnAddDocProduction)),
139     ("&Help",
140     ("&About", "Displays the About Window.", self.OnAbout)))
141    
142     def CreateMenuBar(self):
143     menuBar = wx.MenuBar()
144     for eachMenuData in self.MenuData():
145     menuLabel = eachMenuData[0]
146     menuItems = eachMenuData[1:]
147     menuBar.Append(self.CreateMenu(menuItems), menuLabel)
148     self.SetMenuBar(menuBar)
149    
150    
151     def CreateMenu(self, menuData):
152     menu = wx.Menu()
153     for eachLabel, eachStatus, eachHandler in menuData:
154     if not eachLabel:
155     menu.AppendSeparator()
156     continue
157     menuItem = menu.Append(-1, eachLabel, eachStatus)
158     self.Bind(wx.EVT_MENU, eachHandler, menuItem)
159     return menu
160    
161    
162     def OnFormChanged(self,event):
163     self.oKButton.Enable()
164    
165     def OnSetFields(self,event):
166     #print self.casesListChoice.GetStringSelection()
167     self.SetFields(self.casesListChoice.GetStringSelection())
168     self.oKButton.Disable()
169    
170     def SetFields(self, case):
171     currentChargeableBool,currentRespAttorney,currentRespParalegal,currentRespVendorTpl,currentRevPlatform,respTPM,respOffice,caseStatus = self.console.GetCaseData(case)
172     if currentChargeableBool:
173     self.chargeableCheckBox.SetValue(True)
174     else:
175     self.chargeableCheckBox.SetValue(False)
176     if currentRevPlatform == 'Concordance':
177     ## Make an assumption
178     currentRevPlatform = "Concordance DIS"
179     if currentRevPlatform:
180     #print currentRevPlatform
181     self.reviewPlatformChoice.SetStringSelection(currentRevPlatform)
182     else:
183     self.reviewPlatformChoice.SetStringSelection('')
184     if currentRespAttorney:
185     self.responsibleAttnyTextCtrl.SetValue(currentRespAttorney)
186     else:
187     self.responsibleAttnyTextCtrl.SetValue('')
188     if currentRespParalegal:
189     self.responsibleParalegalTextCtrl.SetValue(currentRespParalegal)
190     else:
191     self.responsibleParalegalTextCtrl.SetValue('')
192     if currentRespVendorTpl[0]:
193     self.responsibleProcessingVendorTextCtrl.SetValue(currentRespVendorTpl[0])
194     else:
195     self.responsibleProcessingVendorTextCtrl.SetValue("")
196     if currentRespVendorTpl[1]:
197     self.responsibleScanningVendorTextCtrl.SetValue(currentRespVendorTpl[1])
198     else:
199     self.responsibleScanningVendorTextCtrl.SetValue('')
200     if currentRespVendorTpl[2]:
201     self.responsibleHostingVendorTextCtrl.SetValue(currentRespVendorTpl[2])
202     else:
203     self.responsibleHostingVendorTextCtrl.SetValue('')
204     if respTPM:
205     self.responsibleTPMTextCtrl.SetValue(respTPM)
206     else:
207     self.responsibleTPMTextCtrl.SetValue('')
208     if respOffice:
209     self.responsibleOfficeTextCtrl.SetValue(respOffice)
210     else:
211     self.responsibleOfficeTextCtrl.SetValue('')
212     if caseStatus:
213     self.caseStatusChoice.SetStringSelection(caseStatus)
214     else:
215     self.caseStatusChoice.SetStringSelection('')
216    
217    
218     def OnProcess(self, event):
219     caseName = self.casesListChoice.GetStringSelection()
220     if self.chargeableCheckBox.GetValue():
221     chargeableBool = True
222     else:
223     chargeableBool = False
224     currentRevPlatform = self.reviewPlatformChoice.GetStringSelection()
225     caseStatus = self.caseStatusChoice.GetStringSelection()
226     currentRespAttorney = self.responsibleAttnyTextCtrl.GetValue()
227     currentRespParalegal = self.responsibleParalegalTextCtrl.GetValue()
228     currentRespVendorTpl = (self.responsibleProcessingVendorTextCtrl.GetValue(),self.responsibleScanningVendorTextCtrl.GetValue(),
229     self.responsibleHostingVendorTextCtrl.GetValue())
230     respTPM = self.responsibleTPMTextCtrl.GetValue()
231     respOffice = self.responsibleOfficeTextCtrl.GetValue()
232     print "Updating Access DB..."
233     self.console.EditCaseData(caseName,chargeableBool,currentRespAttorney,currentRespParalegal,currentRespVendorTpl,currentRevPlatform,
234     respTPM,respOffice, caseStatus)
235     print "Complete!"
236     finishedDlg = wx.MessageDialog(self, "MCP: Your settings have been saved to the Matter Management database.", "MCP: Process Complete",wx.OK, wx.DefaultPosition)
237     finishedDlg.ShowModal()
238     finishedDlg.Destroy()
239     self.oKButton.Disable()
240    
241     def CreateBoxesSection(self):
242     self.oKButton = wx.Button(self.panel, wx.ID_OK,'Save')
243     self.oKButton.SetDefault()
244     self.oKButton.SetSize(self.oKButton.GetBestSize())
245     self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL,'Close')
246     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
247     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
248     self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
249     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
250    
251     def CloseWindow(self, event):
252     self.Close(True)
253    
254     def OnOpenCaseFolder(self,event):
255     caseName = self.casesListChoice.GetStringSelection()
256     office = self.responsibleOfficeTextCtrl.GetValue()
257     err = self.console.OpenCaseFolder(caseName,office)
258     if err:
259     errDlg = wx.MessageDialog(self, "MCP: The path to this case file could not be found.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
260     errDlg.ShowModal()
261     errDlg.Destroy()
262    
263     def OnViewCaseUploads(self, event):
264     uploadList = self.console.GetUploadData(self.casesListChoice.GetStringSelection())
265     numberOfRows = len(uploadList)
266     uploadTotal = self.console.GetUploadTotal(uploadList)
267     caseName = self.casesListChoice.GetStringSelection()
268     CLM = caseName.split("_(")[1]
269     CLM = CLM[:-1]
270     CLM = CLM.replace('-','.')
271     #print CLM
272     if numberOfRows == 0:
273     dlg = wx.MessageDialog(self, "MCP: There are no case uploads for this case.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
274     else:
275     dlg = CaseUploadsDialog.CaseUploadsDialog(self,numberOfRows, uploadList, uploadTotal,CLM)
276     #dlg.Show(True)
277     dlg.ShowModal()
278     dlg.Destroy()
279    
280     def OnViewDocProduction(self,event):
281     prodList = self.console.GetProductionData(self.casesListChoice.GetStringSelection())
282     numberOfRows = len(prodList)
283     prodTotals = self.console.GetProductionTotal(prodList)
284     caseName = self.casesListChoice.GetStringSelection()
285     CLM = caseName.split("_(")[1]
286     CLM = CLM[:-1]
287     CLM = CLM.replace('-','.')
288     #print CLM
289     if numberOfRows == 0:
290     dlg = wx.MessageDialog(self, "MCP: There are no current productions for this case.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
291     else:
292     dlg = CurrentProductionsDialog.CaseUploadsDialog(self,numberOfRows, prodList,CLM, prodTotals)
293     #dlg.Show(True)
294     dlg.ShowModal()
295     dlg.Destroy()
296    
297     def OnAddDocProduction(self, event):
298     caseName = self.casesListChoice.GetStringSelection()
299     CLM = caseName.split("_(")[1]
300     CLM = CLM[:-1]
301     CLM = CLM.replace('-','.')
302     #print CLM
303     dlg = AddDocumentProductionDialog.AddDocumentProductionDialog(self,CLM)
304     if dlg.ShowModal() == wx.ID_OK:
305     prodDate, begBates, endBates, prodDocCount, prodPageCount, prodNotes = dlg.GetValues()
306     #print prodDate
307     dateConverter = NinoGenTools.DateUtilities()
308     prodID = 'prod_' + str(dateConverter.ConvertDateFormat(prodDate, convertToFormat='computer'))
309     errRpt = self.console.AddProductionEntry(CLM,prodID,prodDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes)
310     if errRpt:
311     doneDlg = wx.MessageDialog(self, "MCP: All fields need to be filled out.\nPlease try again.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
312     else:
313     doneDlg = wx.MessageDialog(self, "MCP: Production detail added successfully.", "MCP: Success",wx.OK, wx.DefaultPosition)
314     doneDlg.ShowModal()
315     doneDlg.Destroy()
316    
317    
318    
319     def OnAbout(self, event):
320     """
321     OnAbout(self,event) Displays an about dialog with developer and bug reporting info
322     """
323     dlg = wx.MessageDialog(self, "MCP is a case organization program.\n"
324     "\n\n"
325     "For questions or comments about this program\n"
326     "or to report a bug, please email the program\n"
327     "creator at Nino.Borges@gmail.com\n\n"
328     "MCP is\n"
329     "Copyright (c) 2011 Emanuel Borges.\n"
330     "All rights reserved.\n"
331     "(Nino.Borges@gmail.com)\n",
332     "About MCP", wx.OK | wx.ICON_INFORMATION)
333     dlg.ShowModal()
334     dlg.Destroy()
335    
336    
337     class MyApp(wx.App):
338     def OnInit(self):
339     prgVersion = MCP_Lib.GetMCPVersion()
340     self.frame = MyFrame(None, -1, "View/Edit Case Information %s"%prgVersion)
341     self.frame.Show(True)
342     self.SetTopWindow(self.frame)
343     return True
344    
345    
346     if __name__ == '__main__':
347     app = MyApp(0)
348     app.MainLoop()