本文整理汇总了PHP中validate::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::addError方法的具体用法?PHP validate::addError怎么用?PHP validate::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validate
的用法示例。
在下文中一共展示了validate::addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_details
function write_details($_POST)
{
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($branch_ip, "url", 1, 50, "Invalid Branch IP.");
$v->isOk($branch_company, "url", 4, 4, "Invalid Branch Company Code.");
$v->isOk($branch_username, "string", 1, 50, "Invalid Branch Username.");
// $v->isOk ($branch_password, "url", 1, 50, "Invalid Branch Password.");
// $v->isOk ($branch_passwordconfirm, "url", 1, 50, "Invalid Branch Password.");
// $v->isOk ($branch_ip, "url", 1, 50, "Invalid Branch IP.");
if ($branch_password != $branch_passwordconfirm) {
$v->addError($branch_password, "Passwords do not match.");
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return get_details($_POST, $confirmCust);
}
db_connect();
$add_sql = "\n\t\tINSERT INTO branches_data (\n\t\t\tbranch_name, branch_desc, branch_contact, branch_ip, \n\t\t\tdate_added, last_online, branch_username, branch_password, \n\t\t\tlast_login_from, branch_localuser, branch_company\n\t\t) VALUES (\n\t\t\t'{$branch_name}', '{$branch_desc}', '{$branch_contact}', '{$branch_ip}', \n\t\t\t'now', '1990-01-01', '{$branch_username}', md5('{$branch_password}'), \n\t\t\t'1990-01-01', '{$branch_localuser}', '{$branch_company}'\n\t\t)";
$run_add = pg_exec($add_sql) or errDie("Unable to add branch information.");
$display = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Branch Added</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>Branch Has Been Added.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t";
return $display;
}
示例2: confirm
function confirm($_POST)
{
extract($_POST);
require_lib("validate");
$v = new validate();
$v->isOk("{$retrtries}", "num", 0, 3, "Invalid value for tries.");
$v->isOk("{$retrmins}", "num", 0, 3, "Invalid value for minutes.");
if ($retrtries != 0 && $retrmins == 0) {
$v->addError('', "Tries needs a value");
} elseif ($retrmins != 0 && $retrtries == 0) {
$v->addError('', "Minutes needs a value");
}
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>{$e['msg']}</li>";
}
return enter($confirm);
}
$OUTPUT = "<form method=post action='" . SELF . "'>\n\n\t<input type=hidden name=key value='write'>\n\t<input type=hidden name=retrtries value='{$retrtries}'>\n\t<input type=hidden name=retrminutes value='{$retrmins}'>\n\n\t<table border=0 cellspacing='" . TMPL_tblCellSpacing . "' cellpadding='" . TMPL_tblCellPadding . "'>\n\t\t<th>Setting</th>\n\t\t<th>Value</th>\n\t\t<tr class='bg-odd'>\n\t\t\t<td>Login retries:</td>\n\t\t\t<td>{$retrtries}</td>\n\t\t</tr>\n\t\t<tr class='bg-even'>\n\t\t\t<td>Blocked Time:</td>\n\t\t\t<td>{$retrmins}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align=right colspan=2><input type=submit value='Write »'></td>\n\t\t</tr>\n\t\t<tr><td> </td></tr>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>\n\t</form>";
require 'template.php';
}
示例3: write
function write($_POST)
{
extract($_POST);
require_lib("validate");
$v = new validate();
$v->isOk($assetid, "num", 0, 9, "Invalid stock id (dropdown)");
if ($assetid == 0) {
$v->addError(0, "Please select an asset");
}
$v->isOk($cusnum, "num", 0, 9, "Invalid customer number (dropdown)");
$v->isOk($description, "string", 1, 255, "Invalid description.");
if ($cusnum == 0) {
$v->addError(0, "Please select a customer.");
}
// Display Errors
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>{$e['msg']}</li>";
}
return enter($confirm);
}
// See which stock selection we made
$sql = "SELECT * FROM cubit.assets WHERE id='{$assetid}'";
$stkRslt = db_exec($sql) or errDie("Unable to retrieve stock from Cubit.");
$stock = pg_fetch_array($stkRslt);
$sql = "INSERT INTO workshop (asset_id, stkcod, cusnum, serno, description, notes,\n\t\t\t\tstatus, cdate, active, e_date)\n\t\t\tVALUES ('{$assetid}', '{$stock['des']}', '{$cusnum}', '{$stock['serial']}', '{$description}',\n\t\t\t\t'" . base64_encode($notes) . "', 'Present', current_date, 'true',\n\t\t\t\t'{$ex_date}')";
$wsRslt = db_exec($sql) or errDie("Unable to insert workshop data into Cubit.");
$sql = "INSERT INTO hire.service_history(asset_id, description)\n\t\t\tVALUES ('{$assetid}', '{$stock['des']}')";
db_exec($sql) or errDie("Unable to add to service history.");
if (pg_affected_rows($wsRslt) == 0) {
return $OUTPUT = "<center><li class=err>Could not be added to the workshop</li></center>";
} else {
$refnum = pglib_lastid("workshop", "refnum");
return $OUTPUT = "<li>Successfully added to workshop</li> <script>printer(\"" . SELF . "?key=receipt&cusnum={$cusnum}&refnum={$refnum}&description={$description}&conditions={$conditions}\");</script>";
}
}
示例4: write_data
function write_data($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($id, "num", 1, 9, "ID Field (hidden)");
$v->isOk($surname, "string", 1, 100, "Last name");
$v->isOk($name, "string", 0, 100, "First name");
$v->isOk($account_id, "num", 0, 9, "Account ID (hidden)");
$v->isOk($account_type, "string", 0, 100, "Account type (hidden)");
$v->isOk($lead_source, "string", 0, 100, "Lead Source");
$v->isOk($title, "string", 0, 100, "Title");
$v->isOk($department, "string", 0, 100, "Department");
$v->isOk($tell, "string", 0, 100, "Home Phone");
$v->isOk($cell, "string", 0, 100, "Mobile Phone");
$v->isOk($fax, "string", 0, 100, "Fax");
$v->isOk($tell_office, "string", 0, 100, "Office Phone");
$v->isOk($tell_other, "string", 0, 100, "Other Phone");
$v->isOk($email, "string", 0, 100, "Email");
$v->isOk($email_other, "string", 0, 100, "Other Email");
$v->isOk($assistant, "string", 0, 100, "Assistant");
$v->isOk($assistant_phone, "string", 0, 100, "Assistant Phone");
$v->isOk($padd, "string", 0, 250, "Physical Address");
$v->isOk($padd_city, "string", 0, 100, "Physical Address: City");
$v->isOk($padd_state, "string", 0, 100, "Physical Address: State/Province");
$v->isOk($padd_code, "string", 0, 100, "Physical Address: Postal Code");
$v->isOk($padd_country, "string", 0, 100, "Physical Address: Country");
$v->isOk($hadd, "string", 0, 250, "Postal Address");
$v->isOk($hadd_city, "string", 0, 100, "Postal Address: City");
$v->isOk($hadd_state, "string", 0, 100, "Postal Address: State/Province");
$v->isOk($hadd_code, "string", 0, 100, "Postal Address: Postal Code");
$v->isOk($hadd_country, "string", 0, 100, "Postal Address: Country");
$v->isOk($description, "string", 0, 100, "Description");
$v->isOk($website, "string", 0, 255, "Website");
$v->isOk($religion, "string", 0, 100, "Religion");
$v->isOk($race, "string", 0, 100, "Race");
$v->isOk($gender, "string", 0, 6, "Gender");
$v->isOk($Con, "string", 2, 3, "Invalid private.");
$v->isOk($salespn, "num", 1, 9, "Sales person.");
$v->isOk($team_id, "num", 1, 9, "Team");
if (!empty($ncdate_day) || !empty($ncdate_month) || !empty($ncdate_year)) {
$v->isOk($ncdate_day, "num", 1, 2, "Next contact date (Day)");
$v->isOk($ncdate_month, "num", 1, 2, "Next contact date (Month)");
$v->isOk($ncdate_year, "num", 4, 4, "Next contact date (Year)");
$ncdate = ", ncdate = '{$ncdate_year}-{$ncdate_month}-{$ncdate_day}'";
} else {
$ncdate = "";
}
$birthdate = "{$bf_year}-{$bf_month}-{$bf_day}";
if ($v->isOk($birthdate, "string", 1, 100, "Birthdate")) {
if (!checkdate($bf_month, $bf_day, $bf_year)) {
$v->addError("_OTHER", "Invalid birthdate. No such date exists.");
}
}
$birthdate_description = date("d F Y", mktime(0, 0, 0, $bf_day, $bf_month, $bf_year));
# display errors, if any
if ($v->isError()) {
$err = "The following field value errors occured:<br>";
$errors = $v->getErrors();
foreach ($errors as $e) {
if ($e["value"] == "_OTHER") {
$err .= "<li class='err'>{$e['msg']}</li>";
} else {
$err .= "<li class='err'>Invalid characters: {$e['msg']}</li>";
}
}
return get_data($_POST, $err);
}
db_conn('crm');
if (!pglib_transaction("BEGIN")) {
return "<li class='err'>Unable to edit lead(TB)</li>";
}
$Sl = "SELECT * FROM leads WHERE id='{$id}'";
$Ry = db_exec($Sl) or errDie("Unable to get lead details.");
if (pg_num_rows($Ry) < 1) {
return "Invalid lead.";
}
$cdata = pg_fetch_array($Ry);
if ($account_type == "Customer") {
db_conn("cubit");
$sql = "SELECT surname FROM customers WHERE cusnum='{$account_id}'";
$rslt = db_exec($sql) or errDie("Error reading account name (customers)");
if (pg_num_rows($rslt) > 0) {
$accountname = pg_fetch_result($rslt, 0, 0);
} else {
$account_id = 0;
$accountname = "";
$account_type = "";
}
} else {
if ($account_type == "Supplier") {
db_conn("cubit");
$sql = "SELECT supname FROM suppliers WHERE supid='{$account_id}'";
$rslt = db_exec($sql) or errDie("Error reading account name (suppliers)");
if (pg_num_rows($rslt) > 0) {
$accountname = pg_fetch_result($rslt, 0, 0);
} else {
$account_id = 0;
//.........这里部分代码省略.........
示例5: validate
function validate($data)
{
extract($data);
require_lib("validate");
$v = new validate();
$v->isOk($pricelist, "num", 1, 20, "Invalid pricelist selection.");
$v->isOk($category, "num", 1, 20, "Invalid category selection.");
$v->isOk($classification, "num", 1, 20, "Invalid classification selection.");
$v->isOk($increase, "float", 1, 20, "Invalid increase percentage.");
$v->isOk($decrease, "float", 1, 20, "Invalid decrease percentage.");
if (is_numeric($pricelist) && $pricelist) {
$sql = "SELECT listid FROM exten.pricelist WHERE listid='{$pricelist}'";
$pricelist_rslt = db_exec($sql) or errDie("Unable to retrieve pricelist.");
if (!pg_num_rows($pricelist_rslt)) {
$v->addError("", "Selected pricelist does not exist.");
}
}
if (is_numeric($category) && $category) {
$sql = "SELECT catid FROM cubit.stockcat WHERE catid='{$category}'";
$category_rslt = db_exec($sql) or errDie("Unable to retrieve category.");
if (!pg_num_rows($category_rslt)) {
$v->addError("", "Selected category does not exist.");
}
}
if (is_numeric($classification) && $classification) {
$sql = "SELECT clasid FROM cubit.stockclass WHERE clasid='{$classification}'";
$classification_rslt = db_exec($sql) or errDie("Unable to retrieve classification.");
if (!pg_num_rows($classification_rslt)) {
$v->addError("", "Selected classification does not exist.");
}
}
if ($v->isError()) {
return enter($v->genErrors());
}
return true;
}
示例6: write
function write()
{
extract($_REQUEST);
require_lib("validate");
$v = new validate();
$v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
$sndate = "{$ninv_year}-{$ninv_month}-{$ninv_day}";
if (!checkdate($ninv_month, $ninv_day, $ninv_year)) {
$v->addError($sdate, "Invalid Date.");
}
pglib_transaction("BEGIN");
// Get invoice info
$sql = "SELECT * FROM cubit.nons_invoices WHERE invid='{$invid}' AND div='" . USER_DIV . "'";
$inv_rslt = db_exec($sql) or errDie("Unable to get invoice information");
if (pg_numrows($inv_rslt) < 1) {
return "<i class='err'>Not Found</i>";
}
$inv = pg_fetch_array($inv_rslt);
$TOTAL = $inv["subtot"] + $inv["vat"];
$notenum = pglib_lastid("cubit.nons_inv_notes", "noteid");
$notenum++;
// Add to the non stock credit notes
$sql = "\r\n\t\tINSERT INTO cubit.nons_inv_notes (\r\n\t\t\tinvid, invnum, cusname, cusaddr, cusvatno, chrgvat, \r\n\t\t\tdate, subtot, vat, total, username, prd, notenum, ctyp, \r\n\t\t\tremarks, div\r\n\t\t) VALUES (\r\n\t\t\t'{$inv['invid']}', '{$inv['invnum']}', '{$inv['cusname']}', '{$inv['cusaddr']}', '{$inv['cusvatno']}', '{$inv['chrgvat']}', \r\n\t\t\t'{$sndate}', '{$inv['subtot']}', '{$inv['vat']}', '{$TOTAL}', '" . USER_NAME . "', '" . PRD_DB . "', '{$notenum}', '{$inv['ctyp']}', \r\n\t\t\t'{$inv['remarks']}', '" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to save credit note.");
$noteid = pglib_lastid("cubit.nons_inv_notes", "noteid");
$sql = "SELECT count(id) FROM cubit.nons_inv_items WHERE invid='{$invid}'";
$count_rslt = db_exec($sql) or errDie("Unable to retrieve amount of items.");
$item_count = pg_fetch_result($count_rslt, 0);
$i = 0;
$page = 0;
foreach ($ids as $key => $id) {
$sql = "SELECT * FROM cubit.nons_inv_items WHERE invid='{$invid}' AND id='{$id}'";
$item_rslt = db_exec($sql) or errDie("Unable to retrieve item.");
$item_data = pg_fetch_array($item_rslt);
if ($item_data['vatex'] == 'y') {
$ex = "#";
} else {
$ex = " ";
}
// Time for a new page ??
if ($i >= 25) {
$page++;
$i = 0;
}
$products[$page][] = "\r\n\t\t\t<tr valign='top'>\r\n\t\t\t\t<td style='border-right: 2px solid #000'>\r\n\t\t\t\t\t{$ex} {$item_data['description']} \r\n\t\t\t\t</td>\r\n\t\t\t\t<td style='border-right: 2px solid #000'>\r\n\t\t\t\t\t{$item_data['qty']} \r\n\t\t\t\t</td>\r\n\t\t\t\t<td style='border-right: 2px solid #000' align='right' nowrap>\r\n\t\t\t\t\t" . CUR . " {$item_data['unitcost']} \r\n\t\t\t\t</td>\r\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$item_data['amt']} </td>\r\n\t\t\t</tr>";
$i++;
// Create credit note item
$sql = "\r\n\t\t\tINSERT INTO cubit.nons_note_items (\r\n\t\t\t\tnoteid, qty, description, amt, unitcost, \r\n\t\t\t\tvatcode\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$noteid}', '{$qtys[$key]}', '{$item_data['description']}', '{$amts[$key]}', '{$item_data['unitcost']}', \r\n\t\t\t\t'{$item_data['vatex']}'\r\n\t\t\t)";
db_exec($sql) or errDie("Unable to create credit note item.");
$sql = "SELECT grpid FROM cubit.assets WHERE id='{$item_data['asset_id']}'";
$group_rslt = db_exec($sql) or errDie("Unable to retrieve group.");
$group_id = pg_fetch_result($group_rslt, 0);
$discount = $inv["discount"] / $item_count;
$amt = $item_data["amt"];
// Update royalty report and detail report
$sql = "\r\n\t\t\tINSERT INTO hire.revenue (\r\n\t\t\t\tgroup_id, asset_id, total, discount, credit\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$group_id}', '{$item_data['asset_id']}', '-{$amt}', '-{$discount}', '1'\r\n\t\t\t)";
db_exec($sql) or errDie("Unable to update revenue.");
$i++;
}
$blank_lines = 25;
foreach ($products as $key => $val) {
$bl = $blank_lines - count($products[$key]);
for ($i = 0; $i <= $bl; $i++) {
$products[$key][] = "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'> </td>\r\n\t\t\t\t\t<td> </td>\r\n\t\t\t\t</tr>";
}
}
// Retrieve customer debt account
$sql = "\r\n\t\tSELECT debtacc FROM exten.departments \r\n\t\t\tLEFT JOIN cubit.customers ON departments.deptid=customers.deptid\r\n\t\tWHERE cusnum='{$inv['cusid']}'";
$dept_rslt = db_exec($sql) or errDie("Unable to retrieve departments.");
$debtacc = pg_fetch_result($dept_rslt, 0);
$hireacc = $inv["accid"];
$vatacc = gethook("accnum", "salesacc", "name", "VAT", "vat");
$refnum = getrefnum();
writetrans($hireacc, $debtacc, $sndate, $refnum, $inv["subtot"], "Non-Stock Invoice No. {$inv['invnum']} Credit Note No. {$noteid} Customer\r\n\t\t{$inv['cusname']}");
if ($inv["vat"] != 0) {
writetrans($vatacc, $debtacc, $sndate, $refnum, $inv["vat"], "Non-Stock Invoice No. {$inv['invnum']} Credit Note No. {$noteid} VAT.\r\n\t\tCustomer {$inv['cusname']}");
}
// Record on the statement
$sql = "\r\n\t\tINSERT INTO cubit.stmnt (\r\n\t\t\tcusnum, invid, amount, date, type, \r\n\t\t\tdiv\r\n\t\t) VALUES (\r\n\t\t\t'{$inv['cusid']}', '{$noteid}', '-{$TOTAL}', '{$sndate}', 'Non-Stock Credit Note, for invoice {$inv['invnum']}', \r\n\t\t\t'" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to insert to customer statement.");
// Update the customer (Make the balance less)
$sql = "UPDATE cubit.customers SET balance=(balance-'{$TOTAL}') WHERE cusnum='{$inv['cusid']}'";
db_exec($sql) or errDie("Unable to update customer balance.");
// Update the customer (Make the balance less)
$sql = "UPDATE cubit.open_stmnt SET balance=(balance-'{$TOTAL}') WHERE cusnum='{$inv['cusid']}'";
db_exec($sql) or errDie("Unable to update customer balance.");
// Create ledger record
custledger($inv["cusid"], $hireacc, $sndate, $noteid, "Non-Stock Credit Note {$noteid}", $TOTAL, "c");
custCT($inv["total"], $inv["cusid"], $inv["odate"]);
// Update non-stock invoice
$sql = "UPDATE cubit.nons_invoices SET balance=(balance-'{$TOTAL}') WHERE invid='{$invid}'";
db_exec($sql) or errDie("Unable to update non-stock invoice.");
$sql = "\r\n\t\tINSERT INTO cubit.salesrec (\r\n\t\t\tedate, invid, invnum, debtacc, vat, total, typ, div\r\n\t\t) VALUES (\r\n\t\t\t'{$sndate}', '{$noteid}', '{$notenum}', '0', '{$inv['vat']}', '{$TOTAL}', 'nnon', '" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to record in sales.");
$sql = "\r\n\t\tINSERT INTO cubit.sj (\r\n\t\t\tcid, name, des, date, \r\n\t\t\texl, vat, inc, div\r\n\t\t) VALUES (\r\n\t\t\t'{$inv['cusid']}', '{$inv['cusname']}', 'Credit Note: {$noteid} Invoice {$inv['invnum']}', '{$sndate}', \r\n\t\t\t'-" . ($TOTAL - $inv["vat"]) . "', '{$inv['vat']}', '" . -sprint($TOTAL) . "', '" . USER_DIV . "'\r\n\t\t)";
db_exec($sql) or errDie("Unable to record in sj.");
$sql = "UPDATE cubit.nons_invoices SET accepted='note' WHERE invid='{$invid}'";
db_exec($sql) or errDie("Unable to update invoice.");
com_invoice($inv["salespn"], -($TOTAL - $inv["vat"]), 0, $inv["invnum"], $sndate);
$cc = "\r\n\t\t<script>\r\n\t\t\tCostCenter('ct', 'Credit Note', '{$sndate}',\r\n\t\t\t'Non Stock Credit Note No.{$noteid}', '" . ($TOTAL - $inv["vat"]) . "', '');\r\n\t </script>";
//.........这里部分代码省略.........
示例7: write_req
function write_req($_POST)
{
global $_SESSION;
# get vars
extract($_POST);
$user = $_SESSION["USER_NAME"];
# validate input
require_lib("validate");
$v = new validate();
if (!isset($to)) {
$v->addError("", "No user specified");
} else {
foreach ($to as $arr => $arrval) {
$v->isOk($arrval, "string", 1, 200, "Invalid recipient: {$arrval}");
}
}
// $v->isOk ($des,"string", 1,200, "Invalid message.");
$v->isOk($des, "text", 1, 200, "Invalid message.");
$v->isOk($user, "string", 1, 200, "Invalid user.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return $confirmCust . get_req();
}
db_conn('cubit');
// if should send to all, clear the $to list, and add all users
// it is cleared just incase sum1 selected All option together with another one
// since this could cause the same message sent to the same users twice!!!!
if (in_array("_ALL_", $to)) {
$to = "";
$rslt = db_exec("SELECT username FROM users");
// if users found
if (pg_num_rows($rslt) > 0) {
while ($row = pg_fetch_array($rslt)) {
$to[] = $row["username"];
}
}
}
# write to db
// create the list of users the messages should get sent to
$msg_results = "";
foreach ($to as $arr => $arrval) {
$Sql = "\n\t\t\tINSERT INTO req (\n\t\t\t\tsender, recipient, message, timesent, viewed\n\t\t\t) VALUES (\n\t\t\t\t'{$user}', '{$arrval}', '{$des}', CURRENT_TIMESTAMP, 0\n\t\t\t)";
$Rslt = db_exec($Sql) or errDie("Unable to add to database.", SELF);
if (pg_cmdtuples($Rslt) < 1) {
return "Unable to access database.";
} else {
// if it isn't noticed that person has new messages, notify him
$rslt = db_exec("SELECT * from req_new WHERE for_user='{$arrval}' ");
if (pg_num_rows($rslt) == 0) {
db_exec("INSERT INTO req_new VALUES('{$arrval}')");
}
$msg_results .= "<tr class='datacell'><td>Your message has been sent to {$arrval}</td></tr>";
}
}
$write_req = "\n\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Message proccessed</th>\n\t\t\t</tr>\n\t\t\t<tr class='even'>\n\t\t\t\t<td>{$msg_results}</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<table cellpadding='2' cellspacing='0' class='shtable'>\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\n\t\t\t</tr>\n\t\t\t<tr class='odd'>\n\t\t\t\t<td><a href='" . SELF . "'>Send another message</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='odd'>\n\t\t\t\t<td><a href='view_req.php'>View Messages</a></td>\n\t\t\t</tr>\n\t\t</table>";
return $write_req;
}
示例8: write
function write($_POST)
{
#get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$sdate = $syear . "-" . $smon . "-" . $sday;
if (!checkdate($smon, $sday, $syear)) {
$v->addError($sdate, "Invalid Date.");
}
# used to generate errors
$error = "asa@";
// check the invoice details
$v->isOK($cusname, "string", 1, 100, "Invalid customer name");
$v->isOK($cusaddr, "string", 1, 100, "Invalid customer address");
$v->isOK($cusvatno, "string", 1, 50, "Invalid customer vat number");
if ($chrgvat != "yes" && $chrgvat != "no") {
$v->addError($chrgvat, "Invalid vat option");
}
# check quantities
if (isset($qtys)) {
foreach ($qtys as $keys => $qty) {
$v->isOk($qty, "num", 1, 10, "Invalid Quantity for product number : <b>" . ($keys + 1) . "</b>");
$v->isOk($unitcost[$keys], "float", 1, 20, "Invalid Unit Price for product number : <b>" . ($keys + 1) . "</b>.");
$v->isOk($des[$keys], "string", 1, 255, "Invalid Description.");
if ($qty < 1) {
$v->isOk($qty, "num", 0, 0, "Error : Item Quantity must be at least one. Product number : <b>" . ($keys + 1) . "</b>");
}
}
}
# check amt
if (isset($amt)) {
foreach ($amt as $keys => $amount) {
$v->isOk($amount, "float", 1, 10, "Invalid Amount, please enter all details.");
}
}
# display errors, if any
$err = "";
if ($v->isError()) {
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class=err>" . $e["msg"];
}
$_POST['done'] = "";
return details($_POST, $err);
}
# Get purchase info
db_connect();
$sql = "SELECT * FROM nons_invoices WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to get purchase information");
if (pg_numrows($invRslt) < 1) {
return "<li>- invoices Not Found</li>";
}
$inv = pg_fetch_array($invRslt);
# check if purchase has been printed
if ($inv['done'] == "y") {
$error = "<li class=err> Error : invoice number <b>{$invid}</b> has already been printed.";
$error .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $error;
}
# insert purchase to DB
db_connect();
# begin updating
pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
/* -- Start remove old items -- */
# remove old items
$sql = "DELETE FROM nons_inv_items WHERE invid='{$invid}' AND div = '" . USER_DIV . "'";
$rslt = db_exec($sql) or errDie("Unable to update invoice items in Cubit.", SELF);
/* -- End remove old items -- */
if (isset($qtys)) {
foreach ($qtys as $keys => $value) {
if (isset($remprod)) {
if (in_array($keys, $remprod)) {
# skip product (wonder if $keys still align)
$amt[$keys] = 0;
continue;
} else {
# Calculate amount
$amt[$keys] = $qtys[$keys] * $unitcost[$keys];
# format ddate
$ddate[$keys] = "{$dyear[$keys]}-{$dmon[$keys]}-{$dday[$keys]}";
# insert purchase items
$sql = "INSERT INTO nons_inv_items(invid, qty, amt, unitcost, description, div)\n\t\t\t\t\t\t\tVALUES('{$invid}', '{$qtys[$keys]}', '{$amt[$keys]}', '{$unitcost[$keys]}', '{$des[$keys]}', '" . USER_DIV . "')";
$rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
}
} else {
# Calculate amount
$amt[$keys] = $qtys[$keys] * $unitcost[$keys];
# insert purchase items
$sql = "INSERT INTO nons_inv_items(invid, qty, amt, unitcost, description, div)\n\t\t\t\t\t\tVALUES('{$invid}', '{$qtys[$keys]}', '{$amt[$keys]}', '{$unitcost[$keys]}', '{$des[$keys]}', '" . USER_DIV . "')";
$rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
}
# everything is set place done button
$_POST["done"] = " | <input name=doneBtn type=submit value='Done'>";
}
} else {
$_POST["done"] = "";
//.........这里部分代码省略.........
示例9: alloc
function alloc($_POST, $err = "")
{
extract($_POST);
if (isset($back)) {
if (isset($e)) {
header("Location: cashbook-entry.php");
exit;
}
return sel_cus($_POST);
}
if (isset($print_recpt) and strlen($print_recpt) > 0) {
$send_print = "<input type='hidden' name='print_recpt' value='{$print_recpt}'>";
} else {
$send_print = "";
}
if (isset($bulk_pay) and strlen($bulk_pay) > 0) {
$send_bulk = "<input type='hidden' name='bulk_pay' value='yes'>";
} else {
$send_bulk = "";
}
$all = 0;
$date_arr = explode("-", $tdate);
$date_year = $date_arr[0];
$date_month = $date_arr[1];
$date_day = $date_arr[2];
require_lib("validate");
$v = new validate();
$v->isOk($bankid, "num", 1, 30, "Select Bank Account.");
$v->isOk($date_day, "num", 1, 2, "Invalid Date day.");
$v->isOk($all, "num", 1, 1, "Invalid allocation.");
$v->isOk($date_month, "num", 1, 2, "Invalid Date month.");
$v->isOk($date_year, "num", 1, 4, "Invalid Date Year.");
$v->isOk($descript, "string", 0, 255, "Invalid Description.");
$v->isOk($reference, "string", 0, 50, "Invalid Reference Name/Number.");
$v->isOk($cheqnum, "num", 0, 30, "Invalid Cheque number.");
$v->isOk($amt, "float", 1, 40, "Invalid amount.");
$v->isOk($cusid, "num", 1, 10, "Invalid customer number.");
if (strlen($date_year) != 4) {
$v->isOk($bankname, "num", 1, 1, "Invalid Date year.");
}
if ($amt < 0.01) {
$v->addError($amt, "Amount too small.");
}
$date = $date_day . "-" . $date_month . "-" . $date_year;
if (!checkdate($date_month, $date_day, $date_year)) {
$v->isOk($date, "num", 1, 1, "Invalid date.");
}
if ($v->isError()) {
$confirm = $v->genErrors();
$confirm .= "<br>" . "<input type='button' onClick='history.back();' value='« Correction'>";
return $confirm;
//.alloc($_POST);
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($date) >= strtotime($blocked_date_from) and strtotime($date) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
}
// bank account name
if ($bankid == "0" or ($bank = qryBankAcct($bankid, "accname, bankname")) === false) {
$bank['accname'] = "Cash";
$bank['bankname'] = "";
}
// customer name
$cus = qryCustomer($cusid, "cusname, surname");
if ($print_recpt == "yes") {
$show_print_recpt = "Yes";
} else {
$show_print_recpt = "No";
}
$confirm = "\n\t\t<h3>New Bank Receipt</h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t<input type='hidden' name='accnum' value=''>\n\t\t\t<input type='hidden' name='bankid' value='{$bankid}'>\n\t\t\t<input type='hidden' name='date' value='{$date}'>\n\t\t\t<input type='hidden' name='all' value='{$all}'>\n\t\t\t<input type='hidden' name='cusid' value='{$cusid}'>\n\t\t\t<input type='hidden' name='date_day' value='{$date_day}'>\n\t\t\t<input type='hidden' name='date_month' value='{$date_month}'>\n\t\t\t<input type='hidden' name='date_year' value='{$date_year}'>\n\t\t\t<input type='hidden' name='descript' value='{$descript}'>\n\t\t\t<input type='hidden' name='reference' value='{$reference}'>\n\t\t\t<input type='hidden' name='cheqnum' value='{$cheqnum}'>\n\t\t\t<input type='hidden' name='amt' value='{$amt}'>\n\t\t\t{$send_bulk}\n\t\t\t{$send_print}\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Field</th>\n\t\t\t\t<th>Value</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Account</td>\n\t\t\t\t<td>{$bank['accname']} - {$bank['bankname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Date</td>\n\t\t\t\t<td valign='center'>{$date}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Received from</td>\n\t\t\t\t<td valign='center'>{$cus['cusname']} {$cus['surname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Description</td>\n\t\t\t\t<td valign='center'>" . nl2br($descript) . "</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Reference</td>\n\t\t\t\t<td valign='center'>{$reference}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Cheque Number</td>\n\t\t\t\t<td valign='center'>{$cheqnum}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Amount</td>\n\t\t\t\t<td valign='center'>" . CUR . " {$amt}</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Print Receipt</td>\n\t\t\t\t<td>{$show_print_recpt}</td>\n\t\t\t</tr>";
/* OPTION 1 : AUTO ALLOCATE (allocate) */
#we need a new why of allocating this ... stock,nonstock,pos order is counter productive
#so, we get them all into an array, and sort that ...
if ($all == 0) {
$out = $amt;
$invs_arr = array();
// Connect to database
db_connect();
#####################[ GET OUTSTANDING INVOICES ]######################
$sql = "SELECT invnum, invid, balance, terms, odate FROM invoices WHERE cusnum = '{$cusid}' AND printed = 'y' AND balance>0 AND div = '" . USER_DIV . "' ORDER BY odate ASC";
$prnInvRslt = db_exec($sql);
while (($inv = pg_fetch_array($prnInvRslt)) && $out > 0) {
$invs_arr[] = array("s", $inv['odate'], "{$inv['invid']}", "{$inv['balance']}");
}
#####################[ GET OUTSTANDING NON STOCK INVOICES ]######################
$sql = "SELECT invnum, invid, balance, odate FROM nons_invoices WHERE cusid='{$cusid}' AND done='y' AND balance>0 AND div='" . USER_DIV . "' ORDER BY odate ASC";
$prnInvRslt = db_exec($sql);
while (($inv = pg_fetch_array($prnInvRslt)) && $out > 0) {
$invs_arr[] = array("n", $inv['odate'], "{$inv['invid']}", "{$inv['balance']}");
}
$out = sprint($out);
#####################[ GET OUTSTANDING POS INVOICES ]######################
$sqls = array();
for ($i = 1; $i <= 12; ++$i) {
$sqls[] = "\n\t\t\t\tSELECT invnum, invid, balance, odate \n\t\t\t\tFROM \"{$i}\".pinvoices \n\t\t\t\tWHERE cusnum='{$cusid}' AND done='y' AND balance > 0 AND div='" . USER_DIV . "'";
}
$sql = implode(" UNION ", $sqls);
$prnInvRslt = db_exec($sql);
//.........这里部分代码省略.........
示例10: confirm
function confirm($_POST)
{
extract($_POST);
if (isset($back)) {
return method($cusid);
}
// $date = "$date_day-$date_month-$date_year";
$amt = sprint(array_sum($paidamt));
$setamt = sprint(array_sum($stock_setamt));
if (!isset($print_recpt)) {
$print_recpt = "";
}
if (!isset($descript) or strlen($descript) < 1) {
$descript = $reference;
}
if (!isset($out1)) {
$out1 = '';
}
if (!isset($out2)) {
$out2 = '';
}
if (!isset($out3)) {
$out3 = '';
}
if (!isset($out4)) {
$out4 = '';
}
if (!isset($out5)) {
$out5 = '';
}
$date = "{$date_year}-{$date_month}-{$date_day}";
require_lib("validate");
$v = new validate();
$v->isOk($all, "num", 1, 1, "Invalid allocation.");
$v->isOk($bankid, "num", 1, 30, "Invalid Bank Account.");
$v->isOk($date, "date", 1, 14, "Invalid Date.");
$v->isOk($descript, "string", 1, 255, "Invalid Description.");
$v->isOk($reference, "string", 1, 50, "Invalid Reference Name/Number.");
$v->isOk($cheqnum, "num", 0, 30, "Invalid Cheque number.");
$v->isOk($amt, "float", 1, 40, "Invalid amount.");
$v->isOk($setamt, "float", 1, 40, "Invalid Settlement Amount.");
$v->isOk($setvat, "string", 1, 10, "Invalid Settlement VAT Option.");
$v->isOk($setvatcode, "string", 1, 40, "Invalid Settlement VAT code");
// $v->isOk($out, "float", 1, 40, "Invalid out amount.");
$v->isOk($out1, "float", 0, 40, "Invalid paid amount(currant).");
$v->isOk($out2, "float", 0, 40, "Invalid paid amount(30).");
$v->isOk($out3, "float", 0, 40, "Invalid paid amount(60).");
$v->isOk($out4, "float", 0, 40, "Invalid paid amount(90).");
$v->isOk($out5, "float", 0, 40, "Invalid paid amount(120).");
$v->isOk($cusid, "num", 1, 10, "Invalid customer number.");
$v->isOk($overpay, "float", 1, 40, "Invalid Unallocated Amount.");
$v->isOk($print_recpt, "string", 0, 10, "Invalid Print Receipt Setting.");
if ($amt + $overpay <= 0) {
$v->addError(0, "Invalid Amount Allocated To Receipt.");
}
if (isset($invids)) {
foreach ($invids as $key => $value) {
if ($paidamt[$key] < 0.01) {
continue;
}
if (!isset($stock_setamt[$key]) or strlen($stock_setamt[$key]) < 1) {
$stock_setamt[$key] = 0;
}
$v->isOk($invids[$key], "num", 1, 50, "Invalid Invoice No. [{$key}]");
$v->isOk($paidamt[$key], "float", 1, 40, "Invalid amount to be paid. [{$key}]");
$v->isOk($stock_setamt[$key], "float", 1, 40, "Invalid Settlement Discount Amount");
}
}
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
$_POST['OUT1'] = $out1 + 0;
$_POST['OUT2'] = $out2 + 0;
$_POST['OUT3'] = $out3 + 0;
$_POST['OUT4'] = $out4 + 0;
$_POST['OUT5'] = $out5 + 0;
return $confirm . alloc($_POST);
}
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($date) >= strtotime($blocked_date_from) and strtotime($date) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
}
$out += 0;
$OUT1 = $out1 + 0;
$OUT2 = $out2 + 0;
$OUT3 = $out3 + 0;
$OUT4 = $out4 + 0;
$OUT5 = $out5 + 0;
$tot = 0;
if (isset($invids)) {
foreach ($invids as $key => $value) {
if ($paidamt[$key] < 0.01) {
continue;
}
$tot += $paidamt[$key];
}
//.........这里部分代码省略.........
示例11: alloc
function alloc($_POST)
{
extract($_POST);
if (isset($back)) {
if (isset($e)) {
header("Location: cashbook-entry.php");
exit;
}
return sel_cus($_POST);
}
$passon = "";
require_lib("validate");
$v = new validate();
$v->isOk($all, "num", 1, 1, "Invalid allocation.");
for ($i = 0; $i < $rec_amount; $i++) {
if (!isset($descript[$i]) or !isset($reference[$i]) or !isset($setamt[$i]) or empty($descript[$i]) or empty($reference[$i]) or empty($setamt[$i])) {
continue;
}
$v->isOk($bankid[$i], "num", 1, 30, "Select Bank Account.");
$v->isOk($date_day[$i], "num", 1, 2, "Invalid Date day.");
$v->isOk($date_month[$i], "num", 1, 2, "Invalid Date month.");
$v->isOk($date_year[$i], "num", 1, 4, "Invalid Date Year.");
$v->isOk($descript[$i], "string", 0, 255, "Invalid Description.");
$v->isOk($reference[$i], "string", 0, 50, "Invalid Reference Name/Number.");
$v->isOk($cheqnum[$i], "num", 0, 30, "Invalid Cheque number.");
$v->isOk($amt[$i], "float", 1, 40, "Invalid amount.");
$v->isOk($setamt[$i], "float", 1, 40, "Invalid Settlement Amount.");
$v->isOk($setvat[$i], "string", 1, 10, "Invalid Settlement VAT Option.");
$v->isOk($setvatcode[$i], "string", 1, 40, "Invalid Settlement VAT code");
$v->isOk($cusid[$i], "num", 1, 10, "Invalid customer number.");
if (strlen($date_year[$i]) != 4) {
$v->isOk($bankname, "num", 1, 1, "Invalid Date year.");
}
if ($amt < 0.01) {
$v->addError($amt[$i], "Amount too small.");
}
$date[$i] = $date_day[$i] . "-" . $date_month[$i] . "-" . $date_year[$i];
if (!checkdate($date_month[$i], $date_day[$i], $date_year[$i])) {
$v->isOk($date[$i], "num", 1, 1, "Invalid date.");
}
// bank account name
if (($bank = qryBankAcct($bankid[$i], "accname, bankname")) === false) {
$bank[$i]['accname'] = "Cash";
$bank[$i]['bankname'] = "";
}
// customer name
$cus[$i] = qryCustomer($cusid[$i], "cusnum, cusname, surname");
}
if ($v->isError()) {
$confirm = $v->genErrors();
return $confirm . method($_POST);
}
// <input type='hidden' name='bankid' value='$bankid'>
$cust_arr = array();
$confirm = "\n\t\t<h3>New Bank Receipt</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t<input type='hidden' name='accnum' value=''>\n\t\t\t<input type='hidden' name='rec_amount' value='{$rec_amount}'>\n\t\t\t<input type='hidden' name='all' value='{$all}'>\n\t\t<table " . TMPL_tblDflts . ">";
for ($t = 0; $t < $rec_amount; $t++) {
if (!isset($descript[$t]) or !isset($reference[$t]) or !isset($setamt[$t]) or empty($descript[$t]) or empty($reference[$t]) or empty($setamt[$t])) {
continue;
}
$cus0 = $cus[$t]['cusnum'];
$cus1 = $cus[$t]['cusname'];
$cus2 = $cus[$t]['surname'];
// we dont do this ...
// $amt[$t] = $amt[$t] + $setamt[$t];
$amt[$t] = sprint($amt[$t]);
$setamt[$t] = sprint($setamt[$t]);
if ($setvat[$t] == "inc") {
$showsetvat = "VAT Inclusive";
} else {
$showsetvat = "No VAT";
}
$confirm .= "\n\t\t\t<tr>\n\t\t\t\t<th>Field</th>\n\t\t\t\t<th>Value</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Account</td>\n\t\t\t\t<td>{$bank['accname']} - {$bank['bankname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Date</td>\n\t\t\t\t<td valign='center'>{$date[$t]}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Received from</td>\n\t\t\t\t<td valign='center'>{$cus1} {$cus2}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Description</td>\n\t\t\t\t<td valign='center'>" . nl2br($descript[$t]) . "</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Reference</td>\n\t\t\t\t<td valign='center'>{$reference[$t]}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Cheque Number</td>\n\t\t\t\t<td valign='center'>{$cheqnum[$t]}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Amount</td>\n\t\t\t\t<td valign='center'>" . CUR . " {$amt[$t]}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Settlement Discount</td>\n\t\t\t\t<td valign='center'>" . CUR . " {$setamt[$t]} {$showsetvat}</td>\n\t\t\t</tr>";
/* OPTION 1 : AUTO ALLOCATE (allocate) */
if ($all == 0) {
$out[$t] = $amt[$t];
$invs_arr = array();
// Connect to database
db_connect();
#####################[ GET OUTSTANDING INVOICES ]######################
$sql = "SELECT invnum, invid, balance, terms, odate FROM invoices WHERE cusnum = '{$cusid[$t]}' AND printed = 'y' AND balance>0 AND div = '" . USER_DIV . "' ORDER BY odate ASC";
$prnInvRslt = db_exec($sql);
while (($inv = pg_fetch_array($prnInvRslt)) && $out > 0) {
$invs_arr[] = array("s", $inv['odate'], "{$inv['invid']}", "{$inv['balance']}");
}
#####################[ GET OUTSTANDING NON STOCK INVOICES ]######################
$sql = "SELECT invnum, invid, balance, odate FROM nons_invoices WHERE cusid='{$cusid[$t]}' AND done='y' AND balance>0 AND div='" . USER_DIV . "' ORDER BY odate ASC";
$prnInvRslt = db_exec($sql);
while (($inv = pg_fetch_array($prnInvRslt)) && $out > 0) {
$invs_arr[] = array("n", $inv['odate'], "{$inv['invid']}", "{$inv['balance']}");
}
#####################[ GET OUTSTANDING POS INVOICES ]######################
$sqls = array();
for ($i = 1; $i <= 12; ++$i) {
$sqls[] = "\n\t\t\t\t\tSELECT invnum, invid, balance, odate \n\t\t\t\t\tFROM \"{$i}\".pinvoices \n\t\t\t\t\tWHERE cusnum='{$cusid[$t]}' AND done='y' AND balance > 0 AND div='" . USER_DIV . "'";
}
$sql = implode(" UNION ", $sqls);
$prnInvRslt = db_exec($sql);
while ($inv = pg_fetch_array($prnInvRslt)) {
$invs_arr[] = array("p", $inv['odate'], "{$inv['invid']}", "{$inv['balance']}");
}
//.........这里部分代码省略.........
示例12: write
function write($_GET)
{
$showvat = TRUE;
# get vars
extract($_GET);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($invid, "num", 1, 20, "Invalid Invoice number.");
$sndate = $ninv_year . "-" . $ninv_month . "-" . $ninv_day;
if (!checkdate($ninv_month, $ninv_day, $ninv_year)) {
$v->addError($sdate, "Invalid Date.");
}
$td = $sndate;
foreach ($ids as $key => $id) {
$v->isOk($id, "num", 1, 20, "Invalid Item number.");
$v->isOk($qtys[$key], "float", 1, 20, "Invalid Item quantity.");
$v->isOk($amts[$key], "float", 1, 20, "Invalid Item amount.");
}
$v->isOk($subtot, "float", 1, 20, "Invalid sub-total amount.");
$v->isOk($vat, "float", 1, 20, "Invalid vat amount.");
$v->isOk($total, "float", 1, 20, "Invalid total amount.");
# display errors, if any
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
db_connect();
# Get invoice info
$sql = "SELECT * FROM hire.hire_nons_invoices WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to get invoice information");
if (pg_numrows($invRslt) < 1) {
return "<i class='err'>Not Found</i>";
}
$inv = pg_fetch_array($invRslt);
db_conn("hire");
$noteid = pglib_lastid("hire_nons_inv_notes", "noteid");
$noteid++;
# Begin updates
pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
/* --- Start Products Display --- */
$refnum = getrefnum();
/*refnum*/
$real_noteid = divlastid('note', USER_DIV);
$vattot = 0;
$amttot = 0;
db_connect();
# Products layout
$products = array();
$i = 0;
$page = 0;
foreach ($ids as $key => $id) {
if ($i >= 25) {
$page++;
$i = 0;
}
$sql = "SELECT * FROM hire.hire_nons_inv_items WHERE invid = '{$invid}' AND id = '{$id}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
$stkd = pg_fetch_array($stkdRslt);
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes WHERE id='{$stkd['vatex']}'";
$Ri = db_exec($Sl) or errDie("Unable to get data.");
$vd = pg_fetch_array($Ri);
if (TAX_VAT != $vd['vat_amount'] and $vd['vat_amount'] != "0.00") {
$showvat = FALSE;
}
$temp = $stkd['vatex'];
if ($vd['zero'] == "Yes") {
$stkd['vatex'] = "y";
}
$t = $inv['chrgvat'];
// $VATP = TAX_VAT;
$VATP = $vd['vat_amount'];
$stkacc = $stkd['accid'];
# keep records for transactions
if (isset($totstkamt[$stkacc])) {
if ($stkd['vatex'] == "y") {
$totstkamt[$stkacc] += $amts[$key];
$va = 0;
$inv['chrgvat'] = "";
} else {
$totstkamt[$stkacc] += vats($amts[$key], $inv['chrgvat'], $vd['vat_amount']);
$va = sprint($stkd['amt'] - vats($amts[$key], $inv['chrgvat'], $vd['vat_amount']));
if ($inv['chrgvat'] == "no") {
$va = sprint($amts[$key] * $VATP / 100);
}
}
} else {
if ($stkd['vatex'] == "y") {
$totstkamt[$stkacc] = $amts[$key];
$va = 0;
$inv['chrgvat'] = "";
} else {
$totstkamt[$stkacc] = vats($amts[$key], $inv['chrgvat'], $vd['vat_amount']);
$va = sprint($amts[$key] - vats($amts[$key], $inv['chrgvat'], $vd['vat_amount']));
//.........这里部分代码省略.........
示例13: write_data
function write_data($_POST)
{
$date = date("Y-m-d");
# get vars
extract($_POST);
if (isset($back)) {
return get_data("");
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($surname, "string", 1, 100, "Last name");
$v->isOk($name, "string", 0, 100, "First name");
$v->isOk($accountname, "string", 0, 100, "Account");
$v->isOk($account_id, "num", 0, 9, "Account ID (hidden)");
$v->isOk($account_type, "string", 0, 100, "Account type (hidden)");
$v->isOk($lead_source, "string", 0, 100, "Lead Source");
$v->isOk($title, "string", 0, 100, "Title");
$v->isOk($department, "string", 0, 100, "Department");
$v->isOk($tell, "string", 0, 100, "Home Phone");
$v->isOk($cell, "string", 0, 100, "Mobile Phone");
$v->isOk($fax, "string", 0, 100, "Fax");
$v->isOk($tell_office, "string", 0, 100, "Office Phone");
$v->isOk($tell_other, "string", 0, 100, "Other Phone");
$v->isOk($email, "string", 0, 100, "Email");
$v->isOk($email_other, "string", 0, 100, "Other Email");
$v->isOk($assistant, "string", 0, 100, "Assistant");
$v->isOk($assistant_phone, "string", 0, 100, "Assistant Phone");
$v->isOk($padd, "string", 0, 250, "Physical Address");
$v->isOk($padd_city, "string", 0, 100, "Physical Address: City");
$v->isOk($padd_state, "string", 0, 100, "Physical Address: State/Province");
$v->isOk($padd_code, "string", 0, 100, "Physical Address: Postal Code");
$v->isOk($padd_country, "string", 0, 100, "Physical Address: Country");
$v->isOk($hadd, "string", 0, 250, "Postal Address");
$v->isOk($hadd_city, "string", 0, 100, "Postal Address: City");
$v->isOk($hadd_state, "string", 0, 100, "Postal Address: State/Province");
$v->isOk($hadd_code, "string", 0, 100, "Postal Address: Postal Code");
$v->isOk($hadd_country, "string", 0, 100, "Postal Address: Country");
$v->isOk($description, "string", 0, 100, "Description");
$v->isOk($website, "string", 0, 255, "Website");
$v->isOk($religion, "string", 0, 100, "Religion");
$v->isOk($race, "string", 0, 100, "Race");
$v->isOk($gender, "string", 0, 6, "Gender");
$v->isOk($salespn, "num", 1, 9, "Sales person.");
$v->isOK($team_id, "num", 1, 9, "Team.");
if (!empty($ncdate_day) || !empty($ncdate_month) || !empty($ncdate_year)) {
$v->isOk($ncdate_day, "num", 1, 2, "Next contact date (Day)");
$v->isOk($ncdate_month, "num", 1, 2, "Next contact day (Month)");
$v->isOk($ncdate_year, "num", 4, 4, "Next contact day (Year)");
$ncdate_col = ", ncdate";
$ncdate = ", '{$ncdate_year}-{$ncdate_month}-{$ncdate_day}'";
} else {
$ncdate_col = "";
$ncdate = "";
}
$v->isOk($Con, "string", 2, 3, "Invalid private.");
$birthdate = "{$bf_year}-{$bf_month}-{$bf_day}";
if ($v->isOk($birthdate, "string", 1, 100, "Birthdate")) {
if (!checkdate($bf_month, $bf_day, $bf_year)) {
$v->addError("_OTHER", "Invalid birthdate. No such date exists.");
}
}
$birthdate_description = date("d F Y", mktime(0, 0, 0, $bf_day, $bf_month, $bf_year));
$assigned_to = USER_NAME;
$assigned_to_id = USER_ID;
# display errors, if any
if ($v->isError()) {
$err = "The following field value errors occured:<br>";
$errors = $v->getErrors();
foreach ($errors as $e) {
if ($e["value"] == "_OTHER") {
$err .= "<li class='err'>{$e['msg']}</li>";
} else {
$err .= "<li class='err'>Invalid characters: {$e['msg']}</li>";
}
}
return get_data($err);
}
db_conn('cubit');
if (!pglib_transaction("BEGIN")) {
return "<li class='err'>Unable to add lead to database. (TB)</li>";
}
if (isset($supacc)) {
$supacc = remval($supacc);
$sql = "\r\n\t\t\tINSERT INTO suppliers (\r\n\t\t\t\tdeptid, supno, supname, location, fcid, currency, vatnum, supaddr, contname, tel, fax, \r\n\t\t\t\temail, url, listid, bankname, branname, brancode, bankaccno, balance, fbalance, div\r\n\t\t\t) VALUES (\r\n\t\t\t\t'2', '{$supacc}', '{$surname}', 'loc', '2', 'R', '', '{$hadd} \n {$padd}', '', '{$tell}', '{$fax}', \r\n\t\t\t\t'{$email}', '', '2', '', '', '', '', 0, 0, '" . USER_DIV . "'\r\n\t\t\t)";
$supRslt = db_exec($sql) or errDie("Unable to add supplier to the system.", SELF);
if (pg_cmdtuples($supRslt) < 1) {
return "<li class='err'>Unable to add supplier to database.</li>";
}
if (($supp_id = pglib_lastid("suppliers", "supid")) == 0) {
return "<li class='err'>Unable to add supplier to lead list.</li>";
}
$accountname = $surname;
$account_type = "Supplier";
$account_id = $supp_id;
} else {
$supp_id = 0;
}
if (isset($cusacc)) {
$cusacc = remval($cusacc);
//.........这里部分代码省略.........
示例14: confirm
function confirm()
{
global $_GET;
extract($_GET);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($empnum, "num", 1, 9, "Invalid employee selected.");
$v->isOk($expacc_pension, "string", 1, 3, "Invalid pension account.");
$v->isOk($expacc_provident, "string", 1, 3, "Invalid provident account.");
$v->isOk($expacc_medical, "string", 1, 3, "Invalid medical account.");
$v->isOk($expacc_ret, "string", 1, 3, "Invalid retirement annuity account.");
$v->isOk($expacc_uif, "string", 1, 3, "Invalid uif account.");
$v->isOk($expacc_salwages, "string", 1, 3, "Invalid salaries and wages account.");
$v->isOk($expacc_sdl, "string", 1, 3, "Invalid sdl account.");
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
return slctAcc($confirm);
}
$fields = array("Pension" => "pension", "Provident" => "provident", "UIF" => "uif", "Medical Aid" => "medical", "Retirement Annuity" => "ret", "Salaries & Wages" => "salwages", "SDL" => "sdl");
foreach ($fields as $fdesc => $fn) {
if (isb(${"expacc_{$fn}"})) {
$v->addError("", "Account is blocked for: {$fdesc}");
}
$rslt = get("core", "accname", "accounts", "accid", ${"expacc_{$fn}"});
${"name_{$fn}"} = pg_fetch_result($rslt, 0, 0);
}
$emp_ded = "";
if (isset($dedaccs) && is_array($dedaccs)) {
foreach ($dedaccs as $key => $value) {
if (!$v->isOk($key . $value, "string", 2, 20, "")) {
continue;
}
// salded
db_conn("cubit");
$sql = "SELECT salded.deduction FROM salded, empdeduct\n\t\t\t\t\tWHERE salded.id=empdeduct.dedid AND empdeduct.id='{$key}'";
$rslt = db_exec($sql);
$salded = pg_fetch_array($rslt);
if (isb($value)) {
$v->addError("", "Account is blocked for: {$salded['deduction']}");
}
// accounts
$name_ded = pg_fetch_result(get("core", "accname", "accounts", "accid", $value), 0, 0);
$emp_ded .= "\n\t\t\t<input type='hidden' name='dedaccs[{$key}]' value='{$value}'>\n\t\t\t<tr bgcolor=" . bgcolorg() . ">\n\t\t\t\t<td>{$salded['deduction']}</td>\n\t\t\t\t<td>{$name_ded}</td>\n\t\t\t</tr>";
}
}
$emp_allow = "";
if (isset($allowaccs) && is_array($allowaccs)) {
foreach ($allowaccs as $key => $value) {
if (!$v->isOk($key . $value, "string", 2, 20, "")) {
continue;
}
// salded
db_conn("cubit");
$sql = "SELECT allowances.allowance FROM allowances, empallow\n\t\t\t\t\tWHERE allowances.id=empallow.allowid AND empallow.id='{$key}'";
$rslt = db_exec($sql);
$allowinfo = pg_fetch_array($rslt);
if (isb($value)) {
$v->addError("", "Account is blocked for: {$allowinfo['allowance']}");
}
// accounts
$name_allow = pg_fetch_result(get("core", "accname", "accounts", "accid", $value), 0, 0);
$emp_allow .= "\n\t\t\t<input type='hidden' name='allowaccs[{$key}]' value='{$value}'>\n\t\t\t<tr bgcolor=" . bgcolorg() . ">\n\t\t\t\t<td>{$allowinfo['allowance']}</td>\n\t\t\t\t<td>{$name_allow}</td>\n\t\t\t</tr>";
}
}
// display account block errors if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
return slctAcc($confirm);
}
$confirm = "\n\t\t<h3>Company Contributions to Employee Deductions Expense Accounts</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='GET'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<input type='hidden' name='empnum' value='{$empnum}'>";
foreach ($fields as $fn) {
$confirm .= "<input type='hidden' name='expacc_{$fn}' value='" . ${"expacc_{$fn}"} . "'>";
}
$confirm .= "\n\t\t\t<tr>\n\t\t\t\t<th>Field</th>\n\t\t\t\t<th>Value</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Salaries and Wages</td>\n\t\t\t\t<td>{$name_salwages}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Pension Fund</td>\n\t\t\t\t<td>{$name_pension}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Provident Fund</td>\n\t\t\t\t<td>{$name_provident}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Retirement Annuity Fund</td>\n\t\t\t\t<td>{$name_ret}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Medical Aid</td>\n\t\t\t\t<td>{$name_medical}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>UIF</td>\n\t\t\t\t<td>{$name_uif}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Skills Development Levy</td>\n\t\t\t\t<td>{$name_sdl}</td>\n\t\t\t</tr>\n\t\t\t{$emp_ded}\n\t\t\t<tr><th colspan='2'>Allowances</th></tr>\n\t\t\t{$emp_allow}\n\t\t\t<tr>\n\t\t\t\t<td align='right'><input type='button' value='« Back' onClick='javascript:history.back()'></td>\n\t\t\t\t<td align='right'><input type='submit' value='Add Link »'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
return $confirm;
}
示例15: writeEmp
function writeEmp($_POST)
{
$_POST = var_makesafe($_POST);
global $_FILES;
extract($_POST);
$comp_pension += 0;
$emp_pension += 0;
$comp_ret += 0;
$emp_ret += 0;
$comp_medical += 0;
$emp_medical += 0;
# validate input
require_lib("validate");
$v = new validate();
# Limit field lengths as per database settings
$v->isOk($empnum, "string", 0, 20, "Invalid emp num");
$v->isOk($sname, "string", 1, 50, "Invalid surname.");
$v->isOk($fnames, "string", 1, 50, "Invalid first names.");
$v->isOk($sex, "string", 1, 1, "Invalid sex.");
$v->isOk($marital, "string", 0, 10, "Invalid marital status.");
$v->isOk($designation, "string", 0, 100, "Invalid designation.");
$v->isOk($changelogo, "string", 1, 3, "Invalid image selection.");
$v->isOk($resident, "string", 1, 5, "Invalid residential status.");
$v->isOk($hiredate, "date", 1, 10, "Invalid hire date.");
$v->isOk($telno, "string", 0, 30, "Invalid telephone no.");
$v->isOk($email, "email", 0, 255, "Invalid email address.");
$v->isOk($basic_sal, "float", 1, 9, "Invalid basic salary.");
$v->isOk($hpweek, "float", 1, 5, "Invalid hours per week.");
$v->isOk($saltyp, "string", 1, 2, "Invalid payment period.");
$v->isOk($novert, "float", 1, 9, "Invalid normal overtime.");
$v->isOk($hovert, "float", 1, 9, "Invalid holiday overtime.");
$v->isOk($paytype, "string", 1, 15, "Invalid pay type.");
$v->isOk($bankname, "string", 0, 50, "Invalid bank name.");
$v->isOk($bankcode, "string", 0, 8, "Invalid branch code.");
$v->isOk($bankacctype, "string", 0, 50, "Invalid bank account type.");
$v->isOk($bankaccno, "num", 0, 50, "Invalid bank account no.");
$v->isOk($vaclea, "num", 1, 5, "Invalid vacation leave days.");
$v->isOk($siclea, "num", 1, 5, "Invalid sick leave days.");
$v->isOk($stdlea, "num", 1, 5, "Invalid study leave days.");
$v->isOk($res1, "string", 1, 50, "Invalid residential address. (line 1)");
$v->isOk($res2, "string", 0, 50, "Invalid residential address. (line 2)");
$v->isOk($res3, "string", 0, 50, "Invalid residential address. (line 3)");
$v->isOk($res4, "string", 0, 50, "Invalid residential address. (line 4)");
$v->isOk($pos1, "string", 0, 50, "Invalid postal address. (line 1)");
$v->isOk($pos2, "string", 0, 50, "Invalid postal address. (line 2)");
$v->isOk($pcode, "strin", 0, 16, "Invalid postal code.");
$v->isOk($contsname, "string", 0, 50, "Invalid contact surname.");
$v->isOk($contfnames, "string", 0, 50, "Invalid first names.");
$v->isOk($contres1, "string", 0, 50, "Invalid contact address. (line 1)");
$v->isOk($contres2, "string", 0, 50, "Invalid contact address. (line 2)");
$v->isOk($contres3, "string", 0, 50, "Invalid contact address. (line 3)");
$v->isOk($contres4, "string", 0, 50, "Invalid contact address. (line 4)");
$v->isOk($conttelno, "string", 0, 30, "Invalid contact telephone no.");
$v->isOk($idnum . $passportnum, "string", 1, 30, "Invalid id/passport num (VAL).");
if (!empty($idnum)) {
$v->isOk($idnum, "string", 6, 30, "Invalid id number.");
}
$v->isOk($taxref, "string", 0, 30, "Invalid tax ref no.");
$v->isOk($department, "string", 0, 50, "Invalid department");
$v->isOk($occ_cat, "string", 0, 50, "Invalid Occupational Category");
$v->isOk($occ_level, "string", 0, 50, "Invalid Occupational Level");
$v->isOk($pos_filled, "string", 0, 50, "Invalid Position Files");
$v->isOk($temporary, "string", 0, 50, "Invalid Temporary Data");
$v->isOk($termination_date, "date", 1, 10, "{$termination_date} Invalid termination date.");
$v->isOk($recruitment_from, "string", 0, 50, "Invalid Recruitment From");
$v->isOk($employment_reason, "string", 0, 50, "Invalid Employment Reason");
$v->isOk($union_name, "string", 0, 50, "Invalid Union Name");
$v->isOk($union_mem_num, "string", 0, 50, "Invalid Union Member Name");
$v->isOk($union_pos, "string", 0, 50, "Invalid Union Position");
$v->isOk($race, "string", 0, 50, "Invalid Race");
$v->isOk($disabled_stat, "string", 0, 50, "Invalid Disabled Status");
if (strlen($idnum) >= 6) {
$bd_year = substr($idnum, 0, 2);
$bd_month = substr($idnum, 2, 2);
$bd_day = substr($idnum, 4, 2);
if (!(is_numeric($bd_year) && is_numeric($bd_month) && is_numeric($bd_day) && checkdate($bd_month, $bd_day, $bd_year))) {
$v->addError("", "Invalid id num (BD).");
}
}
if (isset($allowances)) {
foreach ($allowances as $key => $value) {
$v->isOk($allowances[$key], "float", 0, 20, "Invalid allowance amount " . ($key + 1) . ".");
}
}
if (isset($deductid)) {
foreach ($deductid as $key => $value) {
$v->isOk($deductid[$key], "num", 1, 20, "Invalid deductions ID.");
}
}
if (isset($deductions)) {
foreach ($deductions as $key => $value) {
$v->isOk($deductions[$key], "float", 0, 20, "Invalid deduction amount" . ($key + 1) . ".");
}
}
if (isset($allowid)) {
foreach ($allowid as $key => $value) {
$v->isOk($allowid[$key], "num", 1, 20, "Invalid allowance ID.");
}
}
if (isset($allowtax)) {
//.........这里部分代码省略.........