| 1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
| 2 | unit fOrdersPrint;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses
|
---|
| 7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 8 | StdCtrls, ORCtrls, ORfn, ExtCtrls, rOrders, fFrame, DKLang;
|
---|
| 9 |
|
---|
| 10 | type
|
---|
| 11 | TfrmOrdersPrint = class(TForm)
|
---|
| 12 | ckChartCopy: TCheckBox;
|
---|
| 13 | ckLabels: TCheckBox;
|
---|
| 14 | ckRequisitions: TCheckBox;
|
---|
| 15 | ckWorkCopy: TCheckBox;
|
---|
| 16 | lstChartDevice: TORListBox;
|
---|
| 17 | lstLabelDevice: TORListBox;
|
---|
| 18 | lstReqDevice: TORListBox;
|
---|
| 19 | lstWorkDevice: TORListBox;
|
---|
| 20 | cmdChart: TORAlignButton;
|
---|
| 21 | cmdLabels: TORAlignButton;
|
---|
| 22 | cmdReqs: TORAlignButton;
|
---|
| 23 | cmdWork: TORAlignButton;
|
---|
| 24 | cmdOK: TORAlignButton;
|
---|
| 25 | cmdCancel: TORAlignButton;
|
---|
| 26 | pnlBase: TORAutoPanel;
|
---|
| 27 | lblDevice: TLabel;
|
---|
| 28 | lblPartOne: TMemo;
|
---|
| 29 | lblPart2: TMemo;
|
---|
| 30 | DKLanguageController1: TDKLanguageController;
|
---|
| 31 | procedure SetupControls(PrintParams: TPrintParams);
|
---|
| 32 | procedure cmdChartClick(Sender: TObject);
|
---|
| 33 | procedure cmdLabelsClick(Sender: TObject);
|
---|
| 34 | procedure cmdReqsClick(Sender: TObject);
|
---|
| 35 | procedure cmdWorkClick(Sender: TObject);
|
---|
| 36 | procedure cmdOKClick(Sender: TObject);
|
---|
| 37 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 38 | procedure ckChartCopyClick(Sender: TObject);
|
---|
| 39 | procedure ckLabelsClick(Sender: TObject);
|
---|
| 40 | procedure ckRequisitionsClick(Sender: TObject);
|
---|
| 41 | procedure ckWorkCopyClick(Sender: TObject);
|
---|
| 42 | procedure DeviceListClick(Sender: TObject);
|
---|
| 43 | procedure FormKeyUp(Sender: TObject; var Key: Word;
|
---|
| 44 | Shift: TShiftState);
|
---|
| 45 | private
|
---|
| 46 | FPrintIt: boolean;
|
---|
| 47 | FSelectAll: boolean;
|
---|
| 48 | FDevices: string;
|
---|
| 49 | FNature: char;
|
---|
| 50 | procedure SetupPrompting(CheckBox: TCheckBox; DeviceList: TORListBox; ChangeButton: TORAlignButton;
|
---|
| 51 | PromptParam: char; DeviceParam: string);
|
---|
| 52 | end;
|
---|
| 53 |
|
---|
| 54 | var
|
---|
| 55 | frmOrdersPrint: TfrmOrdersPrint;
|
---|
| 56 | PrintParams: TPrintParams;
|
---|
| 57 | AnyPrompts: boolean;
|
---|
| 58 | ResultList: TStringList;
|
---|
| 59 |
|
---|
| 60 | const
|
---|
| 61 | NO_WIN_PRINT = False;
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | procedure SetupOrdersPrint(OrderList: TStringList; var DeviceInfo: string; Nature: Char; SelectAll: Boolean; var PrintIt: Boolean);
|
---|
| 66 |
|
---|
| 67 | implementation
|
---|
| 68 |
|
---|
| 69 | {$R *.DFM}
|
---|
| 70 |
|
---|
| 71 | uses
|
---|
| 72 | fDeviceSelect, uCore, ORNet, fOrders;
|
---|
| 73 |
|
---|
| 74 | procedure SetupOrdersPrint(OrderList: TStringList; var DeviceInfo: string; Nature: Char; SelectAll: Boolean; var PrintIt: Boolean);
|
---|
| 75 | {displays device and copy selection form for printing orders, and returns a record of the selections}
|
---|
| 76 | var
|
---|
| 77 | frmOrdersPrint: TfrmOrdersPrint;
|
---|
| 78 | begin
|
---|
| 79 | frmOrdersPrint := TfrmOrdersPrint.Create(Application);
|
---|
| 80 | try
|
---|
| 81 | frmFrame.CCOWBusy := True;
|
---|
| 82 | ResizeFormToFont(TForm(frmOrdersPrint));
|
---|
| 83 | with frmOrdersPrint do
|
---|
| 84 | begin
|
---|
| 85 | FSelectAll := SelectAll;
|
---|
| 86 | FPrintIt := False;
|
---|
| 87 | FNature := Nature;
|
---|
| 88 | if Nature = #0 then
|
---|
| 89 | begin
|
---|
| 90 | // cmdCancel.Caption := 'Cancel Print'; <-- original line. //kt 8/8/2007
|
---|
| 91 | cmdCancel.Caption := DKLangConstW('fOrdersPrint_Cancel_Print'); //kt added 8/8/2007
|
---|
| 92 | // lblPart2.Text := 'Greyed out items are not available.'; <-- original line. //kt 8/8/2007
|
---|
| 93 | lblPart2.Text := DKLangConstW('fOrdersPrint_Greyed_out_items_are_not_availablex'); //kt added 8/8/2007
|
---|
| 94 | end;
|
---|
| 95 | OrderPrintDeviceInfo(OrderList, PrintParams, Nature);
|
---|
| 96 | SetupControls(PrintParams);
|
---|
| 97 | if (PrintParams.AnyPrompts) {or FSelectAll} then ShowModal;
|
---|
| 98 | DeviceInfo := FDevices;
|
---|
| 99 | PrintIt := FPrintIt;
|
---|
| 100 | end;
|
---|
| 101 | finally
|
---|
| 102 | frmFrame.CCOWBusy := False;
|
---|
| 103 | frmOrdersPrint.Release;
|
---|
| 104 | end;
|
---|
| 105 | end;
|
---|
| 106 |
|
---|
| 107 | procedure TfrmOrdersPrint.SetupControls(PrintParams: TPrintParams);
|
---|
| 108 | begin
|
---|
| 109 | with PrintParams do
|
---|
| 110 | begin
|
---|
| 111 | SetupPrompting(ckChartCopy , lstChartDevice, cmdChart , PromptForChartCopy , ChartCopyDevice);
|
---|
| 112 | SetupPrompting(ckLabels , lstLabelDevice, cmdLabels, PromptForLabels , LabelDevice);
|
---|
| 113 | SetupPrompting(ckRequisitions, lstReqDevice, cmdReqs , PromptForRequisitions, RequisitionDevice);
|
---|
| 114 | SetupPrompting(ckWorkCopy , lstWorkDevice, cmdWork , PromptForWorkCopy , WorkCopyDevice);
|
---|
| 115 | FDevices := lstChartDevice.ItemID + U +
|
---|
| 116 | lstLabelDevice.ItemID + U +
|
---|
| 117 | lstReqDevice.ItemID + U +
|
---|
| 118 | lstWorkDevice.ItemID;
|
---|
| 119 | FPrintIt := not (FDevices = '^^^');
|
---|
| 120 | end;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | procedure TfrmOrdersPrint.SetupPrompting(CheckBox: TCheckBox; DeviceList: TORListBox; ChangeButton: TORAlignButton;
|
---|
| 124 | PromptParam: char; DeviceParam: string);
|
---|
| 125 | { 0 - no prompts - copy is automatically generated.
|
---|
| 126 | checkbox checked and disabled, device defaulted and button disabled
|
---|
| 127 | 1 - prompt for copy and ask which printer should be used.
|
---|
| 128 | checkbox unchecked and enabled, device defaulted and button enabled
|
---|
| 129 | 2 - prompt for copy and automatically print to the
|
---|
| 130 | printer defined in the XXXXX COPY PRINT DEVICE field.
|
---|
| 131 | checkbox unchecked and enabled, device defaulted and button disabled
|
---|
| 132 | * - don't print.
|
---|
| 133 | checkbox unchecked and disabled, device empty and button disabled
|
---|
| 134 | }
|
---|
| 135 | begin
|
---|
| 136 | case PromptParam of
|
---|
| 137 | '0', #0: begin
|
---|
| 138 | CheckBox.Checked := DeviceParam <> '';
|
---|
| 139 | CheckBox.Enabled := False;
|
---|
| 140 | DeviceList.Clear;
|
---|
| 141 | if DeviceParam <> '' then
|
---|
| 142 | begin
|
---|
| 143 | DeviceList.Items.Add(DeviceParam);
|
---|
| 144 | DeviceList.Font.Color := clGrayText;
|
---|
| 145 | DeviceList.ItemIndex := 0;
|
---|
| 146 | CheckBox.Font.Style := CheckBox.Font.Style + [fsBold];
|
---|
| 147 | CheckBox.Font.Color := clInfoText;
|
---|
| 148 | CheckBox.Color := clInfoBk;
|
---|
| 149 | end
|
---|
| 150 | else
|
---|
| 151 | begin
|
---|
| 152 | CheckBox.State := cbUnchecked;
|
---|
| 153 | CheckBox.Enabled := False;
|
---|
| 154 | end;
|
---|
| 155 | ChangeButton.Enabled := False;
|
---|
| 156 | end;
|
---|
| 157 | '1': begin
|
---|
| 158 | CheckBox.State := cbUnchecked;
|
---|
| 159 | CheckBox.Enabled := True;
|
---|
| 160 | DeviceList.Clear;
|
---|
| 161 | if DeviceParam <> '' then DeviceList.Items.Add(DeviceParam);
|
---|
| 162 | ChangeButton.Enabled := False;
|
---|
| 163 | end;
|
---|
| 164 | '2': begin
|
---|
| 165 | CheckBox.State := cbUnchecked;
|
---|
| 166 | CheckBox.Enabled := True;
|
---|
| 167 | DeviceList.Clear;
|
---|
| 168 | if DeviceParam <> '' then
|
---|
| 169 | DeviceList.Items.Add(DeviceParam)
|
---|
| 170 | else
|
---|
| 171 | begin
|
---|
| 172 | CheckBox.State := cbUnchecked;
|
---|
| 173 | CheckBox.Enabled := False;
|
---|
| 174 | end;
|
---|
| 175 | ChangeButton.Enabled := False;
|
---|
| 176 | end;
|
---|
| 177 | '*': begin
|
---|
| 178 | CheckBox.State := cbUnchecked;
|
---|
| 179 | CheckBox.Enabled := False;
|
---|
| 180 | DeviceList.Clear;
|
---|
| 181 | ChangeButton.Enabled := False;
|
---|
| 182 | end;
|
---|
| 183 | end;
|
---|
| 184 | end;
|
---|
| 185 |
|
---|
| 186 | procedure TfrmOrdersPrint.cmdChartClick(Sender: TObject);
|
---|
| 187 | var
|
---|
| 188 | x: string;
|
---|
| 189 | begin
|
---|
| 190 | x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
|
---|
| 191 | if x <> '' then with lstChartDevice do
|
---|
| 192 | begin
|
---|
| 193 | Clear;
|
---|
| 194 | Items.Add(x);
|
---|
| 195 | end;
|
---|
| 196 | end;
|
---|
| 197 |
|
---|
| 198 | procedure TfrmOrdersPrint.cmdLabelsClick(Sender: TObject);
|
---|
| 199 | var
|
---|
| 200 | x: string;
|
---|
| 201 | begin
|
---|
| 202 | x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
|
---|
| 203 | if x <> '' then with lstLabelDevice do
|
---|
| 204 | begin
|
---|
| 205 | Clear;
|
---|
| 206 | Items.Add(x);
|
---|
| 207 | end;
|
---|
| 208 | end;
|
---|
| 209 |
|
---|
| 210 | procedure TfrmOrdersPrint.cmdReqsClick(Sender: TObject);
|
---|
| 211 | var
|
---|
| 212 | x: string;
|
---|
| 213 | begin
|
---|
| 214 | x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
|
---|
| 215 | if x <> '' then with lstReqDevice do
|
---|
| 216 | begin
|
---|
| 217 | Clear;
|
---|
| 218 | Items.Add(x);
|
---|
| 219 | end;
|
---|
| 220 | end;
|
---|
| 221 |
|
---|
| 222 | procedure TfrmOrdersPrint.cmdWorkClick(Sender: TObject);
|
---|
| 223 | var
|
---|
| 224 | x: string;
|
---|
| 225 | begin
|
---|
| 226 | x := SelectDevice(Self, Encounter.Location, NO_WIN_PRINT,'');
|
---|
| 227 | if x <> '' then with lstWorkDevice do
|
---|
| 228 | begin
|
---|
| 229 | Clear;
|
---|
| 230 | Items.Add(x);
|
---|
| 231 | end;
|
---|
| 232 | end;
|
---|
| 233 |
|
---|
| 234 | procedure TfrmOrdersPrint.cmdOKClick(Sender: TObject);
|
---|
| 235 | //const
|
---|
| 236 | //TX_NO_SELECTION = 'No copies were selected for printing. Check a copy type, or Cancel.'; <-- original line. //kt 8/8/2007
|
---|
| 237 | //TX_NO_SELECTION_CAP = 'Nothing Selected!'; <-- original line. //kt 8/8/2007
|
---|
| 238 | var
|
---|
| 239 | TX_NO_SELECTION : string; //kt
|
---|
| 240 | TX_NO_SELECTION_CAP : string; //kt
|
---|
| 241 | begin
|
---|
| 242 | TX_NO_SELECTION := DKLangConstW('fOrdersPrint_No_copies_were_selected_for_printingx__Check_a_copy_typex_or_Cancelx'); //kt added 8/8/2007
|
---|
| 243 | TX_NO_SELECTION_CAP := DKLangConstW('fOrdersPrint_Nothing_Selectedx'); //kt added 8/8/2007
|
---|
| 244 |
|
---|
| 245 | if not ckChartCopy.Checked then lstChartDevice.ItemIndex := -1 else lstChartDevice.ItemIndex := 0;
|
---|
| 246 | if not ckLabels.Checked then lstLabelDevice.ItemIndex := -1 else lstLabelDevice.ItemIndex := 0;
|
---|
| 247 | if not ckRequisitions.Checked then lstReqDevice.ItemIndex := -1 else lstReqDevice.ItemIndex := 0;
|
---|
| 248 | if not ckWorkCopy.Checked then lstWorkDevice.ItemIndex := -1 else lstWorkDevice.ItemIndex := 0;
|
---|
| 249 | FDevices := Piece(lstChartDevice.ItemID, ';', 1) + U +
|
---|
| 250 | Piece(lstLabelDevice.ItemID, ';', 1) + U +
|
---|
| 251 | Piece(lstReqDevice.ItemID, ';', 1) + U +
|
---|
| 252 | Piece(lstWorkDevice.ItemID, ';', 1);
|
---|
| 253 | if FDevices = '^^^' then
|
---|
| 254 | begin
|
---|
| 255 | FPrintIt := False;
|
---|
| 256 | InfoBox(TX_NO_SELECTION, TX_NO_SELECTION_CAP, MB_OK)
|
---|
| 257 | end
|
---|
| 258 | else
|
---|
| 259 | begin
|
---|
| 260 | FPrintIt := True;
|
---|
| 261 | Close;
|
---|
| 262 | end;
|
---|
| 263 | end;
|
---|
| 264 |
|
---|
| 265 | procedure TfrmOrdersPrint.cmdCancelClick(Sender: TObject);
|
---|
| 266 | // Force autoprint of 'don't prompt' items, regardless of continue/cancel selection.
|
---|
| 267 | begin
|
---|
| 268 | if FNature = #0 then FDevices := '^^^'
|
---|
| 269 | else with PrintParams do
|
---|
| 270 | begin
|
---|
| 271 | if (PromptForChartCopy = '0') or (PromptForChartCopy = #0) then
|
---|
| 272 | begin
|
---|
| 273 | if not ckChartCopy.Checked then lstChartDevice.ItemIndex := -1
|
---|
| 274 | else lstChartDevice.ItemIndex := 0;
|
---|
| 275 | end
|
---|
| 276 | else lstChartDevice.ItemIndex := -1;
|
---|
| 277 |
|
---|
| 278 | if (PromptForLabels = '0') or (PromptForLabels = #0) then
|
---|
| 279 | begin
|
---|
| 280 | if not ckLabels.Checked then lstLabelDevice.ItemIndex := -1
|
---|
| 281 | else lstLabelDevice.ItemIndex := 0;
|
---|
| 282 | end
|
---|
| 283 | else lstLabelDevice.ItemIndex := -1;
|
---|
| 284 |
|
---|
| 285 | if (PromptForRequisitions = '0') or (PromptForRequisitions = #0) then
|
---|
| 286 | begin
|
---|
| 287 | if not ckRequisitions.Checked then lstReqDevice.ItemIndex := -1
|
---|
| 288 | else lstReqDevice.ItemIndex := 0;
|
---|
| 289 | end
|
---|
| 290 | else lstReqDevice.ItemIndex := -1;
|
---|
| 291 |
|
---|
| 292 | if (PromptForWorkCopy = '0') or (PromptForWorkCopy = #0) then
|
---|
| 293 | begin
|
---|
| 294 | if not ckWorkCopy.Checked then lstWorkDevice.ItemIndex := -1
|
---|
| 295 | else lstWorkDevice.ItemIndex := 0;
|
---|
| 296 | end
|
---|
| 297 | else lstWorkDevice.ItemIndex := -1;
|
---|
| 298 |
|
---|
| 299 | FDevices := Piece(lstChartDevice.ItemID, ';', 1) + U +
|
---|
| 300 | Piece(lstLabelDevice.ItemID, ';', 1) + U +
|
---|
| 301 | Piece(lstReqDevice.ItemID, ';', 1) + U +
|
---|
| 302 | Piece(lstWorkDevice.ItemID, ';', 1);
|
---|
| 303 | end;
|
---|
| 304 |
|
---|
| 305 | FPrintIt := (FDevices <> '^^^');
|
---|
| 306 | Close;
|
---|
| 307 | end;
|
---|
| 308 |
|
---|
| 309 | procedure TfrmOrdersPrint.ckChartCopyClick(Sender: TObject);
|
---|
| 310 | begin
|
---|
| 311 | cmdChart.Enabled := (ckChartCopy.Checked) and (PrintParams.PromptForChartCopy <> '2');
|
---|
| 312 | end;
|
---|
| 313 |
|
---|
| 314 | procedure TfrmOrdersPrint.ckLabelsClick(Sender: TObject);
|
---|
| 315 | begin
|
---|
| 316 | cmdLabels.Enabled := (ckLabels.Checked) and (PrintParams.PromptForLabels <> '2');
|
---|
| 317 | end;
|
---|
| 318 |
|
---|
| 319 | procedure TfrmOrdersPrint.ckRequisitionsClick(Sender: TObject);
|
---|
| 320 | begin
|
---|
| 321 | cmdReqs.Enabled := (ckRequisitions.Checked) and (PrintParams.PromptForRequisitions <> '2');
|
---|
| 322 | end;
|
---|
| 323 |
|
---|
| 324 | procedure TfrmOrdersPrint.ckWorkCopyClick(Sender: TObject);
|
---|
| 325 | begin
|
---|
| 326 | cmdWork.Enabled := (ckWorkCopy.Checked) and (PrintParams.PromptForWorkCopy <> '2');
|
---|
| 327 | end;
|
---|
| 328 |
|
---|
| 329 | procedure TfrmOrdersPrint.DeviceListClick(Sender: TObject);
|
---|
| 330 | begin
|
---|
| 331 | TORListBox(Sender).ItemIndex := -1;
|
---|
| 332 | end;
|
---|
| 333 |
|
---|
| 334 | procedure TfrmOrdersPrint.FormKeyUp(Sender: TObject; var Key: Word;
|
---|
| 335 | Shift: TShiftState);
|
---|
| 336 | begin
|
---|
| 337 | if Key = VK_ESCAPE then
|
---|
| 338 | begin
|
---|
| 339 | Key := 0;
|
---|
| 340 | Close;
|
---|
| 341 | end;
|
---|
| 342 | end;
|
---|
| 343 |
|
---|
| 344 | end.
|
---|
| 345 |
|
---|