本文整理汇总了PHP中isb函数的典型用法代码示例。如果您正苦于以下问题:PHP isb函数的具体用法?PHP isb怎么用?PHP isb使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enter
function enter()
{
/*
db_connect();
# check if setting exists
$sql = "SELECT label FROM set WHERE label = 'INT_TYPE'";
$Rslt = db_exec ($sql) or errDie ("Unable to check database for existing settings.");
if (pg_numrows ($Rslt) > 0) {
return printSet();
}
*/
core_connect();
$sql = "SELECT * FROM accounts WHERE acctype ='I' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
$numrows = pg_numrows($accRslt);
if (empty($numrows)) {
return "<li>ERROR : There are no income accounts in Cubit.</li>";
}
$slctAcc = "<select name='accid'>";
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$slctAcc .= "<option value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</option>";
}
$slctAcc .= "</select>";
# Connect to db
$enter = "\n\t\t<h3>Cubit Settings</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t<tr>\n\t\t\t\t<th colspan='3'>Interest Calculation</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><input type='radio' size='20' name='typ' value='perc' checked='yes'>Use Percentage <input type='text' name='perc' value='0' size='4'> %</td>\n\t\t\t\t<td><input type='radio' size='20' name='typ' value='brac'>Use Interest Brackets</td>\n\t\t\t\t<td><input type='radio' size='20' name='typ' value='rate'>Use Customer Specific rate | Default rate <input type='text' name='dperc' value='0' size='4'>%</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Interest Received Account</td>\n\t\t\t\t<td>{$slctAcc}</td>\n\t\t\t\t<td><br></td>\n\t\t\t</tr>\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align='right' colspan='2'><input type='submit' value='Continue »'></td>\n\t\t\t\t</tr>\n\t\t\t</form>\n\t\t\t</table>\n\t\t\t<p>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t</tr>\n\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t</table>";
return $enter;
}
示例2: details
//.........这里部分代码省略.........
# Select all products
$products = "\n\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t<tr>\n\t\t\t\t<th>DESCRIPTION</th>\n\t\t\t\t<th>QTY</th>\n\t\t\t\t<th>UNIT PRICE</th>\n\t\t\t\t<th>AMOUNT</th>\n\t\t\t\t<th>Account</th>\n\t\t\t\t<th>VAT Code</th>\n\t\t\t\t<th>Remove</th>\n\t\t\t<tr>";
# get selected stock in this purchase
db_connect();
$sql = "SELECT * FROM rnons_inv_items WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
$i = 0;
while ($stkd = pg_fetch_array($stkdRslt)) {
# keep track of selected stock amounts
$amts[$i] = $stkd['amt'];
$stkd['amt'] = round($stkd['amt'], 2);
$chk = "";
if ($stkd['vatex'] == 'y') {
$chk = "checked=yes";
}
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes ORDER BY code";
$Ri = db_exec($Sl);
$vats = "<select name='vatcodes[]'>";
while ($vd = pg_fetch_array($Ri)) {
if ($stkd['vatex'] == $vd['id']) {
$sel = "selected";
} else {
$sel = "";
}
$vats .= "<option value='{$vd['id']}' {$sel}>{$vd['code']}</option>";
}
$vats .= "</select>";
db_conn('core');
$Sl = "SELECT accid,accname FROM accounts WHERE div='" . USER_DIV . "' ORDER BY accname";
$Ri = db_exec($Sl);
$accounts = "<select name='accounts[]'>";
while ($ad = pg_fetch_array($Ri)) {
if (isb($ad['accid'])) {
continue;
}
if ($ad['accid'] == $stkd['account']) {
$sel = "selected";
} else {
$sel = "";
}
$accounts .= "<option value='{$ad['accid']}' {$sel}>{$ad['accname']}</option>";
}
$accounts .= "</select>";
db_conn('cubit');
# put in product
$products .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'><input type='text' size='50' name='des[]' value='{$stkd['description']}'></td>\n\t\t\t\t<td align='center'><input type='text' size='3' name='qtys[]' value='{$stkd['qty']}'></td>\n\t\t\t\t<td align='center'><input type='text' size='8' name='unitcost[]' value='{$stkd['unitcost']}'></td>\n\t\t\t\t<td><input type='hidden' name='amt[]' value='{$stkd['amt']}'> " . CUR . " " . sprint($stkd["amt"]) . "</td>\n\t\t\t\t<td>{$accounts}</td>\n\t\t\t\t<td align='center'>{$vats}</td>\n\t\t\t\t<td align='center'><input type='checkbox' name='remprod[]' value='{$i}'><input type='hidden' name='SCROLL' value='yes'></td>\n\t\t\t</tr>";
$i++;
}
# Look above(remprod keys)
$keyy = $i;
# look above(if i = 0 then there are no products)
if ($i == 0) {
$done = "";
}
if ($i == 0 || isset($diffwhBtn)) {
db_conn('core');
$Sl = "SELECT accid,accname FROM accounts WHERE div='" . USER_DIV . "' ORDER BY accname";
$Ri = db_exec($Sl);
$accounts = "<select name='accounts[]'>";
while ($ad = pg_fetch_array($Ri)) {
if (isb($ad['accid'])) {
continue;
}
$accounts .= "<option value='{$ad['accid']}'>{$ad['accname']}</option>";
}
示例3: enter
function enter()
{
# connect to db
core_connect();
$depacc = "<select name='incacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'I' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Income accounts yet in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$depacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$depacc .= "</select>";
$debtacc = "<select name='debtacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Balance accounts yet in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
$debtacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$debtacc .= "</select>";
$credacc = "<select name='credacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Balance accounts yet in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
$credacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$credacc .= "</select>";
//Get account for Point of sale income account
$pias = "<select name='pia'>";
$sql = "SELECT accid,accname FROM accounts WHERE acctype = 'I' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Income accounts in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$pias .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$pias .= "</select>";
//Get account for Point of Sale Cash on hand account
$pcas = "<select name='pca'>";
$sql = "SELECT accid,accname FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Income accounts in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
$pcas .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$pcas .= "</select>";
$enter = "<h3>Add Department</h3>\r\n\t<form action='" . SELF . "' method=post>\r\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<input type=hidden name=key value=confirm>\r\n\t<tr><th>Field</th><th>Value</th></tr>\r\n\t<tr class='bg-odd'><td>Dept Number</td><td><input type=text size=10 name=deptno></td></tr>\r\n\t<tr class='bg-even'><td>Department</td><td><input type=text size=20 name=deptname></td></tr>\r\n\t<tr class='bg-odd'><td>Income Account</td><td>{$depacc}</td></tr>\r\n\t<tr class='bg-even'><td>Debtors Control Account</td><td>{$debtacc}</td></tr>\r\n\t<tr class='bg-odd'><td>Creditors Control Account</td><td>{$credacc}</td></tr>\r\n\t<tr class='bg-even'><td>Point of Sale: Cash on hand account</td><td>{$pcas}</td></tr>\r\n\t<tr class='bg-odd'><td>Point of Sale Income Account</td><td>{$pias}</td></tr>\r\n\t<tr><td colspan=2 align=right><input type=submit value='Confirm »'></td></tr>\r\n\t</table></form>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='dept-view.php'>View Departments</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='../core/acc-new2.php'>Add Account</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
return $enter;
}
示例4: writeLoan
function writeLoan($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($empnum, "num", 1, 20, "Invalid employee number.");
$v->isOk($loanid, "num", 1, 20, "Invalid loan ID.");
$v->isOk($loanamt, "float", 1, 10, "Invalid loan amount.");
$v->isOk($loanint, "float", 1, 5, "Invalid loan interest.");
$v->isOk($loanperiod, "num", 1, 3, "Invalid payback period.");
$v->isOk($loaninstall, "float", 1, 10, "Invalid monthly installment.");
$v->isOk($fringebenefit, "float", 1, 10, "Invalid fringe benefit amount.");
$v->isOk($accid, "num", 1, 9, "Invalid bank account selected.");
$v->isOk($account, "num", 1, 9, "Invalid contra account selected.");
$v->isOk($loan_account, "num", 1, 9, "Invalid loan account selected.");
$v->isOk($loan_type, "num", 1, 9, "Invalid loan type selected.");
$ldate = mkdate($lyear, $lmonth, $lday);
$v->isOk($ldate, "date", 1, 1, "Invalid loan date.");
$archdate = mkdate($arch_year, $arch_month, $arch_day);
$v->isOk($archdate, "date", 1, 1, "Invalid approval/denial date.");
if (!checkdate($lmonth, $lday, $lyear)) {
$v->addError("", "Invalid date.");
}
if ($account > 0 && isb($account) || isb($loan_account)) {
$v->addError("", "Main accounts blocked. Please select sub accounts.");
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
return enterLoan($confirmCust);
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($ldate) >= strtotime($blocked_date_from) and strtotime($ldate) <= 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>";
}
# CHECK IF THIS DATE IS IN THE BLOCKED RANGE
$blocked_date_from = getCSetting("BLOCKED_FROM");
$blocked_date_to = getCSetting("BLOCKED_TO");
if (strtotime($archdate) >= strtotime($blocked_date_from) and strtotime($archdate) <= 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 employee details
db_connect();
$sql = "SELECT * FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "'";
$empRslt = db_exec($sql) or errDie("Unable to select employees from database.");
if (pg_numrows($empRslt) < 1) {
return "Invalid employee ID.";
}
$myEmp = pg_fetch_array($empRslt);
if (!isset($deny)) {
# check for previous loan
$sql = "SELECT empnum FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "' AND gotloan='t'::bool";
$chkRslt = db_exec($sql) or errDie("Unable to check existing loans for employee.");
if (pg_numrows($chkRslt) > 0) {
return "<li class='err'>Loan already exists for employee number: {$empnum}.</li>";
}
}
$date = date("Y-m-d");
pglib_transaction("BEGIN");
$totamount = sprint($loanperiod * $loaninstall);
$loanint_amt = $totamount - $loanamt;
$sql = "\n\t\tINSERT INTO emp_loanarchive (\n\t\t\tempnum, loanamt, loaninstall, loanint, loanperiod, loandate, archdate, loan_type, \n\t\t\tdiv, status\n\t\t) VALUES (\n\t\t\t'{$empnum}', '{$totamount}', '{$loaninstall}', '{$loanint}', '{$loanperiod}', '{$ldate}', '{$archdate}', '{$loan_type}', \n\t\t\t'" . USER_DIV . "', '" . (isset($deny) ? "D" : "A") . "'\n\t\t)";
$rslt = db_exec($sql) or errDie("Unable to pre archive loan.");
$loanaid = pglib_lastid('emp_loanarchive', 'id');
$rem_sql = "DELETE FROM loan_requests WHERE id = '{$loanid}'";
$run_rem = db_exec($rem_sql) or errDie("Unable to get loan requests information.");
if (!isset($deny)) {
$refnum = getrefnum();
if ($accid > 0) {
$bankacc = getbankaccid($accid);
}
if ($account > 0) {
$bankacc = $account;
}
writetrans($loan_account, $bankacc, $archdate, $refnum, $loanamt, "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.");
if ($accid > 0) {
banktrans($accid, "withdrawal", $archdate, "{$myEmp['fnames']} {$myEmp['sname']}", "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.", 0, $loanamt, $loan_account);
}
# write to db
$sql = "\n\t\t\tUPDATE cubit.employees \n\t\t\tSET loanamt = '{$totamount}', loanint = '{$loanint}', loanint_amt = '{$loanint_amt}', loanint_unpaid = '{$loanint_amt}', \n\t\t\t\tloanperiod = '{$loanperiod}', loaninstall = '{$loaninstall}', gotloan = 't'::bool, loanpayslip = '{$loanamt}', \n\t\t\t\tloanfringe = '{$fringebenefit}', loandate = '{$archdate}', expacc_loan = '{$loan_account}', \n\t\t\t\tloanamt_tot = '{$totamount}', loanid = '{$loanaid}' \n\t\t\tWHERE empnum = '{$empnum}' AND div = '" . USER_DIV . "'";
$loanRslt = db_exec($sql) or errDie("Unable to add loan to system.", SELF);
if (pg_cmdtuples($loanRslt) < 1) {
return "Unable to add loan to system.";
}
}
pglib_transaction("COMMIT");
$OUT = "<table " . TMPL_tblDflts . ">";
if (isset($deny)) {
$OUT .= "\n\t\t\t<tr>\n\t\t\t\t<th>Loan Denied And Request Archived.</th>\n\t\t\t</tr>";
} else {
$OUT .= "\n\t\t\t<tr>\n\t\t\t\t<th>Loan Granted And Added To System</th>\n\t\t\t</tr>";
}
//.........这里部分代码省略.........
示例5: confirmAllow
function confirmAllow($_POST)
{
# get vars
extract($_POST);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($allowance, "string", 1, 100, "Invalid allowance name.");
$v->isOk($catid, "string", 1, 20, "Invalid Category number.");
$v->isOk($taxable, "string", 1, 3, "Invalid taxablility option.");
$v->isOk($type, "string", 1, 15, "Invalid type.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
}
$confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirmCust;
}
# connect to db
core_connect();
$allacc = "<select name='accid'>";
$sql = "SELECT * FROM accounts WHERE catid = '{$catid}' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
$numrows = pg_numrows($accRslt);
if (empty($numrows)) {
return "<li> There are no accounts under selected category.</li>\n\t\t\t\t<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
} else {
$prevtop = "";
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
if ($acc["topacc"] == $prevtop && $acc["accnum"] != "000") {
$x = " - {$acc['topacc']}/{$acc['accnum']}";
} else {
$x = "{$acc['topacc']}/{$acc['accnum']}";
$prevtop = $acc["topacc"];
}
$allacc .= "<option value='{$acc['accid']}'>{$x} {$acc['accname']}</option>";
}
}
$allacc .= "</select>";
$confirmAllow = "\n\t\t\t\t\t\t<h3>Confirm new allowance</h3>\n\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t\t\t\t\t<input type='hidden' name='allowance' value='{$allowance}'>\n\t\t\t\t\t\t\t<input type='hidden' name='taxable' value='{$taxable}'>\n\t\t\t\t\t\t\t<input type='hidden' name='type' value='{$type}'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th colspan='2'>Allowance Details</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Name of allowance</td>\n\t\t\t\t\t\t\t\t<td align='center'>{$allowance}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Allowance Account</td>\n\t\t\t\t\t\t\t\t<td align='center'>{$allacc}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Add Before PAYE</td>\n\t\t\t\t\t\t\t\t<td align='center'>{$taxable}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<!--\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Allowance Type</td>\n\t\t\t\t\t\t\t\t<td align='center'>{$type}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t//-->\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='2' align='right'><input type=submit value='Write »'></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t<br>" . mkQuickLinks(ql("allowance-add.php", "Add Allowance"), ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
return $confirmAllow;
}
示例6: block_check
function block_check($acc, $debug = false)
{
global $block_check_errs, $block_check_accs;
if (!isset($block_check_accs[$acc]) && isb($acc)) {
$block_check_accs[$acc] = 1;
$sql = "SELECT accname FROM core.accounts WHERE accid='{$acc}'";
$rslt = db_exec($sql) or errDie("Error reading account name for blocked account.");
$accname = pg_fetch_result($rslt, 0, 0);
$block_check_errs .= "<li class='err'>{$accname} is a blocked account. Please use the appropriate feature to\r\n\t\t\t\t\tchange the usage of this account before you continue with processing salaries.</li>";
return false;
}
return true;
}
示例7: details
//.........这里部分代码省略.........
# format date
list($quote_year, $quote_month, $quote_day) = explode("-", $quo['odate']);
// list($followon_year, $followon_month, $followon_day) = explode("-", $quo['ncdate']);
/* --- End Drop Downs --- */
// get the ID of the first warehouse
db_conn("exten");
$sql = "SELECT whid FROM warehouses ORDER BY whid ASC LIMIT 1";
$rslt = db_exec($sql) or errDie("Error reading warehouses (FWH).");
if (pg_num_rows($rslt) > 0) {
$FIRST_WH = pg_fetch_result($rslt, 0, 0);
} else {
$FIRST_WH = "-S";
}
/* --- Start Products Display --- */
# select all products
$products = "\n\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t<tr>\n\t\t\t\t<th>STORE</th>\n\t\t\t\t<th>ITEM NUMBER</th>\n\t\t\t\t<th>VAT CODE</th>\n\t\t\t\t<th>DESCRIPTION</th>\n\t\t\t\t<th>QTY</th>\n\t\t\t\t<th>UNIT PRICE</th>\n\t\t\t\t<th>UNIT DISCOUNT</th>\n\t\t\t\t<th>AMOUNT</th>\n\t\t\t\t<th>Remove</th>\n\t\t\t<tr>";
# get selected stock in this quote
db_connect();
$sql = "SELECT * FROM quote_items WHERE quoid = '{$quoid}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
$i = 0;
$key = 0;
while ($stkd = pg_fetch_array($stkdRslt)) {
$stkd['account'] += 0;
if ($stkd['account'] != 0) {
# Keep track of selected stock amounts
$amts[$i] = $stkd['amt'];
$i++;
db_conn('core');
$Sl = "SELECT accid,topacc,accnum,accname FROM accounts WHERE acctype='I' ORDER BY accname";
$Ri = db_exec($Sl) or errDie("Unable to get accounts.");
$Accounts = "\n\t\t\t\t<select name='accounts[]'>\n\t\t\t\t\t<option value='0'>Select Account</option>";
while ($ad = pg_fetch_array($Ri)) {
if (isb($ad['accid'])) {
continue;
}
if ($ad['accid'] == $stkd['account']) {
$sel = "selected";
} else {
$sel = "";
}
$Accounts .= "<option value='{$ad['accid']}' {$sel}>{$ad['accname']}</option>";
}
$Accounts .= "</select>";
$sernos = "";
$stkd['unitcost'] = sprint($stkd['unitcost']);
$stkd['amt'] = sprint($stkd['amt']);
# Input qty if not serialised
$qtyin = "<input type='text' size='3' name='qtys[]' value='{$stkd['qty']}'>";
$viewcost = "<input type='text' size='8' name='unitcost[]' value='{$stkd['unitcost']}'>";
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes ORDER BY code";
$Ri = db_exec($Sl) or errDie("Unable to get vat codes");
$Vatcodes = "\n\t\t\t\t<select name='vatcodes[]'>\n\t\t\t\t\t<option value='0'>Select</option>";
while ($vd = pg_fetch_array($Ri)) {
if ($stkd['vatcode'] == $vd['id']) {
$sel = "selected";
} else {
$sel = "";
}
$Vatcodes .= "<option value='{$vd['id']}' {$sel}>{$vd['code']}</option>";
}
$Vatcodes .= "</select>";
//print "fo";
# Put in product
$products .= "\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='2'>{$Accounts}<input type='hidden' name='whids[]' value='{$stkd['whid']}'></td>\n\t\t\t\t\t<td><input type='hidden' name='stkids[]' value='{$stkd['stkid']}'>{$Vatcodes}</td>\n\t\t\t\t\t<td><input type='text' size='20' name='descriptions[]' value='{$stkd['description']}'> {$sernos}</td>\n\t\t\t\t\t<td>{$qtyin}</td>\n\t\t\t\t\t<td>{$viewcost}</td>\n\t\t\t\t\t<td><input type='hidden' name='disc[]' value='{$stkd['disc']}'><input type='hidden' name='discp[]' value='{$stkd['discp']}'></td>\n\t\t\t\t\t<td nowrap><input type='hidden' name='amt[]' value='{$stkd['amt']}'> " . CUR . " {$stkd['amt']}</td>\n\t\t\t\t\t<td><input type='checkbox' name='remprod[]' value='{$key}'><input type='hidden' name='SCROLL' value='yes'></td>\n\t\t\t\t</tr>";
示例8: 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;
}
示例9: details
//.........这里部分代码省略.........
}
# format date
list($oyear, $omon, $oday) = explode("-", $quo['odate']);
/* --- End Drop Downs --- */
// get the ID of the first warehouse
db_conn("exten");
$sql = "SELECT whid FROM warehouses ORDER BY whid ASC LIMIT 1";
$rslt = db_exec($sql) or errDie("Error reading warehouses (FWH).");
if (pg_num_rows($rslt) > 0) {
$FIRST_WH = pg_fetch_result($rslt, 0, 0);
} else {
$FIRST_WH = "-S";
}
/* --- Start Products Display --- */
# select all products
$products = "\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0 width=100%>\n\t<tr><th>STORE</th><th>ITEM NUMBER</th><th>VAT CODE</th><th>DESCRIPTION</th><th>QTY</th><th>UNIT PRICE</th><th>UNIT DISCOUNT</th><th>AMOUNT</th><th>Remove</th><tr>";
# get selected stock in this quote
db_connect();
$sql = "SELECT * FROM quote_items WHERE quoid = '{$quoid}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
$i = 0;
$key = 0;
while ($stkd = pg_fetch_array($stkdRslt)) {
$stkd['account'] += 0;
if ($stkd['account'] != 0) {
# Keep track of selected stock amounts
$amts[$i] = $stkd['amt'];
$i++;
db_conn('core');
$Sl = "SELECT accid,topacc,accnum,accname FROM accounts WHERE acctype='I' ORDER BY accname";
$Ri = db_exec($Sl) or errDie("Unable to get accounts.");
$Accounts = "<select name=accounts[]>\n\t\t\t<option value='0'>Select Account</option>";
while ($ad = pg_fetch_array($Ri)) {
if (isb($ad['accid'])) {
continue;
}
if ($ad['accid'] == $stkd['account']) {
$sel = "selected";
} else {
$sel = "";
}
$Accounts .= "<option value='{$ad['accid']}' {$sel}>{$ad['accname']}</option>";
}
$Accounts .= "</select>";
$sernos = "";
# Input qty if not serialised
$qtyin = "<input type=text size=3 name=qtys[] value='{$stkd['qty']}'>";
$viewcost = "<input type=text size=8 name=unitcost[] value='{$stkd['unitcost']}'>";
db_conn('cubit');
$Sl = "SELECT * FROM vatcodes ORDER BY code";
$Ri = db_exec($Sl) or errDie("Unable to get vat codes");
$Vatcodes = "<select name=vatcodes[]>\n\t\t\t<option value='0'>Select</option>";
while ($vd = pg_fetch_array($Ri)) {
if ($stkd['vatcode'] == $vd['id']) {
$sel = "selected";
} else {
$sel = "";
}
$Vatcodes .= "<option value='{$vd['id']}' {$sel}>{$vd['code']}</option>";
}
$Vatcodes .= "</select>";
//print "fo";
# Put in product
$products .= "<tr class='bg-odd'><td colspan=2>{$Accounts}<input type=hidden name=whids[] value='{$stkd['whid']}'></td><td><input type=hidden name=stkids[] value='{$stkd['stkid']}'>{$Vatcodes}</td><td><input type=text size=20 name=descriptions[] value='{$stkd['description']}'> {$sernos}</td><td>{$qtyin}</td><td>{$viewcost}</td><td><input type=hidden name=disc[] value='{$stkd['disc']}'><input type=hidden name=discp[] value='{$stkd['discp']}'></td><td><input type=hidden name=amt[] value='{$stkd['amt']}'> " . CUR . " {$stkd['amt']}</td><td><input type=checkbox name=remprod[] value='{$key}'><input type=hidden name=SCROLL value=yes></td></tr>";
$key++;
} else {
示例10: block_check
function block_check($acc, $debug = false)
{
global $global_empnum;
global $block_check_errs, $block_check_accs;
if (!isset($block_check_accs[$acc]) && isb($acc)) {
$block_check_accs[$acc] = 1;
$sql = "SELECT accname FROM core.accounts WHERE accid='{$acc}'";
$rslt = db_exec($sql) or errDie("Error reading account name for blocked account.");
$accname = pg_fetch_result($rslt, 0, 0);
$block_check_errs .= "<li class='err'>{$accname} is a blocked account. Click\n\t\t\t<a href='empacc-link.php?empnum={$global_empnum}'>here</a> to change the\n\t\t\taccount for as the 'Salaries and Wages' account before you continue\n\t\t\t with reversing salaries.</li>";
return false;
}
return true;
}
示例11: enter
function enter($_POST)
{
extract($_POST);
if (!isset($group)) {
$group = "";
$costacc = 0;
$accdacc = 0;
$depacc = 0;
}
# connect to db
core_connect();
$Dcostacc = "<select name='costacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Balance accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
if ($costacc == $acc['accid']) {
$sel = "selected";
} else {
$sel = "";
}
$Dcostacc .= "<option value='{$acc['accid']}' {$sel}>{$acc['accname']}</option>";
}
}
$Dcostacc .= "</select>";
$Daccdacc = "<select name='accdacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Balance accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
if ($acc['accid'] == $accdacc) {
$sel = "selected";
} else {
$sel = "";
}
$Daccdacc .= "<option value='{$acc['accid']}' {$sel}>{$acc['accname']}</option>";
}
}
$Daccdacc .= "</select>";
$Ddepacc = "<select name='depacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'E' AND div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class=error>There are no Expenditure accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
if ($acc['accid'] == $depacc) {
$sel = "selected";
} elseif ($depacc == 0 && $acc['accname'] == "Depreciation") {
$sel = "selected";
} else {
$sel = "";
}
$Ddepacc .= "<option value='{$acc['accid']}' {$sel}>{$acc['accname']}</option>";
}
}
$Ddepacc .= "</select>";
$enter = "<h3>Add Asset Group</h3>\r\n\t<form action='" . SELF . "' method=post>\r\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<input type=hidden name=key value=confirm>\r\n\t<tr><th>Field</th><th>Value</th></tr>\r\n\t<tr class='bg-even'><td>" . REQ . "Asset Group</td><td><input type=text size=20 name=group value='{$group}'></td></tr>\r\n\t<tr class='bg-odd'><td>" . REQ . "Cost Account</td><td>{$Dcostacc}</td></tr>\r\n\t<tr class='bg-even'><td>" . REQ . "Accumulated Depreciation Account</td><td>{$Daccdacc}</td></tr>\r\n\t<tr class='bg-odd'><td>" . REQ . "Depreciation Account</td><td>{$Ddepacc}</td></tr>\r\n\t<tr><td><br></td></tr>\r\n\t<tr><td colspan=2 align=right><input type=submit value='Confirm »'></td></tr>\r\n\t</table></form>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='assetgrp-view.php'>View Asset Groups</a></td></tr>\r\n\t<script>document.write(getQuicklinkSpecial());</script>\r\n\t</table>";
return $enter;
}
示例12: block_check
function block_check($acc, $empname = false, $debug = false)
{
global $global_empnum;
global $block_check_errs, $block_check_accs;
if (!isset($block_check_accs[$acc]) && isb($acc)) {
$block_check_accs[$acc] = 1;
db_conn("core");
$sql = "SELECT accname FROM accounts WHERE accid='{$acc}'";
$rslt = db_exec($sql) or errDie("Error reading account name for blocked account.");
$accname = pg_fetch_result($rslt, 0, 0);
if ($empname === false) {
$block_check_errs .= "<li class='err'>{$accname} is a blocked account. Please use the appropriate feature to\n\t\t\t\t\t\tchange the usage of this account before you continue with processing salaries.</li>";
} else {
$block_check_errs .= "<li class='err'>{$accname} is a blocked account. Unable to process employee {$empname}. Click\n\t\t\t\t<a href='empacc-link.php?empnum={$global_empnum}'>here</a> to change the\n\t\t\t\taccount to appropriate/custom account before you continue with reversing salaries.</li>";
}
return false;
}
return true;
}
示例13: enter
function enter()
{
extract($_REQUEST);
db_connect();
#branch mode install may not add stores .. disable this script
$get_check = getCSetting("INST_MODE");
if (!isset($get_check) or strlen($get_check) < 1) {
#setting not found ??? do nothing
} elseif ($get_check == "branch") {
return "<li class='err'>Branch Companies May Not Add New Stores.</li>";
}
$fields = array();
$fields["team_id"] = 0;
extract($fields, EXTR_SKIP);
# connect to db
core_connect();
$stkacc = "<select name='stkacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class='err'>There are no Balance accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$stkacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$stkacc .= "</select>";
$cosacc = "<select name='cosacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'E' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class='err'>There are no Expenditure accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$cosacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$cosacc .= "</select>";
$conacc = "<select name='conacc'>";
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "'";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li class='err'>There are no Income accounts yet in Cubit.</li>";
} else {
while ($acc = pg_fetch_array($accRslt)) {
if (isb($acc['accid'])) {
continue;
}
$conacc .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$conacc .= "</select>";
// Team permissions
$sql = "SELECT id, name, des FROM crm.teams ORDER BY name ASC";
$team_rslt = db_exec($sql) or errDie("Unable to retrieve teams.");
$team_sel = "\r\n\t\t<select name='team_id' style='width: 100%'>\r\n\t\t\t<option value='0'>[All]</option>";
while (list($id, $team_name, $team_desc) = pg_fetch_array($team_rslt)) {
if ($team_id == $id) {
$sel = "selected='selected'";
} else {
$sel = "";
}
$team_sel .= "<option value='{$id}' {$sel}>{$team_name} - {$team_desc}</option>";
}
$enter = "\r\n\t\t<h3>Add Store</h3>\r\n\t\t<form action='" . SELF . "' method='POST'>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<input type='hidden' name='key' value='confirm'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Field</th>\r\n\t\t\t\t<th>Value</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Number</td>\r\n\t\t\t\t<td><input type='text' size='10' name='whno' /></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Store</td>\r\n\t\t\t\t<td><input type='text' size='10' maxlength='10' name='whname' /></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Stock Account</td>\r\n\t\t\t\t<td>{$stkacc}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Cost Of Sales Account</td>\r\n\t\t\t\t<td>{$cosacc}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Stock Control Account</td>\r\n\t\t\t\t<td>{$conacc}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Team Permissions</td>\r\n\t\t\t\t<td>{$team_sel}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2' align='right'>\r\n\t\t\t\t\t<input type='submit' value='Confirm »' />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</form>\r\n\t\t<p>\r\n\t\t<table border='0' cellpadding='2' cellspacing='1'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Quick Links</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='whouse-view.php'>View Stores</a></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='../core/acc-new2.php'>Add Account</a></td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><a href='../main.php'>Main Menu</a></td>\r\n\t\t\t</tr>\r\n\t\t</table>";
return $enter;
}
示例14: view
function view($VARS = array(), $err = "")
{
foreach ($VARS as $key => $vals) {
${$key} = $vals;
}
$vars = array("bankname", "branchname", "loc", "fcid", "branchcode", "accname", "accnum", "cardnum", "mon", "year", "lastdigits", "cardname", "cardtyp", "details");
$vard = array("cardtyp" => "Visa", "mon" => date("m"), "year" => date("Y"));
foreach ($vars as $key => $val) {
if (!isset(${$val})) {
${$val} = isset($vard[$val]) ? $vard[$val] : "";
}
}
if (strlen($lastdigits) < 1) {
$lastdigits = "000";
}
db_connect();
# Locations drop down
$locs = array("loc" => "Local", "int" => "International");
$locsel = extlib_cpsel("loc", $locs, $loc);
# currency drop down
$currsel = ext_unddbsel("fcid", "currency", "fcid", "descrip", "There are is no currency found in Cubit, please add currency first.", "");
$chm = "";
$chv = "";
$cho = "";
if ($cardtyp == 'Visa') {
$chv = "checked=yes";
} elseif ($cardtyp == 'Mastercard') {
$chm = "checked=yes";
} else {
$cho = "checked=yes";
}
core_connect();
$sql = "SELECT * FROM accounts WHERE acctype = 'B' AND div = '" . USER_DIV . "' ORDER BY accname";
$accRslt = db_exec($sql) or errDie("Could not retrieve accounts from Cubit.", SELF);
if (pg_numrows($accRslt) < 1) {
return "<li> There are no balance accouts in Cubit.";
}
$accs = "<select name=accid>";
while ($acc = pg_fetch_array($accRslt)) {
if (isbank($acc['accid'])) {
continue;
}
if (isb($acc['accid'])) {
continue;
}
$accs .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
$accs .= "</select>";
//layout
$view = "\n\t<h3>Add New Petrol Card Account</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t<form action='" . SELF . "' method=post name=form>\n\t<input type=hidden name=key value=confirm>\n\t<tr><td colspan=2>{$err}</td></tr>\n\t<tr><th>Field</th><th>Value</th></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Bank Name</td><td ><input type=text size=20 name=bankname value='{$bankname}'></td></tr>\n\t<tr class='bg-even'><td>" . REQ . "Type</td><td>{$locsel}</td></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Currency</td><td>{$currsel}</td></tr>\n\t<tr class='bg-even'><td>" . REQ . "Branch Name</td><td ><input type=text size=20 name=branchname value='{$branchname}'></td></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Branch Code</td><td ><input type=text size=20 name=branchcode value='{$branchcode}'></td></tr>\n\t<tr class='bg-even'><td>" . REQ . "Account Name</td><td ><input type=text size=20 name=accname maxlength=50 value='{$accname}'></td></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Account Number</td><td ><input type=text size=20 name=accnum value='{$accnum}'></td></tr>\n\t<tr class='bg-even'><td>" . REQ . "Ledger Account</td><td>{$accs}</td></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Card Number</td><td ><input type=text size=25 name=cardnum maxlength=16 value='{$cardnum}'></td></tr>\n\t<tr class='bg-even'><td>" . REQ . "Expiry Date</td><td><input type=text size=2 name=mon maxlength=2 value='{$mon}'>-<input type=text size=4 name=year maxlength=4 value='{$year}'>MM-YYYY</td></tr>\n\t<tr class='bg-odd'><td>" . REQ . "Last 3 Digits at back of Card</td><td ><input type=text size=3 maxlength=3 name=lastdigits value='{$lastdigits}'></td></tr>\n\t<tr class='bg-even'><td>Card Type</td><td><input type=radio name=cardtyp value=Visa {$chv}>Visa <input type=radio name=cardtyp value='Mastercard' {$chm}> Mastercard <input type=radio name=cardtyp value='other' {$cho}>Other: <input type=text name=cardname value='{$cardname}'></td>\n\t<tr class='bg-odd'><td>" . REQ . "Details</td><td ><textarea cols=20 rows=3 name=details>{$details}</textarea></td></tr>\n\t<tr><td><br></td></tr>\n\t<tr><td><input type=button value='« Cancel' onClick='javascript:history.back();'></td><td ><input type=submit value='Confirm »'></td></tr>\n\t</form>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='../core/acc-new2.php'>Add Ledger Account</a></td></tr>\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\n\t</table>";
return $view;
}
示例15: writeLoan
function writeLoan($_POST)
{
# get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($empnum, "num", 1, 20, "Invalid employee number.");
$v->isOk($loanamt, "float", 1, 10, "Invalid loan amount.");
$v->isOk($loanint, "float", 1, 5, "Invalid loan interest.");
$v->isOk($loanperiod, "num", 1, 3, "Invalid payback period.");
$v->isOk($loaninstall, "float", 1, 10, "Invalid monthly installment.");
$v->isOk($fringebenefit, "float", 1, 10, "Invalid fringe benefit amount.");
$v->isOk($lday, "num", 1, 2, "Invalid day.");
$v->isOk($lmonth, "num", 1, 2, "Invalid month.");
$v->isOk($lyear, "num", 4, 4, "Invalid year.");
$v->isOk($accid, "num", 1, 9, "Invalid bank account selected.");
$v->isOk($account, "num", 1, 9, "Invalid contra account selected.");
$v->isOk($loan_account, "num", 1, 9, "Invalid loan account selected.");
if (!checkdate($lmonth, $lday, $lyear)) {
$v->addError("", "Invalid date.");
}
if ($account > 0 && isb($account) || isb($loan_account)) {
$v->addError("", "Main accounts blocked. Please select sub accounts.");
}
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class=err>" . $e["msg"] . "</li>";
}
return enterLoan($confirmCust);
}
# get employee details
db_connect();
$sql = "SELECT * FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "'";
$empRslt = db_exec($sql) or errDie("Unable to select employees from database.");
if (pg_numrows($empRslt) < 1) {
return "Invalid employee ID.";
}
$myEmp = pg_fetch_array($empRslt);
# check for previous loan
$sql = "SELECT empnum FROM employees WHERE empnum='{$empnum}' AND div = '" . USER_DIV . "' AND gotloan='t'::bool";
$chkRslt = db_exec($sql) or errDie("Unable to check existing loans for employee.");
if (pg_numrows($chkRslt) > 0) {
return "Loan already exists for employee number: {$empnum}.";
}
if ($accid > 0) {
$bankacc = getbankaccid($accid);
}
# Debit salaries control acc and credit Bank acc
$date = date("Y-m-d");
$refnum = getrefnum();
if ($account > 0) {
$bankacc = $account;
}
writetrans($loan_account, $bankacc, $date, $refnum, $loanamt, "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.");
if ($accid > 0) {
# issue bank record
banktrans($accid, "withdrawal", date("d-m-Y"), "{$myEmp['fnames']} {$myEmp['sname']}", "Loan granted to employee {$myEmp['fnames']} {$myEmp['sname']}.", 0, $loanamt, $loan_account);
}
$totamount = sprint($loanperiod * $loaninstall);
$loanint_amt = $totamount - $loanamt;
# connect to db
db_connect();
$ldate = "{$lyear}-{$lmonth}-{$lday}";
pglib_transaction("BEGIN");
$sql = "INSERT INTO emp_loanarchive (empnum, loanamt, loaninstall, loanint, loanperiod,loandate, div)\n\t\t\tVALUES('{$empnum}', '{$totamount}', '{$loaninstall}', '{$loanint}', '{$loanperiod}', CURRENT_DATE, '" . USER_DIV . "')";
$rslt = db_exec($sql) or errDie("Unable to pre archive loan.");
$loanid = pglib_lastid('emp_loanarchive', 'id');
# write to db
$sql = "UPDATE employees\n\t\t\tSET loanamt='{$totamount}', loanint='{$loanint}', loanint_amt='{$loanint_amt}',\n\t\t\t\tloanint_unpaid='{$loanint_amt}', loanperiod='{$loanperiod}', loaninstall='{$loaninstall}',\n\t\t\t\tgotloan='t'::bool, loanpayslip='{$loanamt}', loanfringe='{$fringebenefit}', loandate='{$ldate}',\n\t\t\t\texpacc_loan='{$loan_account}', loanamt_tot='{$totamount}', loanid='{$loanid}'\n\t\t\tWHERE empnum='{$empnum}' AND div = '" . USER_DIV . "'";
$loanRslt = db_exec($sql) or errDie("Unable to add loan to system.", SELF);
if (pg_cmdtuples($loanRslt) < 1) {
return "Unable to add loan to system.";
}
pglib_transaction("COMMIT");
$writeLoan = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n\t<tr><th>Loan granted and added to system</th></tr>\n\t<tr class=datacell><td>New loan has been successfully added to Cubit.</td></tr>\n\t</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
return $writeLoan;
}