source: cprs/branches/tmg-cprs/CPRS-Chart/fAddlSigners.pas@ 1797

Last change on this file since 1797 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

File size: 11.3 KB
Line 
1//kt -- Modified with SourceScanner on 7/8/2007
2unit fAddlSigners;
3
4interface
5
6uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
7 Buttons, ORCtrls, ORfn, ExtCtrls, FNoteProps,Dialogs, DKLang;
8
9type
10 TfrmAddlSigners = class(TForm)
11 cmdOK: TButton;
12 cmdCancel: TButton;
13 cboSrcList: TORComboBox;
14 DstList: TORListBox;
15 SrcLabel: TLabel;
16 DstLabel: TLabel;
17 pnlBase: TPanel;
18 cmdRemove: TButton;
19 lblAuthor: TOROffsetLabel;
20 cboCosigner: TORComboBox;
21 lblCosigner: TOROffsetLabel;
22 txtAuthor: TCaptionEdit;
23 pnlAdditional: TORAutoPanel;
24 pnlButtons: TORAutoPanel;
25 pnlTop: TORAutoPanel;
26 DKLanguageController1: TDKLanguageController;
27 procedure NewPersonNeedData(Sender: TObject; const StartFrom: String;
28 Direction, InsertAt: Integer);
29 procedure cmdOKClick(Sender: TObject);
30 procedure cmdCancelClick(Sender: TObject);
31 procedure cboSrcListMouseClick(Sender: TObject);
32 procedure cmdRemoveClick(Sender: TObject);
33 procedure FormCreate(Sender: TObject);
34 procedure FormDestroy(Sender: TObject);
35 procedure cboCosignerChange(Sender: TObject);
36 procedure DstListClick(Sender: TObject);
37 procedure cboSrcListKeyDown(Sender: TObject; var Key: Word;
38 Shift: TShiftState);
39 procedure cboCosignerNeedData(Sender: TObject; const StartFrom: String;
40 Direction, InsertAt: Integer);
41 procedure cboCosignerExit(Sender: TObject);
42 procedure cboSrcListClick(Sender: TObject);
43 private
44 FSigners: TStringList ;
45 FCosigner: int64;
46 FExclusions: TStringList;
47 FSigAction: integer;
48 FChanged: Boolean;
49 FNoteIEN: integer;
50 FRefDate: TFMDateTime;
51 FToday: string;
52 FTabID: integer;
53 //kt 7-8-07 Added variables instead of constants
54 TX_SIGNER_CAP : String; //kt added 7/8/2007
55 TX_SIGNER_TEXT : String; //kt added 7/8/2007
56 TX_BAD_SIGNER : String; //kt added 7/8/2007
57 TX_DUP_SIGNER : String; //kt added 7/8/2007
58 TX_NO_COSIGNER : String; //kt added 7/8/2007
59 TX_NO_COSIGNER_CAP : String; //kt added 7/8/2007
60 TX_NO_DELETE : String; //kt added 7/8/2007
61 TX_NO_DELETE_CAP : String; //kt added 7/8/2007
62 //kt end addition
63
64 function CosignerOK: Boolean;
65 procedure SetupVars; //kt 7-8-07 added
66 end;
67
68TSignerList = record
69 Changed: Boolean;
70 Signers: TStringList ;
71 Cosigner: int64;
72 end;
73
74procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
75 var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
76
77const
78 SG_ADDITIONAL = 1;
79 SG_COSIGNER = 2;
80 SG_BOTH = 3;
81
82implementation
83
84{$R *.DFM}
85
86uses
87 rCore, uCore, rTIU, uConst, rPCE;
88
89//const //kt 7-8-07 removed all these constants, made into vars
90//TX_SIGNER_CAP = 'Error adding signers';
91//TX_SIGNER_TEXT = 'Select signers or press Cancel.';
92//TX_BAD_SIGNER = 'Cannot select author, user, expected signer, or expected cosigner' ;
93//TX_DUP_SIGNER = 'You have already selected that additional signer';
94//TX_NO_COSIGNER = ' is not authorized to cosign this document.';
95//TX_NO_COSIGNER_CAP = 'Invalid Cosigner';
96//TX_NO_DELETE = 'A cosigner is required';
97//TX_NO_DELETE_CAP = 'No cosigner selected';
98
99
100procedure TfrmAddlSigners.SetupVars; //kt 7-8-07 added this entire function.
101begin
102 TX_SIGNER_CAP := DKLangConstW('fAddlSigners_Error_adding_signers'); //kt added 7/8/2007
103 TX_SIGNER_TEXT := DKLangConstW('fAddlSigners_Select_signers_or_press_Cancel'); //kt added 7/8/2007
104 TX_BAD_SIGNER := DKLangConstW('fAddlSigners_Cannot_select_author_user_expected_signer_or_expected_cosigner') ; //kt added 7/8/2007
105 TX_DUP_SIGNER := DKLangConstW('fAddlSigners_You_have_already_selected_that_additional_signer'); //kt added 7/8/2007
106 TX_NO_COSIGNER := DKLangConstW('fAddlSigners_is_not_authorized_to_cosign_this_document'); //kt added 7/8/2007
107 TX_NO_COSIGNER_CAP := DKLangConstW('fAddlSigners_Invalid_Cosigner'); //kt added 7/8/2007
108 TX_NO_DELETE := DKLangConstW('fAddlSigners_A_cosigner_is_required'); //kt added 7/8/2007
109 TX_NO_DELETE_CAP := DKLangConstW('fAddlSigners_No_cosigner_selected'); //kt added 7/8/2007
110end;
111
112
113procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
114 var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
115{ displays additional signer form for notes and returns a record of the selection }
116var
117 frmAddlSigners: TfrmAddlSigners;
118 W, H, i: Integer;
119begin
120 frmAddlSigners := TfrmAddlSigners.Create(Application);
121 try
122 with frmAddlSigners do
123 begin
124 FTabID := TabID;
125 FSigAction := SigAction;
126 FNoteIEN := NoteIEN;
127 FRefDate := ARefDate;
128 FExclusions.Assign(Exclusions);
129 FToday := FloatToStr(FMToday);
130 if FSigAction = SG_COSIGNER then
131 begin
132 pnlAdditional.Visible := False;
133 Height := Height - pnlAdditional.Height;
134 end;
135 Font.Size := FontSize;
136 W := ClientWidth;
137 H := ClientHeight;
138 ResizeToFont(FontSize, W, H);
139 ClientWidth := W; pnlBase.Width := W;
140 ClientHeight := H; pnlBase.Height := H;
141 with FExclusions do for i := 0 to Count-1 do
142 begin
143 if Piece(Strings[i],U,3) = 'Author' then txtAuthor.Text := Piece(Strings[i], U, 2)
144 else if Piece(Strings[i],U,3) = 'Expected Cosigner' then
145 begin
146 cboCosigner.Items.Add(Strings[i]);
147 cboCosigner.ItemIndex := 0;
148 end
149 else
150 DstList.Items.Add(Strings[i]);
151 end;
152
153 if (SigAction = SG_COSIGNER) or (SigAction = SG_BOTH) then
154 begin
155 lblCosigner.Caption := 'Expected cosigner';
156 cboCosigner.Caption := 'Expected cosigner';
157 cboCosigner.Color := clWindow;
158 cboCosigner.Enabled := True;
159 cboCosigner.InitLongList('');
160 end;
161 if (SigAction = SG_ADDITIONAL) or (SigAction = SG_BOTH) then
162 cboSrcList.InitLongList('');
163 FChanged := False;
164 ShowModal;
165 with SignerList do
166 begin
167 Signers := TStringList.Create;
168 Signers.Assign(FSigners);
169 Cosigner := FCosigner;
170 Changed := FChanged ;
171 end ;
172 end; {with frmAddlSigners}
173 finally
174 frmAddlSigners.Release;
175 end;
176end;
177
178procedure TfrmAddlSigners.NewPersonNeedData(Sender: TObject;
179 const StartFrom: String; Direction, InsertAt: Integer);
180begin
181 TORComboBox(Sender).ForDataUse(SubSetOfPersons(StartFrom, Direction));
182end;
183
184procedure TfrmAddlSigners.cmdCancelClick(Sender: TObject);
185begin
186 Close;
187end;
188
189procedure TfrmAddlSigners.cmdOKClick(Sender: TObject);
190var
191 i: integer;
192begin
193 SetupVars; //kt 7-8-07 added to establish variables to replace constants
194 FChanged := False;
195 if (FSigAction = SG_ADDITIONAL) and ((DstList.Items.Count = 0) and (FSigners.Count = 0)) then
196 begin
197 InfoBox(TX_SIGNER_TEXT, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
198 Exit;
199 end;
200 if not CosignerOK then Exit;
201 FChanged := True;
202 FCosigner := cboCosigner.ItemIEN;
203 for i := 0 to DstList.Items.Count-1 do
204 begin
205 if fExclusions.IndexOf(DstList.Items[i]) < 0 then FSigners.Add(DstList.Items[i]);
206 end;
207 Close;
208end;
209
210procedure TfrmAddlSigners.cboSrcListMouseClick(Sender: TObject);
211var
212 i: integer;
213begin
214 SetupVars; //kt 7-8-07 added to establish variables to replace constants
215 if cboSrcList.ItemIndex = -1 then exit;
216 if (DstList.SelectByID(cboSrcList.ItemID) <> -1) then
217 begin
218 InfoBox(TX_DUP_SIGNER, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
219 Exit;
220 end;
221 for i := 0 to FExclusions.Count-1 do
222 if (Piece(FExclusions.Strings[i],U,1) = cboSrcList.ItemID) then
223 begin
224 InfoBox(TX_BAD_SIGNER, TX_SIGNER_CAP, MB_OK or MB_ICONWARNING);
225 Exit;
226 end;
227 DstList.Items.Add(cboSrcList.Items[cboSrcList.Itemindex]) ;
228 cboSrcList.SelectByID(cboSrcList.ItemID);
229end;
230
231procedure TfrmAddlSigners.cmdRemoveClick(Sender: TObject);
232var
233 i,j: integer;
234begin
235 with DstList do
236 begin
237 if ItemIndex = -1 then exit ;
238 for i := Items.Count-1 downto 0 do
239 if Selected[i] then
240 begin
241 j := FExclusions.IndexOf(Items[i]);
242 FSigners.Add(ORFn.Pieces(Items[i], U, 1, 2) + '^REMOVE');
243 if j > -1 then FExclusions.Delete(j);
244 Items.Delete(i) ;
245 end;
246 end;
247end;
248
249procedure TfrmAddlSigners.cboCosignerChange(Sender: TObject);
250var
251 i: integer;
252begin
253 if UserInactive(cboCosigner.ItemID) then
254 if (InfoBox(fNoteProps.TX_USER_INACTIVE, TC_INACTIVE_USER, MB_OKCANCEL)= IDCANCEL) then exit;
255 if not CosignerOK then Exit;
256 i := DstList.SelectByID(cboCosigner.ItemID);
257 if i > -1 then
258 begin
259 DstList.Items.Delete(i);
260 FSigners.Add(ORFn.Pieces(cboCosigner.Items[cboCosigner.ItemIndex], U, 1, 2) + '^REMOVE');
261 end;
262end;
263
264procedure TfrmAddlSigners.FormCreate(Sender: TObject);
265begin
266 cboCosigner.Color := ReadOnlyColor;
267 txtAuthor.Color := ReadOnlyColor;
268 FSigners := TStringList.Create;
269 FExclusions := TStringList.Create;
270end;
271
272procedure TfrmAddlSigners.FormDestroy(Sender: TObject);
273begin
274 FSigners.Free;
275 FExclusions.Free;
276end;
277
278procedure TfrmAddlSigners.DstListClick(Sender: TObject);
279begin
280 if DstList.ItemIndex > -1 then cmdRemoveClick(Self);
281end;
282
283procedure TfrmAddlSigners.cboSrcListKeyDown(Sender: TObject; var Key: Word;
284 Shift: TShiftState);
285begin
286 if Key = VK_RETURN then cboSrcListMouseClick(Self);
287end;
288
289function TfrmAddlSigners.CosignerOK: Boolean;
290begin
291 SetupVars; //kt 7-8-07 added to establish variables to replace constants
292 Result := False;
293 if not cboCosigner.Enabled then
294 begin
295 Result := True;
296 Exit;
297 end;
298 if cboCosigner.ItemIndex < 0 then
299 begin
300 InfoBox(TX_NO_DELETE, TX_NO_DELETE_CAP, MB_OK or MB_ICONWARNING);
301 Exit;
302 end;
303 case FTabID of
304 CT_NOTES, CT_CONSULTS:
305 if (not CanCosign(TitleForNote(FNoteIEN), 0, cboCosigner.ItemIEN, FRefDate)) then
306 begin
307 InfoBox(cboCosigner.Text + TX_NO_COSIGNER, TX_NO_COSIGNER_CAP, MB_OK or MB_ICONWARNING);
308 Exit;
309 end;
310 CT_DCSUMM:
311 if not IsUserAProvider(cboCosigner.ItemIEN, FMNow) then
312 begin
313 InfoBox(cboCosigner.Text + TX_NO_COSIGNER, TX_NO_COSIGNER_CAP, MB_OK or MB_ICONWARNING);
314 Exit;
315 end;
316 end;
317 Result := True;
318end;
319
320procedure TfrmAddlSigners.cboCosignerNeedData(Sender: TObject;
321 const StartFrom: String; Direction, InsertAt: Integer);
322begin
323 case FTabID of
324 CT_NOTES: TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
325 CT_CONSULTS: TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
326 CT_DCSUMM: TORComboBox(Sender).ForDataUse(SubSetOfProviders(StartFrom, Direction));
327 end;
328end;
329
330procedure TfrmAddlSigners.cboCosignerExit(Sender: TObject);
331begin
332 with cboCosigner do if Text = '' then ItemIndex := -1;
333end;
334
335procedure TfrmAddlSigners.cboSrcListClick(Sender: TObject);
336var UserEIN:string;
337begin
338 UserEIN := Piece(cboSrcList.Items[cboSrcList.Itemindex],U,1);
339 if UserInactive(UserEIN) then
340 if (InfoBox(fNoteProps.TX_USER_INACTIVE, TC_INACTIVE_USER, MB_OKCANCEL)= IDCANCEL) then exit;
341
342end;
343
344end.
Note: See TracBrowser for help on using the repository browser.