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 ...@@ -112,25 +112,23 @@ begin
XDataWebClient1.Connection := AuthConnection; XDataWebClient1.Connection := AuthConnection;
console.log('ClientConfig'); console.log('ClientConfig');
XDataWebClient1.RawInvoke('IAuthService.VerifyVersion', [clientVersion], XDataWebClient1.RawInvoke('IAuthService.VerifyVersion', [clientVersion],
procedure(Response: TXDataClientResponse) procedure(Response: TXDataClientResponse) //this is the success callback
var var
jsonResult: TJSObject; jsonResult: TJSObject;
error: string; error: string;
begin begin
jsonResult := TJSObject(Response.Result); jsonResult := TJSObject(Response.Result);
console.log(jsonResult);
if jsonResult.HasOwnProperty('error') then if jsonResult.HasOwnProperty('error') then
error := string(jsonResult['error']) begin
else error := string(jsonResult['error']);
error := ''; Callback(False, error);
end
if error <> '' then
Callback(False, error)
else else
Callback(True, ''); Callback(True, '');
end, end,
procedure(Error: TXDataClientError) procedure(Error: TXDataClientError) //this is the error callback
begin begin
Callback(False, Error.ErrorMessage); Callback(False, Error.ErrorMessage);
end); end);
......
...@@ -181,80 +181,6 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -181,80 +181,6 @@ object FViewAddCustomer: TFViewAddCustomer
DataField = 'QB_LIST_ID' DataField = 'QB_LIST_ID'
DataSource = WebDataSource1 DataSource = WebDataSource1
end 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 object memoAddressBlock: TWebMemo
Left = 162 Left = 162
Top = 86 Top = 86
...@@ -343,17 +269,6 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -343,17 +269,6 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnShipAddClick OnClick = btnShipAddClick
end 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 object btnLink: TWebButton
Left = 19 Left = 19
Top = 566 Top = 566
...@@ -437,6 +352,114 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -437,6 +352,114 @@ object FViewAddCustomer: TFViewAddCustomer
end> end>
DataSource = wdsShipTo DataSource = wdsShipTo
end 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 object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 454 Left = 454
...@@ -522,8 +545,13 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -522,8 +545,13 @@ object FViewAddCustomer: TFViewAddCustomer
object xdwdsShipTocontact: TStringField object xdwdsShipTocontact: TStringField
FieldName = 'contact' FieldName = 'contact'
end end
object xdwdsShipToship_block: TStringField object xdwdsShipTofirst_line: TStringField
FieldName = 'first_line'
Size = 200
end
object xdwdsShipToship_block: TMemoField
FieldName = 'ship_block' FieldName = 'ship_block'
BlobType = ftMemo
end end
end end
object tmrReturn: TWebTimer object tmrReturn: TWebTimer
......
...@@ -44,18 +44,12 @@ type ...@@ -44,18 +44,12 @@ type
XDataWebDataSet1FAX: TStringField; XDataWebDataSet1FAX: TStringField;
XDataWebDataSet1PHONE: TStringField; XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1CUSTOMER_ID: TIntegerField; XDataWebDataSet1CUSTOMER_ID: TIntegerField;
edtShippingAddress: TWebEdit;
edtShippingState: TWebEdit;
edtShippingContact: TWebEdit;
edtShippingZip: TWebEdit;
edtShippingCity: TWebEdit;
xdwdsShipToship_id: TStringField; xdwdsShipToship_id: TStringField;
xdwdsShipToshipping_address: TStringField; xdwdsShipToshipping_address: TStringField;
xdwdsShipTocity: TStringField; xdwdsShipTocity: TStringField;
xdwdsShipTostate: TStringField; xdwdsShipTostate: TStringField;
xdwdsShipTozip: TStringField; xdwdsShipTozip: TStringField;
xdwdsShipTocontact: TStringField; xdwdsShipTocontact: TStringField;
memoShipBlock: TWebMemo;
memoAddressBlock: TWebMemo; memoAddressBlock: TWebMemo;
btnAdd: TWebButton; btnAdd: TWebButton;
btnShipSave: TWebButton; btnShipSave: TWebButton;
...@@ -64,7 +58,6 @@ type ...@@ -64,7 +58,6 @@ type
btnShipEdit: TWebButton; btnShipEdit: TWebButton;
btnShipAdd: TWebButton; btnShipAdd: TWebButton;
tmrReturn: TWebTimer; tmrReturn: TWebTimer;
edtFirstLine: TWebEdit;
wdsUsers: TWebDataSource; wdsUsers: TWebDataSource;
xdwdsUsers: TXDataWebDataSet; xdwdsUsers: TXDataWebDataSet;
lblFormState: TWebLabel; lblFormState: TWebLabel;
...@@ -73,9 +66,17 @@ type ...@@ -73,9 +66,17 @@ type
btnUpdate: TWebButton; btnUpdate: TWebButton;
edtRepUser: TWebDBEdit; edtRepUser: TWebDBEdit;
xdwdsUsersQBID: TStringField; xdwdsUsersQBID: TStringField;
xdwdsShipToship_block: TStringField;
XDataWebDataSet1QB_TYPE: 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 btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject); procedure btnEditClick(Sender: TObject);
...@@ -176,6 +177,9 @@ begin ...@@ -176,6 +177,9 @@ begin
XDataWebDataSet1.FieldByName('BILL_ZIP').AsString := JSONObj.GetValue('BILL_ZIP').Value; XDataWebDataSet1.FieldByName('BILL_ZIP').AsString := JSONObj.GetValue('BILL_ZIP').Value;
XDataWebDataSet1.FieldByName('BILL_CONTACT').AsString := JSONObj.GetValue('BILL_CONTACT').Value; XDataWebDataSet1.FieldByName('BILL_CONTACT').AsString := JSONObj.GetValue('BILL_CONTACT').Value;
XDataWebDataSet1QB_TYPE.AsString := JSONObj.GetValue('RepUser').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.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1.Post; XDataWebDataSet1.Post;
...@@ -281,10 +285,10 @@ procedure TFViewAddCustomer.SendAddressToServer; ...@@ -281,10 +285,10 @@ procedure TFViewAddCustomer.SendAddressToServer;
// Creates an Address JSON and then sends it to the server for the address to be // Creates an Address JSON and then sends it to the server for the address to be
// Added or edited. // Added or edited.
var var
AddressJSON, JSONObj: TJSONObject; AddressJSON, JSONObj, test: TJSONObject;
Response: TXDataClientResponse; Response: TXDataClientResponse;
notification, RowData: TJSObject; notification, RowData, customer: TJSObject;
DataArray: TJSArray; address_list: TJSArray;
ship_block: string; ship_block: string;
i: integer; i: integer;
begin begin
...@@ -296,62 +300,66 @@ begin ...@@ -296,62 +300,66 @@ begin
AddressJSON.AddPair('zip', edtShippingzip.Text); AddressJSON.AddPair('zip', edtShippingzip.Text);
AddressJSON.AddPair('contact', edtShippingContact.Text); AddressJSON.AddPair('contact', edtShippingContact.Text);
AddressJSON.AddPair('customer_id', customerID); AddressJSON.AddPair('customer_id', customerID);
AddressJSON.AddPair('first_line', xdwdsShipTofirst_line.AsString);
ship_block := edtFirstLine.Text + slinebreak + ship_block := edtFirstLine.Text + slinebreak +
edtName.Text + slinebreak + edtName.Text + slinebreak +
edtShippingContact.Text + slinebreak + edtShippingContact.Text + slinebreak +
edtShippingAddress.Text + slinebreak + edtShippingAddress.Text + slinebreak +
edtShippingCity.Text + ', ' + edtShippingState.Text + ' ' + edtShippingZip.Text; edtShippingCity.Text + ', ' + edtShippingState.Text + ' ' + edtShippingZip.Text;
AddressJSON.AddPair('ship_block', ship_block); AddressJSON.AddPair('ship_block', ship_block);
if shipmode = 'EDIT' then if shipmode = 'EDIT' then
AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString); AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString);
AddressJSON.AddPair('mode', shipmode); AddressJSON.AddPair('mode', shipmode);
console.log(AddressJSON); XDataWebDataSet1.Close;
xdwdsShipTo.Close;
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString])); [AddressJSON.ToString]));
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowToast(string(notification['status'])); ShowToast(string(notification['status']));
// DataArray := TJSArray(notification['ADDRESS']);
// customer := TJSObject(notification['customer']);
// xdwdsShipTo.Close; XDataWebDataSet1.Close;
// xdwdsShipTo.Open; XDataWebDataSet1.SetJsonData(customer);
// XDataWebDataSet1.Open;
// xdwdsShipTo.First;
// while not xdwdsShipTo.Eof do xdwdsShipTo.Delete;
// edtCustomerID.Text := CustomerID;
// for i := 0 to DataArray.length - 1 do
// begin address_list := TJSArray(customer['SHIPPING_ADDRESS_LIST']);
// 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;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
console.log(xdwdsShipTo.RecordCount); xdwdsShipTo.First;
console.log(notification['ADDRESS']); while not xdwdsShipTo.Eof do xdwdsShipTo.Delete;
console.log(xdwdsShipTo.FieldByName('state').AsString);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString; for i := 0 to address_list.length - 1 do
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString; begin
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString; RowData := TJSObject(address_list[i]);
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString; xdwdsShipTo.Append;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString; xdwdsShipTo.FieldByName('state').AsString := String(RowData['state']);
// GetCustomer(); 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; end;
procedure TFViewAddCustomer.btnAddClick(Sender: TObject); procedure TFViewAddCustomer.btnAddClick(Sender: TObject);
...@@ -419,6 +427,8 @@ procedure TFViewAddCustomer.btnLinkClic(Sender: TObject); ...@@ -419,6 +427,8 @@ procedure TFViewAddCustomer.btnLinkClic(Sender: TObject);
var var
newform: TFSelectCustomer; newform: TFSelectCustomer;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
console.log(CustomerID); console.log(CustomerID);
newform := TFSelectCustomer.CreateNew; newform := TFSelectCustomer.CreateNew;
...@@ -444,6 +454,10 @@ begin ...@@ -444,6 +454,10 @@ begin
end; end;
end end
); );
end
else
ShowToast('Failure:User not authorized to add customer from QuickBooks', 'failure');
end; end;
...@@ -473,12 +487,12 @@ procedure TFViewAddCustomer.wdbtcAddressesClickCell(Sender: TObject; ACol, ...@@ -473,12 +487,12 @@ procedure TFViewAddCustomer.wdbtcAddressesClickCell(Sender: TObject; ACol,
begin begin
xdwdsShipTo.Locate('ship_id', wdbtcAddresses.Cells[0, ARow], []); xdwdsShipTo.Locate('ship_id', wdbtcAddresses.Cells[0, ARow], []);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString; // edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString;
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString; // edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString;
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString; // edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString;
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString; // edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString; // edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString; // //memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString;
if memoShipBlock.Lines.Count > 0 then if memoShipBlock.Lines.Count > 0 then
edtFirstLine.Text := memoShipBlock.Lines[0] edtFirstLine.Text := memoShipBlock.Lines[0]
...@@ -492,7 +506,14 @@ begin ...@@ -492,7 +506,14 @@ begin
if XDataWebDataSet1QB_LIST_ID.AsString = '' then if XDataWebDataSet1QB_LIST_ID.AsString = '' then
ShowToast('Failure:Company must be linked to quickbooks to update!') ShowToast('Failure:Company must be linked to quickbooks to update!')
else else
begin
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
UpdateCustomer(); UpdateCustomer();
end
else
ShowToast('Failure:User not authorized to update customer from QuickBooks', 'failure');
end;
end; end;
......
...@@ -91,10 +91,8 @@ begin ...@@ -91,10 +91,8 @@ begin
QB_ID := xdwdsCustomers.FieldByName('qb_items_qb_id').AsString; QB_ID := xdwdsCustomers.FieldByName('qb_items_qb_id').AsString;
name := xdwdsCustomers.FieldByName('qb_item_name').AsString; name := xdwdsCustomers.FieldByName('qb_item_name').AsString;
description := xdwdsCustomers.FieldByName('item_desc').AsString; description := xdwdsCustomers.FieldByName('item_desc').AsString;
if xdwdsCustomers.FieldByName('status').AsBoolean then status := xdwdsCustomers.FieldByName('status').AsString;
status := 'ACTIVE'
else
status := 'INACTIVE';
confirm := true; confirm := true;
Close; Close;
end; end;
......
...@@ -442,6 +442,8 @@ var ...@@ -442,6 +442,8 @@ var
itemOptions: string; itemOptions: string;
newform: TFViewAddItem; newform: TFViewAddItem;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
newform := TFViewAddItem.CreateNew; newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add'; newform.Caption := 'Select Item to Add';
...@@ -463,6 +465,8 @@ begin ...@@ -463,6 +465,8 @@ begin
xdwdsItems.FieldByName('name').AsString := newform.name; xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description; xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status; xdwdsItems.FieldByName('status').AsString := newform.status;
console.log(xdwdsItems.FieldByName('status').AsString);
console.log(newform.status);
xdwdsItems.Post; xdwdsItems.Post;
EditMode(); EditMode();
...@@ -470,6 +474,10 @@ begin ...@@ -470,6 +474,10 @@ begin
end; end;
end end
); );
end
else
ShowToast('Failure:User not authorized to add item from QuickBooks', 'failure');
end; end;
procedure TFViewItems.btnCancelClick(Sender: TObject); procedure TFViewItems.btnCancelClick(Sender: TObject);
...@@ -506,7 +514,13 @@ var ...@@ -506,7 +514,13 @@ var
itemOptions: string; itemOptions: string;
newform: TFViewAddItem; newform: TFViewAddItem;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin
UpdateItem(); UpdateItem();
end
else
ShowToast('Failure:User not authorized to update item from QuickBooks', 'failure');
end; end;
procedure TFViewItems.UpdateItem(); procedure TFViewItems.UpdateItem();
......
...@@ -106,6 +106,7 @@ begin ...@@ -106,6 +106,7 @@ begin
lblUsers.enabled := false; lblUsers.enabled := false;
lblQBInfo.Enabled := false; lblQBInfo.Enabled := false;
lblCustomers.Enabled := false; lblCustomers.Enabled := false;
lblItemsList.Enabled := false;
end; end;
lblAppTitle.Caption := 'Koehler-Gibson Orders'; lblAppTitle.Caption := 'Koehler-Gibson Orders';
lblVersion.Caption := 'v' + DMConnection.clientVersion; lblVersion.Caption := 'v' + DMConnection.clientVersion;
......
...@@ -391,7 +391,7 @@ var ...@@ -391,7 +391,7 @@ var
orderJSON: TJSONObject; orderJSON: TJSONObject;
qbEnabled: boolean; qbEnabled: boolean;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin begin
if ( VerifyQBOrder() )then if ( VerifyQBOrder() )then
begin begin
...@@ -630,7 +630,7 @@ begin ...@@ -630,7 +630,7 @@ begin
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowToast(string(notification['status'])); ShowToast(string(notification['status']));
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']); xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end; end;
...@@ -666,7 +666,7 @@ begin ...@@ -666,7 +666,7 @@ begin
AddressJSON.AddPair('state', newform.edtState.Text); AddressJSON.AddPair('state', newform.edtState.Text);
AddressJSON.AddPair('zip', newform.edtZip.Text); AddressJSON.AddPair('zip', newform.edtZip.Text);
AddressJSON.AddPair('contact', newform.edtContact.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 + ship_block := newform.edtFirstLine.Text + slinebreak +
edtCompanyName.Text + slinebreak + edtCompanyName.Text + slinebreak +
...@@ -676,6 +676,7 @@ begin ...@@ -676,6 +676,7 @@ begin
AddressJSON.AddPair('ship_block', ship_block); AddressJSON.AddPair('ship_block', ship_block);
AddressJSON.AddPair('mode', 'ADD'); AddressJSON.AddPair('mode', 'ADD');
console.log(AddressJSON);
sendAddressToServer(AddressJSON); sendAddressToServer(AddressJSON);
end; end;
end end
......
...@@ -195,7 +195,7 @@ var ...@@ -195,7 +195,7 @@ var
orderJSON: TJSONObject; orderJSON: TJSONObject;
qbEnabled: boolean; qbEnabled: boolean;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin begin
if ( VerifyQBOrder() )then if ( VerifyQBOrder() )then
begin begin
...@@ -231,7 +231,7 @@ begin ...@@ -231,7 +231,7 @@ begin
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowToast(string(notification['status'])); ShowToast(string(notification['status']));
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']); xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end; end;
......
...@@ -323,7 +323,7 @@ begin ...@@ -323,7 +323,7 @@ begin
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowToast(string(notification['status'])); ShowToast(string(notification['status']));
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']); xdwdsShipTo.SetJSONData(TJSObject(notification['customer'])['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end; end;
...@@ -358,7 +358,7 @@ begin ...@@ -358,7 +358,7 @@ begin
AddressJSON.AddPair('state', newform.edtState.Text); AddressJSON.AddPair('state', newform.edtState.Text);
AddressJSON.AddPair('zip', newform.edtZip.Text); AddressJSON.AddPair('zip', newform.edtZip.Text);
AddressJSON.AddPair('contact', newform.edtContact.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 + ship_block := newform.edtFirstLine.Text + slinebreak +
edtCompanyName.Text + slinebreak + edtCompanyName.Text + slinebreak +
...@@ -455,7 +455,7 @@ var ...@@ -455,7 +455,7 @@ var
orderJSON: TJSONObject; orderJSON: TJSONObject;
qbEnabled: boolean; qbEnabled: boolean;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN' then
begin begin
if ( VerifyQBOrder() )then if ( VerifyQBOrder() )then
begin begin
......
...@@ -38,6 +38,7 @@ type ...@@ -38,6 +38,7 @@ type
state: string; state: string;
zip: string; zip: string;
contact: string; contact: string;
first_line: string;
end; end;
TQBCustomerItem = class TQBCustomerItem = class
...@@ -153,13 +154,14 @@ type ...@@ -153,13 +154,14 @@ type
TAddressItem = class TAddressItem = class
Public Public
ship_block: string; ship_id: string;
first_line: string;
shipping_address: string; shipping_address: string;
city: string; city: string;
state: string; state: string;
contact: string;
zip: string; zip: string;
ship_id: string; contact: string;
ship_block: string;
end; end;
TCustomerItem = class TCustomerItem = class
...@@ -182,6 +184,12 @@ type ...@@ -182,6 +184,12 @@ type
SHIPPING_ADDRESS_LIST: TList<TAddressItem>; SHIPPING_ADDRESS_LIST: TList<TAddressItem>;
end; end;
TCustomerResponse = class
Public
customer: TCustomerItem;
status: string;
end;
TCustomerList = class TCustomerList = class
Public Public
count: integer; count: integer;
...@@ -536,7 +544,7 @@ type ...@@ -536,7 +544,7 @@ type
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): TJSONObject; function AddItem(itemInfo: string): TJSONObject;
function AddShippingAddress(Addressinfo: string): TJSONObject; function AddShippingAddress(Addressinfo: string): TCustomerResponse;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject; function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
function DelUser(username: string): string; function DelUser(username: string): string;
function DelOrder(orderID, orderType, UserID: string): TJSONObject; function DelOrder(orderID, orderType, UserID: string): TJSONObject;
......
...@@ -61,7 +61,7 @@ type ...@@ -61,7 +61,7 @@ type
function AddCorrugatedOrder(orderInfo: string): TJSONObject; function AddCorrugatedOrder(orderInfo: string): TJSONObject;
function AddWebOrder(orderInfo: string): TJSONObject; function AddWebOrder(orderInfo: string): TJSONObject;
function AddCuttingDieOrder(orderInfo: string): TJSONObject; function AddCuttingDieOrder(orderInfo: string): TJSONObject;
function AddShippingAddress(AddressInfo: string): TJSONObject; function AddShippingAddress(AddressInfo: string): TCustomerResponse;
function delOrder(OrderID, OrderType, UserID: string): TJSONObject; function delOrder(OrderID, OrderType, UserID: string): TJSONObject;
function DelShippingAddress(AddressID, CustomerID: string): TJSONObject; function DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
...@@ -505,7 +505,8 @@ begin ...@@ -505,7 +505,8 @@ begin
while not ordersDB.UniQuery1.Eof do while not ordersDB.UniQuery1.Eof do
begin begin
ADDRESS := TJSONObject.Create; 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('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString); ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString); ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
...@@ -617,7 +618,7 @@ begin ...@@ -617,7 +618,7 @@ begin
logger.Log(5, 'Getting customer with SQL: ' + SQL); logger.Log(5, 'Getting customer with SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerItem.Create; result := TCustomerItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(result);
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger; result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
...@@ -649,6 +650,7 @@ begin ...@@ -649,6 +650,7 @@ begin
ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString; ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString; ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').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); result.SHIPPING_ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
...@@ -740,7 +742,7 @@ begin ...@@ -740,7 +742,7 @@ begin
end; end;
end; end;
function TLookupService.AddShippingAddress(AddressInfo: string): TJSONObject; function TLookupService.AddShippingAddress(AddressInfo: string): TCustomerResponse;
var var
JSONData: TJSONObject; JSONData: TJSONObject;
SQL: string; SQL: string;
...@@ -754,7 +756,8 @@ var ...@@ -754,7 +756,8 @@ var
CustomerID: string; CustomerID: string;
begin begin
logger.Log(3, 'TLookupSerivce.AddShippingAddress - start'); logger.Log(3, 'TLookupSerivce.AddShippingAddress - start');
result := TJSONObject.Create; result := TCustomerResponse.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
JSONData := TJSONObject.ParseJSONValue(AddressInfo) as TJSONObject; JSONData := TJSONObject.ParseJSONValue(AddressInfo) as TJSONObject;
if JSONData = nil then if JSONData = nil then
...@@ -769,7 +772,7 @@ begin ...@@ -769,7 +772,7 @@ begin
ShipID := JSONData.GetValue<integer>('customer_ship_id'); ShipID := JSONData.GetValue<integer>('customer_ship_id');
SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID); SQL := 'select * from customers_ship where customer_ship_id = ' + IntToStr(ShipID);
end; end;
logger.Log(5, 'Retrieving Address with SQL ' + SQL); logger.Log(5, 'Retrieving Address with SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
try try
...@@ -803,34 +806,16 @@ begin ...@@ -803,34 +806,16 @@ begin
else else
msg := 'Success: Shipping Address Successfully Edited'; msg := 'Success: Shipping Address Successfully Edited';
logger.Log(3, msg); 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; // Sends the updated Address List Back.
logger.Log(5, 'Retrieving updated customer address list with SQL: ' + SQL); result.customer := GetCustomer(CustomerID);
doQuery(ordersDB.UniQuery1, SQL); result.status := msg;
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;
Result.AddPair('status', msg);
Result.AddPair('ADDRESS', ADDRESS_LIST);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
logger.Log(3, 'TLookupService.AddShippingAddress - end'); logger.Log(3, 'TLookupService.AddShippingAddress - end');
except except
on E: Exception do on E: Exception do
begin 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); Logger.Log(1, 'Error in TLookupService.AddShippingAddress: ' + E.Message);
end end
end; end;
...@@ -3020,7 +3005,7 @@ var ...@@ -3020,7 +3005,7 @@ var
jsObj: TJSONObject; jsObj: TJSONObject;
PhoneObj: TJSONObject; PhoneObj: TJSONObject;
CustomerList: TJSONArray; CustomerList: TJSONArray;
AccessToken, RefreshToken, CompanyID, Client, Secret, BaseUrl, Line1, Line2: string; AccessToken, RefreshToken, CompanyID, Client, Secret, BaseUrl, Line1, Line2, Line3: string;
LastRefresh: TDateTime; LastRefresh: TDateTime;
I: integer; I: integer;
SQL, CustomerTypeID: string; SQL, CustomerTypeID: string;
...@@ -3147,7 +3132,21 @@ begin ...@@ -3147,7 +3132,21 @@ begin
Line1 := ShipAddr.GetValue<string>('Line1', ''); Line1 := ShipAddr.GetValue<string>('Line1', '');
Line2 := ShipAddr.GetValue<string>('Line2', ''); 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 begin
ParsedCustomer.shipping_address := Line2; ParsedCustomer.shipping_address := Line2;
ParsedCustomer.contact := Line1; ParsedCustomer.contact := Line1;
...@@ -3380,7 +3379,10 @@ begin ...@@ -3380,7 +3379,10 @@ begin
ParsedItem.AddPair('item_desc', desc) ParsedItem.AddPair('item_desc', desc)
else else
ParsedItem.AddPair('item_desc', 'N/A'); 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')); ParsedItem.AddPair('qb_items_qb_id', Item.GetValue<string>('Id'));
Result.AddElement(ParsedItem); Result.AddElement(ParsedItem);
......
...@@ -50,6 +50,134 @@ object rptOrderCutting: TrptOrderCutting ...@@ -50,6 +50,134 @@ object rptOrderCutting: TrptOrderCutting
DataSetOptions = [] DataSetOptions = []
Left = 444 Left = 444
Top = 206 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 end
object frxOrderCutting: TfrxReport object frxOrderCutting: TfrxReport
Version = '2026.1.7' Version = '2026.1.7'
...@@ -62,7 +190,7 @@ object rptOrderCutting: TrptOrderCutting ...@@ -62,7 +190,7 @@ object rptOrderCutting: TrptOrderCutting
PrintOptions.Printer = 'Default' PrintOptions.Printer = 'Default'
PrintOptions.PrintOnSheet = 0 PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 45691.397221759300000000 ReportOptions.CreateDate = 45691.397221759300000000
ReportOptions.LastChange = 45707.397776377300000000 ReportOptions.LastChange = 46143.643605335640000000
ScriptLanguage = 'PascalScript' ScriptLanguage = 'PascalScript'
ScriptText.Strings = ( ScriptText.Strings = (
'begin' 'begin'
...@@ -580,7 +708,7 @@ object rptOrderCutting: TrptOrderCutting ...@@ -580,7 +708,7 @@ object rptOrderCutting: TrptOrderCutting
end end
object SpecialInstructions: TfrxTableObject object SpecialInstructions: TfrxTableObject
AllowVectorExport = True AllowVectorExport = True
Left = 11.918845190000000000 Left = 8.139315190000000000
Top = 238.110390390000000000 Top = 238.110390390000000000
object TableColumn61: TfrxTableColumn object TableColumn61: TfrxTableColumn
Width = 723.779527559055000000 Width = 723.779527559055000000
...@@ -618,7 +746,7 @@ object rptOrderCutting: TrptOrderCutting ...@@ -618,7 +746,7 @@ object rptOrderCutting: TrptOrderCutting
DataSetName = 'frxDBOrderCutting' DataSetName = 'frxDBOrderCutting'
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack Font.Color = clBlack
Font.Height = -11 Font.Height = -12
Font.Name = 'Arial' Font.Name = 'Arial'
Font.Style = [] Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom] 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