Commit f5f1995d by Mac Stephens

Merge branch 'cam3'

parents e42020d5 ee8abbae
...@@ -4,8 +4,8 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -4,8 +4,8 @@ object FViewAddCustomer: TFViewAddCustomer
CSSLibrary = cssBootstrap CSSLibrary = cssBootstrap
ElementFont = efCSS ElementFont = efCSS
object lblFormState: TWebLabel object lblFormState: TWebLabel
Left = 18 Left = 19
Top = 16 Top = 578
Width = 3 Width = 3
Height = 15 Height = 15
ElementID = 'lbl_form_state' ElementID = 'lbl_form_state'
...@@ -39,7 +39,7 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -39,7 +39,7 @@ object FViewAddCustomer: TFViewAddCustomer
Text = '' Text = ''
end end
object edtShortName: TWebDBEdit object edtShortName: TWebDBEdit
Left = 19 Left = 24
Top = 12 Top = 12
Width = 121 Width = 121
Height = 22 Height = 22
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<input id="edtcompanyid" class="form-control input-sm"style="width: 100px" required/> <input id="edtcompanyid" class="form-control input-sm"style="width: 100px" required/>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Quickbooks ID:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">QB ID:</label>
<input id="edtqbid" class="form-control input-sm"style="width: 200px" required/> <input id="edtqbid" class="form-control input-sm"style="width: 200px" required/>
</div> </div>
<div class="col-auto"> <div class="col-auto">
......
...@@ -79,7 +79,7 @@ type ...@@ -79,7 +79,7 @@ type
XDataWebDataSet1REP_USER_ID: TStringField; XDataWebDataSet1REP_USER_ID: TStringField;
xdwdsUsersfull_name: TStringField; xdwdsUsersfull_name: TStringField;
lblFormState: TWebLabel; lblFormState: TWebLabel;
procedure btnSaveClick(Sender: TObject); [async] procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject); procedure btnEditClick(Sender: TObject);
...@@ -424,8 +424,8 @@ procedure TFViewAddCustomer.btnSaveClick(Sender: TObject); ...@@ -424,8 +424,8 @@ procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
begin begin
if VerifyCustomer() then if VerifyCustomer() then
begin begin
sendCustomerToServer(); await(sendCustomerToServer());
GetCustomer(); await(GetCustomer());
ViewMode(); ViewMode();
end; end;
end; end;
...@@ -505,16 +505,14 @@ procedure TFViewAddCustomer.GetCustomer; ...@@ -505,16 +505,14 @@ procedure TFViewAddCustomer.GetCustomer;
// Retrieves a customer for a given CustomerID. // Retrieves a customer for a given CustomerID.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
customer : TJSObject; customer, RepUsers : TJSObject;
items: TJSObject; items: TJSObject;
ship_block: TStringList; ship_block: TStringList;
begin begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer', [customerID])); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer', [customerID]));
customer := TJSObject(xdcResponse.Result); customer := TJSObject(xdcResponse.Result);
xdwdsUsers.Close;
xdwdsUsers.SetJSONData(customer['USERS']);
xdwdsUsers.Open;
XDataWebDataSet1.Close; XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer); XDataWebDataSet1.SetJsonData(customer);
...@@ -530,7 +528,7 @@ begin ...@@ -530,7 +528,7 @@ begin
dtpEndDate.Date := XDataWebDataSet1.FieldByName('End_DATE').AsDateTime; dtpEndDate.Date := XDataWebDataSet1.FieldByName('End_DATE').AsDateTime;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']); memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
...@@ -545,6 +543,14 @@ begin ...@@ -545,6 +543,14 @@ begin
edtFirstLine.Text := memoShipBlock.Lines[0] edtFirstLine.Text := memoShipBlock.Lines[0]
else else
edtFirstLine.Text := ''; edtFirstLine.Text := '';
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetRepUsers', []));
RepUsers := TJSObject(xdcResponse.Result);
console.log(RepUsers);
xdwdsUsers.Close;
xdwdsUsers.SetJSONData(RepUsers['value']);
xdwdsUsers.Open;
end; end;
procedure TFViewAddCustomer.tmrReturnTimer(Sender: TObject); procedure TFViewAddCustomer.tmrReturnTimer(Sender: TObject);
......
...@@ -135,6 +135,13 @@ end; ...@@ -135,6 +135,13 @@ end;
// if confirmed then DeleteOrder(); // if confirmed then DeleteOrder();
// end); // end);
// function ShowConfirmationModal(msg, leftLabel, rightLabel: string;): Boolean;
// if ShowConfirmationModal then
// doThing()
// else
// doOtherThing();
procedure ShowConfirmationModal(msg, leftLabel, rightLabel: string; ConfirmProc: TProc<Boolean>); procedure ShowConfirmationModal(msg, leftLabel, rightLabel: string; ConfirmProc: TProc<Boolean>);
begin begin
......
...@@ -43,6 +43,8 @@ type ...@@ -43,6 +43,8 @@ type
public public
{ Public declarations } { Public declarations }
notification: string; notification: string;
confirm: Boolean;
QB_ID, name, description, status: string;
end; end;
var var
...@@ -80,7 +82,18 @@ begin ...@@ -80,7 +82,18 @@ begin
else if xdwdsCustomers.FieldByName('qb_items_id').AsString <> '' then else if xdwdsCustomers.FieldByName('qb_items_id').AsString <> '' then
edtNotification.Text := 'Item Already In Database' edtNotification.Text := 'Item Already In Database'
else else
SendItemToServer(); 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';
confirm := true;
Close;
end;
//SendItemToServer();
end; end;
procedure TfViewAddItem.getItems; procedure TfViewAddItem.getItems;
...@@ -90,6 +103,8 @@ var ...@@ -90,6 +103,8 @@ var
i: integer; i: integer;
begin begin
// Fetch data from XData service // Fetch data from XData service
Utils.ShowSpinner('spinner');
try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.getQBItems', [])); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.getQBItems', []));
customerList := TJSObject(xdcResponse.Result); customerList := TJSObject(xdcResponse.Result);
...@@ -102,6 +117,11 @@ begin ...@@ -102,6 +117,11 @@ begin
// Manually populate the grid // Manually populate the grid
PopulateGridManually; PopulateGridManually;
//Utils.HideSpinner('spinner'); //Utils.HideSpinner('spinner');
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
Utils.HideSpinner('spinner');
end; end;
procedure TFViewAddItem.PopulateGridManually; procedure TFViewAddItem.PopulateGridManually;
......
...@@ -42,15 +42,14 @@ object FViewCustomers: TFViewCustomers ...@@ -42,15 +42,14 @@ object FViewCustomers: TFViewCustomers
ElementFont = efCSS ElementFont = efCSS
HeightStyle = ssAuto HeightStyle = ssAuto
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Text = '500' Text = '50'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange OnChange = wcbPageSizeChange
ItemIndex = -1 ItemIndex = -1
Items.Strings = ( Items.Strings = (
'100' '10'
'250' '25'
'500' '50')
'1000')
end end
object pnlMessage: TWebPanel object pnlMessage: TWebPanel
Left = 12 Left = 12
......
...@@ -83,16 +83,7 @@ begin ...@@ -83,16 +83,7 @@ begin
newform.ShowModal( newform.ShowModal(
procedure(AValue: TModalResult) procedure(AValue: TModalResult)
begin begin
{if newform.confirm then
begin
if newform.cbCorrugatedPlate.Checked then
orderType := 'corrugated'
else if newform.cbWebPlate.Checked then
orderType := 'web'
else
orderType := 'cutting';
orderEntry('', newForm.DBID, 'ADD', orderType);
end; }
end end
); );
end; end;
...@@ -108,8 +99,8 @@ begin ...@@ -108,8 +99,8 @@ begin
DMConnection.ApiConnection.Connected := True; DMConnection.ApiConnection.Connected := True;
PageNumber := 1; PageNumber := 1;
TotalPages := 1; // Initial total pages TotalPages := 1; // Initial total pages
wcbPageSize.Text := '500'; wcbPageSize.Text := '50';
PageSize := 500; PageSize := 50;
HideNotification(); HideNotification();
getCustomers(GenerateSearchOptions()); getCustomers(GenerateSearchOptions());
end; end;
...@@ -135,21 +126,23 @@ begin ...@@ -135,21 +126,23 @@ begin
xdwdsCustomers.Open; xdwdsCustomers.Open;
customerListLength := integer(customerList['count']); customerListLength := integer(customerList['count']);
TotalPages := ( (customerListLength + PageSize - 1) div PageSize); TotalPages := (customerListLength + PageSize - 1) div PageSize;
generatePagination(TotalPages);
if customerListLength = 0 then if customerListLength = 0 then
lblEntries.Caption := 'No entries found' begin
lblEntries.Caption := 'No entries found';
ShowToast('No entries found', 'danger');
end
else if (PageNumber * PageSize) < customerListLength then else if (PageNumber * PageSize) < customerListLength then
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) + lblEntries.Caption := Format('Showing entries %d - %d of %d',
' - ' + IntToStr(customerListLength) + [(PageNumber - 1) * PageSize + 1, PageNumber * PageSize, customerListLength])
' of ' + IntToStr(customerListLength)
else else
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) + lblEntries.Caption := Format('Showing entries %d - %d of %d',
' - ' + IntToStr(customerListLength) + [(PageNumber - 1) * PageSize + 1, customerListLength, customerListLength]);
' of ' + IntToStr(customerListLength);
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve customers: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
...@@ -180,7 +173,6 @@ begin ...@@ -180,7 +173,6 @@ begin
getCustomers(GenerateSearchOptions()); getCustomers(GenerateSearchOptions());
end; end;
procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol, procedure TFViewCustomers.wdbtcCustomersDblClickCell(Sender: TObject; ACol,
ARow: Integer); ARow: Integer);
begin begin
......
...@@ -107,7 +107,7 @@ begin ...@@ -107,7 +107,7 @@ begin
Info := string(responseString['value']); Info := string(responseString['value']);
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not add user: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
......
...@@ -9,10 +9,9 @@ object FViewItems: TFViewItems ...@@ -9,10 +9,9 @@ object FViewItems: TFViewItems
Font.Name = 'Tahoma' Font.Name = 'Tahoma'
Font.Style = [] Font.Style = []
ParentFont = False ParentFont = False
OnCreate = WebFormCreate
object lblEntries: TWebLabel object lblEntries: TWebLabel
Left = 0 Left = 16
Top = 336 Top = 292
Width = 77 Width = 77
Height = 13 Height = 13
Caption = 'Showing 0 of ...' Caption = 'Showing 0 of ...'
...@@ -22,6 +21,17 @@ object FViewItems: TFViewItems ...@@ -22,6 +21,17 @@ object FViewItems: TFViewItems
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object lblFormState: TWebLabel
Left = 380
Top = 422
Width = 3
Height = 13
ElementID = 'lbl_form_state'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcbPageSize: TWebComboBox object wcbPageSize: TWebComboBox
Left = 0 Left = 0
Top = 0 Top = 0
...@@ -42,8 +52,8 @@ object FViewItems: TFViewItems ...@@ -42,8 +52,8 @@ object FViewItems: TFViewItems
'50') '50')
end end
object btnAdd: TWebButton object btnAdd: TWebButton
Left = 565 Left = 567
Top = 318 Top = 442
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Add' Caption = 'Add'
...@@ -55,50 +65,9 @@ object FViewItems: TFViewItems ...@@ -55,50 +65,9 @@ object FViewItems: TFViewItems
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnAddClick OnClick = btnAddClick
end end
object edtName: TWebEdit
Left = 342
Top = 0
Width = 121
Height = 22
ChildOrder = 10
ElementClassName = 'form-control'
ElementID = 'edtname'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtDescription: TWebEdit
Left = 478
Top = 0
Width = 121
Height = 22
ChildOrder = 10
ElementClassName = 'form-control'
ElementID = 'edtdescription'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object cbStatus: TWebCheckBox
Left = 354
Top = 52
Width = 113
Height = 22
ChildOrder = 5
ElementClassName = 'custom-control custom-checkbox'
ElementButtonClassName = 'custom-control-input'
ElementLabelClassName = 'custom-control-label'
ElementID = 'cbstatus'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnSave: TWebButton object btnSave: TWebButton
Left = 565 Left = 567
Top = 228 Top = 352
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Save' Caption = 'Save'
...@@ -114,8 +83,8 @@ object FViewItems: TFViewItems ...@@ -114,8 +83,8 @@ object FViewItems: TFViewItems
OnClick = btnSaveClick OnClick = btnSaveClick
end end
object btnCancel: TWebButton object btnCancel: TWebButton
Left = 565 Left = 567
Top = 256 Top = 380
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Cancel' Caption = 'Cancel'
...@@ -131,8 +100,8 @@ object FViewItems: TFViewItems ...@@ -131,8 +100,8 @@ object FViewItems: TFViewItems
OnClick = btnCancelClick OnClick = btnCancelClick
end end
object btnDelete: TWebButton object btnDelete: TWebButton
Left = 565 Left = 567
Top = 197 Top = 321
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Delete' Caption = 'Delete'
...@@ -146,8 +115,8 @@ object FViewItems: TFViewItems ...@@ -146,8 +115,8 @@ object FViewItems: TFViewItems
OnClick = btnDeleteClick OnClick = btnDeleteClick
end end
object btnEdit: TWebButton object btnEdit: TWebButton
Left = 565 Left = 567
Top = 287 Top = 411
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Edit' Caption = 'Edit'
...@@ -160,13 +129,138 @@ object FViewItems: TFViewItems ...@@ -160,13 +129,138 @@ object FViewItems: TFViewItems
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnEditClick OnClick = btnEditClick
end end
object wdbtcItems: TWebDBTableControl
Left = 16
Top = 86
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 = wdbtcItemsClickCell
Columns = <
item
DataField = 'ID'
Title = 'Item ID'
end
item
DataField = 'name'
Title = 'Name'
end
item
DataField = 'description'
Title = 'Description'
end
item
DataField = 'status'
Title = 'Status'
end
item
DataField = 'QB_ID'
Title = 'QB ID'
end>
DataSource = wdsItems
end
object edtName: TWebDBEdit
Left = 352
Top = 0
Width = 121
Height = 22
ChildOrder = 8
ElementID = 'edtname'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'name'
DataSource = wdsItems
end
object edtDescription: TWebDBEdit
Left = 488
Top = 0
Width = 121
Height = 22
ChildOrder = 8
ElementID = 'edtdescription'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'description'
DataSource = wdsItems
end
object CBStatus: TWebDBCheckBox
Left = 352
Top = 34
Width = 113
Height = 22
Caption = 'Active?'
ChildOrder = 11
ElementClassName = 'custom-control custom-checkbox'
ElementButtonClassName = 'custom-control-input'
ElementLabelClassName = 'custom-control-label'
ElementID = 'cbstatus'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'status'
DataSource = wdsItems
ValueChecked = 'ACTIVE'
ValueUnChecked = 'INACTIVE'
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 426 Left = 294
Top = 240 Top = 356
end end
object XDataWebDataSet1: TXDataWebDataSet object xdwdsItems: TXDataWebDataSet
Left = 440 Left = 440
Top = 300 Top = 300
object xdwdsItemsstatus: TStringField
FieldName = 'status'
end
object xdwdsItemsID: TStringField
FieldName = 'ID'
end
object xdwdsItemsname: TStringField
FieldName = 'name'
end
object xdwdsItemsdescription: TStringField
FieldName = 'description'
end
object xdwdsItemsQB_ID: TStringField
FieldName = 'QB_ID'
end
end
object wdsItems: TWebDataSource
AutoEdit = False
DataSet = xdwdsItems
Left = 268
Top = 300
end end
end end
<nav class="navbar navbar-expand navbar-light bg-light sticky-top" style="z-index: 100;"> <nav class="navbar navbar-expand navbar-light bg-light sticky-top border-light" style="z-index: 100;">
<div class="container-fluid ps-0"> <div class="container-fluid d-flex align-items-center ps-0 pe-0">
<ul class="navbar-nav me-auto ps-2">
<!-- Left-aligned form state label -->
<div class="me-auto ps-3">
<label id="lbl_form_state" class="form-label mb-0 fw-bold text-uppercase text-nowrap text-danger" style="font-size: 16px;">View Mode</label>
</div>
<!-- Right-aligned buttons -->
<ul class="navbar-nav ms-auto pe-2 mb-0">
<li class="nav-item pe-2"> <li class="nav-item pe-2">
<button id="btnadd" class="btn btn-primary btn-sm">Add</button> <button id="btnadd" class="btn btn-primary btn-sm">Add</button>
</li> </li>
...@@ -17,8 +24,10 @@ ...@@ -17,8 +24,10 @@
<button id="btncancel" class="btn btn-danger btn-sm">Cancel</button> <button id="btncancel" class="btn btn-danger btn-sm">Cancel</button>
</li> </li>
</ul> </ul>
</div> </div>
</nav> </nav>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="container mt-4"> <div class="container mt-4">
...@@ -54,20 +63,22 @@ ...@@ -54,20 +63,22 @@
</div> </div>
</form> </form>
<table class="table table-responsive table-striped table-hover table-bordered" id="tblPhoneGrid"> <!-- Table Section -->
<thead class="thead-dark"> <div id="order_table_section" class="overflow-auto mt-2"
<tr> style="max-height: calc(100vh - 250px); padding-bottom: 0; width: 100%;">
<th scope="col">ID</th> <table id="tblPhoneGrid" class="table table-striped table-bordered border-light" style="width: 100%;">
<th scope="col">Name</th> <thead class="sticky-top thead-light">
<th scope="col">Description</th> <tr style="font-size: 0.875rem;">
<th scope="col">Status</th> <!-- Table headers are dynamically generated -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="orderTableBody" class="align-middle">
<!-- Rows will be added dynamically via Delphi code --> <!-- Table rows are dynamically generated -->
</tbody> </tbody>
</table> </table>
</div>
<label id="lblentries"></label> <label id="lblentries"></label>
<nav aria-label="Page navigation"> <nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="pagination"> <ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added dynamically via Delphi code --> <!-- Pagination items will be added dynamically via Delphi code -->
...@@ -78,46 +89,4 @@ ...@@ -78,46 +89,4 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Modal -->
<div class="modal fade" id="audioModal" tabindex="-1" aria-labelledby="audioModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="audioModalLabel">Audio Player</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" onclick="stopAudio()"></button>
</div>
<div class="modal-body">
<audio controls id="audioPlayer">
<source src="" type="audio/mp3" id="audioSource">
Your browser does not support the audio element.
</audio>
</div>
</div>
</div>
</div> </div>
<script>
document.getElementById('tblPhoneGrid').addEventListener('click', function(event) {
// Check if the clicked element is a table cell (td)
if (event.target.tagName === 'TD') {
const row = event.target.parentNode;
const cells = row.getElementsByTagName('td');
// Extract data from the row
const id = cells[0].textContent;
const name = cells[1].textContent;
const description = cells[2].textContent;
const status = cells[3].textContent.trim().toLowerCase();
// Populate form fields
document.getElementById('edtname').value = name;
document.getElementById('edtdescription').value = description;
// Set the checkbox based on the status
const isActive = status === 'active';
document.getElementById('cbstatus').checked = isActive;
console.log(`Row clicked! ID: ${id}, Name: ${name}, Description: ${description}, Status: ${status}`);
}
});
</script>
...@@ -11,30 +11,38 @@ interface ...@@ -11,30 +11,38 @@ interface
uses uses
System.SysUtils, System.Classes, Web, WEBLib.Graphics, WEBLib.Forms, WEBLib.Dialogs, System.SysUtils, System.Classes, Web, WEBLib.Graphics, WEBLib.Forms, WEBLib.Dialogs,
Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls, WEBLib.Controls, WEBLib.Grids, WebLib.Lists, Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls, WEBLib.Controls, WEBLib.Grids, WebLib.Lists,
XData.Web.Client, WEBLib.ExtCtrls, DB, XData.Web.JsonDataset, XData.Web.Client, WEBLib.ExtCtrls, DB, XData.Web.JsonDataset, JS, WEBLib.JSON,
XData.Web.Dataset, XData.Web.Connection, Vcl.Forms, DateUtils; XData.Web.Dataset, XData.Web.Connection, Vcl.Forms, DateUtils, WEBLib.DBCtrls;
type type
TFViewItems = class(TWebForm) TFViewItems = class(TWebForm)
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
XDataWebDataSet1: TXDataWebDataSet; xdwdsItems: TXDataWebDataSet;
lblEntries: TWebLabel; lblEntries: TWebLabel;
wcbPageSize: TWebComboBox; wcbPageSize: TWebComboBox;
btnAdd: TWebButton; btnAdd: TWebButton;
edtName: TWebEdit;
edtDescription: TWebEdit;
cbStatus: TWebCheckBox;
btnSave: TWebButton; btnSave: TWebButton;
btnCancel: TWebButton; btnCancel: TWebButton;
btnDelete: TWebButton; btnDelete: TWebButton;
btnEdit: TWebButton; btnEdit: TWebButton;
procedure WebFormCreate(Sender: TObject); wdbtcItems: TWebDBTableControl;
wdsItems: TWebDataSource;
xdwdsItemsstatus: TStringField;
xdwdsItemsID: TStringField;
xdwdsItemsname: TStringField;
xdwdsItemsdescription: TStringField;
edtName: TWebDBEdit;
edtDescription: TWebDBEdit;
CBStatus: TWebDBCheckBox;
xdwdsItemsQB_ID: TStringField;
lblFormState: TWebLabel;
procedure btnAddClick(Sender: TObject); procedure btnAddClick(Sender: TObject);
procedure wcbPageSizeChange(Sender: TObject); procedure wcbPageSizeChange(Sender: TObject);
procedure btnEditClick(Sender: TObject); procedure btnEditClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject); procedure btnSaveClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure wdbtcItemsClickCell(Sender: TObject; ACol, ARow: Integer);
private private
FChildForm: TWebForm; FChildForm: TWebForm;
procedure AddRowToTable(ID, Name, Description, Status: string); procedure AddRowToTable(ID, Name, Description, Status: string);
...@@ -43,8 +51,11 @@ type ...@@ -43,8 +51,11 @@ type
function GenerateSearchOptions(): string; function GenerateSearchOptions(): string;
procedure ViewMode(); procedure ViewMode();
procedure EditMode(); procedure EditMode();
procedure DisablePagination();
procedure EnablePagination();
[async] procedure GetItems(searchOptions: string); [async] procedure GetItems(searchOptions: string);
[async] procedure AddItem(itemOptions: string); [async] procedure AddItem();
[async] procedure InitializeForm;
var var
PageNumber: integer; PageNumber: integer;
PageSize: integer; PageSize: integer;
...@@ -53,7 +64,10 @@ type ...@@ -53,7 +64,10 @@ type
EndDate: string; EndDate: string;
OrderBy: string; OrderBy: string;
Caller: string; Caller: string;
notification: string;
mode: string;
public public
class function CreateForm(AElementID: string): TWebForm;
end; end;
...@@ -63,12 +77,25 @@ var ...@@ -63,12 +77,25 @@ var
implementation implementation
uses uses
JS, XData.Model.Classes, XData.Model.Classes,
ConnectionModule, Auth.Service, Utils, View.AddItem, View.Main; ConnectionModule, Auth.Service, Utils, View.AddItem, View.Main;
{$R *.dfm} {$R *.dfm}
procedure TFViewItems.WebFormCreate(Sender: TObject); class function TFViewItems.CreateForm(AElementID: string): TWebForm;
begin
Application.CreateForm(TFViewItems, AElementID, Result,
procedure(AForm: TObject)
begin
with TFViewItems(AForm) do
begin
InitializeForm;
end;
end
);
end;
[async] procedure TFViewItems.InitializeForm;
// Initializes important values: // Initializes important values:
// PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc // PageNumber: What page number the user is on IE 1: 1-10, 2: 11-20 etc
// TotalPages: Total number of pages returned from the search. // TotalPages: Total number of pages returned from the search.
...@@ -78,38 +105,10 @@ begin ...@@ -78,38 +105,10 @@ begin
PageNumber := 1; PageNumber := 1;
TotalPages := 1; // Initial total pages TotalPages := 1; // Initial total pages
wcbPageSize.Text := '10'; wcbPageSize.Text := '10';
getItems(GenerateSearchOptions()); await(getItems(GenerateSearchOptions()));
end; ViewMode();
procedure TFViewItems.ViewMode();
begin
btnAdd.Enabled := true;
btnDelete.Enabled := true;
btnSave.Enabled := false;
btnCancel.Enabled := false;
btnEdit.Enabled := true;
FViewMain.change := false;
edtName.Enabled := false;
edtDescription.enabled := false;
cbStatus.Checked := false;
end;
procedure TFViewItems.EditMode();
begin
FViewMain.change := true;
btnAdd.Enabled := false;
btnDelete.Enabled := false;
btnSave.Enabled := true;
btnCancel.Enabled := True;
btnEdit.Enabled := false;
edtName.Enabled := true;
edtDescription.Enabled := true;
cbStatus.enabled := true;
end; end;
procedure TFViewItems.AddRowToTable(ID, Name, Description, Status: string); procedure TFViewItems.AddRowToTable(ID, Name, Description, Status: string);
// Adds one row to #tblPhoneGrid and lets Bootstrap 5.3 highlight the row // Adds one row to #tblPhoneGrid and lets Bootstrap 5.3 highlight the row
// with its built-in `table-active` class when the user clicks it. // with its built-in `table-active` class when the user clicks it.
...@@ -174,8 +173,43 @@ begin ...@@ -174,8 +173,43 @@ begin
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
procedure TFViewItems.DisablePagination;
var
i: Integer;
li: TJSHTMLElement;
ul: TJSHTMLElement;
begin
ul := TJSHTMLElement(document.getElementById('pagination'));
if Assigned(ul) then
begin
for i := 0 to ul.children.length - 1 do
begin
li := TJSHTMLElement(ul.children[i]);
li.setAttribute('disabled', 'true');
li.style.setProperty('pointer-events', 'none'); // Disable click
li.style.setProperty('opacity', '0.5');
end;
end;
end;
procedure TFViewItems.EnablePagination;
var
i: Integer;
li: TJSHTMLElement;
ul: TJSHTMLElement;
begin
ul := TJSHTMLElement(document.getElementById('pagination'));
if Assigned(ul) then
begin
for i := 0 to ul.children.length - 1 do
begin
li := TJSHTMLElement(ul.children[i]);
li.removeAttribute('disabled');
li.style.removeProperty('pointer-events');
li.style.removeProperty('opacity');
end;
end;
end;
procedure TFViewItems.GeneratePagination(TotalPages: Integer); procedure TFViewItems.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table. // Generates pagination for the table.
...@@ -198,7 +232,7 @@ begin ...@@ -198,7 +232,7 @@ begin
PageLink.setAttribute('href', 'javascript:void(0)'); PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent) PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
begin begin
if PageNumber > 1 then if ( ( PageNumber > 1 ) and ( not FViewMain.change ) ) then
begin begin
Dec(PageNumber); Dec(PageNumber);
GetItems(GenerateSearchOptions()); GetItems(GenerateSearchOptions());
...@@ -239,9 +273,12 @@ begin ...@@ -239,9 +273,12 @@ begin
var var
PageNum: Integer; PageNum: Integer;
begin begin
if ( not FViewMain.change ) then
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(GenerateSearchOptions()); GetItems(GenerateSearchOptions());
end;
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem); PaginationElement.appendChild(PageItem);
...@@ -278,9 +315,12 @@ begin ...@@ -278,9 +315,12 @@ begin
var var
PageNum: Integer; PageNum: Integer;
begin begin
if ( not FViewMain.change ) then
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(GenerateSearchOptions()); GetItems(GenerateSearchOptions());
end;
end); end);
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
PaginationElement.appendChild(PageItem); PaginationElement.appendChild(PageItem);
...@@ -315,9 +355,12 @@ begin ...@@ -315,9 +355,12 @@ begin
var var
PageNum: Integer; PageNum: Integer;
begin begin
if ( not FViewMain.change ) then
begin
PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText); PageNum := StrToInt((Event.currentTarget as TJSHTMLElement).innerText);
PageNumber := PageNum; PageNumber := PageNum;
GetItems(generateSearchOptions()); GetItems(generateSearchOptions());
end;
end); end);
end; end;
PageItem.appendChild(PageLink); PageItem.appendChild(PageLink);
...@@ -334,7 +377,7 @@ begin ...@@ -334,7 +377,7 @@ begin
PageLink.setAttribute('href', 'javascript:void(0)'); PageLink.setAttribute('href', 'javascript:void(0)');
PageLink.addEventListener('click', procedure(Event: TJSMouseEvent) PageLink.addEventListener('click', procedure(Event: TJSMouseEvent)
begin begin
if PageNumber < TotalPages then if ( ( PageNumber < TotalPages ) and ( not FViewMain.change ) ) then
begin begin
Inc(PageNumber); Inc(PageNumber);
GetItems(GenerateSearchOptions()); GetItems(GenerateSearchOptions());
...@@ -367,13 +410,12 @@ begin ...@@ -367,13 +410,12 @@ begin
itemList := TJSObject(xdcResponse.Result); itemList := TJSObject(xdcResponse.Result);
data := TJSArray(itemList['data']); data := TJSArray(itemList['data']);
itemListLength := integer(itemList['count']); itemListLength := integer(itemList['count']);
ClearTable(); console.log(data);
for i := 0 to data.Length - 1 do xdwdsItems.Close;
begin xdwdsItems.SetJsonData(data);
item := TJSObject(data[i]); xdwdsItems.Open;
AddRowToTable(string(item['ID']), string(item['name']), string(item['description']),
string(item['status']));
end;
TotalPages := (itemListLength + PageSize - 1) div PageSize; TotalPages := (itemListLength + PageSize - 1) div PageSize;
if (PageNumber * PageSize) < itemListLength then if (PageNumber * PageSize) < itemListLength then
begin begin
...@@ -390,7 +432,7 @@ begin ...@@ -390,7 +432,7 @@ begin
GeneratePagination(TotalPages); GeneratePagination(TotalPages);
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve items: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
...@@ -415,14 +457,41 @@ begin ...@@ -415,14 +457,41 @@ begin
newform.ShowModal( newform.ShowModal(
procedure(AValue: TModalResult) procedure(AValue: TModalResult)
begin begin
getItems(generateSearchOptions()); if newform.confirm then
begin
xdwdsItems.Append;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status;
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end end
); );
end; end;
procedure TFViewItems.btnCancelClick(Sender: TObject); procedure TFViewItems.btnCancelClick(Sender: TObject);
begin begin
ShowToast('Editing items is not yet implemented.', 'info'); ShowConfirmationModal(
'Are you sure you want to cancel all changes to the customer?',
'Yes',
'No',
procedure(confirmed: Boolean)
begin
if confirmed then
begin
FViewMain.change := false;
ViewMode();
ShowToast('failure:Changes Discarded');
xdwdsItems.Cancel;
xdwdsItems.First;
getItems(GenerateSearchOptions());
end;
end);
end; end;
...@@ -433,29 +502,47 @@ end; ...@@ -433,29 +502,47 @@ end;
procedure TFViewItems.btnEditClick(Sender: TObject); procedure TFViewItems.btnEditClick(Sender: TObject);
begin begin
ShowToast('Editing items is not yet implemented.', 'info'); EditMode();
//EditMode();
end; end;
procedure TFViewItems.btnSaveClick(Sender: TObject); procedure TFViewItems.btnSaveClick(Sender: TObject);
//TODO implement editting items //TODO implement editting items
begin begin
ShowToast('Editing items is not yet implemented.', 'info'); //ShowToast('Editing items is not yet implemented.', 'info');
//ViewMode(); if lblFormState.Caption = 'Edit Mode' then
mode := 'EDIT'
else
mode := 'ADD';
xdwdsItems.Post;
AddItem();
ViewMode();
end; end;
procedure TFViewItems.AddItem(itemOptions: string); procedure TFViewItems.AddItem();
// adds an item to the database. // adds an item to the database.
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
item: TJSObject;
itemJSON: TJSONObject;
begin begin
try try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddItem', [itemOptions])); itemJSON := TJSONObject.Create;
itemJSON.AddPair('qb_items_id', xdwdsItems.FieldByName('ID').AsString);
itemJSON.AddPair('qb_item_name', xdwdsItems.FieldByName('name').AsString);
itemJSON.AddPair('item_desc', xdwdsItems.FieldByName('description').AsString);
itemJSON.AddPair('status', xdwdsItems.FieldByName('status').AsString);
itemJSON.AddPair('qb_items_qb_id', xdwdsItems.FieldByName('QB_ID').AsString);
itemJSON.AddPair('mode', mode);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddItem', [itemJSON.ToString]));
getItems(GenerateSearchOptions()); getItems(GenerateSearchOptions());
item := TJSObject(xdcResponse.Result);
showToast(string(item['msg']));
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not add item: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -467,6 +554,17 @@ begin ...@@ -467,6 +554,17 @@ begin
getItems(GenerateSearchOptions()); getItems(GenerateSearchOptions());
end; end;
procedure TFViewItems.wdbtcItemsClickCell(Sender: TObject; ACol, ARow: Integer);
begin
if lblFormState.Caption = 'View Mode' then
begin
console.log(wdbtcItems.Cells[3, ARow]);
console.log(xdwdsItems.Locate('ID', wdbtcItems.Cells[0, ARow], []));
console.log(wdbtcItems.Cells[0, ARow]);
xdwdsItems.Locate('ID', wdbtcItems.Cells[0, ARow], []);
end;
end;
procedure TFViewItems.ClearTable(); procedure TFViewItems.ClearTable();
// clears the table // clears the table
var var
...@@ -488,5 +586,50 @@ begin ...@@ -488,5 +586,50 @@ begin
Result := searchOptions; Result := searchOptions;
end; end;
procedure TFViewItems.ViewMode;
// Enables Customer Fields while disabling shipping address fields.
begin
wcbPageSize.Enabled := true;
wdbtcItems.Enabled := true;
EnablePagination();
btnAdd.Enabled := true;
btnDelete.Enabled := true;
btnSave.Enabled := false;
btnCancel.Enabled := false;
btnEdit.Enabled := true;
FViewMain.change := false;
lblFormState.Caption := 'View Mode';
lblFormState.ElementHandle.classList.remove('text-success');
lblFormState.ElementHandle.classList.add('text-danger');
end;
procedure TFViewItems.EditMode();
begin
xdwdsItems.Edit;
wdbtcItems.Enabled := false;
wcbPageSize.Enabled := false;
FViewMain.change := true;
btnAdd.Enabled := false;
btnDelete.Enabled := false;
btnSave.Enabled := true;
btnCancel.Enabled := True;
btnEdit.Enabled := false;
edtName.Enabled := true;
edtDescription.Enabled := true;
cbStatus.enabled := true;
DisablePagination();
lblFormState.Caption := 'Edit Mode';
lblFormState.ElementHandle.classList.remove('text-danger');
lblFormState.ElementHandle.classList.add('text-success');
end;
end. end.
...@@ -119,20 +119,6 @@ object FViewMain: TFViewMain ...@@ -119,20 +119,6 @@ object FViewMain: TFViewMain
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = lblCustomersClick OnClick = lblCustomersClick
end end
object lblQuickbooks: TWebLabel
Left = 546
Top = 125
Width = 57
Height = 14
Caption = 'QuickBooks'
ElementID = 'lblquickbooks'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = lblQuickbooksClick
end
object lblVersion: TWebLabel object lblVersion: TWebLabel
Left = 358 Left = 358
Top = 209 Top = 209
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
<li class="nav-item"> <li class="nav-item">
<a class="dropdown-item" id="dropdown.menu.itemlist" href="#"><i class="fa fa-cubes fa-fw"></i><span> Items</span></a> <a class="dropdown-item" id="dropdown.menu.itemlist" href="#"><i class="fa fa-cubes fa-fw"></i><span> Items</span></a>
</li> </li>
<li class="nav-item">
<a class="dropdown-item" id="lblquickbooks" href="#"><i class="fa fa-tags fa-fw"></i><span> QuickBooks</span></a>
</li>
</ul> </ul>
<div class="collapse navbar-collapse show" id="navbarNavDropdown"> <div class="collapse navbar-collapse show" id="navbarNavDropdown">
<ul class="navbar-nav ms-auto"> <ul class="navbar-nav ms-auto">
......
...@@ -23,7 +23,6 @@ type ...@@ -23,7 +23,6 @@ type
lblUsers: TWebLinkLabel; lblUsers: TWebLinkLabel;
lblorders: TWebLabel; lblorders: TWebLabel;
lblCustomers: TWebLabel; lblCustomers: TWebLabel;
lblQuickbooks: TWebLabel;
lblVersion: TWebLabel; lblVersion: TWebLabel;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure mnuLogoutClick(Sender: TObject); procedure mnuLogoutClick(Sender: TObject);
...@@ -171,7 +170,9 @@ procedure TFViewMain.lblItemsListClick(Sender: TObject); ...@@ -171,7 +170,9 @@ procedure TFViewMain.lblItemsListClick(Sender: TObject);
begin begin
if ( not ( change ) ) then if ( not ( change ) ) then
begin begin
ShowForm(TFViewItems); if Assigned(FChildForm) then
FChildForm.Free;
TFViewItems.CreateForm(WebPanel1.ElementID);
lblAppTitle.Caption := 'Koehler-Gibson Items'; lblAppTitle.Caption := 'Koehler-Gibson Items';
setActive('Items'); setActive('Items');
end end
......
...@@ -227,6 +227,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -227,6 +227,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 92 Top = 92
Width = 300 Width = 300
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcompanyname' ElementID = 'edtcompanyname'
...@@ -244,6 +245,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -244,6 +245,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 120 Top = 120
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtaccountcompanyname' ElementID = 'edtaccountcompanyname'
...@@ -259,6 +261,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -259,6 +261,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 148 Top = 148
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtinquickbooks' ElementID = 'edtinquickbooks'
...@@ -274,6 +277,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -274,6 +277,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 314 Top = 314
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtshipvia' ElementID = 'edtshipvia'
...@@ -289,6 +293,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -289,6 +293,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 346 Top = 346
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtquantity' ElementID = 'edtquantity'
...@@ -304,6 +309,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -304,6 +309,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 374 Top = 374
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtprice' ElementID = 'edtprice'
ElementPosition = epRelative ElementPosition = epRelative
...@@ -318,6 +324,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -318,6 +324,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 402 Top = 402
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtinvoiceto' ElementID = 'edtinvoiceto'
...@@ -333,6 +340,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -333,6 +340,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 458 Top = 458
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtponumber' ElementID = 'edtponumber'
...@@ -348,6 +356,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -348,6 +356,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 486 Top = 486
Width = 200 Width = 200
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtjobname' ElementID = 'edtjobname'
...@@ -363,6 +372,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -363,6 +372,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 348 Top = 348
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtother' ElementID = 'edtother'
...@@ -378,6 +388,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -378,6 +388,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 207 Top = 207
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcadfile' ElementID = 'edtcadfile'
...@@ -393,6 +404,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -393,6 +404,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 179 Top = 179
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtaroundno' ElementID = 'edtaroundno'
...@@ -408,6 +420,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -408,6 +420,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 151 Top = 151
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtacrossno' ElementID = 'edtacrossno'
...@@ -423,6 +436,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -423,6 +436,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 123 Top = 123
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtdiecutno' ElementID = 'edtdiecutno'
...@@ -438,6 +452,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -438,6 +452,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 95 Top = 95
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtrscd' ElementID = 'edtrscd'
...@@ -453,6 +468,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -453,6 +468,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 64 Top = 64
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtrscw' ElementID = 'edtrscw'
...@@ -468,6 +484,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -468,6 +484,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 39 Top = 39
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtrscl' ElementID = 'edtrscl'
...@@ -483,6 +500,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -483,6 +500,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 506 Top = 506
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcustomadhesive' ElementID = 'edtcustomadhesive'
...@@ -499,6 +517,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -499,6 +517,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 478 Top = 478
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcustombacking' ElementID = 'edtcustombacking'
...@@ -514,6 +533,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -514,6 +533,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 450 Top = 450
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtstandardsetup' ElementID = 'edtstandardsetup'
...@@ -529,6 +549,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -529,6 +549,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 430 Top = 430
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtstripmount' ElementID = 'edtstripmount'
...@@ -544,6 +565,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -544,6 +565,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 334 Top = 334
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtloose' ElementID = 'edtloose'
...@@ -559,6 +581,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -559,6 +581,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 261 Top = 261
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtrscstyle' ElementID = 'edtrscstyle'
...@@ -676,6 +699,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -676,6 +699,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 117 Top = 117
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtclemson' ElementID = 'edtclemson'
...@@ -692,6 +716,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -692,6 +716,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 89 Top = 89
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcrosshairs' ElementID = 'edtcrosshairs'
...@@ -708,6 +733,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -708,6 +733,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 64 Top = 64
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtmachineindent' ElementID = 'edtmachineindent'
...@@ -724,6 +750,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -724,6 +750,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 39 Top = 39
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcylindersize' ElementID = 'edtcylindersize'
...@@ -1063,7 +1090,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1063,7 +1090,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
ShowFocus = False ShowFocus = False
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebDBComboBox1: TWebDBComboBox object wdbcbShipTo: TWebDBComboBox
Left = 26 Left = 26
Top = 430 Top = 430
Width = 145 Width = 145
...@@ -1073,6 +1100,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1073,6 +1100,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Role = 'null' Role = 'null'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = wdbcbShipToChange
ItemIndex = -1 ItemIndex = -1
DataField = 'staff_fields_ship_to' DataField = 'staff_fields_ship_to'
DataSource = WebDataSource1 DataSource = WebDataSource1
...@@ -1108,7 +1136,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1108,7 +1136,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnCancelClick OnClick = btnCancelClick
end end
object WebDBComboBox2: TWebDBComboBox object wdbcbQuickbooksItem: TWebDBComboBox
Left = 26 Left = 26
Top = 515 Top = 515
Width = 145 Width = 145
...@@ -1220,6 +1248,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1220,6 +1248,7 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
Top = 194 Top = 194
Width = 121 Width = 121
Height = 22 Height = 22
TabStop = False
ChildOrder = 81 ChildOrder = 81
ElementID = 'edtordernum' ElementID = 'edtordernum'
Enabled = False Enabled = False
...@@ -1561,6 +1590,9 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated ...@@ -1561,6 +1590,9 @@ object FOrderEntryCorrugated: TFOrderEntryCorrugated
object XDataWebDataSet1supplied_by_customer_order_date: TStringField object XDataWebDataSet1supplied_by_customer_order_date: TStringField
FieldName = 'supplied_by_customer_order_date' FieldName = 'supplied_by_customer_order_date'
end end
object XDataWebDataSet1inQuickBooks: TStringField
FieldName = 'inQuickBooks'
end
end end
object WebDataSource1: TWebDataSource object WebDataSource1: TWebDataSource
AutoEdit = False AutoEdit = False
......
...@@ -179,11 +179,11 @@ type ...@@ -179,11 +179,11 @@ type
wdsShipTo: TWebDataSource; wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet; xdwdsShipTo: TXDataWebDataSet;
xdwdsShipToADDRESS: TStringField; xdwdsShipToADDRESS: TStringField;
WebDBComboBox1: TWebDBComboBox; wdbcbShipTo: TWebDBComboBox;
cbEmail: TWebCheckBox; cbEmail: TWebCheckBox;
XDataWebDataSet1supplied_by_customer_order_date: TStringField; XDataWebDataSet1supplied_by_customer_order_date: TStringField;
btnCancel: TWebButton; btnCancel: TWebButton;
WebDBComboBox2: TWebDBComboBox; wdbcbQuickbooksItem: TWebDBComboBox;
wdsQBItem: TWebDataSource; wdsQBItem: TWebDataSource;
xdwdsQBItem: TXDataWebDataSet; xdwdsQBItem: TXDataWebDataSet;
xdwdsQBItemname: TStringField; xdwdsQBItemname: TStringField;
...@@ -224,6 +224,7 @@ type ...@@ -224,6 +224,7 @@ type
procedure WebButton2Click(Sender: TObject); procedure WebButton2Click(Sender: TObject);
procedure ShowAddAddressForm(); procedure ShowAddAddressForm();
[async] procedure SendAddressToServer(AddressJSON: TJSONObject); [async] procedure SendAddressToServer(AddressJSON: TJSONObject);
procedure wdbcbShipToChange(Sender: TObject);
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
...@@ -261,8 +262,6 @@ begin ...@@ -261,8 +262,6 @@ begin
orderID := orderInfo; orderID := orderInfo;
mode := modeParam; mode := modeParam;
notification := info; notification := info;
console.log('Mode in createform: ' + modeParam);
InitializeForm; InitializeForm;
end; end;
end end
...@@ -398,6 +397,9 @@ begin ...@@ -398,6 +397,9 @@ begin
XDataWebDataSet1mounting_full_mount.AsString := ''; XDataWebDataSet1mounting_full_mount.AsString := '';
XDataWebDataSet1.Post; XDataWebDataSet1.Post;
//xdwdsShipTo.Post;
//xdwdsQBItem.Post;
XDataWebDataSet1.First; XDataWebDataSet1.First;
while not XDataWebDataSet1.Eof do while not XDataWebDataSet1.Eof do
begin begin
...@@ -408,8 +410,6 @@ begin ...@@ -408,8 +410,6 @@ begin
if Field.AsString = '' then if Field.AsString = '' then
begin begin
orderJSON.AddPair(Field.FieldName, ''); orderJSON.AddPair(Field.FieldName, '');
console.log(Field.FieldName);
console.log(Field.AsString);
end end
else else
orderJSON.AddPair(Field.FieldName, Field.AsString); // Add all other fields orderJSON.AddPair(Field.FieldName, Field.AsString); // Add all other fields
...@@ -480,7 +480,7 @@ begin ...@@ -480,7 +480,7 @@ begin
input := TJSHTMLInputElement(document.getElementById('wcbshipto')); input := TJSHTMLInputElement(document.getElementById('wcbshipto'));
if WebDBComboBox1.Text = '' then if wdbcbShipTo.Text = '' then
begin begin
input.classList.add('is-invalid'); input.classList.add('is-invalid');
result := false; result := false;
...@@ -569,7 +569,7 @@ begin ...@@ -569,7 +569,7 @@ begin
window.open(pdfURL, '_blank'); window.open(pdfURL, '_blank');
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not generate corrugated PDF: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -580,7 +580,6 @@ var ...@@ -580,7 +580,6 @@ var
Response: TXDataClientResponse; Response: TXDataClientResponse;
jsObj: TJSObject; jsObj: TJSObject;
begin begin
console.log(orderJSON);
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCorrugatedOrder',
[orderJSON.ToString])); [orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result); jsObj := JS.TJSObject(Response.Result);
...@@ -601,7 +600,7 @@ begin ...@@ -601,7 +600,7 @@ begin
[OrderID, 'corrugated', JS.toString(AuthService.TokenPayload.Properties['user_id'])])); [OrderID, 'corrugated', JS.toString(AuthService.TokenPayload.Properties['user_id'])]));
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not delete order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -840,7 +839,7 @@ var ...@@ -840,7 +839,7 @@ var
orderList : TJSObject; orderList : TJSObject;
i: integer; i: integer;
data: TJSArray; data: TJSArray;
order: TJSObject; order, customer, items: TJSObject;
callListLength: integer; callListLength: integer;
tempString, strColorList: string; tempString, strColorList: string;
colorObject: TJSObject; colorObject: TJSObject;
...@@ -849,7 +848,6 @@ var ...@@ -849,7 +848,6 @@ var
color: TJSObject; color: TJSObject;
colorJSON: TJSONObject; colorJSON: TJSONObject;
colorListJSON: TJSONArray; colorListJSON: TJSONArray;
items: TJSObject;
begin begin
try try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrder', [Order_ID])); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetOrder', [Order_ID]));
...@@ -973,21 +971,23 @@ begin ...@@ -973,21 +971,23 @@ begin
else else
cbStripMount.Checked := false; cbStripMount.Checked := false;
if mode = 'EDIT' then xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer', [XDataWebDataSet1.FieldByName('COMPANY_ID').AsString]));
begin customer := TJSObject(xdcResponse.Result);
CustomerID := XDataWebDataSet1COMPANY_ID.AsString;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(order['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems', []));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(order['ITEMS']); items := TJSObject(order['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -1009,11 +1009,13 @@ begin ...@@ -1009,11 +1009,13 @@ begin
XDataWebDataSet1.Edit; XDataWebDataSet1.Edit;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems', []));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(customer['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
...@@ -1026,7 +1028,7 @@ begin ...@@ -1026,7 +1028,7 @@ begin
dtpApprovedDate.Date := 0; dtpApprovedDate.Date := 0;
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve customer: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -1043,7 +1045,10 @@ end; ...@@ -1043,7 +1045,10 @@ end;
procedure TFOrderEntryCorrugated.EditMode(); procedure TFOrderEntryCorrugated.EditMode();
begin begin
xdwdsShipTo.Edit;
xdwdsQBItem.Edit;
XDataWebDataSet1.Edit; XDataWebDataSet1.Edit;
FViewMain.change := true; FViewMain.change := true;
btnCopy.Enabled := false; btnCopy.Enabled := false;
btnPDF.Enabled := false; btnPDF.Enabled := false;
...@@ -1073,6 +1078,8 @@ begin ...@@ -1073,6 +1078,8 @@ begin
cbWideFormat.Enabled := True; cbWideFormat.Enabled := True;
cbPrintCard.Enabled := True; cbPrintCard.Enabled := True;
cbFullSizePanel.Enabled := True; cbFullSizePanel.Enabled := True;
wdbcbQuickbooksItem.Enabled := true;
wdbcbShipTo.Enabled := true;
lblFormState.Caption := 'Edit Mode'; lblFormState.Caption := 'Edit Mode';
lblFormState.ElementHandle.classList.remove('text-danger'); lblFormState.ElementHandle.classList.remove('text-danger');
...@@ -1111,6 +1118,8 @@ begin ...@@ -1111,6 +1118,8 @@ begin
cbWideFormat.Enabled := False; cbWideFormat.Enabled := False;
cbPrintCard.Enabled := False; cbPrintCard.Enabled := False;
cbFullSizePanel.Enabled := False; cbFullSizePanel.Enabled := False;
wdbcbQuickbooksItem.Enabled := false;
wdbcbShipTo.Enabled := false;
lblFormState.Caption := 'View Mode'; lblFormState.Caption := 'View Mode';
lblFormState.ElementHandle.classList.remove('text-success'); lblFormState.ElementHandle.classList.remove('text-success');
...@@ -1118,6 +1127,12 @@ begin ...@@ -1118,6 +1127,12 @@ begin
end; end;
procedure TFOrderEntryCorrugated.wdbcbShipToChange(Sender: TObject);
begin
console.log(XDataWebDataSet1.FieldByName('staff_fields_ship_to').AsString);
console.log(xdwdsShipTo.FieldByName('ADDRESS').AsString);
end;
initialization initialization
RegisterClass(TFOrderEntryCorrugated); RegisterClass(TFOrderEntryCorrugated);
......
...@@ -2,8 +2,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -2,8 +2,8 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
Width = 956 Width = 956
Height = 728 Height = 728
object WebLabel2: TWebLabel object WebLabel2: TWebLabel
Left = 26 Left = 24
Top = 72 Top = 71
Width = 52 Width = 52
Height = 15 Height = 15
Caption = 'Company' Caption = 'Company'
...@@ -51,60 +51,22 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -51,60 +51,22 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'SHORT_NAME' DataField = 'SHORT_NAME'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtInQuickBooks: TWebDBEdit object edtQBOrderNum: TWebDBEdit
Left = 24 Left = 151
Top = 152 Top = 149
Width = 121 Width = 121
Height = 23 Height = 23
AutoCompletion = acNope AutoCompletion = acNope
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtinquickbooks' ElementID = 'edtqbordernum'
Enabled = False
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'inQuickBooks' DataField = 'QB_ORDER_NUM'
DataSource = WebDataSource1 DataSource = wdsOrder
end
object dtpOrderDate: TWebDateTimePicker
Left = 22
Top = 218
Width = 170
Height = 22
ElementID = 'dtporderdate'
BorderStyle = bsSingle
ChildOrder = 4
Color = clWhite
Date = 45638.529943136570000000
Role = ''
Text = ''
end
object dtpProofDate: TWebDateTimePicker
Left = 22
Top = 250
Width = 170
Height = 22
ElementID = 'dtpproofdate'
BorderStyle = bsSingle
ChildOrder = 4
Color = clWhite
Date = 45638.529943136570000000
Role = ''
Text = ''
end
object dtpShipDate: TWebDateTimePicker
Left = 22
Top = 282
Width = 170
Height = 22
ElementID = 'dtpshipdate'
BorderStyle = bsSingle
ChildOrder = 4
Color = clWhite
Date = 45638.529943136570000000
Role = ''
Text = ''
end end
object edtShipVia: TWebDBEdit object edtShipVia: TWebDBEdit
Left = 24 Left = 24
...@@ -117,7 +79,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -117,7 +79,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'staff_fields_ship_via' DataField = 'staff_fields_ship_via'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtQuantity: TWebDBEdit object edtQuantity: TWebDBEdit
Left = 24 Left = 24
...@@ -131,7 +93,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -131,7 +93,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'staff_fields_quantity' DataField = 'staff_fields_quantity'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtPrice: TWebDBEdit object edtPrice: TWebDBEdit
Left = 24 Left = 24
...@@ -143,7 +105,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -143,7 +105,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'staff_fields_price' DataField = 'staff_fields_price'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtInvoiceTo: TWebDBEdit object edtInvoiceTo: TWebDBEdit
Left = 26 Left = 26
...@@ -156,7 +118,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -156,7 +118,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'staff_fields_invoice_to' DataField = 'staff_fields_invoice_to'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object wdbcbShipTo: TWebDBComboBox object wdbcbShipTo: TWebDBComboBox
Left = 26 Left = 26
...@@ -168,7 +130,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -168,7 +130,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
ItemIndex = -1 ItemIndex = -1
DataField = 'staff_fields_ship_to' DataField = 'staff_fields_ship_to'
DataSource = WebDataSource1 DataSource = wdsOrder
ListField = 'ADDRESS' ListField = 'ADDRESS'
ListSource = wdsShipTo ListSource = wdsShipTo
end end
...@@ -183,11 +145,11 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -183,11 +145,11 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'staff_fields_po_number' DataField = 'staff_fields_po_number'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtJobName: TWebDBEdit object edtJobName: TWebDBEdit
Left = 26 Left = 26
Top = 486 Top = 516
Width = 121 Width = 121
Height = 23 Height = 23
AutoSize = True AutoSize = True
...@@ -195,8 +157,9 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -195,8 +157,9 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
ElementID = 'edtjobname' ElementID = 'edtjobname'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnExit = edtJobNameExit
DataField = 'staff_fields_job_name' DataField = 'staff_fields_job_name'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object edtSpecialInstructions: TWebDBEdit object edtSpecialInstructions: TWebDBEdit
Left = 835 Left = 835
...@@ -209,7 +172,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -209,7 +172,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'general_special_instructions' DataField = 'general_special_instructions'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object btnSave: TWebButton object btnSave: TWebButton
Left = 526 Left = 526
...@@ -236,7 +199,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -236,7 +199,7 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
OnClick = btnCancelClick OnClick = btnCancelClick
end end
object edtCompanyName: TWebDBEdit object edtCompanyName: TWebDBEdit
Left = 26 Left = 24
Top = 92 Top = 92
Width = 121 Width = 121
Height = 22 Height = 22
...@@ -245,19 +208,20 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -245,19 +208,20 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'NAME' DataField = 'NAME'
DataSource = WebDataSource1 DataSource = wdsOrder
end end
object wcbQBItem: TWebDBComboBox object wcbQBItem: TWebDBComboBox
Left = 26 Left = 26
Top = 515 Top = 487
Width = 145 Width = 145
Height = 23 Height = 23
ElementID = 'wcbqbitem' ElementID = 'wcbqbitem'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = wcbQBItemChange
ItemIndex = -1 ItemIndex = -1
DataField = 'staff_fields_quickbooks_item' DataField = 'staff_fields_quickbooks_item'
DataSource = WebDataSource1 DataSource = wdsOrder
ListField = 'name' ListField = 'name'
ListSource = wdsQBItem ListSource = wdsQBItem
end end
...@@ -273,17 +237,6 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -273,17 +237,6 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = btnPDFClick OnClick = btnPDFClick
end end
object edtOrderNum: TWebEdit
Left = 126
Top = 194
Width = 121
Height = 22
ChildOrder = 81
ElementID = 'edtordernum'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnDelete: TWebButton object btnDelete: TWebButton
Left = 534 Left = 534
Top = 458 Top = 458
...@@ -356,78 +309,185 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -356,78 +309,185 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnClick = WebButton2Click OnClick = WebButton2Click
end end
object WebDataSource1: TWebDataSource object wdbcbINQB: TWebDBCheckBox
Left = 26
Top = 149
Width = 113
Height = 22
Caption = 'In Quickbooks?'
ChildOrder = 29
ElementID = 'wdbcbinqb'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'IN_QB'
DataSource = wdsOrder
ValueChecked = 'T'
ValueUnChecked = 'F'
end
object edtOrderNum: TWebDBEdit
Left = 103
Top = 185
Width = 121
Height = 22
ChildOrder = 30
ElementID = 'edtordernum'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'ORDER_ID'
DataSource = wdsOrder
end
object btnQB: TWebButton
Left = 746
Top = 495
Width = 96
Height = 25
Caption = 'Send To QB'
ChildOrder = 30
ElementID = 'btnsendtoqb'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnQBClick
end
object dtpOrderDate: TWebDBDateTimePicker
Left = 22
Top = 218
Width = 170
Height = 22
ElementID = 'dtporderdate'
BorderStyle = bsSingle
ChildOrder = 31
Color = clWhite
Date = 45855.535876481480000000
Role = ''
Text = ''
DataField = 'staff_fields_order_date'
DataSource = wdsOrder
end
object dtpProofDate: TWebDBDateTimePicker
Left = 24
Top = 250
Width = 170
Height = 22
ElementID = 'dtpproofdate'
BorderStyle = bsSingle
ChildOrder = 31
Color = clWhite
Date = 45855.535876481480000000
Role = ''
Text = ''
DataField = 'staff_fields_proof_date'
DataSource = wdsOrder
end
object dtpShipDate: TWebDBDateTimePicker
Left = 24
Top = 282
Width = 170
Height = 22
ElementID = 'dtpshipdate'
BorderStyle = bsSingle
ChildOrder = 31
Color = clWhite
Date = 45855.535876481480000000
Role = ''
Text = ''
DataField = 'staff_fields_ship_date'
DataSource = wdsOrder
end
object edtQBItemDescription: TWebEdit
Left = 26
Top = 548
Width = 121
Height = 22
ChildOrder = 31
ElementID = 'edtitemdescription'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wdsOrder: TWebDataSource
AutoEdit = False AutoEdit = False
DataSet = XDataWebDataSet1 DataSet = xdwdsOrder
Left = 418 Left = 418
Top = 86 Top = 86
end end
object XDataWebDataSet1: TXDataWebDataSet object xdwdsOrder: TXDataWebDataSet
OnCalcFields = xdwdsOrderCalcFields
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 422 Left = 422
Top = 28 Top = 28
object XDataWebDataSet1COMPANY_ID: TIntegerField object xdwdsOrderORDER_DATE: TDateField
FieldName = 'COMPANY_ID'
end
object XDataWebDataSet1USER_ID: TIntegerField
FieldName = 'USER_ID'
end
object XDataWebDataSet1ORDER_DATE: TDateField
FieldName = 'ORDER_DATE' FieldName = 'ORDER_DATE'
end end
object XDataWebDataSet1ORDER_STATUS: TStringField object xdwdsOrderSHORT_NAME: TStringField
FieldName = 'ORDER_STATUS'
end
object XDataWebDataSet1SHORT_NAME: TStringField
FieldName = 'SHORT_NAME' FieldName = 'SHORT_NAME'
end end
object XDataWebDataSet1staff_fields_ship_via: TStringField object xdwdsOrderstaff_fields_ship_via: TStringField
FieldName = 'staff_fields_ship_via' FieldName = 'staff_fields_ship_via'
end end
object XDataWebDataSet1staff_fields_price: TStringField object xdwdsOrderstaff_fields_price: TStringField
FieldName = 'staff_fields_price' FieldName = 'staff_fields_price'
end end
object XDataWebDataSet1staff_fields_invoice_to: TStringField object xdwdsOrderstaff_fields_invoice_to: TStringField
FieldName = 'staff_fields_invoice_to' FieldName = 'staff_fields_invoice_to'
end end
object XDataWebDataSet1staff_fields_invoice_attention: TStringField object xdwdsOrderstaff_fields_invoice_attention: TStringField
FieldName = 'staff_fields_invoice_attention' FieldName = 'staff_fields_invoice_attention'
end end
object XDataWebDataSet1staff_fields_ship_to: TStringField object xdwdsOrderstaff_fields_ship_to: TStringField
FieldName = 'staff_fields_ship_to' FieldName = 'staff_fields_ship_to'
end end
object XDataWebDataSet1staff_fields_ship_attention: TStringField object xdwdsOrderstaff_fields_ship_attention: TStringField
FieldName = 'staff_fields_ship_attention' FieldName = 'staff_fields_ship_attention'
end end
object XDataWebDataSet1staff_fields_po_number: TStringField object xdwdsOrderstaff_fields_po_number: TStringField
FieldName = 'staff_fields_po_number' FieldName = 'staff_fields_po_number'
end end
object XDataWebDataSet1staff_fields_job_name: TStringField object xdwdsOrderstaff_fields_job_name: TStringField
FieldName = 'staff_fields_job_name' FieldName = 'staff_fields_job_name'
end end
object XDataWebDataSet1staff_fields_order_date: TStringField object xdwdsOrderstaff_fields_order_date: TStringField
FieldName = 'staff_fields_order_date' FieldName = 'staff_fields_order_date'
end end
object XDataWebDataSet1staff_fields_proof_date: TStringField object xdwdsOrderstaff_fields_proof_date: TStringField
FieldName = 'staff_fields_proof_date' FieldName = 'staff_fields_proof_date'
end end
object XDataWebDataSet1staff_fields_ship_date: TStringField object xdwdsOrderstaff_fields_ship_date: TStringField
FieldName = 'staff_fields_ship_date' FieldName = 'staff_fields_ship_date'
end end
object XDataWebDataSet1NAME: TStringField object xdwdsOrderNAME: TStringField
FieldName = 'NAME' FieldName = 'NAME'
end end
object XDataWebDataSet1staff_fields_quickbooks_item: TStringField object xdwdsOrderstaff_fields_quickbooks_item: TStringField
FieldName = 'staff_fields_quickbooks_item' FieldName = 'staff_fields_quickbooks_item'
end end
object XDataWebDataSet1general_special_instructions: TStringField object xdwdsOrdergeneral_special_instructions: TStringField
FieldName = 'general_special_instructions' FieldName = 'general_special_instructions'
end end
object XDataWebDataSet1staff_fields_quantity: TStringField object xdwdsOrderstaff_fields_quantity: TStringField
FieldName = 'staff_fields_quantity' FieldName = 'staff_fields_quantity'
end end
object XDataWebDataSet1inQuickBooks: TStringField object xdwdsOrderQB_ESTIMATE_ID: TStringField
FieldName = 'inQuickBooks' FieldName = 'QB_ESTIMATE_ID'
end
object xdwdsOrderQB_ORDER_NUM: TStringField
FieldName = 'QB_ORDER_NUM'
end
object xdwdsOrderUSER_ID: TIntegerField
FieldName = 'USER_ID'
end
object xdwdsOrderCOMPANY_ID: TIntegerField
FieldName = 'COMPANY_ID'
end
object xdwdsOrderORDER_ID: TIntegerField
FieldName = 'ORDER_ID'
end
object xdwdsOrderIN_QB: TStringField
FieldName = 'IN_QB'
end
object xdwdsOrderQB_LIST_ID: TStringField
FieldName = 'QB_LIST_ID'
end end
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
...@@ -458,6 +518,12 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie ...@@ -458,6 +518,12 @@ object FOrderEntryCuttingDie: TFOrderEntryCuttingDie
object xdwdsQBItemname: TStringField object xdwdsQBItemname: TStringField
FieldName = 'name' FieldName = 'name'
end end
object xdwdsQBItemQB_ID: TStringField
FieldName = 'QB_ID'
end
object xdwdsQBItemdescription: TStringField
FieldName = 'description'
end
end end
object tmrReturn: TWebTimer object tmrReturn: TWebTimer
Enabled = False Enabled = False
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
<!-- Left-aligned label --> <!-- Left-aligned label -->
<div class="me-auto ps-3"> <div class="me-auto ps-3">
<label id="lbl_form_state" class="form-label mb-0 fw-bold text-uppercase text-nowrap text-danger" style="font-size: 16px;">View Mode</label> <label id="lbl_order_type" class="form-label mb-0 fw-bold text-uppercase text-nowrap" style="font-size: 16px;">Cutting Die -</label>
</div>
<div class="me-auto ps-2">
<label id="lbl_form_state" class="form-label mb-0 fw-bold text-uppercase text-nowrap text-danger" style="font-size: 16px;"> View Mode</label>
</div> </div>
<!-- Right-aligned buttons --> <!-- Right-aligned buttons -->
...@@ -21,14 +24,17 @@ ...@@ -21,14 +24,17 @@
<button id="btndelete" class="btn btn-danger btn-sm">Delete</button> <button id="btndelete" class="btn btn-danger btn-sm">Delete</button>
</li> </li>
<li class="nav-item pe-2"> <li class="nav-item pe-2">
<button id="btnpdf" class="btn btn-primary btn-sm">PDF</button>
</li>
<li class="nav-item pe-2">
<button id="btnconfirm" class="btn btn-success btn-sm">Save</button> <button id="btnconfirm" class="btn btn-success btn-sm">Save</button>
</li> </li>
<li class="nav-item pe-2"> <li class="nav-item pe-2">
<button id="btncancel" class="btn btn-danger btn-sm">Cancel</button> <button id="btncancel" class="btn btn-danger btn-sm">Cancel</button>
</li> </li>
<li class="nav-item pe-2">
<button id="btnpdf" class="btn btn-primary btn-sm">PDF</button>
</li>
<li class="nav-item pe-2">
<button id="btnsendtoqb" class="btn btn-primary btn-sm">Send To QB</button>
</li>
<li class="nav-item"> <li class="nav-item">
<button id="btnclose" class="btn btn-primary btn-sm">Close</button> <button id="btnclose" class="btn btn-primary btn-sm">Close</button>
</li> </li>
...@@ -54,9 +60,13 @@ ...@@ -54,9 +60,13 @@
Please Provide a Customer ID. Please Provide a Customer ID.
</div> </div>
</div> </div>
<div class="col-auto d-flex flex-column">
<label for="wdbcbinqb" class="form-label mt-2" style="font-weight: 700; font-size: 15px;">In QB?:</label>
<input id="wdbcbinqb" type="checkbox" class="form-check-input mt-1">
</div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">In Quickbooks?:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">QB Order Number:</label>
<input id="edtinquickbooks"type="text" class="form-control" style="width: 150px"/> <input id="edtqbordernum"type="text" class="form-control" style="width: 150px" required/>
</div> </div>
</div> </div>
<h4 class="custom-h4 mt-3">Staff Fields</h4> <h4 class="custom-h4 mt-3">Staff Fields</h4>
...@@ -87,11 +97,17 @@ ...@@ -87,11 +97,17 @@
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Quantity:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Quantity:</label>
<input id="edtquantity" class="form-control input-sm" style="width: 100px"/> <input id="edtquantity" class="form-control input-sm" style="width: 100px" type="number" min="1" required/>
<div class="invalid-feedback" style="font-size: 15px;" required>
Please Provide a Quantity.
</div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Price:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Price:</label>
<input id="edtprice" class="form-control input-sm" style="width: 100px" type="number" min="0"/> <input id="edtprice" class="form-control input-sm" style="width: 100px" type="number" min="1" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Price.
</div>
</div> </div>
<div> <div>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Invoice To:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Invoice To:</label>
...@@ -115,12 +131,26 @@ ...@@ -115,12 +131,26 @@
<input id="edtponumber" class="form-control input-sm" width='50%'/> <input id="edtponumber" class="form-control input-sm" width='50%'/>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Job Name:</label> <label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">QB Item:</label>
<input id="edtjobname" class="form-control input-sm" style="width: 300px"/> <select id="wcbqbitem" class='form-select' required></select>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a QB Item.
</div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<label style="font-weight: 700; font-size: 15px;" class="form-label mt-2">QuickBooks Item:</label> <label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Job Name:</label>
<select id="wcbqbitem" class='form-select'></select> <input id="edtjobname" class="form-control input-sm" style="width: 600px"/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Job Name.
</div>
</div>
<div class="row">
<div class="col-12">
<label for="edtitemdescription" class="form-label mt-2" style="font-weight: 700; font-size: 15px;">
Item Description:
</label>
<input id="edtitemdescription" class="form-control" style="width: 100%;" />
</div>
</div> </div>
</div> </div>
<h4 class="custom-h4 mt-3">General</h4> <h4 class="custom-h4 mt-3">General</h4>
......
unit View.OrderEntryCuttingDie; unit View.OrderEntryCuttingDie;
interface interface
...@@ -11,32 +11,26 @@ uses ...@@ -11,32 +11,26 @@ uses
type type
TFOrderEntryCuttingDie = class(TWebForm) TFOrderEntryCuttingDie = class(TWebForm)
WebDataSource1: TWebDataSource; wdsOrder: TWebDataSource;
XDataWebDataSet1: TXDataWebDataSet; xdwdsOrder: TXDataWebDataSet;
XDataWebDataSet1COMPANY_ID: TIntegerField; xdwdsOrderORDER_DATE: TDateField;
XDataWebDataSet1USER_ID: TIntegerField; xdwdsOrderSHORT_NAME: TStringField;
XDataWebDataSet1ORDER_DATE: TDateField; xdwdsOrderstaff_fields_ship_via: TStringField;
XDataWebDataSet1ORDER_STATUS: TStringField; xdwdsOrderstaff_fields_price: TStringField;
XDataWebDataSet1SHORT_NAME: TStringField; xdwdsOrderstaff_fields_invoice_to: TStringField;
XDataWebDataSet1staff_fields_ship_via: TStringField; xdwdsOrderstaff_fields_invoice_attention: TStringField;
XDataWebDataSet1staff_fields_price: TStringField; xdwdsOrderstaff_fields_ship_to: TStringField;
XDataWebDataSet1staff_fields_invoice_to: TStringField; xdwdsOrderstaff_fields_ship_attention: TStringField;
XDataWebDataSet1staff_fields_invoice_attention: TStringField; xdwdsOrderstaff_fields_po_number: TStringField;
XDataWebDataSet1staff_fields_ship_to: TStringField; xdwdsOrderstaff_fields_job_name: TStringField;
XDataWebDataSet1staff_fields_ship_attention: TStringField; xdwdsOrderstaff_fields_order_date: TStringField;
XDataWebDataSet1staff_fields_po_number: TStringField; xdwdsOrderstaff_fields_proof_date: TStringField;
XDataWebDataSet1staff_fields_job_name: TStringField; xdwdsOrderstaff_fields_ship_date: TStringField;
XDataWebDataSet1staff_fields_order_date: TStringField;
XDataWebDataSet1staff_fields_proof_date: TStringField;
XDataWebDataSet1staff_fields_ship_date: TStringField;
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
WebLabel2: TWebLabel; WebLabel2: TWebLabel;
edtCompanyAccountName: TWebDBEdit; edtCompanyAccountName: TWebDBEdit;
edtInQuickBooks: TWebDBEdit; edtQBOrderNum: TWebDBEdit;
WebLabel1: TWebLabel; WebLabel1: TWebLabel;
dtpOrderDate: TWebDateTimePicker;
dtpProofDate: TWebDateTimePicker;
dtpShipDate: TWebDateTimePicker;
edtShipVia: TWebDBEdit; edtShipVia: TWebDBEdit;
edtQuantity: TWebDBEdit; edtQuantity: TWebDBEdit;
edtPrice: TWebDBEdit; edtPrice: TWebDBEdit;
...@@ -52,16 +46,15 @@ type ...@@ -52,16 +46,15 @@ type
btnSave: TWebButton; btnSave: TWebButton;
btnCancel: TWebButton; btnCancel: TWebButton;
edtCompanyName: TWebDBEdit; edtCompanyName: TWebDBEdit;
XDataWebDataSet1NAME: TStringField; xdwdsOrderNAME: TStringField;
XDataWebDataSet1staff_fields_quickbooks_item: TStringField; xdwdsOrderstaff_fields_quickbooks_item: TStringField;
XDataWebDataSet1general_special_instructions: TStringField; xdwdsOrdergeneral_special_instructions: TStringField;
XDataWebDataSet1staff_fields_quantity: TStringField; xdwdsOrderstaff_fields_quantity: TStringField;
wdsQBItem: TWebDataSource; wdsQBItem: TWebDataSource;
xdwdsQBItem: TXDataWebDataSet; xdwdsQBItem: TXDataWebDataSet;
xdwdsQBItemname: TStringField; xdwdsQBItemname: TStringField;
wcbQBItem: TWebDBComboBox; wcbQBItem: TWebDBComboBox;
btnPDF: TWebButton; btnPDF: TWebButton;
edtOrderNum: TWebEdit;
btnDelete: TWebButton; btnDelete: TWebButton;
btnClose: TWebButton; btnClose: TWebButton;
btnCopy: TWebButton; btnCopy: TWebButton;
...@@ -69,19 +62,34 @@ type ...@@ -69,19 +62,34 @@ type
btnEdit: TWebButton; btnEdit: TWebButton;
btnAdd: TWebButton; btnAdd: TWebButton;
WebButton2: TWebButton; WebButton2: TWebButton;
XDataWebDataSet1inQuickBooks: TStringField;
lblFormState: TWebLabel; lblFormState: TWebLabel;
wdbcbINQB: TWebDBCheckBox;
xdwdsOrderQB_ESTIMATE_ID: TStringField;
xdwdsOrderQB_ORDER_NUM: TStringField;
xdwdsOrderUSER_ID: TIntegerField;
xdwdsOrderCOMPANY_ID: TIntegerField;
xdwdsOrderORDER_ID: TIntegerField;
edtOrderNum: TWebDBEdit;
xdwdsOrderIN_QB: TStringField;
btnQB: TWebButton;
dtpOrderDate: TWebDBDateTimePicker;
dtpProofDate: TWebDBDateTimePicker;
dtpShipDate: TWebDBDateTimePicker;
xdwdsQBItemQB_ID: TStringField;
xdwdsOrderQB_LIST_ID: TStringField;
xdwdsQBItemdescription: TStringField;
edtQBItemDescription: TWebEdit;
procedure btnSaveClick(Sender: TObject); procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
[async] procedure GetCuttingDieOrder(Order_ID: string); [async] procedure GetCuttingDieOrder(Order_ID: string);
[async] procedure GetCustomer(customerID: string); [async] procedure GetEmptyOrderInfo(customerID: string);
[async] procedure AddCuttingDieOrder(orderJSON: TJSONObject); [async] procedure AddCuttingDieOrder(orderJSON: TJSONObject);
procedure btnPDFClick(Sender: TObject); procedure btnPDFClick(Sender: TObject);
[async] procedure GenerateReportPDF; [async] procedure GenerateReportPDF;
procedure SendOrderToServer(); procedure SendOrderToServer();
function VerifyOrder(): boolean; function VerifyOrder(): boolean;
procedure btnDeleteClick(Sender: TObject); [async] procedure btnDeleteClick(Sender: TObject);
[async] procedure delOrder(); [async] procedure delOrder();
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnCopyClick(Sender: TObject); procedure btnCopyClick(Sender: TObject);
...@@ -92,12 +100,19 @@ type ...@@ -92,12 +100,19 @@ type
procedure WebButton2Click(Sender: TObject); procedure WebButton2Click(Sender: TObject);
procedure ShowAddAddressForm(); procedure ShowAddAddressForm();
[async] procedure SendAddressToServer(AddressJSON: TJSONObject); [async] procedure SendAddressToServer(AddressJSON: TJSONObject);
procedure btnQBClick(Sender: TObject);
procedure xdwdsOrderCalcFields(DataSet: TDataSet);
[async] procedure AddEstimate(orderID: string);
function VerifyQBOrder(): boolean;
procedure wcbQBItemChange(Sender: TObject);
procedure edtJobNameExit(Sender: TObject);
private private
FAgencyCode: string; FAgencyCode: string;
FCurrentReportType: string; FCurrentReportType: string;
FSelectProc: TSelectProc; FSelectProc: TSelectProc;
orderID: string; orderID: string;
customerID: string; customerID: string;
customer_qb_id: string;
mode: string; mode: string;
notification: string; notification: string;
procedure EditMode; procedure EditMode;
...@@ -128,7 +143,6 @@ begin ...@@ -128,7 +143,6 @@ begin
orderID := orderInfo; orderID := orderInfo;
mode := modeParam; mode := modeParam;
notification := info; notification := info;
console.log('Mode in createform: ' + modeParam);
InitializeForm; InitializeForm;
end; end;
...@@ -139,10 +153,9 @@ end; ...@@ -139,10 +153,9 @@ end;
[async] procedure TFOrderEntryCuttingDie.InitializeForm; [async] procedure TFOrderEntryCuttingDie.InitializeForm;
begin begin
console.log('The mode in initialize form is: ' + mode);
if mode = 'ADD' then if mode = 'ADD' then
begin begin
await(getCustomer(customerID)); await(getEmptyOrderInfo(customerID));
EditMode; EditMode;
end end
else else
...@@ -151,11 +164,52 @@ begin ...@@ -151,11 +164,52 @@ begin
ViewMode; ViewMode;
end; end;
edtOrderNum.Text := orderID;
if notification <> '' then if notification <> '' then
ShowToast(notification); ShowToast(notification);
end; end;
procedure TFOrderEntryCuttingDie.AddEstimate(orderID: string);
var
Response: TXDataClientResponse;
notification: TJSObject;
msg: string;
begin
try
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddEstimate',
[orderID]));
notification := TJSObject(Response.Result);
msg := string(notification['status']);
Utils.HideSpinner('spinner');
getCuttingDieOrder(orderID);
ShowToast(msg);
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
procedure TFOrderEntryCuttingDie.btnQBClick(Sender: TObject);
begin
//ShowToast('Sending Orders To QuickBooks is not yet Implemented', 'info');
console.log(customer_qb_id);
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
begin
if wdbcbINQB.Checked = false then
begin
Utils.ShowSpinner('spinner');
addEstimate(xdwdsOrder.FieldByName('ORDER_ID').AsString);
end
else
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure');
end;
end
else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure');
end;
procedure TFOrderEntryCuttingDie.WebButton2Click(Sender: TObject); procedure TFOrderEntryCuttingDie.WebButton2Click(Sender: TObject);
begin begin
ShowAddAddressForm(); ShowAddAddressForm();
...@@ -169,7 +223,6 @@ var ...@@ -169,7 +223,6 @@ var
begin begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString])); [AddressJSON.ToString]));
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
ShowToast(string(notification['status'])); ShowToast(string(notification['status']));
xdwdsShipTo.Close; xdwdsShipTo.Close;
...@@ -209,7 +262,7 @@ begin ...@@ -209,7 +262,7 @@ begin
AddressJSON.AddPair('state', newform.edtState.Text); AddressJSON.AddPair('state', newform.edtState.Text);
AddressJSON.AddPair('zip', newform.edtZip.Text); AddressJSON.AddPair('zip', newform.edtZip.Text);
AddressJSON.AddPair('contact', newform.edtContact.Text); AddressJSON.AddPair('contact', newform.edtContact.Text);
AddressJSON.AddPair('customer_id', customerID); AddressJSON.AddPair('customer_id', xdwdsOrder.FieldByName('COMPANY_ID').AsString);
ship_block := newform.edtFirstLine.Text + slinebreak + ship_block := newform.edtFirstLine.Text + slinebreak +
edtCompanyName.Text + slinebreak + edtCompanyName.Text + slinebreak +
...@@ -241,6 +294,15 @@ begin ...@@ -241,6 +294,15 @@ begin
else else
input.classList.remove('is-invalid'); input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtjobname'));
if edtJobName.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtaccountcompanyname')); input := TJSHTMLInputElement(document.getElementById('edtaccountcompanyname'));
if edtCompanyAccountName.Text = '' then if edtCompanyAccountName.Text = '' then
...@@ -255,7 +317,6 @@ begin ...@@ -255,7 +317,6 @@ begin
input := TJSHTMLInputElement(document.getElementById('edtinvoiceto')); input := TJSHTMLInputElement(document.getElementById('edtinvoiceto'));
if edtInvoiceTo.Text = '' then if edtInvoiceTo.Text = '' then
begin begin
console.log('hot');
input.classList.add('is-invalid'); input.classList.add('is-invalid');
result := false; result := false;
end end
...@@ -280,6 +341,36 @@ begin ...@@ -280,6 +341,36 @@ begin
end end
else else
input.classList.remove('is-invalid'); input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtprice'));
if edtPrice.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('edtquantity'));
if edtQuantity.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
input := TJSHTMLInputElement(document.getElementById('wcbqbitem'));
if wcbQBItem.Text = '' then
begin
input.classList.add('is-invalid');
result := false;
end
else
input.classList.remove('is-invalid');
end; end;
...@@ -293,18 +384,13 @@ var ...@@ -293,18 +384,13 @@ var
Response: TXDataClientResponse; Response: TXDataClientResponse;
begin begin
orderJSON := TJSONObject.Create; orderJSON := TJSONObject.Create;
XDataWebDataSet1.Edit; xdwdsOrder.Edit;
//Convert all dates to strings because I was having less issues with that data type. xdwdsOrder.Post;
XDataWebDataSet1staff_fields_proof_date.Value := DateTimeToStr(dtpProofDate.Date); xdwdsOrder.First;
XDataWebDataSet1staff_fields_ship_date.Value := DateTimeToStr(dtpShipDate.Date); while not xdwdsOrder.Eof do
XDataWebDataSet1staff_fields_order_date.Value := DateTimeToStr(dtpOrderDate.Date);
XDataWebDataSet1.Post;
XDataWebDataSet1.First;
while not XDataWebDataSet1.Eof do
begin begin
for Field in XDataWebDataSet1.Fields do for Field in xdwdsOrder.Fields do
begin begin
if Field is TStringField then if Field is TStringField then
begin begin
...@@ -319,21 +405,15 @@ begin ...@@ -319,21 +405,15 @@ begin
orderJSON.AddPair(Field.FieldName, 'T') orderJSON.AddPair(Field.FieldName, 'T')
else else
orderJSON.AddPair(Field.FieldName, ''); orderJSON.AddPair(Field.FieldName, '');
end
else if Field is TIntegerField then
orderJSON.AddPair(Field.FieldName, Field.AsInteger);
end; end;
xdwdsOrder.Next;
end; end;
XDataWebDataSet1.Next;
end;
orderJSON.AddPair('COMPANY_ID', customerID);
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
orderJSON.AddPair('mode', mode);
if mode = 'EDIT' then
orderJSON.AddPair('ORDER_ID', orderID);
if mode = 'ADD' then
ShowToast('Success: Order Added Successfully!')
else
ShowToast('Success: Order Edited Successfully');
orderJSON.AddPair('mode', mode);
console.log(orderJSON);
AddCuttingDieOrder(orderJSON); AddCuttingDieOrder(orderJSON);
end; end;
...@@ -353,16 +433,20 @@ end; ...@@ -353,16 +433,20 @@ end;
procedure TFOrderEntryCuttingDie.btnCopyClick(Sender: TObject); procedure TFOrderEntryCuttingDie.btnCopyClick(Sender: TObject);
begin begin
mode := 'ADD'; mode := 'ADD';
dtpOrderDate.Date := 0; xdwdsOrder.Edit;
dtpProofDate.Date := 0; xdwdsOrder.FieldByName('staff_fields_order_date').AsDateTime := 0;
edtOrderNum.Text := ''; xdwdsOrder.FieldByName('staff_fields_proof_date').AsDateTime := 0;
xdwdsOrder.FieldByName('staff_fields_ship_date').AsDateTime := 0;
xdwdsOrder.FieldByName('ORDER_ID').AsString := '';
xdwdsOrder.Post;
ShowToast('Success: Order Successfully Copied'); ShowToast('Success: Order Successfully Copied');
EditMode(); EditMode();
window.scrollTo(0, 0); window.scrollTo(0, 0);
end; end;
procedure TFOrderEntryCuttingDie.btnDeleteClick(Sender: TObject); [async] procedure TFOrderEntryCuttingDie.btnDeleteClick(Sender: TObject);
begin begin
ShowConfirmationModal( ShowConfirmationModal(
'Are you sure you want to delete this order?', 'Are you sure you want to delete this order?',
...@@ -391,7 +475,7 @@ procedure TFOrderEntryCuttingDie.DelOrder(); ...@@ -391,7 +475,7 @@ procedure TFOrderEntryCuttingDie.DelOrder();
var var
Response: TXDataClientResponse; Response: TXDataClientResponse;
begin begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.DelOrder', [OrderID, 'cutting', JS.toString(AuthService.TokenPayload.Properties['user_id'])])); Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.DelOrder', [xdwdsOrder.FieldByName('ORDER_ID').AsString, 'cutting', JS.toString(AuthService.TokenPayload.Properties['user_id'])]));
end; end;
...@@ -410,8 +494,7 @@ var ...@@ -410,8 +494,7 @@ var
begin begin
try try
// Call the server method to generate the PDF // Call the server method to generate the PDF
console.log(orderID); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderCuttingPDF', [xdwdsOrder.FieldByName('ORDER_ID').AsString]));
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GenerateOrderCuttingPDF', [orderID]));
jsObject := JS.TJSObject(xdcResponse.Result); jsObject := JS.TJSObject(xdcResponse.Result);
pdfURL := JS.toString(jsObject.Properties['value']); pdfURL := JS.toString(jsObject.Properties['value']);
...@@ -420,7 +503,7 @@ begin ...@@ -420,7 +503,7 @@ begin
window.open(pdfURL, '_blank'); window.open(pdfURL, '_blank');
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not generate cutting die PDF: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -435,13 +518,19 @@ begin ...@@ -435,13 +518,19 @@ begin
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCuttingDieOrder', Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddCuttingDieOrder',
[orderJSON.ToString])); [orderJSON.ToString]));
jsObj := JS.TJSObject(Response.Result); jsObj := JS.TJSObject(Response.Result);
if mode = 'ADD' then {if mode = 'ADD' then
OrderID := String(jsObj.Properties['OrderID']); OrderID := String(jsObj.Properties['OrderID']);}
edtOrderNum.Text := OrderID;
xdwdsOrder.Close;
xdwdsOrder.SetJsonData(jsObj);
xdwdsOrder.Open;
edtOrderNum.Text := xdwdsOrder.FieldByName('ORDER_ID').AsString;
mode := 'EDIT'; mode := 'EDIT';
ShowToast(String(jsObj.Properties['status']));
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not save cutting die order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -496,8 +585,8 @@ begin ...@@ -496,8 +585,8 @@ begin
if confirmed then if confirmed then
begin begin
FViewMain.change := false; FViewMain.change := false;
if OrderID <> '' then if xdwdsOrder.FieldByName('ORDER_ID').AsString <> '' then
FViewMain.ViewOrderEntryCuttingDie(OrderID, '', 'EDIT', 'Failure: Changes Discarded') FViewMain.ViewOrderEntryCuttingDie(xdwdsOrder.FieldByName('ORDER_ID').AsString, '', 'EDIT', 'Failure: Changes Discarded')
else else
FViewMain.ViewOrders(''); FViewMain.ViewOrders('');
end; end;
...@@ -518,6 +607,12 @@ begin ...@@ -518,6 +607,12 @@ begin
end; end;
procedure TFOrderEntryCuttingDie.xdwdsOrderCalcFields(DataSet: TDataSet);
begin
if DataSet.FieldByName('IN_QB').IsNull then
DataSet.FieldByName('IN_QB').AsBoolean := False;
end;
procedure TFOrderEntryCuttingDie.getCuttingDieOrder(Order_ID: string); procedure TFOrderEntryCuttingDie.getCuttingDieOrder(Order_ID: string);
// retrieves an order from the server then loads the info into the page // retrieves an order from the server then loads the info into the page
var var
...@@ -525,7 +620,7 @@ var ...@@ -525,7 +620,7 @@ var
orderList : TJSObject; orderList : TJSObject;
i: integer; i: integer;
data: TJSArray; data: TJSArray;
order, items: TJSObject; order, items, customer: TJSObject;
begin begin
Utils.ShowSpinner('spinner'); Utils.ShowSpinner('spinner');
try try
...@@ -533,79 +628,74 @@ begin ...@@ -533,79 +628,74 @@ begin
[Order_ID])); [Order_ID]));
order := TJSObject(xdcResponse.Result); order := TJSObject(xdcResponse.Result);
data := TJSArray(order['data']); data := TJSArray(order['data']);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(order);
XDataWebDataSet1.Open;
// Check boxes and dates need to be manually set xdwdsOrder.Close;
if not (XDataWebDataSet1staff_fields_order_date.AsString = '') then xdwdsOrder.SetJsonData(order);
dtpOrderDate.Date := StrToDateTime(XDataWebDataSet1staff_fields_order_date.Value) xdwdsOrder.Open;
else
dtpOrderDate.Date := 0;
if not (XDataWebDataSet1staff_fields_proof_date.AsString = '') then
dtpProofDate.Date := StrToDateTime(XDataWebDataSet1staff_fields_proof_date.AsString)
else
dtpProofDate.Date := 0;
if not (XDataWebDataSet1staff_fields_ship_date.AsString = '') then
dtpShipDate.Date := StrToDateTime(XDataWebDataSet1staff_fields_ship_date.AsString)
else
dtpShipDate.Date := 0;
console.log(mode); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer',
console.log(XDataWebDataSet1COMPANY_ID.AsString); [xdwdsOrder.FieldByName('COMPANY_ID').AsString]));
if mode = 'EDIT' then
CustomerID := XDataWebDataSet1COMPANY_ID.AsString;
console.log(CustomerID);
if mode = 'EDIT' then customer := TJSObject(xdcResponse.Result);
begin
CustomerID := XDataWebDataSet1COMPANY_ID.AsString;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(order['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end;
customer_qb_id := string(customer['QB_LIST_ID']);
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[]));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(order['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
edtQBItemDescription.text := xdwdsQBItem.FieldByName('description').AsString +
' - ' + xdwdsOrder.FieldByName('staff_fields_job_name').AsString;
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
procedure TFOrderEntryCuttingDie.getCustomer(customerID: string); procedure TFOrderEntryCuttingDie.getEmptyOrderInfo(customerID: string);
// gets a customer from the database then loads the appropiate fields // gets a customer from the database then loads the appropiate fields
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
customer : TJSObject; customer, items : TJSObject;
address: string; address: string;
items: TJSObject;
begin begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer', xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer',
[customerID])); [customerID]));
customer := TJSObject(xdcResponse.Result); customer := TJSObject(xdcResponse.Result);
console.log(customer); customer_qb_id := string(customer['QB_LIST_ID']);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer); xdwdsOrder.Close;
XDataWebDataSet1.Open; xdwdsOrder.Open;
console.log(XDataWebDataSet1NAME.AsString); xdwdsOrder.Append;
xdwdsOrder.FieldByName('NAME').AsString := string(customer['NAME']);
xdwdsOrder.FieldByName('SHORT_NAME').AsString := string(customer['SHORT_NAME']);
xdwdsOrder.FieldByName('staff_fields_invoice_to').AsString := string(customer['staff_fields_invoice_to']);
dtpOrderDate.Date := 0; xdwdsOrder.FieldByName('COMPANY_ID').AsString := customerID;
dtpProofDate.Date := 0; xdwdsOrderUSER_ID.AsString := JS.toString(AuthService.TokenPayload.Properties['user_id']);
dtpShipDate.Date := 0; xdwdsOrder.Post;
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[]));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(customer['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
end; end;
...@@ -621,7 +711,7 @@ end; ...@@ -621,7 +711,7 @@ end;
procedure TFOrderEntryCuttingDie.EditMode; procedure TFOrderEntryCuttingDie.EditMode;
begin begin
XDataWebDataSet1.Edit; xdwdsOrder.Edit;
FViewMain.change := true; FViewMain.change := true;
btnCopy.Enabled := false; btnCopy.Enabled := false;
btnPDF.Enabled := false; btnPDF.Enabled := false;
...@@ -631,6 +721,7 @@ begin ...@@ -631,6 +721,7 @@ begin
btnCancel.Enabled := True; btnCancel.Enabled := True;
btnEdit.Enabled := false; btnEdit.Enabled := false;
btnAdd.Enabled := false; btnAdd.Enabled := false;
btnQB.Enabled := false;
lblFormState.Caption := 'Edit Mode'; lblFormState.Caption := 'Edit Mode';
lblFormState.ElementHandle.classList.remove('text-danger'); lblFormState.ElementHandle.classList.remove('text-danger');
...@@ -638,6 +729,12 @@ begin ...@@ -638,6 +729,12 @@ begin
end; end;
procedure TFOrderEntryCuttingDie.edtJobNameExit(Sender: TObject);
begin
edtQBItemDescription.text := xdwdsQBItem.FieldByName('description').AsString +
' - ' + xdwdsOrder.FieldByName('staff_fields_job_name').AsString;
end;
procedure TFOrderEntryCuttingDie.ViewMode; procedure TFOrderEntryCuttingDie.ViewMode;
begin begin
btnPDF.Enabled := true; btnPDF.Enabled := true;
...@@ -648,6 +745,7 @@ begin ...@@ -648,6 +745,7 @@ begin
btnCancel.Enabled := false; btnCancel.Enabled := false;
btnEdit.Enabled := true; btnEdit.Enabled := true;
btnAdd.Enabled := true; btnAdd.Enabled := true;
btnQB.Enabled := true;
FViewMain.change := false; FViewMain.change := false;
lblFormState.Caption := 'View Mode'; lblFormState.Caption := 'View Mode';
...@@ -655,6 +753,91 @@ begin ...@@ -655,6 +753,91 @@ begin
lblFormState.ElementHandle.classList.add('text-danger'); lblFormState.ElementHandle.classList.add('text-danger');
end; end;
procedure TFOrderEntryCuttingDie.wcbQBItemChange(Sender: TObject);
begin
edtQBItemDescription.text := xdwdsQBItem.FieldByName('description').AsString +
' - ' + xdwdsOrder.FieldByName('staff_fields_job_name').AsString;
end;
function TFOrderEntryCuttingDie.VerifyQBOrder: Boolean;
var
msg, SQL: string;
begin
Result := True;
msg := 'To add an order to QuickBooks, the following must be present:' + sLineBreak;
if edtCompanyName.Text = '' then
begin
msg := msg + '- Company Name cannot be empty' + sLineBreak;
Result := False;
end;
if edtCompanyAccountName.Text = '' then
begin
msg := msg + '- Company ID cannot be empty' + sLineBreak;
Result := False;
end;
if edtInvoiceTo.Text = '' then
begin
msg := msg + '- Invoice To cannot be empty' + sLineBreak;
Result := False;
end;
if wdbcbShipTo.Text = '' then
begin
msg := msg + '- Ship To cannot be empty' + sLineBreak;
Result := False;
end;
if dtpOrderDate.Date = 0 then
begin
msg := msg + '- Order Date cannot be empty' + sLineBreak;
Result := False;
end;
if edtPrice.Text = '' then
begin
msg := msg + '- Price cannot be empty' + sLineBreak;
Result := False;
end;
if edtQuantity.Text = '' then
begin
msg := msg + '- Quantity cannot be empty' + sLineBreak;
Result := False;
end;
if wcbQBItem.Text = '' then
begin
msg := msg + '- Item cannot be empty' + sLineBreak;
Result := False;
end;
if edtJobName.Text = '' then
begin
msg := msg + '- Job Name Cannot be empty' + sLineBreak;
Result := False;
end;
xdwdsQBItem.Locate('name', xdwdsOrder.FieldByName('staff_fields_quickbooks_item').AsString, []);
if xdwdsQBItem.FieldByName('QB_ID').AsString = '' then
begin
msg := msg + '- Item Must be Linked to QuickBooks' + sLineBreak;
Result := False;
end;
if customer_qb_id = '' then
begin
msg := msg + '- Customer Must be Linked to QuickBooks' + sLineBreak;
Result := False;
end;
if not result then
asm
alert(msg);
end;
end;
initialization initialization
RegisterClass(TFOrderEntryCuttingDie); RegisterClass(TFOrderEntryCuttingDie);
......
...@@ -513,6 +513,7 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -513,6 +513,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'proofing_pdf' DataField = 'proofing_pdf'
DataSource = WebDataSource1 DataSource = WebDataSource1
ValueChecked = 'T'
end end
object edtPDFTo: TWebDBEdit object edtPDFTo: TWebDBEdit
Left = 444 Left = 444
...@@ -1311,7 +1312,7 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1311,7 +1312,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
Items.Strings = ( Items.Strings = (
'Cromapro Ink Jet' 'Cromapro Ink Jet'
'Kodak Approval') 'Kodak Approval')
DataField = 'print_orientation_print_orient' DataField = 'proofing_color_contract'
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object btnCopy: TWebButton object btnCopy: TWebButton
...@@ -1412,7 +1413,7 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1412,7 +1413,7 @@ object FOrderEntryWeb: TFOrderEntryWeb
end end
object XDataWebDataSet1: TXDataWebDataSet object XDataWebDataSet1: TXDataWebDataSet
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 408 Left = 434
Top = 4 Top = 4
object XDataWebDataSet1inQuickBooks: TStringField object XDataWebDataSet1inQuickBooks: TStringField
FieldName = 'inQuickBooks' FieldName = 'inQuickBooks'
...@@ -1671,18 +1672,20 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1671,18 +1672,20 @@ object FOrderEntryWeb: TFOrderEntryWeb
object XDataWebDataSet1supplied_by_customer_b_w_or_co: TStringField object XDataWebDataSet1supplied_by_customer_b_w_or_co: TStringField
FieldName = 'supplied_by_customer_b_w_or_co' FieldName = 'supplied_by_customer_b_w_or_co'
end end
object XDataWebDataSet1InQuickbooks: TStringField
FieldName = 'InQuickbooks'
end
end end
object WebDataSource1: TWebDataSource object WebDataSource1: TWebDataSource
AutoEdit = False AutoEdit = False
DataSet = XDataWebDataSet1 DataSet = XDataWebDataSet1
Left = 406 Left = 398
Top = 38 Top = 56
end end
object wdsShipTo: TWebDataSource object wdsShipTo: TWebDataSource
AutoEdit = False
DataSet = xdwdsShipTo DataSet = xdwdsShipTo
Left = 320 Left = 318
Top = 38 Top = 54
end end
object xdwdsShipTo: TXDataWebDataSet object xdwdsShipTo: TXDataWebDataSet
Left = 322 Left = 322
...@@ -1692,10 +1695,9 @@ object FOrderEntryWeb: TFOrderEntryWeb ...@@ -1692,10 +1695,9 @@ object FOrderEntryWeb: TFOrderEntryWeb
end end
end end
object wdsQBItem: TWebDataSource object wdsQBItem: TWebDataSource
AutoEdit = False
DataSet = xdwdsQBItem DataSet = xdwdsQBItem
Left = 244 Left = 240
Top = 34 Top = 52
end end
object xdwdsQBItem: TXDataWebDataSet object xdwdsQBItem: TXDataWebDataSet
Left = 246 Left = 246
......
...@@ -203,7 +203,7 @@ type ...@@ -203,7 +203,7 @@ type
btnAdd: TWebButton; btnAdd: TWebButton;
WebButton2: TWebButton; WebButton2: TWebButton;
lblFormState: TWebLabel; lblFormState: TWebLabel;
XDataWebDataSet1inQuickBooks: TStringField; XDataWebDataSet1InQuickbooks: TStringField;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
[async] procedure getOrder(Order_ID: string); [async] procedure getOrder(Order_ID: string);
[async] procedure getCustomer(customerID: string); [async] procedure getCustomer(customerID: string);
...@@ -560,6 +560,7 @@ begin ...@@ -560,6 +560,7 @@ begin
orderJSON.AddPair('COMPANY_ID', customerID); orderJSON.AddPair('COMPANY_ID', customerID);
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id'])); orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
orderJSON.AddPair('mode', mode); orderJSON.AddPair('mode', mode);
console.log(orderJSON);
if mode = 'EDIT' then if mode = 'EDIT' then
begin begin
orderJSON.AddPair('ORDER_ID', orderID); orderJSON.AddPair('ORDER_ID', orderID);
...@@ -594,7 +595,7 @@ begin ...@@ -594,7 +595,7 @@ begin
window.open(pdfURL, '_blank'); window.open(pdfURL, '_blank');
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not generate web order PDF: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -614,7 +615,7 @@ begin ...@@ -614,7 +615,7 @@ begin
mode := 'EDIT'; mode := 'EDIT';
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not save web order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -776,7 +777,7 @@ var ...@@ -776,7 +777,7 @@ var
orderList : TJSObject; orderList : TJSObject;
i: integer; i: integer;
data: TJSArray; data: TJSArray;
order: TJSObject; order, customer: TJSObject;
callListLength: integer; callListLength: integer;
tempString, strColorList: string; tempString, strColorList: string;
colorObject: TJSObject; colorObject: TJSObject;
...@@ -869,21 +870,24 @@ begin ...@@ -869,21 +870,24 @@ begin
else else
dtpDigitalColorDate.Date := 0; dtpDigitalColorDate.Date := 0;
if mode = 'EDIT' then xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer',
begin [XDataWebDataSet1.FieldByName('COMPANY_ID').AsString]));
CustomerID := XDataWebDataSet1COMPANY_ID.AsString; customer := TJSObject(xdcResponse.Result);
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(order['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
end;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[]));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(order['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve order: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
...@@ -908,11 +912,13 @@ begin ...@@ -908,11 +912,13 @@ begin
xdwdsShipTo.Close; xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']); xdwdsShipTo.SetJSONData(customer['SHIPPING_ADDRESS_LIST']);
xdwdsShipTo.Open; xdwdsShipTo.Open;
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetItems',
[]));
items := TJSObject(xdcResponse.Result);
xdwdsQBItem.Close; xdwdsQBItem.Close;
items := TJSObject(customer['ITEMS']);
xdwdsQBItem.SetJsonData(items['data']); xdwdsQBItem.SetJsonData(items['data']);
xdwdsQBITEM.Open; xdwdsQBITEM.Open;
...@@ -943,6 +949,7 @@ end; ...@@ -943,6 +949,7 @@ end;
procedure TFOrderEntryWeb.EditMode; procedure TFOrderEntryWeb.EditMode;
begin begin
XDataWebDataSet1.Edit; XDataWebDataSet1.Edit;
FViewMain.change := true; FViewMain.change := true;
btnCopy.Enabled := false; btnCopy.Enabled := false;
btnPDF.Enabled := false; btnPDF.Enabled := false;
......
...@@ -128,6 +128,10 @@ object FViewOrders: TFViewOrders ...@@ -128,6 +128,10 @@ object FViewOrders: TFViewOrders
Title = 'Order Num' Title = 'Order Num'
end end
item item
DataField = 'IN_QB'
Title = 'In QB'
end
item
DataField = 'ID' DataField = 'ID'
Title = 'Customer ID' Title = 'Customer ID'
end end
...@@ -194,7 +198,7 @@ object FViewOrders: TFViewOrders ...@@ -194,7 +198,7 @@ object FViewOrders: TFViewOrders
item item
ElementClassName = 'text-nowrap' ElementClassName = 'text-nowrap'
DataField = 'qbRefNum' DataField = 'qbRefNum'
Title = 'QB Ref Num' Title = 'QB Order Num'
TitleElementClassName = 'min-w-80' TitleElementClassName = 'min-w-80'
end end
item item
...@@ -369,12 +373,15 @@ object FViewOrders: TFViewOrders ...@@ -369,12 +373,15 @@ object FViewOrders: TFViewOrders
object xdwdsOrdersprice: TStringField object xdwdsOrdersprice: TStringField
FieldName = 'price' FieldName = 'price'
end end
object xdwdsOrdersqbRefNum: TStringField
FieldName = 'qbRefNum'
end
object xdwdsOrderscolors: TStringField object xdwdsOrderscolors: TStringField
FieldName = 'colors' FieldName = 'colors'
end end
object xdwdsOrdersIN_QB: TStringField
FieldName = 'IN_QB'
end
object xdwdsOrdersqbRefNum: TStringField
FieldName = 'qbRefNum'
end
end end
object wdsOrders: TWebDataSource object wdsOrders: TWebDataSource
DataSet = xdwdsOrders DataSet = xdwdsOrders
...@@ -416,7 +423,7 @@ object FViewOrders: TFViewOrders ...@@ -416,7 +423,7 @@ object FViewOrders: TFViewOrders
object tmrReturn: TWebTimer object tmrReturn: TWebTimer
Enabled = False Enabled = False
OnTimer = tmrReturnTimer OnTimer = tmrReturnTimer
Left = 294 Left = 292
Top = 362 Top = 414
end end
end end
// Displays orders in the grid. Allows the user // Displays orders in the grid. Allows the user
// to sort the entries, filter their search, and search for a specific person. // to sort the entries, filter their search, and search for a specific person.
// Authors: // Authors:
// Cameron Hayes // Cameron Hayes
...@@ -35,7 +35,6 @@ type ...@@ -35,7 +35,6 @@ type
xdwdsOrdersshipDone: TStringField; xdwdsOrdersshipDone: TStringField;
xdwdsOrdersprice: TStringField; xdwdsOrdersprice: TStringField;
xdwdsOrdersID: TStringField; xdwdsOrdersID: TStringField;
xdwdsOrdersqbRefNum: TStringField;
xdwdsOrderscolors: TStringField; xdwdsOrderscolors: TStringField;
btnAddOrder: TWebButton; btnAddOrder: TWebButton;
btnSearch: TWebButton; btnSearch: TWebButton;
...@@ -58,6 +57,8 @@ type ...@@ -58,6 +57,8 @@ type
edtSearch: TWebEdit; edtSearch: TWebEdit;
xdwdsOrdersDBID: TStringField; xdwdsOrdersDBID: TStringField;
tmrReturn: TWebTimer; tmrReturn: TWebTimer;
xdwdsOrdersIN_QB: TStringField;
xdwdsOrdersqbRefNum: TStringField;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure btnAddOrderClick(Sender: TObject); procedure btnAddOrderClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject); procedure btnSearchClick(Sender: TObject);
...@@ -87,10 +88,12 @@ type ...@@ -87,10 +88,12 @@ type
PageNumber: integer; PageNumber: integer;
PageSize: integer; PageSize: integer;
TotalPages: integer; TotalPages: integer;
OrderID: string; statusOrderID: string; // used strictly for setting status.
OrderID: string; // used strictly for search string.
CompanyID: string; CompanyID: string;
JobName: string; JobName: string;
orderType: string; statusOrderType: string; // used strictly for setting status.
orderType: string; // used strictly for search string.on
//Status 1 //Status 1
StartDate1: string; StartDate1: string;
...@@ -174,7 +177,7 @@ begin ...@@ -174,7 +177,7 @@ begin
'</head>' + '</head>' +
'<body class="d-flex flex-column justify-content-center align-items-center vh-100 bg-light">' + '<body class="d-flex flex-column justify-content-center align-items-center vh-100 bg-light">' +
'<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;"></div>' + '<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;"></div>' +
'<div class="mt-3 fs-5 text-muted">Generating PDF, please wait</div>' + '<div class="mt-3 fs-5 text-muted">Generating PDF, please wait</div>' +
'</body>' + '</body>' +
'</html>' '</html>'
); );
...@@ -202,7 +205,7 @@ begin ...@@ -202,7 +205,7 @@ begin
'</head>' + '</head>' +
'<body class="d-flex flex-column justify-content-center align-items-center vh-100 bg-light">' + '<body class="d-flex flex-column justify-content-center align-items-center vh-100 bg-light">' +
'<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;"></div>' + '<div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;"></div>' +
'<div class="mt-3 fs-5 text-muted">Generating PDF, please wait</div>' + '<div class="mt-3 fs-5 text-muted">Generating PDF, please wait</div>' +
'</body>' + '</body>' +
'</html>' '</html>'
); );
...@@ -233,8 +236,7 @@ begin ...@@ -233,8 +236,7 @@ begin
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
begin begin
Utils.ShowErrorModal('Could not generate report PDF: ' + Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
E.ErrorResult.ErrorMessage);
if Assigned(APdfTab) then if Assigned(APdfTab) then
APdfTab.close; // close the blank tab on failure APdfTab.close; // close the blank tab on failure
end; end;
...@@ -305,8 +307,8 @@ begin ...@@ -305,8 +307,8 @@ begin
wcbPageSize.Text := IntToStr(PageSize); wcbPageSize.Text := IntToStr(PageSize);
OrderBy := params.Values['orderby']; OrderBy := params.Values['orderby'];
wlcbOrderBy.DisplayText := OrderBy; wlcbOrderBy.DisplayText := OrderBy;
orderType := params.Values['orderType'].ToLower(); statusOrderType := params.Values['orderType'].ToLower();
OrderID := params.Values['orderID']; statusOrderID := params.Values['orderID'];
companyID := params.Values['companyID']; companyID := params.Values['companyID'];
jobName := params.Values['jobName']; jobName := params.Values['jobName'];
...@@ -442,7 +444,7 @@ begin ...@@ -442,7 +444,7 @@ begin
newForm.Popup := True; newForm.Popup := True;
newForm.Border := fbDialog; newForm.Border := fbDialog;
newForm.Position := poScreenCenter; newForm.Position := poScreenCenter;
newForm.OrderID := OrderID; newForm.OrderID := statusOrderID;
newForm.JobName := wdbtcOrders.Cells[3, row]; newForm.JobName := wdbtcOrders.Cells[3, row];
if wdbtcOrders.Cells[14, row] <> '' then if wdbtcOrders.Cells[14, row] <> '' then
newForm.ShipDue := StrToDateTime(wdbtcOrders.Cells[14, row]) newForm.ShipDue := StrToDateTime(wdbtcOrders.Cells[14, row])
...@@ -460,7 +462,7 @@ begin ...@@ -460,7 +462,7 @@ begin
newForm.ArtDue := StrToDateTime(wdbtcOrders.Cells[8, row]) newForm.ArtDue := StrToDateTime(wdbtcOrders.Cells[8, row])
else else
newForm.ArtDue := 0 ; newForm.ArtDue := 0 ;
newForm.OrderType := OrderType; newForm.OrderType := statusOrderType;
// used to manage Back button handling to close subform // used to manage Back button handling to close subform
window.location.hash := 'subform'; window.location.hash := 'subform';
...@@ -475,7 +477,7 @@ begin ...@@ -475,7 +477,7 @@ begin
begin begin
Utils.ShowSpinner('spinner'); Utils.ShowSpinner('spinner');
StatusJSON := TJSONObject.Create; StatusJSON := TJSONObject.Create;
StatusJSON.AddPair('ORDER_ID', OrderID); StatusJSON.AddPair('ORDER_ID', StatusOrderID);
StatusJSON.AddPair('date', DateTimeToStr(newform.dtpDate.Date)); StatusJSON.AddPair('date', DateTimeToStr(newform.dtpDate.Date));
StatusJSON.AddPair('status', newform.wlcbStatus.Value); StatusJSON.AddPair('status', newform.wlcbStatus.Value);
StatusJSON.AddPair('USER_ID', 1011); StatusJSON.AddPair('USER_ID', 1011);
...@@ -520,8 +522,8 @@ end; ...@@ -520,8 +522,8 @@ end;
procedure TFViewOrders.wdbtcOrdersClickCell(Sender: TObject; ACol, procedure TFViewOrders.wdbtcOrdersClickCell(Sender: TObject; ACol,
ARow: Integer); ARow: Integer);
begin begin
OrderID := wdbtcOrders.Cells[0, ARow]; statusOrderID := wdbtcOrders.Cells[0, ARow];
OrderType := wdbtcOrders.Cells[4, ARow]; statusOrderType := wdbtcOrders.Cells[5, ARow];
row := ARow; row := ARow;
end; end;
...@@ -529,7 +531,13 @@ procedure TFViewOrders.wdbtcOrdersDblClickCell(Sender: TObject; ACol, ...@@ -529,7 +531,13 @@ procedure TFViewOrders.wdbtcOrdersDblClickCell(Sender: TObject; ACol,
ARow: Integer); ARow: Integer);
begin begin
OrderID := wdbtcOrders.Cells[0, ARow]; OrderID := wdbtcOrders.Cells[0, ARow];
orderType := wdbtcOrders.Cells[4, ARow].Split([' '])[0]; orderType := wdbtcOrders.Cells[5, ARow].Split([' '])[0];
// Parameter 1: OrderID: The ID of the order, used when editting an existing order.
// Parameter 2: CustomerID: The ID of the customer, used when adding a new order. Blank when editting an existing order because the customer id is already attached to the order.
// Parameter 3: Mode: EDIT if editting an existing order, ADD if adding a new order.
// Parameter 4: orderType: Type of order so we go to the correct order entry page.
orderEntry(OrderID, '', 'EDIT', orderType); orderEntry(OrderID, '', 'EDIT', orderType);
end; end;
...@@ -771,7 +779,7 @@ begin ...@@ -771,7 +779,7 @@ begin
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve orders: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
finally finally
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
...@@ -788,9 +796,7 @@ end; ...@@ -788,9 +796,7 @@ end;
procedure TFViewOrders.OrderEntry(orderInfo, customerInfo, mode, orderType: string); procedure TFViewOrders.OrderEntry(orderInfo, customerInfo, mode, orderType: string);
begin begin
if orderType = 'corrugated' then if orderType = 'corrugated' then
begin FViewMain.ViewOrderEntryCorrugated(orderInfo, customerInfo, mode, '')
FViewMain.ViewOrderEntryCorrugated(orderInfo, customerInfo, mode, '');
end
else if orderType = 'web' then else if orderType = 'web' then
FViewMain.ViewOrderEntryWeb(orderInfo, customerInfo, mode, '') FViewMain.ViewOrderEntryWeb(orderInfo, customerInfo, mode, '')
else else
......
...@@ -53,6 +53,9 @@ type ...@@ -53,6 +53,9 @@ type
[Async] procedure SendCustomerToServer(); [Async] procedure SendCustomerToServer();
procedure PopulateGridManually(); procedure PopulateGridManually();
procedure ApplyFilter(); procedure ApplyFilter();
var
customerID: string;
msg: string;
public public
{ Public declarations } { Public declarations }
end; end;
...@@ -123,7 +126,7 @@ begin ...@@ -123,7 +126,7 @@ begin
PopulateGridManually; PopulateGridManually;
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve QuickBooks customers: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
...@@ -211,9 +214,10 @@ begin ...@@ -211,9 +214,10 @@ begin
notification := TJSObject(Response.Result); notification := TJSObject(Response.Result);
customerID := string(notification['CustomerID']);
msg := string(notification['status']);
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
FViewMain.ViewAddCustomer(customerID, msg);
FViewMain.ViewAddCustomer(string(notification['CustomerID']), string(notification['status']));
Close(); Close();
end; end;
......
...@@ -65,7 +65,7 @@ begin ...@@ -65,7 +65,7 @@ begin
ShowToast('Failure: Please fill in all information') ShowToast('Failure: Please fill in all information')
else if ( ( OrderType = 'web plate' ) and ( wlcbStatus.Value = 'MOUNT' ) ) then else if ( ( OrderType = 'web plate' ) and ( wlcbStatus.Value = 'MOUNT' ) ) then
ShowToast('Failure: Web Plate Orders do not have Mount Due/Done dates') ShowToast('Failure: Web Plate Orders do not have Mount Due/Done dates')
else if ( ( OrderType = 'cutting die' ) and ( wlcbStatus.Value = 'MOUNT' ) or ( wlcbStatus.Value = 'ART' ) or (wlcbStatus.Value = 'PLATE') ) then else if ( ( OrderType = 'cutting die' ) and ( ( wlcbStatus.Value = 'MOUNT' ) or ( wlcbStatus.Value = 'ART' ) or (wlcbStatus.Value = 'PLATE') ) ) then
ShowToast('Failure: Cutting Die Orders do not have Art/Plate/Mount Due or Done Dates') ShowToast('Failure: Cutting Die Orders do not have Art/Plate/Mount Due or Done Dates')
else else
begin begin
...@@ -93,6 +93,7 @@ begin ...@@ -93,6 +93,7 @@ begin
dtpNewPlateDue.Date := 0; dtpNewPlateDue.Date := 0;
dtpNewArtDue.Date := 0; dtpNewArtDue.Date := 0;
ItemsToRemove := TStringList.Create; ItemsToRemove := TStringList.Create;
console.log(orderType);
if orderType = 'web plate' then if orderType = 'web plate' then
begin begin
dtpNewMountDue.Visible := false; dtpNewMountDue.Visible := false;
...@@ -100,7 +101,7 @@ begin ...@@ -100,7 +101,7 @@ begin
lblMount.Visible := false; lblMount.Visible := false;
lblMountNew.Visible := false; lblMountNew.Visible := false;
wlcbStatus.LookupValues.AddPair('PROOF', 'Proof Done'); wlcbStatus.LookupValues.AddPair('PROOF', 'Proof Done');
wlcbStatus.LookupValues.AddPair('Art', 'Art Done'); wlcbStatus.LookupValues.AddPair('ART', 'Art Done');
wlcbStatus.LookupValues.AddPair('PLATE', 'Plate Done'); wlcbStatus.LookupValues.AddPair('PLATE', 'Plate Done');
wlcbStatus.LookupValues.AddPair('SHIP', 'Ship Done'); wlcbStatus.LookupValues.AddPair('SHIP', 'Ship Done');
end end
...@@ -127,7 +128,7 @@ begin ...@@ -127,7 +128,7 @@ begin
else else
begin begin
wlcbStatus.LookupValues.AddPair('PROOF', 'Proof Done'); wlcbStatus.LookupValues.AddPair('PROOF', 'Proof Done');
wlcbStatus.LookupValues.AddPair('Art', 'Art Done'); wlcbStatus.LookupValues.AddPair('ART', 'Art Done');
wlcbStatus.LookupValues.AddPair('PLATE', 'Plate Done'); wlcbStatus.LookupValues.AddPair('PLATE', 'Plate Done');
wlcbStatus.LookupValues.AddPair('MOUNT', 'Mount Done'); wlcbStatus.LookupValues.AddPair('MOUNT', 'Mount Done');
wlcbStatus.LookupValues.AddPair('SHIP', 'Ship Done'); wlcbStatus.LookupValues.AddPair('SHIP', 'Ship Done');
......
...@@ -91,7 +91,7 @@ begin ...@@ -91,7 +91,7 @@ begin
FViewMain.ViewOrders(''); FViewMain.ViewOrders('');
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Error editing user: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
on E: Exception do on E: Exception do
Utils.ShowErrorModal('Unexpected error: ' + E.Message); Utils.ShowErrorModal('Unexpected error: ' + E.Message);
end; end;
...@@ -145,7 +145,7 @@ begin ...@@ -145,7 +145,7 @@ begin
chkAdminUser.Checked := boolean(user['admin']); chkAdminUser.Checked := boolean(user['admin']);
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve users: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
end; end;
......
...@@ -362,7 +362,7 @@ begin ...@@ -362,7 +362,7 @@ begin
GeneratePagination(TotalPages); GeneratePagination(TotalPages);
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
Utils.ShowErrorModal('Could not retrieve users: ' + E.ErrorResult.ErrorMessage); Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end; end;
Utils.HideSpinner('spinner'); Utils.HideSpinner('spinner');
end; end;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<MainSource>webKGOrders.dpr</MainSource> <MainSource>webKGOrders.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Release</Config> <Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform> <Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms> <TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType> <AppType>Application</AppType>
......
...@@ -47,6 +47,7 @@ type ...@@ -47,6 +47,7 @@ type
name: string; name: string;
description: string; description: string;
status: string; status: string;
QB_ID: string;
end; end;
TItemList = class TItemList = class
...@@ -58,6 +59,7 @@ type ...@@ -58,6 +59,7 @@ type
TOrderItem = class TOrderItem = class
public public
DBID, DBID,
IN_QB,
ID, ID,
companyName, companyName,
jobName, jobName,
...@@ -134,9 +136,8 @@ type ...@@ -134,9 +136,8 @@ type
QB_LIST_ID: string; QB_LIST_ID: string;
FFAX: string; FFAX: string;
REP_USER_ID: string; REP_USER_ID: string;
ADDRESS_LIST: TList<TAddressItem>; SHIPPING_ADDRESS_LIST: TList<TAddressItem>;
ITEMS: TItemList; REP_USERS: TList<TUserItem>;
USERS: TList<TUserItem>
end; end;
TCustomerList = class TCustomerList = class
...@@ -352,12 +353,12 @@ type ...@@ -352,12 +353,12 @@ type
// Company // Company
ORDER_ID: integer;
COMPANY_ID: integer; COMPANY_ID: integer;
NAME: string; NAME: string;
SHORT_NAME: string; SHORT_NAME: string;
inQuickBooks: string; IN_QB: string;
ADDRESS_LIST: TList<TAddressItem>; QB_ORDER_NUM: string;
ITEMS: TItemList;
// Staff Fields: // Staff Fields:
staff_fields_order_date: string; staff_fields_order_date: string;
...@@ -481,7 +482,7 @@ type ...@@ -481,7 +482,7 @@ type
[HttpGet] function GetOrder(orderInfo: string): TFullOrder; [HttpGet] function GetOrder(orderInfo: string): TFullOrder;
[HttpGet] function GetWebOrder(orderInfo: string): TWebOrder; [HttpGet] function GetWebOrder(orderInfo: string): TWebOrder;
[HttpGet] function GetCuttingDieOrder(orderInfo: string): TCuttingDie; [HttpGet] function GetCuttingDieOrder(orderInfo: string): TCuttingDie;
[HttpGet] function GetCustomers(): TCustomerList; [HttpGet] function GetCustomers(customerInfo: string): TCustomerList;
[HttpGet] function GetCustomer(ID: string): TCustomerItem; [HttpGet] function GetCustomer(ID: string): TCustomerItem;
[HttpGet] function GenerateOrderListPDF(searchOptions: string): string; [HttpGet] function GenerateOrderListPDF(searchOptions: string): string;
[HttpGet] function GenerateOrderCorrugatedPDF(orderID: string): string; [HttpGet] function GenerateOrderCorrugatedPDF(orderID: string): string;
...@@ -489,6 +490,7 @@ type ...@@ -489,6 +490,7 @@ type
[HttpGet] function GenerateOrderCuttingPDF(orderID: string): string; [HttpGet] function GenerateOrderCuttingPDF(orderID: string): string;
[HttpGet] function getQBCustomers(): TJSONArray; [HttpGet] function getQBCustomers(): TJSONArray;
[HttpGet] function getQBItems(): TJSONArray; [HttpGet] function getQBItems(): TJSONArray;
[HttpGet] function GetRepUsers(): TList<TUserItem>;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
...@@ -505,6 +507,7 @@ type ...@@ -505,6 +507,7 @@ type
function SetStatus(statusOptions: string): string; function SetStatus(statusOptions: string): string;
function AddCustomer(customerInfo: string): TJSONObject; function AddCustomer(customerInfo: string): TJSONObject;
function ImportQBCustomer(CustomerInfo: string): TJSONObject; function ImportQBCustomer(CustomerInfo: string): TJSONObject;
function AddEstimate(orderInfo: string): TJSONObject;
end; end;
implementation implementation
......
// Implementation of the Lookup Service interface used to send information // Implementation of the Lookup Service interface used to send information
// to the client. Very overcrowded. Probably should move SQL functions to new // to the client. Very overcrowded. Probably should move SQL functions to new
// file. // file.
// Authors: // Authors:
...@@ -22,7 +22,7 @@ uses ...@@ -22,7 +22,7 @@ uses
iexProcEffects, frxDBSet, frxExportBaseDialog, frCoreClasses, rOrderList, rOrderCorrugated, Common.Logging, iexProcEffects, frxDBSet, frxExportBaseDialog, frCoreClasses, rOrderList, rOrderCorrugated, Common.Logging,
DateUtils, REST.Client, REST.Types, WEBLib.REST, WEBLib.WebTools,System.Net.HttpClient, DateUtils, REST.Client, REST.Types, WEBLib.REST, WEBLib.WebTools,System.Net.HttpClient,
System.Net.URLClient, System.Net.HttpClientComponent, System.netencoding, System.Net.URLClient, System.Net.HttpClientComponent, System.netencoding,
IdHTTP, IdSSLOpenSSL, IdSSLOpenSSLHeaders, System.IniFiles; IdHTTP, IdSSLOpenSSL, IdSSLOpenSSLHeaders, System.IniFiles, System.Generics.Collections;
type type
...@@ -35,12 +35,13 @@ type ...@@ -35,12 +35,13 @@ type
function GetUsers(searchOptions: string): TUserList; function GetUsers(searchOptions: string): TUserList;
function GetOrders(searchOptions: string): TOrderList; function GetOrders(searchOptions: string): TOrderList;
function GetOrder(orderInfo: string): TFullOrder; function GetOrder(orderInfo: string): TFullOrder;
function GetCustomers(): TCustomerList; function GetCustomers(customerInfo:string): TCustomerList;
function GetCustomer(ID: string): TCustomerItem; function GetCustomer(ID: string): TCustomerItem;
function GetWebOrder(orderInfo: string): TWebOrder; function GetWebOrder(orderInfo: string): TWebOrder;
function GetCuttingDieOrder(orderInfo: string): TCuttingDie; function GetCuttingDieOrder(orderInfo: string): TCuttingDie;
function GetQBCustomers: TJSONArray; function GetQBCustomers: TJSONArray;
function GetQBItems: TJSONArray; function GetQBItems: TJSONArray;
function GetRepUsers(): TList<TUserItem>;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
...@@ -78,31 +79,279 @@ type ...@@ -78,31 +79,279 @@ type
function RefreshAccessToken: string; function RefreshAccessToken: string;
function ImportQBCustomer(CustomerInfo: string): TJSONObject; function ImportQBCustomer(CustomerInfo: string): TJSONObject;
procedure AddAddrBlock(prefix: string; AddrJSON: TJSONObject); procedure AddAddrBlock(prefix: string; AddrJSON: TJSONObject);
function AddEstimate(orderInfo: string): TJSONObject;
end; end;
implementation implementation
uses uses
System.Generics.Collections,
XData.Sys.Exceptions, uLibrary, rOrderWeb, rOrderCutting; XData.Sys.Exceptions, uLibrary, rOrderWeb, rOrderCutting;
function TLookupService.addEstimate(orderInfo: string): TJSONObject;
var
iniFile: TIniFile;
restClient: TRESTClient;
restRequest: TRESTRequest;
restResponse: TRESTResponse;
param: TRESTRequestParameter;
res: string;
i: integer;
jsValue: TJSONValue;
Customer: TJSONValue;
jsObj: TJSONObject;
CustomerList: TJSONArray;
pair: TJSONPair;
estimateJSON: TJSONObject;
SQL: string;
estimate: TEstimate;
CustomerRef: TRef;
CustomerRefJSON: TJSONObject;
Lines: TArray<string>;
BillAddr: TAddress;
BillAddrJSON: TJSONObject;
CustomField:TJSONObject;
CustomFields: TJSONArray;
ShipAddr: TAddress;
ShipAddrJSON: TJSONObject;
Items: TArray<TLine>;
ItemRef: TRef;
SalesItemLineDetail: TSalesItemLineDetail;
LineArray: TJSONArray;
LineObj, DetailObj, ItemRefObj: TJSONObject;
TaxCodeRef: TJSONObject;
TxnTaxCodeRef: TJSONObject;
TxnTaxDetail: TJSONObject;
JSONData: TJSONObject;
ORDER_ID, companyID, RefreshToken, AccessToken: string;
table, msg: string;
ShipMethodRef: TJSONObject;
LastRefresh: TDateTime;
unitPrice: double;
errorObj, faultObj: TJSONObject;
errorArray: TJSONArray;
begin
BillAddrJSON := TJSONObject.Create;
ShipAddrJSON := TJSONObject.Create;
EstimateJSON := TJSONObject.Create;
CustomerRefJSON := TJSONObject.Create;
CustomFields := TJSONArray.Create;
CustomField := TJSONObject.Create;
LineArray := TJSONArray.Create;
LineObj := TJSONObject.Create;
DetailObj := TJSONObject.Create;
ItemRefObj := TJSONObject.Create;
TaxCodeRef := TJSONObject.Create;
TxnTaxCodeRef := TJSONObject.Create;
TxnTaxDetail := TJSONObject.Create;
try
try
ORDER_ID := orderInfo;
SQL := 'select * from orders where ORDER_ID = ' + ORDER_ID;
doQuery(ordersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString = 'corrugated_plate' then
begin
table := 'corrugated_plate_orders';
end
else if ordersDB.UniQuery1.FieldByName('ORDER_TYPE').AsString = 'web_plate' then
begin
table := 'web_plate_orders';
end
else
table := 'cutting_die_orders';
SQL := 'select * from ' + table + ' cpo join customers c on cpo.COMPANY_ID = c.CUSTOMER_ID join customers_ship cs on cpo.staff_fields_ship_to = cs.ship_block JOIN qb_items ON cpo.staff_fields_quickbooks_item = qb_items.qb_item_name where cpo.ORDER_ID = ' + ORDER_ID;
doQuery(ordersDB.UniQuery1, SQL);
estimateJSON.AddPair('TxnDate', ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString);
CustomerRefJSON := TJSONObject.Create;
CustomerRefJSON.AddPair('value', ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString);
estimateJSON.AddPair('CustomerRef', CustomerRefJSON);
Lines := ordersDB.UniQuery1.FieldByName('staff_fields_invoice_to').AsString.Split([#10]);
for i := 0 to Length(Lines) - 2 do
begin
case i of
0: BillAddrJSON.AddPair('Line1', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
1: BillAddrJSON.AddPair('Line2', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
2: BillAddrJSON.AddPair('Line3', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
3: BillAddrJSON.AddPair('Line4', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
4: BillAddrJSON.AddPair('Line5', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
end;
end;
BillAddrJSON.AddPair('City', ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString);
BillAddrJSON.AddPair('CountrySubDivisionCode', ordersDB.UniQuery1.FieldByName('BILL_STATE').AsString);
BillAddrJSON.AddPair('PostalCode', ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString);
estimateJSON.AddPair('BillAddr', BillAddrJSON);
CustomField.AddPair('DefinitionId', '1');
CustomField.AddPair('Name', 'CUSTID');
CustomField.AddPair('Type', 'StringType');
CustomField.AddPair('StringValue', ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString);
CustomFields.AddElement(CustomField);
EstimateJSON.AddPair('CustomField', CustomFields);
Lines := ordersDB.UniQuery1.FieldByName('ship_block').AsString.Split([sLineBreak]);
for i := 0 to Length(Lines) - 2 do
begin
case i of
0: ShipAddrJSON.AddPair('Line1', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
1: ShipAddrJSON.AddPair('Line2', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
2: ShipAddrJSON.AddPair('Line3', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
3: ShipAddrJSON.AddPair('Line4', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
4: ShipAddrJSON.AddPair('Line5', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
end;
end;
ShipAddrJSON.AddPair('City', ordersDB.UniQuery1.FieldByName('city').AsString);
ShipAddrJSON.AddPair('CountrySubDivisionCode', ordersDB.UniQuery1.FieldByName('state').AsString);
ShipAddrJSON.AddPair('PostalCode', ordersDB.UniQuery1.FieldByName('zip').AsString);
estimateJSON.AddPair('ShipAddr', ShipAddrJSON);
// 🔹 Line object representing one line item
LineObj := TJSONObject.Create;
LineObj.AddPair('Description', ordersDB.UniQuery1.FieldByName('item_desc').AsString + ' - ' + ordersDB.UniQuery1.FieldByName('staff_fields_job_name').AsString);
LineObj.AddPair('Amount', TJSONNumber.Create(ordersDB.UniQuery1.FieldByName('staff_fields_price').AsFloat));
LineObj.AddPair('DetailType', 'SalesItemLineDetail');
ItemRefObj.AddPair('value', ordersDB.UniQuery1.FieldByName('qb_items_qb_id').AsString);
DetailObj.AddPair('ItemRef', ItemRefObj);
DetailObj.AddPair('Qty', TJSONNumber.Create(ordersDB.UniQuery1.FieldByName('staff_fields_quantity').AsFloat));
unitPrice := ordersDB.UniQuery1.FieldByName('staff_fields_price').AsFloat / ordersDB.UniQuery1.FieldByName('staff_fields_quantity').AsInteger;
DetailObj.AddPair('UnitPrice', TJSONNumber.Create(unitPrice));
LineObj.AddPair('SalesItemLineDetail', DetailObj);
LineArray.AddElement(LineObj);
EstimateJSON.AddPair('Line', LineArray);
if ordersDB.UniQuery1.FieldByName('staff_fields_ship_date').AsString <> '' then
begin
estimateJSON.AddPair('ShipDate', ordersDB.UniQuery1.FieldByName('staff_fields_ship_date').AsString)
end;
restClient := TRESTClient.Create(nil);
restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com';
restRequest := TRESTRequest.Create(nil);
restRequest.Client := restClient;
restResponse := TRESTResponse.Create(nil);
restRequest.Response := restResponse;
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
if iniFile.ReadString('Quickbooks', 'LastRefresh', '') = '' then
LastRefresh := 0
else
LastRefresh := StrToDateTime(iniFile.ReadString('Quickbooks', 'LastRefresh', ''));
if MinutesBetween(Now, LastRefresh) > 58 then
RefreshAccessToken();
CompanyID := iniFile.ReadString('Quickbooks', 'CompanyID', '');
RefreshToken := iniFile.ReadString('Quickbooks', 'RefreshToken', '');
AccessToken := iniFile.ReadString('Quickbooks', 'AccessToken', '');
restRequest.Method := rmPOST;
res := '/v3/company/' + companyID + '/estimate';
restRequest.Resource := res;
param := restRequest.Params.AddItem;
param.Name := 'Authorization';
param.Kind := pkHTTPHEADER;
param.Options := param.Options + [TRESTRequestParameterOption.poDoNotEncode];
param.Value := 'Bearer ' + AccessToken;
restRequest.AddBody(estimateJSON.ToJSON, TRESTContentType.ctAPPLICATION_JSON);
restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue).GetValue<TJSONObject>('Estimate');
sql := 'select * from orders where ORDER_ID = ' + ORDER_ID;
doQuery(ordersDB.UniQuery1, SQL);
ordersDB.UniQuery1.Edit;
ordersDB.UniQuery1.FieldByName('IN_QB').AsString := 'T';
ordersDB.UniQuery1.FieldByName('QB_ORDER_NUM').AsString := jsObj.GetValue<string>('DocNumber');
ordersDB.UniQuery1.FieldByName('QB_ESTIMATE_ID').AsString := jsObj.GetValue<string>('Id');
ordersDB.UniQuery1.FieldByName('QB_CREATE_DATE').AsDateTime := Now;
ordersDB.UniQuery1.Post;
result := TJSONObject.Create;
Result.AddPair('status','Success:Estimate Successfully Added');
except
on E: Exception do
begin
logger.Log(2, 'Error when adding Estimate ' + e.Message);
jsValue := restResponse.JSONValue;
if not (jsValue is TJSONObject) then
raise EXDataHttpException.Create(500, 'Unexpected response format');
jsObj := TJSONObject(jsValue);
try
faultObj := jsObj.GetValue<TJSONObject>('Fault');
errorArray := faultObj.GetValue<TJSONArray>('Error');
if (errorArray.Count > 0) and (errorArray.Items[0] is TJSONObject) then
begin
errorObj := TJSONObject(errorArray.Items[0]);
msg := errorObj.GetValue<string>('Detail');
end
else
msg := 'QuickBooks error array is empty.';
except
on E: Exception do
msg := 'Unable to parse QuickBooks error: ' + E.Message;
end;
logger.Log(2, 'QuickBooks Error Message: ' + msg);
raise EXDataHttpException.Create(500, 'Unable to add QuickBooks Estimate: A QuickBooks interface error has occurred!');
end;
end;
finally
iniFile.Free;
restClient.Free;
restRequest.Free;
restResponse.Free;
end;
end;
procedure TLookupService.AfterConstruction; procedure TLookupService.AfterConstruction;
begin begin
inherited; inherited;
ordersDB := TApiDatabase.Create(nil); ordersDB := TApiDatabase.Create(nil);
end; end;
procedure TLookupService.BeforeDestruction; procedure TLookupService.BeforeDestruction;
begin begin
ordersDB.Free; ordersDB.Free;
inherited; inherited;
end; end;
function TLookupService.DelShippingAddress(AddressID, CustomerID: string): TJSONObject; function TLookupService.DelShippingAddress(AddressID, CustomerID: string): TJSONObject;
var var
SQL: string; SQL: string;
...@@ -136,15 +385,38 @@ begin ...@@ -136,15 +385,38 @@ begin
end; end;
function TLookupService.GetCustomers: TCustomerList; function TLookupService.GetCustomers(customerInfo: string): TCustomerList;
// Retrieves a list of customers and sends it to the client in object form. // Retrieves a list of customers and sends it to the client in object form.
// The object contains the ID, Name, Short Name, and the shipping address. // The object contains the ID, Name, Short Name, and the shipping address.
var var
SQL: string; SQL, limitSQL: string;
customer: TCustomerItem; customer: TCustomerItem;
params: TStringList;
PageNum, PageSize: integer;
offset,limit: string;
begin begin
params := TStringList.Create;
params.StrictDelimiter := true;
params.Delimiter := '&';
params.DelimitedText := customerInfo;
PageSize := 0;
PageNum := 0;
if (params.Values['pagenumber'] <> '') then
PageNum := StrToInt(params.Values['pagenumber']);
if params.Values['pagesize'] <> '' then
PageSize := StrToInt(params.Values['pagesize']);
if ( ( PageSize <> 0 ) and (PageNum <> 0 ) ) then
begin
offset := IntToStr((PageNum - 1) * PageSize);
limit := IntToStr(PageSize);
limitSQL := ' limit ' + limit + ' offset ' + offset;
end;
try try
SQL := 'select * from customers'; SQL := 'select * from customers' + limitSQL;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerList.Create; result := TCustomerList.Create;
...@@ -167,15 +439,18 @@ begin ...@@ -167,15 +439,18 @@ begin
customer.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString; customer.START_DATE := ordersDB.UniQuery1.FieldByName('START_DATE').AsString;
result.data.Add(customer); result.data.Add(customer);
result.count := result.count + 1;
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
ordersDB.UniQuery1.Close; ordersDB.UniQuery1.Close;
SQL := 'SELECT COUNT(*) AS total_count from customers';
doQuery(ordersDB.UniQuery1, SQL);
Result.count := ordersDB.UniQuery1.FieldByName('total_count').AsInteger;
ordersDB.UniQuery1.Close;
except except
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in GetCustomers: ' + E.Message); Logger.Log(2, 'Error in GetCustomers: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve customer list: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve customer list: A KG Orders Database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -183,7 +458,7 @@ end; ...@@ -183,7 +458,7 @@ end;
function TLookupService.GetCustomer(ID: string): TCustomerItem; function TLookupService.GetCustomer(ID: string): TCustomerItem;
// Gets one specific customer from the ID given by the client. This is used for // Gets one specific customer from the ID given by the client. This is used for
// the OrderEntry forms. // the AddCustomer form and Order Entry Forms.
var var
SQL: string; SQL: string;
ADDRESS: TAddressItem; ADDRESS: TAddressItem;
...@@ -196,8 +471,7 @@ begin ...@@ -196,8 +471,7 @@ begin
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 LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + ID;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerItem.Create; result := TCustomerItem.Create;
result.ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.ADDRESS_LIST );
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger; result.CUSTOMER_ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
...@@ -216,6 +490,8 @@ begin ...@@ -216,6 +490,8 @@ begin
result.FFAX := ordersDB.UniQuery1.FieldByName('FAX').AsString; result.FFAX := ordersDB.UniQuery1.FieldByName('FAX').AsString;
result.REP_USER_ID := ordersDB.UniQuery1.FieldByName('REP_USER_ID').AsString; result.REP_USER_ID := ordersDB.UniQuery1.FieldByName('REP_USER_ID').AsString;
result.SHIPPING_ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.SHIPPING_ADDRESS_LIST );
while not ordersDB.UniQuery1.Eof do while not ordersDB.UniQuery1.Eof do
begin begin
ADDRESS := TAddressItem.Create; ADDRESS := TAddressItem.Create;
...@@ -227,16 +503,27 @@ begin ...@@ -227,16 +503,27 @@ begin
ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString; ADDRESS.zip := ordersDB.UniQuery1.FieldByName('zip').AsString;
ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString; ADDRESS.contact := ordersDB.UniQuery1.FieldByName('contact').AsString;
ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString; ADDRESS.ship_id := ordersDB.UniQuery1.FieldByName('customer_ship_id').AsString;
result.ADDRESS_LIST.Add(ADDRESS); result.SHIPPING_ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
ordersDB.UniQuery1.Close; except
on E: Exception do
result.ITEMS := GetItems(''); begin
Logger.Log(2, 'Error in GetCustomer: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve customer: A KG Orders database issue has occurred!');
end;
end;
end;
function TLookupService.GetRepUsers: TList<TUserItem>;
// Gets a list of users that qualify to be reps for companies
var
USER: TUserItem;
SQL: string;
begin
SQL := 'SELECT USER_ID, NAME from users where QB_ID IS NOT NULL AND QB_ID <> ' + quotedStr(''); SQL := 'SELECT USER_ID, NAME from users where QB_ID IS NOT NULL AND QB_ID <> ' + quotedStr('');
result.USERS := TList<TUserItem>.Create; result := TList<TUserItem>.Create;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
while not ordersDB.UniQuery1.Eof do while not ordersDB.UniQuery1.Eof do
begin begin
...@@ -244,20 +531,14 @@ begin ...@@ -244,20 +531,14 @@ begin
TXDataOperationContext.Current.Handler.ManagedObjects.Add( USER ); TXDataOperationContext.Current.Handler.ManagedObjects.Add( USER );
USER.userID := ordersDB.UniQuery1.FieldByName('USER_ID').AsString; USER.userID := ordersDB.UniQuery1.FieldByName('USER_ID').AsString;
USER.full_name := ordersDB.UniQuery1.FieldByName('NAME').AsString; USER.full_name := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.USERS.Add(USER); result.Add(USER);
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
except
on E: Exception do
begin
Logger.Log(2, 'Error in GetCustomer: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve customer: ' + E.Message);
end;
end;
end; end;
function TLookupService.GenerateOrderListPDF(searchOptions: string): string; function TLookupService.GenerateOrderListPDF(searchOptions: string): string;
// Generates a PDF for the Order Page
var var
SQL: string; SQL: string;
rptOrderList: TrptOrderList; rptOrderList: TrptOrderList;
...@@ -295,7 +576,10 @@ begin ...@@ -295,7 +576,10 @@ begin
Logger.log(5, 'PDF Report successfully generated for searchOptions: ' + params.DelimitedText); Logger.log(5, 'PDF Report successfully generated for searchOptions: ' + params.DelimitedText);
except except
on E: Exception do on E: Exception do
raise EXDataHttpException.Create(500, 'Failed to generate PDF: ' + E.Message); begin
logger.Log(2, 'An error has occurred in TLookupServiceImpl.GenerateOrderListPDF: ' + E.Message);
raise EXDataHttpException.Create(500, 'Failed to generate PDF: A KG Orders database issue has occurred!');
end;
end; end;
finally finally
rptOrderList.Free; rptOrderList.Free;
...@@ -532,7 +816,7 @@ begin ...@@ -532,7 +816,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(1, 'Error generating corrugated PDF: ' + E.Message); Logger.Log(1, 'Error generating corrugated PDF: ' + E.Message);
raise EXDataHttpException.Create(500, 'Error generating corrugated PDF: ' + E.Message); raise EXDataHttpException.Create(500, 'Error generating corrugated PDF: A KG Orders database issue has occurred!');
end; end;
end; end;
finally finally
...@@ -561,7 +845,7 @@ begin ...@@ -561,7 +845,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(1, 'Error generating web PDF: ' + E.Message); Logger.Log(1, 'Error generating web PDF: ' + E.Message);
raise EXDataHttpException.Create(500, 'Error generating web PDF: ' + E.Message); raise EXDataHttpException.Create(500, 'Error generating web PDF: A KG Orders database issue has occurred!');
end; end;
end; end;
finally finally
...@@ -589,7 +873,7 @@ begin ...@@ -589,7 +873,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(1, 'Error generating cutting die PDF: ' + E.Message); Logger.Log(1, 'Error generating cutting die PDF: ' + E.Message);
raise EXDataHttpException.Create(500, 'Error generating cutting die PDF: ' + E.Message); raise EXDataHttpException.Create(500, 'Error generating cutting die PDF: A KG Orders database issue has occurred!');
end; end;
end; end;
finally finally
...@@ -760,7 +1044,7 @@ begin ...@@ -760,7 +1044,7 @@ begin
status1 := createStatusSearchInfo(params, '1'); status1 := createStatusSearchInfo(params, '1');
status2 := createStatusSearchInfo(params, '2'); status2 := createStatusSearchInfo(params, '2');
SQL := 'SELECT o.ORDER_ID, c.SHORT_NAME, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_TYPE, ' + SQL := 'SELECT o.ORDER_ID, c.SHORT_NAME, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_TYPE, o.IN_QB, o.QB_ORDER_NUM,' +
generateSubquery('PROOF') + generateSubquery('PROOF') +
generateSubquery('ART') + generateSubquery('ART') +
generateSubquery('PLATE') + generateSubquery('PLATE') +
...@@ -870,6 +1154,7 @@ begin ...@@ -870,6 +1154,7 @@ begin
with ordersDB.UniQuery1 do with ordersDB.UniQuery1 do
begin begin
Order.DBID := FieldByName('ORDER_ID').AsString; Order.DBID := FieldByName('ORDER_ID').AsString;
Order.In_QB := FieldByName('IN_QB').AsString;
Order.ID := FieldByName('SHORT_NAME').AsString; Order.ID := FieldByName('SHORT_NAME').AsString;
Order.companyName := FieldByName('COMPANY_NAME').AsString; Order.companyName := FieldByName('COMPANY_NAME').AsString;
Order.jobName := FieldByName('JOB_NAME').AsString; Order.jobName := FieldByName('JOB_NAME').AsString;
...@@ -885,7 +1170,7 @@ begin ...@@ -885,7 +1170,7 @@ begin
Order.shipDue := FieldByName('SHIP_DUE').AsString; Order.shipDue := FieldByName('SHIP_DUE').AsString;
Order.shipDone := FieldByName('SHIP_DONE').AsString; Order.shipDone := FieldByName('SHIP_DONE').AsString;
Order.price := FieldByName('PRICE').AsString; Order.price := FieldByName('PRICE').AsString;
Order.qbRefNum := FieldByName('QB_REF_NUM').AsString; Order.qbRefNum := FieldByName('QB_ORDER_NUM').AsString;
Order.orderType := FieldByName('ORDER_TYPE').AsString.Replace('_', ' '); Order.orderType := FieldByName('ORDER_TYPE').AsString.Replace('_', ' ');
end; end;
...@@ -918,7 +1203,7 @@ begin ...@@ -918,7 +1203,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in GetOrders: ' + E.Message); Logger.Log(2, 'Error in GetOrders: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve order list: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve order list: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -1131,7 +1416,7 @@ begin ...@@ -1131,7 +1416,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in GetOrder: ' + E.Message); Logger.Log(2, 'Error in GetOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve order: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve corrugated order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -1274,7 +1559,7 @@ begin ...@@ -1274,7 +1559,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in GetWebOrder: ' + E.Message); Logger.Log(2, 'Error in GetWebOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve web order: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve web order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -1289,16 +1574,18 @@ var ...@@ -1289,16 +1574,18 @@ var
begin begin
try try
orderID := orderInfo; orderID := orderInfo;
SQL := 'select * from cutting_die_orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = ' + quotedStr(orderID); SQL := 'select * from cutting_die_orders cdo JOIN customers c ON c.CUSTOMER_ID = cdo.COMPANY_ID join orders o on cdo.ORDER_ID = o.ORDER_ID where cdo.ORDER_ID = ' + quotedStr(orderID);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
result := TCuttingDie.Create; result := TCuttingDie.Create;
// Company // Company
result.ORDER_ID := ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger;
result.COMPANY_ID := ordersDB.UniQuery1.FieldByName('COMPANY_ID').AsInteger; result.COMPANY_ID := ordersDB.UniQuery1.FieldByName('COMPANY_ID').AsInteger;
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString; result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
result.inQuickBooks := '?'; result.IN_QB := ordersDB.UniQuery1.FieldByName('IN_QB').AsString;
result.QB_ORDER_NUM := ordersDB.UniQuery1.FieldByName('QB_ORDER_NUM').AsString;
// Staff Fields // Staff Fields
result.staff_fields_order_date := ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString; result.staff_fields_order_date := ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString;
...@@ -1317,27 +1604,11 @@ begin ...@@ -1317,27 +1604,11 @@ begin
ordersDB.UniQuery1.Close; ordersDB.UniQuery1.Close;
SQL := 'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + IntToStr(result.COMPANY_ID);
doQuery(ordersDB.UniQuery1, SQL);
result.ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( result.ADDRESS_LIST );
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TAddressItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( ADDRESS );
ADDRESS.ADDRESS := ordersDB.UniQuery1.FieldByName('ship_block').AsString;
result.ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
ordersDB.UniQuery1.Close;
result.ITEMS := GetItems('');
except except
on E: Exception do on E: Exception do
begin begin
raise EXDataHttpException.Create(500, 'Could not retrieve cutting die order: ' + E.Message); logger.Log(2, 'An Error has occurred in TLookupSerivceImpl.GetCuttingDieOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Could not retrieve cutting die order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -1393,6 +1664,7 @@ begin ...@@ -1393,6 +1664,7 @@ begin
item.name := ordersDB.UniQuery1.FieldByName('qb_item_name').AsString; item.name := ordersDB.UniQuery1.FieldByName('qb_item_name').AsString;
item.description := ordersDB.UniQuery1.FieldByName('item_desc').AsString; item.description := ordersDB.UniQuery1.FieldByName('item_desc').AsString;
item.status := ordersDB.UniQuery1.FieldByName('status').AsString; item.status := ordersDB.UniQuery1.FieldByName('status').AsString;
item.QB_ID := ordersDB.UniQuery1.FieldByName('qb_items_qb_id').AsString;
ordersDB.UniQuery1.Next; ordersDB.UniQuery1.Next;
end; end;
...@@ -1405,7 +1677,7 @@ begin ...@@ -1405,7 +1677,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in GetItems: ' + E.Message); Logger.Log(2, 'Error in GetItems: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve item list: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve item list:A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -1471,10 +1743,8 @@ begin ...@@ -1471,10 +1743,8 @@ begin
on E: Exception do on E: Exception do
begin begin
ordersDB.UniQuery1.Close; ordersDB.UniQuery1.Close;
raise EXDataHttpException.Create( logger.Log(2, 'An error has occurred in TLookupServiceImpl.GetUsers: ' + E.Message);
500, raise EXDataHttpException.Create(500,'Unable to retrieve users: A KG Orders database issue has occurred!');
'Unable to retrieve users: ' + E.Message
);
end; end;
end; end;
end; end;
...@@ -1702,7 +1972,8 @@ begin ...@@ -1702,7 +1972,8 @@ begin
except except
on E: Exception do on E: Exception do
begin begin
Result := TJSONObject.Create.AddPair('error', E.Message); Logger.Log(2, 'Error in AddCorrugatedOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to add or edit web order: A KG Orders database issue has occurred!');
end end
end; end;
end; end;
...@@ -1968,7 +2239,10 @@ begin ...@@ -1968,7 +2239,10 @@ begin
Result := 'Failure: Username already taken'; Result := 'Failure: Username already taken';
except except
on E: Exception do on E: Exception do
raise EXDataHttpException.Create(500, 'AddUser failed: ' + E.Message); begin
logger.Log(2, 'An error occurred in TlookupServiceImpl.AddUser: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to Add User: A KG Orders database issue has occurred!');
end;
end; end;
end; end;
...@@ -1981,10 +2255,13 @@ var ...@@ -1981,10 +2255,13 @@ var
JSONData: TJSONObject; JSONData: TJSONObject;
Name: string; Name: string;
Description, mode: string; Description, mode: string;
Status: boolean; Status: string;
SQL: string; SQL: string;
ID: string;
begin begin
try
logger.Log(1, 'Add Item Hit');
result := TJSONObject.Create; result := TJSONObject.Create;
JSONData := TJSONObject.ParseJSONValue(itemInfo) as TJSONObject; JSONData := TJSONObject.ParseJSONValue(itemInfo) as TJSONObject;
if JSONData = nil then if JSONData = nil then
...@@ -1993,12 +2270,13 @@ begin ...@@ -1993,12 +2270,13 @@ begin
Name := JSONData.GetValue<string>('qb_item_name'); Name := JSONData.GetValue<string>('qb_item_name');
Description := JSONData.GetValue<string>('item_desc'); Description := JSONData.GetValue<string>('item_desc');
Status := StrToBool(JSONData.GetValue<string>('status')); ID := JSONData.GetValue<string>('qb_items_id');
Status := JSONData.GetValue<string>('status');
SQL := 'select * from qb_items where qb_item_name = ' + QuotedStr(Name);
if mode = 'ADD' then if mode = 'ADD' then
begin begin
SQL := 'select * from qb_items where qb_item_name = ' + QuotedStr(Name);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
if true then //ordersDB.UniQuery1.IsEmpty then if true then //ordersDB.UniQuery1.IsEmpty then
begin begin
...@@ -2006,18 +2284,41 @@ begin ...@@ -2006,18 +2284,41 @@ begin
ordersDB.UniQuery1.FieldByName('qb_item_name').AsString := Name; ordersDB.UniQuery1.FieldByName('qb_item_name').AsString := Name;
ordersDB.UniQuery1.FieldByName('item_desc').AsString := Description; ordersDB.UniQuery1.FieldByName('item_desc').AsString := Description;
if status then ordersDB.UniQuery1.FieldByName('status').AsString := status;
ordersDB.UniQuery1.FieldByName('status').AsString := 'ACTIVE'
else
ordersDB.UniQuery1.FieldByName('status').AsString := 'INACTIVE';
ordersDB.UniQuery1.FieldByName('qb_items_qb_id').AsString := JSONData.GetValue<string>('qb_items_qb_id'); ordersDB.UniQuery1.FieldByName('qb_items_qb_id').AsString := JSONData.GetValue<string>('qb_items_qb_id');
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
Result.AddPair('msg', 'Success: Item successfully added'); Result.AddPair('msg', 'Success: Item successfully added');
Result.AddPair('description', ordersDB.UniQuery1.FieldByName('item_desc').AsString);
Result.AddPair('name', ordersDB.UniQuery1.FieldByName('qb_item_name').AsString);
Result.AddPair('status', ordersDB.UniQuery1.FieldByName('status').AsString);
end end
else else
Result.AddPair('msg', 'Failure: Item already exists'); Result.AddPair('msg', 'Failure: Item already exists');
end
else
begin
SQL := 'select * from qb_items where qb_items_id = ' + ID;
doQuery(ordersDB.UniQuery1, SQL);
if ( not ordersDB.UniQuery1.IsEmpty ) then
begin
ordersDB.UniQuery1.Edit;
ordersDB.UniQuery1.FieldByName('qb_item_name').AsString := Name;
ordersDB.UniQuery1.FieldByName('item_desc').AsString := Description;
ordersDB.UniQuery1.FieldByName('status').AsString := status;
ordersDB.UniQuery1.Post;
Result.AddPair('msg', 'Success: Item successfully edited');
end;
end;
except
on E: Exception do
logger.Log(5, 'An error occurred when adding an item: ' + E.Message);
end; end;
end; end;
...@@ -2068,14 +2369,14 @@ begin ...@@ -2068,14 +2369,14 @@ begin
DateFormat.DateSeparator := '-'; DateFormat.DateSeparator := '-';
JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject; JSONData := TJSONObject.ParseJSONValue(orderInfo) as TJSONObject;
if JSONData = nil then if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception raise Exception.Create('Invalid JSON format');
mode := JSONData.GetValue<string>('mode'); mode := JSONData.GetValue<string>('mode');
AddToOrdersTable(mode, 'web_plate', JSONData); AddToOrdersTable(mode, 'web_plate', JSONData);
if mode = 'ADD' then if mode = 'ADD' then
begin begin
ordersDB.UniQuery1.SQL.Text := 'SELECT LAST_INSERT_ID() AS OrderID'; // Use database's method to get the last inserted ID ordersDB.UniQuery1.SQL.Text := 'SELECT LAST_INSERT_ID() AS OrderID';
ordersDB.UniQuery1.Open; ordersDB.UniQuery1.Open;
ORDER_ID := ordersDB.UniQuery1.FieldByName('OrderID').AsInteger; ORDER_ID := ordersDB.UniQuery1.FieldByName('OrderID').AsInteger;
end; end;
...@@ -2098,10 +2399,9 @@ begin ...@@ -2098,10 +2399,9 @@ begin
for Pair in JSONData do for Pair in JSONData do
begin begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value);
if Assigned(Field) then if Assigned(Field) then
begin begin
// handles any dates or datetimes
if (Field is TDateTimeField) then if (Field is TDateTimeField) then
begin begin
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
...@@ -2116,7 +2416,6 @@ begin ...@@ -2116,7 +2416,6 @@ begin
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := ORDER_ID; ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := ORDER_ID;
// Post the record to the database
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then if ( JSONData.GetValue<string>('staff_fields_proof_date') <> '' ) and ( JSONData.GetValue<string>('staff_fields_proof_date') <> '12/30/1899' ) then
...@@ -2142,7 +2441,7 @@ begin ...@@ -2142,7 +2441,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in AddWebOrder: ' + E.Message); Logger.Log(2, 'Error in AddWebOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to add or edit web order: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to add or edit web order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -2159,6 +2458,8 @@ var ...@@ -2159,6 +2458,8 @@ var
ORDER_ID: integer; ORDER_ID: integer;
mode: string; mode: string;
msg: string; msg: string;
temp: string;
temp2: boolean;
begin begin
DateFormat := TFormatSettings.Create; DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd'; DateFormat.ShortDateFormat := 'yyyy-mm-dd';
...@@ -2204,8 +2505,10 @@ begin ...@@ -2204,8 +2505,10 @@ begin
else else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value); TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
end end
else if Field is TStringField then
Field.AsString := Pair.JsonValue.Value
else else
Field.AsString := Pair.JsonValue.Value; Field.AsInteger := pair.JsonValue.AsType<Integer>;
end; end;
end; end;
...@@ -2226,14 +2529,15 @@ begin ...@@ -2226,14 +2529,15 @@ begin
else else
msg := 'Success: Order Successfully Edited'; msg := 'Success: Order Successfully Edited';
Result := TJSONObject.Create.AddPair('status', msg); Result := JSONData;
Result.AddPair('OrderID', ORDER_ID); Result.AddPair('status', msg);
Result.AddPair('ORDER_ID', ORDER_ID);
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except except
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in AddCuttingDieOrder: ' + E.Message); Logger.Log(2, 'Error in AddCuttingDieOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to add cutting die order: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to add cutting die order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -2363,7 +2667,7 @@ begin ...@@ -2363,7 +2667,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in delOrder: ' + E.Message); Logger.Log(2, 'Error in delOrder: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to delete order: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to delete order: A KG Orders database issue has occurred!');
end; end;
end; end;
end; end;
...@@ -2408,8 +2712,11 @@ begin ...@@ -2408,8 +2712,11 @@ begin
Field.Clear // This sets the field to NULL (empty) Field.Clear // This sets the field to NULL (empty)
else else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value) TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value)
else if Pair.JsonValue.Value <> '' then else if ( ( field is TStringField ) and ( Pair.JsonValue.Value <> '' ) ) then
Field.AsString := Pair.JsonValue.Value; Field.AsString := Pair.JsonValue.Value
else if field is TIntegerField then
Field.AsInteger := Pair.JsonValue.AsType<Integer>;
end; end;
end; end;
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsString := OrderID; ordersDB.UniQuery1.FieldByName('ORDER_ID').AsString := OrderID;
...@@ -2418,7 +2725,7 @@ begin ...@@ -2418,7 +2725,7 @@ begin
// End Area // End Area
ordersDB.UniQuery1.FieldByName('ORDER_STATUS').AsString := 'ACTIVE'; ordersDB.UniQuery1.FieldByName('ORDER_STATUS').AsString := 'ACTIVE';
ordersDB.UniQuery1.FieldByName('REVISION_NUMBER').AsInteger := 1; ordersDB.UniQuery1.FieldByName('REVISION_NUMBER').AsInteger := rev_num;
ordersDB.UniQuery1.FieldByName('ORDER_REVISION_ID').AsInteger := RevisionID; ordersDB.UniQuery1.FieldByName('ORDER_REVISION_ID').AsInteger := RevisionID;
ordersDB.UniQuery1.FieldByName('REVISION_USER_ID').AsString := order.GetValue<string>('USER_ID'); ordersDB.UniQuery1.FieldByName('REVISION_USER_ID').AsString := order.GetValue<string>('USER_ID');
// Post the record to the database // Post the record to the database
...@@ -2437,6 +2744,7 @@ var ...@@ -2437,6 +2744,7 @@ var
jsValue: TJSONValue; jsValue: TJSONValue;
ParsedCustomer, Customer, BillAddr: TJSONObject; ParsedCustomer, Customer, BillAddr: TJSONObject;
jsObj: TJSONObject; jsObj: TJSONObject;
PhoneObj: TJSONObject;
CustomerList: TJSONArray; CustomerList: TJSONArray;
AccessToken, RefreshToken, CompanyID, Client, Secret: string; AccessToken, RefreshToken, CompanyID, Client, Secret: string;
LastRefresh: TDateTime; LastRefresh: TDateTime;
...@@ -2505,6 +2813,8 @@ begin ...@@ -2505,6 +2813,8 @@ begin
ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty)); ParsedCustomer.AddPair('In KGOrders', not(ordersDB.UniQuery1.IsEmpty));
ParsedCustomer.AddPair('Id', Customer.GetValue<string>('Id')); ParsedCustomer.AddPair('Id', Customer.GetValue<string>('Id'));
ParsedCustomer.AddPair('CompanyName', Customer.GetValue<string>('DisplayName')); ParsedCustomer.AddPair('CompanyName', Customer.GetValue<string>('DisplayName'));
if Customer.TryGetValue<TJSONObject>('PrimaryPhone', PhoneObj) then
ParsedCustomer.AddPair('PrimaryPhone', PhoneObj.GetValue<string>('FreeFormNumber'));
// Handle Bill Address // Handle Bill Address
if Customer.GetValue('BillAddr') is TJSONObject then if Customer.GetValue('BillAddr') is TJSONObject then
...@@ -2554,7 +2864,7 @@ begin ...@@ -2554,7 +2864,7 @@ begin
on E: Exception do on E: Exception do
begin begin
Logger.Log(2, 'Error in getQBCustomers: ' + E.Message); Logger.Log(2, 'Error in getQBCustomers: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks customers: ' + E.Message); raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!');
end; end;
end; end;
finally finally
...@@ -2584,6 +2894,12 @@ var ...@@ -2584,6 +2894,12 @@ var
LastRefresh: TDateTime; LastRefresh: TDateTime;
iniFile: TIniFile; iniFile: TIniFile;
begin begin
iniFile := nil;
restClient := nil;
restRequest := nil;
restResponse := nil;
try
try
Result := TJSONArray.Create; Result := TJSONArray.Create;
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini'); iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
restClient := TRESTClient.Create(nil); restClient := TRESTClient.Create(nil);
...@@ -2592,7 +2908,6 @@ begin ...@@ -2592,7 +2908,6 @@ begin
restRequest.Client := restClient; restRequest.Client := restClient;
restRequest.Response := restResponse; restRequest.Response := restResponse;
if iniFile.ReadString('Quickbooks', 'LastRefresh', '') = '' then if iniFile.ReadString('Quickbooks', 'LastRefresh', '') = '' then
LastRefresh := 0 LastRefresh := 0
else else
...@@ -2609,17 +2924,10 @@ begin ...@@ -2609,17 +2924,10 @@ begin
restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com'; restClient.BaseURL := 'https://sandbox-quickbooks.api.intuit.com';
if MinutesBetween(Now, LastRefresh) > 58 then
begin
RefreshAccessToken();
end;
restRequest.Method := rmGET; restRequest.Method := rmGET;
res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75'; res := '/v3/company/' + companyID + '/query?query=select * from Item&minorversion=75';
restRequest.Resource := res; restRequest.Resource := res;
param := restRequest.Params.AddItem; param := restRequest.Params.AddItem;
param.Name := 'Authorization'; param.Name := 'Authorization';
param.Kind := pkHTTPHEADER; param.Kind := pkHTTPHEADER;
...@@ -2628,43 +2936,47 @@ begin ...@@ -2628,43 +2936,47 @@ begin
restRequest.Execute; restRequest.Execute;
//memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue; jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue); jsObj := TJSONObject(jsValue);
//CustomerList := TJSONArray(restResponse.JSONValue); ItemList := TJSONArray(TJSONObject(jsObj.GetValue('QueryResponse')).GetValue('Item'));
//Memo1.Lines.Add( jsObj.Format(2) );
ItemList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Item'));
for I := 0 to ItemList.Count - 1 do for I := 0 to ItemList.Count - 1 do
begin begin
Item := ItemList.Items[I] as TJSONObject; Item := ItemList.Items[I] as TJSONObject;
ParsedItem := TJSONObject.Create; ParsedItem := TJSONObject.Create;
SQL := 'select qb_items_id from qb_items where qb_item_name = ' + quotedStr(Item.GetValue<string>('Name')); SQL := 'select qb_items_id from qb_items where qb_item_name = ' + QuotedStr(Item.GetValue<string>('Name'));
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
ParsedItem.AddPair('qb_items_id', ordersDB.UniQuery1.FieldByName('qb_items_id').AsString); ParsedItem.AddPair('qb_items_id', ordersDB.UniQuery1.FieldByName('qb_items_id').AsString);
ParsedItem.AddPair('qb_item_name', item.GetValue<string>('Name')); ParsedItem.AddPair('qb_item_name', Item.GetValue<string>('Name'));
if item.TryGetValue<string>('Description', desc) then if Item.TryGetValue<string>('Description', desc) then
ParsedItem.AddPair('item_desc', desc) ParsedItem.AddPair('item_desc', desc)
else else
ParsedItem.AddPair('item_desc', 'N/A'); ParsedItem.AddPair('item_desc', 'N/A');
ParsedItem.AddPair('status', item.GetValue<string>('Active')); ParsedItem.AddPair('status', Item.GetValue<string>('Active'));
ParsedItem.AddPair('qb_items_qb_id', item.GetValue<string>('Id')); ParsedItem.AddPair('qb_items_qb_id', Item.GetValue<string>('Id'));
Result.AddElement(ParsedItem); Result.AddElement(ParsedItem);
end; end;
// Load customer info except
on E: Exception do
begin
Logger.Log(2, 'Error in getQBCustomers: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Items: A QuickBooks interface error has occurred!');
end;
end;
finally
iniFile.Free;
restClient.Free; restClient.Free;
restRequest.Free; restRequest.Free;
restResponse.Free; restResponse.Free;
iniFile.Free end;
end; end;
procedure TLookupService.AddAddrBlock(prefix: string; AddrJSON: TJSONObject); procedure TLookupService.AddAddrBlock(prefix: string; AddrJSON: TJSONObject);
// the point of this function would be to save space in import QB Customer // the point of this function would be to save space in import QB Customer
begin begin
......
...@@ -162,9 +162,8 @@ type ...@@ -162,9 +162,8 @@ type
procedure addEstimate(orderInfo: string); procedure addEstimate(orderInfo: string);
procedure getQBCustomers(); procedure getQBCustomers();
procedure ShowDeleteConfirm(msg: string); procedure ShowDeleteConfirm(msg: string);
procedure ShowLinkConfirm(msg: string);
procedure DeleteCustomers(); procedure DeleteCustomers();
procedure LinkCustomers(); procedure LinkCustomer();
end; end;
var var
...@@ -221,37 +220,39 @@ begin ...@@ -221,37 +220,39 @@ begin
else else
begin begin
msg := 'Are you sure you want to link QB ID: ' + QB_ID + ' with KG Orders ID: ' + ID; msg := 'Are you sure you want to link QB ID: ' + QB_ID + ' with KG Orders ID: ' + ID;
ShowLinkConfirm(msg); if MessageDlg(msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
// User confirmed
LinkCustomer();
end
else
begin
// User canceled
ShowMessage('Cancelled.');
end;
end; end;
end; end;
procedure TfQB.LinkCustomers(); procedure TfQB.LinkCustomer();
var var
sql: string; sql: string;
begin begin
sql := 'select QB_LIST_ID from customers where CUSTOMER_ID = ' + ID; sql := 'select * from customers where CUSTOMER_ID = ' + ID;
Memo1.Lines.Add('SQL: ' + SQL);
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.RecordCount = 1 then
begin
ordersDB.UniQuery1.Edit; ordersDB.UniQuery1.Edit;
ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString := QB_ID; ordersDB.UniQuery1.FieldByName('QB_LIST_ID').AsString := QB_ID;
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
getCustomers(); getCustomers();
QB_ID := ''; QB_ID := '';
ID := ''; ID := '';
end;
procedure TfQB.ShowLinkConfirm(msg: string);
begin
if MessageDlg(msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
// User confirmed
LinkCustomers();
end end
else else
begin MessageDlg('Wrong # of records return', mtConfirmation, [mbOk], 0)
// User canceled
ShowMessage('Cancelled.');
end;
end; end;
procedure TfQB.Button11Click(Sender: TObject); procedure TfQB.Button11Click(Sender: TObject);
var var
restClient: TRESTClient; restClient: TRESTClient;
...@@ -550,7 +551,7 @@ var ...@@ -550,7 +551,7 @@ var
orderJSON: TJSONObject; orderJSON: TJSONObject;
begin begin
orderJSON := TJSONObject.Create; orderJSON := TJSONObject.Create;
orderJSON.AddPair('ORDER_ID', '19814'); orderJSON.AddPair('ORDER_ID', '19842');
addEstimate(orderJSON.ToString); addEstimate(orderJSON.ToString);
end; end;
...@@ -591,6 +592,7 @@ var ...@@ -591,6 +592,7 @@ var
ORDER_ID: string; ORDER_ID: string;
table: string; table: string;
ShipMethodRef: TJSONObject; ShipMethodRef: TJSONObject;
unitPrice: double;
begin begin
BillAddrJSON := TJSONObject.Create; BillAddrJSON := TJSONObject.Create;
ShipAddrJSON := TJSONObject.Create; ShipAddrJSON := TJSONObject.Create;
...@@ -637,15 +639,15 @@ begin ...@@ -637,15 +639,15 @@ begin
; ;
estimateJSON.AddPair('CustomerRef', CustomerRefJSON); estimateJSON.AddPair('CustomerRef', CustomerRefJSON);
Lines := ordersDB.UniQuery1.FieldByName('staff_fields_invoice_to').AsString.Split([sLineBreak]); Lines := ordersDB.UniQuery1.FieldByName('staff_fields_invoice_to').AsString.Split([#10]);
for i := 0 to Length(Lines) - 2 do for i := 0 to Length(Lines) - 2 do
begin begin
case i of case i of
0: BillAddrJSON.AddPair('Line1', Lines[0]); 0: BillAddrJSON.AddPair('Line1', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
1: BillAddrJSON.AddPair('Line2', Lines[1]); 1: BillAddrJSON.AddPair('Line2', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
2: BillAddrJSON.AddPair('Line3', Lines[2]); 2: BillAddrJSON.AddPair('Line3', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
3: BillAddrJSON.AddPair('Line4', Lines[3]); 3: BillAddrJSON.AddPair('Line4', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
4: BillAddrJSON.AddPair('Line5', Lines[4]); 4: BillAddrJSON.AddPair('Line5', Lines[i].Trim.Replace(#13, '').Replace(#10, ''));
end; end;
end; end;
...@@ -700,7 +702,10 @@ begin ...@@ -700,7 +702,10 @@ begin
DetailObj.AddPair('ItemRef', ItemRefObj); DetailObj.AddPair('ItemRef', ItemRefObj);
DetailObj.AddPair('Qty', TJSONNumber.Create(ordersDB.UniQuery1.FieldByName('staff_fields_quantity').AsFloat)); DetailObj.AddPair('Qty', TJSONNumber.Create(ordersDB.UniQuery1.FieldByName('staff_fields_quantity').AsFloat));
DetailObj.AddPair('UnitPrice', TJSONNumber.Create(ordersDB.UniQuery1.FieldByName('staff_fields_price').AsFloat));
unitPrice := ordersDB.UniQuery1.FieldByName('staff_fields_price').AsFloat / ordersDB.UniQuery1.FieldByName('staff_fields_quantity').AsInteger;
DetailObj.AddPair('UnitPrice', TJSONNumber.Create(unitPrice));
LineObj.AddPair('SalesItemLineDetail', DetailObj); LineObj.AddPair('SalesItemLineDetail', DetailObj);
LineArray.AddElement(LineObj); LineArray.AddElement(LineObj);
......
...@@ -184,7 +184,6 @@ var ...@@ -184,7 +184,6 @@ var
items: TJSObject; items: TJSObject;
begin begin
Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL); Logger.Log(3, 'Generated SQL for Prepare Report: ' + SQL);
//SQL := 'select * from corrugated_plate_orders where ORDER_ID = 18381';
doQuery(uqOrderCorrugated, SQL); doQuery(uqOrderCorrugated, SQL);
if ( string( uqOrderCorrugated.FieldByName('colors_colors').AsString ) ) <> '' then if ( string( uqOrderCorrugated.FieldByName('colors_colors').AsString ) ) <> '' then
...@@ -212,6 +211,7 @@ begin ...@@ -212,6 +211,7 @@ begin
ForceDirectories(ReportDir); ForceDirectories(ReportDir);
Logger.Log(5, 'Reports directory created: ' + ReportDir); Logger.Log(5, 'Reports directory created: ' + ReportDir);
end; end;
reportURL := 'reports/' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.pdf'; reportURL := 'reports/' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.pdf';
ReportFileName := reportDir + reportUrl; ReportFileName := reportDir + reportUrl;
......
...@@ -47,6 +47,75 @@ object rptOrderCutting: TrptOrderCutting ...@@ -47,6 +47,75 @@ object rptOrderCutting: TrptOrderCutting
DataSetOptions = [] DataSetOptions = []
Left = 444 Left = 444
Top = 206 Top = 206
FieldDefs = <
item
FieldName = 'ORDER_ID'
end
item
FieldName = 'COMPANY_ID'
end
item
FieldName = 'USER_ID'
end
item
FieldName = 'ORDER_DATE'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_order_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_proof_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_via'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quantity'
FieldType = fftString
end
item
FieldName = 'staff_fields_price'
FieldType = fftString
end
item
FieldName = 'staff_fields_invoice_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_ship_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_po_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'staff_fields_job_name'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'general_special_instructions'
FieldType = fftString
Size = 2048
end>
end end
object frxOrderCutting: TfrxReport object frxOrderCutting: TfrxReport
Version = '2025.1.4' Version = '2025.1.4'
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
MemoLogLevel=3 MemoLogLevel=3
FileLogLevel=5 FileLogLevel=5
webClientVersion=0.9.7 webClientVersion=0.9.7
LogFileNum=821 LogFileNum=927
[Database] [Database]
--Server=192.168.159.153 Server=192.168.159.155
Server=192.168.102.130 --Server=192.168.102.130
--Server=192.168.75.133 --Server=192.168.75.133
Database=kg_order_entry Database=kg_order_entry
Username=root Username=root
...@@ -17,6 +17,8 @@ Password=emsys01 ...@@ -17,6 +17,8 @@ Password=emsys01
CompanyID=9341454272655710 CompanyID=9341454272655710
ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy
ClientSecret=bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN ClientSecret=bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN
RefreshToken=RT1-10-H0-1760618473k44t73jittvqlr4wynn6 RefreshToken=RT1-44-H0-1762010333a3v07cb5eb0luyn2rppm
AccessToken=eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..IwosInYT2Am8LdNGXuY-zQ._QdW6AZ0up2uAna580wQy7qAZPo3nkfHo0eeSpKllcJ_s69nh33Ld41MnTkxeAv1v1bxhvkDxEvkevfNGnggNHU3XSqIqb6tTKcAqR4zPf14JYgOkn82tw_q2VXWLgboMMpP6CfcBHeZPIbJcEOkmX5g4CY0NOum1-_beYmDHE2sxAxnKxcg3rhjBo33BTFjXSg1xknvkTO_GVbyAWdyZmQOpFRfdXAeUDnPAEZhYNVfACFkEDubdK7PyfcAs_7un_E0NZf270tMc2W0HTyk24wCSLbfeeH2Su-G2wi21JszcNsXSNt9ayGtHEXNcWG6A54k1M8U7o_mvpCXLPEXDtJkx8HnBvTz_ZXrFaztQf0_c8DLld5zW8FC1wn-SzHyoCbYbR2M6tBjVLiK80_FlAal_YjBI8fk9BX7nBab6LbCBIcunt7hRsLWCPiRI8_fwM_Nj8rlvxtIoClcyV7_VpIpxCVUgmxKmgf7zuWD3fYc3i8Bg-DpgGgWPVATXSlfNKhOWIDZfyy0YOlkreXPlNdQwCJ1Su3_3yzu_DioV76C5orqoeWk25NiopiAqJ7cBMj15EiuFx-w3jaqCv6ovzEc5r3by510TNu6msjUh2RQ-nxVqLjyLt6VIp3O00e_.2itJJ0rFwI-foW2v1hDSrw AccessToken=eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwieC5vcmciOiJIMCJ9..7T78YBCSmvuJPRsZ9lGwuQ.1VJssLuNBAPKI7RAJOPluhtlA8DYgNcmXebNkWSxrHJ1949vjY4SPt5JjruuLsNOV09i_xKrQ76w9Zhjom1MiQaSyNoZHU-CZLfOtWgr9r3-gLxizdTlrTs9cEZs__8ep4_oe2r3n2u34QlM0xdVdLWxQbKYjpCl0k_58XPbS5Z_Vo2Y5qqoAuGJIRxMaTueMOH1ut-bV4Em318Ca1jN2DFCh_NYjLwFQQenWxOrCRMBaj7ZgB2yjtS5mEUxhuxsB7FAeONYqBSJ0OAy1yzWE-Ycxzt4dcZBCTHxzUCTH0-P0Mb_M6ivfmiYyKctf2gsZD8Xw91MgnF9TPwG8yXdej05fWr94VWeC3tFp0V-RYYv3_XRuim6fCvxJjWzfVEZwv9jUiZ6WByNSzu1k1W5_rQuSG7_Hs8WiDC1sBChJLfDclLO8pMoznqpSrM8ZmiNoYm4aZPQrpO6rgY8NiTokZRyeTw2adtW1YgDJsZdoEw.i2MSpKztX0v6UN0vZz5gQg
LastRefresh=7/7/2025 1:49:30 PM LastRefresh=7/23/2025 11:18:54 AM
--RefreshToken=RT1-10-H0-1760618473k44t73jittvqlr4wynn6
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