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: 174
Committed: Mon Oct 22 21:59:39 2012 UTC (13 years, 5 months ago) by nino.borges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/MCP/MCP_ViewEdit_UI.py
File size: 20180 byte(s)
Log Message:
Changed View Edit UT to support changing of the cases list. Nothing behind it though.

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 nino.borges 174 ("My Cases", "Chooses from your assigned cases.",self.OnChangeCaseView,"RADIO"),
135     ("My Office Cases", "Chooses from cases assigned to everyone in your office.",self.OnChangeCaseView,"RADIO"),
136     ("All Cases", "Chooses from all cases.",self.OnChangeCaseView,"RADIO"),
137     ("","","",""),
138     ("Case &Uploads", "Displays the Case Uploads for this case.",self.OnViewCaseUploads,""),
139     ("&Production History", "Displays the Production History for this case.",self.OnViewDocProduction,""),
140     ("","","",""),
141     ("My Case &Notes","Opens the case folder for the current selected case.",self.OnViewCaseNotes,""),
142     ("My Production &Spec","Opens the case folder for the current selected case.",self.OnViewProdSpec,""),
143     ("Open Case &Folder","Opens the case folder for the current selected case.",self.OnOpenCaseFolder,"")),
144 ninoborges 8 ("Production",
145 nino.borges 174 ("&Add Production Entry","Adds a new production to the matter database.",self.OnAddDocProduction,"")),
146 ninoborges 8 ("&Help",
147 nino.borges 174 ("&About", "Displays the About Window.", self.OnAbout,"")))
148 ninoborges 8
149     def CreateMenuBar(self):
150     menuBar = wx.MenuBar()
151 nino.borges 158 count = 1
152 ninoborges 8 for eachMenuData in self.MenuData():
153     menuLabel = eachMenuData[0]
154     menuItems = eachMenuData[1:]
155     menuBar.Append(self.CreateMenu(menuItems), menuLabel)
156 nino.borges 158 count = count + 1
157 ninoborges 8 self.SetMenuBar(menuBar)
158    
159    
160     def CreateMenu(self, menuData):
161     menu = wx.Menu()
162 nino.borges 174 for eachLabel, eachStatus, eachHandler, eachType in menuData:
163 ninoborges 8 if not eachLabel:
164     menu.AppendSeparator()
165     continue
166 nino.borges 174 if eachType == "RADIO":
167     menuItem = menu.AppendRadioItem(-1,eachLabel,eachStatus)
168     else:
169     menuItem = menu.Append(-1, eachLabel, eachStatus)
170 ninoborges 8 self.Bind(wx.EVT_MENU, eachHandler, menuItem)
171     return menu
172    
173    
174     def OnFormChanged(self,event):
175     self.oKButton.Enable()
176    
177     def OnSetFields(self,event):
178     #print self.casesListChoice.GetStringSelection()
179     self.SetFields(self.casesListChoice.GetStringSelection())
180     self.oKButton.Disable()
181    
182     def SetFields(self, case):
183     currentChargeableBool,currentRespAttorney,currentRespParalegal,currentRespVendorTpl,currentRevPlatform,respTPM,respOffice,caseStatus = self.console.GetCaseData(case)
184     if currentChargeableBool:
185     self.chargeableCheckBox.SetValue(True)
186     else:
187     self.chargeableCheckBox.SetValue(False)
188     if currentRevPlatform == 'Concordance':
189     ## Make an assumption
190     currentRevPlatform = "Concordance DIS"
191     if currentRevPlatform:
192     #print currentRevPlatform
193     self.reviewPlatformChoice.SetStringSelection(currentRevPlatform)
194     else:
195     self.reviewPlatformChoice.SetStringSelection('')
196     if currentRespAttorney:
197     self.responsibleAttnyTextCtrl.SetValue(currentRespAttorney)
198     else:
199     self.responsibleAttnyTextCtrl.SetValue('')
200     if currentRespParalegal:
201     self.responsibleParalegalTextCtrl.SetValue(currentRespParalegal)
202     else:
203     self.responsibleParalegalTextCtrl.SetValue('')
204     if currentRespVendorTpl[0]:
205     self.responsibleProcessingVendorTextCtrl.SetValue(currentRespVendorTpl[0])
206     else:
207     self.responsibleProcessingVendorTextCtrl.SetValue("")
208     if currentRespVendorTpl[1]:
209     self.responsibleScanningVendorTextCtrl.SetValue(currentRespVendorTpl[1])
210     else:
211     self.responsibleScanningVendorTextCtrl.SetValue('')
212     if currentRespVendorTpl[2]:
213     self.responsibleHostingVendorTextCtrl.SetValue(currentRespVendorTpl[2])
214     else:
215     self.responsibleHostingVendorTextCtrl.SetValue('')
216     if respTPM:
217     self.responsibleTPMTextCtrl.SetValue(respTPM)
218     else:
219     self.responsibleTPMTextCtrl.SetValue('')
220     if respOffice:
221     self.responsibleOfficeTextCtrl.SetValue(respOffice)
222     else:
223     self.responsibleOfficeTextCtrl.SetValue('')
224     if caseStatus:
225     self.caseStatusChoice.SetStringSelection(caseStatus)
226     else:
227     self.caseStatusChoice.SetStringSelection('')
228    
229    
230     def OnProcess(self, event):
231     caseName = self.casesListChoice.GetStringSelection()
232     if self.chargeableCheckBox.GetValue():
233     chargeableBool = True
234     else:
235     chargeableBool = False
236     currentRevPlatform = self.reviewPlatformChoice.GetStringSelection()
237     caseStatus = self.caseStatusChoice.GetStringSelection()
238     currentRespAttorney = self.responsibleAttnyTextCtrl.GetValue()
239     currentRespParalegal = self.responsibleParalegalTextCtrl.GetValue()
240     currentRespVendorTpl = (self.responsibleProcessingVendorTextCtrl.GetValue(),self.responsibleScanningVendorTextCtrl.GetValue(),
241     self.responsibleHostingVendorTextCtrl.GetValue())
242     respTPM = self.responsibleTPMTextCtrl.GetValue()
243     respOffice = self.responsibleOfficeTextCtrl.GetValue()
244     print "Updating Access DB..."
245     self.console.EditCaseData(caseName,chargeableBool,currentRespAttorney,currentRespParalegal,currentRespVendorTpl,currentRevPlatform,
246     respTPM,respOffice, caseStatus)
247     print "Complete!"
248     finishedDlg = wx.MessageDialog(self, "MCP: Your settings have been saved to the Matter Management database.", "MCP: Process Complete",wx.OK, wx.DefaultPosition)
249     finishedDlg.ShowModal()
250     finishedDlg.Destroy()
251     self.oKButton.Disable()
252    
253     def CreateBoxesSection(self):
254     self.oKButton = wx.Button(self.panel, wx.ID_OK,'Save')
255     self.oKButton.SetDefault()
256     self.oKButton.SetSize(self.oKButton.GetBestSize())
257     self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL,'Close')
258     self.cancelButton.SetSize(self.cancelButton.GetBestSize())
259     self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
260     self.buttonSizer.Add(self.oKButton,0,wx.ALL,10)
261     self.buttonSizer.Add(self.cancelButton,0,wx.ALL,10)
262    
263     def CloseWindow(self, event):
264     self.Close(True)
265 nino.borges 158
266 nino.borges 174 def OnChangeCaseView(self,event):
267     self.casesListChoice.Clear()
268     eventID = event.GetId()
269     if eventID == 100:
270     #change it to my cases
271     self.casesListChoice.SetItems(['foo','bar'])
272     if eventID == 101:
273     #change it to office cases
274     pass
275     if eventID == 102:
276     #change it to all cases
277     pass
278    
279    
280 nino.borges 158 def OnViewCaseNotes(self,event):
281     caseName = self.casesListChoice.GetStringSelection()
282     office = self.responsibleOfficeTextCtrl.GetValue()
283     err = self.console.ViewCaseNotes(caseName,office)
284     if err:
285     errDlg = wx.MessageDialog(self, "MCP: The path to this case file could not be found.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
286     errDlg.ShowModal()
287     errDlg.Destroy()
288    
289     def OnViewProdSpec(self,event):
290     caseName = self.casesListChoice.GetStringSelection()
291     office = self.responsibleOfficeTextCtrl.GetValue()
292     err = self.console.ViewProdSpec(caseName,office)
293     if err:
294     errDlg = wx.MessageDialog(self, "MCP: The path to this case file could not be found.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
295     errDlg.ShowModal()
296     errDlg.Destroy()
297 ninoborges 8
298     def OnOpenCaseFolder(self,event):
299     caseName = self.casesListChoice.GetStringSelection()
300     office = self.responsibleOfficeTextCtrl.GetValue()
301     err = self.console.OpenCaseFolder(caseName,office)
302     if err:
303     errDlg = wx.MessageDialog(self, "MCP: The path to this case file could not be found.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
304     errDlg.ShowModal()
305     errDlg.Destroy()
306    
307     def OnViewCaseUploads(self, event):
308     uploadList = self.console.GetUploadData(self.casesListChoice.GetStringSelection())
309     numberOfRows = len(uploadList)
310     uploadTotal = self.console.GetUploadTotal(uploadList)
311     caseName = self.casesListChoice.GetStringSelection()
312     CLM = caseName.split("_(")[1]
313     CLM = CLM[:-1]
314     CLM = CLM.replace('-','.')
315     #print CLM
316     if numberOfRows == 0:
317     dlg = wx.MessageDialog(self, "MCP: There are no case uploads for this case.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
318     else:
319     dlg = CaseUploadsDialog.CaseUploadsDialog(self,numberOfRows, uploadList, uploadTotal,CLM)
320     #dlg.Show(True)
321     dlg.ShowModal()
322     dlg.Destroy()
323    
324     def OnViewDocProduction(self,event):
325     prodList = self.console.GetProductionData(self.casesListChoice.GetStringSelection())
326     numberOfRows = len(prodList)
327     prodTotals = self.console.GetProductionTotal(prodList)
328     caseName = self.casesListChoice.GetStringSelection()
329     CLM = caseName.split("_(")[1]
330     CLM = CLM[:-1]
331     CLM = CLM.replace('-','.')
332     #print CLM
333     if numberOfRows == 0:
334     dlg = wx.MessageDialog(self, "MCP: There are no current productions for this case.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
335     else:
336     dlg = CurrentProductionsDialog.CaseUploadsDialog(self,numberOfRows, prodList,CLM, prodTotals)
337     #dlg.Show(True)
338     dlg.ShowModal()
339     dlg.Destroy()
340    
341     def OnAddDocProduction(self, event):
342     caseName = self.casesListChoice.GetStringSelection()
343     CLM = caseName.split("_(")[1]
344     CLM = CLM[:-1]
345     CLM = CLM.replace('-','.')
346     #print CLM
347     dlg = AddDocumentProductionDialog.AddDocumentProductionDialog(self,CLM)
348     if dlg.ShowModal() == wx.ID_OK:
349     prodDate, begBates, endBates, prodDocCount, prodPageCount, prodNotes = dlg.GetValues()
350     #print prodDate
351     dateConverter = NinoGenTools.DateUtilities()
352     prodID = 'prod_' + str(dateConverter.ConvertDateFormat(prodDate, convertToFormat='computer'))
353     errRpt = self.console.AddProductionEntry(CLM,prodID,prodDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes)
354     if errRpt:
355     doneDlg = wx.MessageDialog(self, "MCP: All fields need to be filled out.\nPlease try again.", "MCP: Does Not Compute",wx.OK, wx.DefaultPosition)
356     else:
357     doneDlg = wx.MessageDialog(self, "MCP: Production detail added successfully.", "MCP: Success",wx.OK, wx.DefaultPosition)
358     doneDlg.ShowModal()
359     doneDlg.Destroy()
360    
361    
362    
363     def OnAbout(self, event):
364     """
365     OnAbout(self,event) Displays an about dialog with developer and bug reporting info
366     """
367     dlg = wx.MessageDialog(self, "MCP is a case organization program.\n"
368     "\n\n"
369     "For questions or comments about this program\n"
370     "or to report a bug, please email the program\n"
371     "creator at Nino.Borges@gmail.com\n\n"
372     "MCP is\n"
373     "Copyright (c) 2011 Emanuel Borges.\n"
374     "All rights reserved.\n"
375     "(Nino.Borges@gmail.com)\n",
376     "About MCP", wx.OK | wx.ICON_INFORMATION)
377     dlg.ShowModal()
378     dlg.Destroy()
379    
380    
381     class MyApp(wx.App):
382     def OnInit(self):
383     prgVersion = MCP_Lib.GetMCPVersion()
384     self.frame = MyFrame(None, -1, "View/Edit Case Information %s"%prgVersion)
385     self.frame.Show(True)
386     self.SetTopWindow(self.frame)
387     return True
388    
389    
390     if __name__ == '__main__':
391     app = MyApp(0)
392     app.MainLoop()