本文整理汇总了PHP中validate::chkrDate方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::chkrDate方法的具体用法?PHP validate::chkrDate怎么用?PHP validate::chkrDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validate
的用法示例。
在下文中一共展示了validate::chkrDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
function write($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($type, "string", 1, 255, "Invalid Transaction type switch.");
$v->isOk($typename, "string", 1, 255, "Invalid Transaction type.");
$edate = $v->chkrDate($edate, "Invalid date.");
$v->isOk($amount, "float", 1, 13, "Invalid Amount.");
$v->isOk($descrip, "string", 0, 255, "Invalid description.");
if (isset($ccids)) {
foreach ($ccids as $key => $value) {
$v->isOk($ccperc[$key], "float", 1, 20, "Invalid Cost center percentage.");
}
} else {
return enter($_POST, "<li class=err> There are no Cost centers found.");
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return enter($_POST, $confirm);
$confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirmCust;
}
$type = strtolower($type);
$edate = ext_rdate($edate);
$edarr = explode("-", $edate);
$prd = $edarr[1];
## start transaction
pglib_transaction("BEGIN") or errDie("Unable to start transaction.");
$ccenters = "";
foreach ($ccids as $key => $value) {
db_connect();
$sql = "SELECT * FROM costcenters_links WHERE id = '{$ccids[$key]}'";
$ccRslt = db_exec($sql) or errDie("Unable to retrieve Cost centers from database.");
$cc = pg_fetch_array($ccRslt);
$ccamts[$key] = sprint($amount * ($ccperc[$key] / 100));
#we need to connect to the actual period db
db_conn($prd);
if ($type == "dtct") {
$sql = "\n\t\t\t\t\tINSERT INTO cctran \n\t\t\t\t\t\t(ccid, trantype, typename, edate, description, amount, username, div, project) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$ccids[$key]}', 'dt', '{$typename}', '{$edate}', '{$descrip}', '{$ccamts[$key]}', '" . USER_NAME . "', '" . USER_DIV . "', '{$ccidpro[$key]}')";
$insRslt = db_exec($sql) or errDie("Unable to retrieve insert Cost center amounts into database.");
$sql = "\n\t\t\t\t\tINSERT INTO cctran \n\t\t\t\t\t\t(ccid, trantype, typename, edate, description, amount, username, div, project) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$ccids[$key]}', 'ct', '{$typename}', '{$edate}', '{$descrip}', '{$ccamts[$key]}', '" . USER_NAME . "', '" . USER_DIV . "', '{$ccidpro[$key]}')";
$insRslt = db_exec($sql) or errDie("Unable to retrieve insert Cost center amounts into database.");
} else {
$sql = "\n\t\t\t\t\tINSERT INTO cctran \n\t\t\t\t\t\t(ccid, trantype, typename, edate, description, amount, username, div, project) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$ccids[$key]}', '{$type}', '{$typename}', '{$edate}', '{$descrip}', '{$ccamts[$key]}', '" . USER_NAME . "', '" . USER_DIV . "', '{$ccidpro[$key]}')";
$insRslt = db_exec($sql) or errDie("Unable to retrieve insert Cost center amounts into database.");
}
}
db_connect();
#now remove the temp entry
$rem_sql = "DELETE FROM cc_popup_data WHERE id = '{$writeid}'";
$run_rem = db_exec($rem_sql) or errDie("Unable to remove temporary cost center information.");
pglib_transaction("COMMIT") or errDie("Unable to complete transaction.");
// Layout
$write = "\n\t\t<center>\n\t\t<table " . TMPL_tblDflts . " width='300'>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'><b>( i )</b> Amount has been allocated to Cost Centers. <b>( i )</b></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<input type=button value=' [X] Close ' onClick='javascript:window.close();'>\n\t\t</center>";
return $write;
}
示例2: write
function write($_POST)
{
db_connect();
# Get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($bankid, "num", 1, 30, "Invalid Bank Account.");
$v->isOk($fbankid, "num", 1, 30, "Invalid Foreign Bank Account.");
$date = $v->chkrDate($date, "Invalid date.");
$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($amount, "float", 1, 10, "Invalid amount.");
$v->isOk($rate, "float", 1, 10, "Invalid exchange rate.");
$v->isOk($ttype, "string", 1, 4, "Invalid Transfer type option.");
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
$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>";
}
# Get bank account name
db_connect();
$sql = "SELECT * FROM bankacct WHERE bankid = '{$bankid}' AND div = '" . USER_DIV . "'";
$bankRslt = db_exec($sql);
$bank = pg_fetch_array($bankRslt);
$sql = "SELECT * FROM bankacct WHERE bankid = '{$fbankid}' AND div = '" . USER_DIV . "'";
$fbankRslt = db_exec($sql);
$fbank = pg_fetch_array($fbankRslt);
bank_xrate_update($fbank['fcid'], $rate);
# date format
$date = explode("-", $date);
$date = $date[2] . "-" . $date[1] . "-" . $date[0];
#refnum
$refnum = getrefnum();
/* -- Start Hooks -- */
# Get hook account number
core_connect();
$sql = "SELECT * FROM bankacc WHERE accid = '{$bankid}' AND div = '" . USER_DIV . "'";
$rslt = db_exec($sql) or errDie("Unable to retrieve bank account link from Cubit", SELF);
# Check if link exists
if (pg_numrows($rslt) < 1) {
return "<li class='err'> ERROR : The bank account that you selected doesn't appear to have an account linked to it.</li>";
}
$banklnk = pg_fetch_array($rslt);
# Get hook account number
core_connect();
$sql = "SELECT * FROM bankacc WHERE accid = '{$fbankid}' AND div = '" . USER_DIV . "'";
$rslt = db_exec($sql) or errDie("Unable to retrieve bank account link from Cubit", SELF);
# Check if link exists
if (pg_numrows($rslt) < 1) {
return "<li class='err'> ERROR : The bank account that you selected doesn't appear to have an account linked to it.</li>";
}
$fbanklnk = pg_fetch_array($rslt);
/* -- End Hooks -- */
$cheqnum = 0 + $cheqnum;
if ($ttype == 'loc') {
$famount = sprint($amount / $rate);
# Record the payment record
db_connect();
$sql = "\n\t\t\tINSERT INTO cashbook (\n\t\t\t\tbankid, trantype, date, name, descript, cheqnum, amount, \n\t\t\t\tfamount, vat, chrgvat, banked, accinv, reference, div\n\t\t\t) VALUES (\n\t\t\t\t'{$bankid}', 'withdrawal', '{$date}', '{$fbank['accname']} {$fbank['bankname']}', '{$descript}', '{$cheqnum}', '{$amount}', \n\t\t\t\t'{$famount}', '0', 'no', 'no', '{$fbanklnk['accnum']}', '{$reference}', '" . USER_DIV . "'\n\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
$lcashid = pglib_lastid("cashbook", "cashid");
$sql = "\n\t\t\tINSERT INTO cashbook (\n\t\t\t\tbankid, trantype, date, name, descript, cheqnum, amount, \n\t\t\t\tfamount, vat, chrgvat, banked, accinv, lcashid, reference, div\n\t\t\t) VALUES (\n\t\t\t\t'{$fbankid}', 'deposit', '{$date}', '{$bank['accname']} {$bank['bankname']}', '{$descript}', '{$cheqnum}', '{$amount}', \n\t\t\t\t'{$famount}', '0', 'no', 'no', '{$banklnk['accnum']}', '{$lcashid}', '{$reference}', '" . USER_DIV . "'\n\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
$lcashid2 = pglib_lastid("cashbook", "cashid");
#restore link
$sql = "UPDATE cashbook SET lcashid = '{$lcashid2}' WHERE cashid = '{$lcashid}'";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
# Update the bankacct table (make fbalance less) [used for cashbook fc value]
$sql = "UPDATE bankacct SET balance = (balance + '{$amount}'::numeric(13,2)), fbalance = (fbalance + '{$famount}'::numeric(13,2)) WHERE bankid = '{$fbankid}' AND div = '" . USER_DIV . "'";
$rslt = db_exec($sql) or errDie("Unable to update invoice in Cubit.", SELF);
# DT(account involved), CT(bank)
writetrans($fbanklnk['accnum'], $banklnk['accnum'], $date, $refnum, $amount, $descript);
} else {
$lamount = sprint($amount * $rate);
# Record the payment record
db_connect();
$sql = "\n\t\t\tINSERT INTO cashbook (\n\t\t\t\tbankid, trantype, date, name, descript, cheqnum, amount, \n\t\t\t\tfamount, vat, chrgvat, banked, accinv, reference, div\n\t\t\t) VALUES (\n\t\t\t\t'{$bankid}', 'deposit', '{$date}', '{$fbank['accname']} {$fbank['bankname']}', '{$descript}', '{$cheqnum}', '{$lamount}', \n\t\t\t\t'{$amount}' , '0', 'no', 'no', '{$fbanklnk['accnum']}', '{$reference}', '" . USER_DIV . "'\n\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
$lcashid = pglib_lastid("cashbook", "cashid");
$sql = "\n\t\t\tINSERT INTO cashbook (\n\t\t\t\tbankid, trantype, date, name, descript, cheqnum, amount, \n\t\t\t\tfamount, vat, chrgvat, banked, accinv, lcashid, reference, div\n\t\t\t) VALUES (\n\t\t\t\t'{$fbankid}', 'withdrawal', '{$date}', '{$bank['accname']} {$bank['bankname']}', '{$descript}', '{$cheqnum}', '{$lamount}', \n\t\t\t\t'{$amount}', '0', 'no', 'no', '{$banklnk['accnum']}', '{$lcashid}', '{$reference}', '" . USER_DIV . "'\n\t\t\t)";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
$lcashid2 = pglib_lastid("cashbook", "cashid");
#restore link
$sql = "UPDATE cashbook SET lcashid = '{$lcashid2}' WHERE cashid = '{$lcashid}'";
$Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
# Update the bankacct table (make fbalance less) [used for cashbook fc value]
$sql = "UPDATE bankacct SET balance = (balance - '{$lamount}'::numeric(13,2)), fbalance = (fbalance - '{$amount}'::numeric(13,2)) WHERE bankid = '{$fbankid}' AND div = '" . USER_DIV . "'";
//.........这里部分代码省略.........