function printStk($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($fday, "num", 1, 2, "Invalid from Date day."); $v->isOk($fmon, "num", 1, 2, "Invalid from Date month."); $v->isOk($fyear, "num", 1, 4, "Invalid from Date Year."); $v->isOk($today, "num", 1, 2, "Invalid to Date day."); $v->isOk($tomon, "num", 1, 2, "Invalid to Date month."); $v->isOk($toyear, "num", 1, 4, "Invalid to Date Year."); # mix dates $fromdate = $fyear . "-" . $fmon . "-" . $fday; $todate = $toyear . "-" . $tomon . "-" . $today; if (!checkdate($fmon, $fday, $fyear)) { $v->isOk($fromdate, "num", 1, 1, "Invalid from date."); } if (!checkdate($tomon, $today, $toyear)) { $v->isOk($todate, "num", 1, 1, "Invalid to date."); } # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class=err>-" . $e["msg"] . "<br>"; } return $confirm; } # connect to database db_connect(); // Layout $report = "\n\t<h3>Non-Stock Sales Report</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n <tr><th>Invoice no.</th><th>Date</th><th>Vat</th><th>SubTotal</th><th>Total</th></tr>"; # Get all relevant records db_connect(); $sql = "SELECT * FROM salesrec WHERE edate >= '{$fromdate}' AND edate <= '{$todate}' AND typ = 'non' AND div = '" . USER_DIV . "'"; $recRslt = db_exec($sql) or errDie("Unable to access databse.", SELF); $i = 0; $tot = 0; $totvat = 0; $totexc = 0; while ($rec = pg_fetch_array($recRslt)) { # Calculate profit $tot += $rec['total']; $totvat += $rec['vat']; $excvat = sprint($rec['total'] - $rec['vat']); $totexc += $excvat; $report .= "<tr class='" . bg_class() . "'><td>{$rec['invnum']}</td><td>{$rec['edate']}</td><td>" . CUR . " {$rec['vat']}</td><td>" . CUR . " {$excvat}</td><td>" . CUR . " {$rec['total']}</td></tr>"; $i++; } $tot = sprint($tot); $totvat = sprint($totvat); $totexc = sprint($totexc); $report .= "<tr class='bg-even'><td colspan=2><b>Totals</b></td><td>" . CUR . " {$totvat}</td><td>" . CUR . " {$totexc}</td><td>" . CUR . " {$tot}</td></tr>\n\t</table>\n <p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\n <tr><td><br></td></tr>\n <tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='sales-reports.php'>Sales Reports</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>"; return $report; }
function writeType($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($type, "string", 1, 20, "Invalid report type."); # 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; } # connect to db db_connect(); # write to db $sql = "INSERT INTO report_types (type, div) VALUES ('{$type}', '" . USER_DIV . "')"; $typeRslt = db_exec($sql) or errDie("Unable to add report type to database."); if (pg_cmdtuples($typeRslt) < 1) { return "Unable to add report type to database."; } $writeType = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>Report type added to system</th></tr>\n<tr class=datacell><td>New report type has been successfully added to Cubit.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees")); return $writeType; }
function con_data($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 0, 100, "Invalid number."); # 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'); $Sql = "DELETE FROM cf WHERE id='{$id}' AND div = '" . USER_DIV . "'"; $Rslt = db_exec($Sql) or errDie("Unable to access database."); $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n\t<tr><th>Cash flow budget entry Removed</th></tr>\n\t<tr class=datacell><td>Entry has been deleted from the system.</td></tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='2' cellspacing='1'>\n\t<tr><th>Quick Links</th></tr>\n\t<tr class='bg-odd'><td><a href='cfe-add.php'>New cash flow budget entry</a></td></tr>\n\t<tr class='bg-odd'><td><a href='cfe-view.php'>View cash flow budget entries</a></td></tr>\n\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>"; return $write; }
function write($_POST) { # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($calloutpid, "num", 1, 50, "Invalid Call Out Person id."); # 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; } # connect to db db_conn("exten"); # write to db $sql = "DELETE FROM calloutpeople WHERE calloutpid = '{$calloutpid}' AND div = '" . USER_DIV . "'"; $calloutpRslt = db_exec($sql) or errDie("Unable to remove Sales Person from system.", SELF); if (pg_cmdtuples($calloutpRslt) < 1) { return "<li class=err>Unable to remove Call Out Person from database."; } $write = "\r\n\t\t\t<table border='0' cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t\t<tr><th>Call Out Person Removed</th></tr>\r\n\t\t\t\t<tr class=datacell><td>Call Out Person <b>{$calloutp}</b>, has been removed.</td></tr>\r\n\t\t\t</table>\r\n\t\t\t<p>\r\n\t\t\t<table border='0' cellpadding='2' cellspacing='1'>\r\n\t\t\t\t<tr><th>Quick Links</th></tr>\r\n\t\t\t\t<tr class='bg-odd'><td><a href='calloutp-view.php'>View Call Out Persons</a></td></tr>\r\n\t\t\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t\t\t</table>"; return $write; }
function write($_POST) { # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($calloutp, "string", 1, 255, "Invalid Call Out Person name."); $v->isOk($telno, "string", 1, 255, "Invalid Call Out Person Contact Number."); # 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; } # connect to db db_conn("exten"); # write to db $sql = "INSERT INTO calloutpeople(calloutp,telno,div) VALUES ('{$calloutp}','{$telno}','" . USER_DIV . "')"; $salespRslt = db_exec($sql) or errDie("Unable to add warehouse to system.", SELF); if (pg_cmdtuples($salespRslt) < 1) { return "<li class=err>Unable to add Call Out Person to database."; } $write = "\r\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t\t<tr><th>Call Out Person added to system</th></tr>\r\n\t\t\t<tr class=datacell><td>New Call Out Person <b>{$calloutp}</b>, has been successfully added to the system.</td></tr>\r\n\t\t</table>\r\n\t\t<p>\r\n\t\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t\t<tr><th>Quick Links</th></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='calloutp-view.php'>View Call Out People</a></td></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='../callout-new.php'>New Call Out Document</a></td></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t\t</table>"; return $write; }
function login($_POST) { global $_SESSION; extract($_POST); require_lib("validate"); $v = new validate(); $v->isOk($code, "string", 1, 5, "Invalid company name."); # Display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class='err'>" . $e["msg"] . "</li>"; } return slctcomp($confirm); } # Change code to lowercase $code = strtolower($code); if (!db_check("cubit_" . $code)) { return slctcomp("<li class='err'>Invalid Company. Select another company or<br />\n\t\t\tclick <a href='company-new.php?key=recover'>here</a> to see if Cubit can recover from this error.</li>"); } # Get Company Name db_conn("cubit"); $sql = "SELECT name FROM companies WHERE code = '{$code}'"; $compRslt = db_exec($sql) or errDie("Unable to access database.", SELF); if (pg_numrows($compRslt) < 1) { $comp['name'] = ""; } else { $comp = pg_fetch_array($compRslt); } $_SESSION["code"] = $code; $_SESSION["comp"] = $comp['name']; header("Location: doc-index.php"); }
function write($_POST) { # Get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # Validate input require_lib("validate"); $v = new validate(); $v->isOk($typeref, "string", 0, 255, "Invalid Document type code."); $v->isOk($typename, "string", 1, 255, "Invalid Document type name."); # 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; } # Connect to db db_conn("yr2"); # Write to db $sql = "INSERT INTO doctypes(typeref, typename, div) VALUES ('{$typeref}', '{$typename}', '" . USER_DIV . "')"; $catRslt = db_exec($sql) or errDie("Unable to add {$typename} to system.", SELF); if (pg_cmdtuples($catRslt) < 1) { return "<li class=err>Unable to add {$typename} to database."; } $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Document type added to system</th></tr>\r\n\t<tr class=datacell><td>New Document type <b>{$typename}</b>, has been successfully added to the system.</td></tr>\r\n\t</table>\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='doctype-view.php'>View Document types</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 $write; }
function banktrans($bankacc, $trantype, $date, $name, $details, $cheqnum, $amount, $accinv) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($bankacc, "num", 1, 50, "Invalid Bank Account number."); $v->isOk($trantype, "string", 1, 50, "Invalid Transaction type."); $v->isOk($date, "date", 1, 14, "Invalid Bank Transaction date."); $v->isOk($name, "string", 1, 50, "Invalid Name."); $v->isOk($details, "string", 0, 255, "Invalid Bank Transacton details."); $v->isOk($cheqnum, "num", 0, 50, "Invalid Bank Transacton cheque number."); $v->isOk($amount, "float", 1, 20, "Invalid Bank Transacton Amount."); $v->isOk($accinv, "num", 1, 20, "Invalid Bank Transaction account involved."); # display errors, if any if ($v->isError()) { $write = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $write .= "<li class=err>" . $e["msg"]; } $OUTPUT = $write . "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; require "../template.php"; } # date format $date = explode("-", $date); $date = $date[2] . "-" . $date[1] . "-" . $date[0]; # record the payment record db_connect(); $sql = "INSERT INTO cashbook(bankid, trantype, date, name, descript, cheqnum, amount, banked, accinv) VALUES ('{$bankacc}', '{$trantype}', '{$date}', '{$name}', '{$details}', '{$cheqnum}', '{$amount}', 'no', '{$accinv}')"; $Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF); }
function write($_POST) { # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($whid, "num", 1, 50, "Invalid Store id."); # 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 db_conn("exten"); # write to db $sql = "DELETE FROM warehouses WHERE whid = '{$whid}' AND div = '" . USER_DIV . "'"; $whRslt = db_exec($sql) or errDie("Unable to remove Store from system.", SELF); if (pg_cmdtuples($whRslt) < 1) { return "<li class='err'>Unable to remove Store from database.</li>"; } $write = "\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>Store Removed</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>Store <b>{$whname}</b>, has been removed.</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='whouse-view.php'>View Stores</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='../main.php'>Main Menu</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>"; return $write; }
function remAllow($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid allowance ID."); # 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; } # connect to db db_connect(); # delete from db $sql = "DELETE FROM allowances WHERE id='{$id}' AND div = '" . USER_DIV . "'"; $allowRslt = db_exec($sql) or errDie("Unable to delete allowance from database."); if (pg_cmdtuples($allowRslt) < 1) { return "Unable to delete allowance from database."; } $sql = "DELETE FROM empallow WHERE allowid='{$id}'"; $rslt = db_exec($sql) or errDie("Error deleting allowances assigned to employees."); $writeAllow = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>Allowance deleted</th></tr>\n<tr class=datacell><td>Allowance, {$id}, has been successfully deleted.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees")); return $writeAllow; }
function viewsaved($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($bankid, "num", 1, 30, "Invalid Bank Account."); $v->isOk($fday, "num", 1, 2, "Invalid Day for the 'From' date."); $v->isOk($fmonth, "num", 1, 2, "Invalid month for the 'From' date.."); $v->isOk($fyear, "num", 1, 4, "Invalid year for the 'From' date.."); $v->isOk($lday, "num", 1, 2, "Invalid Day for the 'To' date."); $v->isOk($lmonth, "num", 1, 2, "Invalid month for the 'To' date.."); $v->isOk($lyear, "num", 1, 4, "Invalid year for the 'To' date.."); # lets mix the date $from = sprintf("%02.2d", $fday) . "-" . sprintf("%02.2d", $fmonth) . "-" . $fyear; $to = sprintf("%02.2d", $lday) . "-" . sprintf("%02.2d", $lmonth) . "-" . $lyear; # 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; } # get bank details $bankRslt = get("cubit", "accname,bankname", "bankacct", "bankid", $bankid); $bank = pg_fetch_array($bankRslt); }
function bal($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid Cash Flow Statement number."); # display errors, if any if ($v->isError()) { $theseErrors = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $theseErrors .= "<li class=err>" . $e["msg"]; } $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $theseErrors; } # connect to core DB core_connect(); # get the Trial Balance $cf = new dbSelect("save_cashflow", "core", grp(m("cols", "output, date_trunc('day', gentime) as gentime"), m("where", "id='{$id}'"))); $cf->run(); if ($cf->num_rows() < 1) { return "<center><li> Invalid Cash Flow Statement Number.</li></center>"; } $stmnt = $cf->fetch_array(); $OUTPUT = base64_decode($stmnt['output']); if (isset($_GET["xls"])) { $cftime = preg_replace("/ 00:00.*/", "", $stmnt["gentime"]); require_lib("xls"); Stream("cashflow-{$cftime}", $OUTPUT); } else { require "../tmpl-print.php"; } }
function writeFringe() { global $_POST; extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($fringeben, "string", 1, 100, "Invalid fringe benefit name."); $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"]; } $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirmCust; } # connect to db db_connect(); # write to db $sql = "INSERT INTO fringebens(fringeben, type, div)\n\t\t\tVALUES ('{$fringeben}', '{$type}', '" . USER_DIV . "')"; $rslt = db_exec($sql) or errDie("Unable to add Fringe Benefit to database (DBE)."); if (pg_cmdtuples($rslt) < 1) { return "Unable to add Fringe Benefit to database (CNT)."; } $OUTPUT = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n\t<tr><th>Fringe Benefit added to system</th></tr>\n\t<tr class=datacell><td>New Fringe Benefit, {$fringeben}, 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 $OUTPUT; }
function inc($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid Income Statement number."); # display errors, if any if ($v->isError()) { $theseErrors = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $theseErrors .= "<li class=err>" . $e["msg"]; } $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $theseErrors; } # connect to core DB core_connect(); # get the income statement $sql = "SELECT * FROM save_income_stmnt WHERE id = '{$id}' AND div = '" . USER_DIV . "'"; $incRslt = db_exec($sql) or errDie("Unable to retrieve income statement from the Database", SELF); if (pg_numrows($incRslt) < 1) { return "<center><li> Invalid Income Statement Number."; } $inc = pg_fetch_array($incRslt); $income = base64_decode($inc['output']); $OUTPUT = $income; require "../tmpl-print.php"; }
function remDeduct($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "string", 1, 20, "Invalid reference number."); # 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; } # connect to db db_connect(); # delete from db $sql = "DELETE FROM salded WHERE id='{$id}' AND div = '" . USER_DIV . "'"; $salRslt = db_exec($sql) or errDie("Unable to delete salary deduction from database."); # delete from db $sql = "DELETE FROM empdeduct WHERE dedid='{$id}' AND div = '" . USER_DIV . "'"; $salRslt = db_exec($sql) or errDie("Unable to delete salary deduction from employee lists."); $writeDeduct = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>Salary deduction deleted</th></tr>\n<tr class=datacell><td>Salary deduction has been successfully deleted.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees")); return $writeDeduct; }
function write($_POST) { # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($min, "num", 1, 9, "Invalid minimum amount."); $v->isOk($max, "num", 1, 9, "Invalid maximum amount."); $v->isOk($percentage, "float", 1, 6, "Invalid interest percentage."); # 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; } # connect to db db_connect(); # add PAYE to db $sql = "INSERT INTO intbracs (min, max, percentage) VALUES ('{$min}', '{$max}', '{$percentage}')"; $pRslt = db_exec($sql) or errDie("Unable to add Interest bracket to database.", SELF); $write = "\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>Interest bracket added to database</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>New Interest bracket has been successfully added to Cubit.</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 bgcolor='#88BBFF'>\r\n\t\t\t\t\t\t<td><a href='intbrac-view.php'>View Interest Brackets</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr bgcolor='#88BBFF'>\r\n\t\t\t\t\t\t<td><a href='main.php'>Main Menu</a></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tr>"; return $write; }
function write() { extract($_REQUEST); require_lib("validate"); $v = new validate(); $v->isOk($invid, "num", 1, 20, "Invalid invoice selection."); if ($v->isError()) { return edit($v->genErrors()); } pglib_transaction("BEGIN"); $subtotal = 0; if (isset($unitprices) && is_array($unitprices)) { foreach ($unitprices as $id => $unitprice) { $sql = "SELECT qty FROM cubit.inv_items WHERE id='{$id}'"; $qty_rslt = db_exec($sql) or errDie("Unable to retrieve qty."); $qty = pg_fetch_result($qty_rslt, 0); $sql = "\n\t\t\tUPDATE cubit.inv_items SET unitcost='{$unitprice}'\n\t\t\tWHERE id='{$id}'"; db_exec($sql) or errDie("Unable to update unit cost."); $subtotal += $unitprice * $qty; } } $vat = $subtotal / 100 * 14; $total = $subtotal + $vat; $sql = "\n\tUPDATE cubit.invoices SET total='{$total}', subtot='{$subtotal}', vat='{$vat}'\n\tWHERE invid='{$invid}'"; db_exec($sql) or errDie("Unable to update invoice totals."); pglib_transaction("COMMIT"); return edit(); }
function printLea($_POST) { # get vars extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($f_day, "num", 1, 2, "Invalid from Date day."); $v->isOk($f_month, "num", 1, 2, "Invalid from Date month."); $v->isOk($f_year, "num", 1, 4, "Invalid from Date Year."); $v->isOk($to_day, "num", 1, 2, "Invalid to Date day."); $v->isOk($to_month, "num", 1, 2, "Invalid to Date month."); $v->isOk($to_year, "num", 1, 4, "Invalid to Date Year."); # mix dates $fromdate = $f_year . "-" . $f_month . "-" . $f_day; $todate = $to_year . "-" . $to_month . "-" . $to_day; $v->isOk($fromdate, "date", 1, 1, "Invalid from date."); $v->isOk($todate, "date", 1, 1, "Invalid to date."); if ($v->isError()) { $err = $v->genErrors(); return $err; } if (isset($empnum)) { $OUTPUT = genslip($empnum, $fromdate, $todate); } else { $OUTPUT = ""; $qry = new dbSelect("employees", "cubit", grp(m("cols", "empnum"), m("where", "div='" . USER_DIV . "'"))); $qry->run(); while ($row = $qry->fetch_array()) { $OUTPUT .= paged(genslip($row["empnum"], $fromdate, $todate)); } } require "../tmpl-print.php"; }
function bal($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid Trial Balance number."); # display errors, if any if ($v->isError()) { $theseErrors = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $theseErrors .= "<li class=err>" . $e["msg"]; } $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $theseErrors; } # connect to core DB core_connect(); # get the Trial Balance $sql = "SELECT * FROM save_trial_bal WHERE id = '{$id}' AND div = '" . USER_DIV . "'"; $balRslt = db_exec($sql) or errDie("Unable to retrieve Trial Balance from the Database", SELF); if (pg_numrows($balRslt) < 1) { return "<center><li> Invalid Trial Balance Number."; } $bal = pg_fetch_array($balRslt); $balance = base64_decode($bal['output']); $OUTPUT = $balance; include "temp.xls.php"; Stream("TB", $OUTPUT); }
function details($_GET) { # get vars foreach ($_GET as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($purid, "num", 1, 20, "Invalid Order number."); # display errors, if any if ($v->isError()) { $err = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $err .= "<li class=err>" . $e["msg"]; } $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } # Get Order info db_connect(); $sql = "SELECT * FROM nons_purch_int WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'"; $purRslt = db_exec($sql) or errDie("Unable to get Order information"); if (pg_numrows($purRslt) < 1) { return "<i class=err>Not Found</i>"; } $pur = pg_fetch_array($purRslt); # Currency $currs = getSymbol($pur['fcid']); $curr = $currs['symbol']; $currsel = "{$currs['symbol']} - {$currs['descrip']}"; /* --- Start Products Display --- */ # Products layout $products = "\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0 width=100%>\n\t<tr><th>ITEM NUMBER</th><th>DESCRIPTION</th><th>QTY</th><th colspan=2>UNIT PRICE</th><th colspan=2>DUTY</th><th>LINE TOTAL</th><tr>"; # get selected stock in this Order db_connect(); $sql = "SELECT * FROM nons_purint_items WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'"; $stkdRslt = db_exec($sql); while ($stkd = pg_fetch_array($stkdRslt)) { # put in product $products .= "<tr class='bg-odd'><td>{$stkd['cod']}</td><td>{$stkd['des']}</td><td>{$stkd['qty']}</td><td>{$pur['curr']} {$stkd['cunitcost']} or </td><td>" . CUR . " {$stkd['unitcost']}</td><td>{$pur['curr']} {$stkd['duty']} or </td><td>{$stkd['dutyp']}%</td><td>{$pur['curr']} {$stkd['amt']}</td></tr>"; } $products .= "</table>"; /* --- End Products Display --- */ /* --- Start Some calculations --- */ # Get subtotal $SUBTOT = sprint($pur['subtot']); # Get Total $TOTAL = sprint($pur['total']); # Get tax $tax = sprint($pur['tax']); /* --- End Some calculations --- */ # format date list($pyear, $pmon, $pday) = explode("-", $pur['pdate']); list($dyear, $dmon, $dday) = explode("-", $pur['ddate']); /* -- Final Layout -- */ $details = "<center><h3>International Non-Stock Order Details</h3>\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0 width=95%>\n\t<tr><td valign=top>\n\t\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0>\n\t\t\t<tr><th colspan=2> Supplier Details </th></tr>\n\t\t\t<tr class='bg-odd'><td>Supplier</td><td valign=center>{$pur['supplier']}</td></tr>\n\t\t\t<tr class='bg-even'><td>Supplier Address</td><td valign=center><pre>{$pur['supaddr']}</pre></td></tr>\n\t\t</table>\n\t</td><td valign=top align=right>\n\t\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0>\n\t\t\t<tr><th colspan=2> Non-Stock Order Details </th></tr>\n\t\t\t<tr class='bg-odd'><td>Non-Stock Order No.</td><td valign=center>{$pur['purnum']}</td></tr>\n\t\t\t<tr class='bg-even'><td>Order No.</td><td valign=center>{$pur['ordernum']}</td></tr>\n\t\t\t<tr class='bg-odd'><td>Terms</td><td valign=center>{$pur['terms']} Days</td></tr>\n\t\t\t<tr class='bg-even'><td>Date</td><td valign=center>{$pday}-{$pmon}-{$pyear}</td></tr>\n\t\t\t<tr class='bg-odd'><td>Foreign Currency</td><td valign=center>{$currsel} Exchange rate {$pur['curr']} {$pur['xrate']}</td></tr>\n\t\t\t<tr class='bg-even'><td>Tax</td><td valign=center>{$pur['curr']} {$pur['tax']}</td></tr>\n\t\t\t<tr class='bg-odd'><td>Shipping Charges</td><td valign=center>{$pur['curr']} {$pur['shipchrg']}</td></tr>\n\t\t\t<tr class='bg-even'><td>Delivery Date</td><td valign=center>{$dday}-{$dmon}-{$dyear}</td></tr>\n\t\t</table>\n\t</td></tr>\n\t<tr><td><br></td></tr>\n\t<tr><td colspan=2>\n\t{$products}\n\t</td></tr>\n\t<tr><td>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<tr><th width=40%>Quick Links</th><th width=45%>Remarks</th><td rowspan=5 valign=top width=15%><br></td></tr>\n\t\t\t<tr><td class='bg-odd'><a href='nons-purch-int-new.php'>New International Non-Stock Order</a></td><td class='bg-odd' rowspan=4 align=center valign=top>" . nl2br($pur['remarks']) . "</td></tr>\n\t\t\t<tr class='bg-odd'><td><a href='nons-purch-int-view.php'>View International Non-Stock Orders</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>\n\t</td><td align=right>\n\t\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0 width=80%>\n\t\t\t<tr class='bg-odd'><td>SUBTOTAL</td><td align=right>{$pur['curr']} {$pur['subtot']}</td></tr>\n\t\t\t<tr class='bg-even'><td>Delivery Charges</td><td align=right>{$pur['curr']} {$pur['shipping']}</td></tr>\n\t\t\t<tr class='bg-odd'><td>Tax </td><td align=right>{$pur['curr']} {$pur['tax']}</td></tr>\n\t\t\t<tr class='bg-even'><th>GRAND TOTAL</th><td align=right>{$pur['curr']} {$pur['total']}</td></tr>\n\t\t</table>\n\t</td></tr>\n\t</table></form>\n\t</center>"; return $details; }
function confirm($catid) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($catid, "num", 1, 50, "Invalid stock category id."); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class=err>-" . $e["msg"] . "<br>"; } return $confirm; } # Select Stock db_connect(); $sql = "SELECT * FROM stockcat WHERE catid = '{$catid}' AND div = '" . USER_DIV . "'"; $catRslt = db_exec($sql) or errDie("Unable to access databse.", SELF); if (pg_numrows($catRslt) < 1) { return "<li> Invalid Stock ID."; } else { $cat = pg_fetch_array($catRslt); } # get stock vars foreach ($cat as $key => $value) { ${$key} = $value; } // Layout $confirm = "<h3>Stock Category</h3>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<tr><th width=40%>Field</th><th width=60%>Value</th></tr>\n\t\t\t<tr class='bg-odd'><td>Category Code</td><td>{$catcod}</td></tr>\n\t\t\t<tr class='bg-even'><td>Category Name</td></td><td>{$cat}</td></tr>\n\t\t\t<tr class='bg-odd'><td valign=top>Description</td><td><pre>{$descript}</pre></td></tr>\n\t\t</table>\n\t\t<p>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=100>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<tr class='bg-odd'><td><a href='stockcat-edit.php?catid={$catid}'>Edit</a></td></tr>\n\t\t\t<tr class='bg-even'><td><a href='stockcat-view.php'>View Stock Category</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>"; return $confirm; }
function write($_POST) { # Get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # Validate input require_lib("validate"); $v = new validate(); $v->isOk($typeid, "string", 1, 20, "Invalid document type number."); # 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; } $doctRs = get("yr2", "*", "doctypes", "typeid", $typeid); $doct = pg_feTch_array($doctRs); # Write to db db_conn("yr2"); $sql = "DELETE FROM doctypes WHERE typeid = '{$typeid}'"; $dRslt = db_exec($sql) or errDie("Unable to remove {$doct['typename']} to system.", SELF); $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Document type removed</th></tr>\r\n\t<tr class=datacell><td>Document type <b>{$doct['typename']}</b>, has been successfully removed from the system.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='doctype-view.php'>View Document types</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>"; return $write; }
function write($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($classname, "string", 1, 255, "Invalid Classification name."); $v->isOk($clasid, "num", 1, 50, "Invalid Classification id."); # 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; } # connect to db db_connect(); # write to db $sql = "DELETE FROM stockclass WHERE clasid = '{$clasid}' AND div = '" . USER_DIV . "'"; $clasRslt = db_exec($sql) or errDie("Unable to remove classification from system.", SELF); if (pg_cmdtuples($clasRslt) < 1) { return "<li class=err>Unable to remove classification."; } $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Classification Removed</th></tr>\r\n\t<tr class=datacell><td>Classification <b> ({$classcode}) {$classname}</b>, has been removed from Cubit.</td></tr>\r\n\t</table>\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='stockclass-view.php'>View Classifications</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 $write; }
function choose_step() { global $_GET; extract($_GET); if (isset($id)) { require_lib("validate"); $v =& new Validate(); if (!$v->isOk($id, "num", 1, 9, "")) { return "<li class=err>Invalid site entry id</li>"; } } $step = 1; switch ($step) { case "0": if (!isset($msg)) { $msg = ""; } $OUTPUT = "{$msg}"; break; case "1": $OUTPUT = "<script>document.location.href='" . urler(PURCHASE_URL . "?" . sendhash()) . "';</script>"; break; } return $OUTPUT; }
function con_data($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } //confirm inserted data # validate input require_lib("validate"); $v = new validate(); # Limit field lengths as per database settings $v->isOk($grpname, "string", 0, 15, "Invalid group name."); $v->isOk($unit, "string", 1, 15, "Invalid group unit."); # display errors, if any if ($v->isError()) { $theseErrors = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $theseErrors .= "<li class=err>" . $e["msg"] . "</li>"; } $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='« Correct submission'>"; return $theseErrors; } $con_data = "<h3>Confirm Group Details</h3>\r\n\t\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t\t<form action='" . SELF . "' method=post>\r\n\t\t<input type=hidden name=key value='write'>\r\n\t\t<input type=hidden name=grpname value='{$grpname}'>\r\n\t\t<input type=hidden name=unit value='{$unit}'>\r\n\t\t<input type=hidden name=id value='{$id}'>\r\n\t\t\r\n\t\t<tr><th colspan=2>Group Details</th></tr>\r\n\t\t<tr class='bg-odd'><td>Group Name</td><td align=center>{$grpname}</td></tr>\r\n\t\t<tr class='bg-odd'><td>Document type</td><td align=center>{$unit}</td></tr>\r\n\t\t<tr><td colspan=2 align=left><input type=submit value='Write »'></td></tr>\r\n\t</form>\r\n\t</table>"; return $con_data; }
function choose_step() { global $_GET; extract($_GET); if (isset($id)) { require_lib("validate"); $v =& new Validate(); if (!$v->isOk($id, "num", 1, 9, "")) { return "<li class=err>Invalid site entry id</li>"; } } $step = 1; switch ($step) { case "0": if (!isset($msg)) { $msg = ""; } $OUTPUT = "{$msg}"; break; case "1": $request = @file(urler(REPORTS_URL . "?" . sendhash())); if ($request == false) { $site_msg = "<li class=err>Connection to server failed. Check you internet connection and try again.</li>"; return $site_msg; } $OUTPUT = implode("", $request); break; } return $OUTPUT; }
function write_details($_POST) { extract($_POST); # validate input require_lib("validate"); $v = new validate(); $v->isOk($branch_ip, "url", 1, 50, "Invalid Branch IP."); $v->isOk($branch_company, "url", 4, 4, "Invalid Branch Company Code."); $v->isOk($branch_username, "string", 1, 50, "Invalid Branch Username."); // $v->isOk ($branch_password, "url", 1, 50, "Invalid Branch Password."); // $v->isOk ($branch_passwordconfirm, "url", 1, 50, "Invalid Branch Password."); // $v->isOk ($branch_ip, "url", 1, 50, "Invalid Branch IP."); if ($branch_password != $branch_passwordconfirm) { $v->addError($branch_password, "Passwords do not match."); } # display errors, if any if ($v->isError()) { $confirmCust = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirmCust .= "<li class='err'>" . $e["msg"] . "</li>"; } return get_details($_POST, $confirmCust); } db_connect(); $add_sql = "\n\t\tINSERT INTO branches_data (\n\t\t\tbranch_name, branch_desc, branch_contact, branch_ip, \n\t\t\tdate_added, last_online, branch_username, branch_password, \n\t\t\tlast_login_from, branch_localuser, branch_company\n\t\t) VALUES (\n\t\t\t'{$branch_name}', '{$branch_desc}', '{$branch_contact}', '{$branch_ip}', \n\t\t\t'now', '1990-01-01', '{$branch_username}', md5('{$branch_password}'), \n\t\t\t'1990-01-01', '{$branch_localuser}', '{$branch_company}'\n\t\t)"; $run_add = pg_exec($add_sql) or errDie("Unable to add branch information."); $display = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Branch Added</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>Branch Has Been Added.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t"; return $display; }
function show_xls($_POST) { $OUT = show_report($_POST); $OUT = clean_html($OUT); require_lib("xls"); StreamXLS("Leave", $OUT); }
function remPaye($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid PAYE ID."); # 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; } # connect to db db_connect(); # remove job $sql = "DELETE FROM paye WHERE id='{$id}'"; $payeRslt = db_exec($sql) or errDie("Unable to remove PAYE bracket.", SELF); if (pg_cmdtuples($payeRslt) < 1) { return "Failed to delete PAYE bracket."; } $remPaye = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>PAYE bracket removed</th></tr>\n<tr class=datacell><td>PAYE bracket has been successfully removed.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees")); return $remPaye; }
function write($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($cusnum, "num", 1, 10, "Invalid Customer Number."); $v->isOk($editid, "num", 1, 10, "Invalid Customer ID."); # 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"); $insert_sql = "DELETE FROM customer_branches WHERE cusnum = '{$cusnum}' AND div = '" . USER_DIV . "' AND id = '{$editid}'"; $run_insert = db_exec($insert_sql); return "<script>\n\t\t\twindow.close ();\n\t\t</script>"; }