[453] | 1 | //kt -- Modified with SourceScanner on 7/8/2007
|
---|
| 2 | unit fAddlSigners;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
|
---|
| 7 | Buttons, ORCtrls, ORfn, ExtCtrls, FNoteProps,Dialogs, DKLang;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 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 |
|
---|
| 68 | TSignerList = record
|
---|
| 69 | Changed: Boolean;
|
---|
| 70 | Signers: TStringList ;
|
---|
| 71 | Cosigner: int64;
|
---|
| 72 | end;
|
---|
| 73 |
|
---|
| 74 | procedure SelectAdditionalSigners(FontSize, NoteIEN, SigAction: Integer; Exclusions: TStrings;
|
---|
| 75 | var SignerList: TSignerList; TabID: integer; ARefDate: TFMDateTime) ;
|
---|
| 76 |
|
---|
| 77 | const
|
---|
| 78 | SG_ADDITIONAL = 1;
|
---|
| 79 | SG_COSIGNER = 2;
|
---|
| 80 | SG_BOTH = 3;
|
---|
| 81 |
|
---|
| 82 | implementation
|
---|
| 83 |
|
---|
| 84 | {$R *.DFM}
|
---|
| 85 |
|
---|
| 86 | uses
|
---|
| 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 |
|
---|
| 100 | procedure TfrmAddlSigners.SetupVars; //kt 7-8-07 added this entire function.
|
---|
| 101 | begin
|
---|
| 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
|
---|
| 110 | end;
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | procedure 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 }
|
---|
| 116 | var
|
---|
| 117 | frmAddlSigners: TfrmAddlSigners;
|
---|
| 118 | W, H, i: Integer;
|
---|
| 119 | begin
|
---|
| 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;
|
---|
| 176 | end;
|
---|
| 177 |
|
---|
| 178 | procedure TfrmAddlSigners.NewPersonNeedData(Sender: TObject;
|
---|
| 179 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 180 | begin
|
---|
| 181 | TORComboBox(Sender).ForDataUse(SubSetOfPersons(StartFrom, Direction));
|
---|
| 182 | end;
|
---|
| 183 |
|
---|
| 184 | procedure TfrmAddlSigners.cmdCancelClick(Sender: TObject);
|
---|
| 185 | begin
|
---|
| 186 | Close;
|
---|
| 187 | end;
|
---|
| 188 |
|
---|
| 189 | procedure TfrmAddlSigners.cmdOKClick(Sender: TObject);
|
---|
| 190 | var
|
---|
| 191 | i: integer;
|
---|
| 192 | begin
|
---|
| 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;
|
---|
| 208 | end;
|
---|
| 209 |
|
---|
| 210 | procedure TfrmAddlSigners.cboSrcListMouseClick(Sender: TObject);
|
---|
| 211 | var
|
---|
| 212 | i: integer;
|
---|
| 213 | begin
|
---|
| 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);
|
---|
| 229 | end;
|
---|
| 230 |
|
---|
| 231 | procedure TfrmAddlSigners.cmdRemoveClick(Sender: TObject);
|
---|
| 232 | var
|
---|
| 233 | i,j: integer;
|
---|
| 234 | begin
|
---|
| 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;
|
---|
| 247 | end;
|
---|
| 248 |
|
---|
| 249 | procedure TfrmAddlSigners.cboCosignerChange(Sender: TObject);
|
---|
| 250 | var
|
---|
| 251 | i: integer;
|
---|
| 252 | begin
|
---|
| 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;
|
---|
| 262 | end;
|
---|
| 263 |
|
---|
| 264 | procedure TfrmAddlSigners.FormCreate(Sender: TObject);
|
---|
| 265 | begin
|
---|
| 266 | cboCosigner.Color := ReadOnlyColor;
|
---|
| 267 | txtAuthor.Color := ReadOnlyColor;
|
---|
| 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 |
|
---|
| 278 | procedure TfrmAddlSigners.DstListClick(Sender: TObject);
|
---|
| 279 | begin
|
---|
| 280 | if DstList.ItemIndex > -1 then cmdRemoveClick(Self);
|
---|
| 281 | end;
|
---|
| 282 |
|
---|
| 283 | procedure TfrmAddlSigners.cboSrcListKeyDown(Sender: TObject; var Key: Word;
|
---|
| 284 | Shift: TShiftState);
|
---|
| 285 | begin
|
---|
| 286 | if Key = VK_RETURN then cboSrcListMouseClick(Self);
|
---|
| 287 | end;
|
---|
| 288 |
|
---|
| 289 | function TfrmAddlSigners.CosignerOK: Boolean;
|
---|
| 290 | begin
|
---|
| 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;
|
---|
| 318 | end;
|
---|
| 319 |
|
---|
| 320 | procedure TfrmAddlSigners.cboCosignerNeedData(Sender: TObject;
|
---|
| 321 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
| 322 | begin
|
---|
| 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;
|
---|
| 328 | end;
|
---|
| 329 |
|
---|
| 330 | procedure TfrmAddlSigners.cboCosignerExit(Sender: TObject);
|
---|
| 331 | begin
|
---|
| 332 | with cboCosigner do if Text = '' then ItemIndex := -1;
|
---|
| 333 | end;
|
---|
| 334 |
|
---|
| 335 | procedure TfrmAddlSigners.cboSrcListClick(Sender: TObject);
|
---|
| 336 | var UserEIN:string;
|
---|
| 337 | begin
|
---|
| 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 |
|
---|
| 342 | end;
|
---|
| 343 |
|
---|
| 344 | end.
|
---|