function executeSQL($sql, $db, $TrapErrors = False) { global $SQLFile; /* Run an sql statement and return an error code */ if (!isset($SQLFile)) { DB_IgnoreForeignKeys($db); $result = DB_query($sql, $db, '', '', false, $TrapErrors); $ErrorNumber = DB_error_no($db); DB_ReinstateForeignKeys($db); return $ErrorNumber; } else { fwrite($SQLFile, $sql . ";\n"); } }
echo '<br />' . _('Changing workcentres records'); $sql = "UPDATE workcentres SET location='" . $_POST['NewLocationID'] . "' WHERE location='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update workcentres records failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<br />' . _('Changing workorders records'); $sql = "UPDATE workorders SET loccode='" . $_POST['NewLocationID'] . "' WHERE loccode='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update workorders records failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<br />' . _('Changing users records'); $sql = "UPDATE www_users SET defaultlocation='" . $_POST['NewLocationID'] . "' WHERE defaultlocation='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update users records failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); DB_ReinstateForeignKeys($db); $result = DB_Txn_Commit($db); echo '<br />' . _('Deleting the old location record'); $sql = "DELETE FROM locations WHERE loccode='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to delete the old location record failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<p>' . _('Location code') . ': ' . $_POST['OldLocationID'] . ' ' . _('was successfully changed to') . ' : ' . $_POST['NewLocationID']; } //only do the stuff above if $InputError==0 } echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; echo '<div class="centre">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<br /> <table>
$result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); prnMsg(_('Changing the customer code in contract header records'), 'info'); $sql = "UPDATE contracts SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; $ErrMsg = _('The SQL to update contract header records failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); $result = DB_IgnoreForeignKeys($db); prnMsg(_('Deleting the old customer branch records from the CustBranch table'), 'info'); $sql = "DELETE FROM custbranch WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; $ErrMsg = _('The SQL to delete the old CustBranch records for the old debtor record failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); prnMsg(_('Deleting the customer code from the DebtorsMaster table'), 'info'); $sql = "DELETE FROM debtorsmaster WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; $ErrMsg = _('The SQL to delete the old debtor record failed'); $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true); $result = DB_Txn_Commit($db); $result = DB_ReinstateForeignKeys($db); } echo '<form onSubmit="return VerifyForm(this);" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post" class="noPrint">'; echo '<div class="centre">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<br /> <table> <tr> <td>' . _('Existing Debtor Code') . ':</td> <td><input type="text" name="OldDebtorNo" size="20" minlength="0" maxlength="20" /></td> </tr> <tr> <td> ' . _('New Debtor Code') . ':</td> <td><input type="text" name="NewDebtorNo" size="20" minlength="0" maxlength="20" /></td> </tr> </table>
echo '<br />' . _('Changing workcentres records'); $sql = "UPDATE workcentres SET location='" . $_POST['NewLocationID'] . "' WHERE location='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update workcentres records failed'); $result = DB_query($sql, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<br />' . _('Changing workorders records'); $sql = "UPDATE workorders SET loccode='" . $_POST['NewLocationID'] . "' WHERE loccode='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update workorders records failed'); $result = DB_query($sql, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<br />' . _('Changing users records'); $sql = "UPDATE www_users SET defaultlocation='" . $_POST['NewLocationID'] . "' WHERE defaultlocation='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to update users records failed'); $result = DB_query($sql, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); DB_ReinstateForeignKeys(); $result = DB_Txn_Commit(); echo '<br />' . _('Deleting the old location record'); $sql = "DELETE FROM locations WHERE loccode='" . $_POST['OldLocationID'] . "'"; $ErrMsg = _('The SQL to delete the old location record failed'); $result = DB_query($sql, $ErrMsg, $DbgMsg, true); echo ' ... ' . _('completed'); echo '<p>' . _('Location code') . ': ' . $_POST['OldLocationID'] . ' ' . _('was successfully changed to') . ' : ' . $_POST['NewLocationID']; } //only do the stuff above if $InputError==0 } echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; echo '<div class="centre">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<br /> <table>
function executeSQL($sql, $db, $TrapErrors = False) { /* Run an sql statement and return an error code */ DB_IgnoreForeignKeys($db); $result = DB_query($sql, $db, '', '', false, $TrapErrors); $ErrorNumber = DB_error_no($db); DB_ReinstateForeignKeys($db); return $ErrorNumber; }