Commit 2603867e by Cam Hayes

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

parent 033837f0
object FViewAddCustomer: TFViewAddCustomer
Width = 640
Height = 480
Width = 842
Height = 607
OnShow = WebFormShow
object dtpStartDate: TWebDateTimePicker
Left = 19
......@@ -37,6 +37,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtcompanyaccountname'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'SHORT_NAME'
DataSource = WebDataSource1
end
object edtName: TWebDBEdit
Left = 19
......@@ -47,6 +49,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'NAME'
DataSource = WebDataSource1
end
object edtBillAddress: TWebDBEdit
Left = 19
......@@ -57,6 +61,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingaddress'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_ADDRESS'
DataSource = WebDataSource1
end
object edtBillCity: TWebDBEdit
Left = 19
......@@ -67,6 +73,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingcity'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_CITY'
DataSource = WebDataSource1
end
object edtBillState: TWebDBEdit
Left = 19
......@@ -77,6 +85,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingstate'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_STATE'
DataSource = WebDataSource1
end
object edtBillZip: TWebDBEdit
Left = 19
......@@ -87,6 +97,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingzip'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_ZIP'
DataSource = WebDataSource1
end
object edtBillContact: TWebDBEdit
Left = 19
......@@ -97,6 +109,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtbillingcontact'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_CONTACT'
DataSource = WebDataSource1
end
object edtPhone: TWebDBEdit
Left = 19
......@@ -107,6 +121,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtphone'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'PHONE'
DataSource = WebDataSource1
end
object edtFax: TWebDBEdit
Left = 19
......@@ -117,6 +133,8 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtfax'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'FAX'
DataSource = WebDataSource1
end
object edtRep: TWebDBEdit
Left = 19
......@@ -127,10 +145,12 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'edtrepid'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'REP_USER_ID'
DataSource = WebDataSource1
end
object btnSave: TWebButton
Left = 280
Top = 407
Left = 88
Top = 525
Width = 96
Height = 25
Caption = 'Save'
......@@ -140,10 +160,11 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
OnClick = btnSaveClick
end
object btnCancel: TWebButton
Left = 280
Top = 367
Left = 88
Top = 485
Width = 96
Height = 25
Caption = 'Cancel'
......@@ -155,8 +176,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
end
object btnDelete: TWebButton
Left = 280
Top = 323
Left = 88
Top = 441
Width = 96
Height = 25
Caption = 'Delete'
......@@ -166,8 +187,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
end
object btnClose: TWebButton
Left = 396
Top = 323
Left = 204
Top = 441
Width = 96
Height = 25
Caption = 'Close'
......@@ -177,8 +198,8 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
end
object btnEdit: TWebButton
Left = 396
Top = 367
Left = 204
Top = 485
Width = 96
Height = 25
Caption = 'Edit'
......@@ -222,6 +243,141 @@ object FViewAddCustomer: TFViewAddCustomer
Role = 'null'
WidthStyle = ssAuto
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
......@@ -32,6 +32,14 @@
<hr class="custom-hr">
<div class="row">
<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>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
......@@ -75,7 +83,7 @@
<h4 class="custom-h4 mt-3">Billing Information</h4>
<hr class="custom-hr">
<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>
<input id="edtbillingaddress" class="form-control input-sm" required/>
</div>
......@@ -96,10 +104,28 @@
</div>
<div class="col-auto">
<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 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 class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
......
......@@ -3,9 +3,11 @@ unit AddCustomer;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls,
WEBLib.DBCtrls, WEBLib.ExtCtrls;
System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
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
TFViewAddCustomer = class(TWebForm)
......@@ -29,15 +31,43 @@ type
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
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 btnCloseNotificationClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
private
{ Private declarations }
procedure HideNotification();
procedure ShowNotification(Notification: string);
[async] procedure GetCustomer();
[async] procedure SendCustomerToServer();
var
customerID: string;
notification: string;
mode: string;
public
{ Public declarations }
class function CreateForm(AElementID, customerInfo, info: string): TWebForm;
......@@ -52,6 +82,66 @@ implementation
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;
begin
Application.CreateForm(TFViewAddCustomer, AElementID, Result,
......@@ -67,8 +157,59 @@ begin
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);
var
SQL: string;
begin
if notification = '' then
hideNotification();
getCustomer();
dtpStartDate.Date := 0;
dtpEndDate.Date := 0;
end;
......
......@@ -282,9 +282,6 @@ object FAddOrder: TFAddOrder
Connection = DMConnection.ApiConnection
Left = 726
Top = 7
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
......@@ -294,6 +291,9 @@ object FAddOrder: TFAddOrder
object xdwdsCustomersstaff_fields_invoice_to: TStringField
FieldName = 'staff_fields_invoice_to'
end
object xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
......
......@@ -26,13 +26,13 @@ type
WebLabel2: TWebLabel;
XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
wdsCustomers: TWebDataSource;
cbCuttingDie: TWebCheckBox;
edtNotification: TWebEdit;
xdwdsCustomersstaff_fields_invoice_to: TStringField;
xdwdsCustomersCUSTOMER_ID: TIntegerField;
procedure WebFormShow(Sender: TObject);
procedure edtSearchChange(Sender: TObject);
procedure cbCorrugatedPlateClick(Sender: TObject);
......@@ -166,7 +166,7 @@ begin
while not xdwdsCustomers.EOF do
begin
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[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString;
......
......@@ -62,8 +62,17 @@ object FViewCustomers: TFViewCustomers
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
......@@ -135,11 +144,18 @@ object FViewCustomers: TFViewCustomers
Connection = DMConnection.ApiConnection
Left = 130
Top = 410
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
Size = 0
end
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
object xdwdsCustomersSTART_DATE: TStringField
FieldName = 'START_DATE'
end
object xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end
end
......@@ -17,6 +17,10 @@
<div class="col-auto">
<button id="btnaddcustomer" class="btn btn-secondary mt-3">Add Customer</button>
</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>
<!-- Entries Label Section d-flex justify-content-between w-100 mt-2-->
......
......@@ -24,8 +24,11 @@ type
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSTART_DATE: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersCUSTOMER_ID: TIntegerField;
procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject);
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
private
{ Private declarations }
procedure GeneratePagination(TotalPages: Integer);
......@@ -169,6 +172,13 @@ begin
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);
begin
FViewMain.ViewAddCustomer('', '');
......
......@@ -864,7 +864,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
DataSource = WebDataSource1
end
object btnSave: TWebButton
Left = 526
Left = 530
Top = 560
Width = 96
Height = 25
......
......@@ -563,7 +563,8 @@ begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder',
[orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result);
OrderID := JS.toString(jsObj.Properties['OrderID']);
if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
mode := 'EDIT';
end;
......
......@@ -125,32 +125,6 @@
<textarea id="edtspecialinstructions" class="form-control" style=" width: 500px; height: 150px;"></textarea>
</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 class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
......
......@@ -224,8 +224,6 @@ begin
orderJSON.AddPair('mode', mode);
if mode = 'EDIT' then
orderJSON.AddPair('ORDER_ID', orderID);
console.log(orderJSON.GetValue('ORDER_ID'));
console.log(orderJSON);
if mode = 'ADD' then
ShowNotification('Success:Order Added Successfully!')
......@@ -331,10 +329,15 @@ end;
procedure TFOrderEntryCuttingDie.AddCuttingDieOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server
var
Response: TXDataClientResponse;
Response: TXDataClientResponse;
jsObj: TJSObject;
begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCuttingDieOrder',
[orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result);
if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
mode := 'EDIT';
end;
class function TFOrderEntryCuttingDie.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm;
......
......@@ -297,7 +297,6 @@ begin
input := TJSHTMLInputElement(document.getElementById('edtinvoiceto'));
if edtInvoiceTo.Text = '' then
begin
console.log('hot');
input.classList.add('is-invalid');
result := false;
end
......@@ -516,7 +515,6 @@ var
begin
// Call the server method to generate the PDF
console.log(orderID);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderWebPDF', [orderID]));
jsObject := JS.TJSObject(xdcResponse.Result);
pdfURL := JS.toString(jsObject.Properties['value']);
......@@ -524,16 +522,21 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window.open(pdfURL, '_blank');
console.log(pdfURL);
end;
procedure TFOrderEntryWeb.AddWebOrder(orderJSON: TJSONObject);
// sends the order JSON object to the server
var
Response: TXDataClientResponse;
Response: TXDataClientResponse;
jsObj: TJSObject;
begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddWebOrder',
[orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result);
if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']);
console.log(OrderID);
mode := 'EDIT';
end;
class function TFOrderEntryWeb.CreateForm(AElementID, orderInfo, customerInfo, mode, info: string): TWebForm;
......@@ -704,7 +707,6 @@ begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetWebOrder',
[Order_ID]));
order := TJSObject(xdcResponse.Result);
console.log(order);
data := TJSArray(order['data']);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(order);
......@@ -712,12 +714,10 @@ begin
if XDataWebDataSet1quantity_and_colors_qty_colors.Value <> '' then
begin
colorObject := TJSObject(TJSJSON.parse(XDataWebDataSet1quantity_and_colors_qty_colors.Value));
console.log(colorObject);
colorList := TJSArray(colorObject['items']);
for I := 0 to colorList.length -1 do
begin
color := TJSObject(colorList[i]);
console.log(color);
addColorRow(String(color['#']), string(color['Color']), string(color['LPI']), string(color['Size']));
end;
end;
......
......@@ -717,8 +717,8 @@ object FSearch: TFSearch
object xdwdsCustomersstaff_fields_invoice_to: TStringField
FieldName = 'staff_fields_invoice_to'
end
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
object xdwdsCustomersCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
end
object wdsCustomers: TWebDataSource
......
......@@ -55,7 +55,7 @@ type
WebLabel5: TWebLabel;
edtCompanyName: TWebEdit;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersCUSTOMER_ID: TIntegerField;
procedure btnConfirmClick(Sender: TObject);
procedure WebFormShow(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
......@@ -116,7 +116,6 @@ begin
DateFormatSettings := TFormatSettings.Create;
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));
edtOrderID.Text := params.Values['orderID'];
edtCompanyID.Text := params.Values['companyID'];
......@@ -287,7 +286,7 @@ begin
while not xdwdsCustomers.EOF do
begin
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[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('staff_fields_invoice_to').AsString;
......
......@@ -114,10 +114,20 @@ type
TCustomerItem = class
Public
NAME: string;
ID: integer;
CUSTOMER_ID: integer;
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;
START_DATE: String;
END_DATE: string;
QB_LIST_ID: string;
FAX: string;
REP_USER_ID: string;
ADDRESS_LIST: TList<TAddressItem>;
ITEMS: TItemList;
end;
......@@ -388,6 +398,7 @@ type
function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: integer): string;
function SetStatus(statusOptions: string): string;
function AddCustomer(customerInfo: string): TJSONObject;
end;
implementation
......
......@@ -96,7 +96,7 @@ var
SQL: string;
customer: TCustomerItem;
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);
result := TCustomerList.Create;
......@@ -108,13 +108,16 @@ begin
begin
customer := TCustomerItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( customer );
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.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;
customer.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.data.Add(customer);
result.count := result.count + 1;
ordersDB.UniQuery1.Next;
......@@ -129,16 +132,31 @@ var
SQL: string;
ADDRESS: TAddressItem;
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);
result := TCustomerItem.Create;
result.ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.ADDRESS_LIST );
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.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
begin
......@@ -203,6 +221,8 @@ var
CustomerID: integer;
mode: string;
temp: string;
msg: string;
unique: boolean;
begin
DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd';
......@@ -217,25 +237,47 @@ begin
if mode = 'ADD' then
begin
// 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.ExecSQL;
// 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);
CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger;
end
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
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
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;
if unique then
begin
if mode = 'ADD' then
SQL := 'select * from customers where CUSTOMER_ID = 0 and CUSTOMER_ID <> 0'
else
begin
SQL := 'select * from customers where CUSTOMER_ID = ' + IntToStr(CustomerID);
end;
doQuery(ordersDB.UniQuery1, SQL);
try
if mode = 'ADD' then
ordersDB.UniQuery1.Insert
......@@ -258,12 +300,17 @@ begin
Field.AsString := Pair.JsonValue.Value;
end;
end;
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := CustomerID;
ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger := CustomerID;
// Post the record to the database
ordersDB.UniQuery1.Post;
Result := TJSONObject.Create.AddPair('status', 'success');
if mode = 'ADD' then
msg := 'Success:Customer Successfully Added'
else
msg := 'Success:Customer Successfully Edited';
Result := TJSONObject.Create.AddPair('status', msg);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
......@@ -271,6 +318,9 @@ 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;
function TLookupService.GenerateOrderCorrugatedPDF(orderID: string): string;
......@@ -1746,14 +1796,13 @@ begin
AddToRevisionsTable(IntToStr(ORDER_ID), 'web_plate_orders_revisions', JSONData);
Result := TJSONObject.Create.AddPair('status', 'success');
Result.AddPair('OrderID', ORDER_ID);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
end
else
result := TJSONObject.Create.AddPair('OrderID', ORDER_ID);
end;
end;
......@@ -1776,7 +1825,6 @@ begin
if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode');
ORDER_ID := JSONData.GetValue<integer>('ORDER_ID');
AddToOrdersTable(mode, 'cutting_die', JSONData);
......@@ -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
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);
except
on E: Exception do
......
......@@ -2,7 +2,7 @@
MemoLogLevel=3
FileLogLevel=5
webClientVersion=0.9.2
LogFileNum=469
LogFileNum=503
[Database]
Server=192.168.159.131
......@@ -17,5 +17,5 @@ Password=emsys01
CompanyID=9341454272655710
ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy
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