function write(&$frm) { if (isset($_REQUEST["btn_back"])) { return enter($frm); } if ($frm->validate("write")) { return confirm($frm); } $upd = new dbUpdate("suppstock", "cubit"); $del = new dbDelete("suppstock", "cubit"); foreach ($_REQUEST["stkcod"] as $suppid => $stkcod) { if (empty($stkcod)) { $del->setOpt("suppid='{$suppid}' AND stkid='{$_REQUEST['id']}'"); $del->run(); continue; } $cols = grp(m("suppid", $suppid), m("stkid", $_REQUEST["id"]), m("stkcod", $stkcod)); $upd->setOpt($cols, "suppid='{$suppid}' AND stkid='{$_REQUEST['id']}'"); $upd->run(DB_REPLACE); } foreach ($_REQUEST["stkdes"] as $suppid => $stkdes) { if (empty($stkcod)) { $del->setOpt("suppid='{$suppid}' AND stkid='{$_REQUEST['id']}'"); $del->run(); continue; } $cols = grp(m("suppid", $suppid), m("stkid", $_REQUEST["id"]), m("stkdes", $stkdes)); $upd->setOpt($cols, "suppid='{$suppid}' AND stkid='{$_REQUEST['id']}'"); $upd->run(DB_REPLACE); } $OUT = "<script>window.close();</script>"; return $OUT; }
function bdel_write($GET) { extract($GET); require_lib("validate"); $v = new validate(); foreach ($ids as $key => $invid) { $v->isOk($invid, "num", 1, 20, "Invalid recuring invoice number."); } if ($v->isError()) { $err = $v->genErrors(); $err .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>"; return $err; } $del = new dbDelete("nons_invoices", "cubit"); foreach ($ids as $key => $invid) { $del->setOpt(wgrp(m("invid", $invid))); $del->run(); } $OUT = "\n\t\t<h3>Batch Delete Non-Stock Invoices</h3>\n\t\tSuccessfully deleted non-stock invoices." . mkQuickLinks(ql("nons-invoice-view.php", "View Non-Stock Invoices")); return $OUT; }