function display() { extract($_REQUEST); $fields = array(); $fields["date_year"] = date("Y"); $fields["date_month"] = date("m"); $fields["date_day"] = date("d"); extract($fields, EXTR_SKIP); $date = dateFmt($date_year, $date_month, $date_day); for ($i = 0; $i < 2; $i++) { if ($i) { $collection = "collect"; } else { $collection = "deliver"; } $sql = "SELECT * FROM hire.collection\r\n\t\t\t\tWHERE {$collection}='1'\r\n\t\t\t\t\tAND time BETWEEN '{$date} 0:00:00' AND '{$date} 23:59:59'"; $clct_rslt = db_exec($sql) or errDie("Unable to retrieve collection."); while ($clct_data = pg_fetch_array($clct_rslt)) { if (!$clct_data["item_id"]) { continue; } $sql = "SELECT * FROM cubit.assets WHERE id='{$clct_data['asset_id']}'"; $asset_rslt = db_exec($sql) or errDie("Unable to retrieve assets."); $sql = "SELECT * FROM hire.hire_invitems WHERE id='{$clct_data['item_id']}'"; $item_rslt = db_exec($sql) or errDie("Unable to retrieve items."); $item_data = pg_fetch_array($item_rslt); if (empty($item_data["invid"])) { continue; } $sql = "SELECT * FROM hire.hire_invoices WHERE invid='{$item_data['invid']}'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoices."); $inv_data = pg_fetch_array($inv_rslt); while ($asset_data = pg_fetch_array($asset_rslt)) { ${$collection} .= "<tr class='" . bg_class() . "'>\r\n\t\t\t\t\t<td>H" . getHirenum($inv_data["invid"], 1) . "</td>\r\n\t\t\t\t\t<td>{$asset_data['des']}</td>\r\n\t\t\t\t\t<td>{$inv_data['cusname']} {$inv_data['surname']}</td>\r\n\t\t\t\t\t<td>" . hireAddress($inv_data["invid"]) . "</td>\r\n\t\t\t\t\t<td>" . getSerial($asset_data["id"]) . "</td>\r\n\t\t\t\t</tr>"; } } if (empty(${$collection})) { ${$collection} = "<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td colspan='5'><li>No results found.</li></td>\r\n\t\t\t</tr>"; } } $OUTPUT = "<center>\r\n\t<h3>Collect and Deliver Report</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr><th colspan='2'>Date</th></tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>" . mkDateSelect("date", $date_year, $date_month, $date_day) . "</td>\r\n\t\t\t<td><input type='submit' value='Select' style='font-weight: bold' /></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 colspan='5'>Deliver</th>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<th>Hire No</th>\r\n\t\t\t<th>Asset</th>\r\n\t\t\t<th>Customer</th>\r\n\t\t\t<th>Address</th>\r\n\t\t\t<th>Serial</th>\r\n\t\t</tr>\r\n\t\t{$deliver}\r\n\t\t<tr>\r\n\t\t\t<th colspan='5'>Collect</th>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<th>Hire No</th>\r\n\t\t\t<th>Asset</th>\r\n\t\t\t<th>Customer</th>\r\n\t\t\t<th>Address</th>\r\n\t\t\t<th>Serial</th>\r\n\t\t</tr>\r\n\t\t{$collect}\r\n\t</table>\r\n\t</center>"; return $OUTPUT; }
function details($_GET) { $showvat = TRUE; # get vars extract($_GET); # validate input require_lib("validate"); $v = new validate(); $v->isOk($invid, "num", 1, 20, "Invalid invoice number."); # display errors, if any if ($v->isError()) { $err = ""; $errors = $v->getErrors(); foreach ($errors as $e) { $err .= "<li class='err'>{$e['msg']}</li>"; } $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>"; return $confirm; } updateTotals($invid); # Get invoice info $sql = "SELECT *, extract('epoch' from timestamp) AS e_time\r\n\t\t\t\tFROM hire.reprint_invoices\r\n\t\t\t\tWHERE invid = '{$invid}' AND div = '" . USER_DIV . "'"; $invRslt = db_exec($sql) or errDie("Unable to get invoice information"); if (pg_numrows($invRslt) < 1) { return "<i class='err'>Not Found[1]</i>"; } $inv = pg_fetch_array($invRslt); # get department db_conn("exten"); $sql = "SELECT * FROM departments WHERE deptid = '{$inv['deptid']}' AND div = '" . USER_DIV . "'"; $deptRslt = db_exec($sql); if (pg_numrows($deptRslt) < 1) { $dept['deptname'] = "<i class='err'>Not Found[2]</i>"; } else { $dept = pg_fetch_array($deptRslt); } /* --- Start some checks --- */ # check if stock was selected(yes = put done button) $sql = "SELECT asset_id FROM hire.reprint_invitems WHERE invid = '{$inv['invid']}'"; $crslt = db_exec($sql); if (pg_numrows($crslt) < 1) { $error = "<li class='err'> Error : Invoice number <b>{$invid}</b> has no items.</li>"; return $error; } /* --- End some checks --- */ /* --- Start Products Display --- */ # Products layout $products = ""; $disc = 0; # get selected stock in this invoice $sql = "SELECT * FROM hire.reprint_invitems WHERE invid = '{$invid}'"; $stkdRslt = db_exec($sql); $tcosamt = 0; while ($stkd = pg_fetch_array($stkdRslt)) { # get selected stock in this warehouse db_connect(); $sql = "SELECT * FROM assets WHERE id = '{$stkd['asset_id']}'"; $stkRslt = db_exec($sql); $stk = pg_fetch_array($stkRslt); $sp = " "; # keep track of discounts $disc += $stkd['disc']; if ($stkd['account'] != 0) { $stk['stkcod'] = $stkd['description']; $stk['stkdes'] = ""; } $Sl = "SELECT * FROM vatcodes WHERE id='{$stkd['vatcode']}'"; $Ri = db_exec($Sl); $vd = pg_fetch_array($Ri); if (TAX_VAT != $vd['vat_amount'] and $vd['vat_amount'] != "0.00") { $showvat = FALSE; } # put in product $stkd['unitcost'] = $stkd['unitcost'] - $stkd['disc']; $return = returnDate($stkd["item_id"]); $hired = hiredDate($stkd["item_id"]); $products .= "\r\n\t\t\t\t<tr valign=top>\r\n\t\t\t\t\t<td>" . getSerial($stk["id"], 1) . " {$stk['des']} ({$stkd['collection']})</td>\r\n\t\t\t\t\t<td>{$stkd['qty']}</td>\r\n\t\t\t\t\t<td>{$hired}</td>\r\n\t\t\t\t\t<td>{$return}</td>\r\n\t\t\t\t\t<td align=right>" . sprint($stkd["amt"]) . "</td>\r\n\t\t\t\t</tr>"; $client_collect = 0; $collect = 0; $deliver = 0; if (preg_match("/(Client Collect|collect)/", $stkd["collection"])) { $client_collect = 1; } if (preg_match("/(^Collect|, Collect)/", $stkd["collection"])) { $collect = 1; } if (preg_match("/Deliver/", $stkd["collection"])) { $deliver = 1; } } /* --- Start Some calculations --- */ # subtotal $SUBTOT = sprint($inv['subtot']); # Calculate tradediscm $traddiscm = $inv["discount"]; // if(strlen($inv['traddisc']) > 0){ // $traddiscm = sprint((($inv['traddisc']/100) * $SUBTOT)); // }else{ // $traddiscm = "0.00"; // } # Calculate subtotal $VATP = TAX_VAT; $SUBTOT = sprint($inv['subtot']); $VAT = sprint($inv['vat']); $TOTAL = sprint($inv['total']); $inv['delchrg'] = sprint($inv['delchrg']); # Update number of prints // $inv['prints']++; // db_conn($prd); // $Sql = "UPDATE hire.reprint_invitems SET prints = '$inv[prints]' WHERE invid = '$invid' AND div = '".USER_DIV."'"; // $upRslt = db_exec($Sql) or errDie ("Unable to update invoice information"); # todays date $date = date("d-m-Y"); $sdate = date("Y-m-d"); if (strlen($inv['comm']) > 0) { $Com = "\r\n\t\t\t\t<table>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td>" . nl2br($inv['comm']) . "</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>"; } else { $Com = ""; } $time = date("G:i:s", $inv["e_time"]); if (isset($cccc)) { $cc = "<script> sCostCenter('dt', 'Sales', '{$date}', 'Invoice No.{$inv['invnum']} for Customer {$inv['cusname']} {$inv['surname']}', '" . ($TOTAL - $VAT) . "', 'Cost Of Sales for Invoice No.{$inv['invnum']}', '{$tcosamt}', ''); </script>"; } else { $cc = ""; } db_conn('cubit'); $Sl = "SELECT * FROM settings WHERE constant='PSALES'"; $Ri = db_exec($Sl) or errDie("Unable to get settings."); $data = pg_fetch_array($Ri); if ($data['value'] == "Yes") { $sp = "<tr><td>Sales Person</td><td>{$inv['salespn']}</td></tr>"; } else { $sp = ""; } $Sl = "SELECT * FROM pc WHERE inv='{$inv['invnum']}'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); if (pg_num_rows($Ri) > 0) { $pd = pg_fetch_array($Ri); //$pc="<tr><td>Change</td><td align=right><b>".CUR." $pd[amount]</b></td></tr>"; $pc = ""; $change = $pd['amount']; } else { $pc = ""; $change = 0; } $Sl = "SELECT * FROM payrec WHERE inv='{$inv['invnum']}' AND method='Cash'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); if (pg_num_rows($Ri) > 0) { $pd = pg_fetch_array($Ri); $pd['amount'] = sprint($pd['amount'] + $change); $pcash = "<!--<tr><td>Paid Cash</td><td align=right><b>" . CUR . " {$pd['amount']}</b></td></tr>-->"; } else { $pcash = ""; } $Sl = "SELECT * FROM payrec WHERE inv='{$inv['invnum']}' AND method='Cheque'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); if (pg_num_rows($Ri) > 0) { $pd = pg_fetch_array($Ri); $pcheque = "<tr><td>Paid Cheque</td><td align=right><b>" . CUR . " {$pd['amount']}</b></td></tr>"; } else { $pcheque = ""; } $Sl = "SELECT * FROM payrec WHERE inv='{$inv['invnum']}' AND method='Credit Card'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); if (pg_num_rows($Ri) > 0) { $pd = pg_fetch_array($Ri); $pcc = "<tr><td>Paid Credit Card</td><td align=right><b>" . CUR . " {$pd['amount']}</b></td></tr>"; } else { $pcc = ""; } $Sl = "SELECT * FROM payrec WHERE inv='{$inv['invnum']}' AND method='Credit'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); if (pg_num_rows($Ri) > 0) { $pd = pg_fetch_array($Ri); $pcc .= "<tr><td>On Credit</td><td align=right><b>" . CUR . " {$pd['amount']}</b></td></tr>"; } else { $pcc .= ""; } // $Sl="SELECT * FROM varrec WHERE inv='$inv[invnum]'"; // $Ri=db_exec($Sl); // // if(pg_num_rows($Ri)>0) { // $rd=pg_fetch_array($Ri); // // $rounding="<tr><td>Rounding</td><td align=right>".CUR." $rd[amount]</td></tr>"; // } else { // $rounding=""; // } // if ($inv['rounding'] > 0) { $due = sprint($inv['total'] - $inv['rounding']); $rounding = "\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>Rounding</td>\r\n\t\t\t\t\t<td align='right'>" . CUR . " {$inv['rounding']}</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>Amount Due</td>\r\n\t\t\t\t\t<td align='right'>" . CUR . " {$due}</td>\r\n\t\t\t\t</tr>"; } else { $rounding = ""; } $cusinfo = ""; if ($inv['cusnum'] > 0) { db_conn('cubit'); $Sl = "SELECT * FROM customers WHERE cusnum='{$inv['cusnum']}'"; $Ri = db_exec($Sl) or errDie("Unable to get data."); $cd = pg_fetch_array($Ri); $inv['cusname'] = $cd['surname'] . " (VAT No. {$cd['vatnum']})"; $cusinfo .= "<p>" . hireAddress($inv["invid"]) . "</p>"; $cusinfo .= "Tel: {$cd['bustel']}<br />"; $cusinfo .= "Order No: {$inv['cordno']}"; } else { if (strlen($inv['vatnum']) > 1) { $inv['cusname'] = "{$inv['cusname']} (VAT No. {$inv['vatnum']})<br />"; $cusinfo .= "Order No: {$inv['cordno']}"; } } db_conn('cubit'); $Sl = "SELECT img2 FROM compinfo"; $Ri = db_exec($Sl); $id = pg_fetch_array($Ri); if (strlen($id['img2']) > 0) { $logo = "<tr>\r\n\t\t\t<td valign='top' width='100%' align=center><img src='compinfo/getimg2.php' width='230' height='47'></td>\r\n\t\t</tr>"; } else { $logo = ""; } $sql = "SELECT value FROM cubit.settings WHERE constant='CONTRACT_TEXT'"; $contract_rslt = db_exec($sql) or errDie("Unable to retrieve contract."); $contract_text = nl2br(base64_decode(pg_fetch_result($contract_rslt, 0))); if (!isset($showvat)) { $showvat = TRUE; } if ($showvat == TRUE) { $vat14 = AT14; } else { $vat14 = ""; } $sql = "SELECT text FROM hire.thanks_text"; $thanks_rslt = db_exec($sql) or errDie("Unable to retrieve thank you text."); $thank_you = pg_fetch_result($thanks_rslt, 0); $details = "<center>\r\n\t<style>\r\n\t\th2 {\r\n\t\t\tfont-size: 2em;\r\n\t\t\tpadding: 0;\r\n\t\t\tmargin: 0;\r\n\t\t}\r\n\t\tth {\r\n\t\t\tfont-weight: bold;\r\n\t\t\ttext-align: left;\r\n\t\t}\r\n\t\t.print_input {\r\n\t\t\tfont-family: monospace;\r\n\t\t\tfont-weight: bold;\r\n\t\t}\r\n\t</style>\r\n\t<table cellpadding='0' cellspacing='1' border=1 width='97%'>\r\n\t<tr><td>\r\n\t\t<table cellpadding='5' cellspacing='0' width='100%'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><img src='../compinfo/getimg.php' width='230' height='47' /></td>\r\n\t\t\t\t<td align='right'><h2>HIRE NOTE</h2></td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t</tr></td>\r\n\t<tr><td>\r\n\t\t<table border='1' width='100%'>\r\n\t\t<tr>\r\n\t\t\t<td valign=top width='50%'>\r\n\t\t\t\t" . COMP_NAME . "<br />\r\n\t\t\t\t" . COMP_ADDRESS . "<br />\r\n\t\t\t\tTEL: " . COMP_TEL . "<br />\r\n\t\t\t\tFAX: " . COMP_FAX . "<br />\r\n\t\t\t\tRegistration Number: " . COMP_REGNO . "<br />\r\n\t\t\t\tVAT Registration Number: " . COMP_VATNO . "<br />\r\n\t\t\t</td>\r\n\t\t\t<td valign='top' width='50%'>\r\n\t\t\t\t{$inv['cusname']}<br />\r\n\t\t\t\t{$cusinfo}\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t</table>\r\n\t</td></tr>\r\n\t<tr><td>\r\n\t\t<table " . TMPL_tblDflts . " width='100%'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align='left' width='25%'>\r\n\t\t\t\t\tNote: H{$inv['invnum']}" . rrev($inv["invid"]) . "\r\n\t\t\t\t</td>\r\n\t\t\t\t<td align='center' width='25%'>CASHIER: {$inv['username']}</td>\r\n\t\t\t\t<td width='25%' align='center'>Time: {$time}</td>\r\n\t\t\t\t<td width='25%' align='right'>{$inv['odate']}</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t</td></tr>\r\n\t<tr><td>\r\n\t<table cellpadding='5' cellspacing='0' border='0' width='100%' bordercolor='#000000'>\r\n\t\t<tr>\r\n\t\t\t<th>CODE</th>\r\n\t\t\t<th>QTY</th>\r\n\t\t\t<th>HIRE DATE</th>\r\n\t\t\t<th>RETURN</th>\r\n\t\t\t<th style='text-align: right'>TOTAL</th>\r\n\t\t<tr>\r\n\t\t{$products}\r\n\t</table>\r\n\t</td></tr>\r\n\t<tr>\r\n\t\t<td valign='top'>\r\n\t\t<table width='100%'>\r\n\t\t<tr><td valign='top'>\r\n\t\t<table cellpadding='2' cellspacing='0' width='80%'>\r\n\t\t\t<tr><td colspan='2'>{$thank_you}</td></tr>\r\n\t\t\t<tr><td>{$Com}</td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t<font style='font-size: 0.75em'>" . nl2br($inv["custom_txt"]) . "<br />\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td> </td></tr>\r\n\t\t</table>\r\n\t\t</td>\r\n\t\t<td align=right valign='top'>\r\n\t\t<table cellpadding='2' cellspacing='0' width='50%'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>Delivery Charge</td>\r\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$inv['delchrg']}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>Trade Discount</td>\r\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$traddiscm}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>SUBTOTAL</td>\r\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$SUBTOT}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>VAT {$vat14}</td>\r\n\t\t\t\t<td align='right' nowrap>" . CUR . " {$VAT}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td nowrap>GRAND TOTAL</td>\r\n\t\t\t\t<td align='right' nowrap><b>" . CUR . " {$TOTAL}</b></td>\r\n\t\t\t</tr>\r\n\t\t\t{$sp}\r\n\t\t</table>\r\n\t</td></tr>\r\n\t\t<table cellpadding='2' cellspacing='0' width='100%' border='1'>\r\n\t\t\t<tr><td colspan='2'>\r\n\t\t\t<div style='font-size: .80em;'>" . stripslashes($contract_text) . "</div></div>\r\n\t\t\t</td></tr>\r\n\t\t\t<tr><td colspan='2'> </td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>Full Names (Print) ____________________________</td>\r\n\t\t\t\t<td>Identity Number ____________________________</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td colspan='2'> </td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>Signature - Customer ____________________________</td>\r\n\t\t\t\t<td>Signature - Authorized Agent ____________________________</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t</td></tr>\r\n\t</td></tr>\r\n\t</table>\r\n\t</table>\r\n\t</center>"; $OUTPUT = $details; require "../tmpl-print.php"; }