source: cprs/branches/foia-cprs/CPRS-Chart/fAddlSigners.pas@ 1688

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

Uploading from OR_30_258

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