Commit baa3b955 by Elias Sarraf

Merge remote-tracking branch 'origin/cam'

parents 245de583 bb45ab03
......@@ -109,6 +109,7 @@ procedure TAuthService.Login(AUser, APassword: string; ASuccess: TOnLoginSuccess
end;
begin
console.log('login');
if (AUser = '') or (APassword = '') then
begin
AError('Please enter a username and a password');
......
unit ConnectionModule;
unit ConnectionModule;
interface
uses
System.SysUtils, System.Classes, WEBLib.Modules, XData.Web.Connection,
App.Types, App.Config, XData.Web.Client;
System.SysUtils, System.Classes, WEBLib.Modules, WEBLib.Dialogs,
App.Types, App.Config, XData.Web.Connection, XData.Web.Client;
type
TDMConnection = class(TWebDataModule)
......@@ -19,7 +19,7 @@ type
FUnauthorizedAccessProc: TUnauthorizedAccessProc;
public
const clientVersion = '0.9.15.1';
const clientVersion = '0.9.15.5';
procedure InitApp(SuccessProc: TSuccessProc;
UnauthorizedAccessProc: TUnauthorizedAccessProc);
procedure SetClientConfig(Callback: TVersionCheckCallback);
......@@ -42,8 +42,17 @@ uses
{$R *.dfm}
procedure TDMConnection.ApiConnectionError(Error: TXDataWebConnectionError);
var
errorMsg: string;
begin
TFViewErrorPage.DisplayConnectionError(Error);
errorMsg := Error.ErrorMessage;
if errorMsg = '' then
errorMsg := 'Connection error';
if Assigned(FUnauthorizedAccessProc) then
FUnauthorizedAccessProc(errorMsg)
else
ShowMessage(errorMsg);
end;
......@@ -63,8 +72,19 @@ end;
procedure TDMConnection.AuthConnectionError(Error: TXDataWebConnectionError);
var
errorMsg: string;
begin
TFViewErrorPage.DisplayConnectionError(Error);
errorMsg := Error.ErrorMessage;
if errorMsg = '' then
errorMsg := 'Connection error';
if errorMsg = 'Error connecting to XData server' then
ShowMessage( 'Error connecting to kgOrdersServer' + sLineBreak + 'Please contact EM Systems support' )
else if Assigned(FUnauthorizedAccessProc) then
FUnauthorizedAccessProc(errorMsg)
else
ShowMessage(errorMsg);
end;
......@@ -87,13 +107,12 @@ begin
LoadConfig(@ConfigLoaded);
end;
procedure TDMConnection.SetClientConfig(Callback: TVersionCheckCallback);
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;
......@@ -101,14 +120,17 @@ begin
jsonResult := TJSObject(Response.Result);
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) //this is the error callback
begin
Callback(False, Error.ErrorMessage);
end);
end;
......
......@@ -92,6 +92,12 @@ end;
procedure ShowErrorModal(msg: string);
begin
HideSpinner('spinner');
if msg = '' then
begin
msg := 'Error connecting to EM Sytems Server.' + slinebreak +
'Please contact EM Systems Support.'
end;
asm
var modal = document.getElementById('main_errormodal');
var label = document.getElementById('main_lblmodal_body');
......
......@@ -23,7 +23,7 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
OnChange = edtShortNameChange
DataField = 'SHORT_NAME'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtName: TWebDBEdit
Left = 19
......@@ -36,7 +36,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'NAME'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtBillAddress: TWebDBEdit
Left = 19
......@@ -49,7 +49,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_ADDRESS'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtBillCity: TWebDBEdit
Left = 19
......@@ -62,7 +62,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_CITY'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtBillState: TWebDBEdit
Left = 19
......@@ -75,7 +75,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_STATE'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtBillZip: TWebDBEdit
Left = 19
......@@ -88,7 +88,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_ZIP'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtBillContact: TWebDBEdit
Left = 19
......@@ -101,7 +101,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'BILL_CONTACT'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object btnSave: TWebButton
Left = 19
......@@ -165,8 +165,9 @@ object FViewAddCustomer: TFViewAddCustomer
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtCustomerIDChange
DataField = 'CUSTOMER_ID'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object edtQBID: TWebDBEdit
Left = 151
......@@ -179,126 +180,7 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'QB_LIST_ID'
DataSource = WebDataSource1
end
object wdbtcAddresses: TWebDBTableControl
Left = 190
Top = 196
Width = 631
Height = 200
ElementClassName = 'table'
ElementId = 'tblPhoneGrid'
BorderColor = clSilver
ChildOrder = 11
ElementFont = efCSS
ElementHeaderClassName = 'thead-light sticky-top bg-light border-light'
ElementPosition = epRelative
ElementTableClassName = 'table table-striped table-hover table-bordered text-sm'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
OnClickCell = wdbtcAddressesDblClickCell
OnDblClickCell = wdbtcAddressesDblClickCell
Columns = <
item
DataField = 'ship_id'
Title = 'ID'
end
item
DataField = 'ship_block'
Title = 'Address'
end>
DataSource = wdsShipTo
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
DataSource = wdsCustomer
end
object memoAddressBlock: TWebMemo
Left = 162
......@@ -388,17 +270,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
......@@ -439,63 +310,211 @@ object FViewAddCustomer: TFViewAddCustomer
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'QB_TYPE'
DataSource = WebDataSource1
DataSource = wdsCustomer
end
object wdbtcAddresses: TWebDBTableControl
Left = 310
Top = 196
Width = 524
Height = 200
ElementId = 'tblShippingAddress'
BorderColor = clSilver
ChildOrder = 31
ElementFont = efCSS
ElementHeaderClassName = 'thead-light'
ElementTableClassName = 'table table-striped table-bordered table-hover'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
OnClickCell = wdbtcAddressesClickCell
Columns = <
item
DataField = 'ship_id'
Title = 'ID'
end
item
DataField = 'ship_block'
Title = 'Address'
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
Top = 72
end
object WebDataSource1: TWebDataSource
AutoEdit = False
DataSet = XDataWebDataSet1
object wdsCustomer: TWebDataSource
DataSet = xdwdsCustomer
Left = 532
Top = 126
end
object XDataWebDataSet1: TXDataWebDataSet
object xdwdsCustomer: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 426
Top = 132
object XDataWebDataSet1SHORT_NAME: TStringField
object xdwdsCustomerSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
object XDataWebDataSet1NAME: TStringField
object xdwdsCustomerNAME: TStringField
FieldName = 'NAME'
end
object XDataWebDataSet1BILL_ADDRESS: TStringField
object xdwdsCustomerBILL_ADDRESS: TStringField
FieldName = 'BILL_ADDRESS'
end
object XDataWebDataSet1BILL_CITY: TStringField
object xdwdsCustomerBILL_CITY: TStringField
FieldName = 'BILL_CITY'
end
object XDataWebDataSet1BILL_STATE: TStringField
object xdwdsCustomerBILL_STATE: TStringField
FieldName = 'BILL_STATE'
end
object XDataWebDataSet1BILL_CONTACT: TStringField
object xdwdsCustomerBILL_CONTACT: TStringField
FieldName = 'BILL_CONTACT'
end
object XDataWebDataSet1BILL_ZIP: TStringField
object xdwdsCustomerBILL_ZIP: TStringField
FieldName = 'BILL_ZIP'
end
object XDataWebDataSet1START_DATE: TStringField
object xdwdsCustomerSTART_DATE: TStringField
FieldName = 'START_DATE'
end
object XDataWebDataSet1QB_LIST_ID: TStringField
object xdwdsCustomerQB_LIST_ID: TStringField
FieldName = 'QB_LIST_ID'
end
object XDataWebDataSet1END_DATE: TStringField
object xdwdsCustomerEND_DATE: TStringField
FieldName = 'END_DATE'
end
object XDataWebDataSet1FAX: TStringField
object xdwdsCustomerFAX: TStringField
FieldName = 'FAX'
end
object XDataWebDataSet1PHONE: TStringField
object xdwdsCustomerPHONE: TStringField
FieldName = 'PHONE'
end
object XDataWebDataSet1CUSTOMER_ID: TIntegerField
object xdwdsCustomerCUSTOMER_ID: TIntegerField
FieldName = 'CUSTOMER_ID'
end
object XDataWebDataSet1QB_TYPE: TStringField
object xdwdsCustomerQB_TYPE: TStringField
FieldName = 'QB_TYPE'
end
end
......@@ -526,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
......
......@@ -57,7 +57,7 @@
<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 ID.
Please Provide a Customer ID.
</div>
</div>
<div class="col-auto">
......@@ -121,7 +121,7 @@
<div class="row">
<div class="overflow-auto mt-2"
style="max-height: calc(100vh - 250px); padding-bottom: 0; width: 100%;">
<table id="tblPhoneGrid" class="table table-striped table-bordered" style="width: 100%;">
<table id="tblShippingAddress" class="table table-striped table-bordered" style="width: 100%;">
<thead class="sticky-top thead-light">
<tr style="font-size: 0.875rem;">
<!-- headers -->
......
......@@ -25,38 +25,31 @@ type
btnDelete: TWebButton;
btnClose: TWebButton;
XDataWebClient1: TXDataWebClient;
WebDataSource1: TWebDataSource;
XDataWebDataSet1: TXDataWebDataSet;
XDataWebDataSet1SHORT_NAME: TStringField;
XDataWebDataSet1NAME: TStringField;
XDataWebDataSet1BILL_ADDRESS: TStringField;
XDataWebDataSet1BILL_CITY: TStringField;
wdsCustomer: TWebDataSource;
xdwdsCustomer: TXDataWebDataSet;
xdwdsCustomerSHORT_NAME: TStringField;
xdwdsCustomerNAME: TStringField;
xdwdsCustomerBILL_ADDRESS: TStringField;
xdwdsCustomerBILL_CITY: TStringField;
edtCustomerID: TWebDBEdit;
edtQBID: TWebDBEdit;
wdbtcAddresses: TWebDBTableControl;
wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet;
XDataWebDataSet1BILL_STATE: TStringField;
XDataWebDataSet1BILL_CONTACT: TStringField;
XDataWebDataSet1BILL_ZIP: TStringField;
XDataWebDataSet1START_DATE: TStringField;
XDataWebDataSet1END_DATE: TStringField;
XDataWebDataSet1QB_LIST_ID: TStringField;
XDataWebDataSet1FAX: TStringField;
XDataWebDataSet1PHONE: TStringField;
XDataWebDataSet1CUSTOMER_ID: TIntegerField;
edtShippingAddress: TWebEdit;
edtShippingState: TWebEdit;
edtShippingContact: TWebEdit;
edtShippingZip: TWebEdit;
edtShippingCity: TWebEdit;
xdwdsCustomerBILL_STATE: TStringField;
xdwdsCustomerBILL_CONTACT: TStringField;
xdwdsCustomerBILL_ZIP: TStringField;
xdwdsCustomerSTART_DATE: TStringField;
xdwdsCustomerEND_DATE: TStringField;
xdwdsCustomerQB_LIST_ID: TStringField;
xdwdsCustomerFAX: TStringField;
xdwdsCustomerPHONE: TStringField;
xdwdsCustomerCUSTOMER_ID: TIntegerField;
xdwdsShipToship_id: TStringField;
xdwdsShipToshipping_address: TStringField;
xdwdsShipTocity: TStringField;
xdwdsShipTostate: TStringField;
xdwdsShipTozip: TStringField;
xdwdsShipTocontact: TStringField;
memoShipBlock: TWebMemo;
memoAddressBlock: TWebMemo;
btnAdd: TWebButton;
btnShipSave: TWebButton;
......@@ -65,7 +58,6 @@ type
btnShipEdit: TWebButton;
btnShipAdd: TWebButton;
tmrReturn: TWebTimer;
edtFirstLine: TWebEdit;
wdsUsers: TWebDataSource;
xdwdsUsers: TXDataWebDataSet;
lblFormState: TWebLabel;
......@@ -74,12 +66,20 @@ type
btnUpdate: TWebButton;
edtRepUser: TWebDBEdit;
xdwdsUsersQBID: TStringField;
xdwdsShipToship_block: TStringField;
XDataWebDataSet1QB_TYPE: TStringField; procedure btnSaveClick(Sender: TObject);
xdwdsCustomerQB_TYPE: TStringField;
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);
procedure wdbtcAddressesDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure btnClearClick(Sender: TObject);
procedure AddressEditMode();
procedure edtShippingAddressChange(Sender: TObject);
......@@ -95,6 +95,8 @@ type
procedure btnUpdateClick(Sender: TObject);
procedure wdblcbRepChange(Sender: TObject);
procedure edtShortNameChange(Sender: TObject);
procedure wdbtcAddressesClickCell(Sender: TObject; ACol, ARow: Integer);
procedure edtCustomerIDChange(Sender: TObject);
private
{ Private declarations }
procedure ViewMode();
......@@ -163,24 +165,25 @@ begin
try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetQBCustomer', [QB_ID]));
qbCustJSON := string(TJSJSON.stringify(xdcResponse.Result));
console.log(qbCustJSON);
JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
//JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
XDataWebDataSet1.Open;
XDataWebDataSet1.Append;
xdwdsCustomer.Open;
xdwdsCustomer.Append;
xdwdsCustomer.FieldByName('NAME').AsString := JSONObj.GetValue('NAME').Value;
xdwdsCustomer.FieldByName('QB_LIST_ID').AsString := JSONObj.GetValue('QB_LIST_ID').Value;
xdwdsCustomer.FieldByName('BILL_ADDRESS').AsString := JSONObj.GetValue('BILL_ADDRESS').Value;
xdwdsCustomer.FieldByName('BILL_CITY').AsString := JSONObj.GetValue('BILL_CITY').Value;
xdwdsCustomer.FieldByName('BILL_STATE').AsString := JSONObj.GetValue('BILL_STATE').Value;
xdwdsCustomer.FieldByName('BILL_ZIP').AsString := JSONObj.GetValue('BILL_ZIP').Value;
xdwdsCustomer.FieldByName('BILL_CONTACT').AsString := JSONObj.GetValue('BILL_CONTACT').Value;
xdwdsCustomerQB_TYPE.AsString := JSONObj.GetValue('RepUser').Value;
memoAddressBlock.Text := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1.FieldByName('NAME').AsString := JSONObj.GetValue('NAME').Value;
XDataWebDataSet1.FieldByName('QB_LIST_ID').AsString := JSONObj.GetValue('QB_LIST_ID').Value;
XDataWebDataSet1.FieldByName('BILL_ADDRESS').AsString := JSONObj.GetValue('BILL_ADDRESS').Value;
XDataWebDataSet1.FieldByName('BILL_CITY').AsString := JSONObj.GetValue('BILL_CITY').Value;
XDataWebDataSet1.FieldByName('BILL_STATE').AsString := JSONObj.GetValue('BILL_STATE').Value;
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;
//XDataWebDataSet1.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1.Post;
//xdwdsCustomer.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
xdwdsCustomer.Post;
xdwdsShipTo.Open;
xdwdsShipTo.Append;
......@@ -202,7 +205,7 @@ begin
CustomerID := '';
input := TJSHTMLInputElement(document.getElementById('edtrepuser'));
if not xdwdsUsers.Locate('QBID', XDataWebDataSet1QB_TYPE.AsString, []) then
if not xdwdsUsers.Locate('QBID', xdwdsCustomerQB_TYPE.AsString, []) then
begin
input.classList.add('changed-field');
input.classList.add('is-invalid');
......@@ -257,7 +260,8 @@ begin
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
FViewMain.ViewAddCustomer('', newform.QB_ID);
end
);
end;
......@@ -278,14 +282,17 @@ begin
Utils.HideSpinner('spinner');
end;
procedure TFViewAddCustomer.SendAddressToServer;
// Creates an Address JSON and then sends it to the server for the address to be
// Added or edited.
var
AddressJSON: TJSONObject;
AddressJSON, JSONObj, test: TJSONObject;
Response: TXDataClientResponse;
notification: TJSObject;
notification, RowData, customer: TJSObject;
address_list: TJSArray;
ship_block: string;
i: integer;
begin
AddressJSON := TJSONObject.Create;
......@@ -295,33 +302,76 @@ 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);
xdwdsCustomer.Close;
xdwdsShipTo.Close;
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString]));
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
customer := TJSObject(notification['customer']);
xdwdsCustomer.Close;
xdwdsCustomer.SetJsonData(customer);
xdwdsCustomer.Open;
edtCustomerID.Text := CustomerID;
address_list := TJSArray(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open;
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;
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
end;
procedure TFViewAddCustomer.btnAddClick(Sender: TObject);
// Takes the user to the Add Customer Page.
var
AccessType: String;
begin
ShowSelectCustomerForm();
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
ShowSelectCustomerForm()
else
ShowToast('Failure:User not authorized to add customer from QuickBooks', 'failure');
end;
......@@ -350,13 +400,13 @@ begin
end;
procedure TFViewAddCustomer.btnClearClick(Sender: TObject);
// Clears the shipping address fields.
begin
Clear();
end;
procedure TFViewAddCustomer.btnCloseClick(Sender: TObject);
// closes the Add Customer page.
begin
......@@ -381,7 +431,11 @@ end;
procedure TFViewAddCustomer.btnLinkClic(Sender: TObject);
var
newform: TFSelectCustomer;
AccessType: string;
begin
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
newform := TFSelectCustomer.CreateNew;
newform.Caption := 'Select Customer to Link';
......@@ -398,14 +452,25 @@ begin
if newform.confirm then
begin
EditMode();
XDataWebDataSet1.Edit;
XDataWebDataSet1QB_LIST_ID.AsString := newform.QB_ID;
XDataWebDataSet1.Post;
xdwdsCustomer.Edit;
xdwdsCustomerQB_LIST_ID.AsString := newform.QB_ID;
xdwdsCustomer.Post;
UpdateCustomer();
end;
end
);
end
else
ShowToast('Failure:User not authorized to link customer to QuickBooks', 'failure');
end;
procedure TFViewAddCustomer.edtCustomerIDChange(Sender: TObject);
begin
EditMode();
end;
procedure TFViewAddCustomer.edtShippingAddressChange(Sender: TObject);
// Puts the form into Address Edit Mode
begin
......@@ -419,24 +484,25 @@ begin
EditMode();
end;
procedure TFViewAddCustomer.wdblcbRepChange(Sender: TObject);
begin
if lblFormState.Caption <> 'Edit Mode' then
EditMode();
end;
procedure TFViewAddCustomer.wdbtcAddressesDblClickCell(Sender: TObject; ACol,
procedure TFViewAddCustomer.wdbtcAddressesClickCell(Sender: TObject; ACol,
ARow: Integer);
// Retrieves the shipping address allowing it to be edited.
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]
......@@ -444,30 +510,43 @@ begin
edtFirstLine.Text := '';
end;
procedure TFViewAddCustomer.btnUpdateClick(Sender: TObject);
var
AccessType: string;
begin
if XDataWebDataSet1QB_LIST_ID.AsString = '' then
if xdwdsCustomerQB_LIST_ID.AsString = '' then
ShowToast('Failure:Company must be linked to quickbooks to update!')
else
begin
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
UpdateCustomer();
end
else
ShowToast('Failure:User not authorized to update customer from QuickBooks', 'failure');
end;
end;
procedure TFViewAddCustomer.UpdateCustomer;
var
customer: TJSObject;
xdcResponse: TXDataClientResponse;
msg, temp: string;
msg, short_name: string;
change: boolean;
input: TJSHTMLInputElement;
begin
try
Utils.ShowSpinner('spinner');
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.UpdateCustomer', [XDataWebDataSet1QB_LIST_ID.AsString]));
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.UpdateCustomer', [xdwdsCustomerQB_LIST_ID.AsString]));
customer := TJSObject(xdcResponse.Result);
change := false;
short_name := edtShortName.Text;
input := TJSHTMLInputElement(document.getElementById('edtcompanyname'));
if string(customer['NAME']) <> XDataWebDataSet1NAME.AsString then
if string(customer['NAME']) <> xdwdsCustomerNAME.AsString then
begin
input.classList.add('changed-field');
change := true;
......@@ -476,7 +555,7 @@ begin
input.classList.remove('changed-field');
input := TJSHTMLInputElement(document.getElementById('edtbillingaddress'));
if string(customer['BILL_ADDRESS']) <> XDataWebDataSet1BILL_ADDRESS.AsString then
if string(customer['BILL_ADDRESS']) <> xdwdsCustomerBILL_ADDRESS.AsString then
begin
input.classList.add('changed-field');
change := true;
......@@ -485,7 +564,7 @@ begin
input.classList.remove('changed-field');
input := TJSHTMLInputElement(document.getElementById('edtbillingcity'));
if string(customer['BILL_CITY']) <> XDataWebDataSet1BILL_CITY.AsString then
if string(customer['BILL_CITY']) <> xdwdsCustomerBILL_CITY.AsString then
begin
input.classList.add('changed-field');
change := true;
......@@ -494,7 +573,7 @@ begin
input.classList.remove('changed-field');
input := TJSHTMLInputElement(document.getElementById('edtbillingstate'));
if string(customer['BILL_STATE']) <> XDataWebDataSet1BILL_STATE.AsString then
if string(customer['BILL_STATE']) <> xdwdsCustomerBILL_STATE.AsString then
begin
input.classList.add('changed-field');
change := true;
......@@ -503,7 +582,16 @@ begin
input.classList.remove('changed-field');
input := TJSHTMLInputElement(document.getElementById('edtbillingzip'));
if string(customer['BILL_ZIP']) <> XDataWebDataSet1BILL_ZIP.AsString then
if string(customer['BILL_ZIP']) <> xdwdsCustomerBILL_ZIP.AsString then
begin
input.classList.add('changed-field');
change := true;
end
else
input.classList.remove('changed-field');
input := TJSHTMLInputElement(document.getElementById('edtrepuser'));
if string(customer['QB_TYPE']) <> xdwdsCustomerQB_TYPE.AsString then
begin
input.classList.add('changed-field');
change := true;
......@@ -511,19 +599,31 @@ begin
else
input.classList.remove('changed-field');
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
if not xdwdsUsers.Locate('QBID', string(customer['QB_TYPE']), []) then
begin
input.classList.add('is-invalid');
end
else
input.classList.remove('is-invalid');
xdwdsCustomer.Close;
xdwdsCustomer.SetJsonData(customer);
xdwdsCustomer.Open;
xdwdsCustomer.Edit;
xdwdsCustomerCUSTOMER_ID.AsString := CustomerID;
xdwdsCustomerSHORT_NAME.AsString := short_name;
;
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
Utils.HideSpinner('spinner');
if change then
begin
EditMode;
ShowToast('Update successful. Changes have been highlighted');
ShowToast('Changes have been highlighted');
end
else
ShowToast('Update successful. No Changes needed');
ShowToast('No Changes needed');
except
on E: EXDataClientRequestException do
begin
......@@ -533,6 +633,7 @@ begin
end;
end;
procedure TFViewAddCustomer.SendCustomerToServer();
// Creates the customer JSON and then sends it to the server.
var
......@@ -545,14 +646,15 @@ var
msg: string;
BILL_ADDRESS_BLOCK: string;
begin
try
if mode = 'EDIT' then
begin
customerJSON := TJSONObject.Create;
XDataWebDataSet1.First;
xdwdsCustomer.First;
while not XDataWebDataSet1.Eof do
while not xdwdsCustomer.Eof do
begin
for Field in XDataWebDataSet1.Fields do
for Field in xdwdsCustomer.Fields do
begin
if Field is TStringField then
begin
......@@ -566,13 +668,10 @@ begin
customerJSON.AddPair(Field.FieldName, Field.AsString);
end;
end;
XDataWebDataSet1.Next;
xdwdsCustomer.Next;
end;
BILL_ADDRESS_BLOCK := edtName.Text + slinebreak +
edtBillContact.Text + slinebreak +
edtBillAddress.Text + slinebreak +
edtBillCity.Text + ', ' + edtBillState.Text + ' ' + edtBillZip.Text;
BILL_ADDRESS_BLOCK := memoAddressBlock.Text;
CustomerJSON.AddPair('BILL_ADDRESS_BLOCK', BILL_ADDRESS_BLOCK);
......@@ -587,19 +686,12 @@ begin
else
begin
JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
JSONObj.AddPair('SHORT_NAME', XDataWebDataSet1SHORT_NAME.AsString);
JSONObj.AddPair('SHORT_NAME', xdwdsCustomerSHORT_NAME.AsString);
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.ImportQBCustomer',
[JSONObj.ToString]));
XDataWebDataSet1.Edit;
notification := TJSObject(Response.Result);
XDataWebDataSet1Customer_ID.AsInteger := integer(notification['CustomerID']);
XDataWebDataSet1.Post;
end;
msg := string(notification['status']);
if CustomerID = '' then
CustomerID := string(notification['CustomerID']);
edtCustomerID.Text := CustomerID;
ShowToast(msg);
if msg.Contains('Failure') then
......@@ -607,19 +699,35 @@ begin
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
input.classList.add('is-invalid');
input := TJSHTMLInputElement(document.getElementById('shortnamefeedback'));
input.innerHTML := 'Company Account Name must be Unique.' ;
input.innerHTML := 'Customer ID must be unique.' ;
end
else
begin
if CustomerID = '' then
CustomerID := string(notification['CustomerID']);
xdwdsCustomer.Edit;
edtCustomerID.Text := CustomerID;
xdwdsCustomerCustomer_ID.AsInteger := integer(notification['CustomerID']);
xdwdsCustomer.Post;
TJSHTMLInputElement(document.getElementById('edtcompanyname')).classList.remove('changed-field');
TJSHTMLInputElement(document.getElementById('edtbillingaddress')).classList.remove('changed-field');
TJSHTMLInputElement(document.getElementById('edtbillingcity')).classList.remove('changed-field');
TJSHTMLInputElement(document.getElementById('edtbillingstate')).classList.remove('changed-field');
TJSHTMLInputElement(document.getElementById('edtbillingzip')).classList.remove('changed-field');
mode := 'EDIT';
await(GetCustomer());
input := TJSHTMLInputElement(document.getElementById('edtrepuser'));
input.classList.remove('changed-field');
input.classList.remove('is-invalid');
ViewMode();
end;
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
// Sends the customer JSON to the server
begin
......@@ -629,18 +737,15 @@ begin
end;
end;
procedure TFViewAddCustomer.Save;
var
input: TJSHTMLInputElement;
begin
await(sendCustomerToServer());
await(GetCustomer());
input := TJSHTMLInputElement(document.getElementById('edtrepuser'));
input.classList.remove('changed-field');
input.classList.remove('is-invalid');
ViewMode();
end;
procedure TFViewAddCustomer.btnShipAddClick(Sender: TObject);
// Sets the form to address edit mode and allows the user to add a shipping address.
begin
......@@ -670,7 +775,7 @@ end;
procedure TFViewAddCustomer.btnShipDeleteClick(Sender: TObject);
begin
ShowToast('Deleting Shipping Addresses is not yet implemented.', 'info');
ShowToast('Deleting shipping addresses is not yet implemented.', 'info');
{ShowConfirmationModal(
'Are you sure you want to delete this address?',
'Delete',
......@@ -706,8 +811,8 @@ begin
if VerifyAddress() then
begin
await(SendAddressToServer);
Clear();
await(GetCustomer); // Ensures xdwdsShipTo is refreshed with server data
//Clear();
//await(GetCustomer); // Ensures xdwdsShipTo is refreshed with server data
ViewMode();
end;
end;
......@@ -722,9 +827,9 @@ begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer', [customerID]));
customer := TJSObject(xdcResponse.Result);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
xdwdsCustomer.Close;
xdwdsCustomer.SetJsonData(customer);
xdwdsCustomer.Open;
edtCustomerID.Text := CustomerID;
......@@ -734,13 +839,13 @@ begin
xdwdsShipTo.Open;
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
console.log(customer['SHIPPING_ADDRESS_LIST']);
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]
else
......@@ -754,6 +859,7 @@ begin
xdwdsUsers.Open;
end;
procedure TFViewAddCustomer.tmrReturnTimer(Sender: TObject);
// Timer to returnto the customer page because it takes slightly too long to
// Delete customers causing ghost customers to show up.
......@@ -779,17 +885,17 @@ begin
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
if edtShortName.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
input := TJSHTMLInputElement(document.getElementById('shortnamefeedback'));
input.innerHTML := 'Please Provide a Customer ID.' ;
end
else
input.classList.remove('is-invalid');
// Billing Information Verification
input := TJSHTMLInputElement(document.getElementById('edtbillingaddress'));
if edtBillAddress.Text = '' then
......@@ -827,16 +933,9 @@ begin
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');
end;
function TFViewAddCustomer.VerifyAddress: Boolean;
// Verifies all the shipping information is filled in.
var
......@@ -899,10 +998,11 @@ begin
end;
procedure TFViewAddCustomer.EditMode;
// Enables Customer Fields while disabling shipping address fields.
begin
XDataWebDataSet1.Edit;
xdwdsCustomer.Edit;
FViewMain.change := true;
btnAdd.Enabled := false;
btnDelete.Enabled := false;
......@@ -931,6 +1031,7 @@ begin
lblFormState.ElementHandle.classList.add('text-success');
end;
procedure TFViewAddCustomer.AddressEditMode;
// Enables Shipping Address fields while disabling customer fields.
begin
......@@ -996,4 +1097,5 @@ begin
lblFormState.ElementHandle.classList.add('text-danger');
end;
end.
\ No newline at end of file
......@@ -206,7 +206,6 @@ object FSelectCustomer: TFSelectCustomer
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
OnCellClick = TMSFNCGrid1CellClick
ExplicitLeft = 4
end
object btnCancel: TWebButton
Left = 556
......
......@@ -86,13 +86,12 @@ begin
ShowToast('Please Select a Customer', 'danger')
else
begin
if ( string(self.Caption).ToLower.Contains('add') and xdwdsCustomers.FieldByName('InKGOrders').AsBoolean) then
if ( xdwdsCustomers.FieldByName('InKGOrders').AsBoolean ) then
ShowToast('failure:Customer Already in Database')
else
begin
confirm := true;
QB_ID := xdwdsCustomers.FieldByName('Id').AsString;
FViewMain.ViewAddCustomer('', QB_ID);
Close();
end;
end;
......
......@@ -112,6 +112,7 @@ object FViewCustomers: TFViewCustomers
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
OnClickCell = wdbtcCustomersClickCell
OnDblClickCell = wdbtcCustomersDblClickCell
Columns = <
item
......
......@@ -38,6 +38,7 @@ type
procedure wdbtcCustomersDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure edtFilterChange(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject);
procedure wdbtcCustomersClickCell(Sender: TObject; ACol, ARow: Integer);
private
{ Private declarations }
procedure GeneratePagination(TotalPages: Integer);
......@@ -82,7 +83,8 @@ begin
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
FViewMain.ViewAddCustomer('', newform.QB_ID);
end
);
end;
......@@ -169,6 +171,12 @@ begin
getCustomers(GenerateSearchOptions());
end;
procedure TFViewCustomers.wdbtcCustomersClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
console.log(xdwdsCustomersSHORT_NAME.AsString);
end;
procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol,
ARow: Integer);
begin
......
......@@ -22,18 +22,11 @@ object FViewHome: TFViewHome
HeightPercent = 100.000000000000000000
Lines.Strings = (
'Change Log:'
'1) Setting a status now autofills due dates.'
'2) Fixed order dates displaying on 3 lines rather than 2.'
'3) Adjusted pdfs so that special instructions would have enough ' +
'space.'
'4) Fixed issue with PDF generation.'
'5) Removed ability to put 0 or a negative number for price and q' +
'uantity on order entry fields.')
'1) Updated access type'
'2) Removed user profile')
ReadOnly = True
SelLength = 0
SelStart = 323
SelStart = 62
WidthPercent = 100.000000000000000000
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;
......
......@@ -439,9 +439,12 @@ end;
procedure TFViewItems.btnAddClick(Sender: TObject);
var
itemOptions: string;
itemOptions, AccessType: string;
newform: TFViewAddItem;
begin
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add';
......@@ -463,6 +466,8 @@ begin
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();
......@@ -470,6 +475,10 @@ begin
end;
end
);
end
else
ShowToast('Failure:User not authorized to add item from QuickBooks', 'failure');
end;
procedure TFViewItems.btnCancelClick(Sender: TObject);
......@@ -498,15 +507,22 @@ end;
procedure TFViewItems.btnDeleteClick(Sender: TObject);
begin
ShowNotificationModal('Deleting items is not yet implemented.');
ShowToast('Deleting items is not yet implemented.', 'info');
end;
procedure TFViewItems.btnUpdateClick(Sender: TObject);
var
itemOptions: string;
itemOptions, AccessType: string;
newform: TFViewAddItem;
begin
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
UpdateItem();
end
else
ShowToast('Failure:User not authorized to update item from QuickBooks', 'failure');
end;
procedure TFViewItems.UpdateItem();
......@@ -560,10 +576,10 @@ begin
if change then
begin
EditMode;
ShowToast('Update successful. Changes have been highlighted');
ShowToast('Changes have been highlighted');
end
else
ShowToast('Update successful. No Changes needed');
ShowToast('No Changes needed');
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......
......@@ -54,7 +54,7 @@ procedure TFViewLogin.btnLoginClick(Sender: TObject);
procedure LoginError(AMsg: string);
begin
ShowNotification('Login Error: ' + AMsg);
ShowNotification(AMsg);
end;
var
hashPW: string;
......
......@@ -22,17 +22,6 @@ object FViewMain: TFViewMain
Transparent = False
WidthPercent = 100.000000000000000000
end
object wllblUserProfile: TWebLinkLabel
Left = 529
Top = 21
Width = 59
Height = 14
ElementID = 'dropdown.menu.userprofile'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = wllblUserProfileClick
Caption = ' User Profile'
end
object wllblLogout: TWebLinkLabel
Left = 554
Top = 148
......@@ -74,6 +63,7 @@ object FViewMain: TFViewMain
Height = 14
ElementID = 'dropdown.menu.itemlist'
ElementFont = efCSS
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblItemsListClick
......@@ -86,6 +76,7 @@ object FViewMain: TFViewMain
Height = 14
ElementID = 'dropdown.menu.users'
ElementFont = efCSS
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblUsersClick
......@@ -114,6 +105,7 @@ object FViewMain: TFViewMain
ElementID = 'lblcustomers'
ElementFont = efCSS
ElementPosition = epRelative
Enabled = False
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
......@@ -140,6 +132,7 @@ object FViewMain: TFViewMain
Caption = 'QB Info'
ElementID = 'dropdown.menu.linktoqb'
ElementFont = efCSS
Enabled = False
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
......@@ -153,8 +146,14 @@ object FViewMain: TFViewMain
Caption = 'TEST MODE'
ElementID = 'view.main.test'
ElementFont = efCSS
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebPanel1: TWebPanel
......
......@@ -4,7 +4,7 @@
<div class="d-flex align-items-center">
<a id="view.main.apptitle" class="navbar-brand" href="index.html">Koehler-Gibson Orders</a>
<span id="view.main.version" class="small text-muted ms-2 me-5"></span>
<span id="view.main.test" class="test-warning fw-bold mb-1" style="display: none;">TEST MODE</span>
<span id="view.main.test" class="test-warning fw-bold mb-1 text-nowrap" style="display: none; font-size: 0.85rem;">TEST MODE</span>
</div>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
......@@ -28,9 +28,6 @@
<a class="dropdown-item" id="dropdown.menu.home" href="#"><i class="fa fa-home fa-fw"></i><span> Home</span></a>
</li>
<li>
<a class="dropdown-item" id="dropdown.menu.userprofile" href="#"><i class="fa fa-user fa-fw"></i><span> User Profile</span></a>
</li>
<li>
<a class="dropdown-item" id="dropdown.menu.users" href="#"><i class="fas fa-address-book fa-fw"></i><span> Users</span></a>
</li>
<li>
......
......@@ -12,7 +12,6 @@ uses
type
TFViewMain = class(TWebForm)
lblUsername: TWebLabel;
wllblUserProfile: TWebLinkLabel;
wllblLogout: TWebLinkLabel;
WebPanel1: TWebPanel;
lblHome: TWebLinkLabel;
......@@ -29,7 +28,6 @@ type
WebLabel1: TWebLabel;
procedure WebFormCreate(Sender: TObject);
procedure mnuLogoutClick(Sender: TObject);
procedure wllblUserProfileClick(Sender: TObject);
procedure wllblLogoutClick(Sender: TObject);
procedure lblHomeClick(Sender: TObject);
procedure lblItemsListClick(Sender: TObject);
......@@ -75,7 +73,6 @@ implementation
uses
Auth.Service,
View.Login,
View.UserProfile,
View.Home,
View.Items,
View.Users,
......@@ -92,7 +89,7 @@ uses
procedure TFViewMain.WebFormCreate(Sender: TObject);
var
userName: string;
userName, AccessType: string;
test: boolean;
begin
FUserInfo := GetUserInfo;
......@@ -100,13 +97,20 @@ begin
lblUsername.Caption := ' ' + userName.ToLower + ' ';
FChildForm := nil;
change := false;
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if (not (JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN')) then
if ( AccessType = 'ADMIN' ) then
begin
lblUsers.enabled := false;
lblQBInfo.Enabled := false;
lblCustomers.Enabled := false;
lblUsers.enabled := true;
end;
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
lblQBInfo.Enabled := true;
lblCustomers.Enabled := true;
lblItemsList.Enabled := true;
end;
lblAppTitle.Caption := 'Koehler-Gibson Orders';
lblVersion.Caption := 'v' + DMConnection.clientVersion;
ShowForm(TFViewOrders);
......@@ -266,14 +270,6 @@ begin
end;
procedure TFViewMain.wllblUserProfileClick(Sender: TObject);
begin
ShowCrudForm(TFViewUserProfile);
lblAppTitle.Caption := 'Koehler-Gibson User Profile';
setActive('User Profile');
end;
function TFViewMain.GetUserInfo: string;
var
userStr: string;
......
......@@ -390,8 +390,10 @@ procedure TFOrderEntryCorrugated.btnQBClick(Sender: TObject);
var
orderJSON: TJSONObject;
qbEnabled: boolean;
AccessType: string;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
if ( VerifyQBOrder() )then
begin
......@@ -513,6 +515,10 @@ begin
xdwdsOrder.Close;
xdwdsOrder.SetJsonData(jsObj);
xdwdsOrder.Open;
cbLoose.Checked := ( xdwdsOrder.FieldByName('mounting_loose').AsString <> '' );
cbStripMount.Checked := ( xdwdsOrder.FieldByName('mounting_strip_mount').AsString <> '' );
OrderID := xdwdsOrderORDER_ID.AsString;
mode := 'EDIT';
ShowToast(string(jsObj.Properties['status']));
......@@ -630,7 +636,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 +672,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 +682,7 @@ begin
AddressJSON.AddPair('ship_block', ship_block);
AddressJSON.AddPair('mode', 'ADD');
console.log(AddressJSON);
sendAddressToServer(AddressJSON);
end;
end
......@@ -787,7 +794,7 @@ begin
container := TJSHTMLElement(document.getElementById('additionalFields'));
if Assigned(container) then
container.innerHTML := ''; // Wipe previous content
container.innerHTML := ''; // Wipe previous colors
if xdwdsOrdercolors_colors.Value <> '' then
begin
......@@ -800,6 +807,7 @@ begin
end;
end;
if xdwdsOrder.FieldByName('mounting_loose').AsString <> '' then
cbLoose.Checked := true;
......
......@@ -194,8 +194,10 @@ procedure TFOrderEntryCuttingDie.btnQBClick(Sender: TObject);
var
orderJSON: TJSONObject;
qbEnabled: boolean;
AccessType: string;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
if ( VerifyQBOrder() )then
begin
......@@ -231,7 +233,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;
......@@ -428,6 +430,7 @@ begin
xdwdsOrder.Close;
xdwdsOrder.SetJsonData(jsObj);
xdwdsOrder.Open;
OrderID := xdwdsOrderORDER_ID.AsString;
mode := 'EDIT';
ShowToast(String(jsObj.Properties['status']));
......@@ -488,8 +491,8 @@ begin
if confirmed then
begin
FViewMain.change := false;
if xdwdsOrder.FieldByName('ORDER_ID').AsString <> '' then
FViewMain.ViewOrderEntryCuttingDie(xdwdsOrder.FieldByName('ORDER_ID').AsString, '', 'EDIT', 'Failure: Changes Discarded')
if orderID <> '' then
FViewMain.ViewOrderEntryCuttingDie(orderID, '', 'EDIT', 'Failure: Changes Discarded')
else
FViewMain.ViewOrders('');
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 +
......@@ -454,8 +454,10 @@ procedure TFOrderEntryWeb.btnQBClick(Sender: TObject);
var
orderJSON: TJSONObject;
qbEnabled: boolean;
AccessType: string;
begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
begin
if ( VerifyQBOrder() )then
begin
......@@ -597,6 +599,7 @@ begin
xdwdsOrder.Open;
mode := 'EDIT';
OrderID := xdwdsOrderORDER_ID.AsString;
ShowToast(String(jsObj.Properties['status']));
except
on E: EXDataClientRequestException do
......@@ -768,6 +771,7 @@ var
colorList: TJSArray;
color: TJSObject;
items: TJSObject;
container: TJSHTMLElement;
begin
Utils.ShowSpinner('spinner');
try
......@@ -779,6 +783,10 @@ begin
xdwdsOrder.SetJsonData(order);
xdwdsOrder.Open;
container := TJSHTMLElement(document.getElementById('additionalFields'));
if Assigned(container) then
container.innerHTML := ''; // Wipe previous colors
if xdwdsOrderquantity_and_colors_qty_colors.Value <> '' then
begin
colorObject := TJSObject(TJSJSON.parse(xdwdsOrderquantity_and_colors_qty_colors.Value));
......@@ -875,6 +883,7 @@ begin
btnCancel.Enabled := True;
btnEdit.Enabled := false;
btnAdd.Enabled := false;
btnQB.Enabled := false;
cbPdf.Enabled := True;
cbInkJet.Enabled := True;
......@@ -912,6 +921,7 @@ begin
btnCancel.Enabled := false;
btnEdit.Enabled := true;
btnAdd.Enabled := true;
btnQB.Enabled := true;
FViewMain.change := false;
cbPdf.Enabled := False;
......
......@@ -14,7 +14,7 @@ uses
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, XData.Web.DatasetCommon,
WEBLib.Grids, VCL.Forms;
WEBLib.Grids, VCL.Forms, Math;
type
TFViewOrders = class(TWebForm)
......@@ -552,8 +552,15 @@ end;
procedure TFViewOrders.wcbPageSizeChange(Sender: TObject);
var
ratio: double;
begin
ratio := PageSize/StrToInt(wcbPageSize.Text);
PageSize := StrToInt(wcbPageSize.Text);
if ratio < 1 then
PageNumber := Ceil(PageNumber * ratio)
else
PageNumber := Ceil(PageNumber * ratio) - Trunc(ratio) + 1;
getOrders(generateSearchOptions());
end;
......
......@@ -36,11 +36,17 @@ implementation
{$R *.dfm}
uses View.Main, Utils;
uses View.Main, Utils, Auth.Service;
procedure TFQBInfo.btnLinkToQBClick(Sender: TObject);
var
AccessType: String;
begin
GetQBLink();
AccessType := JS.toString(AuthService.TokenPayload.Properties['user_access_type']);
if( ( AccessType = 'ADMIN' ) or ( AccessType = 'QBUSR' ) ) then
GetQBLink()
else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure');
end;
procedure TFQBInfo.WebFormCreate(Sender: TObject);
......
......@@ -220,7 +220,7 @@ begin
else if wlcbStatus.DisplayText = 'Plate Done' then
begin
dtpPlateDue.Date := plateDue;
dtpShipDue.Date := plateDue;
dtpShipDue.Date := dtpDate.Date;
end
else if wlcbStatus.DisplayText = 'Ship Done' then
begin
......@@ -235,10 +235,6 @@ begin
begin
dtpShipDue.Date := shipDue;
end
else if wlcbStatus.DisplayText = 'Art Done' then
begin
dtpShipDue.Date := dtpDate.Date;
end
else if wlcbStatus.DisplayText = 'Ship Done' then
begin
dtpShipDue.Date := shipDue;
......
......@@ -195,23 +195,9 @@ object FViewEditUser: TFViewEditUser
ChildOrder = 19
ElementID = 'edtrights'
HeightPercent = 100.000000000000000000
MaxLength = 11
WidthPercent = 100.000000000000000000
end
object cbAccess: TWebComboBox
Left = 346
Top = 90
Width = 145
Height = 23
ElementID = 'cbaccess'
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'SALES'
'USER'
'ADMIN')
end
object edtQB: TWebEdit
Left = 346
Top = 62
......@@ -223,6 +209,33 @@ object FViewEditUser: TFViewEditUser
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object cbAccess: TWebLookupComboBox
Left = 346
Top = 93
Width = 145
Height = 22
ElementID = 'cbaccess'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
ItemIndex = -1
LookupValues = <
item
Value = 'ADMIN'
DisplayText = 'Admin'
end
item
Value = 'USER'
DisplayText = 'User'
end
item
Value = 'SALES'
DisplayText = 'Sales User'
end
item
Value = 'QBUSR'
DisplayText = 'QB User'
end>
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 514
......
......@@ -29,9 +29,9 @@ type
lblRights: TWebLabel;
edtRights: TWebEdit;
lblAccess: TWebLabel;
cbAccess: TWebComboBox;
lblQB: TWebLabel;
edtQB: TWebEdit;
cbAccess: TWebLookupComboBox;
procedure WebFormCreate(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
......@@ -90,7 +90,7 @@ begin
'&password=' + edtPassword.Text +
'&status=' + BoolToStr(cbStatus.Checked) +
'&email=' + edtEmail.Text +
'&access=' + cbAccess.Text +
'&access=' + cbAccess.Value +
'&newuser=' + edtUsername.Text +
'&rights=' + edtRights.Text +
'&QB=' + edtQB.Text;
......@@ -123,7 +123,7 @@ begin
'&password=' + edtPassword.Text +
'&status=' + BoolToStr(cbStatus.Checked) +
'&email=' + edtEmail.Text +
'&access=' + cbAccess.Text +
'&access=' + cbAccess.Value +
'&newuser=' + edtUsername.Text +
'&rights=' + edtRights.Text +
'&QB=' + edtQB.Text;
......@@ -176,7 +176,10 @@ begin
edtPassword.Text := 'hidden';
end;
edtEmail.Text := Email;
cbAccess.Text := Access;
if Access = '' then
cbAccess.Value := 'USER'
else
cbAccess.Value := Access;
edtRights.Text := Rights;
edtQB.Text := QB;
if Status = 'ACTIVE' then
......
object FViewUserProfile: TFViewUserProfile
Width = 604
Height = 434
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object WebLabel1: TWebLabel
Left = 24
Top = 24
Width = 55
Height = 13
Caption = 'User Profile'
ElementID = 'view.userprofile.title'
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
Visible = False
WidthPercent = 100.000000000000000000
end
object WebLabel3: TWebLabel
Left = 41
Top = 60
Width = 38
Height = 14
Caption = 'User ID:'
ElementID = 'view.userprofile.form.lblUserID'
ElementPosition = epRelative
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left = 8
Top = 143
Width = 71
Height = 14
Caption = 'Email Address:'
ElementID = 'view.userprofile.form.lblEmail'
ElementPosition = epRelative
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel4: TWebLabel
Left = 27
Top = 84
Width = 52
Height = 14
Caption = 'Username:'
ElementID = 'view.userprofile.form.lblUserName'
ElementPosition = epRelative
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel5: TWebLabel
Left = 30
Top = 117
Width = 49
Height = 14
Caption = 'Full Name:'
ElementID = 'view.userprofile.form.lblFullName'
ElementPosition = epRelative
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.000000000000000000
end
object WebLabel6: TWebLabel
Left = 15
Top = 171
Width = 64
Height = 13
Caption = 'Access Type:'
ElementID = 'view.userprofile.form.lblAccessType'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel7: TWebLabel
Left = 47
Top = 196
Width = 32
Height = 13
Caption = 'QB ID:'
ElementID = 'view.userprofile.form.lblQBID'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebDBEdit1: TWebDBEdit
Left = 90
Top = 168
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtAccessType'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'AType'
DataSource = wdsUser
end
object WebDBEdit2: TWebDBEdit
Left = 90
Top = 140
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtEmail'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'email_address'
DataSource = wdsUser
end
object WebDBEdit3: TWebDBEdit
Left = 90
Top = 114
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtFullName'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'full_name'
DataSource = wdsUser
end
object WebDBEdit4: TWebDBEdit
Left = 85
Top = 81
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtUsername'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'username'
DataSource = wdsUser
end
object WebDBEdit5: TWebDBEdit
Left = 85
Top = 57
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtUserID'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'userID'
DataSource = wdsUser
end
object WebDBEdit6: TWebDBEdit
Left = 90
Top = 196
Width = 121
Height = 22
ChildOrder = 13
ElementClassName = 'form-control'
ElementID = 'view.userprofile.form.edtQBID'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'WebDBEdit1'
WidthPercent = 100.000000000000000000
DataField = 'QBID'
DataSource = wdsUser
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 359
Top = 52
end
object xdwdsUser: TXDataWebDataSet
Left = 314
Top = 216
object xdwdsUseruserID: TStringField
FieldName = 'userID'
end
object xdwdsUserusername: TStringField
FieldName = 'username'
end
object xdwdsUseremail_address: TStringField
FieldName = 'email_address'
end
object xdwdsUserQBID: TStringField
FieldName = 'QBID'
end
object xdwdsUserAType: TStringField
FieldName = 'Atype'
end
object xdwdsUserfull_name: TStringField
FieldName = 'full_name'
end
end
object wdsUser: TWebDataSource
AutoEdit = False
DataSet = xdwdsUser
Left = 422
Top = 262
end
end
<div class="container">
<!-- Profile form -->
<div class="row">
<div class="col-lg-8 col-xl-6 mx-auto">
<form id="userprofileform" class="needs-validation" role="form" autocomplete="off" novalidate>
<div class="mb-3">
<label id="view.userprofile.form.lblUserID"
for="view.userprofile.form.edtUserID"
class="form-label">User&nbsp;ID</label>
<input id="view.userprofile.form.edtUserID"
class="form-control"
readonly>
</div>
<div class="mb-3">
<label id="view.userprofile.form.lblUserName"
for="view.userprofile.form.edtUsername"
class="form-label">Username</label>
<input id="view.userprofile.form.edtUsername"
class="form-control">
</div>
<div class="mb-3">
<label id="view.userprofile.form.lblFullName"
for="view.userprofile.form.edtFullName"
class="form-label">Full&nbsp;Name</label>
<input id="view.userprofile.form.edtFullName"
class="form-control">
</div>
<div class="mb-3">
<label id="view.userprofile.form.lblEmail"
for="view.userprofile.form.edtEmail"
class="form-label">Email&nbsp;Address</label>
<input id="view.userprofile.form.edtEmail"
type="email"
class="form-control">
</div>
<div class="mb-3">
<label id="view.userprofile.form.lblAccessType"
for="view.userprofile.form.edtAccessType"
class="form-label">Email&nbsp;Address</label>
<input id="view.userprofile.form.edtAccessType"
type="email"
class="form-control">
</div>
<div class="mb-3">
<label id="view.userprofile.form.lblQBID"
for="view.userprofile.form.edtQBID"
class="form-label">Email&nbsp;Address</label>
<input id="view.userprofile.form.edtQBID"
type="email"
class="form-control">
</div>
</form>
</div>
</div>
</div>
unit View.UserProfile;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls,
XData.Web.Client, WEBLib.ExtCtrls, DB, XData.Web.JsonDataset,
XData.Web.Dataset, XData.Web.Connection, Vcl.Forms, ConnectionModule,
WEBLib.Toast, WEBLib.DBCtrls;
type
TFViewUserProfile = class(TWebForm)
WebLabel1: TWebLabel;
WebLabel3: TWebLabel;
WebLabel2: TWebLabel;
WebLabel4: TWebLabel;
WebLabel5: TWebLabel;
XDataWebClient1: TXDataWebClient;
WebDBEdit1: TWebDBEdit;
WebDBEdit2: TWebDBEdit;
WebDBEdit3: TWebDBEdit;
WebDBEdit4: TWebDBEdit;
WebDBEdit5: TWebDBEdit;
WebDBEdit6: TWebDBEdit;
WebLabel6: TWebLabel;
WebLabel7: TWebLabel;
xdwdsUser: TXDataWebDataSet;
wdsUser: TWebDataSource;
xdwdsUseruserID: TStringField;
xdwdsUserusername: TStringField;
xdwdsUseremail_address: TStringField;
xdwdsUserQBID: TStringField;
xdwdsUserAType: TStringField;
xdwdsUserfull_name: TStringField;
procedure WebFormShow(Sender: TObject);
[async] procedure GetUser();
end;
var
FViewUserProfile: TFViewUserProfile;
implementation
uses
Auth.Service,
XData.Model.Classes,
Utils,
View.Main;
{$R *.dfm}
procedure TFViewUserProfile.WebFormShow(Sender: TObject);
begin
GetUser();
end;
procedure TFViewUserProfile.GetUser;
var
xdcResponse: TXDataClientResponse;
userList: TJSObject;
data: TJSArray;
user: TJSObject;
begin
try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetUsers',
[JS.toString(AuthService.TokenPayload.Properties['user_name'])]));
userList := TJSObject(xdcResponse.Result);
data := TJSArray(userList['data']);
user := TJSObject(data[0]);
xdwdsUser.SetJsonData(user);
xdwdsUser.Open;
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
end.
[Paths]
HtmlPath=C:\Projects\kgOrders\kgOrders\kgOrdersClient\TMSWeb\Debug
HtmlFile=index.html
DefaultURL=http://127.0.0.1:8000/webKGOrders
SingleInstance=0
Debug=0
DebugManager=C:\RADTools\TMS\Products\tms.webcore\Bin\Win32\TMSDBGManager.exe
URL=http://127.0.0.1:8000/$(ProjectName)
URLParams=
Browser=1
BrowserBin=
BrowserParams=
Electron=0
ElectronBuild=0
JSDebugger=0
......@@ -21,6 +21,11 @@
text-align: center;
}
#tblPhoneGrid thead th:nth-child(20) {
font-size: 0.9rem !important;
font-weight: bold; /* Optional: keep it bold if shrinking makes it too thin */
}
input[type="text"] {
min-width: 50px;
max-width: 100%;
......@@ -42,11 +47,11 @@ input[type=number] {
.changed-field {
border: 1px solid #ffc107 !important;
border: 1px solid #FFFF00 !important;
}
.changed-field-label {
background-color: #fff3cd;
background-color: #FFFF00;
border-radius: 4px;
padding: 2px 6px;
}
......
......@@ -8,7 +8,6 @@ uses
App.Types in 'App.Types.pas',
ConnectionModule in 'ConnectionModule.pas' {DMConnection: TWebDataModule},
View.Login in 'View.Login.pas' {FViewLogin: TWebForm} {*.html},
View.UserProfile in 'View.UserProfile.pas' {FViewUserProfile: TWebForm} {*.html},
View.ErrorPage in 'View.ErrorPage.pas' {FViewErrorPage: TWebForm} {*.html},
App.Config in 'App.Config.pas',
Paginator.Plugins in 'Paginator.Plugins.pas',
......@@ -65,6 +64,9 @@ end;
procedure UnauthorizedAccessProc(AMessage: string);
begin
if Pos('JWT', AMessage) > 0 then
DisplayLoginView('Login token expired! Please login again')
else
DisplayLoginView(AMessage);
end;
......@@ -89,27 +91,31 @@ begin
end
else
begin
asm
var dlg = document.createElement("dialog");
dlg.classList.add("shadow", "rounded", "border", "p-4");
dlg.style.maxWidth = "500px";
dlg.style.width = "90%";
dlg.style.fontFamily = "system-ui, sans-serif";
dlg.innerHTML =
"<h5 class='fw-bold mb-3 text-danger'>kgOrders web app</h5>" +
"<p class='mb-3' style='white-space: pre-wrap;'>" + ErrorMessage + "</p>" +
"<div class='text-end'>" +
"<button id='refreshBtn' class='btn btn-primary'>Reload</button></div>";
document.body.appendChild(dlg);
dlg.showModal();
document.getElementById("refreshBtn").addEventListener("click", function () {
var base = location.origin + location.pathname;
location.replace(base + "?ver=" + ClientVer + "&r=" + Date.now() + location.hash);
});
end;
// asm
// var dlg = document.createElement("dialog");
// dlg.classList.add("shadow", "rounded", "border", "p-4");
// dlg.style.maxWidth = "500px";
// dlg.style.width = "90%";
// dlg.style.fontFamily = "system-ui, sans-serif";
//
// dlg.innerHTML =
// "<h5 class='fw-bold mb-3 text-danger'>kgOrders web app</h5>" +
// "<p class='mb-3' style='white-space: pre-wrap;'>" + ErrorMessage + "</p>" +
// "<div class='text-end'>" +
// "<button id='refreshBtn' class='btn btn-primary'>Reload</button></div>";
//
// document.body.appendChild(dlg);
// dlg.showModal();
//
// document.getElementById("refreshBtn").addEventListener("click", function () {
// var base = location.origin + location.pathname;
// location.replace(base + "?ver=" + ClientVer + "&r=" + Date.now() + location.hash);
// });
// end;
if Pos('version', ErrorMessage) > 0 then
ShowMessage( ErrorMessage )
else
ShowMessage( 'Error connecting to kgOrdersServer' + sLineBreak + 'Please contact EM Systems support' );
end;
end);
end,
......
......@@ -99,9 +99,9 @@
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_Release>8</VerInfo_Release>
<TMSWebBrowser>1</TMSWebBrowser>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebSingleInstance>1</TMSWebSingleInstance>
<TMSWebBrowser>5</TMSWebBrowser>
<TMSWebOutputPath>..\kgOrdersServer\bin\static</TMSWebOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
......@@ -133,10 +133,6 @@
<Form>FViewLogin</Form>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="View.UserProfile.pas">
<Form>FViewUserProfile</Form>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="View.ErrorPage.pas">
<Form>FViewErrorPage</Form>
<DesignClass>TWebForm</DesignClass>
......
// Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info
// from the data base and send it to the client.
// Author: ???
unit Api.Database;
interface
......@@ -136,7 +133,7 @@ uses
procedure TApiDatabase.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TApiDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
LoadDatabaseSettings( ucKG );
try
ucKG.Connect;
except
......
// Auth Database to verify logins
unit Auth.Database;
interface
......@@ -50,24 +48,21 @@ uses
procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
try
LoadDatabaseSettings( ucKG );
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log( 1, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message );
raise EXDataHttpException.Create(500, 'Error Connecting to database! Please try again later or contact a system admin!');
end;
end;
end;
procedure TAuthDatabase.DataModuleDestroy(Sender: TObject);
begin
ucKG.Connected := false;
Logger.Log( 5, 'TAuthDatabase.DataModuleDestroy' );
end;
end.
......@@ -49,22 +49,33 @@ procedure TAuthService.AfterConstruction;
begin
inherited;
try
Logger.Log(4, 'TAuthService.AfterConstruction');
authDB := TAuthDatabase.Create(nil);
if not authDB.ucKG.Connected then
begin
Logger.Log(1, 'Unable to connect to the database: A KGOrders Server Error has occured!');
raise EXDataHttpException.Create(500, 'Unable to connect to the database: A KGOrders Server Error has occured!');
end;
except
on E: Exception do
begin
Logger.Log(1, 'Error when creating the Auth database: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
Logger.Log(1, 'Error creating the Auth database: ' + E.Message);
raise; //EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
end;
end;
end;
procedure TAuthService.BeforeDestruction;
begin
authDB.Free;
inherited;
end;
function TAuthService.VerifyVersion(clientVersion: string): TJSONObject;
var
iniFile: TIniFile;
......@@ -85,7 +96,7 @@ begin
Result.AddPair('error',
'webApp version mismatch' + sLineBreak + ' Client version: ' + clientVersion +
sLineBreak + ' Server version: ' + webClientVersion +
sLineBreak + 'Please click button to clear cache and reload.');
sLineBreak + 'Please clear cache and reload.');
end;
finally
iniFile.Free;
......@@ -146,6 +157,7 @@ begin
end;
end;
function TAuthService.CheckUser(const user, password: string): Integer;
var
SQL: string;
......@@ -175,6 +187,7 @@ begin
end;
end;
function TAuthService.QBAuthorize(code, realmId, state: string): string;
var
iniFile: TIniFile;
......@@ -187,6 +200,7 @@ begin
Logger.Log(3, 'TAuthService.QBAuthorize - end - result: ' + result);
end;
function TAuthService.ExchangeQBAuthCode(code: string): string;
var
iniFile: TIniFile;
......@@ -280,6 +294,8 @@ begin
end;
end;
initialization
RegisterServiceType(TAuthService);
end.
unit Common.Ini;
interface
uses
System.SysUtils, System.IniFiles, Vcl.Forms;
type
TIniEntries = class
private
// [Settings]
FMemoLogLevel: Integer;
FFileLogLevel: Integer;
FLogFileNum: Integer;
// [Database]
FDBServer: string;
FDBPort: Integer;
FDBDatabase: string;
FDBUsername: string;
FDBPassword: string;
public
constructor Create;
// Properties
property memoLogLevel: Integer read FMemoLogLevel;
property fileLogLevel: Integer read FFileLogLevel;
property logFileNum: Integer read FLogFileNum;
property dbServer: string read FDBServer;
property dbPort: Integer read FDBPort;
property dbDatabase: string read FDBDatabase;
property dbUsername: string read FDBUsername;
property dbPassword: string read FDBPassword;
end;
procedure LoadIniEntries;
var
IniEntries: TIniEntries;
implementation
uses
Common.Logging;
procedure LoadIniEntries;
begin
Logger.Log(1, 'IniEntries global variable instantiated');
end;
{ TIniEntries }
constructor TIniEntries.Create;
var
iniFile: TIniFile;
begin
iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
try
// [Settings]
FMemoLogLevel := iniFile.ReadInteger('Settings', 'MemoLogLevel', 3);
FFileLogLevel := iniFile.ReadInteger('Settings', 'FileLogLevel', 3);
FLogFileNum := iniFile.ReadInteger('Settings', 'LogFileNum', 0);
Inc(FLogFileNum);
iniFile.WriteInteger( 'Settings', 'LogFileNum', FLogFileNum );
// [Database]
FDBServer := iniFile.ReadString('Database', 'Server', '');
FDBPort := iniFile.ReadInteger('Database', 'Port', 0);
FDBDatabase := iniFile.ReadString('Database', 'Database', 'kg_order_entry');
FDBUsername := iniFile.ReadString('Database', 'Username', 'root');
FDBPassword := iniFile.ReadString('Database', 'Password', 'emsys01');
finally
iniFile.Free;
end;
end;
initialization
IniEntries := TIniEntries.Create;
finalization
IniEntries.Free;
end.
......@@ -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;
......@@ -134,11 +134,20 @@ begin
RefreshAccessToken();
Client := iniFile.ReadString('Quickbooks', 'ClientID', '');
logger.Log(5, 'Quickbooks.ClientID: ' + Client);
Secret := iniFile.ReadString('Quickbooks', 'ClientSecret', '');
logger.Log(5, 'Quickbooks.ClientSecret: ' + Secret);
CompanyID := iniFile.ReadString('Quickbooks', 'CompanyID', '');
logger.Log(5, 'Quickbooks.CompanyID: ' + CompanyID);
RefreshToken := iniFile.ReadString('Quickbooks', 'RefreshToken', '');
logger.Log(5, 'Quickbooks.RefreshToken: ' + RefreshToken);
AccessToken := iniFile.ReadString('Quickbooks', 'AccessToken', '');
BaseUrl := iniFile.ReadString('Quickbooks', 'BaseUrl', '');
logger.Log(5, 'Quickbooks.BaseUrl: ' + BaseUrl);
restClient.BaseURL := BaseUrl;
......@@ -153,7 +162,7 @@ begin
param.Value := 'Bearer ' + AccessToken;
restRequest.Execute;
logger.Log(5, 'TLookupService.GetQBInfo - Raw Response: ' + restResponse.Content);
jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue);
CompanyInfoList := TJSONArray(TJSONObject(jsObj.GetValue('QueryResponse')).GetValue('CompanyInfo'));
......@@ -505,7 +514,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);
......@@ -613,11 +623,11 @@ begin
if ID = '' then
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = -1'
else
SQL := 'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + ID;
SQL := 'select * FROM customers c WHERE c.CUSTOMER_ID = ' + ID;
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;
......@@ -638,19 +648,23 @@ begin
result.SHIPPING_ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.SHIPPING_ADDRESS_LIST );
while not ordersDB.UniQuery1.Eof do
SQL := 'SELECT * from customers_ship cs where cs.CUSTOMER_ID = ' + ID;
logger.Log(5, 'Getting customer shipping addresses with SQL: ' + SQL);
doQuery(ordersDB.UniQuery2, SQL);
while not ordersDB.UniQuery2.Eof do
begin
ADDRESS := TAddressItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( ADDRESS );
ADDRESS.ship_block := ordersDB.UniQuery1.FieldByName('ship_block').AsString;
ADDRESS.shipping_address := ordersDB.UniQuery1.FieldByName('address').AsString;
ADDRESS.city := ordersDB.UniQuery1.FieldByName('city').AsString;
ADDRESS.state := ordersDB.UniQuery1.FieldByName('state').AsString;
ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString;
ADDRESS.ship_block := ordersDB.UniQuery2.FieldByName('ship_block').AsString;
ADDRESS.shipping_address := ordersDB.UniQuery2.FieldByName('address').AsString;
ADDRESS.city := ordersDB.UniQuery2.FieldByName('city').AsString;
ADDRESS.state := ordersDB.UniQuery2.FieldByName('state').AsString;
ADDRESS.zip := ordersDB.UniQuery2.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery2.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery2.FieldByName('customer_ship_id').AsString;
ADDRESS.first_line := ordersDB.UniQuery2.FieldByName('first_line').AsString;
result.SHIPPING_ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
ordersDB.UniQuery2.Next;
end;
logger.Log(3, 'TLookupService.GetCustomer - end');
......@@ -740,7 +754,7 @@ begin
end;
end;
function TLookupService.AddShippingAddress(AddressInfo: string): TJSONObject;
function TLookupService.AddShippingAddress(AddressInfo: string): TCustomerResponse;
var
JSONData: TJSONObject;
SQL: string;
......@@ -754,7 +768,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 +784,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 +818,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('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;
// 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;
......@@ -1076,6 +1073,9 @@ begin
if startDate <> '' then
begin
if startDate = '1899/12/30' then
result := result + ' AND ' + quotedStr(startDate) + ' < STATUS_DATE'
else
result := result + ' AND ' + quotedStr(startDate) + ' <= STATUS_DATE';
end;
......@@ -1175,7 +1175,7 @@ begin
begin
if status.startDate <> '' then
begin
result := result + ' AND ' + quotedStr(status.startDate) + ' <= COALESCE(cpo.staff_fields_order_date, wpo.staff_fields_order_date, cdo.staff_fields_order_date)';
result := result + ' AND ' + quotedStr(status.startDate) + ' <= COALESCE(cpo.staff_fields_order_date, wpo.staff_fields_order_date, cdo.staff_fields_order_date';
end;
if ( ( status.endDate <> '1899/12/30' ) AND ( status.endDate <> '' ) ) then
......@@ -1376,20 +1376,40 @@ begin
Order.companyName := FieldByName('COMPANY_NAME').AsString;
Order.jobName := FieldByName('JOB_NAME').AsString;
Order.orderDate := FieldByName('ORDER_DATE').AsString;
Order.proofDue := FieldByName('PROOF_DUE').AsString;
Order.proofDone := FieldByName('PROOF_DONE').AsString;
Order.artDue := FieldByName('ART_DUE').AsString;
Order.artDone := FieldByName('ART_DONE').AsString;
Order.plateDue := FieldByName('PLATE_DUE').AsString;
Order.plateDone := FieldByName('PLATE_DONE').AsString;
Order.mountDue := FieldByName('MOUNT_DUE').AsString;
Order.mountDone := FieldByName('MOUNT_DONE').AsString;
Order.shipDue := FieldByName('SHIP_DUE').AsString;
Order.shipDone := FieldByName('SHIP_DONE').AsString;
Order.price := FieldByName('PRICE').AsString;
Order.qbRefNum := FieldByName('QB_ORDER_NUM').AsString;
Order.orderType := FieldByName('ORDER_TYPE').AsString.Replace('_', ' ');
Order.cadFile := FieldByName('layout_cad_file').AsString;
if FieldByName('PROOF_DUE').AsDateTime = 0 then
Order.proofDue := ''
else
Order.proofDue := FieldByName('PROOF_DUE').AsString;
if FieldByName('ART_DUE').AsDateTime = 0 then
Order.artDue := ''
else
Order.artDue := FieldByName('ART_DUE').AsString;
if FieldByName('PLATE_DUE').AsDateTime = 0 then
Order.plateDue := ''
else
Order.plateDue := FieldByName('PLATE_DUE').AsString;
if FieldByName('MOUNT_DUE').AsDateTime = 0 then
Order.mountDue := ''
else
Order.mountDue := FieldByName('MOUNT_DUE').AsString;
if FieldByName('SHIP_DUE').AsDateTime = 0 then
Order.shipDue := ''
else
Order.shipDue := FieldByName('SHIP_DUE').AsString;
end;
if ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString = 'web_plate' then
......@@ -1879,6 +1899,7 @@ var
hashString: string;
hashPW: string;
unique: boolean;
rightsInt: integer;
begin
logger.log(3, 'TLookupService.EditUser');
params := TStringList.Create;
......@@ -1901,7 +1922,7 @@ begin
logger.Log(5, 'Retrieving customer with SQL: ' + SQL);
doQuery(OrdersDB.UniQuery1, SQL);
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) ) then
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) or ( QB = '' ) ) then
unique := true
else
unique := false;
......@@ -1936,8 +1957,9 @@ begin
if not access.IsEmpty then
ordersDB.UniQuery1.FieldByName('ACCESS_TYPE').AsString := Access;
if not rights.IsEmpty then
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := StrToInt(rights);
if not TryStrToInt(rights, rightsInt) then
rightsInt := 0;
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := rightsInt;
if not perspective.IsEmpty then
ordersDB.UniQuery1.FieldByName('PERSPECTIVE_ID').AsString := perspective;
......@@ -2074,15 +2096,10 @@ begin
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := ORDER_ID;
ordersDB.UniQuery1.Post;
if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_art_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_art_due') <> '12/30/1899' ) then
AddStatusSchedule('ART', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_plate_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_plate_due') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID);
AddStatusSchedule('PLATE', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_mount_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_mount_due') <> '12/30/1899' ) then
AddStatusSchedule('MOUNT', JSONData, ORDER_ID);
AddToRevisionsTable(intToStr(ORDER_ID), 'corrugated_plate_orders_revisions', JSONData);
......@@ -2129,6 +2146,10 @@ begin
else
date := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due');
if date = '' then
date := '12/30/1899';
if ordersDB.uqOrdersStatusSchedule.IsEmpty then
begin
ordersDB.uqOrdersStatusSchedule.Insert;
......@@ -2139,6 +2160,7 @@ begin
else
begin
ordersDB.uqOrdersStatusSchedule.Edit;
change := ordersDB.uqOrdersStatusScheduleSTATUS_DATE.AsDateTime <> StrToDateTime(date);
if change then
begin
......@@ -2146,6 +2168,7 @@ begin
ordersDB.uqOrdersStatusScheduleUSER_ID.AsString := order.GetValue<string>('USER_ID');
end;
end;
ordersDB.uqOrdersStatusScheduleSTATUS_DATE.AsDateTime := StrToDateTime(date);
ordersDB.uqOrdersStatusScheduleORDER_ID.AsInteger := ORDER_ID;
ordersDB.uqOrdersStatusScheduleORDER_STATUS.AsString := StatusType;
......@@ -2308,11 +2331,13 @@ begin
logger.Log(5, 'Retrieving customer with SQL: ' + SQL);
doQuery(OrdersDB.UniQuery1, SQL);
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) ) then
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) or ( QB = '' ) ) then
unique := true
else
unique := false;
if unique then
begin
SQL := 'SELECT * FROM users WHERE USER_NAME = ' + QuotedStr(user.ToLower);
......@@ -2540,13 +2565,9 @@ begin
ordersDB.UniQuery1.Post;
if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_art_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_art_due') <> '12/30/1899' ) then
AddStatusSchedule('ART', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_plate_due') <> '' ) and ( JSONData.GetValue<string>('staff_fields_plate_due') <> '12/30/1899' ) then
AddStatusSchedule('PLATE', JSONData, ORDER_ID);
AddToRevisionsTable(IntToStr(ORDER_ID), 'web_plate_orders_revisions', JSONData);
......@@ -2639,9 +2660,7 @@ begin
// Post the record to the database
ordersDB.UniQuery1.Post;
if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
AddStatusSchedule('PROOF', JSONData, ORDER_ID);
if ( JSONData.GetValue<string>('staff_fields_ship_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_ship_date') <> '12/30/1899' ) then
AddStatusSchedule('SHIP', JSONData, ORDER_ID);
AddToRevisionsTable(IntToStr(ORDER_ID), 'cutting_die_orders_revisions', JSONData);
......@@ -2899,10 +2918,20 @@ begin
RefreshAccessToken();
Client := iniFile.ReadString('Quickbooks', 'ClientID', '');
logger.Log(5, 'Quickbooks.ClientID: ' + Client);
Secret := iniFile.ReadString('Quickbooks', 'ClientSecret', '');
logger.Log(5, 'Quickbooks.ClientSecret: ' + Secret);
CompanyID := iniFile.ReadString('Quickbooks', 'CompanyID', '');
logger.Log(5, 'Quickbooks.CompanyID: ' + CompanyID);
RefreshToken := iniFile.ReadString('Quickbooks', 'RefreshToken', '');
logger.Log(5, 'Quickbooks.RefreshToken: ' + RefreshToken);
AccessToken := iniFile.ReadString('Quickbooks', 'AccessToken', '');
BaseUrl := iniFile.ReadString('Quickbooks', 'BaseUrl', '');
logger.Log(5, 'Quickbooks.BaseUrl: ' + BaseUrl);
restClient.BaseURL := BaseUrl;
restRequest.Method := rmGET;
......@@ -3020,7 +3049,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;
......@@ -3052,10 +3081,20 @@ begin
RefreshAccessToken();
Client := iniFile.ReadString('Quickbooks', 'ClientID', '');
logger.Log(5, 'Quickbooks.ClientID: ' + Client);
Secret := iniFile.ReadString('Quickbooks', 'ClientSecret', '');
logger.Log(5, 'Quickbooks.ClientSecret: ' + Secret);
CompanyID := iniFile.ReadString('Quickbooks', 'CompanyID', '');
logger.Log(5, 'Quickbooks.CompanyID: ' + CompanyID);
RefreshToken := iniFile.ReadString('Quickbooks', 'RefreshToken', '');
logger.Log(5, 'Quickbooks.RefreshToken: ' + RefreshToken);
AccessToken := iniFile.ReadString('Quickbooks', 'AccessToken', '');
BaseUrl := iniFile.ReadString('Quickbooks', 'BaseUrl', '');
logger.Log(5, 'Quickbooks.BaseUrl: ' + BaseUrl);
restClient.BaseURL := BaseUrl;
restRequest.Method := rmGET;
......@@ -3147,7 +3186,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;
......@@ -3343,10 +3396,20 @@ begin
RefreshAccessToken();
Client := iniFile.ReadString('Quickbooks', 'ClientID', '');
logger.Log(5, 'Quickbooks.ClientID: ' + Client);
Secret := iniFile.ReadString('Quickbooks', 'ClientSecret', '');
logger.Log(5, 'Quickbooks.ClientSecret: ' + Secret);
CompanyID := iniFile.ReadString('Quickbooks', 'CompanyID', '');
logger.Log(5, 'Quickbooks.CompanyID: ' + CompanyID);
RefreshToken := iniFile.ReadString('Quickbooks', 'RefreshToken', '');
logger.Log(5, 'Quickbooks.RefreshToken: ' + RefreshToken);
AccessToken := iniFile.ReadString('Quickbooks', 'AccessToken', '');
BaseUrl := iniFile.ReadString('Quickbooks', 'BaseUrl', '');
logger.Log(5, 'Quickbooks.BaseUrl: ' + BaseUrl);
restClient.BaseURL := BaseUrl;
......@@ -3380,7 +3443,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);
......@@ -3645,7 +3711,9 @@ begin
CustomerTypeRef := Customer.GetValue('CustomerTypeRef') as TJSONObject;
logger.Log(5, CustomerTypeRef.ToJSON);
custItem.QB_TYPE := GetCustomerType(CustomerTypeRef.GetValue<string>('value'));
end;
end
else
custItem.QB_TYPE := '';
Result := custItem;
except
......@@ -3775,7 +3843,8 @@ var
CustomerID: Integer;
mode: string;
msg: string;
QB_LIST_ID, BaseUrl: string;
QB_LIST_ID, BaseUrl, SHORT_NAME: string;
unique: boolean;
begin
logger.Log(3, 'TLookupService.ImportQBCustomer');
DateFormat := TFormatSettings.Create;
......@@ -3786,9 +3855,20 @@ begin
if JSONData = nil then
raise Exception.Create('Invalid JSON format');
QB_LIST_ID := JSONData.GetValue<string>('QB_LIST_ID');
SHORT_NAME := JSONData.GetValue<string>('SHORT_NAME');
SQL := 'select CUSTOMER_ID from customers where SHORT_NAME = ' + quotedStr(SHORT_NAME);
logger.Log(5, 'Retrieving customer with SQL: ' + SQL);
doQuery(OrdersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.IsEmpty then
unique := true
else
unique := false;
if unique then
begin
// Update RevisionID
QB_LIST_ID := JSONData.GetValue<string>('QB_LIST_ID');
SQL := 'UPDATE idfield SET KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + QuotedStr('GEN_CUSTOMER_ID');
OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL;
......@@ -3878,9 +3958,14 @@ begin
on E: Exception do
begin
logger.Log(1, 'Error in Import QBCustomer: ' + E.Message);
Result := TJSONObject.Create;
Result.AddPair('error', 'Error importing QB Customer! A QuickBooks interface error has occured!');
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Items: A QuickBooks interface error has occurred!');
end;
end;
end
else
begin
Result := TJSONObject.Create;
Result.AddPair('status', 'Failure:Customer ID must be unique');
end;
end;
......
......@@ -42,6 +42,7 @@ implementation
uses
Common.Logging,
Common.Ini,
Common.Config,
Sparkle.Utils,
Api.Database,
......@@ -110,50 +111,19 @@ end;
procedure TFMain.StartServers;
// Reads from the ini file to figure out what IP the database is located at and
// whether or not Twilio automatic updates should be enabled
var
iniFile: TIniFile;
iniStr: string;
bContinue: boolean;
debugMode: boolean;
devMode: boolean;
begin
// The version is centered when the app is running
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '* kgOrdersServer *' );
Logger.Log(1, Format(' Version: %s ', [FMain.ExeInfo1.FileVersion]));
Logger.Log( 1, '* Developed by EM Systems, Inc. *' );
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '' );
bContinue := True;
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
debugMode := iniFile.ReadBool( 'Settings', 'DebugMode', True );
Logger.Log( 1, 'debugMode: ' + BoolToStr(debugMode, True) );
Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrdersServer.dpr, it executes first' );
Logger.Log(1, '--- Settings ---');
iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->MemoLogLevel: Entry not found - default: 3' )
else
Logger.Log( 1, '--Settings->MemoLogLevel: ' + iniStr );
iniStr := iniFile.ReadString( 'Settings', 'FileLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->FileLogLevel: Entry not found - default: 4' )
else
Logger.Log( 1, '--Settings->FileLogLevel: ' + iniStr );
Logger.Log( 1, '' );
iniStr := iniFile.ReadString( 'Settings', 'LogFileNum', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->LogFileNum: Entry not found' )
else
Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
devMode := iniFile.ReadBool( 'Settings', 'devMode', True );
Logger.Log( 1, 'devMode: ' + BoolToStr(devMode, True) );
iniStr := iniFile.ReadString( 'Settings', 'webClientVersion', '' );
if iniStr.IsEmpty then
......@@ -172,25 +142,25 @@ begin
bContinue := False;
end
else
Logger.Log( 1, '----Database->Server: ' + iniStr );
Logger.Log( 1, '----Database->Server: ini entry: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Database: ini entry not found - default: kg_order_entry' )
Logger.Log( 1, '----Database->Database: ini entry not found - default: ' + iniEntries.dbDatabase )
else
Logger.Log( 1, '----Database->Database: ini entry: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Username: Entry not found - default: root' )
Logger.Log( 1, '----Database->Username: Entry not found - default: ' + iniEntries.dbUsername )
else
Logger.Log( 1, '----Database->Username: ' + iniStr );
Logger.Log( 1, '----Database->Username: ini entry: ' + iniStr );
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 1, '----Database->Password: Entry not found - default: xxxxxx' )
Logger.Log( 1, '----Database->Password: Entry not found - default: xxxxxxxx' )
else
Logger.Log( 1, '----Database->Password: xxxxxxxx' );
Logger.Log( 1, '----Database->Password: ini entry: xxxxxxxx' );
Logger.Log(1, '---Quickbooks---');
......@@ -198,7 +168,7 @@ begin
if iniStr.IsEmpty then
Logger.Log( 1, '--Quickbooks->CompanyID: Entry not found' )
else
Logger.Log( 1, '--Quickbooks->CompanyID: Entry found' );
Logger.Log( 1, '--Quickbooks->CompanyID: ini Entry: found' );
iniStr := IniFile.ReadString( 'Quickbooks', 'ClientID', '' );
if iniStr.IsEmpty then
......@@ -251,8 +221,9 @@ begin
else
begin
Logger.Log( 1, 'ini configuration error: Existing program!' );
if debugMode then
MessageDlg( 'ini configuration error: Existing program!', mtConfirmation, [mbOk], 0 );
if devMode then
MessageDlg( 'ini configuration error!', mtConfirmation, [mbOk], 0 )
else
Close();
end;
end;
......
......@@ -50,6 +50,442 @@ object rptOrderCorrugated: TrptOrderCorrugated
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 = 'START_DATE'
FieldType = fftDateTime
end
item
FieldName = 'END_DATE'
FieldType = fftDateTime
end
item
FieldName = 'ORDER_STATUS'
FieldType = fftString
end
item
FieldName = 'SCHED_JSON'
FieldType = fftString
Size = 4096
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_price'
FieldType = fftString
end
item
FieldName = 'staff_fields_invoice_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_invoice_attention'
FieldType = fftString
Size = 256
end
item
FieldName = 'staff_fields_ship_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_ship_attention'
FieldType = fftString
Size = 256
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_art_due'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_plate_due'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_mount_due'
FieldType = fftDateTime
end
item
FieldName = 'plates_job_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'supplied_by_customer_b_w_copy'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_color_copy'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_plates'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_sample_ca'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_dimension'
FieldType = fftString
Size = 64
end
item
FieldName = 'supplied_by_customer_disk_or_cd'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_e_mail'
FieldType = fftString
Size = 256
end
item
FieldName = 'supplied_by_customer_ftp'
FieldType = fftString
Size = 256
end
item
FieldName = 'supplied_by_customer_other'
FieldType = fftString
Size = 96
end
item
FieldName = 'supplied_by_customer_existing_'
FieldType = fftString
Size = 16
end
item
FieldName = 'supplied_by_customer_ref_art_p'
FieldType = fftString
Size = 256
end
item
FieldName = 'supplied_by_customer_ref_art_a'
FieldType = fftString
Size = 256
end
item
FieldName = 'cut_die_cutdier'
FieldType = fftString
end
item
FieldName = 'cut_die_cutdieb'
FieldType = fftString
end
item
FieldName = 'cut_die_cutdief'
FieldType = fftString
end
item
FieldName = 'cut_die_cutdierkr'
FieldType = fftString
end
item
FieldName = 'cut_die_cutdiefkr'
FieldType = fftString
end
item
FieldName = 'cut_die_cad_file'
FieldType = fftString
Size = 128
end
item
FieldName = 'cut_die_attached'
FieldType = fftString
end
item
FieldName = 'cut_die_boxpol250'
FieldType = fftString
end
item
FieldName = 'cut_die_boxpol155'
FieldType = fftString
end
item
FieldName = 'cut_die_boxpol125'
FieldType = fftString
end
item
FieldName = 'cut_die_brub'
FieldType = fftString
end
item
FieldName = 'proofing_fax'
FieldType = fftString
Size = 16
end
item
FieldName = 'proofing_fax_attn'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_e_mail'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_e_mail_attn'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_ship_to'
FieldType = fftString
Size = 1024
end
item
FieldName = 'proofing_full_size_panel'
FieldType = fftString
end
item
FieldName = 'proofing_print_card'
FieldType = fftString
end
item
FieldName = 'proofing_wide_format'
FieldType = fftString
end
item
FieldName = 'proofing_pdf_file'
FieldType = fftString
end
item
FieldName = 'proofing_other'
FieldType = fftString
Size = 64
end
item
FieldName = 'proofing_art_approved_as_is'
FieldType = fftString
end
item
FieldName = 'proofing_approved_date'
FieldType = fftDateTime
end
item
FieldName = 'proofing_changes_required'
FieldType = fftString
end
item
FieldName = 'proofing_changes_date'
FieldType = fftDateTime
end
item
FieldName = 'layout_rsc_l'
FieldType = fftString
end
item
FieldName = 'layout_rcs_w'
FieldType = fftString
end
item
FieldName = 'layout_rcs_d'
FieldType = fftString
end
item
FieldName = 'layout_die_cut_no'
FieldType = fftString
Size = 45
end
item
FieldName = 'layout_accross_no'
FieldType = fftString
end
item
FieldName = 'layout_around_no'
FieldType = fftString
end
item
FieldName = 'layout_cad_file'
FieldType = fftString
Size = 45
end
item
FieldName = 'layout_excalibur_die'
FieldType = fftString
end
item
FieldName = 'mounting_loose'
FieldType = fftString
end
item
FieldName = 'mounting_sticky_bak'
FieldType = fftString
end
item
FieldName = 'mounting_full_mount'
FieldType = fftString
end
item
FieldName = 'mounting_strip_mount'
FieldType = fftString
end
item
FieldName = 'colors_cylinder_size'
FieldType = fftString
Size = 45
end
item
FieldName = 'colors_machine_ident'
FieldType = fftString
Size = 45
end
item
FieldName = 'mounting_standard_setup'
FieldType = fftString
Size = 45
end
item
FieldName = 'mounting_custom_backing'
FieldType = fftString
Size = 96
end
item
FieldName = 'mounting_custom_adhesive'
FieldType = fftString
Size = 45
end
item
FieldName = 'colors_cross_hairs'
FieldType = fftString
end
item
FieldName = 'colors_clemson'
FieldType = fftString
end
item
FieldName = 'plates_thickness'
FieldType = fftString
end
item
FieldName = 'plates_plate_material'
FieldType = fftString
Size = 16
end
item
FieldName = 'general_special_instructions'
FieldType = fftString
Size = 2048
end
item
FieldName = 'colors_colors'
FieldType = fftString
Size = 4096
end
item
FieldName = 'staff_fields_quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quantity'
FieldType = fftString
end
item
FieldName = 'layout_rsc_style'
FieldType = fftString
Size = 32
end
item
FieldName = 'staff_fields_art_location'
FieldType = fftString
Size = 16
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 frxOrderCorrugated: TfrxReport
Version = '2026.1.7'
......
......@@ -138,7 +138,7 @@ uses
procedure TrptOrderCorrugated.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TrptOrderCorrugated.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
LoadDatabaseSettings( ucKG );
try
ucKG.Connect;
except
......@@ -156,15 +156,15 @@ var
colorArray: TJSONArray;
colorsObject, colorObject: TJSONObject;
colorsString: string;
i: Integer;
i, maxColors: Integer;
begin
logger.Log( 5, 'TrptOrderCorrugated.PopulateColorTable' );
maxColors := 13;
colorsString := uqOrderCorrugated.FieldByName('colors_colors').AsString;
colorsObject := TJSONObject.ParseJSONValue(colorsString) as TJSONObject;
colorArray := TJSONArray(colorsObject.GetValue<TJSONArray>('items'));
for i := 0 to colorArray.Count - 1 do
for i := 0 to maxColors - 1 do
begin
row := frxOrderCorrugated.FindObject('ColorRow' + IntToStr(i + 1)) as TfrxCustomTableRow;
colorObject := colorArray.Items[i] as TJSONObject;
......
......@@ -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]
......
......@@ -69,7 +69,7 @@ uses
procedure TrptOrderCutting.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TrptOrderCutting.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
LoadDatabaseSettings( ucKG );
try
ucKG.Connect;
except
......
......@@ -401,11 +401,10 @@ object rptOrderList: TrptOrderList
Left = 941.480349130000000000
Top = 7.559060000000000000
Width = 45.354330710000000000
Height = 30.236220472440900000
Height = 30.236220470000000000
StretchMode = smActualHeight
ContentScaleOptions.Constraints.MaxIterationValue = 0
ContentScaleOptions.Constraints.MinIterationValue = 0
DataField = 'QB_REF_NUM'
DataSet = frxDBOrders
DataSetName = 'frxDBOrders'
Font.Charset = DEFAULT_CHARSET
......@@ -415,7 +414,7 @@ object rptOrderList: TrptOrderList
Font.Style = []
Frame.Typ = []
Memo.UTF8W = (
'[frxDBOrders."QB_REF_NUM"]')
'[frxDBOrders."QB_ORDER_NUM"]')
ParentFont = False
end
object Memo56: TfrxMemoView
......@@ -1217,11 +1216,6 @@ object rptOrderList: TrptOrderList
FieldName = 'PRICE'
Required = True
end
object uqOrdersQB_REF_NUM: TStringField
FieldName = 'QB_REF_NUM'
ReadOnly = True
Size = 24
end
object uqOrdersCOLORS: TStringField
FieldKind = fkCalculated
FieldName = 'COLORS'
......@@ -1271,6 +1265,10 @@ object rptOrderList: TrptOrderList
object uqOrdersORDER_DATE: TDateField
FieldName = 'ORDER_DATE'
end
object uqOrdersQB_ORDER_NUM: TStringField
FieldName = 'QB_ORDER_NUM'
Size = 50
end
end
object frxDBOrders: TfrxDBDataset
UserName = 'frxDBOrders'
......@@ -1280,6 +1278,126 @@ object rptOrderList: TrptOrderList
DataSetOptions = []
Left = 444
Top = 232
FieldDefs = <
item
FieldName = 'ORDER_ID'
end
item
FieldName = 'Loc'
FieldType = fftString
Size = 16
end
item
FieldName = 'COMPANY_NAME'
FieldType = fftString
Size = 90
end
item
FieldName = 'JOB_NAME'
FieldType = fftString
Size = 128
end
item
FieldName = 'ORDER_TYPE'
FieldType = fftString
Size = 45
end
item
FieldName = 'PROOF_DUE'
FieldType = fftDateTime
end
item
FieldName = 'PROOF_DONE'
FieldType = fftDateTime
end
item
FieldName = 'ART_DUE'
FieldType = fftDateTime
end
item
FieldName = 'ART_DONE'
FieldType = fftDateTime
end
item
FieldName = 'PLATE_DUE'
FieldType = fftDateTime
end
item
FieldName = 'PLATE_DONE'
FieldType = fftDateTime
end
item
FieldName = 'MOUNT_DUE'
FieldType = fftDateTime
end
item
FieldName = 'MOUNT_DONE'
FieldType = fftDateTime
end
item
FieldName = 'SHIP_DUE'
FieldType = fftDateTime
end
item
FieldName = 'SHIP_DONE'
FieldType = fftDateTime
end
item
FieldName = 'PRICE'
end
item
FieldName = 'COLORS'
FieldType = fftString
end
item
FieldName = 'po_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'NEW_ORDER_DATE'
FieldType = fftString
Size = 20
end
item
FieldName = 'NEW_PROOF_DONE'
FieldType = fftString
Size = 20
end
item
FieldName = 'NEW_ART_DONE'
FieldType = fftString
Size = 20
end
item
FieldName = 'NEW_PLATE_DONE'
FieldType = fftString
Size = 20
end
item
FieldName = 'NEW_MOUNT_DONE'
FieldType = fftString
Size = 20
end
item
FieldName = 'NEW_SHIP_DONE'
FieldType = fftString
Size = 20
end
item
FieldName = 'ORDER_DATE'
FieldType = fftDateTime
end
item
FieldName = 'QB_ORDER_NUM'
FieldType = fftString
Size = 50
end>
end
object uqColors: TUniQuery
Connection = ucKG
......
......@@ -30,7 +30,6 @@ type
uqOrdersSHIP_DUE: TDateField;
uqOrdersSHIP_DONE: TDateTimeField;
uqOrdersPRICE: TFloatField;
uqOrdersQB_REF_NUM: TStringField;
uqOrdersCOLORS: TStringField;
uqColors: TUniQuery;
uqOrderspo_number: TStringField;
......@@ -42,6 +41,7 @@ type
uqOrdersNEW_MOUNT_DONE: TStringField;
uqOrdersNEW_SHIP_DONE: TStringField;
uqOrdersORDER_DATE: TDateField;
uqOrdersQB_ORDER_NUM: TStringField;
procedure DataModuleCreate(Sender: TObject);
procedure uqOrdersCalcFields(DataSet: TDataSet);
......@@ -68,7 +68,7 @@ uses
procedure TrptOrderList.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TrptOrderList.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
LoadDatabaseSettings( ucKG );
try
ucKG.Connect;
except
......
......@@ -4,14 +4,9 @@ object rptOrderWeb: TrptOrderWeb
Width = 640
object ucKG: TUniConnection
ProviderName = 'MySQL'
Database = 'kg_order_entry'
Username = 'root'
Server = '192.168.159.10'
Connected = True
LoginPrompt = False
Left = 289
Top = 119
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
object frxPDFExport1: TfrxPDFExport
UseFileCache = True
......@@ -49,6 +44,442 @@ object rptOrderWeb: TrptOrderWeb
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 = 'START_DATE'
FieldType = fftDateTime
end
item
FieldName = 'END_DATE'
FieldType = fftDateTime
end
item
FieldName = 'ORDER_STATUS'
FieldType = fftString
end
item
FieldName = 'SCHED_JSON'
FieldType = fftString
Size = 4096
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_price'
FieldType = fftString
end
item
FieldName = 'staff_fields_invoice_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_invoice_attention'
FieldType = fftString
Size = 256
end
item
FieldName = 'staff_fields_ship_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_ship_attention'
FieldType = fftString
Size = 256
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_art_due'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_plate_due'
FieldType = fftDateTime
end
item
FieldName = 'plates_job_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'supplied_by_customer_b_w_or_co'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_plates'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_sample'
FieldType = fftString
Size = 45
end
item
FieldName = 'supplied_by_customer_dimension'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_other'
FieldType = fftString
Size = 45
end
item
FieldName = 'supplied_by_customer_disk'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_e_mail'
FieldType = fftString
Size = 128
end
item
FieldName = 'supplied_by_customer_ftp'
FieldType = fftString
Size = 128
end
item
FieldName = 'plates_plate_material'
FieldType = fftString
Size = 16
end
item
FieldName = 'plates_thickness'
FieldType = fftString
end
item
FieldName = 'supplied_by_customer_total_inc'
FieldType = fftString
Size = 32
end
item
FieldName = 'supplied_by_customer_sheets_us'
FieldType = fftString
Size = 32
end
item
FieldName = 'supplied_by_customer_initials'
FieldType = fftString
Size = 16
end
item
FieldName = 'proofing_pdf'
FieldType = fftString
end
item
FieldName = 'proofing_pdf_to'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_pdf_date_1'
FieldType = fftDateTime
end
item
FieldName = 'proofing_pdf_date_2'
FieldType = fftDateTime
end
item
FieldName = 'proofing_pdf_date_3'
FieldType = fftDateTime
end
item
FieldName = 'proofing_full_size_ink_jet_for'
FieldType = fftString
end
item
FieldName = 'proofing_ink_jet_to'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_ink_jet_to_2'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_ink_jet_date_1'
FieldType = fftDateTime
end
item
FieldName = 'proofing_ink_jet_date_2'
FieldType = fftDateTime
end
item
FieldName = 'proofing_ink_jet_date_3'
FieldType = fftDateTime
end
item
FieldName = 'proofing_color_contract'
FieldType = fftString
Size = 17
end
item
FieldName = 'proofing_color_contrac_to'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_color_contrac_date_1'
FieldType = fftDateTime
end
item
FieldName = 'proofing_color_contrac_date_2'
FieldType = fftDateTime
end
item
FieldName = 'proofing_digital_color_key'
FieldType = fftString
end
item
FieldName = 'proofing_digital_color_to'
FieldType = fftString
Size = 256
end
item
FieldName = 'proofing_digital_color_date_1'
FieldType = fftDateTime
end
item
FieldName = 'quantity_and_colors_press_name'
FieldType = fftString
Size = 64
end
item
FieldName = 'quantity_and_colors_anilox_info'
FieldType = fftString
Size = 64
end
item
FieldName = 'plate_marks_microdots'
FieldType = fftString
end
item
FieldName = 'plate_marks_microdots_comments'
FieldType = fftString
Size = 128
end
item
FieldName = 'plate_marks_crosshairs'
FieldType = fftString
end
item
FieldName = 'plate_marks_crosshairs_comments'
FieldType = fftString
Size = 128
end
item
FieldName = 'plate_marks_color_bars'
FieldType = fftString
end
item
FieldName = 'plate_marks_color_bars_comments'
FieldType = fftString
Size = 128
end
item
FieldName = 'plate_marks_other'
FieldType = fftString
Size = 16
end
item
FieldName = 'plate_marks_other_comments'
FieldType = fftString
Size = 128
end
item
FieldName = 'print_orientation_print_orient'
FieldType = fftString
end
item
FieldName = 'layout_around'
FieldType = fftString
end
item
FieldName = 'layout_accross'
FieldType = fftString
end
item
FieldName = 'layout_surface_print'
FieldType = fftString
end
item
FieldName = 'layout_reverse_print'
FieldType = fftString
end
item
FieldName = 'layout_cylinder_repeat'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_cutoff_dimension'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_pitch'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_teeth'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_bleed'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_cutback'
FieldType = fftString
Size = 16
end
item
FieldName = 'layout_minimum_trap_dim'
FieldType = fftString
end
item
FieldName = 'layout_maximum_trap_dim'
FieldType = fftString
end
item
FieldName = 'upc_size'
FieldType = fftString
Size = 16
end
item
FieldName = 'upc_bar_width_reduction'
FieldType = fftString
Size = 16
end
item
FieldName = 'quantity_and_colors_qty_colors'
FieldType = fftString
Size = 4096
end
item
FieldName = 'general_comments'
FieldType = fftString
Size = 4096
end
item
FieldName = 'staff_fields_quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quantity'
FieldType = fftString
end
item
FieldName = 'upc_distortion_percent'
FieldType = fftString
Size = 16
end
item
FieldName = 'upc_distortion_amount'
FieldType = fftString
Size = 16
end
item
FieldName = 'staff_fields_art_location'
FieldType = fftString
Size = 16
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 frxOrderWeb: TfrxReport
Version = '2026.1.7'
......@@ -1135,7 +1566,7 @@ object rptOrderWeb: TrptOrderWeb
DataSetName = 'frxDBOrderWeb'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlack
Font.Height = -12
Font.Height = -9
Font.Name = 'Arial'
Font.Style = []
Frame.Typ = [ftLeft, ftRight, ftTop, ftBottom]
......@@ -4645,7 +5076,6 @@ object rptOrderWeb: TrptOrderWeb
'SELECT * FROM web_plate_orders w JOIN orders o ON w.ORDER_ID = o' +
'.ORDER_ID WHERE w.ORDER_ID = 1568')
Active = True
Left = 457
Top = 106
object uqOrderWebORDER_ID: TIntegerField
......
......@@ -137,7 +137,7 @@ uses
procedure TrptOrderWeb.DataModuleCreate(Sender: TObject);
begin
Logger.Log( 5, 'TrptOrderWeb.DataModuleCreate' );
LoadDatabaseSettings( ucKG, 'kgOrdersServer.ini' );
LoadDatabaseSettings( ucKG );
try
ucKG.Connect;
except
......@@ -155,15 +155,16 @@ var
colorArray: TJSONArray;
colorsObject, colorObject: TJSONObject;
colorsString: string;
i: Integer;
i, maxColors: Integer;
begin
maxColors := 10;
logger.Log( 5, 'TrptOrderWeb.PopulateColorTable' );
colorsString := uqOrderWeb.FieldByName('quantity_and_colors_qty_colors').AsString;
colorsObject := TJSONObject.ParseJSONValue(colorsString) as TJSONObject;
colorArray := TJSONArray(colorsObject.GetValue<TJSONArray>('items'));
for i := 0 to colorArray.Count - 1 do
for i := 0 to maxColors - 1 do
begin
row := frxOrderWeb.FindObject('ColorRow' + IntToStr(i + 1)) as TfrxCustomTableRow;
colorObject := colorArray.Items[i] as TJSONObject;
......
......@@ -3,32 +3,25 @@ unit uLibrary;
interface
uses
System.Classes, Uni;
Common.Ini,
System.Classes,
Uni;
procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
procedure DoQuery( uq: TUniQuery; sql: string );
procedure LoadDatabaseSettings(uc: TUniConnection);
procedure DoQuery(uq: TUniQuery; sql: string);
implementation
uses
System.SysUtils,
System.IniFiles,
Vcl.Forms,
Data.DB;
procedure LoadDatabaseSettings( uc: TUniConnection; iniFilename: string );
var
iniFile: TIniFile;
procedure LoadDatabaseSettings(uc: TUniConnection);
begin
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + iniFilename );
try
uc.Server := iniFile.ReadString('Database', 'Server', '');
uc.Database := iniFile.ReadString('Database', 'Database', 'kg_order_entry');
uc.Username := iniFile.ReadString('Database', 'Username', 'root');
uc.Password := iniFile.ReadString('Database', 'Password', 'emsys01');
finally
iniFile.Free;
end;
uc.Server := iniEntries.dbServer;
uc.Database := iniEntries.dbDatabase;
uc.Username := iniEntries.dbUsername;
uc.Password := iniEntries.dbPassword;
end;
procedure DoQuery(uq: TUniQuery; sql: string);
......
......@@ -26,10 +26,11 @@ uses
rOrderCorrugated in 'Source\rOrderCorrugated.pas' {rptOrderCorrugated: TDataModule},
rOrderWeb in 'Source\rOrderWeb.pas' {rptOrderWeb: TDataModule},
rOrderCutting in 'Source\rOrderCutting.pas' {rptOrderCutting: TDataModule},
qbAPI in 'Source\qbAPI.pas' {fQB};
qbAPI in 'Source\qbAPI.pas' {fQB},
Common.Ini in 'Source\Common.Ini.pas';
type
TMemoLogAppender = class( TInterfacedObject, ILogAppender )
TMemoLogAppender = class(TInterfacedObject, ILogAppender)
private
FLogLevel: Integer;
FLogMemo: TMemo;
......@@ -40,18 +41,19 @@ type
procedure Send(logLevel: Integer; Log: ILog);
end;
TFileLogAppender = class( TInterfacedObject, ILogAppender )
TFileLogAppender = class(TInterfacedObject, ILogAppender)
private
FLogLevel: Integer;
FLogFile: string;
FCriticalSection: TCriticalSection;
public
constructor Create(ALogLevel: Integer; AFilename: string);
constructor Create(ALogLevel: Integer; AFilename: string; AFileNum: Integer);
destructor Destroy; override;
procedure Send(logLevel: Integer; Log: ILog);
end;
{ TMemoLogAppender }
constructor TMemoLogAppender.Create(ALogLevel: Integer; ALogMemo: TMemo);
begin
FLogLevel := ALogLevel;
......@@ -67,34 +69,33 @@ end;
procedure TMemoLogAppender.Send(logLevel: Integer; Log: ILog);
var
FormattedMessage: string;
LogTime: TDateTime;
LogMsg: string;
logMsg: string;
logTime: TDateTime;
formattedMessage: string;
begin
FCriticalSection.Acquire;
try
LogTime := Now;
logTime := Now;
FormattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', LogTime);
LogMsg := Log.GetMessage;
if LogMsg.IsEmpty then
FormattedMessage := ''
formattedMessage := FormatDateTime('[yyyy-mm-dd HH:nn:ss.zzz]', logTime);
logMsg := Log.GetMessage;
if logMsg.IsEmpty then
formattedMessage := ''
else
FormattedMessage := FormattedMessage + '[' + IntToStr(logLevel) +'] ' + LogMsg;
formattedMessage := formattedMessage + '[' + IntToStr(logLevel) + '] ' + logMsg;
if logLevel <= FLogLevel then
FLogMemo.Lines.Add( FormattedMessage );
FLogMemo.Lines.Add(formattedMessage);
finally
FCriticalSection.Release;
end;
end;
{ TFileLogAppender }
constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string);
constructor TFileLogAppender.Create(ALogLevel: integer; AFilename: string; AFileNum: integer);
var
iniFile: TIniFile;
fileNum: integer;
logsDir: string;
begin
FLogLevel := ALogLevel;
......@@ -103,14 +104,7 @@ begin
if not DirectoryExists(logsDir) then
CreateDir(logsDir);
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
FLogFile := logsDir + AFilename + Format( '%.4d', [fileNum] ) + '.log';
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally
iniFile.Free;
end;
FLogFile := logsDir + AFilename + Format( '%.4d', [AFileNum] ) + '.log';
end;
destructor TFileLogAppender.Destroy;
......@@ -119,14 +113,16 @@ begin
inherited;
end;
procedure TFileLogAppender.Send(logLevel: integer; Log: ILog);
procedure TFileLogAppender.Send(logLevel: Integer; Log: ILog);
var
formattedMessage: string;
logTime: TDateTime;
logFile: TextFile;
logMsg: string;
txtFile: TextFile;
logTime: TDateTime;
formattedMessage: string;
begin
if logLevel > FLogLevel then
Exit;
FCriticalSection.Acquire;
try
logTime := Now;
......@@ -136,18 +132,18 @@ begin
if logMsg.IsEmpty then
formattedMessage := ''
else
formattedMessage := formattedMessage + '[' + IntToStr(logLevel) +'] ' + logMsg;
formattedMessage := formattedMessage + '[' + IntToStr(logLevel) + '] ' + logMsg;
try
AssignFile( txtFile, FLogFile );
AssignFile( logFile, FLogFile );
if FileExists(FLogFile) then
Append( txtFile )
Append(logFile)
else
ReWrite( txtFile );
if logLevel <= FLogLevel then
WriteLn( txtFile, formattedMessage );
Rewrite(logFile);
try
Writeln(logFile, formattedMessage);
finally
CloseFile(txtFile);
CloseFile(logFile);
end;
finally
FCriticalSection.Release;
......@@ -157,23 +153,55 @@ end;
{$R *.res}
var
iniFilename: string;
iniFile: TIniFile;
MemoLogLevel: Integer;
FileLogLevel: Integer;
iniStr: string;
begin
ReportMemoryLeaksOnShutdown := True;
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFMain, FMain);
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
iniFilename := ChangeFileExt( Application.ExeName, '.ini' );
iniFile := TIniFile.Create( iniFilename );
try
MemoLogLevel := iniFile.ReadInteger( 'Settings', 'MemoLogLevel', 3 );
FileLogLevel := iniFile.ReadInteger( 'Settings', 'FileLogLevel', 4 );
Logger.AddAppender( TMemoLogAppender.Create(iniEntries.memoLogLevel, FMain.memoinfo) );
Logger.AddAppender( TFileLogAppender.Create(iniEntries.fileLogLevel, 'emT3XDataServer', iniEntries.logFileNum) );
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '* kgOrdersServer *' );
Logger.Log( 1, Format(' Version: %s ', [FMain.ExeInfo1.FileVersion]));
Logger.Log( 1, '* Developed by EM Systems, Inc. *' );
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '' );
//iniEntries is automatically instantiated when the file Common.Ini is used
//we added LoadIniEntries call to put an entry in the Log file
LoadIniEntries;
Logger.Log( 1, 'iniFile: ' + iniFilename );
iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->MemoLogLevel: ini entry not found - default: ' + IntToStr(iniEntries.memoLogLevel) )
else
Logger.Log( 1, '--Settings->MemoLogLevel: ini entry: ' + iniStr );
iniStr := iniFile.ReadString( 'Settings', 'FileLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->FileLogLevel: ini entry not found - default: ' + IntToStr(iniEntries.fileLogLevel) )
else
Logger.Log( 1, '--Settings->FileLogLevel: ini entry: ' + iniStr );
Logger.Log( 1, '' );
iniStr := iniFile.ReadString( 'Settings', 'LogFileNum', '' );
if iniStr = '1' then
Logger.Log( 1, '--Settings->LogFileNum: ini entry not found - LogFileNum 1 added to iniFile' )
else
Logger.Log( 1, '--Settings->LogFileNum: ini entry: ' + iniStr );
finally
iniFile.Free;
end;
Logger.AddAppender(TMemoLogAppender.Create( MemoLogLevel, FMain.memoinfo ));
Logger.AddAppender(TFileLogAppender.Create( FileLogLevel, 'kgOrdersServer' ));
Application.Run;
end.
......@@ -114,11 +114,11 @@
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_ExeOutput>.\bin</DCC_ExeOutput>
<DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.9.15.1;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.9.15.4;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_Release>15</VerInfo_Release>
<VerInfo_Build>1</VerInfo_Build>
<VerInfo_Build>4</VerInfo_Build>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
......@@ -209,6 +209,7 @@
<Form>fQB</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="Source\Common.Ini.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
......
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