Commit 033837f0 by Cam Hayes

commit to begin merging changes into maser

parent 82a18ead
object FViewAddCustomer: TFViewAddCustomer
Width = 640
Height = 480
OnShow = WebFormShow
object dtpStartDate: TWebDateTimePicker
Left = 19
Top = 216
Width = 170
Height = 22
ElementID = 'dtpstartdate'
BorderStyle = bsSingle
ChildOrder = 10
Color = clWhite
Date = 45779.471405393520000000
Role = ''
Text = ''
end
object dtpEndDate: TWebDateTimePicker
Left = 19
Top = 248
Width = 170
Height = 22
ElementID = 'dtpenddate'
BorderStyle = bsSingle
ChildOrder = 10
Color = clWhite
Date = 45779.471405393520000000
Role = ''
Text = ''
end
object edtShortName: TWebDBEdit
Left = 19
Top = 12
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtcompanyaccountname'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtName: TWebDBEdit
Left = 19
Top = 40
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtBillAddress: TWebDBEdit
Left = 19
Top = 68
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtbillingaddress'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtBillCity: TWebDBEdit
Left = 19
Top = 98
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtbillingcity'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtBillState: TWebDBEdit
Left = 19
Top = 126
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtbillingstate'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtBillZip: TWebDBEdit
Left = 19
Top = 160
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtbillingzip'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtBillContact: TWebDBEdit
Left = 19
Top = 188
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtbillingcontact'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtPhone: TWebDBEdit
Left = 19
Top = 276
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtphone'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtFax: TWebDBEdit
Left = 19
Top = 304
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtfax'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtRep: TWebDBEdit
Left = 19
Top = 332
Width = 121
Height = 22
ChildOrder = 12
ElementID = 'edtrepid'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnSave: TWebButton
Left = 280
Top = 407
Width = 96
Height = 25
Caption = 'Save'
ChildOrder = 79
ElementID = 'btnconfirm'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
end
object btnCancel: TWebButton
Left = 280
Top = 367
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementID = 'btncancel'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
Role = 'null'
WidthPercent = 100.000000000000000000
end
object btnDelete: TWebButton
Left = 280
Top = 323
Width = 96
Height = 25
Caption = 'Delete'
ChildOrder = 79
ElementID = 'btndelete'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnClose: TWebButton
Left = 396
Top = 323
Width = 96
Height = 25
Caption = 'Close'
ChildOrder = 80
ElementID = 'btnclose'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnEdit: TWebButton
Left = 396
Top = 367
Width = 96
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementID = 'btnedit'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object pnlMessage: TWebPanel
Left = 324
Top = 19
Width = 121
Height = 33
ElementID = 'view.login.message'
ChildOrder = 5
ElementPosition = epRelative
Role = 'null'
TabOrder = 17
object lblMessage: TWebLabel
Left = 28
Top = 9
Width = 46
Height = 15
Caption = 'Message'
ElementID = 'view.login.message.label'
ElementPosition = epRelative
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCloseNotification: TWebButton
Left = 96
Top = 3
Width = 22
Height = 25
ChildOrder = 1
ElementID = 'view.login.message.button'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Role = 'null'
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
end
end
end
<nav class="navbar navbar-expand navbar-light bg-light sticky-top" style="z-index: 100;">
<div class="container-fluid ps-0">
<div id="view.login.message" class="alert alert-danger"
style="padding: 0.25rem 0.5rem; font-size: 0.875rem; line-height: 1.5; display: flex; align-items: center; margin: 0 0 0 60px; height: 32px; width: 400px;">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span>
</div>
<ul class="navbar-nav me-auto ps-2">
<li class="nav-item pe-2">
<button id="btnedit" class="btn btn-primary btn-sm">Edit</button>
</li>
<li class="nav-item pe-2">
<button id="btndelete" class="btn btn-danger btn-sm">Delete</button>
</li>
<li class="nav-item pe-2">
<button id="btnconfirm" class="btn btn-success btn-sm">Save</button>
</li>
<li class="nav-item pe-2">
<button id="btncancel" class="btn btn-danger btn-sm">Cancel</button>
</li>
<li class="nav-item">
<button id="btnclose" class="btn btn-primary btn-sm">Close</button>
</li>
</ul>
</div>
</nav>
<div class="row mx-5">
<div class="col-12 col-md-8">
</div>
<h4 class="custom-h4 mt-3">Company Information</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Name:</label>
<input id="edtcompanyname" type="text" class="form-control" style="width: 300px;" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" class="form-label mt-2">Company Account Name:</label>
<input id="edtcompanyaccountname"type="text" class="form-control" style="width: 150px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide a Company Account Name.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Start Date:</label>
<input class="form-control input-sm" id="dtpstartdate" type="date" required>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">End Date:</label>
<input class="form-control input-sm" id="dtpenddate" type="date" required>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Phone:</label>
<input id="edtphone" type="text" class="form-control"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Fax:</label>
<input id="edtfax" class="form-control input-sm"style="width: 200px" required/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Invoice Address.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Representative ID:</label>
<input id="edtrepid" class="form-control input-sm" style="width: 200px" required/>
<div class="invalid-feedback" style="font-size: 15px"; >
Please Provide a Ship To Address.
</div>
</div>
</div>
<h4 class="custom-h4 mt-3">Billing Information</h4>
<hr class="custom-hr">
<div class="row">
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Address:</label>
<input id="edtbillingaddress" class="form-control input-sm" required/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing City</label>
<input id="edtbillingcity" class="form-control input-sm" style="width: 250px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing State:</label>
<input id="edtbillingstate" class="form-control input-sm" style="width: 100px"/>
<div class="invalid-feedback" style="font-size: 15px;">
Please Provide an Order Date.
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Zip Code:</label>
<input id="edtbillingzip" class="form-control input-sm" style="width: 200px"/>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Billing Contact:</label>
<input id="edtbillingcontact" class="form-control input-sm" style="width: 150px"/>
</div>
</div>
</div>
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmation_modal_label">Confirm</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="modal_body">
Are you sure you want to delete this order?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id= 'btn_confirm_cancel'>Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_delete">Delete</button>
</div>
</div>
</div>
</div>
<style>
.modal-backdrop {
opacity: 0 !important;
}
</style>
unit AddCustomer;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, Vcl.StdCtrls, WEBLib.StdCtrls,
WEBLib.DBCtrls, WEBLib.ExtCtrls;
type
TFViewAddCustomer = class(TWebForm)
dtpStartDate: TWebDateTimePicker;
dtpEndDate: TWebDateTimePicker;
edtShortName: TWebDBEdit;
edtName: TWebDBEdit;
edtBillAddress: TWebDBEdit;
edtBillCity: TWebDBEdit;
edtBillState: TWebDBEdit;
edtBillZip: TWebDBEdit;
edtBillContact: TWebDBEdit;
edtPhone: TWebDBEdit;
edtFax: TWebDBEdit;
edtRep: TWebDBEdit;
btnSave: TWebButton;
btnCancel: TWebButton;
btnDelete: TWebButton;
btnClose: TWebButton;
btnEdit: TWebButton;
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
procedure WebFormShow(Sender: TObject);
private
{ Private declarations }
procedure HideNotification();
procedure ShowNotification(Notification: string);
var
customerID: string;
notification: string;
public
{ Public declarations }
class function CreateForm(AElementID, customerInfo, info: string): TWebForm;
end;
var
FViewAddCustomer: TFViewAddCustomer;
implementation
{$R *.dfm}
uses View.Main;
class function TFViewAddCustomer.CreateForm(AElementID: string; customerInfo: string; info: string): TWebForm;
begin
Application.CreateForm(TFViewAddCustomer, AElementID, Result,
procedure(AForm: TObject)
begin
with TFViewAddCustomer(AForm) do
begin
TFViewAddCustomer(AForm).customerID := customerInfo;
TFViewAddCustomer(AForm).notification := info;
end;
end
);
end;
procedure TFViewAddCustomer.WebFormShow(Sender: TObject);
begin
dtpStartDate.Date := 0;
dtpEndDate.Date := 0;
end;
procedure TFViewAddCustomer.HideNotification;
begin
pnlMessage.ElementHandle.hidden := True;
end;
procedure TFViewAddCustomer.ShowNotification(Notification: string);
var
splitNotification: TArray<string>;
begin
console.log(notification);
if Notification <> '' then
begin
splitNotification := Notification.Split([':']);
if(splitNotification[0] = 'Success') then
begin
asm
var messageDiv = document.getElementById('view.login.message');
messageDiv.classList.remove('alert-danger');
messageDiv.classList.add('alert-success');
end;
end
else
begin
asm
var messageDiv = document.getElementById('view.login.message');
messageDiv.classList.remove('alert-success');
messageDiv.classList.add('alert-danger');
end;
end;
console.log(splitNotification[1]) ;
lblMessage.Caption := splitNotification[1];
pnlMessage.ElementHandle.hidden := False;
end;
end;
end.
\ No newline at end of file
......@@ -28,6 +28,7 @@ object FViewCustomers: TFViewCustomers
TabOrder = 6
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnAddCustomerClick
end
object wdbtcCustomers: TWebDBTableControl
Left = 9
......
......@@ -25,6 +25,7 @@ type
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSTART_DATE: TStringField;
procedure WebFormCreate(Sender: TObject);
procedure btnAddCustomerClick(Sender: TObject);
private
{ Private declarations }
procedure GeneratePagination(TotalPages: Integer);
......@@ -168,6 +169,11 @@ begin
end;
end;
procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject);
begin
FViewMain.ViewAddCustomer('', '');
end;
procedure TFViewCustomers.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
......
......@@ -57,6 +57,7 @@ type
procedure ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode, info: string);
procedure ViewOrders(info: string);
procedure ShowUserForm(Info: string);
procedure ViewAddCustomer(customerInfo, info: string);
var
search: string;
change: boolean;
......@@ -79,7 +80,7 @@ uses
View.OrderEntryCorrugated,
View.OrderEntryCuttingDie,
View.OrderEntryWeb,
View.Customers;
View.Customers, AddCustomer;
{$R *.dfm}
......@@ -294,6 +295,14 @@ begin
FChildForm := TFOrderEntryCuttingDie.CreateForm(WebPanel1.ElementID, orderInfo, customerInfo, mode, info);
end;
procedure TFViewMain.ViewAddCustomer(customerInfo: string; info: string);
begin
lblAppTitle.Caption := 'Koehler-Gibson Add Customer';
if Assigned(FChildForm) then
FChildForm.Free;
FChildForm := TFViewAddCustomer.CreateForm(WebPanel1.ElementID, customerInfo, info);
end;
procedure TFViewMain.ShowUserForm(Info: string);
begin
if Assigned(FChildForm) then
......
......@@ -24,7 +24,8 @@ uses
View.SetStatus in 'View.SetStatus.pas' {FSetStatus: TWebForm} {*.html},
View.OrderEntryCuttingDie in 'View.OrderEntryCuttingDie.pas' {FOrderEntryCuttingDie: TWebForm} {*.html},
View.OrderEntryWeb in 'View.OrderEntryWeb.pas' {FOrderEntryWeb: TWebForm} {*.html},
View.Customers in 'View.Customers.pas' {FViewCustomers: TWebForm} {*.html};
View.Customers in 'View.Customers.pas' {FViewCustomers: TWebForm} {*.html},
AddCustomer in 'AddCustomer.pas' {FViewAddCustomer: TWebForm} {*.html};
{$R *.res}
......
......@@ -191,6 +191,11 @@
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="AddCustomer.pas">
<Form>FViewAddCustomer</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/>
<None Include="css\app.css"/>
<None Include="config\config.json"/>
......
......@@ -38,6 +38,7 @@ type
function GetWebOrder(orderInfo: string): TWebOrder;
function GetCuttingDieOrder(orderInfo: string): TCuttingDie;
function EditUser(const editOptions: string): string;
function GenerateOrderListPDF(searchOptions: string): string;
......@@ -46,6 +47,7 @@ type
function GenerateOrderCuttingPDF(orderID: string): string;
function AddUser(userInfo: string): string;
function AddCustomer(customerInfo: string): TJSONObject;
function AddItem(itemInfo: string): string;
function DelUser(username: string): string;
function AddCorrugatedOrder(orderInfo: string): TJSONObject;
......@@ -191,6 +193,86 @@ begin
end;
function TLookupService.AddCustomer(customerInfo: string): TJSONObject;
var
JSONData: TJSONObject;
SQL: string;
Pair: TJSONPair;
Field: TField;
DateFormat: TFormatSettings;
CustomerID: integer;
mode: string;
temp: string;
begin
DateFormat := TFormatSettings.Create;
DateFormat.ShortDateFormat := 'yyyy-mm-dd';
DateFormat.DateSeparator := '-';
JSONData := TJSONObject.ParseJSONValue(customerInfo) as TJSONObject;
if JSONData = nil then
raise Exception.Create('Invalid JSON format'); // If parsing fails, raise an exception
mode := JSONData.GetValue<string>('mode');
if mode = 'ADD' then
begin
// Update RevisionID
SQL := 'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID');
OrdersDB.UniQuery1.SQL.Text := SQL;
OrdersDB.UniQuery1.ExecSQL;
// Retrieve updated RevisionID
SQL := 'select KEYVALUE from idfield where KEYNAME = ' + quotedStr('GEN_ORDER_REVISION_ID');
doQuery(OrdersDB.UniQuery1, SQL);
CustomerID := OrdersDB.UniQuery1.FieldByName('KEYVALUE').AsInteger;
end
else
CustomerID := JSONData.GetValue<integer>('CustomerID');
if mode = 'ADD' then
SQL := 'select * from customers where ORDER_ID = 0 and ORDER_ID <> 0'
else
begin
SQL := 'select * from customers where ORDER_ID = ' + IntToStr(CustomerID);
end;
doQuery(ordersDB.UniQuery1, SQL);
try
if mode = 'ADD' then
ordersDB.UniQuery1.Insert
else
ordersDB.UniQuery1.Edit;
for Pair in JSONData do
begin
Field := ordersDB.UniQuery1.FindField(Pair.JsonString.Value); // Checks if the field exists in the dataset
if Assigned(Field) then
begin
if (Field is TDateTimeField) then
begin
if (Pair.JsonValue.Value = '') or (Pair.JsonValue.Value = 'null') or (Pair.JsonValue.Value = '12/30/1899') then
Field.Clear // This sets the field to NULL (empty)
else
TDateTimeField(Field).AsDateTime := StrToDate(Pair.JsonValue.Value);
end
else if Pair.JsonValue.Value <> '' then
Field.AsString := Pair.JsonValue.Value;
end;
end;
ordersDB.UniQuery1.FieldByName('ORDER_ID').AsInteger := CustomerID;
// Post the record to the database
ordersDB.UniQuery1.Post;
Result := TJSONObject.Create.AddPair('status', 'success');
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
except
on E: Exception do
begin
Result := TJSONObject.Create.AddPair('error', E.Message);
end
end;
end;
function TLookupService.GenerateOrderCorrugatedPDF(orderID: string): string;
var
SQL: string;
......@@ -351,22 +433,27 @@ begin
+ status.statusTableShort +'.ORDER_ID = o.ORDER_ID ' +
'AND ' + status.statusTableShort + '.ORDER_STATUS = ' +
quotedStr(status.statusType) + ')';
// out dated useage. uncomment if you want to return entries where dues are null, but dones exist or vice versa.
//generateStatusSelectSQL(status.altStatusTableShort, status.altStatusTableLong, status.startDate, status.endDate, status.statusType);
end
else
result := result + ' AND ' + generateStatusSelectSQL(status.statusTableShort, status.statusTableLong, status.startDate, status.endDate, status.statusType);
end
else
begin
if status.startDate <> '' then
if status.null then
begin
result := result + ' AND ' + quotedStr(status.startDate) + ' <= o.ORDER_DATE';
end;
if ( ( status.endDate <> '1899/12/30' ) AND ( status.endDate <> '' ) ) then
result := result + ' AND ' + quotedStr(status.startDate) + ' IS NULL';
end
else
begin
result := result + ' AND ' + quotedStr(status.endDate) + ' >= o.ORDER_DATE';
if status.startDate <> '' then
begin
result := result + ' AND ' + quotedStr(status.startDate) + ' <= COALESCE(cpo.staff_fields_order_date, wpo.staff_fields_order_date, cdo.staff_fields_order_date)';
end;
if ( ( status.endDate <> '1899/12/30' ) AND ( status.endDate <> '' ) ) then
begin
result := result + ' AND ' + quotedStr(status.endDate) + ' >= COALESCE(cpo.staff_fields_order_date, wpo.staff_fields_order_date, cdo.staff_fields_order_date)';
end;
end;
end;
end;
......
......@@ -22,7 +22,6 @@ object fQB: TfQB
'Memo1')
ScrollBars = ssVertical
TabOrder = 0
ExplicitTop = 58
end
object Button1: TButton
Left = 42
......@@ -40,7 +39,7 @@ object fQB: TfQB
Height = 196
Align = alBottom
Lines.Strings = (
'Memo2')
'')
ScrollBars = ssVertical
TabOrder = 2
end
......@@ -74,6 +73,7 @@ object fQB: TfQB
BorderColor = 11250603
ControlLook.FixedGradientFrom = clWhite
ControlLook.FixedGradientTo = clWhite
ControlLook.FixedGradientHoverFrom = clGray
ControlLook.FixedGradientHoverTo = clWhite
ControlLook.FixedGradientHoverMirrorFrom = clWhite
ControlLook.FixedGradientHoverMirrorTo = clWhite
......@@ -178,5 +178,31 @@ object fQB: TfQB
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '9.1.4.1'
ColWidths = (
64
64
64
64
64)
RowHeights = (
22
22
22
22
22
22
22
22
22
22)
end
object Button3: TButton
Left = 260
Top = 18
Width = 139
Height = 25
Caption = 'Get Customer By ID'
TabOrder = 5
OnClick = Button3Click
end
end
......@@ -21,9 +21,11 @@ type
Memo2: TMemo;
Button2: TButton;
asgData: TAdvStringGrid;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
httpReqTokenRefresh: TWebHttpRequest;
......@@ -85,8 +87,8 @@ begin
GetCustomers();
end;
procedure TfQB.getCustomers();
var
procedure TfQB.Button3Click(Sender: TObject);
var
restClient: TRESTClient;
restRequest: TRESTRequest;
restResponse: TRESTResponse;
......@@ -114,7 +116,8 @@ begin
end;
restRequest.Method := rmGET;
res := '/v3/company/' + companyID + '/query?query=select * from Customer&minorversion=75';
//GET /v3/company/<realmId>/customer/<customerId>
res := '/v3/company/' + companyid + '/customer/58';
restRequest.Resource := res;
param := restRequest.Params.AddItem;
......@@ -130,23 +133,74 @@ begin
jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue);
Memo2.Lines.Add(res);
Memo2.Lines.Add( jsObj.Format(2) );
//CustomerList := TJSONArray(restResponse.JSONValue);
CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// LoadJSONArray( CustomerList );
restClient.Free;
restRequest.Free;
restResponse.Free;
end;
procedure TfQB.getCustomers();
var
restClient: TRESTClient;
restRequest: TRESTRequest;
restResponse: TRESTResponse;
param: TRESTRequestParameter;
res: string;
jsValue: TJSONValue;
Customer: TJSONValue;
jsObj: TJSONObject;
CustomerList: TJSONArray;
pair: TJSONPair;
begin
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;
LoadJSONArray( CustomerList );
{for Customer in CustomerList do
if MinutesBetween(Now, LastRefresh) > 58 then
begin
for pair in TJSONObject(Customer).pair do
begin
RefreshAccessToken();
end;
end;
end; }
restRequest.Method := rmGET;
//res := '/v3/company/' + companyID + '/preferences';
res := '/v3/company/' + companyID + '/query?query=select * from Customer where CompanyName = ' + quotedStr('TYOGA CONTAINER') + '&minorversion=75'; // '/customer/58';
restRequest.Resource := res;
///query?query=select * from Customer where CompanyName = ' + quotedStr('TYOGA CONTAINER') + '&minorversion=75';
//jsObj := TJSONObject.ParseJSONValue(restresponse.Content) as TJSONObject;
//companyInfo := TJSONObject(jsObj.GetValue('CompanyInfo'));
param := restRequest.Params.AddItem;
param.Name := 'Authorization';
param.Kind := pkHTTPHEADER;
param.Options := param.Options + [TRESTRequestParameterOption.poDoNotEncode];
param.Value := 'Bearer ' + AccessToken;
restRequest.Execute;
memo1.Lines.Add(restresponse.Content);
jsValue := restResponse.JSONValue;
jsObj := TJSONObject(jsValue);
Memo2.Lines.Add(res);
Memo2.Lines.Add( jsObj.Format(2) );
//CustomerList := TJSONArray(restResponse.JSONValue);
// CustomerList := TJSONArray( TJSONObject( jsObj.GetValue('QueryResponse') ).GetValue('Customer')) ;
// LoadJSONArray( CustomerList );
restClient.Free;
restRequest.Free;
......
......@@ -2,7 +2,7 @@
MemoLogLevel=3
FileLogLevel=5
webClientVersion=0.9.2
LogFileNum=443
LogFileNum=469
[Database]
Server=192.168.159.131
......@@ -17,5 +17,5 @@ Password=emsys01
CompanyID=9341454272655710
ClientID=ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy
ClientSecret=bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN
RefreshToken=RT1-219-H0-175466891417di6x52592vlv2cmjhu
RefreshToken=RT1-96-H0-175492905304b5i0seva405h1axtuf
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