[456] | 1 | unit fAddlSigners;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
|
---|
[830] | 6 | Buttons, ORCtrls, ORfn, ExtCtrls, FNoteProps, Dialogs, fBase508Form,
|
---|
| 7 | VA508AccessibilityManager;
|
---|
[456] | 8 |
|
---|
| 9 | type
|
---|
[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);
|
---|
| 33 | procedure cboSrcListMouseClick(Sender: TObject);
|
---|
[830] | 34 | procedure btnRemoveSignersClick(Sender: TObject);
|
---|
[456] | 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);
|
---|
[830] | 44 | procedure DstListChange(Sender: TObject);
|
---|
| 45 | procedure btnRemoveAllSignersClick(Sender: TObject);
|
---|
| 46 | procedure cboSrcListChange(Sender: TObject);
|
---|
[456] | 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;
|
---|
[830] | 58 |
|
---|
[456] | 59 | end;
|
---|
| 60 |
|
---|
| 61 | TSignerList = record
|
---|
| 62 | Changed: Boolean;
|
---|
| 63 | Signers: TStringList ;
|
---|
| 64 | Cosigner: int64;
|
---|
| 65 | end;
|
---|
| 66 |
|
---|
| 67 | procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
|
---|
| 68 | var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
|
---|
| 69 |
|
---|
| 70 | const
|
---|
| 71 | SG_ADDITIONAL = 1;
|
---|
| 72 | SG_COSIGNER = 2;
|
---|
| 73 | SG_BOTH = 3;
|
---|
| 74 |
|
---|
| 75 | implementation
|
---|
| 76 |
|
---|
| 77 | {$R *.DFM}
|
---|
| 78 |
|
---|
| 79 | uses
|
---|
[830] | 80 | rCore, uCore, rTIU, uConst, rPCE, fDCSumm;
|
---|
[456] | 81 |
|
---|
| 82 | const
|
---|
| 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 |
|
---|
| 93 | procedure 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 }
|
---|
| 96 | var
|
---|
| 97 | frmAddlSigners: TfrmAddlSigners;
|
---|
| 98 | W, H, i: Integer;
|
---|
| 99 | begin
|
---|
| 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;
|
---|
[830] | 108 | FastAssign(Exclusions, FExclusions);
|
---|
[456] | 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
|
---|
[830] | 130 | begin
|
---|
[456] | 131 | DstList.Items.Add(Strings[i]);
|
---|
[830] | 132 | btnRemoveAllSigners.Enabled := DstList.Items.Count > 0;
|
---|
| 133 | end;
|
---|
[456] | 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;
|
---|
[830] | 151 | FastAssign(FSigners, Signers);
|
---|
[456] | 152 | Cosigner := FCosigner;
|
---|
| 153 | Changed := FChanged ;
|
---|
| 154 | end ;
|
---|
| 155 | end; {with frmAddlSigners}
|
---|
| 156 | finally
|
---|
| 157 | frmAddlSigners.Release;
|
---|
| 158 | end;
|
---|
| 159 | end;
|
---|
| 160 |
|
---|
| 161 | procedure TfrmAddlSigners.NewPersonNeedData(Sender: TObject;
|
---|
| 162 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 163 | begin
|
---|
| 164 | TORComboBox(Sender).ForDataUse(SubSetOfPersons(StartFrom, Direction));
|
---|
| 165 | end;
|
---|
| 166 |
|
---|
| 167 | procedure TfrmAddlSigners.cmdCancelClick(Sender: TObject);
|
---|
| 168 | begin
|
---|
| 169 | Close;
|
---|
| 170 | end;
|
---|
| 171 |
|
---|
| 172 | procedure TfrmAddlSigners.cmdOKClick(Sender: TObject);
|
---|
| 173 | var
|
---|
| 174 | i: integer;
|
---|
| 175 | begin
|
---|
| 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;
|
---|
| 190 | end;
|
---|
| 191 |
|
---|
| 192 | procedure TfrmAddlSigners.cboSrcListMouseClick(Sender: TObject);
|
---|
| 193 | var
|
---|
| 194 | i: integer;
|
---|
| 195 | begin
|
---|
| 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]) ;
|
---|
[830] | 209 | btnRemoveSigners.Enabled := DstList.SelCount > 0;
|
---|
| 210 | btnRemoveAllSigners.Enabled := DstList.Items.Count > 0;
|
---|
| 211 |
|
---|
[456] | 212 | end;
|
---|
| 213 |
|
---|
[830] | 214 | procedure TfrmAddlSigners.btnRemoveAllSignersClick(Sender: TObject);
|
---|
| 215 | begin
|
---|
| 216 | inherited;
|
---|
| 217 | DstList.SelectAll;
|
---|
| 218 | btnRemoveSignersClick(self);
|
---|
| 219 | end;
|
---|
| 220 |
|
---|
| 221 | procedure TfrmAddlSigners.btnRemoveSignersClick(Sender: TObject);
|
---|
[456] | 222 | var
|
---|
| 223 | i,j: integer;
|
---|
| 224 | begin
|
---|
| 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;
|
---|
| 237 | end;
|
---|
| 238 |
|
---|
[830] | 239 | procedure TfrmAddlSigners.btnAddSignersClick(Sender: TObject);
|
---|
| 240 | begin
|
---|
| 241 | inherited;
|
---|
| 242 | cboSrcListMouseClick(btnAddSigners);
|
---|
| 243 | end;
|
---|
| 244 |
|
---|
[456] | 245 | procedure TfrmAddlSigners.cboCosignerChange(Sender: TObject);
|
---|
| 246 | var
|
---|
| 247 | i: integer;
|
---|
| 248 | begin
|
---|
[830] | 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
|
---|
[456] | 256 | begin
|
---|
| 257 | DstList.Items.Delete(i);
|
---|
[830] | 258 | FSigners.Add(ORFn.Pieces(Items[ItemIndex], U, 1, 2) + '^REMOVE');
|
---|
[456] | 259 | end;
|
---|
[830] | 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;
|
---|
[456] | 264 | end;
|
---|
| 265 |
|
---|
| 266 | procedure TfrmAddlSigners.FormCreate(Sender: TObject);
|
---|
| 267 | begin
|
---|
| 268 | FSigners := TStringList.Create;
|
---|
| 269 | FExclusions := TStringList.Create;
|
---|
| 270 | end;
|
---|
| 271 |
|
---|
| 272 | procedure TfrmAddlSigners.FormDestroy(Sender: TObject);
|
---|
| 273 | begin
|
---|
| 274 | FSigners.Free;
|
---|
| 275 | FExclusions.Free;
|
---|
| 276 | end;
|
---|
| 277 |
|
---|
[830] | 278 | procedure TfrmAddlSigners.DstListChange(Sender: TObject);
|
---|
[456] | 279 | begin
|
---|
[830] | 280 | inherited;
|
---|
| 281 | if 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;
|
---|
[456] | 290 | end;
|
---|
| 291 |
|
---|
| 292 | procedure TfrmAddlSigners.cboSrcListKeyDown(Sender: TObject; var Key: Word;
|
---|
| 293 | Shift: TShiftState);
|
---|
| 294 | begin
|
---|
| 295 | if Key = VK_RETURN then cboSrcListMouseClick(Self);
|
---|
| 296 | end;
|
---|
| 297 |
|
---|
| 298 | function TfrmAddlSigners.CosignerOK: Boolean;
|
---|
| 299 | begin
|
---|
| 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;
|
---|
| 326 | end;
|
---|
| 327 |
|
---|
| 328 | procedure TfrmAddlSigners.cboCosignerNeedData(Sender: TObject;
|
---|
| 329 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 330 | begin
|
---|
| 331 | case FTabID of
|
---|
| 332 | CT_NOTES: TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
|
---|
| 333 | CT_CONSULTS: TORComboBox(Sender).ForDataUse(SubSetOfUsersWithClass(StartFrom, Direction, FToday));
|
---|
[830] | 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 |
|
---|
[456] | 339 | end;
|
---|
| 340 | end;
|
---|
| 341 |
|
---|
| 342 | procedure TfrmAddlSigners.cboCosignerExit(Sender: TObject);
|
---|
| 343 | begin
|
---|
| 344 | with cboCosigner do if Text = '' then ItemIndex := -1;
|
---|
| 345 | end;
|
---|
| 346 |
|
---|
[830] | 347 | procedure TfrmAddlSigners.cboSrcListChange(Sender: TObject);
|
---|
| 348 | begin
|
---|
| 349 | inherited;
|
---|
| 350 | btnAddSigners.Enabled := CboSrcList.ItemIndex > -1;
|
---|
| 351 | end;
|
---|
| 352 |
|
---|
[456] | 353 | procedure TfrmAddlSigners.cboSrcListClick(Sender: TObject);
|
---|
| 354 | begin
|
---|
[830] | 355 | if UserInactive(cboSrcList.ItemID) then
|
---|
| 356 | if (InfoBox(fNoteProps.TX_USER_INACTIVE, TC_INACTIVE_USER, MB_OKCANCEL)= IDCANCEL) then exit;
|
---|
[456] | 357 |
|
---|
| 358 | end;
|
---|
| 359 |
|
---|
| 360 | end.
|
---|