Commit d00a993f by Cam Hayes

Most of Order Entry is finished on every page now beginning to work on tracking changes

parent 9bbaf56d
...@@ -1173,6 +1173,29 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1173,6 +1173,29 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCloseClick OnClick = btnCloseClick
end end
object edtOrderNum: TWebEdit
Left = 126
Top = 194
Width = 121
Height = 22
ChildOrder = 81
ElementID = 'edtordernum'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btn_confirm_delete: TWebButton
Left = 1094
Top = 414
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 82
ElementID = 'btn_confirm_delete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btn_confirm_deleteClick
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 1014 Left = 1014
...@@ -1185,7 +1208,6 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1185,7 +1208,6 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 256 Top = 256
end end
object XDataWebDataSet1: TXDataWebDataSet object XDataWebDataSet1: TXDataWebDataSet
AfterEdit = XDataWebDataSet1AfterEdit
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 1060 Left = 1060
Top = 182 Top = 182
...@@ -1478,11 +1500,12 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1478,11 +1500,12 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
end end
object WebDataSource1: TWebDataSource object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1 DataSet = XDataWebDataSet1
Left = 1170 Left = 1176
Top = 192 Top = 182
end end
object wdsShipTo: TWebDataSource object wdsShipTo: TWebDataSource
DataSet = xdwdsShipTo DataSet = xdwdsShipTo
OnDataChange = wdsShipToDataChange
Left = 1090 Left = 1090
Top = 124 Top = 124
end end
...@@ -1495,6 +1518,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1495,6 +1518,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
end end
object wdsQBItem: TWebDataSource object wdsQBItem: TWebDataSource
DataSet = xdwdsQBItem DataSet = xdwdsQBItem
OnDataChange = wdsQBItemDataChange
Left = 1172 Left = 1172
Top = 128 Top = 128
end end
...@@ -1505,4 +1529,10 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1505,4 +1529,10 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
FieldName = 'name' FieldName = 'name'
end end
end end
object tmrReturn: TWebTimer
Enabled = False
OnTimer = tmrReturnTimer
Left = 308
Top = 124
end
end end
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Num:</label>
<input id="edtordernum" class="form-control input-sm" style="width: 100px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label>
<input class="form-control input-sm" id="dtporderdate" type="date"> <input class="form-control input-sm" id="dtporderdate" type="date">
</div> </div>
...@@ -324,3 +328,25 @@ ...@@ -324,3 +328,25 @@
</div> </div>
</div> </div>
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmation_modal_label">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete this order?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
<style>
.modal-backdrop {
opacity: 0 !important;
}
</style>
...@@ -197,6 +197,9 @@ type ...@@ -197,6 +197,9 @@ type
btnCopy: TWebButton; btnCopy: TWebButton;
btnDelete: TWebButton; btnDelete: TWebButton;
btnClose: TWebButton; btnClose: TWebButton;
edtOrderNum: TWebEdit;
btn_confirm_delete: TWebButton;
tmrReturn: TWebTimer;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
...@@ -214,10 +217,14 @@ type ...@@ -214,10 +217,14 @@ type
procedure btnPDFClick(Sender: TObject); procedure btnPDFClick(Sender: TObject);
procedure btnCopyClick(Sender: TObject); procedure btnCopyClick(Sender: TObject);
procedure sendOrderToServer(); procedure sendOrderToServer();
procedure XDataWebDataSet1AfterEdit(DataSet: TDataSet);
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject); procedure btnCloseNotificationClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject);
procedure wdsShipToDataChange(Sender: TObject; Field: TField);
procedure wdsQBItemDataChange(Sender: TObject; Field: TField);
procedure btn_confirm_deleteClick(Sender: TObject);
procedure tmrReturnTimer(Sender: TObject);
function VerifyOrder(): boolean;
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -377,21 +384,61 @@ begin ...@@ -377,21 +384,61 @@ begin
if mode = 'ADD' then if mode = 'ADD' then
ShowNotification('Success:Order Added Successfully!') ShowNotification('Success:Order Added Successfully!')
else else
ShowNotification('Success:Order Edited Successfully') ShowNotification('Success:Order Edited Successfully');
AddCorrugatedOrder(orderJSON);
end; end;
procedure TFOrderEntryCorrugated.btnConfirmClick(Sender: TObject); procedure TFOrderEntryCorrugated.btnConfirmClick(Sender: TObject);
// Converts all the information on the page into a JSON to then send to the server // Converts all the information on the page into a JSON to then send to the server
begin begin
if VerifyOrder() then
begin
sendOrderToServer(); sendOrderToServer();
btnPDF.Enabled := true;
btnDelete.Enabled := true;
end;
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
function TFOrderEntryCorrugated.VerifyOrder: Boolean;
begin
result := true;
if edtCompanyName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Name');
window.scrollTo(0,0);
result := false;
end;
if edtCompanyAccountName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Account Name');
window.scrollTo(0,0);
result := false;
end;
if edtInvoiceTo.Text = '' then
begin
showNotification('Failure:Orders Must Have an Invoice Address');
window.scrollTo(0,0);
result := false;
end;
if WebDBComboBox1.Text = '' then
begin
showNotification('Failure:Orders Must Have a Billing Address');
window.scrollTo(0,0);
result := false;
end;
if dtpOrderDate.Date = 0 then
begin
showNotification('Failure:Orders Must Have an Order Date');
window.scrollTo(0,0);
result := false;
end;
end;
procedure TFOrderEntryCorrugated.btnCopyClick(Sender: TObject); procedure TFOrderEntryCorrugated.btnCopyClick(Sender: TObject);
begin begin
mode := 'ADD'; mode := 'ADD';
//sendOrderToServer();
window.scrollTo(0, 0); window.scrollTo(0, 0);
dtpOrderDate.Date := 0; dtpOrderDate.Date := 0;
dtpProofDate.Date := 0; dtpProofDate.Date := 0;
...@@ -400,15 +447,20 @@ begin ...@@ -400,15 +447,20 @@ begin
dtpMountDue.Date := 0; dtpMountDue.Date := 0;
dtpShipDate.Date := 0; dtpShipDate.Date := 0;
dtpApprovedDate.Date := 0; dtpApprovedDate.Date := 0;
edtOrderNum.Text := '';
btnPDF.Enabled := False;
btnDelete.Enabled := False;
ShowNotification('Success:Order Successfully Copied'); ShowNotification('Success:Order Successfully Copied');
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
procedure TFOrderEntryCorrugated.btnDeleteClick(Sender: TObject); procedure TFOrderEntryCorrugated.btnDeleteClick(Sender: TObject);
begin begin
//mode := 'DEL'; asm
//sendOrderToServer(); var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
DelOrder(); keyboard: false });
confirmationModal.show();
end;
end; end;
procedure TFOrderEntryCorrugated.btnPDFClick(Sender: TObject); procedure TFOrderEntryCorrugated.btnPDFClick(Sender: TObject);
...@@ -419,6 +471,18 @@ begin ...@@ -419,6 +471,18 @@ begin
showNotification('Failure:Cannot Generate PDF when Adding an Order'); showNotification('Failure:Cannot Generate PDF when Adding an Order');
end; end;
procedure TFOrderEntryCorrugated.btn_confirm_deleteClick(Sender: TObject);
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.hide();
startSpinner();
end;
delOrder();
tmrReturn.Enabled := true;
end;
[async] procedure TFOrderEntryCorrugated.GenerateReportPDF; [async] procedure TFOrderEntryCorrugated.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results // sends the search to the server which then sends back a pdf of the results
var var
...@@ -449,8 +513,6 @@ begin ...@@ -449,8 +513,6 @@ begin
jsObj := JS.TJSObject(Response.Result); jsObj := JS.TJSObject(Response.Result);
OrderID := JS.toString(jsObj.Properties['OrderID']); OrderID := JS.toString(jsObj.Properties['OrderID']);
mode := 'EDIT'; mode := 'EDIT';
console.log(mode);
console.log(OrderID);
end; end;
procedure TFOrderEntryCorrugated.DelOrder(); procedure TFOrderEntryCorrugated.DelOrder();
...@@ -750,23 +812,31 @@ begin ...@@ -750,23 +812,31 @@ begin
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
dtpOrderDate.Date := 0;
dtpProofDate.Date := 0;
dtpArtDue.Date := 0;
dtpPlateDue.Date := 0;
dtpMountDue.Date := 0;
dtpShipDate.Date := 0;
dtpApprovedDate.Date := 0;
end; end;
procedure TFOrderEntryCorrugated.WebFormShow(Sender: TObject); procedure TFOrderEntryCorrugated.WebFormShow(Sender: TObject);
begin begin
if mode <> 'ADD' then if mode <> 'ADD' then
getOrder(orderID) begin
getOrder(orderID);
end
else else
begin
getCustomer(customerID); getCustomer(customerID);
btnPDF.Enabled := False;
btnDelete.Enabled := False;
end;
edtOrderNum.Text := OrderID;
HideNotification(); HideNotification();
end; end;
procedure TFOrderEntryCorrugated.XDataWebDataSet1AfterEdit(DataSet: TDataSet);
begin
//this only works for the first time it is changed
console.log('change');
end;
procedure TFOrderEntryCorrugated.HideNotification; procedure TFOrderEntryCorrugated.HideNotification;
begin begin
pnlMessage.ElementHandle.hidden := True; pnlMessage.ElementHandle.hidden := True;
...@@ -801,12 +871,33 @@ begin ...@@ -801,12 +871,33 @@ begin
end; end;
procedure TFOrderEntryCorrugated.tmrReturnTimer(Sender: TObject);
begin
asm
endSpinner();
end;
tmrReturn.Enabled := false;
FViewMain.ViewOrders('Success: Order Successfully Deleted');
end;
procedure TFOrderEntryCorrugated.tmrScrollTopTimer(Sender: TObject); procedure TFOrderEntryCorrugated.tmrScrollTopTimer(Sender: TObject);
begin begin
tmrScrollTop.Enabled := False; tmrScrollTop.Enabled := False;
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
procedure TFOrderEntryCorrugated.wdsQBItemDataChange(Sender: TObject;
Field: TField);
begin
console.log('change');
end;
procedure TFOrderEntryCorrugated.wdsShipToDataChange(Sender: TObject;
Field: TField);
begin
console.log('change');
end;
initialization initialization
RegisterClass(TFOrderEntryCorrugated); RegisterClass(TFOrderEntryCorrugated);
......
...@@ -202,11 +202,11 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -202,11 +202,11 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object btnConfirm: TWebButton object btnConfirm: TWebButton
Left = 652 Left = 566
Top = 560 Top = 538
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Confirm' Caption = 'Save'
ChildOrder = 79 ChildOrder = 79
ElementID = 'btnconfirm' ElementID = 'btnconfirm'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
...@@ -214,8 +214,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -214,8 +214,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
OnClick = btnConfirmClick OnClick = btnConfirmClick
end end
object btnCancel: TWebButton object btnCancel: TWebButton
Left = 764 Left = 680
Top = 560 Top = 538
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Cancel' Caption = 'Cancel'
...@@ -230,7 +230,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -230,7 +230,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
Top = 19 Top = 19
Width = 121 Width = 121
Height = 33 Height = 33
ElementID = 'pnl_message' ElementID = 'view.login.message'
ChildOrder = 5 ChildOrder = 5
ElementPosition = epRelative ElementPosition = epRelative
Role = 'alert' Role = 'alert'
...@@ -289,8 +289,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -289,8 +289,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
ListSource = wdsQBItem ListSource = wdsQBItem
end end
object btnPDF: TWebButton object btnPDF: TWebButton
Left = 710 Left = 782
Top = 610 Top = 537
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'PDF' Caption = 'PDF'
...@@ -300,6 +300,65 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -300,6 +300,65 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnPDFClick OnClick = btnPDFClick
end end
object edtOrderNum: TWebEdit
Left = 126
Top = 194
Width = 121
Height = 22
ChildOrder = 81
ElementID = 'edtordernum'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnDelete: TWebButton
Left = 574
Top = 578
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 79
ElementID = 'btndelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnDeleteClick
end
object btnClose: TWebButton
Left = 684
Top = 573
Width = 96
Height = 25
Caption = 'Close'
ChildOrder = 80
ElementID = 'btnclose'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCloseClick
end
object btn_confirm_delete: TWebButton
Left = 860
Top = 414
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 82
ElementID = 'btn_confirm_delete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btn_confirm_deleteClick
end
object btnCopy: TWebButton
Left = 786
Top = 573
Width = 96
Height = 25
Caption = 'Copy'
ChildOrder = 78
ElementID = 'btncopy'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCopyClick
end
object WebDataSource1: TWebDataSource object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1 DataSet = XDataWebDataSet1
Left = 22 Left = 22
...@@ -372,8 +431,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -372,8 +431,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 160 Left = 192
Top = 18 Top = 92
end end
object tmrScrollTop: TWebTimer object tmrScrollTop: TWebTimer
Interval = 100 Interval = 100
...@@ -405,4 +464,10 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -405,4 +464,10 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
FieldName = 'name' FieldName = 'name'
end end
end end
object tmrReturn: TWebTimer
Enabled = False
OnTimer = tmrReturnTimer
Left = 306
Top = 62
end
end end
<div class="col-12 col-md-8"> <div class="col-12 col-md-8">
<div class="row"> <div class="row">
<div class=col-sm> <div class=col-sm>
<div id="pnl_message" class="alert alert-danger"> <div class=col-sm>
<div id="view.login.message" class="alert alert-danger">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button> <button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span> <span id="view.login.message.label"></span>
</div> </div>
</div> </div>
</div> </div>
</div>
<h4 class="custom-h4 mt-3">Company</h4> <h4 class="custom-h4 mt-3">Company</h4>
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
...@@ -27,6 +29,10 @@ ...@@ -27,6 +29,10 @@
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Num:</label>
<input id="edtordernum" class="form-control input-sm" style="width: 100px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label>
<input class="form-control input-sm" id="dtporderdate" type="date"> <input class="form-control input-sm" id="dtporderdate" type="date">
</div> </div>
...@@ -81,13 +87,45 @@ ...@@ -81,13 +87,45 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<button id="btnconfirm" class="btn btn-primary btn-sm float-end my-2">Confirm</button> <button id="btnconfirm" class="btn btn-primary btn-sm float-end my-2">Save</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button> <button id="btncancel" class="btn btn-primary btn-sm float-end my-2">Cancel</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btncopy" class="btn btn-primary btn-sm float-end my-2">Copy</button>
</div>
<div class="col-auto">
<button id="btnpdf" class="btn btn-primary btn-sm float-end my-2">PDF</button> <button id="btnpdf" class="btn btn-primary btn-sm float-end my-2">PDF</button>
</div> </div>
<div class="col-auto">
<button id="btndelete" class="btn btn-primary btn-sm float-end my-2">Delete</button>
</div>
<div class="col-auto">
<button id="btnclose" class="btn btn-primary btn-sm float-end my-2">Close</button>
</div> </div>
</div>
</div>
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmation_modal_label">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete this order?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
</div> </div>
<style>
.modal-backdrop {
opacity: 0 !important;
}
</style>
...@@ -65,6 +65,12 @@ type ...@@ -65,6 +65,12 @@ type
xdwdsQBItemname: TStringField; xdwdsQBItemname: TStringField;
wcbQBItem: TWebDBComboBox; wcbQBItem: TWebDBComboBox;
btnPDF: TWebButton; btnPDF: TWebButton;
edtOrderNum: TWebEdit;
btnDelete: TWebButton;
btnClose: TWebButton;
btn_confirm_delete: TWebButton;
btnCopy: TWebButton;
tmrReturn: TWebTimer;
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
...@@ -77,6 +83,14 @@ type ...@@ -77,6 +83,14 @@ type
[async] procedure AddCuttingDieOrder(orderJSON: TJSONObject); [async] procedure AddCuttingDieOrder(orderJSON: TJSONObject);
procedure btnPDFClick(Sender: TObject); procedure btnPDFClick(Sender: TObject);
[async] procedure GenerateReportPDF; [async] procedure GenerateReportPDF;
procedure SendOrderToServer();
function VerifyOrder(): boolean;
procedure btnDeleteClick(Sender: TObject);
[async] procedure delOrder();
procedure btnCloseClick(Sender: TObject);
procedure btnCopyClick(Sender: TObject);
procedure btn_confirm_deleteClick(Sender: TObject);
procedure tmrReturnTimer(Sender: TObject);
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -98,10 +112,43 @@ implementation ...@@ -98,10 +112,43 @@ implementation
uses uses
View.Home, View.Main; View.Home, View.Main;
procedure TFOrderEntryCuttingDie.btnConfirmClick(Sender: TObject); function TFOrderEntryCuttingDie.VerifyOrder: Boolean;
// Converts all the information on the page into a JSON to then send to the server begin
result := true;
if edtCompanyName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Name');
window.scrollTo(0,0);
result := false;
end;
if edtCompanyAccountName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Account Name');
window.scrollTo(0,0);
result := false;
end;
if edtInvoiceTo.Text = '' then
begin
showNotification('Failure:Orders Must Have an Invoice Address');
window.scrollTo(0,0);
result := false;
end;
if wdbcbShipTo.Text = '' then
begin
showNotification('Failure:Orders Must Have a Billing Address');
window.scrollTo(0,0);
result := false;
end;
if dtpOrderDate.Date = 0 then
begin
showNotification('Failure:Orders Must Have an Order Date');
window.scrollTo(0,0);
result := false;
end;
end;
procedure TFOrderEntryCuttingDie.SendOrderToServer;
var var
I, J: integer;
orderJSON: TJSONObject; orderJSON: TJSONObject;
fieldNames: TStringList; fieldNames: TStringList;
itemList: TJSNodeList; itemList: TJSNodeList;
...@@ -147,8 +194,62 @@ begin ...@@ -147,8 +194,62 @@ begin
orderJSON.AddPair('ORDER_ID', orderID); orderJSON.AddPair('ORDER_ID', orderID);
console.log(orderJSON.GetValue('ORDER_ID')); console.log(orderJSON.GetValue('ORDER_ID'));
console.log(orderJSON); console.log(orderJSON);
if mode = 'ADD' then
ShowNotification('Success:Order Added Successfully!')
else
ShowNotification('Success:Order Edited Successfully');
AddCuttingDieOrder(orderJSON); AddCuttingDieOrder(orderJSON);
FViewMain.ViewOrders('Success:Order added successfully!');
end;
procedure TFOrderEntryCuttingDie.btnConfirmClick(Sender: TObject);
// Converts all the information on the page into a JSON to then send to the server
var
I, J: integer;
orderJSON: TJSONObject;
fieldNames: TStringList;
itemList: TJSNodeList;
header, value: string;
Field: TField;
Response: TXDataClientResponse;
begin
if VerifyOrder() then
begin
sendOrderToServer();
btnPDF.Enabled := true;
btnDelete.Enabled := true;
end;
window.scrollTo(0, 0);
end;
procedure TFOrderEntryCuttingDie.btnCopyClick(Sender: TObject);
begin
mode := 'ADD';
dtpOrderDate.Date := 0;
dtpProofDate.Date := 0;
edtOrderNum.Text := '';
btnPDF.Enabled := False;
btnDelete.Enabled := False;
ShowNotification('Success:Order Successfully Copied');
window.scrollTo(0, 0);
end;
procedure TFOrderEntryCuttingDie.btnDeleteClick(Sender: TObject);
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.show();
end;
end;
procedure TFOrderEntryCuttingDie.DelOrder();
var
Response: TXDataClientResponse;
begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.DelOrder',
[OrderID, 'corrugated', JS.toString(AuthService.TokenPayload.Properties['user_id'])]));
end; end;
procedure TFOrderEntryCuttingDie.btnPDFClick(Sender: TObject); procedure TFOrderEntryCuttingDie.btnPDFClick(Sender: TObject);
...@@ -156,6 +257,18 @@ begin ...@@ -156,6 +257,18 @@ begin
GenerateReportPDF; GenerateReportPDF;
end; end;
procedure TFOrderEntryCuttingDie.btn_confirm_deleteClick(Sender: TObject);
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.hide();
startSpinner();
end;
delOrder();
tmrReturn.Enabled := true;
end;
[async] procedure TFOrderEntryCuttingDie.GenerateReportPDF; [async] procedure TFOrderEntryCuttingDie.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results // sends the search to the server which then sends back a pdf of the results
var var
...@@ -206,6 +319,11 @@ end; ...@@ -206,6 +319,11 @@ end;
procedure TFOrderEntryCuttingDie.btnCancelClick(Sender: TObject); procedure TFOrderEntryCuttingDie.btnCancelClick(Sender: TObject);
begin begin
//FViewMain.ViewOrders('');
end;
procedure TFOrderEntryCuttingDie.btnCloseClick(Sender: TObject);
begin
FViewMain.ViewOrders(''); FViewMain.ViewOrders('');
end; end;
...@@ -306,6 +424,7 @@ begin ...@@ -306,6 +424,7 @@ begin
getCuttingDieOrder(orderID) getCuttingDieOrder(orderID)
else else
getCustomer(customerID); getCustomer(customerID);
edtOrderNum.Text := OrderID;
HideNotification(); HideNotification();
end; end;
...@@ -324,6 +443,15 @@ begin ...@@ -324,6 +443,15 @@ begin
end; end;
procedure TFOrderEntryCuttingDie.tmrReturnTimer(Sender: TObject);
begin
asm
endSpinner();
end;
tmrReturn.Enabled := false;
FViewMain.ViewOrders('Success: Order Successfully Deleted');
end;
procedure TFOrderEntryCuttingDie.tmrScrollTopTimer(Sender: TObject); procedure TFOrderEntryCuttingDie.tmrScrollTopTimer(Sender: TObject);
begin begin
tmrScrollTop.Enabled := False; tmrScrollTop.Enabled := False;
......
...@@ -117,7 +117,7 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -117,7 +117,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
Top = 19 Top = 19
Width = 121 Width = 121
Height = 33 Height = 33
ElementID = 'pnl_message' ElementID = 'view.login.message'
ChildOrder = 5 ChildOrder = 5
ElementPosition = epRelative ElementPosition = epRelative
Role = 'alert' Role = 'alert'
...@@ -147,6 +147,7 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -147,6 +147,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
Role = 'button' Role = 'button'
WidthStyle = ssAuto WidthStyle = ssAuto
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCloseNotificationClick
end end
end end
object edtCompanyName: TWebDBEdit object edtCompanyName: TWebDBEdit
...@@ -1222,6 +1223,29 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1222,6 +1223,29 @@ object FOrderEntryWeb: TFOrderEntryWeb
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCloseClick OnClick = btnCloseClick
end end
object edtOrderNum: TWebEdit
Left = 126
Top = 194
Width = 121
Height = 22
ChildOrder = 81
ElementID = 'edtordernum'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btn_confirm_delete: TWebButton
Left = 1094
Top = 414
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 82
ElementID = 'btn_confirm_delete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btn_confirm_deleteClick
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 160 Left = 160
...@@ -1521,4 +1545,10 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1521,4 +1545,10 @@ object FOrderEntryWeb: TFOrderEntryWeb
FieldName = 'name' FieldName = 'name'
end end
end end
object tmrReturn: TWebTimer
Enabled = False
OnTimer = tmrReturnTimer
Left = 306
Top = 62
end
end end
<div class="col-12 col-md-8"> <div class="col-12 col-md-8">
<div class="row"> <div class="row">
<div class=col-sm> <div class=col-sm>
<div id="pnl_message" class="alert alert-danger"> <div id="view.login.message" class="alert alert-danger">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button> <button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span> <span id="view.login.message.label"></span>
</div> </div>
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Num:</label>
<input id="edtordernum" class="form-control input-sm" style="width: 100px"/>
</div>
<div class="col-auto">
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label> <label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Order Date:</label>
<input class="form-control input-sm" id="dtporderdate" type="date"> <input class="form-control input-sm" id="dtporderdate" type="date">
</div> </div>
...@@ -375,4 +379,27 @@ ...@@ -375,4 +379,27 @@
<button id="btnclose" class="btn btn-primary btn-sm float-end my-2">Close</button> <button id="btnclose" class="btn btn-primary btn-sm float-end my-2">Close</button>
</div> </div>
</div> </div>
</div>
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmation_modal_label">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete this order?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_delete">Delete</button>
</div>
</div>
</div> </div>
</div>
</div>
<style>
.modal-backdrop {
opacity: 0 !important;
}
</style>
...@@ -201,6 +201,9 @@ type ...@@ -201,6 +201,9 @@ type
btnCopy: TWebButton; btnCopy: TWebButton;
btnDelete: TWebButton; btnDelete: TWebButton;
btnClose: TWebButton; btnClose: TWebButton;
edtOrderNum: TWebEdit;
btn_confirm_delete: TWebButton;
tmrReturn: TWebTimer;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
...@@ -220,6 +223,10 @@ type ...@@ -220,6 +223,10 @@ type
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject);
[async] procedure DelOrder; [async] procedure DelOrder;
procedure btnCloseNotificationClick(Sender: TObject);
procedure tmrReturnTimer(Sender: TObject);
procedure btn_confirm_deleteClick(Sender: TObject);
function VerifyOrder(): boolean;
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -244,10 +251,50 @@ uses ...@@ -244,10 +251,50 @@ uses
procedure TFOrderEntryWeb.btnConfirmClick(Sender: TObject); procedure TFOrderEntryWeb.btnConfirmClick(Sender: TObject);
begin begin
SendOrderToServer(); if VerifyOrder() then
begin
sendOrderToServer();
btnPDF.Enabled := true;
btnDelete.Enabled := true;
end;
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
function TFOrderEntryWeb.VerifyOrder: Boolean;
begin
result := true;
if edtCompanyName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Name');
window.scrollTo(0,0);
result := false;
end;
if edtCompanyAccountName.Text = '' then
begin
showNotification('Failure:Orders Must Have a Company Account Name');
window.scrollTo(0,0);
result := false;
end;
if edtInvoiceTo.Text = '' then
begin
showNotification('Failure:Orders Must Have an Invoice Address');
window.scrollTo(0,0);
result := false;
end;
if WebDBComboBox1.Text = '' then
begin
showNotification('Failure:Orders Must Have a Billing Address');
window.scrollTo(0,0);
result := false;
end;
if dtpOrderDate.Date = 0 then
begin
showNotification('Failure:Orders Must Have an Order Date');
window.scrollTo(0,0);
result := false;
end;
end;
procedure TFOrderEntryWeb.btnCopyClick(Sender: TObject); procedure TFOrderEntryWeb.btnCopyClick(Sender: TObject);
begin begin
mode := 'ADD'; mode := 'ADD';
...@@ -265,13 +312,20 @@ begin ...@@ -265,13 +312,20 @@ begin
dtpColorContractDate1.Date := 0; dtpColorContractDate1.Date := 0;
dtpColorContractDate2.Date := 0; dtpColorContractDate2.Date := 0;
dtpDigitalColorDate.Date := 0; dtpDigitalColorDate.Date := 0;
edtOrderNum.Text := '';
btnPDF.Enabled := False;
btnDelete.Enabled := False;
ShowNotification('Success:Order Successfully Copied'); ShowNotification('Success:Order Successfully Copied');
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
procedure TFOrderEntryWeb.btnDeleteClick(Sender: TObject); procedure TFOrderEntryWeb.btnDeleteClick(Sender: TObject);
begin begin
DelOrder(); asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.show();
end;
end; end;
[async] procedure TFOrderEntryWeb.DelOrder(); [async] procedure TFOrderEntryWeb.DelOrder();
...@@ -377,6 +431,18 @@ begin ...@@ -377,6 +431,18 @@ begin
GenerateReportPDF; GenerateReportPDF;
end; end;
procedure TFOrderEntryWeb.btn_confirm_deleteClick(Sender: TObject);
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.hide();
startSpinner();
end;
delOrder();
tmrReturn.Enabled := true;
end;
procedure TFOrderEntryWeb.GenerateReportPDF; procedure TFOrderEntryWeb.GenerateReportPDF;
// sends the search to the server which then sends back a pdf of the results // sends the search to the server which then sends back a pdf of the results
var var
...@@ -494,6 +560,11 @@ begin ...@@ -494,6 +560,11 @@ begin
FViewMain.ViewOrders(''); FViewMain.ViewOrders('');
end; end;
procedure TFOrderEntryWeb.btnCloseNotificationClick(Sender: TObject);
begin
hideNotification();
end;
procedure TFOrderEntryWeb.WebFormCreate(Sender: TObject); procedure TFOrderEntryWeb.WebFormCreate(Sender: TObject);
begin begin
if not DMConnection.ApiConnection.Connected then if not DMConnection.ApiConnection.Connected then
...@@ -652,6 +723,21 @@ begin ...@@ -652,6 +723,21 @@ begin
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
dtpOrderDate.Date := 0;
dtpProofDate.Date := 0;
dtpArtDue.Date := 0;
dtpPlateDue.Date := 0;
dtpShipDate.Date := 0;
dtpPDFDate1.Date := 0;
dtpPDFDate2.Date := 0;
dtpPDFDate3.Date := 0;
dtpInkJetDate1.Date := 0;
dtpInkJetDate2.Date := 0;
dtpInkJetDate3.Date := 0;
dtpColorContractDate1.Date := 0;
dtpColorContractDate2.Date := 0;
dtpDigitalColorDate.Date := 0;
end; end;
procedure TFOrderEntryWeb.WebFormShow(Sender: TObject); procedure TFOrderEntryWeb.WebFormShow(Sender: TObject);
...@@ -660,6 +746,7 @@ begin ...@@ -660,6 +746,7 @@ begin
getOrder(orderID) getOrder(orderID)
else else
getCustomer(customerID); getCustomer(customerID);
edtOrderNum.Text := OrderID;
HideNotification(); HideNotification();
end; end;
...@@ -697,6 +784,15 @@ begin ...@@ -697,6 +784,15 @@ begin
end; end;
procedure TFOrderEntryWeb.tmrReturnTimer(Sender: TObject);
begin
asm
endSpinner();
end;
tmrReturn.Enabled := false;
FViewMain.ViewOrders('Success: Order Successfully Deleted');
end;
procedure TFOrderEntryWeb.tmrScrollTopTimer(Sender: TObject); procedure TFOrderEntryWeb.tmrScrollTopTimer(Sender: TObject);
begin begin
tmrScrollTop.Enabled := False; tmrScrollTop.Enabled := False;
......
...@@ -125,6 +125,7 @@ object FViewOrders: TFViewOrders ...@@ -125,6 +125,7 @@ object FViewOrders: TFViewOrders
Columns = < Columns = <
item item
DataField = 'DBID' DataField = 'DBID'
Title = 'Order Num'
end end
item item
DataField = 'ID' DataField = 'ID'
......
...@@ -624,7 +624,6 @@ begin ...@@ -624,7 +624,6 @@ begin
xdwdsOrders.Close; xdwdsOrders.Close;
xdwdsOrders.SetJsonData(orderList['data']); xdwdsOrders.SetJsonData(orderList['data']);
xdwdsOrders.Open; xdwdsOrders.Open;
//wdbtcOrders.HideColumn(0);
asm asm
endSpinner(); endSpinner();
......
...@@ -132,9 +132,9 @@ object FSearch: TFSearch ...@@ -132,9 +132,9 @@ object FSearch: TFSearch
object WebLabel1: TWebLabel object WebLabel1: TWebLabel
Left = 20 Left = 20
Top = 8 Top = 8
Width = 48 Width = 63
Height = 14 Height = 14
Caption = 'Order ID:' Caption = 'Order Num:'
Font.Charset = ANSI_CHARSET Font.Charset = ANSI_CHARSET
Font.Color = clBlack Font.Color = clBlack
Font.Height = -11 Font.Height = -11
...@@ -708,18 +708,18 @@ object FSearch: TFSearch ...@@ -708,18 +708,18 @@ object FSearch: TFSearch
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 418 Left = 418
Top = 393 Top = 393
object xdwdsCustomersID: TIntegerField object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'ID' FieldName = 'SHORT_NAME'
end end
object xdwdsCustomersNAME: TStringField object xdwdsCustomersNAME: TStringField
FieldName = 'NAME' FieldName = 'NAME'
end end
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
object xdwdsCustomersstaff_fields_invoice_to: TStringField object xdwdsCustomersstaff_fields_invoice_to: TStringField
FieldName = 'staff_fields_invoice_to' FieldName = 'staff_fields_invoice_to'
end end
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
end end
object wdsCustomers: TWebDataSource object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers DataSet = xdwdsCustomers
......
...@@ -44,9 +44,7 @@ type ...@@ -44,9 +44,7 @@ type
lblCompanyID: TWebLabel; lblCompanyID: TWebLabel;
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet; xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField; xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
wdsCustomers: TWebDataSource; wdsCustomers: TWebDataSource;
WebLabel3: TWebLabel; WebLabel3: TWebLabel;
edtJobName: TWebEdit; edtJobName: TWebEdit;
...@@ -56,6 +54,8 @@ type ...@@ -56,6 +54,8 @@ type
xdwdsCustomersstaff_fields_invoice_to: TStringField; xdwdsCustomersstaff_fields_invoice_to: TStringField;
WebLabel5: TWebLabel; WebLabel5: TWebLabel;
edtCompanyName: TWebEdit; edtCompanyName: TWebEdit;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersID: TIntegerField;
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
...@@ -254,6 +254,8 @@ begin ...@@ -254,6 +254,8 @@ begin
xdwdsCustomers.SetJsonData(customerList['data']); xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open; xdwdsCustomers.Open;
console.log(customerList['data']);
// Manually populate the grid // Manually populate the grid
PopulateGridManually; PopulateGridManually;
end; end;
...@@ -289,7 +291,7 @@ begin ...@@ -289,7 +291,7 @@ begin
while not xdwdsCustomers.EOF do while not xdwdsCustomers.EOF do
begin begin
TMSFNCGrid1.RowCount := RowIndex + 1; TMSFNCGrid1.RowCount := RowIndex + 1;
console.log(xdwdsCustomers.FieldByName('ID').AsString);
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString; TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString; TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString;
TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString; TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
......
...@@ -633,7 +633,7 @@ object FData: TFData ...@@ -633,7 +633,7 @@ object FData: TFData
ColCount = 22 ColCount = 22
DrawingStyle = gdsClassic DrawingStyle = gdsClassic
FixedColor = clWhite FixedColor = clWhite
RowCount = 101 RowCount = 2
FixedRows = 1 FixedRows = 1
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goFixedRowDefAlign] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goFixedRowDefAlign]
TabOrder = 3 TabOrder = 3
...@@ -1500,105 +1500,6 @@ object FData: TFData ...@@ -1500,105 +1500,6 @@ object FData: TFData
64) 64)
RowHeights = ( 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
22) 22)
end end
object edtUsername: TEdit object edtUsername: TEdit
...@@ -1686,7 +1587,6 @@ object FData: TFData ...@@ -1686,7 +1587,6 @@ object FData: TFData
Top = 472 Top = 472
end end
object uqUsers: TUniQuery object uqUsers: TUniQuery
Connection = ucKG
SQL.Strings = ( SQL.Strings = (
'select * from users') 'select * from users')
Left = 669 Left = 669
...@@ -1700,7 +1600,6 @@ object FData: TFData ...@@ -1700,7 +1600,6 @@ object FData: TFData
Top = 369 Top = 369
end end
object uqWeb: TUniQuery object uqWeb: TUniQuery
Connection = ucKG
SQL.Strings = ( SQL.Strings = (
'select * from web_plate_orders') 'select * from web_plate_orders')
Left = 745 Left = 745
...@@ -2029,15 +1928,4 @@ object FData: TFData ...@@ -2029,15 +1928,4 @@ object FData: TFData
Size = 16 Size = 16
end end
end end
object ucKG: TUniConnection
ProviderName = 'MySQL'
Database = 'kg_order_entry'
Username = 'root'
Server = '192.168.159.132'
Connected = True
LoginPrompt = False
Left = 855
Top = 457
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
end end
...@@ -38,7 +38,6 @@ type ...@@ -38,7 +38,6 @@ type
Timer1: TTimer; Timer1: TTimer;
Button1: TButton; Button1: TButton;
uqWeb: TUniQuery; uqWeb: TUniQuery;
ucKG: TUniConnection;
uqWebORDER_ID: TIntegerField; uqWebORDER_ID: TIntegerField;
uqWebCOMPANY_ID: TIntegerField; uqWebCOMPANY_ID: TIntegerField;
uqWebUSER_ID: TIntegerField; uqWebUSER_ID: TIntegerField;
......
...@@ -65,6 +65,7 @@ type ...@@ -65,6 +65,7 @@ type
procedure AddToOrdersTable(mode, ORDER_TYPE: string; JSONData: TJSONObject); procedure AddToOrdersTable(mode, ORDER_TYPE: string; JSONData: TJSONObject);
procedure AfterConstruction; override; procedure AfterConstruction; override;
procedure BeforeDestruction; override; procedure BeforeDestruction; override;
procedure AddToRevisionsTable(OrderID, table: string; order: TJSONObject);
end; end;
implementation implementation
...@@ -421,7 +422,7 @@ begin ...@@ -421,7 +422,7 @@ begin
offset := IntToStr((PageNum - 1) * PageSize); offset := IntToStr((PageNum - 1) * PageSize);
limit := IntToStr(PageSize); limit := IntToStr(PageSize);
SQL := 'SELECT o.ORDER_ID, c.SHORT_NAME, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '; SQL := 'SELECT o.ORDER_ID, c.SHORT_NAME, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_TYPE, ';
// Generate the subqueries that get the Status Dates(Due and Done) // Generate the subqueries that get the Status Dates(Due and Done)
SQL := SQL + generateSubquery('PROOF'); SQL := SQL + generateSubquery('PROOF');
...@@ -466,7 +467,8 @@ begin ...@@ -466,7 +467,8 @@ begin
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM, ' + 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_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 ' + 'coalesce( cpo.staff_fields_quickbooks_item, wpo.staff_fields_quickbooks_item, cdo.staff_fields_quickbooks_item ) AS quickbooks_item, ' +
'coalesce( cpo.staff_fields_order_date, wpo.staff_fields_order_date, cdo.staff_fields_order_date ) AS ORDER_DATE ' +
whereSQL + ' ' + orderBySQL + ' LIMIT ' + limit + ' OFFSET ' + offset; whereSQL + ' ' + orderBySQL + ' LIMIT ' + limit + ' OFFSET ' + offset;
...@@ -1227,6 +1229,7 @@ var ...@@ -1227,6 +1229,7 @@ var
DateFormat: TFormatSettings; DateFormat: TFormatSettings;
ORDER_ID: integer; ORDER_ID: integer;
mode: string; mode: string;
temp: string;
begin begin
DateFormat := TFormatSettings.Create; DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd'; DateFormat.ShortDateFormat := 'yyyy-mm-dd';
...@@ -1264,9 +1267,13 @@ begin ...@@ -1264,9 +1267,13 @@ begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
if Assigned(Field) then if Assigned(Field) then
begin begin
// handles any dates or datetimes if (Field is TDateTimeField) then
if (Field is TDateTimeField) and (Pair.JsonValue.Value <> '') then begin
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value) if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
Field.Clear // This sets the field to NULL (empty)
else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
end
else if Pair.JsonValue.Value <> '' then else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value; Field.AsString := Pair.JsonValue.Value;
end; end;
...@@ -1276,18 +1283,24 @@ begin ...@@ -1276,18 +1283,24 @@ begin
// Post the record to the database // Post the record to the database
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
temp := JSONData.GetValue<string>('staff_fields_proof_date');
if JSONData.GetValue<string>('staff_fields_proof_date') <> '' then if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID); AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_ship_date') <> '' then temp := JSONData.GetValue<string>('staff_fields_ship_date');
if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID); AddStatusSchedule('SHIP', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_art_due') <> '' then temp := JSONData.GetValue<string>('staff_fields_art_due');
if ( JSONData.GetValue<string>('staff_fields_art_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_art_due') <> '12/30/1899' ) then
AddStatusSchedule('ART', JSONData, ORDER_ID); AddStatusSchedule('ART', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_plate_due') <> '' then temp := JSONData.GetValue<string>('staff_fields_plate_due');
if ( JSONData.GetValue<string>('staff_fields_plate_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_plate_due') <> '12/30/1899' ) then
AddStatusSchedule('PLATE', JSONData, ORDER_ID); AddStatusSchedule('PLATE', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_mount_due') <> '' then temp := JSONData.GetValue<string>('staff_fields_mount_due');
if ( JSONData.GetValue<string>('staff_fields_mount_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_mount_due') <> '12/30/1899' ) then
AddStatusSchedule('MOUNT', JSONData, ORDER_ID); AddStatusSchedule('MOUNT', JSONData, ORDER_ID);
addToRevisionsTable(intToStr(ORDER_ID), 'corrugated_plate_orders_revisions', JSONData);
Result := TJSONObject.Create.AddPair('status', 'success'); Result := TJSONObject.Create.AddPair('status', 'success');
Result.AddPair('OrderID', ORDER_ID); Result.AddPair('OrderID', ORDER_ID);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
...@@ -1333,14 +1346,14 @@ begin ...@@ -1333,14 +1346,14 @@ begin
change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString <> order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date'); change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString <> order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date'); ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
if mode <> 'EDIT' then if mode <> 'EDIT' then
ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date'); ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsString := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date')
end end
else else
begin begin
change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime <> StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due')); change := ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime <> StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'));
ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due')); ordersDB.UniQuery1.FieldByName('STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'));
if mode <> 'EDIT' then if mode <> 'EDIT' then
ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due')); ordersDB.UniQuery1.FieldByName('ORIGINAL_STATUS_DATE').AsDateTime := StrToDateTime(order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due'))
end; end;
ordersDB.UniQuery1.FieldByName('USER_ID').AsString := order.GetValue<string>('USER_ID'); ordersDB.UniQuery1.FieldByName('USER_ID').AsString := order.GetValue<string>('USER_ID');
...@@ -1616,8 +1629,13 @@ begin ...@@ -1616,8 +1629,13 @@ begin
if Assigned(Field) then if Assigned(Field) then
begin begin
// handles any dates or datetimes // handles any dates or datetimes
if (Field is TDateTimeField) and (Pair.JsonValue.Value <> '') then if (Field is TDateTimeField) then
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value) begin
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
Field.Clear // This sets the field to NULL (empty)
else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
end
else if Pair.JsonValue.Value <> '' then else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value; Field.AsString := Pair.JsonValue.Value;
end; end;
...@@ -1628,15 +1646,17 @@ begin ...@@ -1628,15 +1646,17 @@ begin
// Post the record to the database // Post the record to the database
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
if JSONData.GetValue<string>('staff_fields_proof_date') <> '' then if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID); AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_ship_date') <> '' then if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID); AddStatusSchedule('SHIP', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_art_due') <> '' then if ( JSONData.GetValue<string>('staff_fields_art_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_art_due') <> '12/30/1899' ) then
AddStatusSchedule('ART', JSONData, ORDER_ID); AddStatusSchedule('ART', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_plate_due') <> '' then if ( JSONData.GetValue<string>('staff_fields_plate_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_plate_due') <> '12/30/1899' ) then
AddStatusSchedule('PLATE', JSONData, ORDER_ID); AddStatusSchedule('PLATE', JSONData, ORDER_ID);
AddToRevisionsTable(IntToStr(ORDER_ID), 'web_plate_orders_revisions', JSONData);
Result := TJSONObject.Create.AddPair('status', 'success'); Result := TJSONObject.Create.AddPair('status', 'success');
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except except
...@@ -1699,8 +1719,13 @@ begin ...@@ -1699,8 +1719,13 @@ begin
if Assigned(Field) then if Assigned(Field) then
begin begin
// handles any dates or datetimes // handles any dates or datetimes
if (Field is TDateTimeField) and (Pair.JsonValue.Value <> '') then if (Field is TDateTimeField) then
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value) begin
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
Field.Clear // This sets the field to NULL (empty)
else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
end
else if Pair.JsonValue.Value <> '' then else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value; Field.AsString := Pair.JsonValue.Value;
end; end;
...@@ -1711,13 +1736,11 @@ begin ...@@ -1711,13 +1736,11 @@ begin
// Post the record to the database // Post the record to the database
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
if JSONData.GetValue<string>('staff_fields_proof_date') <> '' then if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID); AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if JSONData.GetValue<string>('staff_fields_ship_date') <> '' then if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID); AddStatusSchedule('SHIP', JSONData, ORDER_ID);
Result := TJSONObject.Create.AddPair('status', 'success');
Result.AddPair('OrderID', ORDER_ID);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except except
...@@ -1741,10 +1764,9 @@ var ...@@ -1741,10 +1764,9 @@ var
JSONArray: TJSONArray; JSONArray: TJSONArray;
Pair: TJSONPair; Pair: TJSONPair;
Field: TField; Field: TField;
ORDER_ID: string;
mode: string; mode: string;
stream: TStringStream; stream: TStringStream;
RevisionID: integer; RevisionID, rev_num: integer;
JSONValue: TJSONValue; JSONValue: TJSONValue;
JSONObject: TJSONObject; JSONObject: TJSONObject;
DataObject: TJSONObject; DataObject: TJSONObject;
...@@ -1807,7 +1829,12 @@ begin ...@@ -1807,7 +1829,12 @@ begin
JSONData := JSONArray.Items[0] as TJSONObject; JSONData := JSONArray.Items[0] as TJSONObject;
SQL := 'select * from ' + table2 + ' where ORDER_ID = 0 and ORDER_ID <> 0'; SQL := 'select max(REVISION_NUMBER) as rev_num from ' + table2 + ' where ORDER_ID = ' + orderID;
doQuery(ordersDB.UniQuery1, SQL);
rev_num := ordersDB.UniQuery1.FieldByName('rev_num').AsInteger + 1;
SQL := 'select * from ' + table2 + ' where ORDER_ID = ' + orderID;
doQuery(ordersDB.UniQuery1, SQL);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
try try
...@@ -1834,7 +1861,7 @@ begin ...@@ -1834,7 +1861,7 @@ begin
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
Result := TJSONObject.Create.AddPair('status', 'success'); Result := TJSONObject.Create.AddPair('status', 'success');
Result.AddPair('OrderID', ORDER_ID); Result.AddPair('OrderID', OrderID);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except except
on E: Exception do on E: Exception do
...@@ -1853,6 +1880,63 @@ begin ...@@ -1853,6 +1880,63 @@ begin
OrdersDB.UniQuery1.ExecSQL; OrdersDB.UniQuery1.ExecSQL;
end; end;
procedure TLookupService.AddToRevisionsTable(OrderID: string; table: string; order: TJSONObject);
var
SQL, UserID: string;
Pair: TJSONPair;
rev_num, RevisionID: integer;
Field: TField;
begin
// Get Revision Number
SQL := 'select max(REVISION_NUMBER) as rev_num from ' + table + ' where ORDER_ID = ' + orderID;
doQuery(ordersDB.UniQuery1, SQL);
rev_num := ordersDB.UniQuery1.FieldByName('rev_num').AsInteger + 1;
// Update RevisionID
SQL := 'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID');
OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL;
// Retrieve updated RevisionID
SQL := 'select KEYVALUE from idfield where KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID');
doQuery(OrdersDB.UniQuery1, SQL);
RevisionID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger;
// Begin Area where we could replace this with marks code(need to convert from c++
SQL := 'select * from ' + table + ' where ORDER_ID = -1';
doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Insert;
for Pair in order do
begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
if Assigned(Field) then
begin
// handles any dates or datetimes
if (Field is TDateTimeField) then
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
Field.Clear // This sets the field to NULL (empty)
else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value)
else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value;
end;
end;
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsString := OrderID;
ordersDB.UniQuery1.FieldByName('ORDER_DATE').AsDateTime := Now;
// End Area
ordersDB.UniQuery1.FieldByName('ORDER_STATUS').AsString := 'ACTIVE';
ordersDB.UniQuery1.FieldByName('REVISION_NUMBER').AsInteger := 1;
ordersDB.UniQuery1.FieldByName('ORDER_REVISION_ID').AsInteger := RevisionID;
ordersDB.UniQuery1.FieldByName('REVISION_USER_ID').AsString := order.GetValue<string>('USER_ID');
// Post the record to the database
ordersDB.UniQuery1.Post;
end;
initialization initialization
RegisterServiceType(TLookupService); RegisterServiceType(TLookupService);
end. end.
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
MemoLogLevel=3 MemoLogLevel=3
FileLogLevel=5 FileLogLevel=5
webClientVersion=0.9.2 webClientVersion=0.9.2
LogFileNum=396 LogFileNum=428
[Database] [Database]
Server=192.168.159.132 Server=192.168.159.131
--Server=192.168.102.130 --Server=192.168.102.130
--Server=192.168.75.133 --Server=192.168.75.133
Database=kg_order_entry Database=kg_order_entry
......
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