本文整理汇总了PHP中getrefnum函数的典型用法代码示例。如果您正苦于以下问题:PHP getrefnum函数的具体用法?PHP getrefnum怎么用?PHP getrefnum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getrefnum函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
function update($_POST)
{
# Get Vars ( banked[] )
extract($_POST);
# check if anything is selected
if (!isset($banked)) {
$err = "<li class='err'> Please Select at least one entry to update.";
return cashbook($_POST, $err);
}
/* - Start Hooks - */
$vatacc = gethook("accnum", "salesacc", "name", "VAT");
/* - End Hooks - */
$refnum = getrefnum();
/*refnum*/
db_conn('core');
$rid = pglib_lastid("save_bank_recon", "id");
$rid++;
# Record all trans
foreach ($banked as $key => $cashid) {
# Connect to database
db_Connect();
$sql = "SELECT * FROM cashbook WHERE cashid='{$cashid}' AND div = '" . USER_DIV . "'";
$cashRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve details from database.", SELF);
$cash = pg_fetch_array($cashRslt);
# Set record as banked
db_connect();
$sql = "UPDATE cashbook SET banked = 'yes',rid='{$rid}' WHERE cashid='{$cashid}' AND div = '" . USER_DIV . "'";
$Rslt = db_exec($sql) or errDie("Unable to set bank deposit as banked in Cubit.", SELF);
}
// Connect to database
db_connect();
$sql = "SELECT * FROM cashbook WHERE bankid = '{$bankid}' AND banked = 'no' AND div = '" . USER_DIV . "' ORDER BY date DESC";
$cashRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve bank transactions from database.", SELF);
$sql = "SELECT * FROM bankacct WHERE bankid= '{$bankid}' AND div = '" . USER_DIV . "'";
$bankRslt = db_exec($sql);
$bank = pg_fetch_array($bankRslt);
$cur = CUR;
$amtd = "amount";
if ($bank['btype'] == 'int') {
$currs = getSymbol($bank['fcid']);
$cur = $currs['symbol'];
$amtd = "famount";
}
$tot = 0;
$totr = 0;
$totp = 0;
$recpts = "";
$paymnts = "";
while ($cash = pg_fetch_array($cashRslt)) {
if ($cash['trantype'] == "deposit") {
$recpts .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$cash['date']}</td>\n\t\t\t\t\t<td>{$cash['descript']}</td>\n\t\t\t\t\t<td align='right'>{$cur} {$cash[$amtd]}</td>\n\t\t\t\t</tr>";
$totr += $cash[$amtd];
} else {
$paymnts .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$cash['date']}</td>\n\t\t\t\t\t<td>{$cash['descript']}</td>\n\t\t\t\t\t<td align='right'>{$cur} {$cash[$amtd]}</td>\n\t\t\t\t</tr>";
$totp += $cash[$amtd];
}
$tot += $cash[$amtd];
}
$reconbal = sprint($cbal + ($totr - $totp));
# 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.";
}
$banklnk = pg_fetch_array($rslt);
# Get bank balance
$sql = "SELECT (debit - credit) as bal FROM trial_bal WHERE period='12' AND accid = '{$banklnk['accnum']}' AND div = '" . USER_DIV . "'";
$brslt = db_exec($sql) or errDie("Unable to retrieve bank account link from Cubit", SELF);
$bal = pg_fetch_array($brslt);
if ($bank['btype'] == 'int') {
$bal['bal'] = $bank['fbalance'];
}
$diff = sprint($reconbal - $bal['bal']);
$derr = "";
if ($diff != 0) {
$derr = "\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><b class='err'>Bank statement and computer balance not balancing by</b></td>\n\t\t\t\t<td align='right'>{$cur} {$diff}</td>\n\t\t\t</tr>";
}
$totp = sprint($totp);
// Layout
$update = "\n\t\t<center>\n\t\t<h3>Bank Reconciliation Output</h3>\n\t\t<form action='" . SELF . "' method='POST' name='form1'>\n\t\t\t<input type='hidden' name='key' value='save'>\n\t\t\t<input type='hidden' name='bankid' value='{$bankid}'>\n\t\t<table cellpadding='2' cellspacing='0' border=0 bordercolor='#000000' width='80%'>\n\t\t\t<tr>\n\t\t\t\t<td colspan='10'>\n\t\t\t\t\t<table cellpadding='2' cellspacing='0' border=0 bordercolor='#000000' width=100%>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><b>Bank Account : </b>{$bank['accname']}</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td align='right'><b>Prepared By : </b>" . USER_NAME . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><b>Closing Balance As per Bank Statement : </b>{$cur} {$cbal}</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<td><b>Plus Outstanding Receipts :</b></td>\n\t\t\t</tr>\n\t\t\t<!--<tr><th>Date</th><th>Reference</th><th>Amount</th></tr>-->\n\t\t\t{$recpts}\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td align='right'>____________</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><b>Sub Total</b></td>\n\t\t\t\t<td align='right'>{$cur} {$totr}</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<td><b>Less Outstanding Payments :</b></td>\n\t\t\t</tr>\n\t\t\t<!--<tr><th>Date</th><th>Reference</th><th>Amount</th></tr>-->\n\t\t\t{$paymnts}\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td align='right'>____________</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><b>Sub Total</b></td>\n\t\t\t\t<td align='right'>{$cur} {$totp}</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br><td></tr>\n\t\t\t{$derr}\n\t\t\t<tr><td><br><td></tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td align='right'>____________</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><b>Reconciled Bank Balance</b></td>\n\t\t\t\t<td align='right'>{$cur} {$reconbal}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><b>Computer Bank Balance</b></td>\n\t\t\t\t<td align='right'>{$cur} {$bal['bal']}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td align='right'>____________</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><b>Diff</b></td>\n\t\t\t\t<td align='right'>{$cur} {$diff}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td align='right'>____________</td>\n\t\t\t</tr>";
$upcode = base64_encode($update);
$button = "</table></form>";
core_connect();
$gendate = date("Y-m-d");
$sql = "\n\t\tINSERT INTO save_bank_recon (\n\t\t\tbankid, gendate, recon, div\n\t\t) VALUES (\n\t\t\t'{$bankid}', '{$gendate}', '{$upcode}', '" . USER_DIV . "'\n\t\t)";
$saveRslt = db_exec($sql) or errDie("Unable to save bank recon to database", SELF);
$update .= $button;
$OUTPUT = $update;
require "../tmpl-print.php";
}
示例2: slctacc
function slctacc()
{
// connect
db_conn(PRD_DB);
$refnum = getrefnum();
/*refnum*/
// Accounts (debit)
$view = "<center>\n <h3> Journal transaction </h3>\n <br><br>\n <form action='" . SELF . "' method=post name=form>\n <input type=hidden name=key value=details>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' align=center>\n <tr><th>Field</th><th>Value</th></tr>\n <tr class='bg-odd'><td>Date</td><td><input type=text size=2 name=day maxlength=2 value='" . date("d") . "'>-<input type=text size=2 name=mon maxlength=2 value='" . date("m") . "'>-<input type=text size=4 name=year maxlength=4 value='" . date("Y") . "'></td></tr>\n <tr class='bg-odd'><td>Reference Number</td><td><input type=text size=10 name=refnum value='" . $refnum++ . "'></td></tr>\n <tr><td><br></td></tr>\n <tr><td align=center>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><td><h4>Debit</h4></td></tr>\n <tr><th>Select Account</th></tr>\n <tr class='bg-even'>\n <td valign=center>\n <select name='dtaccid'>";
core_connect();
$sql = "SELECT * FROM accounts WHERE div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li>There are No accounts in Cubit.";
}
while ($acc = pg_fetch_array($accRslt)) {
$view .= "<option value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</option>";
}
$view .= "</select></td></tr>\n </table>\n </td>\n <td align=center>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><td><h4>Credit</h4></td></tr>\n <tr><th>Select Account</th></tr>\n <tr class='bg-even'>\n <td valign=center>\n <select name=ctaccid>";
$sql = "SELECT * FROM accounts WHERE div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li>There are No accounts in Cubit.";
}
while ($acc = pg_fetch_array($accRslt)) {
$view .= "<option value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</option>";
}
$view .= "</select>\n </td><td><input name=details type=submit value='Enter Details >'></td></tr>\n </table>\n </td></tr>\n </table><br><br><br>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' align=center>\n <td align=center>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><td><h4>Debit</h4></td></tr>\n <tr><th>Account number</th></tr>\n <tr class='bg-even'><td valign=center><input type=text name=dtaccnum size=20></td></tr>\n </table>\n </td>\n <td align=center>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><td><h4>Credit</h4></td></tr>\n <tr><th>Account number</th></tr>\n <tr class='bg-even'>\n <td valign=center><input type=text name=ctaccnum size=20></td><td><input type=submit value='Enter Details >'></td></tr></table>\n </td></tr>\n </table>\n <br>\n <input type=button value='< Go Back' onClick='javascript:history.back();'>\n </form>\n <table border=0 cellpadding='2' cellspacing='1' width=15%>\n\t<tr><td><br></td></tr>\n\t<tr><th>Quick Links</th></tr>\n\t<tr class=datacell><td align=center><a href='trans-new.php'>Journal Transactions</td></tr>\n\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table></center>";
return $view;
}
示例3: slctacc
function slctacc($err = "")
{
extract($_POST);
db_conn(PRD_DB);
if (!isset($refnum)) {
$refnum = getrefnum();
}
// if (empty($jr_year)) {
// explodeDate(false, $jr_year, $jr_month, $jr_day);
// }
if (empty($dtaccid)) {
$dtaccid = false;
}
if (empty($ctaccid)) {
$ctaccid = false;
}
/** REFNUM **/
//Select Account <input align='right' type='button' onClick=\"popupSized('acc-new2.php?update_parent=yes','accounts','700','400');\" value='Add Account'>
if (!isset($yr_day)) {
$trans_date_setting = getCSetting("USE_TRANSACTION_DATE");
if (isset($trans_date_setting) and $trans_date_setting == "yes") {
$trans_date_value = getCSetting("TRANSACTION_DATE");
$date_arr = explode("-", $trans_date_value);
$jr_year = $date_arr[0];
$jr_month = $date_arr[1];
$jr_day = $date_arr[2];
} else {
$jr_year = date("Y");
$jr_month = date("m");
$jr_day = date("d");
}
}
$view = "\n\t\t<center>\n\t\t<h3> Journal transaction </h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST' name='form'>\n\t\t\t<input type='hidden' name='key' value='details' />\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>Date</td>\n\t\t\t\t<td>" . mkDateSelect("jr", $jr_year, $jr_month, $jr_day) . "</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Reference Number</td>\n\t\t\t\t<td><input type='text' size='10' name='refnum' value='" . $refnum++ . "'></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td align='center'>\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<td><h4>Debit</h4></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Select Account <input align='right' type='button' onClick=\"window.open('acc-new2.php?update_parent=yes','accounts','width=700, height=400');\" value='New Account'></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 valign='center'>" . mkAccSelect("dtaccid", $dtaccid) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t\t<td align='center'>\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<td><h4>Credit</h4></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Select Account <input align='right' type='button' onClick=\"window.open('acc-new2.php?update_parent=yes','accounts','width=700, height=400');\" value='New Account'></th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t<td valign='center'>" . mkAccSelect("ctaccid", $ctaccid) . "</td>\n\t\t\t\t\t\t\t<td><input name='details' type='submit' value='Enter Details >'></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<br />\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<td align='center'>\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<td><h4>Debit</h4></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Account number</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t<td valign='center'><input type='text' name='dtaccnum' size='20'></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t\t<td align='center'>\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<td><h4>Credit</h4></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Account number</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t<td valign='center'><input type='text' name='ctaccnum' size='20'></td>\n\t\t\t\t\t\t\t<td><input type='submit' value='Enter Details >'></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<br />\n\t\t</form>" . mkQuickLinks(ql("../reporting/index-reports.php", "Financials"), ql("../core/acc-new2.php", "Add New Account"), ql("trans-new.php", "Journal Transactions"));
return $view;
}
示例4: slctacc
function slctacc()
{
$refnum = getrefnum();
/*refnum*/
// Accounts (debit)
$view = "<center>\n <h3>Add Journal transactions to batch </h3>\n <form action='" . SELF . "' method=post name=form>\n <input type=hidden name=key value=confirm>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' align=center>\n <tr><th>Date</th><th>Ref num</th><th>Debit</th><th>Credit</th><th>Amount</th><th>Description</th></tr>";
for ($i = 0; $i != 5; $i++) {
$view .= "<tr><td><input type=text size=10 name=date[] value=" . date("d-m-Y") . "></td>\n <td><input type=text size=10 name=refnum[] value='{$refnum}'></td>\n <td valign=center>\n <select name='dtaccid[]'>";
core_connect();
$sql = "SELECT * FROM accounts ORDER BY topacc, accnum ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li>There are No accounts in Cubit.";
}
while ($acc = pg_fetch_array($accRslt)) {
$view .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
$view .= "</select></td>\n <td valign=center>\n <select name=ctaccid[]>";
$sql = "SELECT * FROM accounts ORDER BY topacc, accnum ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li>There are No accounts in Cubit.";
}
while ($acc = pg_fetch_array($accRslt)) {
$view .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
$view .= "</select></td>\n <td><input type=text size=10 name=amount[]></td>\n <td><input type=text size=30 name=descript[]></td>\n </tr>";
}
$view .= "\n <tr><td><input type=button value=Back OnClick='javascript:history.back()'></td><td valign=center colspan=2><input type=submit value='Record Transaction'></td></tr>\n </form>\n </table>\n\t<table border=0 cellpadding='2' cellspacing='1' width=15%>\n <tr><td>\n <br>\n </td></tr>\n <tr><th>Quick Links</th></tr>\n <tr class=datacell><td align=center><a href='trans-new.php'>Journal Transactions</td></tr>\n <script>document.write(getQuicklinkSpecial());</script>\n </table>";
return $view;
}
示例5: write
function write($frm)
{
extract($_REQUEST);
if ($frm->validate("write")) {
return confirm($frm);
}
pglib_transaction("BEGIN");
db_conn('cubit');
$user = USER_NAME;
$Sql = "SELECT * FROM assets WHERE (dep_month='yes' AND remaction IS NULL)";
$Rslt = db_exec($Sql) or errDie("Unable to access database.");
$cc = "";
$todate = mkdate($date_year, $date_month, $date_day);
$ttime = mktimefd($todate);
$refnum = getrefnum($todate);
while ($led = pg_fetch_array($Rslt)) {
if (empty($led["autodepr_date"])) {
$led["autodepr_date"] = $led["date"];
}
explodeDate($led["autodepr_date"], $date_year, $date_month, $date_day);
$ftime = mktime(0, 0, 0, $date_month, $date_day, $date_year);
$depmonths = 0;
while ($ftime < $ttime) {
++$depmonths;
$ftime = mktime(0, 0, 0, $date_month + $depmonths, $date_day, $date_year);
}
if ($depmonths == 0) {
continue;
}
$depperc = $led["dep_perc"];
$ml_perc = $depperc * ($depmonths % 12 / 12);
$years = ($depmonths - $depmonths % 12) / 12;
$baseamt = $led["amount"] - $led["accdep"];
$depamt = 0;
/* yearly depreciations */
for ($i = 1; $i <= $years; ++$i) {
$depamt += ($baseamt - $depamt) * ($depperc / 100);
}
/* monthly depreciation */
$depamt += ($baseamt - $depamt) * ($ml_perc / 100);
$sql = "SELECT * FROM assetgrp WHERE grpid = '{$led['grpid']}' AND div = '" . USER_DIV . "'";
$grpRslt = db_exec($sql);
$grp = pg_fetch_array($grpRslt);
writetrans($grp['depacc'], $grp['accdacc'], $todate, $refnum, $depamt, "{$led['des']} Depreciation");
db_connect();
$sql = "UPDATE assets SET accdep = (accdep + '{$depamt}'), autodepr_date='{$todate}'\r\n\t\t\t\tWHERE (id='{$led['id']}' AND div = '" . USER_DIV . "')";
db_exec($sql) or errdie("Could not update assets table.");
$snetval = $baseamt - $depamt;
$sdate = date("Y-m-d");
$sql = "INSERT INTO assetledger(assetid, asset, date, depamt, netval, div) \r\n\t\t\t\tVALUES ('{$led['id']}', '{$led['des']}', '{$todate}', '{$depamt}', '{$snetval}', '" . USER_DIV . "')";
db_exec($sql) or errdie("Could not write to asset ledger.");
$cc .= "CostCenter('ct', 'Asset Depreciation', '{$todate}', '{$led['des']} Depreciation', '{$depamt}', '');";
}
pglib_transaction("COMMIT");
$write = "\r\n\t<script> \r\n\t{$cc}\r\n\t</script>\r\n\t<table " . TMPL_tblDflts . " width='50%'>\r\n\t\t<tr>\r\n\t\t\t<th>Auto Asset Depreciation</th>\r\n\t\t</tr>\r\n\t\t<tr class='datacell'>\r\n\t\t\t<td>Asset Depreciation has calculated and recorded.</td>\r\n\t\t</tr>\r\n\t</table>";
return $write;
}
示例6: slctacc
function slctacc()
{
db_conn(PRD_DB);
# get last ref number
$refnum = getrefnum();
/*refnum*/
// Accounts (debit)
$view = "<center>\n <h3> Multiple Journal transactions </h3>\n <form action='" . SELF . "' method=post name=form>\n <input type=hidden name=key value=confirm>\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' align=center>\n <tr><th>Date</th><th>Ref num</th><th>Debit (Acc No.)</th><th>Credit (Acc No.)</th><th>Amount</th><th>Description</th></tr>";
for ($i = 0; $i != 15; $i++) {
$view .= "<tr class='bg-even'>\n <td><input type=text size=2 name=day[] maxlength=2>-<input type=text size=2 name=mon[] maxlength=2 value='" . date("m") . "'>-<input type=text size=4 name=year[] maxlength=4 value='" . date("Y") . "'></td>\n <td><input type=text size=10 name=refnum[] value='" . $refnum++ . "'></td>\n <td valign=center><input type=text size=12 name='dtaccnum[]'></td>\n <td valign=center><input type=text size=12 name='ctaccnum[]'></td>\n <td><input type=text size=20 name=amount[]></td>\n <td><input type=text size=30 name=descript[]></td>\n </tr>";
}
$view .= "\n <tr><td><input type=button value=Back OnClick='javascript:history.back()'></td><td valign=center colspan=2><input type=submit value='Record Transaction'></td></tr>\n </form>\n </table>\n\t<table border=0 cellpadding='2' cellspacing='1' width=15%>\n <tr><td>\n <br>\n </td></tr>\n <tr><th>Quick Links</th></tr>\n <tr class=datacell><td align=center><a href='trans-new.php'>Journal Transactions</td></tr>\n <script>document.write(getQuicklinkSpecial());</script>\n </table>";
return $view;
}
示例7: slctacc
function slctacc($_POST, $err = "")
{
extract($_POST);
$translist = "";
if (!isset($total)) {
$total = 1;
}
if (!isset($refnum)) {
$refnum = getrefnum();
}
$jump_bot = "";
if (isset($more)) {
$jump_bot = "\n\t\t\t<script>\n\t\t\t\twindow.location.hash='bottom';\n\t\t\t</script>";
$total++;
}
if (!isset($date_year)) {
$trans_date_setting = getCSetting("USE_TRANSACTION_DATE");
if (isset($trans_date_setting) and $trans_date_setting == "yes") {
$trans_date_value = getCSetting("TRANSACTION_DATE");
$date_arr = explode("-", $trans_date_value);
$date_year = $date_arr[0];
$date_month = $date_arr[1];
$date_day = $date_arr[2];
} else {
$date_year = date("Y");
$date_month = date("m");
$date_day = date("d");
}
}
for ($i = 0; $i != $total; $i++) {
core_connect();
$sql = "SELECT * FROM accounts WHERE div = '" . USER_DIV . "' ORDER BY accname ASC";
$accRslt = db_exec($sql);
if (pg_numrows($accRslt) < 1) {
return "<li>There are No accounts in Cubit.</li>";
}
$dtaccid[$i] += 0;
$dtamount[$i] += 0;
$ctamount[$i] += 0;
$translist .= "\n\t\t\t<tr bgcolor=" . bgcolorg() . ">\n\t\t\t\t<td valign='center'>" . mkAccSelect("accid[]", $accid[$i]) . "</td>\n\t\t\t\t<td><input type='text' size='20' name='descript[]' value='{$descript[$i]}'></td>\n\t\t\t\t<td><input type='text' size='7' name='dtamount[]' value='{$dtamount[$i]}'></td>\n\t\t\t\t<td><input type='text' size='7' name='ctamount[]' value='{$ctamount[$i]}'></td>\n\t\t\t</tr>";
}
$translist .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='2' align='right'><b>Total:</b></td>\n\t\t\t<td>" . CUR . " " . sprint(array_sum($dtamount)) . "</td>\n\t\t\t<td>" . CUR . " " . sprint(array_sum($ctamount)) . "</td>\n\t\t</tr>";
// Accounts (debit)
$view = "\n\t\t<center>\n\t\t<h3>Process Multiple Account Journal Transactions</h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST' name='form'>\n\t\t\t<input type='hidden' name='key' value='confirm'>\n\t\t\t<input type='hidden' name='total' value='{$total}'>\n\t\t<table " . TMPL_tblDflts . " align='center'>\n\t\t\t<tr>\n\t\t\t\t<th>Transaction Date</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>" . mkDateSelect("date", $date_year, $date_month, $date_day) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Select Contra Account</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>" . mkAccSelect("account", $account) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Reference Number</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'><input type='text' size='5' name='refnum' value='{$refnum}'></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t</table>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Account <input align='right' type='button' onClick=\"window.open('acc-new2.php?update_parent=yes','accounts','width=700, height=400');\" value='New Account'></th>\n\t\t\t\t<th>Description</th>\n\t\t\t\t<th>Debit</th>\n\t\t\t\t<th>Credit</th>\n\t\t\t</tr>\n\t\t\t{$translist}\n\t\t\t<tr>\n\t\t\t\t<td colspan='3'><input type='submit' name='more' value='Add Another'></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valign='center' colspan='4' align='right'><input type='submit' name='confirm' value='Confirm »'></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>\n\t\t<a name='bottom'>\n\t\t{$jump_bot}\n\t\t<table border=0 cellpadding='2' cellspacing='1' width=15%>\n\t\t\t<tr><td><br></td></tr>\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='datacell'>\n\t\t\t\t<td align='center'><a href='../reporting/index-reports.php'>Financials</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='batch-view.php'>View batch Entries</td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='trans-new.php'>Journal Transaction</td>\n\t\t\t</tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
return $view;
}
示例8: slctacc
function slctacc($err = "")
{
extract($_POST);
db_conn(PRD_DB);
$refnum = getrefnum();
if (empty($jr_year)) {
explodeDate(false, $jr_year, $jr_month, $jr_day);
}
if (empty($dtaccid)) {
$dtaccid = false;
}
if (empty($ctaccid)) {
$ctaccid = false;
}
/** REFNUM **/
$view = "\n\t\t\t\t<center>\n\t\t\t\t<h3> Journal transaction </h3>\n\t\t\t\t{$err}\n\t\t\t\t<form action='" . SELF . "' method='POST' name='form'>\n\t\t\t\t\t<input type='hidden' name='key' value='details' />\n\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Field</th>\n\t\t\t\t\t\t<th>Value</th>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>Date</td>\n\t\t\t\t\t\t<td>" . mkDateSelect("jr", $jr_year, $jr_month, $jr_day) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>Reference Number</td>\n\t\t\t\t\t\t<td><input type='text' size='10' name='refnum' value='" . $refnum++ . "'></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><h4>Debit</h4></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>Select Account</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t<td valign='center'>" . mkAccSelect("dtaccid", $dtaccid) . "</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><h4>Credit</h4></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>Select Account</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t\t\t<td valign='center'>" . mkAccSelect("ctaccid", $ctaccid) . "</td>\n\t\t\t\t\t\t\t\t\t<td><input name='details' type='submit' value='Enter Details >'></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t<br />\n\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><h4>Debit</h4></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>Account number</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t\t\t<td valign='center'><input type='text' name='dtaccnum' size='20'></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td align='center'>\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><h4>Credit</h4></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>Account number</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t\t\t\t\t\t\t<td valign='center'><input type='text' name='ctaccnum' size='20'></td>\n\t\t\t\t\t\t\t\t\t<td><input type='submit' value='Enter Details >'></td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t<br />\n\t\t\t\t</form>" . mkQuickLinks(ql("../reporting/index-reports.php", "Financials"), ql("../core/acc-new2.php", "Add New Account"), ql("../core/trans-new.php", "Journal Transactions"));
return $view;
}
示例9: confirm
function confirm($_POST)
{
# Get Vars ( banked[] )
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# check if anything is selected
if (!isset($bank)) {
return "<li class=err> Please Select at least one entry to proccess.";
}
$OUTPUT = "<h3>Process Multiple Entries</h3>\r\n <h4>Confirm Selection</h4>\r\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n <form action='" . SELF . "' method=post>\r\n <input type=hidden name=key value=bank>\r\n <tr><th>Bank Name</th><th>Account Name</th><th>Date</th><th>Reference No</th><th>Paid to/Received from<th>Description</th><th>Transaction Type</th><th>Amount</th><th>Account paid/received from</th></tr>";
$refnum = getrefnum();
/*refnum*/
# get ifo for each deposit
$tot = 0;
foreach ($bank as $key => $cashid) {
// Connect to database
db_Connect();
$sql = "SELECT * FROM cashbook WHERE cashid='{$cashid}'";
$cashRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve details from database.", SELF);
$numrows = pg_numrows($cashRslt);
# display all bank Deposits
for ($i = 0; $i < $numrows; $i++) {
$cash = pg_fetch_array($cashRslt, $i);
# Get account name for account involved
$accRslt = get("core", "accname", "accounts", "accid", $cash['accinv']);
$acc = pg_fetch_array($accRslt);
# get account name for bank account
db_connect();
$sql = "SELECT accname, bankname FROM bankacct WHERE bankid = '{$cash['bankid']}'";
$bankRslt = db_exec($sql);
$bank = pg_fetch_array($bankRslt);
$OUTPUT .= "<input type=hidden name=bank[] value='{$cashid}'><tr class='" . bg_class() . "'><td>{$bank['bankname']}</td><td align=center>{$bank['accname']}</td>\r\n <td align=center><input type=text size=2 name=day[] maxlength=2 value='" . date("d") . "'>-<input type=text size=2 name=mon[] maxlength=2 value='" . date("m") . "'>-<input type=text size=4 name=year[] maxlength=4 value='" . date("Y") . "'></td>\r\n <td align=center><input type=text size=7 name=refnum[] value='" . $refnum++ . "'></td><td align=center>{$cash['name']}</td><td align=center>{$cash['descript']}</td><td align=center>{$cash['trantype']}</td>\r\n <td align=right>" . CUR . " {$cash['amount']}</td><td align=center>{$acc['accname']}</td></tr>";
$tot = $cash['amount'];
}
}
$OUTPUT .= "<tr class='bg-even'><td colspan=7><b>Total Outstanding</b></td><td colspan=2><b>" . CUR . " {$tot}</b></td></tr>\r\n \t\t\t<tr><td colspan=8><br></td><td><input type=submit value='Confirm'></td></tr></form></table>";
return $OUTPUT;
}
示例10: confirm
function confirm($cashid)
{
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($cashid, "num", 1, 20, "Invalid Reference number.");
# 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;
}
$refnum = getrefnum();
/*refnum*/
// Connect to database
Db_Connect();
$sql = "SELECT * FROM cashbook WHERE cashid = '{$cashid}'";
$accntRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve cashbook entry details from database.", SELF);
$numrows = pg_numrows($accntRslt);
if ($numrows < 1) {
$OUTPUT = "<li clss='err'>The deposit with reference number, <b>{$cashid}</b> was not found in Cubit.</li>";
return $OUTPUT;
}
$accnt = pg_fetch_array($accntRslt);
$confirm = "\r\n \t\t\t\t<h3>Confirm Entry</h3>\r\n\t\t\t\t <table " . TMPL_tblDflts . ">\r\n\t\t\t\t <form action='" . SELF . "' method='POST'>\r\n\t\t\t\t\t <input type='hidden' name='key' value='bank'>\r\n\t\t\t\t\t <input type='hidden' name='cashid' value='{$accnt['cashid']}'>";
# get account name for the account involved
$AccRslt = get("core", "accname", "accounts", "accid", $accnt['accinv']);
$accinv = pg_fetch_array($AccRslt);
$AccRslt = get("cubit", "*", "bankacct", "bankid", $accnt['bankid']);
$bank = pg_fetch_array($AccRslt);
$confirm .= "\r\n\t\t\t\t\t <tr>\r\n\t\t\t\t\t \t<th>Field</th>\r\n\t\t\t\t\t \t<th>Value</th>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Bank Name</td>\r\n\t\t\t\t\t \t<td>{$bank['bankname']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Account Number</td>\r\n\t\t\t\t\t \t<td>{$bank['accnum']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Transaction Type</td>\r\n\t\t\t\t\t \t<td>{$accnt['trantype']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Date of Transaction</td>\r\n\t\t\t\t\t \t<td>{$accnt['date']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Paid to/Received from</td>\r\n\t\t\t\t\t \t<td>{$accnt['name']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Date</td>\r\n\t\t\t\t\t \t<td>\r\n\t\t\t\t\t \t\t<input type='text' size='2' name='day' maxlength='2'>-\r\n\t\t\t\t\t \t\t<input type='text' size='2' name='mon' maxlength='2' value='" . date("m") . "'>-\r\n\t\t\t\t\t \t\t<input type='text' size='4' name='year' maxlength='4' value='" . date("Y") . "'> DD-MM-YYYY\r\n\t\t\t\t\t \t</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Journal Reference No.</td>\r\n\t\t\t\t\t \t<td valign='center'><input type='text' size='7' name='refnum' value='{$refnum}'></td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Description</td>\r\n\t\t\t\t\t \t<td>{$accnt['descript']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Amount</td>\r\n\t\t\t\t\t \t<td>" . CUR . " {$accnt['amount']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr class='" . bg_class() . "'>\r\n\t\t\t\t\t \t<td>Transaction Contra Account</td>\r\n\t\t\t\t\t \t<td>{$accinv['accname']}</td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t\t <tr>\r\n\t\t\t\t\t \t<td align='right'><input type='button' value='« Back' onClick='javascript:history.back()'></td>\r\n\t\t\t\t\t \t<td align='right'><input type='submit' value='Bank Deposit Record »'></td>\r\n\t\t\t\t\t </tr>\r\n\t\t\t\t </form>\r\n\t\t\t\t </table>";
return $confirm;
}
示例11: details
function details($_GET)
{
# get vars
extract($_GET);
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
# 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 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);
# format date
$inv['odate'] = explode("-", $inv['odate']);
$inv['odate'] = $inv['odate'][2] . "-" . $inv['odate'][1] . "-" . $inv['odate'][0];
/* --- Start Products Display --- */
# Products layout
$products = "";
$disc = 0;
# get selected stock in this invoice
db_connect();
$sql = "SELECT * FROM nons_inv_items WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
# Put in product
while ($stk = pg_fetch_array($stkdRslt)) {
$Sl = "SELECT * FROM vatcodes WHERE id='{$stk['vatex']}'";
$Ri = db_exec($Sl);
$vd = pg_fetch_array($Ri);
if ($vd['zero'] == "Yes") {
$stk['vatex'] = "y";
}
if ($stk['vatex'] == 'y') {
$ex = "#";
} else {
$ex = " ";
}
$products .= "\r\n\t\t\t<tr valign='top'>\r\n\t\t\t\t<td style='border-right: 2px solid #000' nowrap>{$ex} {$stk['description']}</td>\r\n\t\t\t\t<td style='border-right: 2px solid #000' align='right'>{$stk['qty']}</td>\r\n\t\t\t\t<td style='border-right: 2px solid #000' align='right'>{$stk['unitcost']}</td>\r\n\t\t\t\t<td align='right'>" . CUR . " {$stk['amt']}</td>\r\n\t\t\t</tr>";
}
/* --- Start Some calculations --- */
# Subtotal
$SUBTOT = sprint($inv['subtot']);
$VAT = sprint($inv['vat']);
$TOTAL = sprint($inv['total']);
/* --- End Some calculations --- */
/* - Start Hooks - */
$vatacc = gethook("accnum", "salesacc", "name", "VAT");
/* - End Hooks - */
# todays date
$date = date("d-m-Y");
$sdate = date("Y-m-d");
$refnum = getrefnum();
/*refnum*/
/* --- Updates ---- */
db_connect();
# Get selected stock in this invoice
$sql = "SELECT * FROM nons_inv_items WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
/* -- Format the remarks boxlet -- */
// $inv["remarks"] = "<table border='1'><tr><td>Remarks:<br>$inv[remarks]</td></tr></table>";
if ($inv['chrgvat'] == "yes") {
$inv['chrgvat'] = "Inclusive";
} elseif ($inv['chrgvat'] == "no") {
$inv['chrgvat'] = "Exclusive";
} else {
$inv['chrgvat'] = "No vat";
}
$table_borders = "\r\n\t\tborder-top: 2px solid #000000;\r\n\t\tborder-left: 2px solid #000000;\r\n\t\tborder-right: 2px solid #000000;\r\n\t\tborder-bottom: none;";
/* -- Final Layout -- */
$details = "\r\n\t\t<center>\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table border='0' cellpadding='2' cellspacing='2' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align='left'><img src='compinfo/getimg.php' width='230' height='47'>{$barcode}</td>\r\n\t\t\t\t\t<td align='left'><font size='5'><b>" . COMP_NAME . "</b></font></td>\r\n\t\t\t\t\t<td align='right'><font size='5'><b>Quote</b></font></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td valign='top'>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'>" . COMP_ADDRESS . " </td>\r\n\t\t\t\t</tr>\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</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>REG:</b> " . COMP_REGNO . "</b> </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>VAT REG:</b> " . COMP_VATNO . " </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Tel:</b> " . COMP_TEL . " </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>Fax:</b> " . COMP_FAX . " </td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td><td valign='top'>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><b>Date</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>{$inv['odate']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000'> </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td colspan='2'><b>Quote No:</b> {$inv['invid']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t{$sp}\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td align='center'><font size='4'><b>Quote To:</b></font></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width='33%' style='border-right: 2px solid #000'><b>{$inv['cusname']}</b></td>\r\n\t\t\t\t\t<td width='33%'><b>Address</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000' valign='bottom'><b>Customer VAT No:</b> {$inv['cusvatno']}</td>\r\n\t\t\t\t\t<td>" . nl2br($inv["cusaddr"]) . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000'><b>VAT:</b> {$inv['chrgvat']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000;'><b>Description</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000;' align='right'><b>Qty</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000; border-right: 2px solid #000;' align='right'><b>Unit Price</b></td>\r\n\t\t\t\t\t<td style='border-bottom: 2px solid #000' align='right'><b>Amount</b></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t{$products}\r\n\t\t\t</table>\r\n\t\t\t</td></tr>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='{$table_borders}'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><i>VAT Exempt Indicator: #</i></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>{$inv['remarks']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>\r\n\t\t</table>\r\n\r\n\t\t<table cellpadding='0' cellspacing='0' width='85%' style='border: 2px solid #000000'>\r\n\t\t\t<tr><td>\r\n\t\t\t<table cellpadding='2' cellspacing='0' border='0' width='100%'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style='border-right: 2px solid #000' width='60%'> </td>\r\n\t\t\t\t\t<td><b>Subtotal:</b></td>\r\n\t\t\t\t\t<td align='right' nowrap><b>" . CUR . " {$inv['subtot']}</b></td>\r\n\t\t\t\t</tr>\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><b>VAT @ " . TAX_VAT . "%:</b></td>\r\n\t\t\t\t\t<td align='right' nowrap><b>" . CUR . " {$inv['vat']}</b></td>\r\n\t\t\t\t</tr>\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><b>Total Incl VAT:</b></td>\r\n\t\t\t\t\t<td align='right' nowrap><b>" . CUR . " {$inv['total']}</b></td>\r\n\t\t\t\t</tr>\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></td>\r\n\t\t\t\t\t<td nowrap></td>\r\n\t\t\t</table>\r\n\t\t</table>";
$OUTPUT = $details;
require "tmpl-print.php";
}
示例12: recvpayment_write
function recvpayment_write()
{
if (isset($_POST["btn_back"])) {
return details($_POST);
}
extract($_POST);
$v = new validate();
$v->isOk($cusnum, "num", 1, 10, "Invalid customer id.");
$v->isOk($bank_acc, "num", 1, 10, "Invalid cash account selected.");
$v->isOk($pcc, "float", 1, 40, "Invalid credit card amount.");
$v->isOk($pcash, "float", 1, 40, "Invalid cash amount.");
$v->isOk($pcheque, "float", 1, 40, "Invalid cheque amount.");
$v->isOk($amt, "float", 1, 40, "Invalid total received amount.");
$v->isOk($out, "float", 1, 40, "Invalid unallocated amount.");
$v->isOk($descript, "string", 1, 255, "Invalid description.");
$v->isOk($date, "date", 1, 1, "Invalid invoice date.");
if ($v->isError()) {
return details($_POST, $v->genErrors());
}
$sdate = $date;
$cus = qryCustomer($cusnum);
$dept = qryDepartment($cus["deptid"], "debtacc");
$refnum = getrefnum();
pglib_transaction("BEGIN");
/* do the calculations/recordings */
# update the customer (make balance less)
$sql = "UPDATE cubit.customers SET balance = (balance - '{$amt}'::numeric(13,2))\n\t\t\tWHERE cusnum = '{$cus['cusnum']}' AND div = '" . USER_DIV . "'";
$rslt = db_exec($sql) or errDie("Unable to update invoice in Cubit.", SELF);
if (isset($invids)) {
foreach ($invids as $key => $value) {
$ii = $invids[$key];
/* OPTION 1: STOCK INVOICES */
if (!isset($itype[$ii]) && !isset($ptype[$ii])) {
$sql = "SELECT prd,invnum,odate FROM cubit.invoices\n\t\t\t\t\t\tWHERE invid ='{$invids[$key]}' AND div = '" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice details from database.");
if (pg_numrows($invRslt) < 1) {
return "<li class=err>Invalid Invoice Number.";
}
$inv = pg_fetch_array($invRslt);
$inv['invnum'] += 0;
// reduce invoice balance
$sql = "UPDATE cubit.invoices\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$invids[$key]}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
$sql = "UPDATE cubit.open_stmnt\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$inv['invnum']}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
# record the payment on the statement
$sql = "\n\t\t\t\t\tINSERT INTO cubit.stmnt \n\t\t\t\t\t\t(cusnum, invid, amount, date, type, div, allocation_date) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$cus['cusnum']}','{$inv['invnum']}', '" . ($paidamt[$key] - $paidamt[$key] * 2) . "','{$sdate}', 'Payment for Invoice No. {$inv['invnum']}', '" . USER_DIV . "', '{$inv['odate']}')";
$stmntRslt = db_exec($sql) or errDie("Unable to insert statement record in Cubit.", SELF);
custledger($cus['cusnum'], $bank_acc, $sdate, $inv['invnum'], "Payment for Invoice No. {$inv['invnum']}", $paidamt[$key], "c");
$rinvids .= "|{$invids[$key]}";
$amounts .= "|{$paidamt[$key]}";
if ($inv['prd'] == "0") {
$inv['prd'] = PRD_DB;
}
$invprds .= "|{$inv['prd']}";
$rages .= "|0";
$invidsers .= " - {$inv['invnum']}";
/* OPTION 1: NONS STOCK INVOICES */
} else {
if (!isset($ptype[$ii])) {
$sql = "SELECT prd,invnum,descrip,age,odate FROM cubit.nons_invoices\n\t\t\t\t\t\tWHERE invid ='{$invids[$key]}' AND div = '" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice details from database.");
if (pg_numrows($invRslt) < 1) {
return "<li class=err>Invalid Invoice Number.";
}
$inv = pg_fetch_array($invRslt);
$inv['invnum'] += 0;
# reduce the money that has been paid
$sql = "UPDATE cubit.nons_invoices\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$invids[$key]}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
$sql = "UPDATE cubit.open_stmnt\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$inv['invnum']}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
# record the payment on the statement
$sql = "\n\t\t\t\t\tINSERT INTO cubit.stmnt \n\t\t\t\t\t\t(cusnum, invid, amount, date, type, div, allocation_date) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$cus['cusnum']}','{$inv['invnum']}', '" . ($paidamt[$key] - $paidamt[$key] * 2) . "','{$sdate}', 'Payment for Non Stock Invoice No. {$inv['invnum']} - {$inv['descrip']}', '" . USER_DIV . "', '{$inv['odate']}')";
$stmntRslt = db_exec($sql) or errDie("Unable to insert statement record in Cubit.", SELF);
custledger($cus['cusnum'], $bank_acc, $sdate, $inv['invnum'], "Payment for Non Stock Invoice No. {$inv['invnum']} - {$inv['descrip']}", $paidamt[$key], "c");
recordCT($paidamt[$key], $cus['cusnum'], $inv['age'], $sdate);
$rinvids .= "|{$invids[$key]}";
$amounts .= "|{$paidamt[$key]}";
$invprds .= "|0";
$rages .= "|{$inv['age']}";
$invidsers .= " - {$inv['invnum']}";
} else {
/* pos invoices */
$sql = "SELECT * FROM cubit.prd_pinvoices\n\t\t\t\t\t\tWHERE invid='{$invids[$key]}' AND div='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice details from database.");
if (pg_numrows($invRslt) < 1) {
return "<li class='err'>Invalid Invoice Number.</li>";
}
$inv = pg_fetch_array($invRslt);
// reduce the invoice balance
$sql = "UPDATE \"{$inv['iprd']}\".pinvoices\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$invids[$key]}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
$sql = "UPDATE cubit.open_stmnt\n\t\t\t\t\t\tSET balance = (balance - {$paidamt[$key]}::numeric(13,2))\n\t\t\t\t\t\tWHERE invid = '{$inv['invnum']}' AND div = '" . USER_DIV . "'";
$payRslt = db_exec($sql) or errDie("Unable to update Invoice information in Cubit.", SELF);
# record the payment on the statement
$sql = "\n\t\t\t\t\tINSERT INTO cubit.stmnt\n\t\t\t\t\t\t(cusnum, invid, amount, date, type, div, allocation_date) \n\t\t\t\t\tVALUES \n\t\t\t\t\t\t('{$cus['cusnum']}','{$inv['invnum']}', '" . ($paidamt[$key] - $paidamt[$key] * 2) . "','{$sdate}', 'Payment for Non Stock Invoice No. {$inv['invnum']}', '" . USER_DIV . "', '{$inv['odate']}')";
$stmntRslt = db_exec($sql) or errDie("Unable to insert statement record in Cubit.", SELF);
custledger($cus['cusnum'], $bank_acc, $sdate, $inv['invnum'], "Payment for Non Stock Invoice No. {$inv['invnum']}", $paidamt[$key], "c");
recordCT($paidamt[$key], $cus['cusnum'], 0, $sdate);
//.........这里部分代码省略.........
示例13: con_data
function con_data($_POST)
{
# get vars
extract($_POST);
if (isset($back)) {
return view_data($_POST);
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($id, "num", 0, 100, "Invalid number.");
$v->isOk($depamt, "float", 0, 14, "Invalid Depreciation Amount.");
$v->isOk($depmonths, "num", 0, 3, "Invalid auto depreciation period.");
$v->isOk("{$depmonths}{$depamt}", "float", 1, 14, "Enter one of Depreciation amount or period.");
if (!empty($depamt) && $netval < $depamt) {
$v->isOk("###", "float", 1, 1, "Error : Depreciation amount must not be more than the Net Value.");
} else {
if (!empty($depmonths) && $depperc <= 0) {
$v->addError("###", "Depriaction percentage has to be more than 0 if depreciating by period.");
}
}
$v->isOk($date, "date", 1, 14, "Invalid account open date.");
# display errors, if any
if ($v->isError()) {
$confirmCust = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirmCust .= "<li class=err>" . $e["msg"];
}
$confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirmCust;
}
db_conn('cubit');
$user = USER_NAME;
$Sql = "SELECT * FROM assets WHERE (id='{$id}' AND div = '" . USER_DIV . "')";
$Rslt = db_exec($Sql) or errDie("Unable to access database.");
if (pg_numrows($Rslt) < 1) {
return "Asset not Found";
}
$led = pg_fetch_array($Rslt);
# Get group
$sql = "SELECT * FROM assetgrp WHERE grpid = '{$led['grpid']}' AND div = '" . USER_DIV . "'";
$grpRslt = db_exec($sql);
$grp = pg_fetch_array($grpRslt);
# get last ref number
$refnum = getrefnum($date);
if ($led["dep_acc"]) {
$dep_acc = $led["dep_acc"];
} else {
// Maintain backwards compatibiltiy
$sql = "\r\n\t\tSELECT accid FROM core.accounts\r\n\t\tWHERE topacc='2200' AND accnum='000'";
$acc_rslt = db_exec($sql) or errDie("Unable to retrieve account.");
$dep_acc = pg_fetch_result($acc_rslt, 0);
}
if ($led["accdep_acc"]) {
$accdep_acc = $led["accdep_acc"];
} else {
// Maintain backwards compatibiltiy
$accdep_acc = $grp["accdacc"];
}
pglib_transaction("BEGIN");
# dt(depacc) ct(accdep)
writetrans($dep_acc, $accdep_acc, $date, $refnum, $depamt, "{$led['des']} Depreciation");
db_connect();
$sql = "UPDATE assets SET accdep = (accdep + '{$depamt}') WHERE (id='{$id}' AND div = '" . USER_DIV . "')";
$up = db_exec($sql) or errdie("Could not update assets table.");
$snetval = $netval - $depamt;
$sdate = date("Y-m-d");
$sql = "INSERT INTO assetledger(assetid, asset, date, depamt, netval, div) \r\n\t\t\tVALUES ('{$id}', '{$led['des']}', '{$date}', '{$depamt}', '{$snetval}', '" . USER_DIV . "')";
$rec = db_exec($sql) or errdie("Could not write to asset ledger.");
$cc = "<script> CostCenter('ct', 'Asset Depreciation', '{$date}', '{$led['des']} Depreciation', '{$depamt}', ''); </script>";
pglib_transaction("COMMIT");
$write = "\r\n\t\t\t\t{$cc}\r\n\t\t\t\t<table " . TMPL_tblDflts . " width='50%'>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>Asset Depreciation</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr class='datacell'>\r\n\t\t\t\t\t\t<td>Asset Depreciation has been recorded</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>\r\n\t\t\t\t<p>\r\n\t\t\t\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>Quick Links</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t<td><a href='asset-new.php'>New Asset</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t<td><a href='asset-view.php'>View Assets</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\r\n\t\t\t\t</table>";
return $write;
}
示例14: 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>";
//.........这里部分代码省略.........
示例15: det
function det($_POST)
{
# Get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
if (isset($ord)) {
foreach ($ord as $key => $value) {
$v->isOk($ord[$key], "num", 1, 50, "Invalid order No.");
}
} else {
return "<li> - No Credit Purchases Seleted. Please select at least one entry.";
}
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>" . $e["msg"];
}
$confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
$refnum = getrefnum();
/*refnum*/
# connect to core
core_Connect();
# account to be paid
$paid = "<select name='accpaid[]'>";
$sql = "SELECT * FROM accounts WHERE acctype ='B'";
$accRslt = db_exec($sql);
$numrows = pg_numrows($accRslt);
if (empty($numrows)) {
return "<li>There are no Income accounts yet in Cubit.";
} else {
while ($acc = pg_fetch_array($accRslt)) {
$paid .= "<option value='{$acc['accid']}'>{$acc['accname']}</option>";
}
}
$paid .= "</select>";
$pay = "";
# Debtors
foreach ($ord as $key => $value) {
db_connect();
# Get all the details
$sql = "SELECT * FROM credit_invoices WHERE ordnum = '{$ord[$key]}'";
$invRslt = db_exec($sql) or errDie("Unable to access database.");
if (pg_numrows($invRslt) < 1) {
return "<li class=err> - Invalid Invoice Number.";
}
$inv = pg_fetch_array($invRslt);
# Get debt invoice info
$sql = "SELECT amount,terms FROM debtors WHERE ordnum ='{$ord[$key]}'";
$dtRslt = db_exec($sql) or errDie("Unable to retrieve invoice details from database.");
if (pg_numrows($dtRslt) < 1) {
return "<li class=err>Invalid Invoice Number.";
}
$dt = pg_fetch_array($dtRslt);
foreach ($inv as $keys => $values) {
${$keys} = $values;
}
$pay .= "<tr class='bg-odd'>\r\n <td><input type=hidden size=20 name=ord[] value='{$ord[$key]}'>{$cusname}</td>\r\n <td align=center>{$orddate}</td>\r\n <td align=center>{$invdate}</td>\r\n <td align=center>" . CUR . " {$dt['amount']}</td>\r\n <td align=center>{$dt['terms']} days</td>\r\n <td align=center>" . CUR . " <input type=text name='paidamt[]' size=7></td>\r\n <td align=center>{$paid}</td>\r\n </tr>";
}
$det = "<center>\r\n <h3>Add Multiple Debtors Payments to batch file</h3>\r\n <form action='" . SELF . "' method=post>\r\n <input type=hidden name=key value=confirm>\r\n <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n <tr><th>Customer Name</th><th>Order Date</th><th>Invoice Date</th><th>Outstanding Amount</th><th>Terms</th><th>Amount Paid</th><th>Account Paid</th></tr>\r\n {$pay}\r\n <tr><td><br></td></tr>\r\n <tr><td align=right colspan=6><input type=button value='« Back' onClick='javascript:history.back()'></td><td align=right colspan=1><input type=submit value='Confirm Transactions »'></td></tr>\r\n </form></table>\r\n <table border=0 cellpadding='2' cellspacing='1' width=15%>\r\n <tr><th>Quick Links</th></tr>\r\n <tr bgcolor='#88BBFF'><td><a href='debtors-view.php'>View Debtors</a></td></tr>\r\n <script>document.write(getQuicklinkSpecial());</script>\r\n <tr bgcolor='#88BBFF'><td><a href='main.php'>Main Menu</a></td></tr>\r\n </table>";
return $det;
}