isset($_GET['user_id']) ? $user_id = $_GET['user_id'] : ($user_id = ""); $logAction = ""; $logDebugSQL = ""; if (isset($_POST["submit"])) { isset($_POST['user_id']) ? $user_id = $_POST['user_id'] : ($user_id = ""); include 'library/opendb.php'; if (trim($user_id) != "") { $currDate = date('Y-m-d H:i:s'); $currBy = $_SESSION['operator_user']; $sql = "INSERT INTO " . $configValues['CONFIG_DB_TBL_DALOBILLINGINVOICE'] . " (id, user_id, date, status_id, type_id, notes, creationdate, creationby, updatedate, updateby) " . " VALUES (0, '" . $dbSocket->escapeSimple($user_id) . "', '" . $dbSocket->escapeSimple($invoice_date) . "', '" . $dbSocket->escapeSimple($invoice_status_id) . "', '" . $dbSocket->escapeSimple($invoice_type_id) . "', '" . $dbSocket->escapeSimple($invoice_notes) . "', " . " '{$currDate}', '{$currBy}', NULL, NULL)"; $res = $dbSocket->query($sql); $logDebugSQL .= $sql . "\n"; if (!PEAR::isError($res)) { $invoice_id = $dbSocket->getOne("SELECT LAST_INSERT_ID() FROM `" . $configValues['CONFIG_DB_TBL_DALOBILLINGINVOICE'] . "`"); // add the invoice items which the user created addInvoiceItems($dbSocket, $invoice_id, $invoice_items); $successMsg = "Added to database new invoice: <b>{$invoice_id}</b>"; $logAction .= "Successfully added new invoice [{$invoice_id}] on page: "; } else { $failureMsg = "Error in executing invoice INSERT statement"; $logAction .= "Failed adding new invoice on page: "; } } else { $failureMsg = "you must provide a user id which matches the userbillinfo records"; $logAction .= "Failed adding new invoice on page: "; } include 'library/closedb.php'; } function addInvoiceItems($dbSocket, $invoice_id, $invoice_items) { global $logDebugSQL;
$logAction = ""; $logDebugSQL = ""; include 'library/opendb.php'; if (isset($_POST["submit"])) { if (trim($invoice_id) != "") { $currDate = date('Y-m-d H:i:s'); $currBy = $_SESSION['operator_user']; $invoice_id = $dbSocket->escapeSimple($invoice_id); $sql = "UPDATE " . $configValues['CONFIG_DB_TBL_DALOBILLINGINVOICE'] . " SET " . " date='" . $dbSocket->escapeSimple($invoice_date) . "', " . " status_id='" . $dbSocket->escapeSimple($invoice_status_id) . "', " . " type_id='" . $dbSocket->escapeSimple($invoice_type_id) . "', " . " notes='" . $dbSocket->escapeSimple($invoice_notes) . "', " . " updatedate='{$currDate}', updateby='{$currBy}' " . " WHERE id='" . $invoice_id . "'"; $res = $dbSocket->query($sql); $logDebugSQL .= $sql . "\n"; if (!PEAR::isError($res)) { //$invoice_id = $dbSocket->getOne( "SELECT LAST_INSERT_ID() FROM `".$configValues['CONFIG_DB_TBL_DALOBILLINGINVOICE']."`" ); //var_dump($invoice_id); // add the invoice items which the user created addInvoiceItems($dbSocket, $invoice_id); $successMsg = "Added to database new invoice: <b>{$invoice_id}</b>"; $logAction .= "Successfully added new invoice [{$invoice_id}] on page: "; } else { $failureMsg = "Error in executing invoice INSERT statement"; $logAction .= "Failed adding new invoice on page: "; } } else { $failureMsg = "you must provide a user id which matches the userbillinfo records"; $logAction .= "Failed adding new invoice on page: "; } } function addInvoiceItems($dbSocket, $invoice_id = '') { global $logDebugSQL; global $configValues;