Commit 9f3d6ebb by Cam Hayes

Prototype of KG Orders to be deployed

parent 22f237d7
......@@ -992,7 +992,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Height = 25
Caption = 'PDF'
ChildOrder = 77
ElementID = 'btnedit'
ElementID = 'btnpdf'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnPDFClick
......
......@@ -306,7 +306,7 @@
<button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button>
</div>
<div class="col-auto">
<button id="btnedit" class="btn btn-primary btn-sm float-end my-2">Edit</button>
<button id="btnpdf" class="btn btn-primary btn-sm float-end my-2">PDF</button>
</div>
</div>
</div>
......
......@@ -288,6 +288,18 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
ListField = 'name'
ListSource = wdsQBItem
end
object btnPDF: TWebButton
Left = 710
Top = 610
Width = 96
Height = 25
Caption = 'PDF'
ChildOrder = 77
ElementID = 'btnpdf'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnPDFClick
end
object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1
Left = 22
......
......@@ -86,5 +86,8 @@
<div class="col-auto">
<button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button>
</div>
<div class="col-auto">
<button id="btnpdf" class="btn btn-primary btn-sm float-end my-2">PDF</button>
</div>
</div>
</div>
......@@ -64,6 +64,7 @@ type
xdwdsQBItem: TXDataWebDataSet;
xdwdsQBItemname: TStringField;
wcbQBItem: TWebDBComboBox;
btnPDF: TWebButton;
procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject);
......@@ -74,6 +75,8 @@ type
[async] procedure GetCustomer(customerID: string);
procedure tmrScrollTopTimer(Sender: TObject);
[async] procedure AddCuttingDieOrder(orderJSON: TJSONObject);
procedure btnPDFClick(Sender: TObject);
[async] procedure GenerateReportPDF;
private
FAgencyCode: string;
FCurrentReportType: string;
......@@ -138,7 +141,7 @@ begin
XDataWebDataSet1.Next;
end;
orderJSON.AddPair('COMPANY_ID', customerID);
orderJSON.AddPair('USER_ID', '1011');
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
orderJSON.AddPair('mode', mode);
if mode = 'EDIT' then
orderJSON.AddPair('ORDER_ID', orderID);
......@@ -148,6 +151,30 @@ begin
FViewMain.ViewOrders('Success');
end;
procedure TFOrderEntryCuttingDie.btnPDFClick(Sender: TObject);
begin
GenerateReportPDF;
end;
[async] procedure TFOrderEntryCuttingDie.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results
var
xdcResponse: TXDataClientResponse;
searchOptions, pdfURL: string;
jsObject: TJSObject;
begin
// Call the server method to generate the PDF
console.log(orderID);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderCuttingPDF', [orderID]));
jsObject := JS.TJSObject(xdcResponse.Result);
pdfURL := JS.toString(jsObject.Properties['value']);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window.open(pdfURL, '_blank');
end;
procedure TFOrderEntryCuttingDie.AddCuttingDieOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server
var
......
......@@ -1107,6 +1107,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
ElementID = 'btncancel'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object wcbQBItem: TWebDBComboBox
Left = 26
......
......@@ -349,6 +349,7 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window.open(pdfURL, '_blank');
console.log(pdfURL);
end;
procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject);
......
......@@ -126,6 +126,9 @@ uses
procedure TFViewOrders.btnPDFClick(Sender: TObject);
begin
asm
startSpinner();
end;
GenerateReportPDF;
end;
......@@ -146,6 +149,9 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window.open(pdfURL, '_blank');
asm
endSpinner();
end;
end;
......@@ -310,6 +316,7 @@ procedure TFViewOrders.ShowSetStatusForm();
var
newform: TFSetStatus;
begin
console.log('set status');
newform := TFSetStatus.CreateNew;
newform.Caption := 'Input Search Options';
......@@ -317,10 +324,24 @@ begin
newForm.Border := fbDialog;
newForm.OrderID := OrderID;
newForm.JobName := wdbtcOrders.Cells[2, row];
newForm.ShipDue := StrToDateTime(wdbtcOrders.Cells[13, row]);
newForm.MountDue := StrToDateTime(wdbtcOrders.Cells[11, row]);
newForm.PlateDue := StrToDateTime(wdbtcOrders.Cells[9, row]);
newForm.ArtDue := StrToDateTime(wdbtcOrders.Cells[7, row]);
if wdbtcOrders.Cells[13, row] <> '' then
newForm.ShipDue := StrToDateTime(wdbtcOrders.Cells[13, row])
else
newForm.MountDue := 0;
if wdbtcOrders.Cells[11, row] <> '' then
newForm.MountDue := StrToDateTime(wdbtcOrders.Cells[11, row])
else
newForm.MountDue := 0;
if wdbtcOrders.Cells[9, row] <> '' then
newForm.PlateDue := StrToDateTime(wdbtcOrders.Cells[9, row])
else
newForm.PlateDue := 0;
if wdbtcOrders.Cells[7, row] <> '' then
newForm.ArtDue := StrToDateTime(wdbtcOrders.Cells[7, row])
else
newForm.ArtDue := 0 ;
newForm.OrderType := OrderType;
console.log(OrderType);
// used to manage Back button handling to close subform
window.location.hash := 'subform';
......@@ -372,6 +393,7 @@ procedure TFViewOrders.wdbtcOrdersClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
OrderID := wdbtcOrders.Cells[0, ARow];
OrderType := wdbtcOrders.Cells[3, ARow];
row := ARow;
end;
......
......@@ -219,49 +219,6 @@ object FSearch: TFSearch
ParentFont = False
WidthPercent = 100.000000000000000000
end
object pnlMessage: TWebPanel
Left = 92
Top = 637
Width = 121
Height = 33
ElementClassName = 'card'
ElementID = 'pnl_message'
ChildOrder = 5
ElementBodyClassName = 'card-body'
ElementFont = efCSS
ElementPosition = epRelative
Role = 'alert'
TabOrder = 0
object lblMessage: TWebLabel
Left = 26
Top = 11
Width = 44
Height = 14
Caption = 'Message'
ElementID = 'pnl_message'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCloseNotification: TWebButton
Left = 96
Top = 3
Width = 22
Height = 25
ChildOrder = 1
ElementClassName = 'btn btn-light'
ElementID = 'view.login.message.button'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Role = 'button'
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
end
end
object wcbFilterType1: TWebComboBox
Left = 8
Top = 462
......@@ -393,6 +350,7 @@ object FSearch: TFSearch
Items.Strings = (
'Corrugated'
'Web'
'Cutting Die'
'Any')
end
object wcbFilterType2: TWebComboBox
......@@ -472,7 +430,7 @@ object FSearch: TFSearch
Height = 233
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 12
TabOrder = 11
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 4
......
......@@ -17,9 +17,6 @@ uses
type
TFSearch = class(TWebForm)
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
wcbFilterType1: TWebComboBox;
btnConfirm: TWebButton;
edtOrderID: TWebEdit;
......
......@@ -92,7 +92,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel6: TWebLabel
object lblMount: TWebLabel
Left = 324
Top = 200
Width = 62
......@@ -107,7 +107,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel7: TWebLabel
object lblMountNew: TWebLabel
Left = 482
Top = 200
Width = 78
......@@ -122,7 +122,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel8: TWebLabel
object lblPlate: TWebLabel
Left = 11
Top = 200
Width = 54
......@@ -137,7 +137,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel9: TWebLabel
object lblPlateNew: TWebLabel
Left = 169
Top = 200
Width = 78
......@@ -152,7 +152,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel10: TWebLabel
object lblArt: TWebLabel
Left = 324
Top = 142
Width = 44
......@@ -167,7 +167,7 @@ object FSetStatus: TFSetStatus
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel11: TWebLabel
object lblArtNew: TWebLabel
Left = 482
Top = 142
Width = 78
......@@ -226,8 +226,8 @@ object FSetStatus: TFSetStatus
Text = ''
end
object btnConfirm: TWebButton
Left = 25
Top = 323
Left = 14
Top = 273
Width = 96
Height = 25
Caption = 'Confirm'
......@@ -242,8 +242,8 @@ object FSetStatus: TFSetStatus
OnClick = btnConfirmClick
end
object btnCancel: TWebButton
Left = 147
Top = 323
Left = 125
Top = 273
Width = 96
Height = 25
Caption = 'Cancel'
......
......@@ -24,17 +24,17 @@ type
dtpShipDue: TWebDateTimePicker;
WebLabel5: TWebLabel;
dtpNewShipDue: TWebDateTimePicker;
WebLabel6: TWebLabel;
lblMount: TWebLabel;
dtpMountDue: TWebDateTimePicker;
WebLabel7: TWebLabel;
lblMountNew: TWebLabel;
dtpNewMountDue: TWebDateTimePicker;
WebLabel8: TWebLabel;
lblPlate: TWebLabel;
dtpPlateDue: TWebDateTimePicker;
WebLabel9: TWebLabel;
lblPlateNew: TWebLabel;
dtpNewPlateDue: TWebDateTimePicker;
WebLabel10: TWebLabel;
lblArt: TWebLabel;
dtpArtDue: TWebDateTimePicker;
WebLabel11: TWebLabel;
lblArtNew: TWebLabel;
dtpNewArtDue: TWebDateTimePicker;
procedure WebFormShow(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
......@@ -46,7 +46,7 @@ type
public
{ Public declarations }
confirm: boolean;
OrderID, JobName: string;
OrderID, JobName, OrderType: string;
ShipDue, MountDue, PlateDue, ArtDue: TDateTime;
end;
......@@ -66,6 +66,10 @@ procedure TFSetStatus.btnConfirmClick(Sender: TObject);
begin
if ( (dtpDate.Date = 0 ) or ( wlcbStatus.value = '' ) ) then
ShowNotification('Failure:Please fill in all information')
else if ( ( OrderType = 'web plate' ) and ( wlcbStatus.Value = 'MOUNT' ) ) then
ShowNotification('Failure:Web Plate Orders do not have Mount Due/Done dates')
else if ( ( OrderType = 'cutting die' ) and ( wlcbStatus.Value = 'MOUNT' ) or ( wlcbStatus.Value = 'ART' ) or (wlcbStatus.Value = 'PLATE') ) then
ShowNotification('Failure:Cutting Die Orders do not have Art/Plate/Mount Due or Done Dates')
else
begin
confirm := true;
......@@ -87,6 +91,34 @@ begin
dtpNewMountDue.Date := 0;
dtpNewPlateDue.Date := 0;
dtpNewArtDue.Date := 0;
if orderType = 'web plate' then
begin
dtpNewMountDue.Visible := false;
dtpMountDue.Visible := false;
lblMount.Visible := false;
lblMountNew.Visible := false;
end
else if orderType = 'cutting die' then
begin
dtpNewMountDue.Visible := false;
dtpMountDue.Visible := false;
lblMount.Visible := false;
lblMountNew.Visible := false;
dtpPlateDue.Visible := false;
dtpNewPlateDue.Visible := false;
lblPlate.Visible := false;
lblPlateNew.Visible := false;
dtpArtDue.Visible := false;
dtpNewArtDue.Visible := false;
lblArt.Visible := false;
lblArtNew.Visible := false;
end;
end;
procedure TFSetStatus.HideNotification;
......
......@@ -43,8 +43,6 @@ object FData: TFData
Lines.Strings = (
'Memo1')
TabOrder = 1
ExplicitLeft = -2
ExplicitTop = 435
end
object DBAdvGrid1: TDBAdvGrid
Left = 6
......@@ -632,10 +630,10 @@ object FData: TFData
Top = 237
Width = 985
Height = 199
ColCount = 20
ColCount = 22
DrawingStyle = gdsClassic
FixedColor = clWhite
RowCount = 2
RowCount = 101
FixedRows = 1
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goFixedRowDefAlign]
TabOrder = 3
......@@ -791,7 +789,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'account_sid'
FieldName = 'price'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -817,7 +815,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'api_version'
EditLength = 16
FieldName = 'Loc'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -843,7 +842,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'call_sid'
EditLength = 90
FieldName = 'COMPANY_NAME'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -869,7 +869,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'conference_sid'
EditLength = 128
FieldName = 'JOB_NAME'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -895,7 +896,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'date_created'
FieldName = 'ORDER_DATE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -921,7 +922,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'date_updated'
EditLength = 45
FieldName = 'ORDER_TYPE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -947,7 +949,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'start_time'
FieldName = 'PROOF_DUE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -973,7 +975,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'duration'
FieldName = 'PROOF_DONE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -999,7 +1001,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'sid'
FieldName = 'ART_DUE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1025,7 +1027,59 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'price'
FieldName = 'ART_DONE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
HeaderFont.Charset = DEFAULT_CHARSET
HeaderFont.Color = 3881787
HeaderFont.Height = -12
HeaderFont.Name = 'Segoe UI'
HeaderFont.Style = []
PrintBorders = [cbTop, cbLeft, cbRight, cbBottom]
PrintFont.Charset = DEFAULT_CHARSET
PrintFont.Color = clWindowText
PrintFont.Height = -12
PrintFont.Name = 'Segoe UI'
PrintFont.Style = []
Width = 64
end
item
Borders = []
BorderPen.Color = clSilver
ButtonHeight = 18
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'PLATE_DUE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
HeaderFont.Charset = DEFAULT_CHARSET
HeaderFont.Color = 3881787
HeaderFont.Height = -12
HeaderFont.Name = 'Segoe UI'
HeaderFont.Style = []
PrintBorders = [cbTop, cbLeft, cbRight, cbBottom]
PrintFont.Charset = DEFAULT_CHARSET
PrintFont.Color = clWindowText
PrintFont.Height = -12
PrintFont.Name = 'Segoe UI'
PrintFont.Style = []
Width = 64
end
item
Borders = []
BorderPen.Color = clSilver
ButtonHeight = 18
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'PLATE_DONE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1051,7 +1105,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'price_unit'
FieldName = 'MOUNT_DUE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1077,7 +1131,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'status'
FieldName = 'MOUNT_DONE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1103,7 +1157,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'channels'
FieldName = 'SHIP_DUE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1129,7 +1183,7 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'source'
FieldName = 'SHIP_DONE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1149,13 +1203,14 @@ object FData: TFData
Width = 64
end
item
Alignment = taRightJustify
Borders = []
BorderPen.Color = clSilver
ButtonHeight = 18
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'error_code'
FieldName = 'PRICE'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1181,7 +1236,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'uri'
EditLength = 24
FieldName = 'QB_REF_NUM'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1207,7 +1263,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'encryption_details'
EditLength = 3
FieldName = 'COLORS'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1233,7 +1290,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'media_url'
EditLength = 16
FieldName = 'po_number'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1259,7 +1317,8 @@ object FData: TFData
CheckFalse = 'N'
CheckTrue = 'Y'
Color = clWindow
FieldName = 'transcription'
EditLength = 45
FieldName = 'quickbooks_item'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
......@@ -1436,9 +1495,110 @@ object FData: TFData
64
64
64
64
64
64)
RowHeights = (
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22
22)
end
object edtUsername: TEdit
......@@ -1526,6 +1686,7 @@ object FData: TFData
Top = 472
end
object uqUsers: TUniQuery
Connection = ucKG
SQL.Strings = (
'select * from users')
Left = 669
......
......@@ -176,11 +176,11 @@ var
begin
for Field in uqWeb.Fields do
begin
SQL := 'SELECT ORDER_ID, ORDER_DATE, ' + Field.AsString + ' LENGTH( ' + Field.AsString +
SQL := 'SELECT ORDER_ID, ORDER_DATE, ' + Field.FieldName + ', LENGTH( ' + Field.FieldName +
') AS max_length FROM web_plate_orders ORDER BY max_length DESC LIMIT 1';
doQuery(uqUsers, SQL);
memo1.Lines.Add(Field.AsString + ', ' + uqUsers.FieldByName('ORDER_ID').AsString +
', ' + uqUsers.FieldByName('ORDER_DATE').AsString +', ' + uqUsers.FieldByName('max_length').AsString);
memo1.Lines.Add(Field.FieldName + ', ' + uqUsers.FieldByName('ORDER_ID').AsString +
', ' + uqUsers.FieldByName('max_length').AsString + ', ' + uqUsers.FieldByName('ORDER_DATE').AsString);
end;
end;
......@@ -209,7 +209,7 @@ var
begin
rptOrderList := TrptOrderList.Create(nil);
try
rptOrderList.PrepareReport(searchOptions);
rptOrderList.PrepareReport(searchOptions, '');
dsGrid2.DataSet := rptOrderList.uqOrders;
finally
rptOrderList.Free;
......
......@@ -372,6 +372,7 @@ type
[HttpGet] function GenerateOrderListPDF(searchOptions: string): string;
[HttpGet] function GenerateOrderCorrugatedPDF(orderID: string): string;
[HttpGet] function GenerateOrderWebPDF(orderID: string): string;
[HttpGet] function GenerateOrderCuttingPDF(orderID: string): string;
function AddUser(userInfo: string): string;
......
......@@ -42,6 +42,7 @@ type
function GenerateOrderListPDF(searchOptions: string): string;
function GenerateOrderCorrugatedPDF(orderID: string): string;
function GenerateOrderWebPDF(orderID: string): string;
function GenerateOrderCuttingPDF(orderID: string): string;
function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string;
......@@ -68,7 +69,7 @@ implementation
uses
System.Generics.Collections,
XData.Sys.Exceptions, uLibrary, rOrderWeb;
XData.Sys.Exceptions, uLibrary, rOrderWeb, rOrderCutting;
procedure TLookupService.AfterConstruction;
begin
......@@ -152,11 +153,28 @@ function TLookupService.GenerateOrderListPDF(searchOptions: string): string;
var
SQL: string;
rptOrderList: TrptOrderList; // Local instance of rptOrders
CompanyID, CompanyName: string;
params: TStringList;
begin
rptOrderList := TrptOrderList.Create(nil);
try
params := TStringList.Create;
params.StrictDelimiter := true;
// parse the searchOptions
params.Delimiter := '&';
params.DelimitedText := searchOptions;
companyID := params.Values['companyID'];
if companyID <> '' then
begin
SQL := 'Select NAME from customers c where CUSTOMER_ID = ' + companyID;
doQuery(ordersDB.UniQuery1, SQL);
CompanyName := 'Company: ' + ordersDB.UniQuery1.FieldByName('NAME').AsString;
end
else
CompanyName := '';
SQL := GenerateOrdersSQL(searchOptions).SQL;
result := rptOrderList.PrepareReport(SQL);
result := rptOrderList.PrepareReport(SQL, CompanyName);
//rptOrderList.GeneratePDF;
......@@ -196,7 +214,8 @@ begin
rptOrderWeb := TrptOrderWeb.Create(nil);
try
// Generate SQL query for a single order
SQL := 'SELECT * FROM web_plate_orders WHERE ORDER_ID = ' + orderID;
//SQL := 'SELECT * FROM web_plate_orders w WHERE w.ORDER_ID = ' + orderID ;
SQL := 'SELECT * FROM web_plate_orders w LEFT JOIN qb_sales_orders q ON w.ORDER_ID = q.ORDER_ID WHERE w.ORDER_ID = ' + orderID ;
// Prepare the report with the query
Result := rptOrderWeb.PrepareReport(SQL);
......@@ -208,6 +227,26 @@ begin
end;
end;
function TLookupService.GenerateOrderCuttingPDF(orderID: string): string;
var
SQL: string;
rptOrderCutting: TrptOrderCutting; // Local instance of the report
begin
rptOrderCutting := TrptOrderCutting.Create(nil);
try
// Generate SQL query for a single order
SQL := 'SELECT * FROM cutting_die_orders WHERE ORDER_ID = ' + orderID;
// Prepare the report with the query
Result := rptOrderCutting.PrepareReport(SQL);
// Optionally log success
Logger.Log(5, 'PDF Report successfully generated for order ID: ' + orderID);
finally
rptOrderCutting.Free;
end;
end;
function TLookupService.generateSubQuery(currStatus: string): string;
// Generates the subquery in order to retrieve all the status due/done dates
......@@ -379,7 +418,29 @@ begin
offset := IntToStr((PageNum - 1) * PageSize);
limit := IntToStr(PageSize);
SQL := 'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, ';
{ SQL := 'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, ' +
'o.ORDER_DATE, o.ORDER_TYPE, oss_proof.STATUS_DATE AS PROOF_DUE, oss_art.STATUS_DATE AS ART_DUE, ' +
'oss_plate.STATUS_DATE AS PLATE_DUE, oss_mount.STATUS_DATE AS MOUNT_DUE, oss_ship.STATUS_DATE AS SHIP_DUE, ' +
'os_proof.STATUS_DATE AS PROOF_DONE, os_art.STATUS_DATE AS ART_DONE, os_plate.STATUS_DATE AS PLATE_DONE, ' +
'os_mount.STATUS_DATE AS MOUNT_DONE, os_ship.STATUS_DATE AS SHIP_DONE, ' +
'o.PRICE, qb.QB_REF_NUM, coalesce( cpo.staff_fields_po_number, wpo.staff_fields_po_number, cdo.staff_fields_po_number ) AS po_number, ' +
'coalesce( cpo.staff_fields_quickbooks_item, wpo.staff_fields_quickbooks_item, cdo.staff_fields_quickbooks_item ) AS quickbooks_item ' +
'FROM orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID LEFT JOIN qb_sales_orders qb ON qb.ORDER_ID = o.ORDER_ID ' +
'LEFT JOIN ORDERS_status_schedule oss_proof ON o.ORDER_ID = oss_proof.Order_id AND oss_proof.order_status = ' + quotedStr('PROOF') +
' LEFT JOIN ORDERS_status_schedule oss_art ON o.ORDER_ID = oss_art.Order_id AND oss_art.order_status = ' + quotedStr('ART') +
' LEFT JOIN orders_status_schedule oss_plate ON o.ORDER_ID = oss_plate.Order_id AND oss_plate.order_status = ' + quotedStr('PLATE') +
' LEFT JOIN orders_status_schedule oss_mount ON o.ORDER_ID = oss_mount.Order_id AND oss_mount.order_status = ' + quotedStr('MOUNT') +
' LEFT JOIN orders_status_schedule oss_ship ON o.ORDER_ID = oss_ship.Order_id AND oss_ship.order_status = ' + quotedStr('SHIP') +
'LEFT JOIN ORDERS_status os_proof ON o.ORDER_ID = os_proof.Order_id AND os_proof.order_status = ' + quotedStr('PROOF') +
' LEFT JOIN ORDERS_status os_art ON o.ORDER_ID = os_art.Order_id AND os_art.order_status = ' + quotedStr('ART') +
' LEFT JOIN orders_status os_plate ON o.ORDER_ID = os_plate.Order_id AND os_plate.order_status = ' + quotedStr('PLATE') +
' LEFT JOIN orders_status os_mount ON o.ORDER_ID = os_mount.Order_id AND os_mount.order_status = ' + quotedStr('MOUNT') +
' LEFT JOIN orders_status os_ship ON o.ORDER_ID = os_ship.Order_id AND os_ship.order_status = ' + quotedStr('SHIP') +
' LEFT JOIN corrugated_plate_orders cpo ON o.ORDER_ID = cpo.ORDER_ID ' +
'LEFT JOIN web_plate_orders wpo ON o.ORDER_ID = wpo.ORDER_ID ' +
'LEFT JOIN cutting_die_orders cdo ON o.ORDER_ID = cdo.ORDER_ID '; }
SQL := 'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, ';
// Generate the subqueries that get the Status Dates(Due and Done)
SQL := SQL + generateSubquery('PROOF');
......@@ -390,7 +451,10 @@ begin
// Generate the Where SQL based on if there is a status filter applied or not
whereSQL := 'from orders o join customers c on ' +
'c.CUSTOMER_ID = o.COMPANY_ID left join qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID where 0 = 0';
'c.CUSTOMER_ID = o.COMPANY_ID left join qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID ' +
' LEFT JOIN corrugated_plate_orders cpo ON o.ORDER_ID = cpo.ORDER_ID ' +
'LEFT JOIN web_plate_orders wpo ON o.ORDER_ID = wpo.ORDER_ID ' +
'LEFT JOIN cutting_die_orders cdo ON o.ORDER_ID = cdo.ORDER_ID where 0 = 0';
if ( ( status1.filterType <> '' ) and ( status1.filterType <> 'NONE' ) ) then
whereSQL := whereSQL + generateStatusWhereSQL(status1);
......@@ -399,7 +463,12 @@ begin
whereSQL := whereSQL + generateStatusWhereSQL(status2);
if ( ( orderType <> '' ) and ( orderType <> 'any' ) ) then
whereSQL := whereSQL + ' AND o.ORDER_TYPE = ' + quotedStr(orderType + '_plate');
begin
if ( orderType <> 'cutting die') then
whereSQL := whereSQL + ' AND o.ORDER_TYPE = ' + quotedStr(orderType + '_plate')
else
whereSQL := whereSQL + ' AND o.ORDER_TYPE = ' + quotedStr('cutting_die');
end;
if orderID <> '' then
whereSQL := whereSQL + ' AND o.ORDER_ID = ' + orderID;
......@@ -414,7 +483,10 @@ begin
orderBySQL := 'ORDER BY ' + OrderBy;
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' ' + orderBySQL + ' LIMIT ' + limit + ' OFFSET ' + offset;
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM, ' +
'coalesce( cpo.staff_fields_po_number, wpo.staff_fields_po_number, cdo.staff_fields_po_number ) AS po_number, ' +
'coalesce( cpo.staff_fields_quickbooks_item, wpo.staff_fields_quickbooks_item, cdo.staff_fields_quickbooks_item ) AS quickbooks_item ' +
whereSQL + ' ' + orderBySQL + ' LIMIT ' + limit + ' OFFSET ' + offset;
// send the SQL and whereSQL back. whereSQL is needed to get the total count.
......
unit rOrderCutting;
interface
uses
System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging,
frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON,
frxTableObject, frxUtils;
type
TrptOrderCutting = class(TDataModule)
ucKG: TUniConnection;
frxPDFExport1: TfrxPDFExport;
frxDBOrderCutting: TfrxDBDataset;
frxOrderCutting: TfrxReport;
uqOrderCutting: TUniQuery;
uqOrderCuttingORDER_ID: TIntegerField;
uqOrderCuttingCOMPANY_ID: TIntegerField;
uqOrderCuttingUSER_ID: TIntegerField;
uqOrderCuttingORDER_DATE: TDateTimeField;
uqOrderCuttingstaff_fields_order_date: TDateField;
uqOrderCuttingstaff_fields_proof_date: TDateField;
uqOrderCuttingstaff_fields_ship_date: TDateField;
uqOrderCuttingstaff_fields_ship_via: TStringField;
uqOrderCuttingstaff_fields_quantity: TStringField;
uqOrderCuttingstaff_fields_price: TStringField;
uqOrderCuttingstaff_fields_invoice_to: TStringField;
uqOrderCuttingstaff_fields_ship_to: TStringField;
uqOrderCuttingstaff_fields_po_number: TStringField;
uqOrderCuttingstaff_fields_job_name: TStringField;
uqOrderCuttingstaff_fields_quickbooks_item: TStringField;
uqOrderCuttinggeneral_special_instructions: TStringField;
private
{ Private declarations }
public
{ Public declarations }
function PrepareReport(SQL: string): string;
function GeneratePDF: string;
end;
var
rptOrderCutting: TrptOrderCutting;
implementation
uses
uLibrary, Common.Config;
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
function TrptOrderCutting.PrepareReport(SQL: string): string;
var
orderList : TJSObject;
i: integer;
data: TJSArray;
order: TJSObject;
callListLength: integer;
tempString, strColorList: string;
colorObject: TJSONObject;
colorList: TJSArray;
colorLength: integer;
color: TJSObject;
colorJSON: TJSONObject;
colorListJSON: TJSONArray;
items: TJSObject;
begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
//SQL := 'select * from corrugated_plate_orders where ORDER_ID = 18381';
doQuery(uqOrderCutting, SQL);
result := GeneratePDF;
Logger.Log(3, 'Report preparation complete.');
end;
function TrptOrderCutting.GeneratePDF: string;
var
ReportDir, ReportFileName: string;
reportURL: string;
begin
ReportDir := ServerConfig.reportsFolder;
if not DirectoryExists(ReportDir) then
begin
ForceDirectories(ReportDir);
Logger.Log(5, 'Reports directory created: ' + ReportDir);
end;
reportURL := 'reports\' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.pdf';
ReportFileName := reportDir + reportUrl;
frxPDFExport1.FileName := ReportFileName;
frxPDFExport1.ShowDialog := False;
try
frxOrderCutting.PrepareReport;
frxOrderCutting.Export(frxPDFExport1);
//frxOrders.ShowPreparedReport;
finally
frxOrderCutting.Clear; // Clears the report to avoid memory bloat
end;
Logger.Log(5, 'PDF saved to: ' + ReportFileName);
result := reportURL;
end;
end.
......@@ -3,9 +3,9 @@ unit rOrderList;
interface
uses
System.SysUtils, System.Classes, frxClass, frxExportBaseDialog, frxExportPDF,
Data.DB, DBAccess, Uni, UniProvider, MySQLUniProvider, System.IniFiles, Vcl.Forms,
MemDS, frxDBSet, frxTableObject, frCoreClasses, Common.Logging, System.IOUtils, JSON;
System.SysUtils, System.Classes, Data.DB, MemDS, DBAccess, Uni, Common.Logging,
frxClass, frxExportBaseDialog, frxExportPDF, frCoreClasses, frxDBSet, JS, JSON,
frxTableObject, frxUtils, DateUtils;
type
TrptOrderList = class(TDataModule)
......@@ -34,6 +34,14 @@ type
uqOrdersQB_REF_NUM: TStringField;
uqOrdersCOLORS: TStringField;
uqColors: TUniQuery;
uqOrderspo_number: TStringField;
uqOrdersquickbooks_item: TStringField;
uqOrdersNEW_ORDER_DATE: TStringField;
uqOrdersNEW_PROOF_DONE: TStringField;
uqOrdersNEW_ART_DONE: TStringField;
uqOrdersNEW_PLATE_DONE: TStringField;
uqOrdersNEW_MOUNT_DONE: TStringField;
uqOrdersNEW_SHIP_DONE: TStringField;
procedure DataModuleCreate(Sender: TObject);
procedure uqOrdersCalcFields(DataSet: TDataSet);
......@@ -41,7 +49,7 @@ type
function getColorCount(colors: string): string;
public
function PrepareReport(SQL: string): string;
function PrepareReport(SQL, CompanyName: string): string;
function GeneratePDF: string;
end;
......@@ -72,7 +80,12 @@ begin
end;
function TrptOrderList.PrepareReport(SQL: string): string;
function TrptOrderList.PrepareReport(SQL, CompanyName: string): string;
var
memo: TFrxMemoView;
temp: TDateTime;
DateFormat: TFormatSettings;
tempStr: string;
begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
......@@ -80,6 +93,23 @@ begin
uqOrders.SQL.Text := SQL;
uqOrders.Open;
uqOrders.Edit;
memo := frxOrderList.FindObject('CompanyName') as TFrxMemoView;
memo.Text := CompanyName;
DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'mm/dd/yyyy';
DateFormat.DateSeparator := '/';
DateFormat.TimeSeparator := ':';
DateFormat.ShortTimeFormat := 'HH:nn';
tempStr := FormatDateTime('m/d/yyyy HH:nn', uqOrdersORDER_DATE.AsDateTime);
temp := StrToDateTime(FormatDateTime('m/d/yyyy HH:nn', uqOrdersORDER_DATE.AsDateTime), DateFormat);
uqOrdersORDER_DATE.AsDateTime := RecodeSecond(uqOrdersORDER_DATE.AsDateTime, 0);
uqOrders.Post;
//FormatDateTime('yyyy-mm-dd hh:nn', myDate);
result := GeneratePDF;
......@@ -116,6 +146,36 @@ begin
finally
uqColors.Close; // Ensure it is closed
end;
if uqOrdersORDER_DATE.AsString <> '' then
uqOrdersNEW_ORDER_DATE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersORDER_DATE.AsDateTime)
else
uqOrdersNEW_ORDER_DATE.AsString := '';
if uqOrdersPROOF_DONE.AsString <> '' then
uqOrdersNEW_PROOF_DONE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersPROOF_DONE.AsDateTime)
else
uqOrdersNEW_PROOF_DONE.AsString := '';
if uqOrdersART_DONE.AsString <> '' then
uqOrdersNEW_ART_DONE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersART_DONE.AsDateTime)
else
uqOrdersNEW_ART_DONE.AsString := '';
if uqOrdersPLATE_DONE.AsString <> '' then
uqOrdersNEW_PLATE_DONE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersPLATE_DONE.AsDateTime)
else
uqOrdersNEW_PLATE_DONE.AsString := '';
if uqOrdersMOUNT_DONE.AsString <> '' then
uqOrdersNEW_MOUNT_DONE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersMOUNT_DONE.AsDateTime)
else
uqOrdersNEW_MOUNT_DONE.AsString := '';
if uqOrdersSHIP_DONE.AsString <> '' then
uqOrdersNEW_SHIP_DONE.AsString := FormatDateTime('m/d/yyyy HH:nn', uqOrdersSHIP_DONE.AsDateTime)
else
uqOrdersNEW_SHIP_DONE.AsString := '';
end;
//create new field called color count
......
......@@ -99,14 +99,6 @@ type
uqOrderWebupc_distortion_percent: TStringField;
uqOrderWebupc_distortion_amount: TStringField;
uqOrderWebstaff_fields_art_location: TStringField;
uqOrderWebqb_sales_orders_id: TLongWordField;
uqOrderWebORDER_ID_1: TLongWordField;
uqOrderWebORDER_REVISION_ID: TLongWordField;
uqOrderWebQB_TXN_NUM: TStringField;
uqOrderWebQB_EDIT_SEQ: TStringField;
uqOrderWebORDER_TYPE: TStringField;
uqOrderWebCREATE_TIME: TDateTimeField;
uqOrderWebQB_TXN_ID: TStringField;
uqOrderWebQB_REF_NUM: TStringField;
private
{ Private declarations }
......@@ -212,7 +204,7 @@ begin
try
frxOrderWeb.PrepareReport;
frxOrderWeb.Export(frxPDFExport1);
//frxOrders.ShowPreparedReport;
//frxOrderWeb.ShowPreparedReport;
finally
frxOrderWeb.Clear; // Clears the report to avoid memory bloat
end;
......
......@@ -24,7 +24,8 @@ uses
Data in 'Source\Data.pas' {FData},
rOrderList in 'Source\rOrderList.pas' {rptOrderList: TDataModule},
rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule},
rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule};
rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule},
rOrderCutting in 'Source\rOrderCutting.pas' {rptOrderCutting: TDataModule};
type
TMemoLogAppender = class( TInterfacedObject, ILogAppender )
......
......@@ -180,6 +180,11 @@
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<DCCReference Include="Source\rOrderCutting.pas">
<Form>rptOrderCutting</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
......
[Settings]
MemoLogLevel=4
FileLogLevel=5
LogFileNum=221
LogFileNum=303
webClientVersion=1.0.0
[Database]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment