function cancel() { extract($_REQUEST); pglib_transaction("BEGIN"); if (isset($rem) && is_array($rem)) { foreach ($rem as $invid) { db_conn("cubit"); $sql = "DELETE FROM pinvoices WHERE invid='{$invid}'"; $pinvRslt = db_exec($sql) or errDie("Unable to remove invoice from Cubit."); #get any allocated serial numbers and remove items ... AND re-allocate stock $get_sers = "SELECT ss,serno,stkid,qty FROM pinv_items WHERE invid = '{$invid}'"; $run_sers = db_exec($get_sers) or errDie("Unable to get invoice items serial numbers"); if (pg_numrows($run_sers) < 1) { #no items ? } else { while ($parr = pg_fetch_array($run_sers)) { if (strlen($parr['ss']) > 0) { $me = $parr['ss']; } else { $me = $parr['serno']; } #determine which table to connect to and update it switch (substr($me, strlen($me) - 1, 1)) { case "0": $tab = "ss0"; break; case "1": $tab = "ss1"; break; case "2": $tab = "ss2"; break; case "3": $tab = "ss3"; break; case "4": $tab = "ss4"; break; case "5": $tab = "ss5"; break; case "6": $tab = "ss6"; break; case "7": $tab = "ss7"; break; case "8": $tab = "ss8"; break; case "9": $tab = "ss9"; break; default: return order($_POST, "The code you selected is invalid"); } $upd = "UPDATE {$tab} SET active = 'yes' WHERE code = '{$parr['ss']}' OR code = '{$parr['serno']}'"; $run_upd = db_exec($upd) or errDie("Unable to update stock serial numbers"); #look 4 this stock item $get_stock = "SELECT * FROM stock WHERE stkid = '{$parr['stkid']}' LIMIT 1"; $run_stock = db_exec($get_stock) or errDie("Unable to get stock information."); if (pg_numrows($run_stock) < 1) { #cant find stock item ??? } else { $min_alloc = $parr['qty'] + 0; $starr = pg_fetch_array($run_stock); #all set ... re-allocate stock $update_sql = "UPDATE stock SET alloc = alloc - '{$min_alloc}' WHERE stkid = '{$starr['stkid']}'"; $update_run = db_exec($update_sql) or errDie("Unable to update allocated stock information."); } } } #now remove the items $rem_items = "DELETE FROM pinv_items WHERE invid = '{$invid}'"; $run_rem = db_exec($rem_items) or errDie("Unable to remove invoice items"); } } return printInv(); }
# # # # # # # # # # # require "settings.php"; if (isset($_POST["key"])) { switch ($_POST["key"]) { case "viewinv": $OUTPUT = printInv($_POST); break; case "viewtemp": $OUTPUT = printtemp($_POST); break; default: $OUTPUT = slct(); } } else { # Display default output $OUTPUT = slct(); } require "template.php"; # Default view function slct() {
# # # # # # # # # # ## # credit-invoice-details.php :: Module to view & print invoices ## require "settings.php"; # print invoice info $OUTPUT = printInv($_GET['ordnum']); require "template.php"; # Print the invoice info function printInv($ordnum) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($ordnum, "num", 1, 50, "Invalid order number."); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class=err>" . $e["msg"]; }
switch ($_REQUEST["key"]) { case "Send Emails": if (!isset($_REQUEST["evs"]) or !is_array($_REQUEST["evs"])) { $OUTPUT = printInv(); } else { $evss = implode(",", $_REQUEST["evs"]); header("Location: quote-email.php?evs={$evss}"); } break; case "view": default: $OUTPUT = printInv(); break; } } else { $OUTPUT = printInv(); } $OUTPUT .= mkQuickLinks(ql("quote-new.php", "New Quote"), ql("customers-new.php", "New Customer")); require "template.php"; ## # Functions ## # show quotes function printInv() { extract($_REQUEST); if (isset($key)) { $key = strtolower($key); switch ($key) { case "export to spreadsheet": case "print":
$nA[] = 1000000; $tA = array(0.6, 0.7, 0.8, 0.9, 0.95, 0.975, 0.99, 0.995); printf("%7s", "df"); foreach ($tA as $t) { printf(" t=%4.3f", $t); } printf("\n"); foreach ($nA as $n) { printf("%7d", $n); foreach ($tA as $t) { printf(" %7.3f", tInv($t, $n, 0.001)); } printf("\n"); } } printInv(); function printTtest() { $before = array(25, 25, 27, 44, 30, 67, 53, 53, 52, 60, 28); printf("before:"); foreach ($before as $elm) { printf(" %d", $elm); } printf("\n"); $after = array(27, 29, 37, 56, 46, 82, 57, 80, 61, 59, 43); printf("after:"); foreach ($after as $elm) { printf(" %d", $elm); } printf("\n"); $dArr = sampDiff($before, $after);