ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/DisclosureLetterDialog.py
Revision: 321
Committed: Tue Mar 26 14:51:35 2013 UTC (13 years ago) by nino.borges
Content type: text/x-python
File size: 5841 byte(s)
Log Message:
Added the disclosure letter feature with dialogs and warning message on main view edit.

File Contents

# User Rev Content
1 nino.borges 321 """
2     DisclosureLetterDialog
3    
4     Created by
5     Emanuel Borges
6     03.20.2013
7    
8     This dialog will show the disclosure letter information and allow you to edit
9     and update.
10     """
11    
12     import wx, os
13    
14     class DisclosureLetterDialog(wx.Dialog):
15     def __init__(self, parent,disclosureLetterSet, disclosureLetterPath,casePath):
16     self.casePath = casePath
17     #self.CLM = CLM
18     self.parent = parent
19     wx.Dialog.__init__(self, parent, -1, "Disclosure Letter", style = wx.DEFAULT_DIALOG_STYLE, size = (550,210))
20     disclosureLetterPathStaticText = wx.StaticText(self, -1, "Disclosure Letter Path:",wx.DefaultPosition)
21     self.disclosureLetterPathControl = wx.TextCtrl(self,-1,disclosureLetterPath, size=(296,-1))
22     #casePathStaticText = wx.StaticText(self, -1, "Case Files Path:",wx.DefaultPosition)
23     #self.casePathControl = wx.TextCtrl(self,-1,casePath, size=(296,-1))
24     #self.casePathControl.Enable(False)
25     openDisclosureLetterButton = wx.Button(self,-1,"Open")
26     loadDisclosureLetterButton = wx.Button(self,-1,"Load Letter")
27     openRelativityTemplateButton = wx.Button(self,-1,"Relativity Template")
28     openConcordanceTemplateButtom = wx.Button(self,-1,"Concordance Template")
29     mainSizer = wx.BoxSizer(wx.VERTICAL)
30     disclosureLetterPathSizer = wx.BoxSizer(wx.HORIZONTAL)
31     disclosureLetterPathSizer.Add(disclosureLetterPathStaticText,0,wx.ALL,5)
32     disclosureLetterPathSizer.Add(self.disclosureLetterPathControl,0,wx.ALL,5)
33     disclosureLetterPathSizer.Add(openDisclosureLetterButton,0,wx.ALL,5)
34    
35     letterOptionsStaticBox = wx.StaticBox(self, -1, 'Letter Options:')
36     letterOptionsBoxSizer = wx.StaticBoxSizer(letterOptionsStaticBox, wx.HORIZONTAL)
37     letterOptionsBoxSizer.Add(loadDisclosureLetterButton,0,wx.ALL,5)
38     letterOptionsBoxSizer.Add(openRelativityTemplateButton,0,wx.ALL,5)
39     letterOptionsBoxSizer.Add(openConcordanceTemplateButtom,0,wx.ALL,5)
40    
41     #casePathSizer = wx.BoxSizer(wx.HORIZONTAL)
42     #casePathSizer.Add(casePathStaticText,0,wx.ALL,5)
43     #casePathSizer.Add(self.casePathControl,0,wx.ALL,5)
44    
45     mainSizer.Add(disclosureLetterPathSizer,0,wx.ALL, 10)
46     mainSizer.Add(letterOptionsBoxSizer,0,wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
47    
48     oKButton = wx.Button(self, wx.ID_OK)
49     oKButton.SetDefault()
50     cancelButton = wx.Button(self, wx.ID_CANCEL)
51     buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
52     buttonSizer.Add(oKButton,0,wx.ALL,5)
53     buttonSizer.Add(cancelButton,0,wx.ALL,5)
54     mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER|wx.ALL, 15)
55     self.SetSizer(mainSizer)
56    
57     self.Bind(wx.EVT_BUTTON, self.OnOpenLetter, openDisclosureLetterButton)
58     self.Bind(wx.EVT_BUTTON, self.OnLoadLetter, loadDisclosureLetterButton)
59     self.Bind(wx.EVT_BUTTON, self.OnOpenRelativityTemplate, openRelativityTemplateButton)
60     self.Bind(wx.EVT_BUTTON, self.OnOpenConcordanceTemplate, openConcordanceTemplateButtom)
61    
62     if disclosureLetterPath:
63     pass
64     else:
65     openDisclosureLetterButton.Enable(False)
66    
67     def OnOpenLetter(self,event):
68     disclosureLetterPath = self.disclosureLetterPathControl.GetValue()
69     err = False
70     if disclosureLetterPath:
71     if os.path.exists(disclosureLetterPath):
72     os.startfile(disclosureLetterPath)
73     else:
74     print "An alternate media folder for this case was not found."
75     err = True
76     else:
77     err = True
78     return err
79    
80     def OnLoadLetter(self,event):
81     dlg = wx.FileDialog(self,"Select Signed Disclosure Letter")
82     if dlg.ShowModal() == wx.ID_OK:
83     disclosureLetterPath = dlg.GetPath()
84     dlg.Destroy()
85     if os.path.exists(os.path.join(self.casePath,'Disclosure_Letter')):
86     pass
87     else:
88     os.mkdir(os.path.join(self.casePath,'Disclosure_Letter'))
89     newDisclosureLetterPath = os.path.join(os.path.join(self.casePath,'Disclosure_Letter'),os.path.split(disclosureLetterPath)[1])
90     os.rename(disclosureLetterPath,newDisclosureLetterPath)
91     if os.path.exists(newDisclosureLetterPath):
92     sucessDlg = wx.MessageDialog(self, "MCP: Disclosure letter ready to be loaded into database.", "MCP: Success",wx.OK, wx.DefaultPosition)
93     sucessDlg.ShowModal()
94     sucessDlg.Destroy()
95     self.disclosureLetterPathControl.SetValue(newDisclosureLetterPath)
96     else:
97     sucessDlg = wx.MessageDialog(self, "MCP: Disclosure letter could not be copied to case directory.", "MCP: Error!",wx.OK, wx.DefaultPosition)
98    
99     def OnOpenRelativityTemplate(self,event):
100     os.startfile(r"\\bstads01\app\Manny\MCP\DisclosureLetterTemplates\Disclosure Letter Template for Relativity.doc")
101     def OnOpenConcordanceTemplate(self,event):
102     os.startfile(r"\\bstads01\app\Manny\MCP\DisclosureLetterTemplates\Disclosure Letter template for Concordance.DOC")
103    
104    
105     def GetValues(self):
106     ## check to see if it's a drive letter. if so, convert to unc.
107     ## Do not allow local paths.
108     disclosureLetterPath = self.disclosureLetterPathControl.GetValue()
109     if os.path.splitdrive(disclosureLetterPath)[0]:
110     err = True
111     else:
112     if os.path.exists(disclosureLetterPath):
113     err = False
114     else:
115     if disclosureLetterPath == "":
116     err = False
117     else:
118     err = True
119     return disclosureLetterPath, err