Commit 32d4033d by Cam Hayes

Got QB ID to be unique and fixed the error modal to hide the spinner and remain on the form

parent 151f60b4
......@@ -91,6 +91,7 @@ end;
procedure ShowErrorModal(msg: string);
begin
HideSpinner('spinner');
asm
var modal = document.getElementById('main_errormodal');
var label = document.getElementById('main_lblmodal_body');
......@@ -106,7 +107,8 @@ begin
// Bind hard reload to button
if (reloadBtn) {
reloadBtn.onclick = function () {
window.location.reload(true); // hard reload, bypass cache
//window.location.reload(true); // hard reload, bypass cache
bsModal.hide();
};
}
......
......@@ -61,10 +61,10 @@
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Territory:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Representative:</label>
<input id="edtrepuser"type="text" class="form-control" style="width: 150px"/>
<div class="invalid-feedback" id="territorywarning" style="font-size: 15px;">
Territory not found in kgOrders
Representative not found in kgOrders
</div>
</div>
</div>
......
......@@ -9,8 +9,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 95
Height = 15
Caption = 'Search Customers'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left = 279
......@@ -18,8 +18,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 134
Height = 15
Caption = 'Selected Customer Name'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel3: TWebLabel
Left = 131
......@@ -27,8 +27,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 113
Height = 15
Caption = 'Selected Customer ID'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 4
......@@ -36,8 +36,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 121
Height = 22
ChildOrder = 2
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtSearchChange
end
object edtName: TWebEdit
......@@ -47,8 +47,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
......@@ -59,7 +59,7 @@ object FSelectCustomer: TFSelectCustomer
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 2
DefaultRowHeight = 40.00000000000000000
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 4
Options.Bands.Enabled = True
......@@ -85,7 +85,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 90.00000000000000000
Width = 90.000000000000000000
end
item
BorderWidth = 1
......@@ -100,7 +100,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 150.00000000000000000
Width = 150.000000000000000000
end
item
BorderWidth = 1
......@@ -115,7 +115,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 400.00000000000000000
Width = 400.000000000000000000
end
item
BorderWidth = 1
......@@ -130,7 +130,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 106.00000000000000000
Width = 106.000000000000000000
end
item
BorderWidth = 1
......@@ -145,7 +145,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 1.00000000000000000
Width = 1.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
......@@ -215,8 +215,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Caption = 'Cancel'
ChildOrder = 5
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object btnConfirm: TWebButton
......@@ -226,8 +226,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Caption = 'Select'
ChildOrder = 5
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object edtID: TWebEdit
......@@ -237,8 +237,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......
......@@ -125,7 +125,10 @@ begin
PopulateGridManually;
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
end;
......
......@@ -13,8 +13,8 @@ object FViewCustomers: TFViewCustomers
ElementID = 'lblentries'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnAddCustomer: TWebButton
Left = 12
......@@ -26,10 +26,10 @@ object FViewCustomers: TFViewCustomers
ElementID = 'btnaddcustomer'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
TabOrder = 6
TabStop = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddCustomerClick
end
object wcbPageSize: TWebComboBox
......@@ -41,9 +41,9 @@ object FViewCustomers: TFViewCustomers
ElementID = 'wcbpagesize'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
Text = '50'
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange
ItemIndex = -1
Items.Strings = (
......@@ -66,8 +66,8 @@ object FViewCustomers: TFViewCustomers
Height = 15
Caption = 'Message'
ElementID = 'view.login.message.label'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCloseNotification: TWebButton
Left = 96
......@@ -76,8 +76,8 @@ object FViewCustomers: TFViewCustomers
Height = 25
ChildOrder = 1
ElementID = 'view.login.message.button'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object wdbtcCustomers: TWebDBTableControl
......@@ -139,8 +139,8 @@ object FViewCustomers: TFViewCustomers
Height = 22
ChildOrder = 5
ElementID = 'edtfilter'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtFilterChange
end
object XDataWebClient1: TXDataWebClient
......
......@@ -177,10 +177,7 @@ end;
procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject);
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
ShowSelectCustomerForm()
else
ShowNotificationModal('QuickBooks interface is not currently active');
ShowSelectCustomerForm()
end;
procedure TFViewCustomers.edtFilterChange(Sender: TObject);
......
......@@ -123,7 +123,10 @@ begin
//Utils.HideSpinner('spinner');
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
Utils.HideSpinner('spinner');
end;
......
......@@ -442,39 +442,35 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
begin
newform := TFViewAddItem.CreateNew;
newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// used to manage Back button handling to close subform
window.location.hash := 'subform';
newform.ShowModal(
procedure(AValue: TModalResult)
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
begin
if newform.confirm then
begin
xdwdsItems.Append;
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.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
else
ShowNotificationModal('QuickBooks interface is not currently active.');
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end
);
end
end;
procedure TFViewItems.btnCancelClick(Sender: TObject);
......@@ -511,12 +507,7 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
begin
UpdateItem();
end
else
ShowNotificationModal('QuickBooks interface is not currently active.');
UpdateItem();
end;
procedure TFViewItems.UpdateItem();
......
......@@ -95,7 +95,7 @@
Please contact EMSystems to solve the issue.
</div>
<div class="modal-footer justify-content-center">
<button type="button" id="btn_modal_restart" class="btn btn-primary">Back to Orders</button>
<button type="button" id="btn_modal_restart" class="btn btn-primary">Close</button>
</div>
</div>
</div>
......
......@@ -391,14 +391,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -195,14 +195,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -455,14 +455,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -13,9 +13,9 @@ object FQBInfo: TFQBInfo
Font.Height = -24
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblCompanyName: TWebLabel
Left = 16
......@@ -28,9 +28,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblCompanyID: TWebLabel
Left = 15
......@@ -43,9 +43,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblLastRefresh: TWebLabel
Left = 16
......@@ -58,9 +58,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object btnLinkToQB: TWebButton
Left = 235
......@@ -69,8 +69,8 @@ object FQBInfo: TFQBInfo
Height = 25
Caption = 'Link to QB'
ChildOrder = 3
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnLinkToQBClick
end
object btnClose: TWebButton
......@@ -80,8 +80,8 @@ object FQBInfo: TFQBInfo
Height = 25
Caption = 'Close'
ChildOrder = 3
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCloseClick
end
object XDataWebClient1: TXDataWebClient
......
......@@ -86,7 +86,10 @@ begin
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
end;
......
......@@ -99,7 +99,10 @@ begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddUser', [userInfo]));
responseString := TJSObject(xdcResponse.Result);
Info := string(responseString['value']);
FViewMain.ShowUserForm(Info);
if Info.ToLower.Contains('failure') then
ShowToast(Info)
else
FViewMain.ShowUserForm(Info);
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......@@ -129,7 +132,10 @@ begin
[editOptions]));
responseString := TJSObject(xdcResponse.Result);
Info := string(responseString['value']);
FViewMain.ShowUserForm(Info);
if Info.ToLower.Contains('failure') then
ShowToast(Info)
else
FViewMain.ShowUserForm(Info);
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......
......@@ -127,14 +127,6 @@ begin
raise EXDataHttpUnauthorized.Create('User not active!');
end;
iniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
try
qbEnabled := iniFile.ReadBool('Quickbooks', 'Enabled', true);
finally
iniFile.Free;
end;
JWT := TJWT.Create;
try
JWT.Claims.JWTId := LowerCase(Copy(TUtils.GuidToVariant(TUtils.NewGuid), 2, 36));
......@@ -147,7 +139,6 @@ begin
JWT.Claims.SetClaimOfType<string>('user_email', authDB.uq.FieldByName('EMAIL').AsString);
JWT.Claims.SetClaimOfType<string>('user_qb_id', authDB.uq.FieldByName('QB_ID').AsString);
JWT.Claims.SetClaimOfType<string>('user_access_type', authDB.uq.FieldByName('ACCESS_TYPE').AsString);
JWT.Claims.SetClaimOfType<boolean>('qb_enabled', qbEnabled);
Result := TJOSE.SHA256CompactToken(serverConfig.jwtTokenSecret, JWT);
finally
......
......@@ -961,19 +961,16 @@ end;
function TLookupService.GenerateOrderCorrugatedPDF(orderID: string): string;
var
SQL: string;
rptOrderCorrugated: TrptOrderCorrugated; // Local instance of the report
rptOrderCorrugated: TrptOrderCorrugated;
begin
rptOrderCorrugated := TrptOrderCorrugated.Create(nil);
logger.Log(3, 'TLookupService.GenerateOrderCorrugatedPDF');
try
try
// Generate SQL query for a single order
SQL := 'SELECT * FROM corrugated_plate_orders c join orders o on c.ORDER_ID = o.ORDER_ID WHERE c.ORDER_ID = ' + orderID;
// Prepare the report with the query
Result := rptOrderCorrugated.PrepareReport(SQL);
// Optionally log success
Logger.Log(3, 'PDF Report successfully generated for order ID: ' + orderID);
except
on E: Exception do
......@@ -1876,6 +1873,7 @@ var
newUser: string;
hashString: string;
hashPW: string;
unique: boolean;
begin
logger.log(3, 'TLookupService.EditUser');
params := TStringList.Create;
......@@ -1894,54 +1892,71 @@ begin
QB := params.Values['QB'];
newUser := params.Values['newuser'];
SQL := 'select * from users where USER_NAME = ' + QuotedStr(user);
doQuery(ordersDB.UniQuery1, SQL);
SQL := 'select USER_ID, USER_NAME from users where QB_ID = ' + quotedStr(QB);
logger.Log(5, 'Retrieving customer with SQL: ' + SQL);
doQuery(OrdersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.IsEmpty then
Result := 'Failure:No such user found'
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) ) then
unique := true
else
unique := false;
if unique then
begin
ordersDB.UniQuery1.Edit;
SQL := 'select * from users where USER_NAME = ' + QuotedStr(user);
doQuery(ordersDB.UniQuery1, SQL);
if not newUser.IsEmpty then
ordersDB.UniQuery1.FieldByName('USER_NAME').AsString := newUser;
if ordersDB.UniQuery1.IsEmpty then
Result := 'Failure:No such user found'
else
begin
ordersDB.UniQuery1.Edit;
if not full_name.IsEmpty then
ordersDB.UniQuery1.FieldByName('NAME').AsString := full_name;
if not newUser.IsEmpty then
ordersDB.UniQuery1.FieldByName('USER_NAME').AsString := newUser;
if not status.IsEmpty then
begin
if StrToBool(status) then
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'ACTIVE'
else
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'INACTIVE'
end;
if not full_name.IsEmpty then
ordersDB.UniQuery1.FieldByName('NAME').AsString := full_name;
ordersDB.UniQuery1.FieldByName('EMAIL').AsString := email;
if not status.IsEmpty then
begin
if StrToBool(status) then
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'ACTIVE'
else
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'INACTIVE'
end;
if not access.IsEmpty then
ordersDB.UniQuery1.FieldByName('ACCESS_TYPE').AsString := Access;
ordersDB.UniQuery1.FieldByName('EMAIL').AsString := email;
if not rights.IsEmpty then
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := StrToInt(rights);
if not access.IsEmpty then
ordersDB.UniQuery1.FieldByName('ACCESS_TYPE').AsString := Access;
if not perspective.IsEmpty then
ordersDB.UniQuery1.FieldByName('PERSPECTIVE_ID').AsString := perspective;
if not rights.IsEmpty then
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := StrToInt(rights);
ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB;
if not perspective.IsEmpty then
ordersDB.UniQuery1.FieldByName('PERSPECTIVE_ID').AsString := perspective;
if((not (Password = 'hidden')) and (not (Password.IsEmpty))) then
begin
hashString := ordersDB.UniQuery1.FieldByName('NAME').AsString + password;
hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
ordersDB.UniQuery1.FieldByName('password').AsString := hashPW;
end;
ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB;
ordersDB.UniQuery1.Post;
Result := 'Success: User Successfully Edited';
logger.Log(4, 'User Successfully Edited');
if((not (Password = 'hidden')) and (not (Password.IsEmpty))) then
begin
hashString := ordersDB.UniQuery1.FieldByName('NAME').AsString + password;
hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
ordersDB.UniQuery1.FieldByName('password').AsString := hashPW;
end;
ordersDB.UniQuery1.Post;
Result := 'Success: User Successfully Edited';
logger.Log(4, 'User Successfully Edited');
end;
ordersDB.UniQuery1.Close;
end
else
begin
Result := 'Failure: QB ID Must Be Unique';
logger.Log(3, 'Failure: Company Account Name Must Be Unique');
end;
ordersDB.UniQuery1.Close;
finally
params.Free;
end;
......@@ -2264,6 +2279,7 @@ var
SQL: string;
rightsInt: Integer;
params: TStringList;
unique: boolean;
begin
logger.Log(3, 'TLookupService.AddUser');
params := TStringList.Create;
......@@ -2283,40 +2299,53 @@ begin
perspective := params.Values['perspective'];
QB := params.Values['QB'];
SQL := 'SELECT * FROM users WHERE USER_NAME = ' + QuotedStr(user.ToLower);
ordersDB.UniQuery1.Close;
ordersDB.UniQuery1.SQL.Text := SQL;
ordersDB.UniQuery1.Open;
SQL := 'select USER_ID, USER_NAME from users where QB_ID = ' + quotedStr(QB);
logger.Log(5, 'Retrieving customer with SQL: ' + SQL);
doQuery(OrdersDB.UniQuery1, SQL);
if ordersDB.UniQuery1.IsEmpty then
if ( (OrdersDB.UniQuery1.IsEmpty) or (OrdersDB.UniQuery1.FieldByName('USER_NAME').AsString = user) ) then
unique := true
else
unique := false;
if unique then
begin
ordersDB.UniQuery1.Insert;
SQL := 'SELECT * FROM users WHERE USER_NAME = ' + QuotedStr(user.ToLower);
ordersDB.UniQuery1.Close;
ordersDB.UniQuery1.SQL.Text := SQL;
ordersDB.UniQuery1.Open;
ordersDB.UniQuery1.FieldByName('USER_NAME').AsString := user;
ordersDB.UniQuery1.FieldByName('PASSWORD').AsString := THashSHA2.GetHashString(full_name + password, THashSHA2.TSHA2Version.SHA512).ToUpper;
ordersDB.UniQuery1.FieldByName('NAME').AsString := full_name;
if ordersDB.UniQuery1.IsEmpty then
begin
ordersDB.UniQuery1.Insert;
if StrToBoolDef(status, False) then
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'ACTIVE'
else
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'INACTIVE';
ordersDB.UniQuery1.FieldByName('USER_NAME').AsString := user;
ordersDB.UniQuery1.FieldByName('PASSWORD').AsString := THashSHA2.GetHashString(full_name + password, THashSHA2.TSHA2Version.SHA512).ToUpper;
ordersDB.UniQuery1.FieldByName('NAME').AsString := full_name;
ordersDB.UniQuery1.FieldByName('EMAIL').AsString := email;
ordersDB.UniQuery1.FieldByName('ACCESS_TYPE').AsString := access;
if StrToBoolDef(status, False) then
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'ACTIVE'
else
ordersDB.UniQuery1.FieldByName('STATUS').AsString := 'INACTIVE';
if not TryStrToInt(rights, rightsInt) then
rightsInt := 0;
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := rightsInt;
ordersDB.UniQuery1.FieldByName('EMAIL').AsString := email;
ordersDB.UniQuery1.FieldByName('ACCESS_TYPE').AsString := access;
ordersDB.UniQuery1.FieldByName('PERSPECTIVE_ID').AsString := perspective;
ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB;
if not TryStrToInt(rights, rightsInt) then
rightsInt := 0;
ordersDB.UniQuery1.FieldByName('SYSTEM_RIGHTS').AsInteger := rightsInt;
ordersDB.UniQuery1.Post;
Result := 'Success: User successfully added';
ordersDB.UniQuery1.FieldByName('PERSPECTIVE_ID').AsString := perspective;
ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB;
ordersDB.UniQuery1.Post;
Result := 'Success: User successfully added';
end
else
Result := 'Failure: Username already taken';
end
else
Result := 'Failure: Username already taken';
Result := 'Failure: QB ID Must Be Unique';
logger.Log(4, Result);
except
on E: Exception do
......@@ -2837,7 +2866,7 @@ var
I: integer;
SQL: string;
begin
logger.Log(3, 'TLookupService.GetQBCustomers');
logger.Log(3, 'TLookupService.GetQBCustomers - start');
Result := TQBCustomerList.Create;
iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini');
restClient := TRESTClient.Create(nil);
......@@ -3135,7 +3164,7 @@ begin
on E: Exception do
begin
Logger.Log(2, 'Error in getQBCustomer: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!');
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Customer: A QuickBooks interface error has occurred!');
end;
end;
finally
......@@ -3581,7 +3610,7 @@ begin
on E: Exception do
begin
Logger.Log(2, 'Error in UpdateCustomer: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to retrieve QuickBooks Customers: A QuickBooks interface error has occurred!');
raise EXDataHttpException.Create(500, 'Unable to update QuickBooks Customer: A QuickBooks interface error has occurred!');
end;
end;
finally
......@@ -3800,8 +3829,9 @@ begin
except
on E: Exception do
begin
logger.Log(1, 'Error in Import QBCustomer: ' + E.Message);
Result := TJSONObject.Create;
Result.AddPair('error', E.Message);
Result.AddPair('error', 'Error importing QB Customer! A QuickBooks interface error has occured!');
end;
end;
end;
......
......@@ -193,11 +193,6 @@ begin
Logger.Log( 1, '----Database->Password: xxxxxxxx' );
Logger.Log(1, '---Quickbooks---');
iniStr := IniFile.ReadString( 'Quickbooks', 'Enabled', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Quickbooks->Enabled: Entry not found - default: true' )
else
Logger.Log( 1, '--Quickbooks->Enabled: ' + iniStr );
iniStr := IniFile.ReadString( 'Quickbooks', 'CompanyID', '' );
if iniStr.IsEmpty then
......
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