source: cprs/trunk/CPRS-Chart/fAddlSigners.pas@ 1166

Last change on this file since 1166 was 830, checked in by Kevin Toppenberg, 14 years ago

Upgrading to version 27

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