Commit 526d09d9 by Cam Hayes

Made some minor improvements with the items page and tested everything so that…

Made some minor improvements with the items page and tested everything so that it is ready for deployment.
parent aaffc371
......@@ -112,25 +112,23 @@ begin
XDataWebClient1.Connection := AuthConnection;
console.log('ClientConfig');
XDataWebClient1.RawInvoke('IAuthService.VerifyVersion', [clientVersion],
procedure(Response: TXDataClientResponse)
procedure(Response: TXDataClientResponse) //this is the success callback
var
jsonResult: TJSObject;
error: string;
begin
jsonResult := TJSObject(Response.Result);
console.log(jsonResult);
if jsonResult.HasOwnProperty('error') then
error := string(jsonResult['error'])
else
error := '';
if error <> '' then
Callback(False, error)
begin
error := string(jsonResult['error']);
Callback(False, error);
end
else
Callback(True, '');
end,
procedure(Error: TXDataClientError)
procedure(Error: TXDataClientError) //this is the error callback
begin
Callback(False, Error.ErrorMessage);
end);
......
......@@ -181,80 +181,6 @@ object FViewAddCustomer: TFViewAddCustomer
DataField = 'QB_LIST_ID'
DataSource = WebDataSource1
end
object edtShippingAddress: TWebEdit
Left = 190
Top = 460
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingaddress'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingState: TWebEdit
Left = 190
Top = 516
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingstate'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingContact: TWebEdit
Left = 190
Top = 578
Width = 121
Height = 22
ChildOrder = 22
ElementID = 'edtshippingcontact'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingZip: TWebEdit
Left = 190
Top = 550
Width = 121
Height = 22
ChildOrder = 22
EditType = weNumeric
ElementID = 'edtshippingzip'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShippingAddressChange
end
object edtShippingCity: TWebEdit
Left = 190
Top = 488
Width = 121
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
......@@ -343,17 +269,6 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
OnClick = btnShipAddClick
end
object edtFirstLine: TWebEdit
Left = 190
Top = 430
Width = 121
Height = 22
ChildOrder = 35
ElementID = 'edtfirstline'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnLink: TWebButton
Left = 19
Top = 566
......@@ -437,6 +352,114 @@ object FViewAddCustomer: TFViewAddCustomer
end>
DataSource = wdsShipTo
end
object edtFirstLine: TWebDBEdit
Left = 190
Top = 432
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtfirstline'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'first_line'
DataSource = wdsShipTo
end
object edtShippingState: TWebDBEdit
Left = 190
Top = 516
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtshippingstate'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'state'
DataSource = wdsShipTo
end
object edtShippingAddress: TWebDBEdit
Left = 190
Top = 460
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtshippingaddress'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'shipping_address'
DataSource = wdsShipTo
end
object edtShippingCity: TWebDBEdit
Left = 190
Top = 488
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtshippingcity'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'city'
DataSource = wdsShipTo
end
object edtShippingZip: TWebDBEdit
Left = 188
Top = 544
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtshippingzip'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'zip'
DataSource = wdsShipTo
end
object edtShippingContact: TWebDBEdit
Left = 190
Top = 572
Width = 121
Height = 22
ChildOrder = 34
ElementClassName = 'form-control'
ElementID = 'edtshippingcontact'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'contact'
DataSource = wdsShipTo
end
object memoShipBlock: TWebDBMemo
Left = 460
Top = 402
Width = 185
Height = 89
ElementClassName = 'form-control'
ElementID = 'memoshipblock'
ElementFont = efCSS
HeightPercent = 100.000000000000000000
Lines.Strings = (
'')
ReadOnly = True
SelLength = 0
SelStart = 2
WidthPercent = 100.000000000000000000
DataField = 'ship_block'
DataSource = wdsShipTo
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 454
......@@ -522,8 +545,13 @@ object FViewAddCustomer: TFViewAddCustomer
object xdwdsShipTocontact: TStringField
FieldName = 'contact'
end
object xdwdsShipToship_block: TStringField
object xdwdsShipTofirst_line: TStringField
FieldName = 'first_line'
Size = 200
end
object xdwdsShipToship_block: TMemoField
FieldName = 'ship_block'
BlobType = ftMemo
end
end
object tmrReturn: TWebTimer
......
......@@ -44,18 +44,12 @@ type
XDataWebDataSet1FAX: TStringField;
XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1CUSTOMER_ID: TIntegerField;
edtShippingAddress: TWebEdit;
edtShippingState: TWebEdit;
edtShippingContact: TWebEdit;
edtShippingZip: TWebEdit;
edtShippingCity: TWebEdit;
xdwdsShipToship_id: TStringField;
xdwdsShipToshipping_address: TStringField;
xdwdsShipTocity: TStringField;
xdwdsShipTostate: TStringField;
xdwdsShipTozip: TStringField;
xdwdsShipTocontact: TStringField;
memoShipBlock: TWebMemo;
memoAddressBlock: TWebMemo;
btnAdd: TWebButton;
btnShipSave: TWebButton;
......@@ -64,7 +58,6 @@ type
btnShipEdit: TWebButton;
btnShipAdd: TWebButton;
tmrReturn: TWebTimer;
edtFirstLine: TWebEdit;
wdsUsers: TWebDataSource;
xdwdsUsers: TXDataWebDataSet;
lblFormState: TWebLabel;
......@@ -73,9 +66,17 @@ type
btnUpdate: TWebButton;
edtRepUser: TWebDBEdit;
xdwdsUsersQBID: TStringField;
xdwdsShipToship_block: TStringField;
XDataWebDataSet1QB_TYPE: TStringField;
wdbtcAddresses: TWebDBTableControl; procedure btnSaveClick(Sender: TObject);
wdbtcAddresses: TWebDBTableControl;
edtFirstLine: TWebDBEdit;
xdwdsShipTofirst_line: TStringField;
edtShippingState: TWebDBEdit;
xdwdsShipToship_block: TMemoField;
edtShippingAddress: TWebDBEdit;
edtShippingCity: TWebDBEdit;
edtShippingZip: TWebDBEdit;
edtShippingContact: TWebDBEdit;
memoShipBlock: TWebDBMemo; procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
......@@ -176,6 +177,9 @@ begin
XDataWebDataSet1.FieldByName('BILL_ZIP').AsString := JSONObj.GetValue('BILL_ZIP').Value;
XDataWebDataSet1.FieldByName('BILL_CONTACT').AsString := JSONObj.GetValue('BILL_CONTACT').Value;
XDataWebDataSet1QB_TYPE.AsString := JSONObj.GetValue('RepUser').Value;
memoAddressBlock.Text := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
//XDataWebDataSet1.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1.Post;
......@@ -281,10 +285,10 @@ procedure TFViewAddCustomer.SendAddressToServer;
// Creates an Address JSON and then sends it to the server for the address to be
// Added or edited.
var
AddressJSON, JSONObj: TJSONObject;
AddressJSON, JSONObj, test: TJSONObject;
Response: TXDataClientResponse;
notification, RowData: TJSObject;
DataArray: TJSArray;
notification, RowData, customer: TJSObject;
address_list: TJSArray;
ship_block: string;
i: integer;
begin
......@@ -296,62 +300,66 @@ begin
AddressJSON.AddPair('zip', edtShippingzip.Text);
AddressJSON.AddPair('contact', edtShippingContact.Text);
AddressJSON.AddPair('customer_id', customerID);
AddressJSON.AddPair('first_line', xdwdsShipTofirst_line.AsString);
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 shipmode = 'EDIT' then
AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString);
AddressJSON.AddPair('mode', shipmode);
console.log(AddressJSON);
XDataWebDataSet1.Close;
xdwdsShipTo.Close;
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString]));
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
// DataArray := TJSArray(notification['ADDRESS']);
//
// xdwdsShipTo.Close;
// xdwdsShipTo.Open;
//
// xdwdsShipTo.First;
// while not xdwdsShipTo.Eof do xdwdsShipTo.Delete;
//
// for i := 0 to DataArray.length - 1 do
// begin
// RowData := TJSObject(DataArray[i]);
//
// xdwdsShipTo.Append;
// xdwdsShipTo.FieldByName('state').AsString := String(RowData['state']);
// xdwdsShipTo.FieldByName('city').AsString := String(RowData['city']);
// xdwdsShipTo.FieldByName('ship_id').AsString := String(RowData['ship_id']);
// xdwdsShipTo.FieldByName('shipping_address').AsString := String(RowData['shipping_address']);
// xdwdsShipTo.FieldByName('zip').AsString := String(RowData['zip']);
// xdwdsShipTo.FieldByName('ship_block').AsString := String(RowData['ship_block']);
// xdwdsShipTo.FieldByName('contact').AsString := String(RowData['contact']);
//
// xdwdsShipTo.Post;
// end;
customer := TJSObject(notification['customer']);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
edtCustomerID.Text := CustomerID;
address_list := TJSArray(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open;
console.log(xdwdsShipTo.RecordCount);
console.log(notification['ADDRESS']);
console.log(xdwdsShipTo.FieldByName('state').AsString);
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('ship_block').AsString;
// GetCustomer();
xdwdsShipTo.First;
while not xdwdsShipTo.Eof do xdwdsShipTo.Delete;
for i := 0 to address_list.length - 1 do
begin
RowData := TJSObject(address_list[i]);
xdwdsShipTo.Append;
xdwdsShipTo.FieldByName('state').AsString := String(RowData['state']);
xdwdsShipTo.FieldByName('city').AsString := String(RowData['city']);
xdwdsShipTo.FieldByName('ship_id').AsString := String(RowData['ship_id']);
xdwdsShipTo.FieldByName('shipping_address').AsString := String(RowData['shipping_address']);
xdwdsShipTo.FieldByName('zip').AsString := String(RowData['zip']);
xdwdsShipTo.FieldByName('ship_block').AsString := String(RowData['ship_block']);
xdwdsShipTo.FieldByName('contact').AsString := String(RowData['contact']);
xdwdsShipTo.FieldByName('first_line').AsString := String(RowData['first_line']);
xdwdsShipTo.Post;
end;
xdwdsShipTo.First;
console.log(xdwdsShipToship_block.AsString);
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
end;
procedure TFViewAddCustomer.btnAddClick(Sender: TObject);
......@@ -419,31 +427,37 @@ procedure TFViewAddCustomer.btnLinkClic(Sender: TObject);
var
newform: TFSelectCustomer;
begin
console.log(CustomerID);
newform := TFSelectCustomer.CreateNew;
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
console.log(CustomerID);
newform := TFSelectCustomer.CreateNew;
newform.Caption := 'Select Customer to Link';
newForm.Popup := True;
newForm.Border := fbDialog;
newForm.Position := poScreenCenter;
newform.Caption := 'Select Customer to Link';
newForm.Popup := True;
newForm.Border := fbDialog;
newForm.Position := poScreenCenter;
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// used to manage Back button handling to close subform
window.location.hash := 'subform';
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
newform.ShowModal(
procedure(AValue: TModalResult)
begin
EditMode();
XDataWebDataSet1.Edit;
XDataWebDataSet1QB_LIST_ID.AsString := newform.QB_ID;
XDataWebDataSet1.Post;
UpdateCustomer();
console.log(CustomerID);
end;
end
);
if newform.confirm then
begin
EditMode();
XDataWebDataSet1.Edit;
XDataWebDataSet1QB_LIST_ID.AsString := newform.QB_ID;
XDataWebDataSet1.Post;
UpdateCustomer();
console.log(CustomerID);
end;
end
);
end
else
ShowToast('Failure:User not authorized to add customer from QuickBooks', 'failure');
end;
......@@ -473,12 +487,12 @@ procedure TFViewAddCustomer.wdbtcAddressesClickCell(Sender: TObject; ACol,
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;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString;
// 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('ship_block').AsString;
if memoShipBlock.Lines.Count > 0 then
edtFirstLine.Text := memoShipBlock.Lines[0]
......@@ -492,7 +506,14 @@ begin
if XDataWebDataSet1QB_LIST_ID.AsString = '' then
ShowToast('Failure:Company must be linked to quickbooks to update!')
else
UpdateCustomer();
begin
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
UpdateCustomer();
end
else
ShowToast('Failure:User not authorized to update customer from QuickBooks', 'failure');
end;
end;
......
......@@ -91,10 +91,8 @@ begin
QB_ID := xdwdsCustomers.FieldByName('qb_items_qb_id').AsString;
name := xdwdsCustomers.FieldByName('qb_item_name').AsString;
description := xdwdsCustomers.FieldByName('item_desc').AsString;
if xdwdsCustomers.FieldByName('status').AsBoolean then
status := 'ACTIVE'
else
status := 'INACTIVE';
status := xdwdsCustomers.FieldByName('status').AsString;
confirm := true;
Close;
end;
......
......@@ -442,34 +442,42 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
newform := TFViewAddItem.CreateNew;
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// used to manage Back button handling to close subform
window.location.hash := 'subform';
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
newform.ShowModal(
procedure(AValue: TModalResult)
begin
xdwdsItems.Append;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status;
if newform.confirm then
begin
xdwdsItems.Append;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status;
console.log(xdwdsItems.FieldByName('status').AsString);
console.log(newform.status);
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end
);
end
else
ShowToast('Failure:User not authorized to add item from QuickBooks', 'failure');
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end
);
end;
procedure TFViewItems.btnCancelClick(Sender: TObject);
......@@ -506,7 +514,13 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
UpdateItem();
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
UpdateItem();
end
else
ShowToast('Failure:User not authorized to update item from QuickBooks', 'failure');
end;
procedure TFViewItems.UpdateItem();
......
......@@ -106,6 +106,7 @@ begin
lblUsers.enabled := false;
lblQBInfo.Enabled := false;
lblCustomers.Enabled := false;
lblItemsList.Enabled := false;
end;
lblAppTitle.Caption := 'Koehler-Gibson Orders';
lblVersion.Caption := 'v' + DMConnection.clientVersion;
......
......@@ -391,7 +391,7 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
if ( VerifyQBOrder() )then
begin
......@@ -630,7 +630,7 @@ begin
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open;
end;
......@@ -666,7 +666,7 @@ begin
AddressJSON.AddPair('state', newform.edtState.Text);
AddressJSON.AddPair('zip', newform.edtZip.Text);
AddressJSON.AddPair('contact', newform.edtContact.Text);
AddressJSON.AddPair('customer_id', customerID);
AddressJSON.AddPair('customer_id', xdwdsOrder.FieldByName('COMPANY_ID').AsString);
ship_block := newform.edtFirstLine.Text + slinebreak +
edtCompanyName.Text + slinebreak +
......@@ -676,6 +676,7 @@ begin
AddressJSON.AddPair('ship_block', ship_block);
AddressJSON.AddPair('mode', 'ADD');
console.log(AddressJSON);
sendAddressToServer(AddressJSON);
end;
end
......
......@@ -195,7 +195,7 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
if ( VerifyQBOrder() )then
begin
......@@ -231,7 +231,7 @@ begin
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open;
end;
......
......@@ -323,7 +323,7 @@ begin
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open;
end;
......@@ -358,7 +358,7 @@ begin
AddressJSON.AddPair('state', newform.edtState.Text);
AddressJSON.AddPair('zip', newform.edtZip.Text);
AddressJSON.AddPair('contact', newform.edtContact.Text);
AddressJSON.AddPair('customer_id', customerID);
AddressJSON.AddPair('customer_id', xdwdsOrderCOMPANY_ID.AsString);
ship_block := newform.edtFirstLine.Text + slinebreak +
edtCompanyName.Text + slinebreak +
......@@ -455,7 +455,7 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
if ( VerifyQBOrder() )then
begin
......
......@@ -38,6 +38,7 @@ type
state: string;
zip: string;
contact: string;
first_line: string;
end;
TQBCustomerItem = class
......@@ -153,13 +154,14 @@ type
TAddressItem = class
Public
ship_block: string;
ship_id: string;
first_line: string;
shipping_address: string;
city: string;
state: string;
contact: string;
zip: string;
ship_id: string;
contact: string;
ship_block: string;
end;
TCustomerItem = class
......@@ -182,6 +184,12 @@ type
SHIPPING_ADDRESS_LIST: TList<TAddressItem>;
end;
TCustomerResponse = class
Public
customer: TCustomerItem;
status: string;
end;
TCustomerList = class
Public
count: integer;
......@@ -536,7 +544,7 @@ type
function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): TJSONObject;
function AddShippingAddress(Addressinfo: string): TJSONObject;
function AddShippingAddress(Addressinfo: string): TCustomerResponse;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function DelUser(username: string): string;
function DelOrder(orderID, orderType, UserID: string): TJSONObject;
......
......@@ -61,7 +61,7 @@ type
function AddCorrugatedOrder(orderInfo: string): TJSONObject;
function AddWebOrder(orderInfo: string): TJSONObject;
function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TCustomerResponse;
function delOrder(OrderID, OrderType, UserID: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
......@@ -505,7 +505,8 @@ begin
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('ship_block', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('first_line', ordersDB.UniQuery1.FieldByName('first_line').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);
......@@ -617,7 +618,7 @@ begin
logger.Log(5, 'Getting customer with SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(result);
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
......@@ -649,6 +650,7 @@ begin
ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString;
ADDRESS.first_line := ordersDB.UniQuery1.FieldByName('first_line').AsString;
result.SHIPPING_ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
......@@ -740,7 +742,7 @@ begin
end;
end;
function TLookupService.AddShippingAddress(AddressInfo: string): TJSONObject;
function TLookupService.AddShippingAddress(AddressInfo: string): TCustomerResponse;
var
JSONData: TJSONObject;
SQL: string;
......@@ -754,7 +756,8 @@ var
CustomerID: string;
begin
logger.Log(3, 'TLookupSerivce.AddShippingAddress - start');
result := TJSONObject.Create;
result := TCustomerResponse.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
JSONData := TJSONObject.ParseJSONValue(AddressInfo) as TJSONObject;
if JSONData = nil then
......@@ -769,7 +772,7 @@ begin
ShipID := JSONData.GetValue<integer>('customer_ship_id');
SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID);
end;
logger.Log(5, 'Retrieving Address with SQL ' + SQL);
logger.Log(5, 'Retrieving Address with SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL);
try
......@@ -803,34 +806,16 @@ begin
else
msg := 'Success: Shipping Address Successfully Edited';
logger.Log(3, msg);
// Sends the updated Address List Back.
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + CustomerID;
logger.Log(5, 'Retrieving updated customer address list with SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL);
ADDRESS_LIST := TJSONArray.Create;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ship_block', 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;
// Sends the updated Address List Back.
result.customer := GetCustomer(CustomerID);
result.status := msg;
Result.AddPair('status', msg);
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
logger.Log(3, 'TLookupService.AddShippingAddress - end');
except
on E: Exception do
begin
Result.AddPair('error', E.Message);
result.status := 'An error has occured! Please contact an admin for support.';
Logger.Log(1, 'Error in TLookupService.AddShippingAddress: ' + E.Message);
end
end;
......@@ -3020,7 +3005,7 @@ var
jsObj: TJSONObject;
PhoneObj: TJSONObject;
CustomerList: TJSONArray;
AccessToken, RefreshToken, CompanyID, Client, Secret, BaseUrl, Line1, Line2: string;
AccessToken, RefreshToken, CompanyID, Client, Secret, BaseUrl, Line1, Line2, Line3: string;
LastRefresh: TDateTime;
I: integer;
SQL, CustomerTypeID: string;
......@@ -3147,7 +3132,21 @@ begin
Line1 := ShipAddr.GetValue<string>('Line1', '');
Line2 := ShipAddr.GetValue<string>('Line2', '');
if Line2 <> '' then
Line3 := ShipAddr.GetValue<string>('Line3', '');
if Line3 <> '' then
begin
ParsedCustomer.first_line := Line1;
ParsedCustomer.shipping_address := Line3;
ParsedCustomer.contact := Line2;
ParsedCustomer.ship_block := ShipAddr.GetValue('Line1', '') + sLineBreak +
Customer.GetValue<string>('DisplayName') + sLineBreak +
ShipAddr.GetValue('Line2', '') + sLineBreak +
ShipAddr.GetValue('Line3', '') + sLineBreak +
ShipAddr.GetValue('City', '') + ', ' +
ShipAddr.GetValue('CountrySubDivisionCode', '') + ' ' +
ShipAddr.GetValue('PostalCode', '')
end
else if Line2 <> '' then
begin
ParsedCustomer.shipping_address := Line2;
ParsedCustomer.contact := Line1;
......@@ -3380,7 +3379,10 @@ begin
ParsedItem.AddPair('item_desc', desc)
else
ParsedItem.AddPair('item_desc', 'N/A');
ParsedItem.AddPair('status', Item.GetValue<string>('Active'));
if Item.GetValue<string>('Active') = 'true' then
ParsedItem.AddPair('status', 'ACTIVE')
else
ParsedItem.AddPair('status', 'INACTIVE');
ParsedItem.AddPair('qb_items_qb_id', Item.GetValue<string>('Id'));
Result.AddElement(ParsedItem);
......
......@@ -50,6 +50,134 @@ object rptOrderCutting: TrptOrderCutting
DataSetOptions = []
Left = 444
Top = 206
FieldDefs = <
item
FieldName = 'ORDER_ID'
end
item
FieldName = 'COMPANY_ID'
end
item
FieldName = 'USER_ID'
end
item
FieldName = 'ORDER_DATE'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_order_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_proof_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_via'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quantity'
FieldType = fftString
end
item
FieldName = 'staff_fields_price'
FieldType = fftString
end
item
FieldName = 'staff_fields_invoice_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_ship_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_po_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'staff_fields_job_name'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'general_special_instructions'
FieldType = fftString
Size = 2048
end
item
FieldName = 'ORDER_STATUS'
FieldType = fftString
Size = 50
end
item
FieldName = 'ORDER_ID_1'
end
item
FieldName = 'COMPANY_ID_1'
end
item
FieldName = 'ORDER_TYPE'
FieldType = fftString
Size = 45
end
item
FieldName = 'ORDER_DATE_1'
FieldType = fftDateTime
end
item
FieldName = 'PRICE'
end
item
FieldName = 'JOB_NAME'
FieldType = fftString
Size = 128
end
item
FieldName = 'USER_ID_1'
end
item
FieldName = 'LOCATION'
FieldType = fftString
Size = 16
end
item
FieldName = 'IN_QB'
FieldType = fftString
end
item
FieldName = 'QB_ORDER_NUM'
FieldType = fftString
Size = 30
end
item
FieldName = 'QB_ESTIMATE_ID'
FieldType = fftString
Size = 30
end
item
FieldName = 'QB_ORDER_USER'
FieldType = fftString
Size = 60
end
item
FieldName = 'QB_CREATE_DATE'
FieldType = fftDateTime
end>
end
object frxOrderCutting: TfrxReport
Version = '2026.1.7'
......@@ -62,7 +190,7 @@ object rptOrderCutting: TrptOrderCutting
PrintOptions.Printer = 'Default'
PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 45691.397221759300000000
ReportOptions.LastChange = 45707.397776377300000000
ReportOptions.LastChange = 46143.643605335640000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
'begin'
......@@ -580,7 +708,7 @@ object rptOrderCutting: TrptOrderCutting
end
object SpecialInstructions: TfrxTableObject
AllowVectorExport = True
Left = 11.918845190000000000
Left = 8.139315190000000000
Top = 238.110390390000000000
object TableColumn61: TfrxTableColumn
Width = 723.779527559055000000
......@@ -618,7 +746,7 @@ object rptOrderCutting: TrptOrderCutting
DataSetName = 'frxDBOrderCutting'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Height = -12
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
......
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