Commit aba393fe by Cam Hayes

Shipping Address Entry is working on the Add Customer Form

parent 2603867e
...@@ -149,8 +149,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -149,8 +149,8 @@ object FViewAddCustomer: TFViewAddCustomer
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object btnSave: TWebButton object btnSave: TWebButton
Left = 88 Left = 19
Top = 525 Top = 402
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Save' Caption = 'Save'
...@@ -163,8 +163,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -163,8 +163,8 @@ object FViewAddCustomer: TFViewAddCustomer
OnClick = btnSaveClick OnClick = btnSaveClick
end end
object btnCancel: TWebButton object btnCancel: TWebButton
Left = 88 Left = 19
Top = 485 Top = 473
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Cancel' Caption = 'Cancel'
...@@ -174,10 +174,11 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -174,10 +174,11 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Role = 'null' Role = 'null'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end end
object btnDelete: TWebButton object btnDelete: TWebButton
Left = 88 Left = 19
Top = 441 Top = 371
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Delete' Caption = 'Delete'
...@@ -187,8 +188,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -187,8 +188,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object btnClose: TWebButton object btnClose: TWebButton
Left = 204 Left = 19
Top = 441 Top = 433
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Close' Caption = 'Close'
...@@ -196,10 +197,11 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -196,10 +197,11 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'btnclose' ElementID = 'btnclose'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCloseClick
end end
object btnEdit: TWebButton object btnEdit: TWebButton
Left = 204 Left = 19
Top = 485 Top = 504
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Edit' Caption = 'Edit'
...@@ -207,6 +209,7 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -207,6 +209,7 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'btnedit' ElementID = 'btnedit'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnEditClick
end end
object pnlMessage: TWebPanel object pnlMessage: TWebPanel
Left = 324 Left = 324
...@@ -304,13 +307,92 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -304,13 +307,92 @@ object FViewAddCustomer: TFViewAddCustomer
Header.ListItemElementClassName = 'page-item' Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link' Header.ListLinkElementClassName = 'page-link'
WordWrap = True WordWrap = True
OnDblClickCell = wdbtcAddressesDblClickCell
Columns = < Columns = <
item item
DataField = 'ship_id'
Title = 'ID'
end
item
DataField = 'ADDRESS' DataField = 'ADDRESS'
Title = 'ADDRESS' Title = 'Address'
end> end>
DataSource = wdsShipTo DataSource = wdsShipTo
end end
object btnAddAddress: TWebButton
Left = 190
Top = 420
Width = 96
Height = 25
Caption = 'Add Address'
ChildOrder = 21
ElementID = 'btnaddaddress'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddAddressClick
end
object edtShippingAddress: TWebEdit
Left = 190
Top = 460
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingaddress'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtShippingState: TWebEdit
Left = 190
Top = 516
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingstate'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtShippingContact: TWebEdit
Left = 190
Top = 578
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcontact'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtShippingZip: TWebEdit
Left = 190
Top = 550
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingzip'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtShippingCity: TWebEdit
Left = 190
Top = 488
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcity'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnClear: TWebButton
Left = 296
Top = 420
Width = 96
Height = 25
Caption = 'Clear'
ChildOrder = 27
ElementID = 'btnclear'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnClearClick
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 454 Left = 454
...@@ -322,6 +404,7 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -322,6 +404,7 @@ object FViewAddCustomer: TFViewAddCustomer
Top = 126 Top = 126
end end
object XDataWebDataSet1: TXDataWebDataSet object XDataWebDataSet1: TXDataWebDataSet
AfterEdit = XDataWebDataSet1AfterEdit
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 426 Left = 426
Top = 132 Top = 132
...@@ -374,10 +457,29 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -374,10 +457,29 @@ object FViewAddCustomer: TFViewAddCustomer
Top = 128 Top = 128
end end
object xdwdsShipTo: TXDataWebDataSet object xdwdsShipTo: TXDataWebDataSet
AfterEdit = xdwdsShipToAfterEdit
Left = 698 Left = 698
Top = 44 Top = 44
object xdwdsShipToADDRESS: TStringField object xdwdsShipToADDRESS: TStringField
FieldName = 'ADDRESS' FieldName = 'ADDRESS'
end end
object xdwdsShipToship_id: TStringField
FieldName = 'ship_id'
end
object xdwdsShipToshipping_address: TStringField
FieldName = 'shipping_address'
end
object xdwdsShipTocity: TStringField
FieldName = 'city'
end
object xdwdsShipTostate: TStringField
FieldName = 'state'
end
object xdwdsShipTozip: TStringField
FieldName = 'zip'
end
object xdwdsShipTocontact: TStringField
FieldName = 'contact'
end
end end
end end
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
</div> </div>
</nav> </nav>
<div class="row mx-5"> <div class="row mx-5">
<div class="col-12 col-md-8">
</div>
<h4 class="custom-h4 mt-3">Company Information</h4> <h4 class="custom-h4 mt-3">Company Information</h4>
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
...@@ -40,16 +37,16 @@ ...@@ -40,16 +37,16 @@
<input id="edtqbid" class="form-control input-sm"style="width: 200px" required/> <input id="edtqbid" class="form-control input-sm"style="width: 200px" required/>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" 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;">
Please Provide a Company Name. Please Provide a Company Name.
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Account Name:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Company Account Name:</label>
<input id="edtcompanyaccountname"type="text" class="form-control" style="width: 150px" required/> <input id="edtcompanyaccountname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;"> <div class="invalid-feedback" id="shortnamefeedback" style="font-size: 15px;">
Please Provide a Company Account Name. Please Provide a Company Account Name.
</div> </div>
</div> </div>
...@@ -67,17 +64,11 @@ ...@@ -67,17 +64,11 @@
</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">Fax:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Fax:</label>
<input id="edtfax" class="form-control input-sm"style="width: 200px" required/> <input id="edtfax" class="form-control input-sm"style="width: 200px"/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Invoice Address.
</div>
</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">Representative ID:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Representative ID:</label>
<input id="edtrepid" class="form-control input-sm" style="width: 200px" required/> <input id="edtrepid" class="form-control input-sm" style="width: 200px"/>
<div class="invalid-feedback" style="font-size: 15px"; >
Please Provide a Ship To Address.
</div>
</div> </div>
</div> </div>
<h4 class="custom-h4 mt-3">Billing Information</h4> <h4 class="custom-h4 mt-3">Billing Information</h4>
...@@ -113,16 +104,50 @@ ...@@ -113,16 +104,50 @@
<h4 class="custom-h4 mt-3">Shipping Addresses</h4> <h4 class="custom-h4 mt-3">Shipping Addresses</h4>
<hr class="custom-hr"> <hr class="custom-hr">
<div class="row"> <div class="row">
<table id="tblPhoneGrid" class="table table-striped table-bordered" style="width: 100%;"> <table id="tblPhoneGrid" class="table table-striped table-bordered" style="width: 100%;">
<thead class="sticky-top thead-light"> <thead class="sticky-top thead-light">
<tr style="font-size: 0.875rem;"> <tr style="font-size: 0.875rem;">
<!-- Table headers are dynamically generated --> <!-- Table headers are dynamically generated -->
</tr> </tr>
</thead> </thead>
<tbody id="orderTableBody" class="align-middle"> <tbody id="orderTableBody" class="align-middle">
<!-- Table rows are dynamically generated --> <!-- Table rows are dynamically generated -->
</tbody> </tbody>
</table> </table>
</div>
<div class="row mt-3">
<div class="col-12">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Shipping Address:</label>
<input id="edtshippingaddress" class="form-control input-sm" required/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Shipping City</label>
<input id="edtshippingcity" class="form-control input-sm" style="width: 250px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Shipping State:</label>
<input id="edtshippingstate" class="form-control input-sm" style="width: 100px"/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Order Date.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Shipping Zip Code:</label>
<input id="edtshippingzip" class="form-control input-sm" style="width: 200px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Shipping Contact:</label>
<input id="edtshippingcontact" class="form-control input-sm" style="width: 250px"/>
</div>
</div>
<div class="row mt-3">
<div class="col-auto">
<button id="btnaddaddress" class="btn btn-danger btn-sm">Add Address</button>\
</div>
<div class="col-auto">
<button id="btnclear" class="btn btn-primary btn-sm">Clear</button>
</div>
</div>
</div> </div>
......
...@@ -43,7 +43,6 @@ type ...@@ -43,7 +43,6 @@ type
wdbtcAddresses: TWebDBTableControl; wdbtcAddresses: TWebDBTableControl;
wdsShipTo: TWebDataSource; wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet; xdwdsShipTo: TXDataWebDataSet;
xdwdsShipToADDRESS: TStringField;
XDataWebDataSet1BILL_STATE: TStringField; XDataWebDataSet1BILL_STATE: TStringField;
XDataWebDataSet1BILL_CONTACT: TStringField; XDataWebDataSet1BILL_CONTACT: TStringField;
XDataWebDataSet1BILL_ZIP: TStringField; XDataWebDataSet1BILL_ZIP: TStringField;
...@@ -54,16 +53,42 @@ type ...@@ -54,16 +53,42 @@ type
XDataWebDataSet1PHONE: TStringField; XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1REP_USER_ID: TIntegerField; XDataWebDataSet1REP_USER_ID: TIntegerField;
XDataWebDataSet1CUSTOMER_ID: TIntegerField; XDataWebDataSet1CUSTOMER_ID: TIntegerField;
btnAddAddress: TWebButton;
edtShippingAddress: TWebEdit;
edtShippingState: TWebEdit;
edtShippingContact: TWebEdit;
edtShippingZip: TWebEdit;
edtShippingCity: TWebEdit;
btnClear: TWebButton;
xdwdsShipToADDRESS: TStringField;
xdwdsShipToship_id: TStringField;
xdwdsShipToshipping_address: TStringField;
xdwdsShipTocity: TStringField;
xdwdsShipTostate: TStringField;
xdwdsShipTozip: TStringField;
xdwdsShipTocontact: TStringField;
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject); procedure btnCloseNotificationClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject); procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure xdwdsShipToAfterEdit(DataSet: TDataSet);
procedure XDataWebDataSet1AfterEdit(DataSet: TDataSet);
procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure wdbtcAddressesDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure btnAddAddressClick(Sender: TObject);
procedure btnClearClick(Sender: TObject);
private private
{ Private declarations } { Private declarations }
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure ViewMode();
procedure EditMode();
[async] procedure GetCustomer(); [async] procedure GetCustomer();
[async] procedure SendCustomerToServer(); [async] procedure SendCustomerToServer();
[async] procedure SendAddressToServer();
function Verify(): boolean;
var var
customerID: string; customerID: string;
notification: string; notification: string;
...@@ -80,19 +105,123 @@ implementation ...@@ -80,19 +105,123 @@ implementation
{$R *.dfm} {$R *.dfm}
uses View.Main; uses View.Main, View.Customers;
procedure TFViewAddCustomer.SendAddressToServer;
var
Field: TField;
AddressJSON: TJSONObject;
Response: TXDataClientResponse;
notification: TJSObject;
begin
AddressJSON := TJSONObject.Create;
XDataWebDataSet1.First;
AddressJSON.AddPair('address', edtShippingAddress.Text);
AddressJSON.AddPair('city', edtShippingcity.Text);
AddressJSON.AddPair('state', edtShippingstate.Text);
AddressJSON.AddPair('zip', edtShippingzip.Text);
AddressJSON.AddPair('contact', edtShippingContact.Text);
AddressJSON.AddPair('customer_id', customerID);
if btnAddAddress.Caption = 'Add Address' then
AddressJSON.AddPair('mode', 'ADD')
else
begin
AddressJSON.AddPair('mode', 'EDIT');
AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString);
end;
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString]));
notification := TJSObject(Response.Result);
ShowNotification(string(notification['status']));
end;
procedure TFViewAddCustomer.btnAddAddressClick(Sender: TObject);
begin
if btnAddAddress.Caption = 'Save' then
btnAddAddress.Caption := 'Add Address';
SendAddressToServer();
end;
procedure TFViewAddCustomer.btnCancelClick(Sender: TObject);
begin
FViewMain.change := false;
if CustomerID <> '' then
begin
FViewMain.ViewAddCustomer(CustomerID, 'Failure:Changes Discarded');
end
else
FViewMain.ShowForm(TFViewCustomers);
end;
procedure TFViewAddCustomer.btnClearClick(Sender: TObject);
begin
edtShippingAddress.Text := '';
edtShippingCity.Text := '';
edtShippingState.Text := '';
edtShippingZip.Text := '';
edtShippingContact.Text := '';
btnAddAddress.Caption := 'Add Address';
end;
procedure TFViewAddCustomer.btnCloseClick(Sender: TObject);
begin
FViewMain.ShowForm(TFViewCustomers)
end;
procedure TFViewAddCustomer.btnCloseNotificationClick(Sender: TObject); procedure TFViewAddCustomer.btnCloseNotificationClick(Sender: TObject);
begin begin
HideNotification(); HideNotification();
end; end;
procedure TFViewAddCustomer.btnEditClick(Sender: TObject);
begin
EditMode();
end;
procedure TFViewAddCustomer.EditMode;
begin
FViewMain.change := true;
btnDelete.Enabled := false;
btnClose.Enabled := false;
btnSave.Enabled := true;
btnCancel.Enabled := True;
btnEdit.Enabled := false;
end;
procedure TFViewAddCustomer.ViewMode;
begin
btnDelete.Enabled := true;
btnClose.Enabled := true;
btnSave.Enabled := false;
btnCancel.Enabled := false;
btnEdit.Enabled := true;
FViewMain.change := false;
end;
procedure TFViewAddCustomer.wdbtcAddressesDblClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
xdwdsShipTo.Locate('ship_id', wdbtcAddresses.Cells[0, ARow], []);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString;
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString;
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString;
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString;
btnAddAddress.Caption := 'Save';
end;
procedure TFViewAddCustomer.SendCustomerToServer(); procedure TFViewAddCustomer.SendCustomerToServer();
var var
customerJSON: TJSONObject; customerJSON: TJSONObject;
Field: TField; Field: TField;
Response: TXDataClientResponse; Response: TXDataClientResponse;
notification: TJSObject; notification: TJSObject;
input: TJSHTMLElement;
msg: string;
begin begin
customerJSON := TJSONObject.Create; customerJSON := TJSONObject.Create;
...@@ -132,14 +261,50 @@ begin ...@@ -132,14 +261,50 @@ begin
[customerJSON.ToString])); [customerJSON.ToString]));
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowNotification(string(notification['status'])); msg := string(notification['status']);
console.log(notification['status']); ShowNotification(msg);
if msg.Contains('Failure') then
begin
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
input.classList.add('is-invalid');
end;
end; end;
function TFViewAddCustomer.Verify(): boolean;
var
input: TJSHTMLElement;
begin
result := true;
input := TJSHTMLInputElement(document.getElementById('edtcompanyname'));
if edtName.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
if edtShortName.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
end;
procedure TFViewAddCustomer.btnSaveClick(Sender: TObject); procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
begin begin
sendCustomerToServer(); if verify then
begin
sendCustomerToServer();
ViewMode();
end;
end; end;
class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm; class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm;
...@@ -179,6 +344,8 @@ begin ...@@ -179,6 +344,8 @@ begin
XDataWebDataSet1.SetJsonData(customer); XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open; XDataWebDataSet1.Open;
console.log(customer['ADDRESS_LIST']);
if CustomerID = '-1' then if CustomerID = '-1' then
begin begin
edtCustomerID.Text := ''; edtCustomerID.Text := '';
...@@ -208,12 +375,27 @@ begin ...@@ -208,12 +375,27 @@ begin
if notification = '' then if notification = '' then
hideNotification(); hideNotification();
if mode = 'ADD' then
EditMode()
else
ViewMode();
getCustomer(); getCustomer();
dtpStartDate.Date := 0; dtpStartDate.Date := 0;
dtpEndDate.Date := 0; dtpEndDate.Date := 0;
end; end;
procedure TFViewAddCustomer.XDataWebDataSet1AfterEdit(DataSet: TDataSet);
begin
EditMode();
end;
procedure TFViewAddCustomer.xdwdsShipToAfterEdit(DataSet: TDataSet);
begin
EditMode();
end;
procedure TFViewAddCustomer.HideNotification; procedure TFViewAddCustomer.HideNotification;
begin begin
pnlMessage.ElementHandle.hidden := True; pnlMessage.ElementHandle.hidden := True;
......
...@@ -30,58 +30,6 @@ object FViewCustomers: TFViewCustomers ...@@ -30,58 +30,6 @@ object FViewCustomers: TFViewCustomers
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnAddCustomerClick OnClick = btnAddCustomerClick
end end
object wdbtcCustomers: TWebDBTableControl
Left = 9
Top = 138
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
OnDblClickCell = wdbtcCustomersDblClickCell
Columns = <
item
DataField = 'CUSTOMER_ID'
Title = 'ID'
end
item
DataField = 'SHORT_NAME'
Title = 'SHORT_NAME'
end
item
DataField = 'START_DATE'
Title = 'Start Date'
end
item
DataField = 'NAME'
Title = 'Name'
end>
DataSource = wdsCustomers
end
object wcbPageSize: TWebComboBox object wcbPageSize: TWebComboBox
Left = 22 Left = 22
Top = 52 Top = 52
...@@ -108,7 +56,7 @@ object FViewCustomers: TFViewCustomers ...@@ -108,7 +56,7 @@ object FViewCustomers: TFViewCustomers
Height = 33 Height = 33
ElementID = 'view.login.message' ElementID = 'view.login.message'
ChildOrder = 17 ChildOrder = 17
TabOrder = 3 TabOrder = 2
object lblMessage: TWebLabel object lblMessage: TWebLabel
Left = 16 Left = 16
Top = 11 Top = 11
...@@ -130,20 +78,83 @@ object FViewCustomers: TFViewCustomers ...@@ -130,20 +78,83 @@ object FViewCustomers: TFViewCustomers
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
end end
object wdbtcCustomers: TWebDBTableControl
Left = 8
Top = 202
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
OnDblClickCell = wdbtcCustomersDblClickCell
Columns = <
item
DataField = 'CUSTOMER_ID'
Title = 'Customer ID'
end
item
DataField = 'SHORT_NAME'
Title = 'Account Name'
end
item
DataField = 'NAME'
Title = 'Name'
end
item
DataField = 'START_DATE'
Title = 'Start Date'
end>
DataSource = wdsCustomers
end
object edtFilter: TWebEdit
Left = 246
Top = 20
Width = 121
Height = 22
ChildOrder = 5
ElementID = 'edtfilter'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtFilterChange
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 28 Left = 158
Top = 410 Top = 90
end end
object wdsCustomers: TWebDataSource object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers DataSet = xdwdsCustomers
Left = 224 Left = 262
Top = 414 Top = 116
end end
object xdwdsCustomers: TXDataWebDataSet object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 130 Left = 346
Top = 410 Top = 92
object xdwdsCustomersSHORT_NAME: TStringField object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME' FieldName = 'SHORT_NAME'
Size = 0 Size = 0
......
...@@ -10,17 +10,21 @@ ...@@ -10,17 +10,21 @@
</div> </div>
<!-- Actions Row --> <!-- Actions Row -->
<div class="row mt-3 justify-content-center"> <div class="row mt-3 justify-content-center align-items-end">
<div class="col-auto d-flex align-items-center"> <div class="col-auto">
<label class="mt-3" style="font-weight: 700;font-size: 1.10rem;">Show <select class="custom-select" id="wcbpagesize" style="font-size: 1.00rem;"></select> entries</label> <label for="wcbpagesize" class="form-label fw-bold" style="font-size: 1.1rem;">
Show
<select class="form-select d-inline-block w-auto" id="wcbpagesize" style="font-size: 1rem;"></select>
entries
</label>
</div>
<div class="col-auto">
<button id="btnaddcustomer" class="btn btn-secondary">Add Customer</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="btnaddcustomer" class="btn btn-secondary mt-3">Add Customer</button> <label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Company Account Name:</label>
<input id="edtfilter" type="text" class="form-control" style="width: 200px;" />
</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-->
......
...@@ -8,13 +8,15 @@ uses ...@@ -8,13 +8,15 @@ uses
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage, WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls, ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset,
WEBLib.Grids; WEBLib.Grids, VCL.TMSFNCTypes, VCL.TMSFNCUtils, VCL.TMSFNCGraphics,
VCL.TMSFNCGraphicsTypes, VCL.TMSFNCGridCell, VCL.TMSFNCGridOptions,
VCL.TMSFNCCustomControl, VCL.TMSFNCCustomScrollControl, VCL.TMSFNCGridData,
VCL.TMSFNCCustomGrid, VCL.TMSFNCGrid;
type type
TFViewCustomers = class(TWebForm) TFViewCustomers = class(TWebForm)
lblEntries: TWebLabel; lblEntries: TWebLabel;
btnAddCustomer: TWebButton; btnAddCustomer: TWebButton;
wdbtcCustomers: TWebDBTableControl;
wcbPageSize: TWebComboBox; wcbPageSize: TWebComboBox;
pnlMessage: TWebPanel; pnlMessage: TWebPanel;
lblMessage: TWebLabel; lblMessage: TWebLabel;
...@@ -26,9 +28,12 @@ type ...@@ -26,9 +28,12 @@ type
xdwdsCustomersSTART_DATE: TStringField; xdwdsCustomersSTART_DATE: TStringField;
xdwdsCustomersSHORT_NAME: TStringField; xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersCUSTOMER_ID: TIntegerField; xdwdsCustomersCUSTOMER_ID: TIntegerField;
wdbtcCustomers: TWebDBTableControl;
edtFilter: TWebEdit;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject); procedure btnAddCustomerClick(Sender: TObject);
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer); procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure edtFilterChange(Sender: TObject);
private private
{ Private declarations } { Private declarations }
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
...@@ -120,8 +125,6 @@ begin ...@@ -120,8 +125,6 @@ begin
' of ' + IntToStr(customerListLength); ' of ' + IntToStr(customerListLength);
end; end;
// Optional: Continue using pagination if needed
GeneratePagination(TotalPages);
end; end;
end; end;
...@@ -184,6 +187,12 @@ begin ...@@ -184,6 +187,12 @@ begin
FViewMain.ViewAddCustomer('', ''); FViewMain.ViewAddCustomer('', '');
end; end;
procedure TFViewCustomers.edtFilterChange(Sender: TObject);
begin
xdwdsCustomers.Filter := 'SHORT_NAME LIKE ' + quotedStr('%' + edtFilter.Text + '%');
xdwdsCustomers.Filtered := true;
end;
procedure TFViewCustomers.GeneratePagination(TotalPages: Integer); procedure TFViewCustomers.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table. // Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search // TotalPages: Total amount of pages generated by the search
......
...@@ -56,6 +56,7 @@ type ...@@ -56,6 +56,7 @@ type
procedure ViewOrderEntryWeb(orderInfo, customerInfo, mode, info: string); procedure ViewOrderEntryWeb(orderInfo, customerInfo, mode, info: string);
procedure ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode, info: string); procedure ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode, info: string);
procedure ViewOrders(info: string); procedure ViewOrders(info: string);
procedure ViewCustomerList(info: string);
procedure ShowUserForm(Info: string); procedure ShowUserForm(Info: string);
procedure ViewAddCustomer(customerInfo, info: string); procedure ViewAddCustomer(customerInfo, info: string);
var var
...@@ -254,6 +255,11 @@ begin ...@@ -254,6 +255,11 @@ begin
Application.CreateForm(AFormClass, WebPanel1.ElementID, FChildForm); Application.CreateForm(AFormClass, WebPanel1.ElementID, FChildForm);
end; end;
procedure TFViewMain.ViewCustomerList(info: string);
begin
end;
procedure TFViewMain.EditUser(Mode, Username, Password, Name, Status, Email, procedure TFViewMain.EditUser(Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string); Access, Rights, Perspective, QB: string);
begin begin
......
...@@ -495,6 +495,10 @@ begin ...@@ -495,6 +495,10 @@ begin
XDataWebDataSet1.Open; XDataWebDataSet1.Open;
console.log(XDataWebDataSet1NAME.AsString); console.log(XDataWebDataSet1NAME.AsString);
dtpOrderDate.Date := 0;
dtpProofDate.Date := 0;
dtpShipDate.Date := 0;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
......
...@@ -109,6 +109,12 @@ type ...@@ -109,6 +109,12 @@ type
TAddressItem = class TAddressItem = class
Public Public
ADDRESS: string; ADDRESS: string;
shipping_address: string;
city: string;
state: string;
contact: string;
zip: string;
ship_id: string;
end; end;
TCustomerItem = class TCustomerItem = class
...@@ -390,6 +396,7 @@ type ...@@ -390,6 +396,7 @@ type
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string; function AddItem(itemInfo: string): string;
function AddShippingAddress(Addressinfo: string): TJSONObject;
function DelUser(username: string): string; function DelUser(username: string): string;
function DelOrder(orderID, orderType, UserID: string): TJSONObject; function DelOrder(orderID, orderType, UserID: string): TJSONObject;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
......
...@@ -53,6 +53,7 @@ type ...@@ -53,6 +53,7 @@ type
function AddCorrugatedOrder(orderInfo: string): TJSONObject; function AddCorrugatedOrder(orderInfo: string): TJSONObject;
function AddWebOrder(orderInfo: string): TJSONObject; function AddWebOrder(orderInfo: string): TJSONObject;
function AddCuttingDieOrder(orderInfo: string): TJSONObject; function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TJSONObject;
function delOrder(OrderID, OrderType, UserID: string): TJSONObject; function delOrder(OrderID, OrderType, UserID: string): TJSONObject;
function GenerateSubQuery(currStatus: string): string; function GenerateSubQuery(currStatus: string): string;
...@@ -132,7 +133,7 @@ var ...@@ -132,7 +133,7 @@ var
SQL: string; SQL: string;
ADDRESS: TAddressItem; ADDRESS: TAddressItem;
begin begin
SQL := 'select * FROM customers c LEFT 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;
...@@ -163,6 +164,12 @@ begin ...@@ -163,6 +164,12 @@ begin
ADDRESS := TAddressItem.Create; ADDRESS := TAddressItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( ADDRESS ); TXDataOperationContext.Current.Handler.ManagedObjects.Add( ADDRESS );
ADDRESS.ADDRESS := ordersDB.UniQuery1.FieldByName('ship_block').AsString; ADDRESS.ADDRESS := ordersDB.UniQuery1.FieldByName('ship_block').AsString;
ADDRESS.shipping_address := ordersDB.UniQuery1.FieldByName('address').AsString;
ADDRESS.city := ordersDB.UniQuery1.FieldByName('city').AsString;
ADDRESS.state := ordersDB.UniQuery1.FieldByName('state').AsString;
ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString;
result.ADDRESS_LIST.Add(ADDRESS); result.ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
...@@ -210,6 +217,79 @@ begin ...@@ -210,6 +217,79 @@ begin
end; end;
end; end;
function TLookupService.AddShippingAddress(AddressInfo: string): TJSONObject;
var
JSONData: TJSONObject;
SQL: string;
Pair: TJSONPair;
Field: TField;
ShipID: integer;
mode: string;
temp: string;
msg: string;
ship_block: string;
begin
JSONData := TJSONObject.ParseJSONValue(AddressInfo) as TJSONObject;
if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode');
if mode = 'EDIT' then
ShipID := JSONData.GetValue<integer>('customer_ship_id');
if mode = 'ADD' then
SQL := 'select * from customers_ship where customer_id = 0 and customer_id <> 0'
else
begin
SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID);
end;
doQuery(ordersDB.UniQuery1, SQL);
try
if mode = 'ADD' then
ordersDB.UniQuery1.Insert
else
ordersDB.UniQuery1.Edit;
for Pair in JSONData do
begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
if Assigned(Field) then
begin
if (Field is TDateTimeField) then
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
Field.AsString := Pair.JsonValue.Value;
end;
end;
//OrdersDB.UniQuery1.FieldByName('address').AsString := JSONData.GetValue<string>('shipping_address');
//TODO Ask about shipping block & link to quickbooks
// OrdersDB.UniQuery1.FieldByName('ship_block') := ship_block;
// Post the record to the database
ordersDB.UniQuery1.Post;
if mode = 'ADD' then
msg := 'Success:Shipping Address Successfully Added'
else
msg := 'Success:Shipping Address Successfully Edited';
Result := TJSONObject.Create.AddPair('status', msg);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
end
end;
end;
function TLookupService.AddCustomer(customerInfo: string): TJSONObject; function TLookupService.AddCustomer(customerInfo: string): TJSONObject;
var var
...@@ -232,8 +312,6 @@ begin ...@@ -232,8 +312,6 @@ begin
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');
if mode = 'ADD' then if mode = 'ADD' then
begin begin
// Update RevisionID // Update RevisionID
......
...@@ -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=503 LogFileNum=518
[Database] [Database]
Server=192.168.159.131 Server=192.168.159.131
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
"jwtTokenSecret": "super_secret0123super_secret4567", "jwtTokenSecret": "super_secret0123super_secret4567",
"adminPassword": "whatisthisusedfor", "adminPassword": "whatisthisusedfor",
"webAppFolder": "static", "webAppFolder": "static",
"reportsFolder": "reports/" "reportsFolder": "..\\kgOrdersClient\\TMSWeb\\Debug\\"
} }
\ No newline at end of file
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