Commit 2603867e by Cam Hayes

AddCustomer is finished up to shipping information, and fixed order entry bugs

parent 033837f0
object FViewAddCustomer: TFViewAddCustomer object FViewAddCustomer: TFViewAddCustomer
Width = 640 Width = 842
Height = 480 Height = 607
OnShow = WebFormShow OnShow = WebFormShow
object dtpStartDate: TWebDateTimePicker object dtpStartDate: TWebDateTimePicker
Left = 19 Left = 19
...@@ -37,6 +37,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -37,6 +37,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtcompanyaccountname' ElementID = 'edtcompanyaccountname'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'SHORT_NAME'
DataSource = WebDataSource1
end end
object edtName: TWebDBEdit object edtName: TWebDBEdit
Left = 19 Left = 19
...@@ -47,6 +49,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -47,6 +49,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtcompanyname' ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'NAME'
DataSource = WebDataSource1
end end
object edtBillAddress: TWebDBEdit object edtBillAddress: TWebDBEdit
Left = 19 Left = 19
...@@ -57,6 +61,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -57,6 +61,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingaddress' ElementID = 'edtbillingaddress'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'BILL_ADDRESS'
DataSource = WebDataSource1
end end
object edtBillCity: TWebDBEdit object edtBillCity: TWebDBEdit
Left = 19 Left = 19
...@@ -67,6 +73,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -67,6 +73,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingcity' ElementID = 'edtbillingcity'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'BILL_CITY'
DataSource = WebDataSource1
end end
object edtBillState: TWebDBEdit object edtBillState: TWebDBEdit
Left = 19 Left = 19
...@@ -77,6 +85,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -77,6 +85,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingstate' ElementID = 'edtbillingstate'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'BILL_STATE'
DataSource = WebDataSource1
end end
object edtBillZip: TWebDBEdit object edtBillZip: TWebDBEdit
Left = 19 Left = 19
...@@ -87,6 +97,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -87,6 +97,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingzip' ElementID = 'edtbillingzip'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'BILL_ZIP'
DataSource = WebDataSource1
end end
object edtBillContact: TWebDBEdit object edtBillContact: TWebDBEdit
Left = 19 Left = 19
...@@ -97,6 +109,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -97,6 +109,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingcontact' ElementID = 'edtbillingcontact'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'BILL_CONTACT'
DataSource = WebDataSource1
end end
object edtPhone: TWebDBEdit object edtPhone: TWebDBEdit
Left = 19 Left = 19
...@@ -107,6 +121,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -107,6 +121,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtphone' ElementID = 'edtphone'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'PHONE'
DataSource = WebDataSource1
end end
object edtFax: TWebDBEdit object edtFax: TWebDBEdit
Left = 19 Left = 19
...@@ -117,6 +133,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -117,6 +133,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtfax' ElementID = 'edtfax'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'FAX'
DataSource = WebDataSource1
end end
object edtRep: TWebDBEdit object edtRep: TWebDBEdit
Left = 19 Left = 19
...@@ -127,10 +145,12 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -127,10 +145,12 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtrepid' ElementID = 'edtrepid'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'REP_USER_ID'
DataSource = WebDataSource1
end end
object btnSave: TWebButton object btnSave: TWebButton
Left = 280 Left = 88
Top = 407 Top = 525
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Save' Caption = 'Save'
...@@ -140,10 +160,11 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -140,10 +160,11 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Role = 'null' Role = 'null'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnSaveClick
end end
object btnCancel: TWebButton object btnCancel: TWebButton
Left = 280 Left = 88
Top = 367 Top = 485
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Cancel' Caption = 'Cancel'
...@@ -155,8 +176,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -155,8 +176,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object btnDelete: TWebButton object btnDelete: TWebButton
Left = 280 Left = 88
Top = 323 Top = 441
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Delete' Caption = 'Delete'
...@@ -166,8 +187,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -166,8 +187,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object btnClose: TWebButton object btnClose: TWebButton
Left = 396 Left = 204
Top = 323 Top = 441
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Close' Caption = 'Close'
...@@ -177,8 +198,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -177,8 +198,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object btnEdit: TWebButton object btnEdit: TWebButton
Left = 396 Left = 204
Top = 367 Top = 485
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Edit' Caption = 'Edit'
...@@ -222,6 +243,141 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -222,6 +243,141 @@ object FViewAddCustomer: TFViewAddCustomer
Role = 'null' Role = 'null'
WidthStyle = ssAuto WidthStyle = ssAuto
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCloseNotificationClick
end
end
object edtCustomerID: TWebDBEdit
Left = 151
Top = 12
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtcompanyid'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'CUSTOMER_ID'
DataSource = WebDataSource1
end
object edtQBID: TWebDBEdit
Left = 151
Top = 40
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtqbid'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'QB_LIST_ID'
DataSource = WebDataSource1
end
object wdbtcAddresses: TWebDBTableControl
Left = 190
Top = 204
Width = 631
Height = 200
ElementClassName = 'table'
ElementId = 'tblPhoneGrid'
BorderColor = clSilver
ChildOrder = 11
ElementFont = efCSS
ElementHeaderClassName = 'thead-light sticky-top bg-light'
ElementPosition = epRelative
ElementTableClassName = 'table table-striped table-hover table-bordered text-sm'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
Columns = <
item
DataField = 'ADDRESS'
Title = 'ADDRESS'
end>
DataSource = wdsShipTo
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 454
Top = 72
end
object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1
Left = 532
Top = 126
end
object XDataWebDataSet1: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 426
Top = 132
object XDataWebDataSet1SHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
object XDataWebDataSet1NAME: TStringField
FieldName = 'NAME'
end
object XDataWebDataSet1BILL_ADDRESS: TStringField
FieldName = 'BILL_ADDRESS'
end
object XDataWebDataSet1BILL_CITY: TStringField
FieldName = 'BILL_CITY'
end
object XDataWebDataSet1BILL_STATE: TStringField
FieldName = 'BILL_STATE'
end
object XDataWebDataSet1BILL_CONTACT: TStringField
FieldName = 'BILL_CONTACT'
end
object XDataWebDataSet1BILL_ZIP: TStringField
FieldName = 'BILL_ZIP'
end
object XDataWebDataSet1START_DATE: TStringField
FieldName = 'START_DATE'
end
object XDataWebDataSet1END_DATE: TStringField
FieldName = 'END_DATE'
end
object XDataWebDataSet1QB_LIST_ID: TStringField
FieldName = 'QB_LIST_ID'
end
object XDataWebDataSet1FAX: TStringField
FieldName = 'FAX'
end
object XDataWebDataSet1PHONE: TStringField
FieldName = 'PHONE'
end
object XDataWebDataSet1REP_USER_ID: TIntegerField
FieldName = 'REP_USER_ID'
end
object XDataWebDataSet1CUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end
object wdsShipTo: TWebDataSource
DataSet = xdwdsShipTo
Left = 698
Top = 128
end
object xdwdsShipTo: TXDataWebDataSet
Left = 698
Top = 44
object xdwdsShipToADDRESS: TStringField
FieldName = 'ADDRESS'
end end
end end
end end
...@@ -32,6 +32,14 @@ ...@@ -32,6 +32,14 @@
<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">Company ID</label>
<input id="edtcompanyid" class="form-control input-sm"style="width: 100px" required/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Quickbooks ID:</label>
<input id="edtqbid" class="form-control input-sm"style="width: 200px" required/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label> <label for="wdbe_first_name" class="form-label mt-2">Company Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/> <input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;"> <div class="invalid-feedback" style="font-size: 15px;">
...@@ -75,7 +83,7 @@ ...@@ -75,7 +83,7 @@
<h4 class="custom-h4 mt-3">Billing Information</h4> <h4 class="custom-h4 mt-3">Billing Information</h4>
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
<div class="col-auto"> <div class="col-12">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Address:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Address:</label>
<input id="edtbillingaddress" class="form-control input-sm" required/> <input id="edtbillingaddress" class="form-control input-sm" required/>
</div> </div>
...@@ -96,11 +104,29 @@ ...@@ -96,11 +104,29 @@
</div> </div>
<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">Billing Contact:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Contact:</label>
<input id="edtbillingcontact" class="form-control input-sm" style="width: 150px"/> <input id="edtbillingcontact" class="form-control input-sm" style="width: 250px"/>
</div> </div>
</div> </div>
<div id="order_table_section" class="overflow-auto mt-2"
style="max-height: calc(100vh - 250px); padding-bottom: 0; width: 100%;">
</div>
<h4 class="custom-h4 mt-3">Shipping Addresses</h4>
<hr class="custom-hr">
<div class="row">
<table id="tblPhoneGrid" class="table table-striped table-bordered" style="width: 100%;">
<thead class="sticky-top thead-light">
<tr style="font-size: 0.875rem;">
<!-- Table headers are dynamically generated -->
</tr>
</thead>
<tbody id="orderTableBody" class="align-middle">
<!-- Table rows are dynamically generated -->
</tbody>
</table>
</div> </div>
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true"> <div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
......
...@@ -3,9 +3,11 @@ unit AddCustomer; ...@@ -3,9 +3,11 @@ unit AddCustomer;
interface interface
uses uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls, System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls, WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.DBCtrls, WEBLib.ExtCtrls; WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB, WEBLib.Grids;
type type
TFViewAddCustomer = class(TWebForm) TFViewAddCustomer = class(TWebForm)
...@@ -29,15 +31,43 @@ type ...@@ -29,15 +31,43 @@ type
pnlMessage: TWebPanel; pnlMessage: TWebPanel;
lblMessage: TWebLabel; lblMessage: TWebLabel;
btnCloseNotification: TWebButton; btnCloseNotification: TWebButton;
XDataWebClient1: TXDataWebClient;
WebDataSource1: TWebDataSource;
XDataWebDataSet1: TXDataWebDataSet;
XDataWebDataSet1SHORT_NAME: TStringField;
XDataWebDataSet1NAME: TStringField;
XDataWebDataSet1BILL_ADDRESS: TStringField;
XDataWebDataSet1BILL_CITY: TStringField;
edtCustomerID: TWebDBEdit;
edtQBID: TWebDBEdit;
wdbtcAddresses: TWebDBTableControl;
wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet;
xdwdsShipToADDRESS: TStringField;
XDataWebDataSet1BILL_STATE: TStringField;
XDataWebDataSet1BILL_CONTACT: TStringField;
XDataWebDataSet1BILL_ZIP: TStringField;
XDataWebDataSet1START_DATE: TStringField;
XDataWebDataSet1END_DATE: TStringField;
XDataWebDataSet1QB_LIST_ID: TStringField;
XDataWebDataSet1FAX: TStringField;
XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1REP_USER_ID: TIntegerField;
XDataWebDataSet1CUSTOMER_ID: TIntegerField;
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
private private
{ Private declarations } { Private declarations }
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
[async] procedure GetCustomer();
[async] procedure SendCustomerToServer();
var var
customerID: string; customerID: string;
notification: string; notification: string;
mode: string;
public public
{ Public declarations } { Public declarations }
class function CreateForm(AElementID, customerInfo, info: string): TWebForm; class function CreateForm(AElementID, customerInfo, info: string): TWebForm;
...@@ -52,6 +82,66 @@ implementation ...@@ -52,6 +82,66 @@ implementation
uses View.Main; uses View.Main;
procedure TFViewAddCustomer.btnCloseNotificationClick(Sender: TObject);
begin
HideNotification();
end;
procedure TFViewAddCustomer.SendCustomerToServer();
var
customerJSON: TJSONObject;
Field: TField;
Response: TXDataClientResponse;
notification: TJSObject;
begin
customerJSON := TJSONObject.Create;
if dtpStartDate.Date <> 0 then
XDataWebDataSet1START_DATE.Value := DateTimeToStr(dtpStartDate.Date);
if dtpEndDate.Date <> 0 then
XDataWebDataSet1END_DATE.Value := DateTimeToStr(dtpEndDate.Date);
XDataWebDataSet1.First;
while not XDataWebDataSet1.Eof do
begin
for Field in XDataWebDataSet1.Fields do
begin
if Field is TStringField then
begin
if Field.AsString = '' then
customerJSON.AddPair(Field.FieldName, '')
else
customerJSON.AddPair(Field.FieldName, Field.AsString); // Add all other fields
end
else if Field is TIntegerField then
begin
customerJSON.AddPair(Field.FieldName, Field.AsString);
end;
end;
XDataWebDataSet1.Next;
end;
customerJSON.AddPair('mode', mode);
if mode = 'EDIT' then
customerJSON.AddPair('CUSTOMER_ID', customerID);
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCustomer',
[customerJSON.ToString]));
notification := TJSObject(Response.Result);
ShowNotification(string(notification['status']));
console.log(notification['status']);
end;
procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
begin
sendCustomerToServer();
end;
class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm; class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm;
begin begin
Application.CreateForm(TFViewAddCustomer, AElementID, Result, Application.CreateForm(TFViewAddCustomer, AElementID, Result,
...@@ -67,8 +157,59 @@ begin ...@@ -67,8 +157,59 @@ begin
end; end;
procedure TFViewAddCustomer.GetCustomer;
var
xdcResponse: TXDataClientResponse;
customer : TJSObject;
address: string;
items: TJSObject;
begin
if CustomerID = '' then
begin
console.log(CustomerID);
customerID := '-1';
mode := 'ADD';
end
else
mode := 'EDIT';
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer',
[customerID]));
customer := TJSObject(xdcResponse.Result);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
if CustomerID = '-1' then
begin
edtCustomerID.Text := '';
end;
if XDataWebDataSet1.FieldByName('START_DATE').AsString <> '' then
dtpStartDate.Date := XDataWebDataSet1.FieldByName('START_DATE').AsDateTime;
if XDataWebDataSet1.FieldByName('END_DATE').AsString <> '' then
dtpEndDate.Date := XDataWebDataSet1.FieldByName('End_DATE').AsDateTime;
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']);
xdwdsShipTo.Open;
{xdwdsQBItem.Close;
items := TJSObject(customer['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open;}
end;
procedure TFViewAddCustomer.WebFormShow(Sender: TObject); procedure TFViewAddCustomer.WebFormShow(Sender: TObject);
var
SQL: string;
begin begin
if notification = '' then
hideNotification();
getCustomer();
dtpStartDate.Date := 0; dtpStartDate.Date := 0;
dtpEndDate.Date := 0; dtpEndDate.Date := 0;
end; end;
......
...@@ -282,9 +282,6 @@ object FAddOrder: TFAddOrder ...@@ -282,9 +282,6 @@ object FAddOrder: TFAddOrder
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 726 Left = 726
Top = 7 Top = 7
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
object xdwdsCustomersNAME: TStringField object xdwdsCustomersNAME: TStringField
FieldName = 'NAME' FieldName = 'NAME'
end end
...@@ -294,6 +291,9 @@ object FAddOrder: TFAddOrder ...@@ -294,6 +291,9 @@ object FAddOrder: TFAddOrder
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 xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end end
object wdsCustomers: TWebDataSource object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers DataSet = xdwdsCustomers
......
...@@ -26,13 +26,13 @@ type ...@@ -26,13 +26,13 @@ type
WebLabel2: TWebLabel; WebLabel2: TWebLabel;
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet; xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField; xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField; xdwdsCustomersSHORT_NAME: TStringField;
wdsCustomers: TWebDataSource; wdsCustomers: TWebDataSource;
cbCuttingDie: TWebCheckBox; cbCuttingDie: TWebCheckBox;
edtNotification: TWebEdit; edtNotification: TWebEdit;
xdwdsCustomersstaff_fields_invoice_to: TStringField; xdwdsCustomersstaff_fields_invoice_to: TStringField;
xdwdsCustomersCUSTOMER_ID: TIntegerField;
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure edtSearchChange(Sender: TObject); procedure edtSearchChange(Sender: TObject);
procedure cbCorrugatedPlateClick(Sender: TObject); procedure cbCorrugatedPlateClick(Sender: TObject);
...@@ -166,7 +166,7 @@ begin ...@@ -166,7 +166,7 @@ begin
while not xdwdsCustomers.EOF do while not xdwdsCustomers.EOF do
begin begin
TMSFNCGrid1.RowCount := RowIndex + 1; TMSFNCGrid1.RowCount := RowIndex + 1;
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString; TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('CUSTOMER_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;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString; TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString;
......
...@@ -62,8 +62,17 @@ object FViewCustomers: TFViewCustomers ...@@ -62,8 +62,17 @@ object FViewCustomers: TFViewCustomers
Header.ListItemElementClassName = 'page-item' Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link' Header.ListLinkElementClassName = 'page-link'
WordWrap = True WordWrap = True
OnDblClickCell = wdbtcCustomersDblClickCell
Columns = < Columns = <
item item
DataField = 'CUSTOMER_ID'
Title = 'ID'
end
item
DataField = 'SHORT_NAME'
Title = 'SHORT_NAME'
end
item
DataField = 'START_DATE' DataField = 'START_DATE'
Title = 'Start Date' Title = 'Start Date'
end end
...@@ -135,11 +144,18 @@ object FViewCustomers: TFViewCustomers ...@@ -135,11 +144,18 @@ object FViewCustomers: TFViewCustomers
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 130 Left = 130
Top = 410 Top = 410
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
Size = 0
end
object xdwdsCustomersNAME: TStringField object xdwdsCustomersNAME: TStringField
FieldName = 'NAME' FieldName = 'NAME'
end end
object xdwdsCustomersSTART_DATE: TStringField object xdwdsCustomersSTART_DATE: TStringField
FieldName = 'START_DATE' FieldName = 'START_DATE'
end end
object xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end end
end end
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
<div class="col-auto"> <div class="col-auto">
<button id="btnaddcustomer" class="btn btn-secondary mt-3">Add Customer</button> <button id="btnaddcustomer" class="btn btn-secondary mt-3">Add Customer</button>
</div> </div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Quickbooks ID:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div> </div>
<!-- Entries Label Section d-flex justify-content-between w-100 mt-2--> <!-- Entries Label Section d-flex justify-content-between w-100 mt-2-->
......
...@@ -24,8 +24,11 @@ type ...@@ -24,8 +24,11 @@ type
xdwdsCustomers: TXDataWebDataSet; xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersNAME: TStringField; xdwdsCustomersNAME: TStringField;
xdwdsCustomersSTART_DATE: TStringField; xdwdsCustomersSTART_DATE: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersCUSTOMER_ID: TIntegerField;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject); procedure btnAddCustomerClick(Sender: TObject);
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
private private
{ Private declarations } { Private declarations }
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
...@@ -169,6 +172,13 @@ begin ...@@ -169,6 +172,13 @@ begin
end; end;
end; end;
procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
console.log(wdbtcCustomers.Cells[0, ARow]);
FViewMain.ViewAddCustomer(wdbtcCustomers.Cells[0, ARow], '') ;
end;
procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject); procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject);
begin begin
FViewMain.ViewAddCustomer('', ''); FViewMain.ViewAddCustomer('', '');
......
...@@ -864,7 +864,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -864,7 +864,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object btnSave: TWebButton object btnSave: TWebButton
Left = 526 Left = 530
Top = 560 Top = 560
Width = 96 Width = 96
Height = 25 Height = 25
......
...@@ -563,7 +563,8 @@ begin ...@@ -563,7 +563,8 @@ begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder',
[orderJSON.ToString])); [orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result); jsObj := JS.TJSObject(Response.Result);
OrderID := JS.toString(jsObj.Properties['OrderID']); if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
mode := 'EDIT'; mode := 'EDIT';
end; end;
......
...@@ -125,32 +125,6 @@ ...@@ -125,32 +125,6 @@
<textarea id="edtspecialinstructions" class="form-control" style=" width: 500px; height: 150px;"></textarea> <textarea id="edtspecialinstructions" class="form-control" style=" width: 500px; height: 150px;"></textarea>
</div> </div>
</div> </div>
<div class="row">
<div class="col-auto">
<button id="btnconfirm" class="btn btn-primary btn-sm float-end my-2">Save</button>
</div>
<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="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>
</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 class="col-auto">
<button id="btnedit" class="btn btn-primary btn-sm float-end my-2">Edit</button>
</div>
<div class="col-auto">
<button id="btnadd" class="btn btn-primary btn-sm float-end my-2">Add</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 fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
......
...@@ -224,8 +224,6 @@ begin ...@@ -224,8 +224,6 @@ begin
orderJSON.AddPair('mode', mode); orderJSON.AddPair('mode', mode);
if mode = 'EDIT' then if mode = 'EDIT' then
orderJSON.AddPair('ORDER_ID', orderID); orderJSON.AddPair('ORDER_ID', orderID);
console.log(orderJSON.GetValue('ORDER_ID'));
console.log(orderJSON);
if mode = 'ADD' then if mode = 'ADD' then
ShowNotification('Success:Order Added Successfully!') ShowNotification('Success:Order Added Successfully!')
...@@ -331,10 +329,15 @@ end; ...@@ -331,10 +329,15 @@ end;
procedure TFOrderEntryCuttingDie.AddCuttingDieOrder(orderJSON: TJSONObject); procedure TFOrderEntryCuttingDie.AddCuttingDieOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server // sends the order JSON object to the server
var var
Response: TXDataClientResponse; Response: TXDataClientResponse;
jsObj: TJSObject;
begin begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCuttingDieOrder', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCuttingDieOrder',
[orderJSON.ToString])); [orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result);
if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
mode := 'EDIT';
end; end;
class function TFOrderEntryCuttingDie.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm; class function TFOrderEntryCuttingDie.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm;
......
...@@ -297,7 +297,6 @@ begin ...@@ -297,7 +297,6 @@ begin
input := TJSHTMLInputElement(document.getElementById('edtinvoiceto')); input := TJSHTMLInputElement(document.getElementById('edtinvoiceto'));
if edtInvoiceTo.Text = '' then if edtInvoiceTo.Text = '' then
begin begin
console.log('hot');
input.classList.add('is-invalid'); input.classList.add('is-invalid');
result := false; result := false;
end end
...@@ -516,7 +515,6 @@ var ...@@ -516,7 +515,6 @@ var
begin begin
// Call the server method to generate the PDF // Call the server method to generate the PDF
console.log(orderID);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderWebPDF', [orderID])); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderWebPDF', [orderID]));
jsObject := JS.TJSObject(xdcResponse.Result); jsObject := JS.TJSObject(xdcResponse.Result);
pdfURL := JS.toString(jsObject.Properties['value']); pdfURL := JS.toString(jsObject.Properties['value']);
...@@ -524,16 +522,21 @@ begin ...@@ -524,16 +522,21 @@ begin
// Open the PDF in a new browser tab without needing a different form // Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets // This method is much faster too, even for large datasets
window.open(pdfURL, '_blank'); window.open(pdfURL, '_blank');
console.log(pdfURL);
end; end;
procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject); procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server // sends the order JSON object to the server
var var
Response: TXDataClientResponse; Response: TXDataClientResponse;
jsObj: TJSObject;
begin begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddWebOrder', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddWebOrder',
[orderJSON.ToString])); [orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result);
if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
console.log(OrderID);
mode := 'EDIT';
end; end;
class function TFOrderEntryWeb.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm; class function TFOrderEntryWeb.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm;
...@@ -704,7 +707,6 @@ begin ...@@ -704,7 +707,6 @@ begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetWebOrder', xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetWebOrder',
[Order_ID])); [Order_ID]));
order := TJSObject(xdcResponse.Result); order := TJSObject(xdcResponse.Result);
console.log(order);
data := TJSArray(order['data']); data := TJSArray(order['data']);
XDataWebDataSet1.Close; XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(order); XDataWebDataSet1.SetJsonData(order);
...@@ -712,12 +714,10 @@ begin ...@@ -712,12 +714,10 @@ begin
if XDataWebDataSet1quantity_and_colors_qty_colors.Value <> '' then if XDataWebDataSet1quantity_and_colors_qty_colors.Value <> '' then
begin begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1quantity_and_colors_qty_colors.Value)); colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1quantity_and_colors_qty_colors.Value));
console.log(colorObject);
colorList := TJSArray(colorObject['items']); colorList := TJSArray(colorObject['items']);
for I := 0 to colorList.length -1 do for I := 0 to colorList.length -1 do
begin begin
color := TJSObject(colorList[i]); color := TJSObject(colorList[i]);
console.log(color);
addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size'])); addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size']));
end; end;
end; end;
......
...@@ -717,8 +717,8 @@ object FSearch: TFSearch ...@@ -717,8 +717,8 @@ object FSearch: TFSearch
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 object xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'ID' FieldName = 'CUSTOMER_ID'
end end
end end
object wdsCustomers: TWebDataSource object wdsCustomers: TWebDataSource
......
...@@ -55,7 +55,7 @@ type ...@@ -55,7 +55,7 @@ type
WebLabel5: TWebLabel; WebLabel5: TWebLabel;
edtCompanyName: TWebEdit; edtCompanyName: TWebEdit;
xdwdsCustomersSHORT_NAME: TStringField; xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersID: TIntegerField; xdwdsCustomersCUSTOMER_ID: 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);
...@@ -116,7 +116,6 @@ begin ...@@ -116,7 +116,6 @@ begin
DateFormatSettings := TFormatSettings.Create; DateFormatSettings := TFormatSettings.Create;
DateFormatSettings.ShortDateFormat := 'yyyy/mm/dd'; DateFormatSettings.ShortDateFormat := 'yyyy/mm/dd';
console.log(UpperCase(Copy(params.Values['orderType'], 1, 1)) + LowerCase(Copy(params.Values['orderType'], 2, MaxInt)));
wcbOrderType.Text := UpperCase(Copy(params.Values['orderType'], 1, 1)) + LowerCase(Copy(params.Values['orderType'], 2, MaxInt)); wcbOrderType.Text := UpperCase(Copy(params.Values['orderType'], 1, 1)) + LowerCase(Copy(params.Values['orderType'], 2, MaxInt));
edtOrderID.Text := params.Values['orderID']; edtOrderID.Text := params.Values['orderID'];
edtCompanyID.Text := params.Values['companyID']; edtCompanyID.Text := params.Values['companyID'];
...@@ -287,7 +286,7 @@ begin ...@@ -287,7 +286,7 @@ begin
while not xdwdsCustomers.EOF do while not xdwdsCustomers.EOF do
begin begin
TMSFNCGrid1.RowCount := RowIndex + 1; TMSFNCGrid1.RowCount := RowIndex + 1;
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString; TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('CUSTOMER_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;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString; TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString;
......
...@@ -114,10 +114,20 @@ type ...@@ -114,10 +114,20 @@ type
TCustomerItem = class TCustomerItem = class
Public Public
NAME: string; NAME: string;
ID: integer; CUSTOMER_ID: integer;
SHORT_NAME: string; SHORT_NAME: string;
BILL_ADDRESS: string;
BILL_CITY: string;
BILL_STATE: string;
BILL_ZIP: string;
BILL_CONTACT: string;
PHONE: string;
staff_fields_invoice_to: string; staff_fields_invoice_to: string;
START_DATE: String; START_DATE: String;
END_DATE: string;
QB_LIST_ID: string;
FAX: string;
REP_USER_ID: string;
ADDRESS_LIST: TList<TAddressItem>; ADDRESS_LIST: TList<TAddressItem>;
ITEMS: TItemList; ITEMS: TItemList;
end; end;
...@@ -388,6 +398,7 @@ type ...@@ -388,6 +398,7 @@ type
function AddCuttingDieOrder(orderInfo: string): TJSONObject; function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string; function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
function SetStatus(statusOptions: string): string; function SetStatus(statusOptions: string): string;
function AddCustomer(customerInfo: string): TJSONObject;
end; end;
implementation implementation
......
...@@ -96,7 +96,7 @@ var ...@@ -96,7 +96,7 @@ var
SQL: string; SQL: string;
customer: TCustomerItem; customer: TCustomerItem;
begin begin
SQL := 'select NAME, CUSTOMER_ID, SHORT_NAME, BILL_ADDRESS, BILL_CITY, BILL_STATE, BILL_ZIP, START_DATE from customers'; SQL := 'select * from customers';
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerList.Create; result := TCustomerList.Create;
...@@ -108,13 +108,16 @@ begin ...@@ -108,13 +108,16 @@ begin
begin begin
customer := TCustomerItem.Create; customer := TCustomerItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( customer ); TXDataOperationContext.Current.Handler.ManagedObjects.Add( customer );
customer.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; customer.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
customer.ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger; customer.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
customer.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString; customer.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
customer.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString + customer.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString + ', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString +
' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString; ' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
customer.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString; customer.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.data.Add(customer); result.data.Add(customer);
result.count := result.count + 1; result.count := result.count + 1;
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
...@@ -129,16 +132,31 @@ var ...@@ -129,16 +132,31 @@ var
SQL: string; SQL: string;
ADDRESS: TAddressItem; ADDRESS: TAddressItem;
begin begin
SQL := 'SELECT c.NAME, c.SHORT_NAME, c.BILL_ADDRESS_BLOCK, s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + ID; SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + ID;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerItem.Create; result := TCustomerItem.Create;
result.ADDRESS_LIST := TList<TAddressItem>.Create; result.ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.ADDRESS_LIST ); TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.ADDRESS_LIST );
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.ID := StrToInt(ID); result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString; result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS_BLOCK').AsString; result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString +
' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
result.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.BILL_ADDRESS := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString;
result.BILL_CITY := ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString;
result.BILL_STATE := ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString;
result.BILL_ZIP := ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
result.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.BILL_CONTACT := ordersDB.UniQuery1.FieldByName('BILL_CONTACT').AsString;
result.PHONE := ordersDB.UniQuery1.FieldByName('PHONE').AsString;
result.END_DATE := ordersDB.UniQuery1.FieldByName('END_DATE').AsString;
result.QB_LIST_ID := ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString;
result.FAX := ordersDB.UniQuery1.FieldByName('FAX').AsString;
result.REP_USER_ID := ordersDB.UniQuery1.FieldByName('REP_USER_ID').AsString;
while not ordersDB.UniQuery1.Eof do while not ordersDB.UniQuery1.Eof do
begin begin
...@@ -203,6 +221,8 @@ var ...@@ -203,6 +221,8 @@ var
CustomerID: integer; CustomerID: integer;
mode: string; mode: string;
temp: string; temp: string;
msg: string;
unique: boolean;
begin begin
DateFormat := TFormatSettings.Create; DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd'; DateFormat.ShortDateFormat := 'yyyy-mm-dd';
...@@ -217,60 +237,90 @@ begin ...@@ -217,60 +237,90 @@ begin
if mode = 'ADD' then if mode = 'ADD' then
begin begin
// Update RevisionID // Update RevisionID
SQL := 'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID'); SQL := 'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + quotedStr('GEN_CUSTOMER_ID');
OrdersDB.UniQuery1.SQL.Text := SQL; OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL; OrdersDB.UniQuery1.ExecSQL;
// Retrieve updated RevisionID // Retrieve updated RevisionID
SQL := 'select KEYVALUE from idfield where KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID'); SQL := 'select KEYVALUE from idfield where KEYNAME = ' + quotedStr('GEN_CUSTOMER_ID');
doQuery(OrdersDB.UniQuery1, SQL); doQuery(OrdersDB.UniQuery1, SQL);
CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger; CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger;
end end
else else
CustomerID := JSONData.GetValue<integer>('CustomerID'); CustomerID := JSONData.GetValue<integer>('CUSTOMER_ID');
SQL := 'select CUSTOMER_ID from customers where SHORT_NAME = ' + quotedStr(JSONData.GetValue<string>('SHORT_NAME'));
doQuery(OrdersDB.UniQuery1, SQL);
if mode = 'ADD' then if mode = 'ADD' then
SQL := 'select * from customers where ORDER_ID = 0 and ORDER_ID <> 0' begin
if OrdersDB.UniQuery1.IsEmpty then
unique := true
else
unique := false;
end
else else
begin begin
SQL := 'select * from customers where ORDER_ID = ' + IntToStr(CustomerID); if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger = CustomerID) ) then
unique := true
else
unique := false;
end; end;
doQuery(ordersDB.UniQuery1, SQL);
try if unique then
begin
if mode = 'ADD' then if mode = 'ADD' then
ordersDB.UniQuery1.Insert SQL := 'select * from customers where CUSTOMER_ID = 0 and CUSTOMER_ID <> 0'
else else
ordersDB.UniQuery1.Edit;
for Pair in JSONData do
begin begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset SQL := 'select * from customers where CUSTOMER_ID = ' + IntToStr(CustomerID);
if Assigned(Field) then end;
doQuery(ordersDB.UniQuery1, SQL);
try
if mode = 'ADD' then
ordersDB.UniQuery1.Insert
else
ordersDB.UniQuery1.Edit;
for Pair in JSONData do
begin begin
if (Field is TDateTimeField) then Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
if Assigned(Field) then
begin begin
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then if (Field is TDateTimeField) then
Field.Clear // This sets the field to NULL (empty) begin
else if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value); Field.Clear // This sets the field to NULL (empty)
end else
else if Pair.JsonValue.Value <> '' then TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
Field.AsString := Pair.JsonValue.Value; end
else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value;
end;
end; end;
end; ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger := CustomerID;
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := CustomerID;
// Post the record to the database // Post the record to the database
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
Result := TJSONObject.Create.AddPair('status', 'success'); if mode = 'ADD' then
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); msg := 'Success:Customer Successfully Added'
except else
on E: Exception do msg := 'Success:Customer Successfully Edited';
begin
Result := TJSONObject.Create.AddPair('error', E.Message); Result := TJSONObject.Create.AddPair('status', msg);
end TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
end; except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
end
end;
end
else
Result := TJSONObject.Create.AddPair('status', 'Failure:Company Account Name Must Be Unique');
end; end;
function TLookupService.GenerateOrderCorrugatedPDF(orderID: string): string; function TLookupService.GenerateOrderCorrugatedPDF(orderID: string): string;
...@@ -1746,14 +1796,13 @@ begin ...@@ -1746,14 +1796,13 @@ begin
AddToRevisionsTable(IntToStr(ORDER_ID), 'web_plate_orders_revisions', JSONData); AddToRevisionsTable(IntToStr(ORDER_ID), 'web_plate_orders_revisions', JSONData);
Result := TJSONObject.Create.AddPair('status', 'success'); 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
on E: Exception do on E: Exception do
begin begin
Result := TJSONObject.Create.AddPair('error', E.Message); Result := TJSONObject.Create.AddPair('error', E.Message);
end end
else
result := TJSONObject.Create.AddPair('OrderID', ORDER_ID);
end; end;
end; end;
...@@ -1776,7 +1825,6 @@ begin ...@@ -1776,7 +1825,6 @@ begin
if JSONData = nil then if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode'); mode := JSONData.GetValue<string>('mode');
ORDER_ID := JSONData.GetValue<integer>('ORDER_ID');
AddToOrdersTable(mode, 'cutting_die', JSONData); AddToOrdersTable(mode, 'cutting_die', JSONData);
...@@ -1829,7 +1877,10 @@ begin ...@@ -1829,7 +1877,10 @@ begin
if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) 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);
AddToRevisionsTable(IntToStr(ORDER_ID), 'cutting_die_orders_revisions', JSONData);
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
on E: Exception do on E: Exception do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
MemoLogLevel=3 MemoLogLevel=3
FileLogLevel=5 FileLogLevel=5
webClientVersion=0.9.2 webClientVersion=0.9.2
LogFileNum=469 LogFileNum=503
[Database] [Database]
Server=192.168.159.131 Server=192.168.159.131
...@@ -17,5 +17,5 @@ Password=emsys01 ...@@ -17,5 +17,5 @@ Password=emsys01
CompanyID=9341454272655710 CompanyID=9341454272655710
ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy
ClientSecret=bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN ClientSecret=bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN
RefreshToken=RT1-96-H0-175492905304b5i0seva405h1axtuf RefreshToken=RT1-86-H0-17551964757vq6lk1eu183mmu09c1o
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