Commit ab14864b by Cam Hayes

Finished the changes discussed with Dave and Elias

parent aba393fe
......@@ -186,6 +186,7 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'btndelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnDeleteClick
end
object btnClose: TWebButton
Left = 19
......@@ -319,18 +320,6 @@ object FViewAddCustomer: TFViewAddCustomer
end>
DataSource = wdsShipTo
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
......@@ -338,8 +327,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingaddress'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingState: TWebEdit
Left = 190
......@@ -348,8 +339,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingstate'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingContact: TWebEdit
Left = 190
......@@ -358,8 +351,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcontact'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingZip: TWebEdit
Left = 190
......@@ -368,8 +363,10 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingzip'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingCity: TWebEdit
Left = 190
......@@ -378,20 +375,135 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcity'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object memoShipBlock: TWebMemo
Left = 508
Top = 460
Width = 185
Height = 89
ElementID = 'memoshipblock'
Enabled = False
HeightPercent = 100.000000000000000000
SelLength = 0
SelStart = 0
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object memoAddressBlock: TWebMemo
Left = 162
Top = 86
Width = 185
Height = 89
ElementID = 'memoaddressblock'
Enabled = False
HeightPercent = 100.000000000000000000
SelLength = 0
SelStart = 0
WidthPercent = 100.000000000000000000
OnChange = memoAddressBlockChange
end
object btnAdd: TWebButton
Left = 19
Top = 535
Width = 96
Height = 25
Caption = 'Add'
ChildOrder = 84
ElementID = 'btnadd'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddClick
end
object btnShipSave: TWebButton
Left = 339
Top = 441
Width = 96
Height = 25
Caption = 'Save'
ChildOrder = 79
ElementID = 'btnshipconfirm'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
OnClick = btnShipSaveClick
end
object btnShipCancel: TWebButton
Left = 339
Top = 480
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementID = 'btnshipcancel'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object btnClear: TWebButton
Left = 296
Top = 420
object btnShipDelete: TWebButton
Left = 339
Top = 410
Width = 96
Height = 25
Caption = 'Clear'
ChildOrder = 27
ElementID = 'btnclear'
Caption = 'Delete'
ChildOrder = 79
ElementID = 'btnshipdelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipDeleteClick
end
object btnShipEdit: TWebButton
Left = 339
Top = 511
Width = 96
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementID = 'btnshipedit'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipEditClick
end
object btnShipAdd: TWebButton
Left = 339
Top = 549
Width = 96
Height = 25
Caption = 'Add'
ChildOrder = 84
ElementID = 'btnshipadd'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnShipAddClick
end
object btn_confirm_delete: TWebButton
Left = 725
Top = 433
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 82
ElementID = 'btn_confirm_delete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btn_confirm_deleteClick
end
object edtFirstLine: TWebEdit
Left = 190
Top = 430
Width = 121
Height = 22
ChildOrder = 35
ElementID = 'edtfirstline'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnClearClick
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......@@ -482,4 +594,10 @@ object FViewAddCustomer: TFViewAddCustomer
FieldName = 'contact'
end
end
object tmrReturn: TWebTimer
Enabled = False
OnTimer = tmrReturnTimer
Left = 542
Top = 42
end
end
......@@ -7,6 +7,9 @@
</div>
<ul class="navbar-nav me-auto ps-2">
<li class="nav-item pe-2">
<button id="btnadd" class="btn btn-primary btn-sm">Add</button>
</li>
<li class="nav-item pe-2">
<button id="btnedit" class="btn btn-primary btn-sm">Edit</button>
</li>
<li class="nav-item pe-2">
......@@ -25,11 +28,11 @@
</div>
</nav>
<div class="row mx-5">
<h4 class="custom-h4 mt-3">Company Information</h4>
<h4 class="custom-h4 mt-3">Customer Information</h4>
<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>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer Num</label>
<input id="edtcompanyid" class="form-control input-sm"style="width: 100px" required/>
</div>
<div class="col-auto">
......@@ -37,14 +40,14 @@
<input id="edtqbid" class="form-control input-sm"style="width: 200px" required/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" 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">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" 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">Customer ID:</label>
<input id="edtcompanyaccountname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" id="shortnamefeedback" style="font-size: 15px;">
Please Provide a Company Account Name.
......@@ -74,32 +77,50 @@
<h4 class="custom-h4 mt-3">Billing Information</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-12">
<div class="col-auto">
<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" style="width: 300px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Address.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing City</label>
<input id="edtbillingcity" class="form-control input-sm" style="width: 250px"/>
<input id="edtbillingcity" class="form-control input-sm" style="width: 250px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a City.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing State:</label>
<input id="edtbillingstate" class="form-control input-sm" style="width: 100px"/>
<input id="edtbillingstate" class="form-control input-sm" style="width: 100px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Order Date.
Please Provide a State.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Zip Code:</label>
<input id="edtbillingzip" class="form-control input-sm" style="width: 200px"/>
<input id="edtbillingzip" class="form-control input-sm" style="width: 200px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Zip Code.
</div>
</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: 250px"/>
<input id="edtbillingcontact" class="form-control input-sm" style="width: 250px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Billing Contact.
</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 class="row mt-3">
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label">Billing Address Block</label>
<textarea id="memoaddressblock" class="form-control" style=" width: 500px; height: 150px;" required></textarea>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter a Billing Address Block.
</div>
</div>
</div>
<h4 class="custom-h4 mt-3">Shipping Addresses</h4>
<hr class="custom-hr">
......@@ -115,37 +136,74 @@
</tbody>
</table>
</div>
<div class="row mt-1">
<div class="col-auto">
<button id="btnshipadd" class="btn btn-primary btn-sm">Add</button>
</div>
<div class="col-auto">
<button id="btnshipedit" class="btn btn-primary btn-sm">Edit</button>
</div>
<div class="col-auto">
<button id="btnshipdelete" class="btn btn-danger btn-sm">Delete</button>
</div>
<div class="col-auto">
<button id="btnshipconfirm" class="btn btn-success btn-sm">Save</button>
</div>
<div class="col-auto">
<button id="btnshipcancel" class="btn btn-danger btn-sm">Cancel</button>
</div>
</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 class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">First Line:</label>
<input id="edtfirstline" class="form-control input-sm" style="width: 300px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter the First Line.
</div>
</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"/>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Address:</label>
<input id="edtshippingaddress" class="form-control input-sm" style="width: 300px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter an Address.
</div>
</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"/>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">City</label>
<input id="edtshippingcity" class="form-control input-sm" style="width: 250px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Order Date.
Please Enter a City.
</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"/>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">State:</label>
<input id="edtshippingstate" class="form-control input-sm" style="width: 100px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter a State.
</div>
</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"/>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Zip Code:</label>
<input id="edtshippingzip" class="form-control input-sm" style="width: 200px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter a Zip Code.
</div>
</div>
</div>
<div class="row mt-3">
<div class="col-auto">
<button id="btnaddaddress" class="btn btn-danger btn-sm">Add Address</button>\
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Contact:</label>
<input id="edtshippingcontact" class="form-control input-sm" style="width: 250px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter a Shipping Contact.
</div>
</div>
</div>
<div class="row my-3">
<div class="col-auto">
<button id="btnclear" class="btn btn-primary btn-sm">Clear</button>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label">Shipping Block</label>
<textarea id="memoshipblock" class="form-control" style=" width: 500px; height: 150px;" required></textarea>
<div class="invalid-feedback" style="font-size: 15px;">
Please Enter a Shipping Block.
</div>
</div>
</div>
</div>
......
......@@ -53,13 +53,11 @@ type
XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1REP_USER_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;
......@@ -67,6 +65,17 @@ type
xdwdsShipTostate: TStringField;
xdwdsShipTozip: TStringField;
xdwdsShipTocontact: TStringField;
memoShipBlock: TWebMemo;
memoAddressBlock: TWebMemo;
btnAdd: TWebButton;
btnShipSave: TWebButton;
btnShipCancel: TWebButton;
btnShipDelete: TWebButton;
btnShipEdit: TWebButton;
btnShipAdd: TWebButton;
btn_confirm_delete: TWebButton;
tmrReturn: TWebTimer;
edtFirstLine: TWebEdit;
procedure WebFormShow(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
......@@ -76,8 +85,18 @@ type
procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure wdbtcAddressesDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure btnAddAddressClick(Sender: TObject);
procedure btnClearClick(Sender: TObject);
procedure memoAddressBlockChange(Sender: TObject);
procedure AddressEditMode();
procedure edtShippingAddressChange(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btn_confirm_deleteClick(Sender: TObject);
procedure tmrReturnTimer(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure btnShipAddClick(Sender: TObject);
procedure btnShipEditClick(Sender: TObject);
procedure btnShipSaveClick(Sender: TObject);
procedure btnShipDeleteClick(Sender: TObject);
private
{ Private declarations }
......@@ -88,11 +107,15 @@ type
[async] procedure GetCustomer();
[async] procedure SendCustomerToServer();
[async] procedure SendAddressToServer();
function Verify(): boolean;
[async] procedure DelAddress();
function VerifyCustomer(): boolean;
function VerifyAddress(): boolean;
procedure Clear();
var
customerID: string;
notification: string;
mode: string;
shipmode: string;
public
{ Public declarations }
class function CreateForm(AElementID, customerInfo, info: string): TWebForm;
......@@ -107,15 +130,44 @@ implementation
uses View.Main, View.Customers;
procedure TFViewAddCustomer.Clear();
begin
edtShippingAddress.Text := '';
edtShippingCity.Text := '';
edtShippingState.Text := '';
edtShippingZip.Text := '';
edtShippingContact.Text := '';
memoShipBlock.Text := '';
edtFirstLine.Text := '';
end;
procedure TFViewAddCustomer.DelAddress;
var
Response: TXDataClientResponse;
notification: TJSObject;
begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.DelShippingAddress',
[xdwdsShipTo.FieldByName('ship_id').AsString, customerID]));
notification := TJSObject(Response.Result);
ShowNotification(string(notification['status']));
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open;
asm
endSpinner();
end;
end;
procedure TFViewAddCustomer.SendAddressToServer;
var
Field: TField;
AddressJSON: TJSONObject;
Response: TXDataClientResponse;
notification: TJSObject;
ship_block: string;
begin
AddressJSON := TJSONObject.Create;
XDataWebDataSet1.First;
AddressJSON.AddPair('address', edtShippingAddress.Text);
AddressJSON.AddPair('city', edtShippingcity.Text);
AddressJSON.AddPair('state', edtShippingstate.Text);
......@@ -123,48 +175,48 @@ begin
AddressJSON.AddPair('contact', edtShippingContact.Text);
AddressJSON.AddPair('customer_id', customerID);
ship_block := edtFirstLine.Text + slinebreak +
edtName.Text + slinebreak +
edtShippingContact.Text + slinebreak +
edtShippingAddress.Text + slinebreak +
edtShippingCity.Text + ', ' + edtShippingState.Text + ' ' + edtShippingZip.Text;
AddressJSON.AddPair('ship_block', ship_block);
if btnAddAddress.Caption = 'Add Address' then
AddressJSON.AddPair('mode', 'ADD')
else
begin
AddressJSON.AddPair('mode', 'EDIT');
if shipmode = 'EDIT' then
AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString);
end;
AddressJSON.AddPair('mode', shipmode);
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString]));
notification := TJSObject(Response.Result);
ShowNotification(string(notification['status']));
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open;
end;
procedure TFViewAddCustomer.btnAddAddressClick(Sender: TObject);
procedure TFViewAddCustomer.btnAddClick(Sender: TObject);
begin
if btnAddAddress.Caption = 'Save' then
btnAddAddress.Caption := 'Add Address';
SendAddressToServer();
FViewMain.ViewAddCustomer('', '');
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);
document.getElementById('modal_body').innerHTML := 'Are you sure you want to cancel all changes to the customer?';
document.getElementById('btn_confirm_cancel').innerText := 'No';
document.getElementById('btn_confirm_delete').innerText := 'Yes';
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.show();
end;
end;
procedure TFViewAddCustomer.btnClearClick(Sender: TObject);
begin
edtShippingAddress.Text := '';
edtShippingCity.Text := '';
edtShippingState.Text := '';
edtShippingZip.Text := '';
edtShippingContact.Text := '';
btnAddAddress.Caption := 'Add Address';
Clear();
end;
procedure TFViewAddCustomer.btnCloseClick(Sender: TObject);
......@@ -177,29 +229,115 @@ begin
HideNotification();
end;
procedure TFViewAddCustomer.btnDeleteClick(Sender: TObject);
begin
ShowMessage('Deleting Customers Is Not Yet Available');
end;
procedure TFViewAddCustomer.btnEditClick(Sender: TObject);
begin
EditMode();
end;
procedure TFViewAddCustomer.edtShippingAddressChange(Sender: TObject);
begin
AddressEditMode();
end;
procedure TFViewAddCustomer.EditMode;
begin
FViewMain.change := true;
btnAdd.Enabled := false;
btnDelete.Enabled := false;
btnClose.Enabled := false;
btnSave.Enabled := true;
btnCancel.Enabled := True;
btnEdit.Enabled := false;
// Disable Shipping Address Editting
edtShippingAddress.Enabled := false;
edtShippingCity.Enabled := false;
edtShippingState.Enabled := false;
edtShippingZip.Enabled := false;
edtShippingContact.Enabled := false;
edtFirstLine.Enabled := false;
btnShipDelete.Enabled := false;
btnShipSave.Enabled := false;
btnShipCancel.Enabled := false;
btnShipEdit.Enabled := false;
btnShipAdd.Enabled := false;
end;
procedure TFViewAddCustomer.AddressEditMode;
begin
FViewMain.change := true;
btnDelete.Enabled := false;
btnClose.Enabled := false;
btnSave.Enabled := false;
btnCancel.Enabled := false;
btnEdit.Enabled := false;
btnAdd.Enabled := false;
btnShipDelete.Enabled := false;
btnShipSave.Enabled := true;
btnShipCancel.Enabled := true;
btnShipEdit.Enabled := false;
btnShipAdd.Enabled := false;
edtShippingAddress.Enabled := true;
edtShippingCity.Enabled := true;
edtShippingState.Enabled := true;
edtShippingZip.Enabled := true;
edtShippingContact.Enabled := true;
edtFirstLine.Enabled := true;
edtName.Enabled := false;
edtShortName.Enabled := false;
edtBillAddress.Enabled := false;
edtBillCity.Enabled := false;
edtBillState.Enabled := false;
edtBillZip.Enabled := false;
edtBillContact.Enabled := false;
dtpStartDate.Enabled := false;
dtpEndDate.Enabled := false;
edtFax.Enabled := false;
edtPhone.enabled := false;
edtRep.Enabled := false;
end;
procedure TFViewAddCustomer.ViewMode;
begin
btnAdd.Enabled := true;
btnDelete.Enabled := true;
btnClose.Enabled := true;
btnSave.Enabled := false;
btnCancel.Enabled := false;
btnEdit.Enabled := true;
FViewMain.change := false;
btnShipAdd.Enabled := true;
btnShipDelete.Enabled := true;
btnShipSave.Enabled := false;
btnShipCancel.Enabled := false;
btnShipEdit.Enabled := true;
FViewMain.change := false;
// Make Sure Customer is editable
edtName.Enabled := true;
edtShortName.Enabled := true;
edtBillAddress.Enabled := true;
edtBillCity.Enabled := true;
edtBillState.Enabled := true;
edtBillZip.Enabled := true;
edtBillContact.Enabled := true;
dtpStartDate.Enabled := true;
dtpEndDate.Enabled := true;
edtFax.Enabled := true;
edtPhone.enabled := true;
edtRep.Enabled := true;
end;
procedure TFViewAddCustomer.wdbtcAddressesDblClickCell(Sender: TObject; ACol,
......@@ -211,7 +349,8 @@ begin
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString;
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString;
btnAddAddress.Caption := 'Save';
memoShipBlock.Text := xdwdsShipTo.FieldByName('ADDRESS').AsString;
edtFirstLine.Text := memoShipBlock.Lines[0];
end;
procedure TFViewAddCustomer.SendCustomerToServer();
......@@ -253,6 +392,8 @@ begin
XDataWebDataSet1.Next;
end;
customerJSON.AddPair('BILL_ADDRESS_BLOCK', memoAddressBlock.Text);
customerJSON.AddPair('mode', mode);
if mode = 'EDIT' then
customerJSON.AddPair('CUSTOMER_ID', customerID);
......@@ -268,45 +409,92 @@ begin
begin
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
input.classList.add('is-invalid');
input := TJSHTMLInputElement(document.getElementById('shortnamefeedback'));
input.innerHTML := 'Company Account Name must be Unique.' ;
end;
end;
function TFViewAddCustomer.Verify(): boolean;
var
input: TJSHTMLElement;
procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
begin
result := true;
input := TJSHTMLInputElement(document.getElementById('edtcompanyname'));
if edtName.Text = '' then
if VerifyCustomer() then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
sendCustomerToServer();
ViewMode();
end;
end;
procedure TFViewAddCustomer.btnShipAddClick(Sender: TObject);
begin
shipmode := 'ADD';
Clear();
AddressEditMode();
end;
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
if edtShortName.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
procedure TFViewAddCustomer.btnShipDeleteClick(Sender: TObject);
begin
document.getElementById('modal_body').innerHTML := 'Are you sure you want to delete this address?';
document.getElementById('btn_confirm_cancel').innerText := 'Cancel';
document.getElementById('btn_confirm_delete').innerText := 'Delete';
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.show();
end;
end;
procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
procedure TFViewAddCustomer.btnShipEditClick(Sender: TObject);
begin
shipmode := 'EDIT';
AddressEditMode();
end;
procedure TFViewAddCustomer.btnShipSaveClick(Sender: TObject);
begin
if verify then
if VerifyAddress() then
begin
sendCustomerToServer();
SendAddressToServer();
Clear();
ViewMode();
end;
end;
procedure TFViewAddCustomer.btn_confirm_deleteClick(Sender: TObject);
begin
if document.getElementById('btn_confirm_delete').innerText = 'Yes' then
// checks if the modal is canceling
begin
if CustomerID <> '' then
begin
FViewMain.ViewAddCustomer(CustomerID, 'Failure:Changes Discarded');
end
else
FViewMain.ShowForm(TFViewCustomers);
end
else if document.getElementById('modal_body').innerHTML.Contains('customer') then
// checks if the user is deleting a customer or a shipping address
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.hide();
startSpinner();
end;
//delCustomer();
tmrReturn.Enabled := true;
end
else
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
keyboard: false });
confirmationModal.hide();
startSpinner();
end;
delAddress();
end;
end;
class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm;
begin
Application.CreateForm(TFViewAddCustomer, AElementID, Result,
......@@ -328,10 +516,10 @@ var
customer : TJSObject;
address: string;
items: TJSObject;
ship_block: TStringList;
begin
if CustomerID = '' then
begin
console.log(CustomerID);
customerID := '-1';
mode := 'ADD';
end
......@@ -344,8 +532,6 @@ begin
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
console.log(customer['ADDRESS_LIST']);
if CustomerID = '-1' then
begin
edtCustomerID.Text := '';
......@@ -361,10 +547,15 @@ begin
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']);
xdwdsShipTo.Open;
{xdwdsQBItem.Close;
items := TJSObject(customer['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open;}
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
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;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ADDRESS').AsString;
edtFirstLine.Text := memoShipBlock.Lines[0];
end;
......@@ -373,7 +564,9 @@ var
SQL: string;
begin
if notification = '' then
hideNotification();
hideNotification()
else
showNotification(notification);
if mode = 'ADD' then
EditMode()
......@@ -401,11 +594,15 @@ begin
pnlMessage.ElementHandle.hidden := True;
end;
procedure TFViewAddCustomer.memoAddressBlockChange(Sender: TObject);
begin
EditMode();
end;
procedure TFViewAddCustomer.ShowNotification(Notification: string);
var
splitNotification: TArray<string>;
begin
console.log(notification);
if Notification <> '' then
begin
splitNotification := Notification.Split([':']);
......@@ -425,10 +622,162 @@ begin
messageDiv.classList.add('alert-danger');
end;
end;
console.log(splitNotification[1]) ;
lblMessage.Caption := splitNotification[1];
pnlMessage.ElementHandle.hidden := False;
end;
end;
procedure TFViewAddCustomer.tmrReturnTimer(Sender: TObject);
begin
asm
endSpinner();
end;
tmrReturn.Enabled := false;
FViewMain.ViewCustomerList('Success:Customer Successfully Deleted');
end;
function TFViewAddCustomer.VerifyCustomer(): boolean;
var
input: TJSHTMLElement;
begin
result := true;
// Company Verification
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');
// Billing Information Verification
input := TJSHTMLInputElement(document.getElementById('edtbillingaddress'));
if edtBillAddress.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtbillingcity'));
if edtBillCity.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtbillingstate'));
if edtBillState.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtbillingzip'));
if edtBillZip.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtbillingcontact'));
if edtBillContact.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('memoaddressblock'));
if memoAddressBlock.Lines.Count = 0 then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
end;
function TFViewAddCustomer.VerifyAddress: Boolean;
var
input: TJSHTMLElement;
begin
result := true;
input := TJSHTMLInputElement(document.getElementById('edtshippingaddress'));
if edtShippingAddress.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtshippingcity'));
if edtShippingCity.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtshippingstate'));
if edtShippingState.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtshippingzip'));
if edtShippingZip.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtshippingcontact'));
if edtShippingContact.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtfirstline'));
if edtFirstLine.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
end;
end.
\ No newline at end of file
......@@ -5,9 +5,9 @@ object FAddOrder: TFAddOrder
object WebLabel1: TWebLabel
Left = 4
Top = 81
Width = 35
Width = 95
Height = 15
Caption = 'Search'
Caption = 'Search Customers'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
......@@ -16,7 +16,7 @@ object FAddOrder: TFAddOrder
Top = 81
Width = 113
Height = 15
Caption = 'Selected Company ID'
Caption = 'Selected Customer ID'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
......@@ -74,7 +74,7 @@ object FAddOrder: TFAddOrder
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 70.000000000000000000
Width = 90.000000000000000000
end
item
BorderWidth = 1
......@@ -119,7 +119,7 @@ object FAddOrder: TFAddOrder
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 382.000000000000000000
Width = 362.000000000000000000
end
item
BorderWidth = 1
......
......@@ -154,9 +154,9 @@ begin
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'DBID';
TMSFNCGrid1.Cells[1, 0] := 'ID';
TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[0, 0] := 'Customer Num';
TMSFNCGrid1.Cells[1, 0] := 'Customer ID';
TMSFNCGrid1.Cells[2, 0] := 'Customer Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// Populate the grid with data from the dataset
......
......@@ -114,15 +114,15 @@ object FViewCustomers: TFViewCustomers
Columns = <
item
DataField = 'CUSTOMER_ID'
Title = 'Customer ID'
Title = 'Customer Num'
end
item
DataField = 'SHORT_NAME'
Title = 'Account Name'
Title = 'Customer ID'
end
item
DataField = 'NAME'
Title = 'Name'
Title = 'Customer Name'
end
item
DataField = 'START_DATE'
......
......@@ -22,7 +22,7 @@
<button id="btnaddcustomer" class="btn btn-secondary">Add Customer</button>
</div>
<div class="col-auto">
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Company Account Name:</label>
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtfilter" type="text" class="form-control" style="width: 200px;" />
</div>
</div>
......
......@@ -15,7 +15,6 @@ uses
type
TFViewCustomers = class(TWebForm)
lblEntries: TWebLabel;
btnAddCustomer: TWebButton;
wcbPageSize: TWebComboBox;
pnlMessage: TWebPanel;
......@@ -30,6 +29,7 @@ type
xdwdsCustomersCUSTOMER_ID: TIntegerField;
wdbtcCustomers: TWebDBTableControl;
edtFilter: TWebEdit;
lblEntries: TWebLabel;
procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject);
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
......@@ -115,7 +115,7 @@ begin
else if (PageNumber * PageSize) < customerListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' - ' + IntToStr(customerListLength) +
' of ' + IntToStr(customerListLength);
end
else if (PageNumber * PageSize) >= customerListLength then
......
......@@ -38,25 +38,25 @@
<div class="col-12 col-md-8">
</div>
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<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">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -523,7 +523,7 @@ begin
else
FViewMain.ViewOrders('');
end
else
else
begin
asm
var confirmationModal = new bootstrap.Modal(document.getElementById('confirmation_modal'), {
......
......@@ -34,25 +34,25 @@
</div>
</nav>
<div class="row mx-5">
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<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">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">>In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -34,25 +34,25 @@
</div>
</nav>
<div class="row mx-5">
<h4 class="custom-h4 mt-3">Company</h4>
<h4 class="custom-h4 mt-3">Customer</h4>
<hr class="custom-hr">
<div class="row">
<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">Customer Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
Please Provide a Customer Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Account Company Name:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Customer ID:</label>
<input id="edtaccountcompanyname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
Please Provide a Customer ID.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">In Quickbooks?:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">In Quickbooks?:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/>
</div>
</div>
......
......@@ -129,11 +129,11 @@ object FViewOrders: TFViewOrders
end
item
DataField = 'ID'
Title = 'ID'
Title = 'Customer ID'
end
item
DataField = 'companyName'
Title = 'Company Name'
Title = 'Customer Name'
end
item
DataField = 'jobName'
......
......@@ -149,7 +149,7 @@ object FSearch: TFSearch
Top = 56
Width = 107
Height = 14
Caption = 'Search Companies:'
Caption = 'Search Customers:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -162,9 +162,9 @@ object FSearch: TFSearch
object lblCompanyID: TWebLabel
Left = 174
Top = 56
Width = 68
Width = 72
Height = 14
Caption = 'Company ID:'
Caption = 'Customer ID:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -207,9 +207,9 @@ object FSearch: TFSearch
object WebLabel5: TWebLabel
Left = 338
Top = 56
Width = 89
Width = 93
Height = 14
Caption = 'Company Name:'
Caption = 'Customer Name:'
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
......@@ -457,7 +457,7 @@ object FSearch: TFSearch
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 40.000000000000000000
Width = 80.000000000000000000
end
item
BorderWidth = 1
......@@ -502,7 +502,7 @@ object FSearch: TFSearch
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 320.000000000000000000
Width = 280.000000000000000000
end
item
BorderWidth = 1
......
......@@ -274,9 +274,9 @@ begin
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'DBID';
TMSFNCGrid1.Cells[1, 0] := 'ID';
TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[0, 0] := 'Customer Num';
TMSFNCGrid1.Cells[1, 0] := 'Customer ID';
TMSFNCGrid1.Cells[2, 0] := 'Customer Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// Populate the grid with data from the dataset
......
......@@ -397,6 +397,7 @@ type
function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string;
function AddShippingAddress(Addressinfo: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function DelUser(username: string): string;
function DelOrder(orderID, orderType, UserID: string): TJSONObject;
function EditUser(const editOptions: string): string;
......
......@@ -55,6 +55,7 @@ type
function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TJSONObject;
function delOrder(OrderID, OrderType, UserID: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function GenerateSubQuery(currStatus: string): string;
......@@ -90,6 +91,38 @@ begin
inherited;
end;
function TLookupService.DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
var
SQL: string;
ADDRESS_LIST: TJSONArray;
ADDRESS: TJSONObject;
begin
SQL := 'DELETE FROM customers_ship WHERE customer_ship_id = ' + AddressID;
OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL;
result := TJSONObject.Create;
result.AddPair('status', 'Success:Address Successfully Deleted');
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + CustomerID;
doQuery(ordersDB.UniQuery1, SQL);
ADDRESS_LIST := TJSONArray.Create;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
ADDRESS.AddPair('zip', ordersDB.UniQuery1.FieldByName('zip').AsString);
ADDRESS.AddPair('contact', ordersDB.UniQuery1.FieldByName('contact').AsString);
ADDRESS.AddPair('ship_id', ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString);
ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
end;
function TLookupService.GetCustomers: TCustomerList;
// Retrieves a list of customers and sends it to the client in object form.
// The object contains the ID, Name, Short Name, and the shipping address.
......@@ -142,10 +175,7 @@ begin
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
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').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString +
' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS_BLOCK').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;
......@@ -228,11 +258,18 @@ var
temp: string;
msg: string;
ship_block: string;
ADDRESS: TJSONObject;
ADDRESS_LIST:TJSONArray;
CustomerID: string;
JSONArray: TJSONArray;
Item: TAddressItem;
begin
result := TJSONObject.Create;
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');
CustomerID := JSONData.GetValue<string>('customer_id');
if mode = 'EDIT' then
ShipID := JSONData.GetValue<integer>('customer_ship_id');
......@@ -267,26 +304,39 @@ begin
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'
begin
msg := 'Success:Shipping Address Successfully Added';
end
else
msg := 'Success:Shipping Address Successfully Edited';
Result := TJSONObject.Create.AddPair('status', msg);
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + CustomerID;
doQuery(ordersDB.UniQuery1, SQL);
ADDRESS_LIST := TJSONArray.Create;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
ADDRESS.AddPair('zip', ordersDB.UniQuery1.FieldByName('zip').AsString);
ADDRESS.AddPair('contact', ordersDB.UniQuery1.FieldByName('contact').AsString);
ADDRESS.AddPair('ship_id', ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString);
ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
Result.AddPair('status', msg);
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
Result.AddPair('error', E.Message);
end
end;
end;
......
......@@ -2,7 +2,7 @@
MemoLogLevel=3
FileLogLevel=5
webClientVersion=0.9.2
LogFileNum=518
LogFileNum=537
[Database]
Server=192.168.159.131
......
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