Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Problem with passing hashcoockie to a query Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
tsignadze
Posts: 43
Joined: Tue Feb 21, 2023 12:14 am
Has thanked: 22 times
Been thanked: 1 time

Problem with passing hashcoockie to a query

Unread post by tsignadze »

Hi, guys. I have a following procedure:

I am struggling with two errors:
1) it does not matter if I have Integrated checkbox ticked, it always goes to else block.
2) #SerialNumber# is passed, because message says it passed, something got updated, but when I am checking table, nothing has been updated. What kind of sorcery is this?

Code: Select all

if ('#ContactNumber#' == '') {
    nuDisplayError('საკონტაქტო ნომერი აუცილებელია!');
    return;
}
if ('#InstallServiceNumber#' == '') {
    nuDisplayError('ინსტალის ტასკის ნომერი აუცილებელია!');
    return;
}
if ('#BlankorNot#' != 'Blank') {
    nuDisplayError('არ არის ბალვანკა!');
    return;
}
if ('#BlankType#' != 'FISCAL') {
    nuDisplayError('არ არის ფისკალურისთვის განკუთვნილი ბალვანკა!');
    return;
}
define("checkboxChecked", 100);

$checkboxChecked = isset($_POST['Integrated']) && $_POST['Integrated'] === 'on';

if (checkboxChecked) {
    // Checkbox is checked, run this query
    $sql = "UPDATE TRSYSDATABASE SET
    MerchantName = '#MerchantName#',
    INN = '#INN#',
    TerminalID = '#TerminalID#',
    MerchantID = '#MerchantID#',
    Reconcilation = '#Reconcilation#',
    Address = '#Address#',
    InstallAppNumber = '#InstallAppNumber#',
    ClientBank = '#ClientBank#',
    ContactNumber = '#ContactNumber#',
    InstallServiceNumber = '#InstallServiceNumber#',
    InstallDate = '#InstallDate#',
    InstallUser = '#InstallUser#',
    InstallStatus = 'Installed',
    Location = 'მერჩანტთან',
    Integrated = 'INTEGRATED',
    BlankorNot = 'NotBlank'
    WHERE SerialNumber = '#SerialNumber#'";
} else {
    // Checkbox is not checked, run this query instead
    $sql = "UPDATE TRSYSDATABASE SET
    MerchantName = '#MerchantName#',
    INN = '#INN#',
    TerminalID = '#TerminalID#',
    MerchantID = '#MerchantID#',
    Reconcilation = '#Reconcilation#',
    Address = '#Address#',
    InstallAppNumber = '#InstallAppNumber#',
    ClientBank = '#ClientBank#',
    ContactNumber = '#ContactNumber#',
    InstallServiceNumber = '#InstallServiceNumber#',
    InstallDate = '#InstallDate#',
    InstallUser = '#InstallUser#',
    InstallStatus = 'Installed',
    Location = 'მერჩანტთან',
    Integrated = 'NOTINTEGRATED',
    BlankorNot = 'NotBlank'
    WHERE SerialNumber = '#SerialNumber#'";
}

nuRunQuery($sql);

$affected_rows = nuRunQuery("SELECT ROW_COUNT()")->fetchColumn();

if ($affected_rows > 0) {
    $js = "nuMessage('წარმატებით დაემატა!', 2000,closePopup);

	function closePopup() {
		nuClosePopup();
	}
	";
} elseif ($affected_rows === 0) {
    $js = "nuMessage('არაფერი დაემატა, გადაამოწმე');";
} else {
    nuDisplayError('შეცდომაა, მიმართეთ ადმინისტრატორს!!!');
    return;
}

nuJavaScriptCallback($js);
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Problem with passing hashcoockie to a query

Unread post by kev1n »

See the other topic with my suggestion.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Problem with passing hashcoockie to a query

Unread post by kev1n »

Add nuDebug($sql); before running the SQL to inspect the generated in nuDebug Results.
tsignadze
Posts: 43
Joined: Tue Feb 21, 2023 12:14 am
Has thanked: 22 times
Been thanked: 1 time

Re: Problem with passing hashcoockie to a query

Unread post by tsignadze »

Kevin thank you for quick answers.
I am too tired for today, I guess. I was pushing double into int...
Everything works flawlessly.
Till tomorrow (hopefully not) :D
Post Reply