function AssetLedg() { # Set up table to display in $Assets = "\r\n\t<h3>Asset Ledger</h3>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<tr><th>Group</th><th>Serial</th><th>Location</th><th>Description</th><th>Date Bought</th><th>Date Added</th><th>Cost Amount</th><th>Net Value</th></tr>"; db_connect(); $i = 0; $tot = 0; $totnet = 0; $Sl = "SELECT * FROM assets WHERE div = '" . USER_DIV . "' ORDER BY serial"; $Rs = db_exec($Sl) or errDie("Unable to retrieve Asset Ledger from database."); if (pg_numrows($Rs) < 1) { return "<li>There are no Assets recorded on Cubit."; } while ($Led = pg_fetch_array($Rs)) { $netval = sprint($Led['amount'] - $Led['accdep']); $Led['amount'] = sprint($Led['amount']); # Get group db_connect(); $sql = "SELECT * FROM assetgrp WHERE grpid = '{$Led['grpid']}' AND div = '" . USER_DIV . "'"; $grpRslt = db_exec($sql); $grp = pg_fetch_array($grpRslt); $tot = $tot + $Led['amount']; $totnet = $totnet + $netval; $Assets .= "<tr><td>{$grp['grpname']}</td><td>{$Led['serial']}</td><td>{$Led['locat']}</td><td>{$Led['des']}</td><td>{$Led['bdate']}</td><td>{$Led['date']}</td><td align=right>" . CUR . " {$Led['amount']}</td><td align=right>" . CUR . " {$netval}</td></tr>"; $i++; } $tot = sprint($tot); $totnet = sprint($totnet); $Assets .= "<tr><td colspan=6>Total Assets: {$i} </td><td align=right>" . CUR . " {$tot}</td><td align=right>" . CUR . " {$totnet}</td></tr>"; $Assets .= "</table>"; include "temp.xls.php"; Stream("Assets", $Assets); return $Assets; }
function display() { extract($_REQUEST); $fields = array(); $fields["search"] = ""; extract($fields, EXTR_SKIP); $sql = "SELECT supno, supname, suppliers.balance AS sup_balance,\n\t\t\t\trecon_creditor_balances.balance AS recon_balance,\n\t\t\t\t(SELECT sum(amount) FROM cubit.recon_balance_ct \n\t\t\t\tWHERE supid=suppliers.supid) AS reason_total\n\t\t\tFROM cubit.suppliers\n\t\t\t\tLEFT JOIN cubit.recon_creditor_balances\n\t\t\t\t\tON suppliers.supid=recon_creditor_balances.supid\n\t\t\tWHERE supno ILIKE '{$search}%' OR supname ILIKE '{$search}%'\n\t\t\tORDER BY supno ASC"; $ct_rslt = db_exec($sql) or errDie("Unable to retrieve suppliers."); $ct_out = ""; while ($ct_data = pg_fetch_array($ct_rslt)) { if ($ct_data["recon_balance"] > $ct_data["reason_total"]) { $variance = $ct_data["reason_total"] - $ct_data["recon_balance"]; } else { $variance = $ct_data["recon_balance"] - $ct_data["reason_total"]; } if ($variance == 0) { continue; } $ct_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$ct_data['supno']}</td>\n\t\t\t<td>{$ct_data['supname']}</td>\n\t\t\t<td>{$ct_data['reason_total']}</td>\n\t\t\t<td>{$ct_data['recon_balance']}</td>\n\t\t\t<td>" . sprint($variance) . "</td>\n\t\t</tr>"; } if (empty($ct_out)) { $ct_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='6'><li>No results found</li></td>\n\t\t</tr>"; } $OUTPUT = "\n\t<h3>Creditor Reason Recon Variance Report</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='2'>Search</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td><input type='text' name='search' value='{$search}' /></td>\n\t\t\t<td><input type='submit' value='Search' /></td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Supplier No.</th>\n\t\t\t<th>Supplier Name</th>\n\t\t\t<th>Reason Total</th>\n\t\t\t<th>Balance According to Creditor</th>\n\t\t\t<th>Variance</th>\n\t\t</tr>\n\t\t{$ct_out}\n\t</table>"; return $OUTPUT; }
function display() { extract($_REQUEST); $fields = array(); $fields["search"] = ""; extract($fields, EXTR_SKIP); if (is_numeric($search)) { $invnum_w = "OR invnum='{$search}'"; } else { $invnum_w = ""; } $sql = "SELECT invid, invnum, cusname, total, hire_invid, accepted, hire_invnum\r\n\t\t\tFROM cubit.nons_invoices\r\n\t\t\tWHERE done='y' AND hire_invid>0 AND cusname ILIKE '%{$search}%' {$invnum_w}"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve hire invoices."); $inv_out = ""; while ($inv_data = pg_fetch_array($inv_rslt)) { if ($inv_data["accepted"] != "note") { $cnote = "\r\n\t\t\t<td>\r\n\t\t\t\t<a href='hire-invoice-note.php?invid={$inv_data['invid']}'>\r\n\t\t\t\t\tCredit Note\r\n\t\t\t\t</a>\r\n\t\t\t</td>"; } else { $cnote = "<td> </td>"; } $inv_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t<td>\r\n\t\t\t\t<a href='javascript:printer(\"hire/hire_note_reprint.php?invid={$inv_data['hire_invid']}\")'>\r\n\t\t\t\t\tH{$inv_data['hire_invnum']}\r\n\t\t\t\t</a>\r\n\t\t\t</td>\r\n\t\t\t<td>{$inv_data['invnum']}</td>\r\n\t\t\t<td>{$inv_data['cusname']}</td>\r\n\t\t\t<td>" . CUR . sprint($inv_data["total"]) . "</td>\r\n\t\t\t<td><a href='javascript:popupOpen(\"nons-invoice-reprint.php?invid={$inv_data['invid']}\")'>Reprint</a></td>\r\n\t\t\t{$cnote}\r\n\t\t</tr>"; } if (empty($inv_out)) { $inv_out = "<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='5'><li>Please enter customer name or hire no.</li></td>\r\n\t\t</tr>"; } $OUTPUT = "<h3>View Hire Invoices</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th colspan='2'>Enter Hire No or Customer Name</th>\r\n\t\t</tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td><input type='text' name='search' value='{$search}' /></td>\r\n\t\t\t<td><input type='submit' value='Search' style='width: 100%' /></td>\r\n\t\t</tr>\r\n\t</table>\r\n\t</form>\r\n\t<p></p>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th>Hire No</th>\r\n\t\t\t<th>Invoice No</th>\r\n\t\t\t<th>Customer</th>\r\n\t\t\t<th>Total</th>\r\n\t\t\t<th colspan='2'>Options</th>\r\n\t\t</tr>\r\n\t\t{$inv_out}\r\n\t</table>"; return $OUTPUT; }
function confirm() { extract($_REQUEST); $sql = "DROP TABLE cubit.import_assets"; db_exec($sql); $sql = "CREATE TABLE cubit.import_assets (\r\n\t\t\t\tid serial,\r\n\t\t\t\tserial varchar,\r\n\t\t\t\tlocat varchar,\r\n\t\t\t\tdes varchar,\r\n\t\t\t\tdate date,\r\n\t\t\t\tbdate date,\r\n\t\t\t\tamount numeric default 0,\r\n\t\t\t\tdiv numeric default 2,\r\n\t\t\t\tgrpid numeric default 0,\r\n\t\t\t\taccdep numeric default 0,\r\n\t\t\t\tdep_perc numeric default 0,\r\n\t\t\t\tdep_month varchar,\r\n\t\t\t\tserial2 varchar,\r\n\t\t\t\tteam_id numeric default 0,\r\n\t\t\t\tpuramt numeric default 0,\r\n\t\t\t\tconacc numeric default 0,\r\n\t\t\t\tsaledate date,\r\n\t\t\t\tsaleamt numeric default 0,\r\n\t\t\t\tinvid numeric default 0,\r\n\t\t\t\tautodepr_date date,\r\n\t\t\t\tsdate date,\r\n\t\t\t\ttemp_asset varchar default 'n',\r\n\t\t\t\tnonserial varchar,\r\n\t\t\t\ttype_id numeric default 0,\r\n\t\t\t\tsplit_from numeric default 1,\r\n\t\t\t\tdays numeric default 0,\r\n\t\t\t\ton_hand numeric default 0,\r\n\t\t\t\tsvdate date,\r\n\t\t\t\tprice numeric(16,2) default 0,\r\n\t\t\t\tper_day numeric(16,2) default 0,\r\n\t\t\t\tper_hour numeric(16,2) default 0,\r\n\t\t\t\tper_week numeric(16,2) default 0\r\n\t\t\t)"; @db_exec($sql); $sql = "DELETE FROM import_assets"; db_exec($sql) or errDie("Unable to clear import table."); $lines = file($_FILES["filename"]["tmp_name"]); $counter = 0; $items_out = ""; foreach ($lines as $line) { $line_arr = explode("|", trim($line)); $sql = "\r\n\t\t\tINSERT INTO import_assets (\r\n\t\t\t\tserial, locat, des, date, bdate, \r\n\t\t\t\tamount, div, grpid, accdep, dep_perc, dep_month, \r\n\t\t\t\tserial2, team_id, puramt, conacc, saledate, saleamt, \r\n\t\t\t\tinvid, autodepr_date, sdate, temp_asset, nonserial, type_id, \r\n\t\t\t\tsplit_from, days, on_hand, svdate, price, per_day, \r\n\t\t\t\tper_hour, per_week\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$line_arr['1']}', '', '{$line_arr['2']}', '{$line_arr['38']}', '{$line_arr['32']}', \r\n\t\t\t\t'{$line_arr['30']}', '2', '4', '0', '{$line_arr['41']}', 'no', \r\n\t\t\t\t'{$line_arr['36']}', '0', '{$line_arr['30']}', '0', 'now', '0.00', \r\n\t\t\t\t'0', 'now', 'now', 'n', '0', '0', \r\n\t\t\t\t'1', '0', '0', 'now', '{$line_arr['9']}', '{$line_arr['9']}', \r\n\t\t\t\t'{$line_arr['13']}', '{$line_arr['11']}'\r\n\t\t\t)"; db_exec($sql) or errDie("Unable to add asset {$line_arr['1']} {$line_arr['2']}."); $line_id = pglib_lastid("cubit.import_assets", "id"); // Convert the date from YYYYMMDD to YYYY-MM-DD if (strlen($line_arr[32]) == 8 && !preg_match("/\\-/", $line_arr["32"])) { $line_arr[32] = substr($line_arr['32'], 0, 4) . "-" . substr($line_arr['32'], 4, 2) . "-" . substr($line_arr['32'], 6, 2); } if (strlen($line_arr[38]) == 8 && !preg_match("/\\-/", $line_arr["32"])) { $line_arr[38] = substr($line_arr['38'], 0, 4) . "-" . substr($line_arr['38'], 4, 2) . "-" . substr($line_arr['38'], 6, 2); } if (empty($line_arr[1])) { $line_arr[36] = $line_arr[6]; } $items_out .= "\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td><input type='hidden' name='serial[]' value='{$line_arr['1']}' />{$line_arr['1']}</td>\r\n\t\t\t\t<td><input type='hidden' name='locat[]' value='' /></td>\r\n\t\t\t\t<td><input type='hidden' name='des' value='{$line_arr['2']}' />{$line_arr['2']}</td>\r\n\t\t\t\t<td><input type='hidden' name='date' value='{$line_arr['38']}' />{$line_arr['38']}</td>\r\n\t\t\t\t<td><input type='hidden' name='bdate' value='{$line_arr['32']}' />{$line_arr['32']}</td>\r\n\t\t\t\t<td align='right'><input type='hidden' name='puramt' value='{$line_arr['30']}' />" . sprint($line_arr[30]) . "</td>\r\n\t\t\t\t<td align='right'><input type='text' name='per_hour[{$line_id}]' value='" . sprint($line_arr[13]) . "' size='5' /></td>\r\n\t\t\t\t<td align='right'><input type='text' name='per_day[{$line_id}]' value='" . sprint($line_arr[9]) . "' size='5' /></td>\r\n\t\t\t\t<td align='right'><input type='text' name='per_week[{$line_id}]' value='" . sprint($line_arr[11]) . "' size='5' /></td>\r\n\t\t\t</tr>"; } $OUTPUT = "\r\n\t\t<center>\r\n\t\t<h3>Import Assets</h3>\r\n\t\t<form method='POST' action='" . SELF . "'>\r\n\t\t\t<input type='hidden' name='key' value='write' />\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Serial</th>\r\n\t\t\t\t<th>Location</th>\r\n\t\t\t\t<th>Description</th>\r\n\t\t\t\t<th>Date Received/Purchased</th>\r\n\t\t\t\t<th>Date Added</th>\r\n\t\t\t\t<th>Cost Amount</th>\r\n\t\t\t\t<th>Per Hour</th>\r\n\t\t\t\t<th>Per Day</th>\r\n\t\t\t\t<th>Per Week</th>\r\n\t\t\t</tr>\r\n\t\t\t{$items_out}\r\n\t\t</table>\r\n\t\t\t<input type='submit' value='Write »' />\r\n\t\t</form>\r\n\t\t</center>"; return $OUTPUT; }
function display($msg = "") { extract($_REQUEST); $fields = array(); $fields["search"] = ""; extract($fields, EXTR_SKIP); $sql = "SELECT assets.id, des, locat, per_day, per_hour, per_week, serial\r\n\t\t\t\tFROM cubit.assets\r\n\t\t\t\t\tLEFT JOIN hire.basis_prices\r\n\t\t\t\t\t\tON assets.id = basis_prices.assetid\r\n\t\t\t\tWHERE remaction IS NULL AND (assets.id ILIKE '{$search}%' OR\r\n\t\t\t\t\tdes ILIKE '{$search}%' OR locat ILIKE '{$search}%' OR\r\n\t\t\t\t\tper_day ILIKE '%{$search}%' OR per_hour ILIKE '%{$search}%' OR\r\n\t\t\t\t\tper_week ILIKE '%{$search}%' OR serial ILIKE '{$search}%')\r\n\t\t\t\tORDER BY des ASC"; $asset_rslt = db_exec($sql); $basis_out = ""; while ($asset_data = pg_fetch_array($asset_rslt)) { if (empty($asset_data["per_hour"])) { $asset_data["per_hour"] = "0.00"; } if (empty($asset_data["per_day"])) { $asset_data["per_day"] = "0.00"; } if (empty($asset_data["per_week"])) { $asset_data["per_week"] = "0.00"; } $basis_out .= "\r\n\t\t<input type='hidden' name='asset[]' value='{$asset_data['id']}' />\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>{$asset_data['des']}</td>\r\n\t\t\t<td>{$asset_data['serial']}</td>\r\n\t\t\t<td>{$asset_data['locat']}</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . CUR . "\r\n\t\t\t\t<input type='text' name='hour[{$asset_data['id']}]'\r\n\t\t\t\tvalue='" . sprint($asset_data["per_hour"]) . "' size='5'\r\n\t\t\t\tstyle='text-align: right' />\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . CUR . "\r\n\t\t\t\t<input type='text' name='day[{$asset_data['id']}]'\r\n\t\t\t\tvalue='" . sprint($asset_data["per_day"]) . "' size='5'\r\n\t\t\t\tstyle='text-align: right' />\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t\t" . CUR . "\r\n\t\t\t\t<input type='text' name='week[{$asset_data['id']}]'\r\n\t\t\t\tvalue='" . sprint($asset_data["per_week"]) . "' size='5'\r\n\t\t\t\tstyle='text-align: right' />\r\n\t\t\t</td>\r\n\t\t</tr>"; } if (empty($basis_out)) { $basis_out = "\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='6'><li>No results found.</li></td>\r\n\t\t</tr>"; } $OUTPUT = "<center>\r\n\t<h3>Default Basis Prices</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th colspan='2'>Search</th>\r\n\t\t</tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td><input type='text' name='search' value='{$search}' /></td>\r\n\t\t\t<td><input type='submit' value='Search' /></td>\r\n\t\t</tr>\r\n\t</table>\r\n\t</form>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<input type='hidden' name='key' value='save' />\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t{$msg}\r\n\t\t<tr>\r\n\t\t\t<th>Plant</th>\r\n\t\t\t<th>Serial</th>\r\n\t\t\t<th>Location</th>\r\n\t\t\t<th>Hour</th>\r\n\t\t\t<th>Day</th>\r\n\t\t\t<th>Week</th>\r\n\t\t</tr>\r\n\t\t{$basis_out}\r\n\t\t<tr>\r\n\t\t\t<td colspan='6' align='center'>\r\n\t\t\t\t<input type='submit' value='Set Basis »'\r\n\t\t\t\tstyle='font-weight: bold' />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t</form>"; return $OUTPUT; }
function adjust_display() { extract($_REQUEST); $fields = array(); $fields["page"] = 1; extract($fields, EXTR_SKIP); $sql = "SELECT stock.stkid, bar, stkcod, stkdes, catname, csprice,\n\t\t\t\t(qty-units) AS adjust_qty\n\t\t\tFROM cubit.stock_take\n\t\t\t\tLEFT JOIN cubit.stock ON stock.stkid=stock_take.stkid\n\t\t\tWHERE adjusted='0' AND page='{$page}'\n\t\t\tORDER BY stkcod ASC"; $adjust_rslt = db_exec($sql) or errDie("Unable to retrieve adjustments."); $adjust_out = ""; while ($adjust_data = pg_fetch_array($adjust_rslt)) { if ($adjust_data["adjust_qty"] == 0) { continue; } $value = $adjust_data["csprice"] * $adjust_data["adjust_qty"]; $adjust_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$adjust_data['bar']}</td>\n\t\t\t<td>{$adjust_data['catname']}</td>\n\t\t\t<td>{$adjust_data['stkcod']}</td>\n\t\t\t<td>{$adjust_data['stkdes']}</td>\n\t\t\t<td align='center'>" . sprint3($adjust_data['adjust_qty']) . "</td>\n\t\t\t<td align='right'>" . sprint($value) . "</th>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='adjust_qty[{$adjust_data['stkid']}]'\n\t\t\t\tvalue='{$adjust_data['adjust_qty']}' />\n\t\t\t\t<input type='submit' name='update[{$adjust_data['stkid']}]'\n\t\t\t\tvalue='Adjust' />\n\t\t\t</td>\n\t\t</tr>"; } if (empty($adjust_out)) { $adjust_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='7'>\n\t\t\t\t<li>No results found for this page.</li>\n\t\t\t</td>\n\t\t</tr>"; } $sql = "SELECT max(page) FROM cubit.stock_take"; $mp_rslt = db_exec($sql) or errDie("Unable to retrieve total pages."); $max_page = pg_fetch_result($mp_rslt, 0); if ($page < $max_page) { $adjust_btn = "\n\t\t\t<a href='" . SELF . "?key=adjust_display&page=" . ($page + 1) . "'>\n\t\t\t\tNext »\n\t\t\t</a>"; } else { $adjust_btn = ""; } $OUTPUT = "\n\t<center>\n\t<h3>Stock Take - Adjustments</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='2'>Page</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='page' value='{$page}' size='3'\n\t\t\t\tstyle='font-weight: bold; text-align: center' />\n\t\t\t</td>\n\t\t\t<td><input type='submit' value='OK' /></td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<form method='post' action='" . SELF . "'>\n\t<input type='hidden' name='key' value='adjust_update' />\n\t<input type='hidden' name='page' value='{$page}' />\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Barcode</th>\n\t\t\t<th>Category</th>\n\t\t\t<th>Stock Code</th>\n\t\t\t<th>Stock Description</th>\n\t\t\t<th>Adjustment</th>\n\t\t\t<th>Value</th>\n\t\t\t<th> </th>\n\t\t</tr>\n\t\t{$adjust_out}\n\t</table>\n\t<input type='submit' name='button[page_complete]' value='Adjust Page' />\n\t<br />\n\t{$adjust_btn}\n\t</center>"; return $OUTPUT; }
function display() { extract($_REQUEST); $fields = array(); $fields["from_year"] = date("Y"); $fields["from_month"] = date("m"); $fields["from_day"] = date("d"); $fields["to_year"] = date("Y"); $fields["to_month"] = date("m"); $fields["to_day"] = date("d"); extract($fields, EXTR_SKIP); $from_date = "{$from_year}-{$from_month}-{$from_day}"; $to_date = "{$to_year}-{$to_month}-{$to_day}"; $sql = "\n\tSELECT invnum, cash, cheque, credit, sdate, cusname\n\tFROM cubit.nons_invoices\n\tWHERE sdate BETWEEN '{$from_date}' AND '{$to_date}' AND hire_invnum!='0'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoices."); $total_cash = 0; $total_cheque = 0; $total_credit = 0; $inv_out = ""; while ($inv_data = pg_fetch_array($inv_rslt)) { $inv_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$inv_data['sdate']}</td>\n\t\t\t<td align='center'>{$inv_data['invnum']}</td>\n\t\t\t<td>{$inv_data['cusname']}</td>\n\t\t\t<td align='right'>" . sprint($inv_data["cash"]) . "</td>\n\t\t\t<td align='right'>" . sprint($inv_data["cheque"]) . "</td>\n\t\t\t<td align='right'>" . sprint($inv_data["credit"]) . "</td>\n\t\t</tr>"; $total_cash += $inv_data["cash"]; $total_cheque += $inv_data["cheque"]; $total_credit += $inv_data["credit"]; } if (empty($inv_out)) { $inv_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='6'><li>No results found.</li></td>\n\t\t</tr>"; } $OUTPUT = "\n\t<center>\n\t<h3>Daily Hire Cashup Report</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='4'>Date Range</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\n\t\t\t<td> <b>To</b> </td>\n\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\n\t\t\t<td><input type='submit' value='Select' /></td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Date</th>\n\t\t\t<th>Invoice No</th>\n\t\t\t<th>Customer</th>\n\t\t\t<th>Cash</th>\n\t\t\t<th>Cheque</th>\n\t\t\t<th>Credit Card</th>\n\t\t</tr>\n\t\t{$inv_out}\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='3'><b>Total</b></td>\n\t\t\t<td align='right'><b>" . sprint($total_cash) . "</b></td>\n\t\t\t<td align='right'><b>" . sprint($total_cheque) . "</b></td>\n\t\t\t<td align='right'><b>" . sprint($total_credit) . "</b></td>\n\t</table>\n\t</center>"; return $OUTPUT; }
function display() { extract($_REQUEST); $fields = array(); $fields["from_year"] = date("Y"); $fields["from_month"] = date("m"); $fields["from_day"] = "01"; $fields["to_year"] = date("Y"); $fields["to_month"] = date("m"); $fields["to_day"] = date("d"); extract($fields, EXTR_SKIP); $from_date = "{$from_year}-{$from_month}-{$from_day}"; $to_date = "{$to_year}-{$to_month}-{$to_day}"; $sql = "\n\tSELECT id, stock.stkcod, stock.stkdes, qty, cost_per_unit, (qty*cost_per_unit) AS total,\n\t\textract('epoch' FROM timestamp) AS e_time\n\tFROM cubit.manu_hist_main\n\t\tLEFT JOIN cubit.stock ON manu_hist_main.stkid=stock.stkid\n\tWHERE timestamp BETWEEN '{$from_date} 0:00:00' AND '{$to_date} 23:59:59'\n\tORDER BY timestamp DESC"; $main_rslt = db_exec($sql) or errDie("Unable to retrieve main items."); $hist_out = ""; while ($main_data = pg_fetch_array($main_rslt)) { $hist_out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><b>" . date("d-m-Y", $main_data["e_time"]) . "</b></td>\n\t\t\t\t<td><b>({$main_data['stkcod']}) {$main_data['stkdes']}</b></td>\n\t\t\t\t<td align='center'><b>{$main_data['qty']}</b></td>\n\t\t\t\t<td align='right'><b>" . sprint($main_data["cost_per_unit"]) . "</b></td>\n\t\t\t\t<td align='right'><b>" . sprint($main_data["total"]) . "</b></td>\n\t\t\t</tr>"; $sql = "\n\t\tSELECT stkcod, stkdes, qty, cost_per_unit, (qty*cost_per_unit) AS total\n\t\tFROM cubit.manu_hist_sub\n\t\t\tLEFT JOIN cubit.stock ON manu_hist_sub.stkid=stock.stkid\n\t\tWHERE main_id='{$main_data['id']}'\n\t\tORDER BY timestamp ASC"; $sub_rslt = db_exec($sql) or errDie("Unable to retrieve sub items."); while ($sub_data = pg_fetch_array($sub_rslt)) { $hist_out .= "\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td> </td>\n\t\t\t\t\t<td>({$sub_data['stkcod']}) {$sub_data['stkdes']}</td>\n\t\t\t\t\t<td align='center'>{$sub_data['qty']}</td>\n\t\t\t\t\t<td align='right'>" . sprint($sub_data["cost_per_unit"]) . "</td>\n\t\t\t\t\t<td align='right'>" . sprint($sub_data["total"]) . "</td>\n\t\t\t\t</tr>"; } } if (empty($hist_out)) { $hist_out = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='5'><li>No results found.</li></td>\n\t\t\t</tr>"; } $OUTPUT = "\n\t\t<center>\n\t\t<h3>Manufacturing Cost Report</h3>\n\t\t<form method='post' action='" . SELF . "'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th colspan='4'>Date Range</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\n\t\t\t\t<td> <b>To</b> </td>\n\t\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\n\t\t\t\t<td><input type='submit' value='Select' style='font-weight:bold' /></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Date</th>\n\t\t\t\t<th>Stock</th>\n\t\t\t\t<th>Qty</th>\n\t\t\t\t<th>Cost per Unit</th>\n\t\t\t\t<th>Total</th>\n\t\t\t</tr>\n\t\t\t{$hist_out}\n\t\t</table>\n\t\t</center>"; return $OUTPUT; }
function view($frm) { extract($_REQUEST); if ($msg = cForm::validateValue($supid, "num", 1, 10)) { return "<li class='err'>The supplier ID is invalid. {$msg}</li>\n\t\t\t<input type='button' onclick='window.history.back();' value='« Correction' />"; } /* @var frm cForm */ $frm->settitle("Supplier Pricelist"); $frm->setkey("import"); $frm->add_heading("Import New Pricelist"); $frm->add_message("\n\t\t\t<li class='err'>Pricelists has to be in CSV format and to import them\n\t\t\t\tyou have to specify the order and format of the fields<br />\n\t\t\t\tby selecting what each of them are in the same order as they appear\n\t\t\t\tin the file. Only the stock code<br />\n\t\t\t\tand the price is needed, so for the other fields you simply\n\t\t\t\tselect the '-' options.\n\t\t\t</li>", "inst"); $frm->add_message("\n\t\t\t<li class='err'>Note that the stock codes of the supplier should be added\n\t\t\t\tby editing the stock item and selecting the<br />\n\t\t\t\t'Add/Edit/Remove' button below the stock code input field.\n\t\t\t</li>", "suppstkcod"); $frm->add_hidden("supid", $supid, "num"); $frm->add_file("Pricelist", "supplist"); $frm->add_checkbox("VAT Inclusive", "vatinc", true, true); $frm->add_heading("Comma Seperated Volume (CSV) Fields"); $frm->add_layout("\n\t<tr %bgc>\n\t\t<td colspan='2' nowrap='t'>\n\t\t\t<strong>\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly\n\t\t\t</strong>\n\t\t</td>\n\t</tr>"); // field types $ft = array("ignore" => "-", "stkcod" => "Stock Code", "price" => "Price"); $frm->add_select("", "fld[0]", "stkcod", $ft, "string", "5:6"); $frm->add_select("", "fld[1]", "price", $ft, "string", "5:6"); $frm->add_select("", "fld[2]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[3]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[4]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[5]", "ignore", $ft, "string", "5:6"); $frm->add_ctrlbtn("Import", "submit", "btn_import"); $OUT = $frm->getfrm_input(); /* supplier info */ $suppinfo = qrySupplier($supid); $supcur = qryCurrency($suppinfo["fcid"]); $supcur = $supcur["symbol"]; /* list current pricelist */ $OUT .= "\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th>Stock Code</td>\n\t\t<th>Supplier Stock Code</th>\n\t\t<th>Current Supplier Price</th>\n\t\t<th>Current Selling Price</th>\n\t</tr>"; $sql = "SELECT pli.*\n\t\t\tFROM exten.spricelist pl INNER JOIN exten.splist_prices pli\n\t\t\t\tON pl.listid=pli.listid\n\t\t\tWHERE pl.suppid='{$supid}'"; $qry = new dbSql($sql); $qry->run(); if ($qry->num_rows() <= 0) { $OUT .= "\n\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t<td colspan='4'>No pricelist.</td>\n\t\t</tr>"; } $i = 0; while ($row = $qry->fetch_array()) { if (empty($row["supstkcod"])) { $our_stkcod = "No supplier stock code"; $our_price = ""; } else { if (($stkid = suppStkid($supid, $row["supstkcod"])) === false) { $our_stkcod = "<li class='err'>No such stock item.\n\t\t\t\t<a href='stock-add.php?stkcod={$row['supstkcod']}&supid={$supid}&supstkcod={$row['supstkcod']}'>Add Stock</a> /\n\t\t\t\t<a href='stock-view.php'>Edit Stock</li>"; $our_price = ""; } else { $stkrow = qryStock($stkid, "stkcod, selamt"); $our_stkcod = "<strong>{$stkrow['stkcod']}</strong>"; $our_price = CUR . " " . sprint($stkrow["selamt"]); } } $OUT .= "\n\t\t<tr bgcolor='" . bgcolor($i) . "'>\n\t\t\t<td>{$our_stkcod}</td>\n\t\t\t<td>{$row['supstkcod']}</td>\n\t\t\t<td align='right'>{$supcur} " . sprint($row["price"]) . "</td>\n\t\t\t<td align='right'>{$our_price}</td>\n\t\t</tr>"; } $OUT .= "\n\t</table>"; return $OUT; }
/** * Set a required item. * * @param string $key * @param mixed $value * @return Factory */ public function set($key, $value) { if (!in_array($key, $this->_requires)) { throw new Exception(sprint("Can not set key that is not required: '%s'", $key)); } $this->_items[$key] = $value; return $this; }
function display() { extract($_REQUEST); $fields = array(); $fields["from_year"] = date("Y"); $fields["from_month"] = date("m"); $fields["from_day"] = date("d"); $fields["to_year"] = date("Y"); $fields["to_month"] = date("m"); $fields["to_day"] = date("d"); $fields["group_id"] = 0; $fields["type_id"] = 0; extract($fields, EXTR_SKIP); $sql = "SELECT grpid, grpname FROM cubit.assetgrp ORDER BY grpname ASC"; $group_rslt = db_exec($sql) or errDie("Unable to retrieve groups."); $group_sel = "\n\t<select name='group_id' style='width: 100%'>\n\t\t<option value='0'>[All]</option>"; while ($group_data = pg_fetch_array($group_rslt)) { $sel = $group_id == $group_data["grpid"] ? "selected='t'" : ""; $group_sel .= "\n\t\t<option value='{$group_data['grpid']}'>\n\t\t\t{$group_data['grpname']}\n\t\t</option>"; } $group_sel .= "</select>"; $sql = "SELECT id, name FROM cubit.asset_types ORDER BY name ASC"; $type_rslt = db_exec($sql) or errDie("Unable to retrieve asset types."); $type_sel = "\n\t<select name='type_id' style='width: 100%'>\n\t\t<option value='0'>[All]</option>"; while ($type_data = pg_fetch_array($type_rslt)) { $sel = $type_id == $type_data["id"] ? "selected='t'" : ""; $type_sel .= "\n\t\t<option value='{$type_data['id']}'>\n\t\t\t{$type_data['name']}\n\t\t</option>"; } $type_sel .= "</select>"; $OUTPUT = "\n\t<center>\n\t<h3>Asset Sale Report</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='4'>Date Range</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td><b>From</b> </td>\n\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\n\t\t\t<td> <b>To</b> </td>\n\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th colspan='2'>Group</th>\n\t\t\t<th colspan='2'>Type</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='2'>{$group_sel}</td>\n\t\t\t<td colspan='2'>{$type_sel}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan='4' align='center'>\n\t\t\t\t<input type='submit' value='Select' style='font-weight: bold' />\n\t\t\t</td>\n\t\t</tr>\n\t</table>\n\t</form>"; $where_ar = array(); if ($group_id > 0) { $where_ar[] = "grpid='{$group_id}'"; } if ($type_id > 0) { $where_ar[] = "type_id='{$type_id}'"; } $where_sql = implode(" AND ", $where_ar); if (!empty($where_sql)) { $where_sql .= " AND "; } $sql = "\n\tSELECT id, des, serial, serial2, nonserial, saledate, saleamt\n\tFROM cubit.assets_prev\n\tWHERE {$where_sql} div='" . USER_DIV . "' AND remaction='Sale'"; $sale_rslt = db_exec($sql) or errDie("Unable to retrieve sales."); $sale_out = ""; while ($sale_data = pg_fetch_array($sale_rslt)) { if ($sale_data["nonserial"]) { $qty_sold = $sale_data["serial2"]; } else { $qty_sold = 1; } $sale_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$sale_data['des']}</td>\n\t\t\t<td>{$sale_data['serial']}</td>\n\t\t\t<td align='center'>{$qty_sold}</td>\n\t\t\t<td align='center'>{$sale_data['saledate']}</td>\n\t\t\t<td align='right'>" . sprint($sale_data["saleamt"]) . "</td>\n\t\t\t<td align='right'>{$sale_data['accdep']}</td>\n\t\t</tr>"; } if (empty($sale_out)) { $sale_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='5'>\n\t\t\t\t<li>No results found from your current selection</li>\n\t\t\t</td>\n\t\t</tr>"; } $OUTPUT .= "\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Asset</th>\n\t\t\t<th>Serial</th>\n\t\t\t<th>Qty Sold</th>\n\t\t\t<th>Sale Date</th>\n\t\t\t<th>Amount</th>\n\t\t\t<th>Accumulated Depreciation</th>\n\t\t\t<th>Profit / Loss</th>\n\t\t</tr>\n\t\t{$sale_out}\n\t</table>\n\t</center>"; return $OUTPUT; }
function details($_GET) { # get vars extract($_GET); # 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"] . "</li>"; } $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } # Get Order info db_connect(); $sql = "SELECT * FROM nons_purchases 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); /* --- Start Products Display --- */ # Products layout $products = "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>ITEM NUMBER</th>\n\t\t\t\t\t\t\t<th>DESCRIPTION</th>\n\t\t\t\t\t\t\t<th>QTY OUTSTANDING</th>\n\t\t\t\t\t\t\t<th>UNIT PRICE</th>\n\t\t\t\t\t\t\t<th>DELIVERY DATE</th>\n\t\t\t\t\t\t\t<th>AMOUNT</th>\n\t\t\t\t\t\t<tr>"; # get selected stock in this Order db_connect(); $sql = "SELECT * FROM nons_pur_items WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'"; $stkdRslt = db_exec($sql); while ($stkd = pg_fetch_array($stkdRslt)) { # format date list($dyear, $dmon, $dday) = explode("-", $stkd['ddate']); # put in product $products .= "\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>{$stkd['cod']}</td>\n\t\t\t\t\t\t\t\t<td>{$stkd['des']}</td>\n\t\t\t\t\t\t\t\t<td>{$stkd['qty']}</td>\n\t\t\t\t\t\t\t\t<td nowrap>" . CUR . " {$stkd['unitcost']}</td>\n\t\t\t\t\t\t\t\t<td>{$dday}-{$dmon}-{$dyear}</td>\n\t\t\t\t\t\t\t\t<td nowrap>" . CUR . " {$stkd['amt']}</td>\n\t\t\t\t\t\t\t</tr>"; } $products .= "</table>"; /* --- Start Some calculations --- */ # Get subtotal $SUBTOT = sprint($pur['subtot']); # Get Total $TOTAL = sprint($pur['total']); # Get vat $VAT = sprint($pur['vat']); /* --- End Some calculations --- */ # format date list($pyear, $pmon, $pday) = explode("-", $pur['pdate']); // format the vat inclusive variable for nicer display if ($pur['vatinc'] == "novat") { $pur['vatinc'] = "No Vat"; } /* -- Final Layout -- */ $details = "\n\t\t\t\t\t<center>\n\t\t\t\t\t<h3>Non-Stock Order Details</h3>\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='95%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td valign='top'>\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Supplier Details </th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Supplier</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['supplier']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Account number</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'><pre>{$pur['supaddr']}</pre></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td valign='top' align='right'>\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Non-Stock Order Details </th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Non-Stock Order No.</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['purnum']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Order No.</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['ordernum']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Supplier Invoice No</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['supinv']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Delivery Ref No.</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['refno']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Terms</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['terms']} Days</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Date</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pday}-{$pmon}-{$pyear}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>VAT Inclusive</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['vatinc']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Delivery Charges</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>" . CUR . " {$pur['shipchrg']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'>{$products}</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>\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th width='40%'>Quick Links</th>\n\t\t\t\t\t\t\t\t\t\t<th width='45%'>Remarks</th>\n\t\t\t\t\t\t\t\t\t\t<td rowspan='5' valign='top' width='15%'><br></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td class='" . bg_class() . "'><a href='nons-purchase-new.php'>New Non-Stock Order</a></td>\n\t\t\t\t\t\t\t\t\t\t<td class='" . bg_class() . "' rowspan='4' align='center' valign='top'>" . nl2br($pur['remarks']) . "</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='nons-purchase-view.php'>View Non-Stock Orders</a></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td align='right'>\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . " width='80%'>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>SUBTOTAL</td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$pur['subtot']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>Delivery Charges</td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$pur['shipping']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<td>VAT @ " . TAX_VAT . " %</td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$pur['vat']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t\t<th>GRAND TOTAL</th>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$pur['total']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</form>\n\t\t\t\t\t</center>"; return $details; }
function show_listing() { db_connect(); #######################[ LOANS APPLICATIONS ]########################## $get_loans = "SELECT * FROM loan_requests ORDER BY loanamt"; $run_loans = db_exec($get_loans) or errDie("Unable to get loan applications."); if (pg_numrows($run_loans) < 1) { $listing = "<tr class='" . bg_class() . "'><td colspan='8'>No Loan Applications Found.</td></tr>"; } else { $listing = ""; while ($larr = pg_fetch_array($run_loans)) { $get_emp = "SELECT fnames,sname FROM employees WHERE empnum = '{$larr['empnum']}' LIMIT 1"; $run_emp = db_exec($get_emp) or errDie("Unable to get employee information."); if (pg_numrows($run_emp) < 1) { $showemp = "<li class='err'>Invalid Employee For Loan Selected</li>"; } else { $earr = pg_fetch_array($run_emp); $showemp = "{$earr['fnames']} {$earr['sname']}"; } $get_type = "SELECT * FROM loan_types WHERE id = '{$larr['loan_type']}' LIMIT 1"; $run_type = db_exec($get_type) or errDie("Unable to get loan type information."); if (pg_numrows($run_type) < 1) { $showloantype = "Invalid Loan Type Selected"; } else { $tarr = pg_fetch_array($run_type); $showloantype = $tarr['loan_type']; } $listing .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td>{$showemp}</td>\n\t\t\t\t\t\t<td>{$larr['loanamt']}</td>\n\t\t\t\t\t\t<td>{$larr['loaninstall']}</td>\n\t\t\t\t\t\t<td>{$larr['loanint']}</td>\n\t\t\t\t\t\t<td>{$larr['loanperiod']}</td>\n\t\t\t\t\t\t<td>{$larr['loandate']}</td>\n\t\t\t\t\t\t<td>{$showloantype}</td>\n\t\t\t\t\t\t<td><a href='loan_apply_approve.php?id={$larr['id']}&deny=t'>Deny</a></td>\n\t\t\t\t\t\t<td><a href='loan_apply_approve.php?id={$larr['id']}'>Approve</a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t"; } } ######################################################################## #####################[ CURRENT LOANS ]################################## $employees = ""; $i = 0; db_connect(); $sql = "SELECT * FROM employees WHERE gotloan='t'::bool AND div = '" . USER_DIV . "' ORDER BY sname"; $empRslt = db_exec($sql) or errDie("Unable to select employees with loans from database."); if (pg_numrows($empRslt) < 1) { $employees .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td colspan='7'>No Employees With Loans Found.</td>\n\t\t\t\t\t</tr>"; // return "No employee-loans found in database.<p>" // .mkQuickLinks( // ql("loan_apply.php", "Apply For New Loan"), // ql("../admin-employee-add.php", "Add Employee"), // ql("../admin-employee-view.php", "View Employees") // ); } else { while ($myEmp = pg_fetch_array($empRslt)) { $totloan = sprint($myEmp['loaninstall'] * $myEmp['loanperiod']); $totout = sprint($myEmp['loanamt']); $employees .= "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>{$myEmp['sname']}, {$myEmp['fnames']} ({$myEmp['enum']})</td>\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$totloan}</td>\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$totout}</td>\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " {$myEmp['loaninstall']}</td>\n\t\t\t\t\t\t\t<td align='right'>{$myEmp['loanint']} %</td>\n\t\t\t\t\t\t\t<td align='right'>{$myEmp['loanperiod']} months</td>\n\t\t\t\t\t\t\t<td><a href='loan-edit.php?empnum={$myEmp['empnum']}'>Edit</a></td>\n\t\t\t\t\t\t</tr>\n"; $i++; } } ######################################################################## $display = "\n\t\t\t<h2>Summary Of Present Loans</h2>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<input type='hidden' name='key' value='input'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Employee</th>\n\t\t\t\t\t<th>Loan amount(incl interest)</th>\n\t\t\t\t\t<th>Amount outstanding</th>\n\t\t\t\t\t<th>Monthly installment</th>\n\t\t\t\t\t<th>Loan interest</th>\n\t\t\t\t\t<th>Payback period</th>\n\t\t\t\t\t<th colspan='2'>Options</th>\n\t\t\t\t</tr>\n\t\t\t\t{$employees}\n\t\t\t</table>\n\t\t\t<br><br>\n\t\t\t<h2>Current Loan Applications</h2>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Employee</th>\n\t\t\t\t\t<th>Loan Amount</th>\n\t\t\t\t\t<th>Installments</th>\n\t\t\t\t\t<th>Loan Interest Rate</th>\n\t\t\t\t\t<th>Loan Period</th>\n\t\t\t\t\t<th>Loan Date</th>\n\t\t\t\t\t<th>Loan Type</th>\n\t\t\t\t\t<th colspan='2'>Options</th>\n\t\t\t\t</tr>\n\t\t\t\t{$listing}\n\t\t\t</table><br>" . mkQuickLinks(ql("loan_apply.php", "New Loan Application")); return $display; }
function add() { core_connect(); # Get Petty cash account $cashacc = gethook("accnum", "bankacc", "name", "Petty Cash"); # Get account name for thy lame User's Sake $accRslt = get("core", "*", "accounts", "accid", $cashacc); if (pg_numrows($accRslt) < 1) { return "<li class='err'> Petty Cash Account not found.</li>"; } $acc = pg_fetch_array($accRslt); # Check available funds $cashacc = gethook("accnum", "bankacc", "name", "Petty Cash"); core_connect(); $sql = "SELECT (debit - credit) as bal FROM trial_bal WHERE month='" . PRD_DB . "' AND accid = '{$cashacc}' AND div = '" . USER_DIV . "'"; $accbRslt = db_exec($sql); if (pg_numrows($accbRslt) < 1) { return "<li class='err'> Petty Cash Account not found.</li>"; } $accb = pg_fetch_array($accbRslt); $accb['bal'] = sprint($accb['bal']); # mourn if the is no money if ($accb['bal'] < 1) { return "\n\t\t\t<li class='err'> There are no Petty Cash funds available.</li>\n\t\t\t<p>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td><a href='petty-trans.php'>Transfer funds to petty cash account</a></td>\n\t\t\t\t</tr>\n\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t</table>"; } // Layout $add = "\n\t\t<h3>Funds transfer to Bank</h3>\n\t\t<table " . TMPL_tblDflts . " width='300'>\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<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>Bank Account</td>\n\t\t\t\t<td valign='center'>\n\t\t\t\t\t<select name='bankid'>"; db_connect(); $sql = "SELECT * FROM bankacct WHERE btype != 'int' AND div = '" . USER_DIV . "'"; $banks = db_exec($sql); if (pg_numrows($banks) < 1) { return "<li class='err'> There are no accounts held at the selected Bank.</li>\n\t\t<p><input type='button' onClick='JavaScript:history.back();' value='« Correct Selection'>"; } while ($bacc = pg_fetch_array($banks)) { $add .= "<option value='{$bacc['bankid']}'>({$bacc['acctype']}) {$bacc['accname']} - {$bacc['bankname']}</option>"; } if (!isset($date_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); $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"); } } $add .= "\n\t\t\t\t\t</select>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Date</td>\n\t \t<td>" . mkDateSelect("date", $date_year, $date_month, $date_day) . "</td>\n\t </tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Received from</td>\n\t \t<td valign='center'><input size='20' name='name' value='Petty Cash'></td>\n\t </tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Description</td>\n\t \t<td valign='center'><textarea cols='18' rows='2' name='descript'></textarea></td>\n\t </tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Cheque Number</td>\n\t \t<td valign='center'><input size='10' name='cheqnum'></td>\n\t </tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Amount</td>\n\t \t<td valign='center'>" . CUR . " <input type='text' size='10' name='amount'> Max : " . CUR . " {$accb['bal']}<input type='hidden' name='max' value='{$accb['bal']}'></td>\n\t </tr>\n\t <tr class='" . bg_class() . "'>\n\t \t<td>Petty Cash Account</td>\n\t \t<td><input type='hidden' name='accinv' value='{$acc['accid']}'>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</td>\n\t </tr>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<td><input type='button' value='< Cancel' onClick='javascript:history.back();'></td>\n\t\t\t\t<td valign='center'><input type='submit' value='Confirm >'></td>\n\t\t\t</tr>\n\t\t</table>"; # main table (layout with menu) $OUTPUT = "\n\t\t\t<center>\n\t <table width='100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width='65%' align='left'>{$add}</td>\n\t\t\t\t\t<td valign='top' align='center'>\n\t\t\t\t\t\t<table " . TMPL_tblDflts . " width='65%'>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t </table>"; return $OUTPUT; }
function confirm($_POST, $_FILES) { extract($_POST); $importfile = tempnam("/tmp", "cubitimport_"); $file = fopen($_FILES["compfile"]["tmp_name"], "r"); if ($file == false) { return "<li class='err'>Cannot read file.</li>" . select_file(); } db_conn('cubit'); $Sl = "\n\t\tCREATE TABLE import_data (\n\t\t\tdes1 varchar, des2 varchar,\n\t\t\tdes3 varchar, des4 varchar,\n\t\t\tdes5 varchar, des6 varchar,\n\t\t\tdes7 varchar, des8 varchar,\n\t\t\tdes9 varchar, des10 varchar,\n\t\t\tdes11 varchar, des12 varchar,\n\t\t\tdes13 varchar, des14 varchar,\n\t\t\tdes15 varchar, des16 varchar\n\t\t)"; $Ri = @db_exec($Sl); $Sl = "DELETE FROM import_data"; $Ri = db_exec($Sl) or errDie("Unable to clear import table"); while (!feof($file)) { $data = safe(fgets($file, 4096)); $datas = explode(",", $data); if (!isset($datas[2])) { continue; } $code = safe($datas[0]); $description = safe($datas[1]); $amount = sprint($datas[3]); $camount = sprint($datas[2]); $balance = sprint($datas[5]); $units = safe($datas[4]); $Sl = "\n\t\t\tINSERT INTO import_data (\n\t\t\t\tdes1, des2, des3, des4, des5, des6\n\t\t\t) VALUES (\n\t\t\t\t'{$code}', '{$description}', '{$amount}', '{$balance}', '{$units}', '{$camount}'\n\t\t\t)"; $Rl = db_exec($Sl) or errDie("Unable to insert data."); } fclose($file); #get stores db_conn('exten'); $get_stores = "SELECT * FROM warehouses WHERE div = '" . USER_DIV . "' ORDER BY whname"; $run_stores = db_exec($get_stores) or errDie("Unable to get stores information."); if (pg_numrows($run_stores) < 1) { return "Unable to get stores information."; } else { $storedrop = "<select name='store'>"; while ($sarr = pg_fetch_array($run_stores)) { $storedrop .= "<option value='{$sarr['whid']}'>{$sarr['whname']}</option>"; } $storedrop .= "</select>"; } $out = "\n\t\t<h3>Stock Import</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='3'>Select Store</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='3'>{$storedrop}</td>\n\t\t\t\t</tr>\n\t\t\t\t" . TBL_BR . "\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Stock Code</th>\n\t\t\t\t\t<th>Description</th>\n\t\t\t\t\t<th>Cost Price</th>\n\t\t\t\t\t<th>Selling Price</th>\n\t\t\t\t</tr>"; db_conn('cubit'); $Sl = "SELECT * FROM import_data"; $Ri = db_exec($Sl); $i = 0; while ($fd = pg_fetch_array($Ri)) { $out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$fd['des1']}</td>\n\t\t\t\t<td>{$fd['des2']}</td>\n\t\t\t\t<td>{$fd['des6']}</td>\n\t\t\t\t<td>{$fd['des3']}</td>\n\t\t\t</tr>"; $i++; } $out .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='3' align='right'><input type='submit' value='Write »'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>"; return $out; }
function customer_age($cusnum, $days, $fcid, $loc) { $ldays = $days; if ($days == 149) { $ldays = 365 * 10; } $sql = "\n\tSELECT sum(amount) FROM cubit.stmnt\n\tWHERE cusnum='{$cusnum}' AND\n\t\tdate BETWEEN '" . extlib_ago($ldays) . "' AND '" . extlib_ago($days - 29) . "'"; $amount_rslt = db_exec($sql) or errDie("Unable to retrieve aging."); $amount = pg_fetch_result($amount_rslt, 0); return sprint($amount); }
/** * @param StoreEntity $store * @param $orderId * @return ErpOrderEntity * @throws ErpOrderNotFound */ public function getOrder(StoreEntity $store, $orderId) { $request = $this->client->createRequest('GET', sprintf('%s/orders/%s', $store->getErpUrl(), $orderId), ['auth' => [$store->getErpUsername(), $store->getErpPassword()]]); try { $response = $this->sendRequest($request)->xml(); $order = ErpOrderEntity::createFromOrderXMLObject($response, $orderId); } catch (\Exception $e) { throw new ErpOrderNotFound(sprint('Order Id %s is not yet ready')); } return $order; }
function recon($id) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 20, "Invalid Bank Recon 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 Bank Recon $sql = "SELECT * FROM save_bank_recon WHERE id = '{$id}'"; $recRslt = db_exec($sql) or errDie("Unable to retrieve Bank Recon from the Database", SELF); if (pg_numrows($recRslt) < 1) { return "<center><li> Invalid Bank Recon Number."; } $rec = pg_fetch_array($recRslt); $recon = base64_decode($rec['recon']); db_conn('cubit'); $payments = "<p>\r\n\t<h3>Reconciled Payments</h3>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='80%'>\r\n\t<tr><td><b>Date</b></td><td><b>To</b></td><td><b>Description</b></td><td><b>Cheque</b></td><td><b>Amount</b></td></tr>"; $Sl = "SELECT * FROM cashbook WHERE rid='{$id}' AND trantype='withdrawal'"; $Ri = db_exec($Sl) or errDie("Unable to get data,"); if (pg_num_rows($Ri) > 0) { while ($data = pg_fetch_array($Ri)) { $payments .= "<tr><td>{$data['date']}</td><td>{$data['name']}</td><td>{$data['descript']}</td><td>{$data['cheqnum']}</td><td align=right>" . CUR . " " . sprint($data['amount']) . "</td></tr>"; } $payments .= "</table>"; } else { $payments = "<p>There were no reconciled payments."; } $depos = "<p>\r\n\t<h3>Reconciled Deposits</h3>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='80%'>\r\n\t<tr><td><b>Date</b></td><td><b>From</b></td><td><b>Description</b></td><td><b>Cheque</b></td><td><b>Amount</b></td></tr>"; $Sl = "SELECT * FROM cashbook WHERE rid='{$id}' AND trantype='deposit'"; $Ri = db_exec($Sl) or errDie("Unable to get data,"); if (pg_num_rows($Ri) > 0) { while ($data = pg_fetch_array($Ri)) { $depos .= "<tr><td>{$data['date']}</td><td>{$data['name']}</td><td>{$data['descript']}</td><td>{$data['cheqnum']}</td><td align=right>" . CUR . " " . sprint($data['amount']) . "</td></tr>"; } $depos .= "</table>"; } else { $depos = "<p>There were no reconciled deposits."; } $OUTPUT = $recon . "</table>" . $payments . $depos; require "../tmpl-print.php"; }
function display() { extract($_REQUEST); $reports = array("acid_test", "customers_turnover", "daily_sales_in_receivables", "inventory_turnover", "days_cost_of_sales_in_inventory", "accounts_receivable_turnover", "accounts_payable_turnover", "days_cost_of_sales_in_accounts_payable", "assets_turnover", "debt_ratio", "depreciation_expense_gross_depreciable_property", "current_ratio", "working_captial", "accounts_receivable_working_capital", "inventory_working_capital", "long_term_liabilities_working_capital", "sales_working_capital", "gross_profit_turnover", "net_profit_turnover", "return_on_assets", "return_on_investment", "repairs_and_maintenance_gross_depreciation_of_property", "owners_equity", "debt_equity", "financial_leverage", "interest_net_income_excluding_interest", "operating_cycle_days"); $not_percentage = array("daily_sales_in_receivables", "days_cost_of_sales_in_inventory", "days_cost_of_sales_in_accounts_payable", "working_capital", "operating_cycle_days"); $i = 1; $reports_out = ""; foreach ($reports as $name) { if ($i == 1) { $reports_out .= "<tr><td width='20%' valign='top'>"; } else { $reports_out .= "<td width='20%' valign='top'>"; } if (function_exists($name)) { list($description, $calculation) = call_user_func($name); } else { $description = "Not implemented."; } $calculation = sprint($calculation); if (!in_array($name, $not_percentage)) { $calculation .= "%"; } $reports_out .= "\n\t\t<table " . TMPL_tblDflts . " width='100%' style='border: 1px solid #fff'>\n\t\t\t<tr><th>" . nice_name($name) . "</th></tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>\n\t\t\t\t\t<span style='font-size: 0.9em; letter-spacing: -0.065em'>\n\t\t\t\t\t\t{$description}\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr bgcolor='#ffffff'>\n\t\t\t\t<td align='center'>\n\t\t\t\t\t<span style='font-size: 1.2em; color: #f00; font-weight:bold'>\n\t\t\t\t\t\t{$calculation}\n\t\t\t\t\t</span>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>"; if ($i == 5) { $reports_out .= "</td></tr>"; $i = 0; } else { $reports_out .= "</td>"; } $i++; } if (!isset($heart)) { $sql = "SELECT value FROM cubit.settings WHERE constant='HEART'"; $heart_rslt = db_exec($sql) or errDie("Unable to retrieve heart display value."); $heart = pg_fetch_result($heart_rslt, 0); } else { $sql = "UPDATE cubit.settings SET value='{$heart}' WHERE constant='HEART'"; db_exec($sql) or errDie("Unable to update heart status"); } if ($heart) { $heart_yes = "checked"; $heart_no = ""; } else { $heart_yes = ""; $heart_no = "checked"; } $bgcolor = bgcolorg(); $ql = mkQuickLinks(ql("ratio_settings.php", "Link Accounts to Ratios")); $OUTPUT = "\n\t<table cellpadding='5' cellspacing='2'>{$reports_out}</table>\n\t<center>\n\t<form method='post' action='" . SELF . "' name='form'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr><th colspan='2'>Display Heart on Main Menu</th></tr>\n\t\t<tr>\n\t\t\t<td class='" . bg_class() . "' align='center'>\n\t\t\t\tYes <input type='radio' name='heart' value='1'\n\t\t\t\tonchange='javascript:document.form.submit()' {$heart_yes} />\n\t\t\t</td>\n\t\t\t<td class='" . bg_class() . "' align='center'>\n\t\t\t\tNo <input type='radio' name='heart' value='0'\n\t\t\t\tonchange='javascript:document.form.submit()' {$heart_no} />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr><td colspan='2' align='center'>{$ql}</td></tr>\n\t</table>\n\t</form>\n\t</center>"; return $OUTPUT; }
function login($params) { $response = false; $username = strip_tags($params['username']); $password = strip_tags($params['password']); $qry = sprint("SELECT * FROM members WHERE username='******' AND password='******'", $username, $password); $dbres = $this->dbconnect(); $qres = mysql_num_rows(mysql_query($qry, $dbres)) or die(mysql_error()); if ($qres > 0) { $response = true; } else { $response = false; } }
function display($msg = "") { extract($_REQUEST); $fields = array(); $fields["search"] = "[_BLANK_]"; extract($fields, EXTR_SKIP); $sql = "SELECT assets.id, des, locat, per_day, per_hour, per_week,\n\t\t\t\tper_month, serial, default_basis\n\t\t\t\tFROM cubit.assets\n\t\t\t\t\tLEFT JOIN hire.basis_prices\n\t\t\t\t\t\tON assets.id = basis_prices.assetid\n\t\t\t\tWHERE remaction IS NULL AND (\n\t\t\t\t\tdes ILIKE '{$search}%' OR serial ILIKE '%{$search}%')\n\t\t\t\tORDER BY des ASC"; $asset_rslt = db_exec($sql); if ($search == "[_BLANK_]") { $n_msg = "Please type first few letters of the asset's name or serial"; $search = ""; } else { $n_msg = "No results found"; } $basis_types = array("per_hour" => "Hourly", "per_day" => "Daily", "per_week" => "Weekly", "per_month" => "Monthly"); $basis_out = ""; while ($asset_data = pg_fetch_array($asset_rslt)) { if (empty($asset_data["per_hour"])) { $asset_data["per_hour"] = "0.00"; } if (empty($asset_data["per_day"])) { $asset_data["per_day"] = "0.00"; } if (empty($asset_data["per_week"])) { $asset_data["per_week"] = "0.00"; } if (empty($asset_data["per_month"])) { $asset_data["per_month"] = "0.00"; } if (empty($asset_data["default_basis"])) { $asset_data["default_basis"] = "per_day"; } $types_sel = "<select name='default_basis[{$asset_data['id']}]'>"; foreach ($basis_types as $key => $value) { if ($key == $asset_data["default_basis"]) { $sel = "selected='t'"; } else { $sel = ""; } $types_sel .= "<option value='{$key}' {$sel}>{$value}</option>"; } $types_sel .= "</select>"; $basis_out .= "\n\t\t<input type='hidden' name='asset[]' value='{$asset_data['id']}' />\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$types_sel}</td>\n\t\t\t<td>{$asset_data['des']}</td>\n\t\t\t<td>{$asset_data['serial']}</td>\n\t\t\t<td>{$asset_data['locat']}</td>\n\t\t\t<td>\n\t\t\t\t" . CUR . "\n\t\t\t\t<input type='text' name='hour[{$asset_data['id']}]'\n\t\t\t\tvalue='" . sprint($asset_data["per_hour"]) . "' size='5'\n\t\t\t\tstyle='text-align: right' />\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t" . CUR . "\n\t\t\t\t<input type='text' name='day[{$asset_data['id']}]'\n\t\t\t\tvalue='" . sprint($asset_data["per_day"]) . "' size='5'\n\t\t\t\tstyle='text-align: right' />\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t" . CUR . "\n\t\t\t\t<input type='text' name='week[{$asset_data['id']}]'\n\t\t\t\tvalue='" . sprint($asset_data["per_week"]) . "' size='5'\n\t\t\t\tstyle='text-align: right' />\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t" . CUR . "\n\t\t\t\t<input type='text' name='month[{$asset_data['id']}]'\n\t\t\t\tvalue='" . sprint($asset_data["per_month"]) . "' size='5'\n\t\t\t\tstyle='text-align: right' />\n\t\t\t</td>\n\t\t</tr>"; } if (empty($basis_out)) { $basis_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='8'><li>{$n_msg}</li></td>\n\t\t</tr>"; } $OUTPUT = "<center>\n\t<h3>Default Basis Prices</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='2'>Search</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td><input type='text' name='search' value='{$search}' /></td>\n\t\t\t<td><input type='submit' value='Search' /></td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<form method='post' action='" . SELF . "'>\n\t<input type='hidden' name='key' value='save' />\n\t<table " . TMPL_tblDflts . ">\n\t\t{$msg}\n\t\t<tr>\n\t\t\t<th>Default Basis</th>\n\t\t\t<th>Plant</th>\n\t\t\t<th>Serial</th>\n\t\t\t<th>Location</th>\n\t\t\t<th>Hour</th>\n\t\t\t<th>Day</th>\n\t\t\t<th>Week</th>\n\t\t\t<th>Month</th>\n\t\t</tr>\n\t\t{$basis_out}\n\t\t<tr>\n\t\t\t<td colspan='8' align='center'>\n\t\t\t\t<input type='submit' value='Set Basis »'\n\t\t\t\tstyle='font-weight: bold' />\n\t\t\t</td>\n\t\t</tr>\n\t</table>\n\t</form>"; return $OUTPUT; }
function hireNotes($errors = "") { extract($_REQUEST); $fields = array(); $fields["date_year"] = date("Y"); $fields["date_month"] = date("m"); $fields["date_day"] = date("d"); extract($fields, EXTR_SKIP); // Retrieve monthly hire notes for this customer $sql = "SELECT * FROM hire.monthly_invoices WHERE invnum>0 AND invoiced='0'\r\n\t\t\tORDER BY invnum DESC"; $mi_rslt = db_exec($sql) or errDie("Unable to retrieve monthly hire notes."); $mi_out = ""; while ($mi_data = pg_fetch_array($mi_rslt)) { $sql = "SELECT *,\r\n\t\t\t\t\t(SELECT serial FROM cubit.assets WHERE id=asset_id) AS serial,\r\n\t\t\t\t\t(SELECT des FROM cubit.assets WHERE id=asset_id) as des\r\n\t\t\t\tFROM hire.monthly_invitems\r\n\t\t\t\tWHERE invid='{$mi_data['hire_invid']}'"; $mii_rslt = db_exec($sql) or errDie("Unable to retrieve items."); if (!pg_num_rows($mii_rslt)) { $sql = "DELETE FROM hire.monthly_invoices WHERE invid='{$mi_data['invid']}'"; db_exec($sql) or errDie("Unable to remove monthly invoice."); continue; } $mi_out .= "<tr>\r\n\t\t\t<th colspan='5'>Monthly Hire No: {$mi_data['invnum']}</th>\r\n\t\t\t<th align='right'>\r\n\t\t\t\t<input type='submit' name='invoice[{$mi_data['invid']}]'\r\n\t\t\t\tvalue='Invoice' />\r\n\t\t\t</th>\r\n\t\t</tr>"; $sql = "SELECT surname, cusname FROM cubit.customers\r\n\t\t\t\t\tWHERE cusnum='{$mi_data['cusnum']}'"; $cust_rslt = db_exec($sql) or errDie("Unable to retrieve customers."); $cust_data = pg_fetch_array($cust_rslt); while ($mii_data = pg_fetch_array($mii_rslt)) { if (!isset($mii_data["invoiced_month"])) { $mii_data["invoiced_month"] = 0; } if ($mii_data["invoiced_month"] == date("m")) { continue; } if (empty($mii_data["e_invoiced"])) { $invoiced = "Never"; } else { $invoiced = date("d-m-Y", $mii_data["e_invoiced"]); } $basis = ucwords(implode(" ", explode("_", $mii_data["basis"]))); $mi_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>{$cust_data['surname']} {$cust_data['cusname']}</td>\r\n\t\t\t\t<td>{$basis}</td>\r\n\t\t\t\t<td>" . getSerial($mii_data["asset_id"], true) . " {$mii_data['des']}</td>\r\n\t\t\t\t<td>{$mii_data['qty']}</td>\r\n\t\t\t\t<td>" . sprint($mii_data["amt"]) . "</td>\r\n\t\t\t\t<td> </td>\r\n\t\t\t</tr>"; } } if (empty($mi_out)) { $mi_out = "<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='6'>No invoices found.</td>\r\n\t\t</tr>"; } if (!isset($cust_id)) { $cust_id = 0; } $OUTPUT = "<center>\r\n\t<h3>Monthly Processing</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr><td colspan='2'>{$errors}</td></tr>\r\n\t\t<tr><th colspan='2'>Processing Date</th></tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td align='center'>" . mkDateSelect("date", $date_year, $date_month, $date_day) . "</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t<input type='hidden' name='cust_id' value='{$cust_id}' />\r\n\t<input type='hidden' name='key' value='invoice' />\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th>Customer</th>\r\n\t\t\t<th>Basis</th>\r\n\t\t\t<th>Item</th>\r\n\t\t\t<th>Qty</th>\r\n\t\t\t<th>Amount</th>\r\n\t\t\t<th> </th>\r\n\t\t</tr>\r\n\t\t{$mi_out}\r\n\t\t</form>\r\n\t\t<form method='post' action='" . SELF . "'>\r\n\t\t<input type='hidden' name='cust_id' value='{$cust_id}' />\r\n\t\t<input type='hidden' name='key' value='reset' />\r\n\t\t<tr>\r\n\t\t\t<td colspan='6' align='center'>\r\n\t\t\t\t<input type='submit' value='Reset' />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>"; return $OUTPUT; }
function printCenter($_GET) { # Get vars extract($_GET); # Query server db_connect(); $sql = "SELECT * FROM costcenters WHERE ccid = '{$ccid}'"; $ccRslt = db_exec($sql) or errDie("Unable to retrieve Cost centers from database."); if (pg_numrows($ccRslt) < 1) { return "<li class='err'> - Invalid Cost Center."; } $cc = pg_fetch_array($ccRslt); $sp4 = " "; # get income $income = ""; db_conn($prd); $sql = "SELECT * FROM cctran WHERE ccid = '{$cc['ccid']}' AND trantype = 'dt'"; $recRslt = db_exec($sql) or errDie("Unable to retrieve Cost Centers from database."); if (pg_numrows($recRslt) > 0) { $income = "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td colspan='4'><h3>Income</h3></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th>Type</th>\r\n\t\t\t\t\t<th>Date</th>\r\n\t\t\t\t\t<th>Description</th>\r\n\t\t\t\t\t<th>Amount</th>\r\n\t\t\t\t\t<th>Posted By</th>\r\n\t\t\t\t</tr>"; $totinc = 0; for ($i = 0; $rec = pg_fetch_array($recRslt); $i++) { $totinc += $rec['amount']; $rec['edate'] = ext_rdate($rec['edate']); $income .= "\r\n\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t<td>{$rec['typename']}</td>\r\n\t\t\t\t\t\t<td>{$sp4} {$rec['edate']} {$sp4}</td>\r\n\t\t\t\t\t\t<td>{$rec['description']}</td>\r\n\t\t\t\t\t\t<td align='right'>{$sp4}" . CUR . " {$rec['amount']}</td>\r\n\t\t\t\t\t\t<td>{$rec['username']}</td>\r\n\t\t\t\t\t</tr>"; } $totinc = sprint($totinc); $income .= "\r\n\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t<td colspan='3' align='right'><b>Total</b></td>\r\n\t\t\t\t\t<td align='right'><b>" . CUR . " {$totinc}</b></td>\r\n\t\t\t\t\t<td><br></td>\r\n\t\t\t\t</tr>"; } #get expenses $expense = ""; db_conn($prd); $sql = "SELECT * FROM cctran WHERE ccid = '{$cc['ccid']}' AND trantype = 'ct'"; $recRslt = db_exec($sql) or errDie("Unable to retrieve Cost Centers from database."); if (pg_numrows($recRslt) > 0) { $expense = "\r\n\t\t\t\t<tr><td><br></td></tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td colspan='4'><h3>Expenses</h3></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th>Type</th>\r\n\t\t\t\t\t<th>Date</th>\r\n\t\t\t\t\t<th>Description</th>\r\n\t\t\t\t\t<th>Amount</th>\r\n\t\t\t\t\t<th>Posted By</th>\r\n\t\t\t\t</tr>"; $totexp = 0; for ($i = 0; $rec = pg_fetch_array($recRslt); $i++) { $totexp += $rec['amount']; $rec['edate'] = ext_rdate($rec['edate']); $expense .= "\r\n\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t<td>{$rec['typename']}</td>\r\n\t\t\t\t\t\t<td>{$sp4} {$rec['edate']} {$sp4}</td>\r\n\t\t\t\t\t\t<td>{$rec['description']}</td>\r\n\t\t\t\t\t\t<td align='right'>{$sp4}" . CUR . " {$rec['amount']}</td>\r\n\t\t\t\t\t\t<td>{$rec['username']}</td>\r\n\t\t\t\t\t</tr>"; } $totexp = sprint($totexp); $expense .= "\r\n\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t<td colspan='3' align='right'><b>Total</b></td>\r\n\t\t\t\t\t<td align='right'><b>" . CUR . " {$totexp}</b></td>\r\n\t\t\t\t</tr>"; } $printCenter = "\r\n\t\t\t\t<center>\r\n\t\t\t\t<h3>Cost Centers Detailed Report</h3>\r\n\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>Cost Center</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>{$sp4} {$cc['centername']} ({$cc['centercode']}) {$sp4}</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 " . TMPL_tblDflts . ">\r\n\t\t\t\t\t{$income}\r\n\t\t\t\t\t{$expense}\r\n\t\t\t\t</table>\r\n\t\t\t\t<p>\r\n\t\t\t\t<form action='" . SELF . "' method='POST'>\r\n\t\t\t\t\t<input type='hidden' name='key' value='export'>\r\n\t\t\t\t\t<input type='hidden' name='ccid' value='{$ccid}'>\r\n\t\t\t\t\t<input type='hidden' name='prd' value='{$prd}'>\r\n\t\t\t\t\t<input type='submit' value='Export To Spreadsheet'>\r\n\t\t\t\t</form>\r\n\t\t\t\t<p>\r\n\t\t\t\t<p>\r\n\t\t\t\t<input type='button' value='[X] Close' onClick='javascript:window.close();'>"; return $printCenter; }
function edit($listid) { # validate input require_lib("validate"); $v = new validate(); $v->isOk($listid, "num", 1, 50, "Invalid Price List id."); # display errors, if any if ($v->isError()) { $confirm = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $confirm .= "<li class='err'>-" . $e["msg"] . "</li>"; } return $confirm; } # Select Stock db_conn("exten"); $sql = "SELECT * FROM pricelist WHERE listid = '{$listid}' AND div = '" . USER_DIV . "'"; $listRslt = db_exec($sql) or errDie("Unable to access databse.", SELF); if (pg_numrows($listRslt) < 1) { return "<li> Invalid Price List ID."; } else { $list = pg_fetch_array($listRslt); } $vattype = getSetting("SELAMT_VAT") == 'inc' ? "Including Vat" : "Excluding Vat"; $enter = "\r\n\t\t<h3>Price List</h3>\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Field</th>\r\n\t\t\t\t<th>Value</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>Price list</td>\r\n\t\t\t\t<td align='center'>{$list['listname']}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='2'><h3>Prices</h3><td>\r\n\t\t\t<tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Item</th>\r\n\t\t\t\t<th>Price Amount</th>\r\n\t\t\t</tr>"; # Query server $i = 0; db_conn('exten'); $sql = "SELECT * FROM plist_prices WHERE listid = '{$listid}' AND div = '" . USER_DIV . "' AND show='Yes' ORDER BY stkid ASC"; $stkpRslt = db_exec($sql) or errDie("Unable to retrieve stock items from database."); if (pg_numrows($stkpRslt) < 1) { return "<li class='err'> There are no stock item on the selected pricelist.</li>"; } while ($stkp = pg_fetch_array($stkpRslt)) { db_connect(); # get stock details $sql = "SELECT stkid, stkcod, stkdes FROM stock WHERE stkid = '{$stkp['stkid']}' AND div = '" . USER_DIV . "'"; $stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database."); $stk = pg_fetch_array($stkRslt); $enter .= "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>{$stk['stkcod']} - " . extlib_rstr($stk['stkdes'], 30) . "</td>\r\n\t\t\t\t\t<td align='right'>" . CUR . " " . sprint($stkp['price']) . " {$vattype}</td>\r\n\t\t\t\t</tr>"; } $enter .= "\r\n\t\t\t</table>"; $OUTPUT = $enter; require "temp.xls.php"; Stream("Pricelist", $OUTPUT); return $OUTPUT; }
function view_data($_GET) { foreach ($_GET as $key => $value) { ${$key} = $value; } # validate input require_lib("validate"); $v = new validate(); $v->isOk($id, "num", 1, 100, "Invalid num."); # 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; } 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"; } $set = pg_fetch_array($Rslt); # Get group db_connect(); $sql = "SELECT * FROM assetgrp WHERE grpid = '{$set['grpid']}' AND div = '" . USER_DIV . "'"; $grpRslt = db_exec($sql); $grp = pg_fetch_array($grpRslt); # Get Transactions db_connect(); $sql = "SELECT * FROM assetledger WHERE assetid = '{$id}'"; $tranRslt = db_exec($sql); $trans = ""; while ($tran = pg_fetch_array($tranRslt)) { # Format date $tran['date'] = explode("-", $tran['date']); $tran['date'] = $tran['date'][2] . "-" . $tran['date'][1] . "-" . $tran['date'][0]; $tran['depamt'] = sprint($tran['depamt']); $tran['netval'] = sprint($tran['netval']); $trans .= "\r\n\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t<td>{$tran['date']}</td>\r\n\t\t\t\t\t\t<td align='right'>" . CUR . " {$tran['depamt']}</td>\r\n\t\t\t\t\t\t<td align='right'>" . CUR . " {$tran['netval']}</td>\r\n\t\t\t\t\t</tr>"; } $view_data = "\r\n\t\t\t\t<h3>Depreciation Report</h3>\r\n\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t<tr valign='top'>\r\n\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<th colspan='2'>Asset Details</th>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t<td>Group</td>\r\n\t\t\t\t\t\t\t\t\t<td>{$grp['grpname']}</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t<td>Description</td>\r\n\t\t\t\t\t\t\t\t\t<td>{$set['des']}</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t<td>Date Bought</td>\r\n\t\t\t\t\t\t\t\t\t<td>{$set['bdate']}</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t<td>Cost Amount</td>\r\n\t\t\t\t\t\t\t\t\t<td>{$set['amount']}</td>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>\r\n\t\t\t\t<br>\r\n\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<th>Date</th>\r\n\t\t\t\t\t\t<th>Accum Depreciation</th>\r\n\t\t\t\t\t\t<th>Net Value</th>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t{$trans}\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-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 $view_data; }
function show_receipt($_GET) { extract($_GET); if (!isset($recid) or strlen($recid) < 1) { return "<li class='err'>Invalid use of module. Invalid Receipt ID.</li>"; } db_connect(); $get_rec = "SELECT * FROM cashbook WHERE cashid = '{$recid}' LIMIT 1"; $run_rec = db_exec($get_rec) or errDie("Unable to get receipt information."); if (pg_numrows($run_rec) < 1) { return "<li class='err'>Receipt information not found.</li>"; } else { $cash_arr = pg_fetch_array($run_rec); #get customer information $get_cust = "SELECT accno,surname,paddr1 FROM customers WHERE cusnum = '{$cash_arr['cusnum']}' LIMIT 1"; $run_cust = db_exec($get_cust) or errDie("Unable to get customer information."); if (pg_numrows($run_cust) < 1) { $cus_addr = ""; $cus_accno = ""; } else { $cus_arr = pg_fetch_array($run_cust); $cus_addr = $cus_arr['paddr1']; $cus_accno = $cus_arr['accno']; } $inv_ids = explode("|", $cash_arr['rinvids']); $inv_amts = explode("|", $cash_arr['amounts']); $null1 = array_shift($inv_ids); $null2 = array_shift($inv_amts); $listing = ""; $total = 0; foreach ($inv_ids as $key => $each) { $listing .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$cash_arr['date']}</td>\n\t\t\t\t\t<td>{$cash_arr['reference']}</td>\n\t\t\t\t\t<td>" . CUR . " " . sprint($inv_amts[$key]) . "</td>\n\t\t\t\t</tr>"; $total = $total + $inv_amts[$key]; } $unalloc = $cash_arr['amount'] - $total; if ($unalloc > 0) { $listing .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$cash_arr['date']}</td>\n\t\t\t\t\t<td>{$cash_arr['reference']} (Unallocated)</td>\n\t\t\t\t\t<td>" . CUR . " " . sprint($unalloc) . "</td>\n\t\t\t\t</tr>"; $total += $unalloc; } $listing .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><b>Total:</b></td>\n\t\t\t\t<td>" . CUR . " " . sprint($total) . "</td>\n\t\t\t</tr>"; $receiptnumber = $cash_arr['cashid']; } $comments = getCSetting("DEFAULT_BANK_RECPT_COMMENTS"); $rborder = "style='border-right: 2px solid #000'"; $display = "\n\t\t<style>\n\t\t\ttable { border: 2px solid #000 }\n\t\t</style>\n\t\t<table border='0' cellpadding='2' cellspacing='2' width='80%' align='center'>\n\t\t\t<tr>\n\t\t\t\t<td width='30%'></td>\n\t\t\t\t<td align='center'><font size='5'><b>" . COMP_NAME . "</b></font></td>\n\t\t\t\t<td align='right'><font size='4'><b>Customer Receipt</b></font></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<table cellpadding='1' cellspacing='0' width='80%' align='center'>\n\t\t\t<tr>\n\t\t\t\t<td {$rborder}>\n\t\t\t\t\t<b>" . COMP_NAME . "</b><br>\n\t\t\t\t\t" . COMP_ADDRESS . "<br>\n\t\t\t\t\t" . COMP_PADDR . "\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<b>Received From:</b><br>\n\t\t\t\t\t{$cash_arr['name']}<br>\n\t\t\t\t\t{$cus_addr}<br>\n\t\t\t\t\t<br>\n\t\t\t\t\t<b>Account Number:</b> {$cus_accno}<br>\n\t\t\t\t\t<b>Receipt Number:</b> {$receiptnumber}\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<table " . TMPL_tblDflts . " width='80%' align='center'>\n\t\t\t<tr>\n\t\t\t\t<td><b>Date</b></td>\n\t\t\t\t<td><b>Ref Num</b></td>\n\t\t\t\t<td><b>Amount</b></td>\n\t\t\t</tr>\n\t\t\t{$listing}\n\t\t\t" . TBL_BR . "\n\t\t\t" . TBL_BR . "\n\t\t</table>\n\t\t<p>\n\t\t<table " . TMPL_tblDflts . " width='80%' align='center'>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td width='60%'>" . nl2br(base64_decode($comments)) . "</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></td>\n\t\t\t\t<td align='center'>Signature</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<div style='position:absolute;left:11%'>\n\t\t<font size='1'>© Cubit Accounting Software</font>\n\t\t</div>"; return $display; }
function get_report_parms($_POST, $err = "") { extract($_POST); db_connect(); $view_report = ""; if (isset($search) and strlen($search) > 0) { if (!isset($medical_aid) or !is_array($medical_aid)) { unset($_POST["search"]); return get_report_parms($_POST, "<li class='err'>Please Select At Least One Medical Aid.</li>"); } foreach ($medical_aid as $mid) { $med_total = 0; $get_med = "SELECT * FROM medical_aid WHERE id = '{$mid}' LIMIT 1"; $run_med = db_exec($get_med) or errDie("Unable to get medical aid information."); $marr = pg_fetch_array($run_med); $view_report .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='3'>{$marr['medical_aid_name']}</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Contact</td>\n\t\t\t\t\t<td colspan='2'>{$marr['medical_aid_contact_number']}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Bank Name</td>\n\t\t\t\t\t<td colspan='2'>{$marr['medical_aid_bank_name']}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Bank Branch</td>\n\t\t\t\t\t<td colspan='2'>{$marr['medical_aid_bank_branch']}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Bank Account</td>\n\t\t\t\t\t<td colspan='2'>{$marr['medical_aid_bank_account']}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Employee Name</th>\n\t\t\t\t\t<th>Medical Aid Number</th>\n\t\t\t\t\t<th>Contribution Amount</th>\n\t\t\t\t</tr>"; #get all emps using this medical aid $get_emps = "SELECT * FROM employees WHERE medical_aid = '{$mid}' ORDER BY sname, fnames"; $run_emps = db_exec($get_emps) or errDie("Unable to get employee information."); if (pg_numrows($run_emps) > 0) { while ($earr = pg_fetch_array($run_emps)) { $earr['comp_medical'] += 0; $view_report .= "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>{$earr['sname']}, {$earr['fnames']}</td>\n\t\t\t\t\t\t\t<td>{$earr['medical_aid_number']}</td>\n\t\t\t\t\t\t\t<td align='right'>" . CUR . " " . sprint($earr['comp_medical']) . "</td>\n\t\t\t\t\t\t</tr>"; $med_total += $earr['comp_medical']; } $view_report .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<th colspan='2'>Total</th>\n\t\t\t\t\t\t<td align='right'>" . CUR . " " . sprint($med_total) . "</td>\n\t\t\t\t\t</tr>"; } else { $view_report .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td colspan='3'>No Employees Using This Medical Aid Option.</td>\n\t\t\t\t\t</tr>"; } $view_report .= "<tr><td><br></td></tr>"; } } $get_meds = "SELECT * FROM medical_aid ORDER BY medical_aid_name"; $run_meds = db_exec($get_meds) or errDie("Unable to get medical aid information."); if (pg_numrows($run_meds) > 0) { $medical_aid_drop = "<select name='medical_aid[]' multiple size='5'>"; while ($marr = pg_fetch_array($run_meds)) { $medical_aid_drop .= "<option value='{$marr['id']}'>{$marr['medical_aid_name']}</option>"; } $medical_aid_drop .= "</select>"; } else { $medical_aid_drop = "No Medical Aid Options Found."; } $display = "\n\t\t<h3>Medical Aid Report</h3>\n\t\t{$err}\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Medical Aid Options</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$medical_aid_drop}</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<td align='right'><input type='submit' name='search' value='Search'></td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t{$view_report}\n\t\t</table>\n\t\t</form>"; return $display; }
function win($_POST) { # get vars foreach ($_POST as $key => $value) { ${$key} = $value; } /* --------------------------- bal ------------------------------*/ $report = ""; core_connect(); $sql = "SELECT * FROM trialgrpaccids WHERE gkey = '{$gkey}'"; $gaccRslt = db_exec($sql) or errDie("Unable to get group accounts information."); while ($gacc = pg_fetch_array($gaccRslt)) { $sql = "SELECT * FROM trial_bal WHERE accid = '{$gacc['accid']}' AND div = '" . USER_DIV . "'"; $accRslt = db_exec($sql) or errDie("Unable to view account."); $acc = pg_fetch_array($accRslt); $report .= "<tr class='bg-even'><td>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</td>"; if (true) { if ($acc['debit'] > $acc['credit']) { $acc['debit'] = sprint($acc['debit'] - $acc['credit']); $acc['credit'] = 0; } if ($acc['credit'] > $acc['debit']) { $acc['credit'] = sprint($acc['credit'] - $acc['debit']); $acc['debit'] = 0; } if ($acc['credit'] == $acc['debit']) { $acc['credit'] = 0; $acc['debit'] = 0; } } if (floatval($acc['debit']) == 0) { $report .= "<td align=right> - </td>"; } else { $report .= "<td align=right>{$acc['debit']}</td>"; } if (floatval($acc['credit']) == 0) { $report .= "<td align=right> - </td>"; } else { $report .= "<td align=right>{$acc['credit']}</td>"; } $report .= "</tr>"; } /* -- Final Layout -- */ $details = "<center><h3>Trial Balance Note 000/00{$gkey}</h3>\r\n\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' border=0 width=360>\r\n\t<tr><th>Accounts</th><th>Debit</th><th>Credit</th></tr>\r\n\t{$report}\r\n\t<tr><td><br></td></tr>\r\n\t<tr><td colspan=3 align=center><input type=button value='[X]Close' onClick='javascript:window.close();'></td></tr>\r\n\t</table>"; return $details; }
function details($_GET) { # get vars extract($_GET); # validate input require_lib("validate"); $v = new validate(); $v->isOk($rpurid, "num", 1, 20, "Invalid purchase number."); $v->isOk($prd, "num", 1, 20, "Invalid period Database number."); # display errors, if any if ($v->isError()) { $err = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $err .= "<li class='err'>" . $e["msg"] . "</li>"; } return $confirm; } db_conn($prd); $sql = "SELECT * FROM rnons_purch_int WHERE purid='{$rpurid}'"; $purRslt = db_exec($sql) or errDie("Unable to retrieve purchase information from Cubit."); $pur = pg_fetch_array($purRslt); /* --- Start Products Display --- */ # Products layout $products = "\r\n\t<table " . TMPL_tblDflts . " width=100%>\r\n\t<tr>\r\n\t\t<th>ITEM NUMBER</th>\r\n\t\t<th>DESCRIPTION</th>\r\n\t\t<th>QTY</th>\r\n\t\t<th>UNIT PRICE</th>\r\n\t\t<th>AMOUNT</th>\r\n\t<tr>"; # get selected stock in this purchase db_conn($prd); $sql = "SELECT * FROM rnons_purint_items WHERE purid='{$rpurid}'"; $stkdRslt = db_exec($sql); while ($stkd = pg_fetch_array($stkdRslt)) { $amt = sprint($stkd['unitcost'] * $stkd['qty']); # put in product $products .= "\r\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t<td>{$stkd['cod']}</td>\r\n\t\t\t\t\t\t\t<td>{$stkd['des']}</td>\r\n\t\t\t\t\t\t\t<td align='right'>{$stkd['qty']}</td>\r\n\t\t\t\t\t\t\t<td align='right' nowrap>" . CUR . " {$stkd['unitcost']}</td>\r\n\t\t\t\t\t\t\t<td align='right' nowrap>" . CUR . " {$amt}</td>\r\n\t\t\t\t\t\t</tr>"; } $products .= "</table>"; /* --- Start Some calculations --- */ # Get subtotal $SUBTOT = sprint($pur['subtot']); /* --- End Some calculations --- */ # format date list($ryear, $rmon, $rday) = explode("-", $pur['rdate']); /* -- Final Layout -- */ $details = "\r\n\t\t\t\t\t<center>\r\n\t\t\t\t\t<h3>Returned International Non Stock Purchase Details</h3>\r\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='95%'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td valign='top'>\r\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Supplier Details </th>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td>Supplier</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['supplier']}</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='top'>Supplier Address</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>" . nl2br($pur['supaddr']) . "</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td valign='top' align='right'>\r\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Purchase Details </th>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td>Purchase No.</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['purnum']}</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td>Delivery Ref No.</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['refno']}</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td>Terms</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['terms']} Days</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td>Date</td>\r\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$rday}-{$rmon}-{$ryear}</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr><td> </td></tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td colspan='2'>{$products}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th width='50%'>Quick Links</th>\r\n\t\t\t\t\t\t\t\t\t\t<th width='45%'>Remarks</th>\r\n\t\t\t\t\t\t\t\t\t\t<td rowspan='5' valign='top' width='15%'><br></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t\t<a href='purch-int-new.php'>New International Purchase</a>\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td class='" . bg_class() . "' rowspan='4' align='center' valign='top'>\r\n\t\t\t\t\t\t\t\t\t\t\t" . nl2br($pur['remarks']) . "\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td><a href='purch-int-view-prd.php'>View Received International Purchases</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<td><a href='main.php'>Main Menu</a></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td align='right'>\r\n\t\t\t\t\t\t\t\t<table " . TMPL_tblDflts . " width='80%'>\r\n\t\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t\t\t\t\t\t<th>Total Cost Returned</th>\r\n\t\t\t\t\t\t\t\t\t\t<td align='right' nowrap>{$pur['curr']} {$SUBTOT}</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t\t</form>\r\n\t\t\t\t\t</center>"; return $details; }
private static function output_file_content($filename, $disposition) { if ($filename instanceof \org\rhaco\io\File) { if (is_file($filename->fullname())) { $filename = $filename->fullname(); } else { \org\rhaco\net\http\Header::send('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT'); \org\rhaco\net\http\Header::send('Content-Type', $filename->mime() . '; name=' . $filename->name()); \org\rhaco\net\http\Header::send('Content-Disposition', $disposition . '; filename=' . $filename->name()); print $filename->value(); exit; } } if (is_file($filename)) { $update = @filemtime($filename); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $update <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { \org\rhaco\net\http\Header::send_status(304); exit; } \org\rhaco\net\http\Header::send('Last-Modified', gmdate('D, d M Y H:i:s', $update) . ' GMT'); \org\rhaco\net\http\Header::send('Content-Type', self::mime($filename) . '; name=' . basename($filename)); \org\rhaco\net\http\Header::send('Content-Disposition', $disposition . '; filename=' . basename($filename)); if (isset($_SERVER['HTTP_RANGE']) && preg_match("/^bytes=(\\d+)\\-(\\d+)\$/", $_SERVER['HTTP_RANGE'], $range)) { list($null, $offset, $end) = $range; $length = $end - $offset + 1; \org\rhaco\net\http\Header::send_status(206); \org\rhaco\net\http\Header::send('Accept-Ranges', 'bytes'); \org\rhaco\net\http\Header::send('Content-length', sprint('%u', $length)); \org\rhaco\net\http\Header::send('Content-Range', sprintf('bytes %u-%u/%u', $offset, $end, filesize($filename))); print file_get_contents($filename, null, null, $offset, $length); exit; } else { \org\rhaco\net\http\Header::send('Content-length', sprintf('%u', filesize($filename))); $fp = fopen($filename, 'rb'); while (!feof($fp)) { echo fread($fp, 8192); flush(); } fclose($fp); exit; } } \org\rhaco\net\http\Header::send_status(404); exit; }