| 1 | //kt -- Modified with SourceScanner on 8/8/2007
 | 
|---|
| 2 | unit fODAuto;
 | 
|---|
| 3 | 
 | 
|---|
| 4 | interface
 | 
|---|
| 5 | 
 | 
|---|
| 6 | uses
 | 
|---|
| 7 |   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 | 
|---|
| 8 |   fODBase, StdCtrls, ComCtrls, ExtCtrls, ORFn, ORCtrls, DKLang;
 | 
|---|
| 9 | 
 | 
|---|
| 10 | type
 | 
|---|
| 11 |   TfrmODAuto = class(TfrmODBase)
 | 
|---|
| 12 |     Label1: TLabel;
 | 
|---|
| 13 |   public
 | 
|---|
| 14 |     procedure InitDialog; override;
 | 
|---|
| 15 |     procedure SetupDialog(OrderAction: Integer; const ID: string); override;
 | 
|---|
| 16 |     procedure Validate(var AnErrMsg: string); override;
 | 
|---|
| 17 |   end;
 | 
|---|
| 18 | 
 | 
|---|
| 19 | var
 | 
|---|
| 20 |   frmODAuto: TfrmODAuto;
 | 
|---|
| 21 | 
 | 
|---|
| 22 | implementation
 | 
|---|
| 23 | 
 | 
|---|
| 24 | {$R *.DFM}
 | 
|---|
| 25 | 
 | 
|---|
| 26 | uses rODBase, rOrders, fTemplateDialog, uTemplateFields, rTemplates, uConst, uTemplates,
 | 
|---|
| 27 |      rConsults, uCore, uODBase;
 | 
|---|
| 28 | 
 | 
|---|
| 29 | procedure TfrmODAuto.InitDialog;
 | 
|---|
| 30 | begin
 | 
|---|
| 31 |   inherited;
 | 
|---|
| 32 |   // nothing for now
 | 
|---|
| 33 | end;
 | 
|---|
| 34 | 
 | 
|---|
| 35 | procedure TfrmODAuto.Validate(var AnErrMsg: string);
 | 
|---|
| 36 | var
 | 
|---|
| 37 |   cptn, tmp, DocInfo: string;
 | 
|---|
| 38 |   TempSL: TStringList;
 | 
|---|
| 39 |   LType: TTemplateLinkType;
 | 
|---|
| 40 |   IEN: integer;
 | 
|---|
| 41 |   HasObjects: boolean;
 | 
|---|
| 42 | 
 | 
|---|
| 43 | begin
 | 
|---|
| 44 |   inherited;
 | 
|---|
| 45 |   DocInfo := '';
 | 
|---|
| 46 |   LType := DisplayGroupToLinkType(Responses.DisplayGroup);
 | 
|---|
| 47 |   tmp := Responses.EValueFor('COMMENT', 1);
 | 
|---|
| 48 |   ExpandOrderObjects(tmp, HasObjects);
 | 
|---|
| 49 |   Responses.OrderContainsObjects := Responses.OrderContainsObjects or HasObjects;
 | 
|---|
| 50 |   if (LType <> ltNone) or HasTemplateField(tmp) then
 | 
|---|
| 51 |   begin
 | 
|---|
| 52 | //  cptn := 'Reason for Request: ' + Responses.EValueFor('ORDERABLE', 1);  <-- original line.  //kt 8/8/2007
 | 
|---|
| 53 |     cptn := DKLangConstW('fODAuto_Reason_for_Requestx')+' ' + Responses.EValueFor(DKLangConstW('fODAuto_ORDERABLE'), 1); //kt added 8/8/2007
 | 
|---|
| 54 |     case LType of
 | 
|---|
| 55 |       ltConsult:   IEN := StrToIntDef(GetServiceIEN(Responses.IValueFor('ORDERABLE', 1)),0);
 | 
|---|
| 56 |       ltProcedure: IEN := StrToIntDef(GetProcedureIEN(Responses.IValueFor('ORDERABLE', 1)),0);
 | 
|---|
| 57 |       else         IEN := 0;
 | 
|---|
| 58 |     end;
 | 
|---|
| 59 |     if IEN <> 0 then
 | 
|---|
| 60 |       ExecuteTemplateOrBoilerPlate(tmp, IEN, LType, nil, cptn, DocInfo)
 | 
|---|
| 61 |     else
 | 
|---|
| 62 |       CheckBoilerplate4Fields(tmp, cptn);
 | 
|---|
| 63 | 
 | 
|---|
| 64 |     if tmp <> '' then
 | 
|---|
| 65 |       Responses.Update('COMMENT', 1, TX_WPTYPE, tmp)
 | 
|---|
| 66 |     else
 | 
|---|
| 67 |     begin
 | 
|---|
| 68 |       TempSL := TStringList.Create;
 | 
|---|
| 69 |       try
 | 
|---|
| 70 |         TempSL.Text := Responses.EValueFor('COMMENT', 1);
 | 
|---|
| 71 |         Convert2LMText(TempSL);
 | 
|---|
| 72 |         Responses.Update('COMMENT', 1, TX_WPTYPE, TempSL.Text);
 | 
|---|
| 73 |       finally
 | 
|---|
| 74 |         TempSL.Free;
 | 
|---|
| 75 |       end;
 | 
|---|
| 76 |     end;
 | 
|---|
| 77 |   end;
 | 
|---|
| 78 | end;
 | 
|---|
| 79 | 
 | 
|---|
| 80 | procedure TfrmODAuto.SetupDialog(OrderAction: Integer; const ID: string);
 | 
|---|
| 81 | var
 | 
|---|
| 82 |   DialogNames: TDialogNames;
 | 
|---|
| 83 | begin
 | 
|---|
| 84 |   inherited;  // Responses is already loaded here
 | 
|---|
| 85 |   AutoAccept := True;
 | 
|---|
| 86 | //StatusText('Loading Dialog Definition');  <-- original line.  //kt 8/8/2007
 | 
|---|
| 87 |   StatusText(DKLangConstW('fODAuto_Loading_Dialog_Definition')); //kt added 8/8/2007
 | 
|---|
| 88 |   FillerID := FillerIDForDialog(DialogIEN);
 | 
|---|
| 89 |   IdentifyDialog(DialogNames, DialogIEN);
 | 
|---|
| 90 |   Responses.Dialog := DialogNames.BaseName;                      // loads formatting info
 | 
|---|
| 91 |   StatusText('');
 | 
|---|
| 92 | end;
 | 
|---|
| 93 | 
 | 
|---|
| 94 | end.
 | 
|---|