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

Last change on this file since 1751 was 1679, checked in by healthsevak, 10 years ago

Updating the working copy to CPRS version 28

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