function rev($n, $cnt = 0, $reva = []) { if ($cnt == count($n)) { return $reva; } $reva[] = $n[count($n) - 1 - $cnt]; return rev($n, $cnt + 1, $reva); }
function display($msg = "") { extract($_REQUEST); $fields = array(); $fields["search"] = "~:BLANK:~"; extract($fields, EXTR_SKIP); removeDead(); $sql = "SELECT invid FROM hire.hire_invoices WHERE done='y' AND printed='y'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve hire notes."); while ($inv_data = pg_fetch_array($inv_rslt)) { updateTotals($inv_data["invid"]); } // Retrieve invoices if ($search == "~:BLANK:~") { // We don't want any results at first $sql = "SELECT * FROM hire.hire_invoices WHERE cusnum='-1.23'"; $search = ""; } else { if (!empty($search)) { $sql = "SELECT * FROM hire.hire_invoices WHERE done='y'\r\n\t\t\t\t\tAND invnum ILIKE '%{$search}%'\r\n\t\t\t\tUNION\r\n\t\t\t\tSELECT * FROM hire.hire_invoices WHERE done='y'\r\n\t\t\t\t\tAND cusname ILIKE '%{$search}%'\r\n\t\t\t\tORDER BY invnum DESC"; } else { $sql = "SELECT * FROM hire.hire_invoices\r\n\t\t\t\t\tWHERE done='y'\r\n\t\t\t\t\tORDER BY invnum DESC"; } } $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoices."); $total = 0; $hires_out = ""; while ($inv_data = pg_fetch_array($inv_rslt)) { // Retrieve customer $sql = "SELECT * FROM cubit.customers WHERE cusnum='{$inv_data['cusnum']}'"; $cust_rslt = db_exec($sql) or errDie("Unable to retrieve customers."); $cust_data = pg_fetch_array($cust_rslt); $hires_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t<td>\r\n\t\t\t\t<a href='javascript:printer(\"hire/hire-invoice-new.php?invid={$inv_data['invid']}&reprint=1\")'>\r\n\t\t\t\t\tH{$inv_data['invnum']}" . rev($inv_data["invid"]) . "\r\n\t\t\t\t</a>\r\n\t\t\t</td>\r\n\t\t\t<td>{$cust_data['surname']}</td>\r\n\t\t\t<td>" . CUR . "{$inv_data['total']}</td>\r\n\t\t\t<td>\r\n\t\t\t\t<a href='hire-invoice-new.php?invid={$inv_data['invid']}&reprint=1'>\r\n\t\t\t\t\tView Hire\r\n\t\t\t\t</a>\r\n\t\t\t</td>\r\n\t\t\t<td>\r\n\t\t\t<a href='javascript:printer(\"hire/hire_note_reprint.php?invid={$inv_data['invid']}\")'>Reprint</a>\r\n\t\t\t</td>\r\n\t\t\t<!--<td><a href='hires_return.php?invid={$inv_data['invid']}'>Return</a></td>-->\r\n\t\t\t<!--<td><a href='hires_swap.php?invid={$inv_data['invid']}'>Swap</a></td>-->\r\n\t\t</tr>"; $total += $inv_data["total"]; } if (empty($hires_out)) { $hires_out = "<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='5'>Please enter a hire no or customer name</td>\r\n\t\t</tr>"; } if (isset($added)) { $msg = "<li class='err'>Item/s successfully hired out</li>"; } $OUTPUT = "<h3>View Hire</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 Client 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='Filter' /></td>\r\n\t\t</tr>\r\n\t</table>\r\n\t</form>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<td colspan='5'>{$msg}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<th>Hire No</td>\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{$hires_out}\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='2'><strong>Total</strong></td>\r\n\t\t\t<td>" . sprint($total) . "</td>\r\n\t\t\t<td colspan='4'> </td>\r\n\t\t</tr>\r\n\t</table>"; return $OUTPUT; }
function display() { extract($_REQUEST); $fields = array(); $fields["search"] = ""; extract($fields, EXTR_SKIP); $sql = "SELECT accno, customers.surname, bustel, invnum, des,\r\n\t\t\t\thire_invitems.id, hire_invitems.invid\r\n\t\t\tFROM hire.hire_invitems\r\n\t\t\t\tLEFT JOIN hire.hire_invoices\r\n\t\t\t\t\tON hire_invitems.invid=hire_invoices.invid\r\n\t\t\t\tLEFT JOIN cubit.customers\r\n\t\t\t\t\tON hire_invoices.cusnum=customers.cusnum\r\n\t\t\t\tLEFT JOIN cubit.assets\r\n\t\t\t\t\tON hire_invitems.asset_id=assets.id\r\n\t\t\tWHERE customers.surname ILIKE '%{$search}%' OR\r\n\t\t\t\tbustel ILIKE '%{$search}%' OR\tdes ILIKE '%{$search}%'"; $overdue_rslt = db_exec($sql) or errDie("Unable to retrieve hires."); $overdue_out = ""; $i = 0; while ($overdue_data = pg_fetch_array($overdue_rslt)) { if (!isOverdue($overdue_data["id"])) { continue; } $overdue_out .= "\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>{$overdue_data['accno']}</td>\r\n\t\t\t<td>{$overdue_data['surname']}</td>\r\n\t\t\t<td>{$overdue_data['bustel']}</td>\r\n\t\t\t<td>H{$overdue_data['invnum']}" . rev($overdue_data["invid"]) . "</td>\r\n\t\t\t<td>{$overdue_data['des']}</td>\r\n\t\t\t<td>" . returnDate($overdue_data["id"]) . "</td>\r\n\t\t</tr>"; } if (empty($overdue_out)) { $overdue_out = "<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>Overdue Hires Report</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr><th colspan='2'>Search</th></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>\r\n\t\t\t\t<input type='submit' value='Search' style='font-weight: bold' />\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>\r\n\t</form>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th>Acc No</th>\r\n\t\t\t<th>Company / Name</th>\r\n\t\t\t<th>Telephone</th>\r\n\t\t\t<th>Hire No</th>\r\n\t\t\t<th>Product Code</th>\r\n\t\t\t<th>Return Date</th>\r\n\t\t</tr>\r\n\t\t{$overdue_out}\r\n\t</table>"; return $OUTPUT; }
function invoiceHire() { extract($_REQUEST); pglib_transaction("BEGIN"); $sql = "SELECT * FROM hire.hire_invoices WHERE invid='{$invid}'"; $hi_rslt = db_exec($sql) or errDie("Unable to retrieve invoice."); $hi_data = pg_fetch_array($hi_rslt); $sql = "SELECT * FROM cubit.customers WHERE cusnum='{$hi_data['cusnum']}'"; $cust_rslt = db_exec($sql) or errDie("Unable to retrieve customer."); $cust_data = pg_fetch_array($cust_rslt); $sql = "SELECT * FROM core.accounts WHERE topacc='1050' AND accnum='000'"; $acc_rslt = db_exec($sql) or errDie("Unable to retrieve account."); $acc_data = pg_fetch_array($acc_rslt); // $sql = " // INSERT INTO hire.hire_invoices (deptid, cusnum, // deptname, cusacc, cusname, surname, cusaddr, cusvatno, cordno, // ordno, chrgvat, terms, traddisc, salespn, odate, delchrg, subtot, // vat, total, balance, comm, printed, done, div, username, rounding, // delvat, vatnum, pcash, pcheque, pcc, pcredit, invnum) // VALUES('$hi_data[deptid]', '$hi_data[cusnum]', // '$hi_data[deptname]', '$hi_data[cusacc]', '$hi_data[cusname]', // '$hi_data[surname]', '$hi_data[cusaddr]', '$hi_data[cusvatno]', // '$hi_data[cordno]', '$hi_data[ordno]', '$hi_data[chrgvat]', // '$hi_data[terms]', '$hi_data[traddisc]', '$hi_data[salespn]', // '$hi_data[odate]', '$hi_data[delchrg]', '$hi_data[subtot]', // '$hi_data[vat]' , '$hi_data[total]', '$hi_data[balance]', // '$hi_data[comm]', 'y', 'y', '".USER_DIV."', '".USER_NAME."', // '$hi_data[rounding]', '$hi_data[delvat]', '$hi_data[vatnum]', // '$hi_data[pcash]', '$hi_data[pcheque]', '$hi_data[pcc]', // '$hi_data[pcredit]', '$hi_data[invnum]')"; // db_exec($sql) or errDie("Unable to create new hire note."); // $in_invid = pglib_lastid("hire.hire_invoices", "invid"); // // $in_invnum = $hi_data["invnum"]; // // $sql = "UPDATE hire.hire_invoices SET invnum='$in_invnum' // WHERE invid='$in_invid'"; // db_exec($sql) or errDie("Unable to update hire no."); $hire_invnum = "{$hi_data['invnum']}" . rev($hi_data["invid"]); # Insert invoice to DB $sql = "\r\n\t\tINSERT INTO cubit.nons_invoices (\r\n\t\t\tcusnum, cusname, cusaddr, chrgvat, sdate, odate, \r\n\t\t\tsubtot, balance, vat, total, done, username, prd, \r\n\t\t\tinvnum, typ, div, accid, discount, delivery, \r\n\t\t\thire_invid, hire_invnum\r\n\t\t) VALUES (\r\n\t\t\t'{$cust_data['cusnum']}', '{$cust_data['surname']}', '{$cust_data['paddr1']}', 'yes', CURRENT_DATE, CURRENT_DATE, \r\n\t\t\t'{$hi_data['subtot']}', '{$hi_data['total']}', '{$hi_data['vat']}', '{$hi_data['total']}', 'n', '" . USER_NAME . "', '" . PRD_DB . "', \r\n\t\t\t'{$hi_data['invnum']}', 'inv', '" . USER_DIV . "','{$acc_data['accid']}', '{$hi_data['discount']}', '{$hi_data['delivery']}', \r\n\t\t\t'{$hi_data['invid']}', '{$hire_invnum}'\r\n\t\t)"; $rslt = db_exec($sql) or errDie("Unable to create template Non-Stock Invoice.", SELF); db_conn("hire"); $nons_invid = lastinvid(); db_conn("cubit"); $sql = "SELECT * FROM hire.hire_invitems WHERE invid='{$invid}'"; $hire_rslt = db_exec($sql) or errDie("Unable to retrieve hire items."); while ($hire_data = pg_fetch_array($hire_rslt)) { $sql = "SELECT des FROM cubit.assets WHERE id='{$hire_data['asset_id']}'"; $des_rslt = db_exec($sql) or errDie("Unable to retrieve asset."); $itemdes = pg_fetch_result($des_rslt, 0); if ($hire_data["basis"] == "per_hour") { $des = getSerial($hire_data["asset_id"], 1) . " {$itemdes} hired for {$hire_data['hours']} hours."; } elseif ($hire_data["basis"] == "per_day") { $des = getSerial($hire_data["asset_id"], 1) . " {$itemdes} hired from {$hire_data['from_date']} to {$hire_data['to_date']}."; } else { $des = getSerial($hire_data["asset_id"], 1) . " {$itemdes} hired for {$hire_data['weeks']} weeks."; } $sql = "\r\n\t\t\tINSERT INTO hire.hire_nons_inv_items (\r\n\t\t\t\tinvid, qty, description, div, amt, unitcost, vatex, \r\n\t\t\t\taccid, item_id, asset_id\r\n\t\t\t) VALUES (\r\n\t\t\t\t'{$nons_invid}', '{$hire_data['qty']}', '{$des}', " . USER_DIV . ", '{$hire_data['amt']}', '{$hire_data['amt']}', '2', \r\n\t\t\t\t'{$acc_data['accid']}', '{$hire_data['id']}', '{$hire_data['asset_id']}'\r\n\t\t\t)"; db_exec($sql) or errDie("Unable to add non stock items."); /* $sql = " INSERT INTO hire.hire_invitems (invid, qty, ss, div, amt, discp, disc, unitcost, noted, serno, vatcode, description, account, from_date, to_date, asset_id, basis, hours, stkid, collection, weeks, days) VALUES ('$in_invid', '$hire_data[qty]', '$hire_data[ss]', '$hire_data[div]', '$hire_data[amt]', '$hire_data[discp]', '$hire_data[disc]', '$hire_data[unitcost]', '$hire_data[noted]', '$hire_data[serno]', '$hire_data[vatcode]', '$hire_data[description]', '$hire_data[account]', '$hire_data[from_date]', '$hire_data[to_date]', '$hire_data[asset_id]', '$hire_data[basis]', '$hire_data[hours]', '$hire_data[stkid]', '$hire_data[collection]', '$hire_data[weeks]', '$hire_data[days]')"; db_exec($sql) or errDie("Unable to create new hire note items.");*/ } pglib_transaction("COMMIT"); header("Location: hire-nons-invoice-print.php?invid={$nons_invid}&key=cconfirm&ctyp=s&cusnum={$hi_data['cusnum']}&post=true&monthly=1"); return $OUTPUT; }
} return $leet; } echo autocorrect ("hi, world"); echo '<br>'; echo autocorrect ("isn't this cool or what"); ?> </p> <br> Write a function that reverses a string <?php $strstr = "hello"; function rev ($strstr) { $new = ""; for ($x = strlen($strstr)-1; $x >= 0; $x--) { $new = $new . $strstr[$x]; } return $new ; } echo rev ($strstr); ?>
if (cot_auth('forums', $key, 'R')) { $jumpbox[cot_url('forums', "m=topics&s=" . $key, '', true)] = $val['tpath']; } } function rev($sway) { return $sway == 'desc' ? 'asc' : 'desc'; } function cursort($trigger, $way) { global $R; if ($trigger) { return $way == 'asc' ? $R['icon_down'] : $R['icon_up']; } return ''; } foreach (array('title', 'viewcount', 'postcount', 'creationdate', 'updated') as $ord) { $title_urls[$ord] = cot_url('forums', "m=topics&s={$s}&ord={$ord}&w=" . rev($w)); } $t->assign(array('FORUMS_TOPICS_PARENT_SECTION_ID' => $s, 'FORUMS_TOPICS_SECTION_RSS' => cot_url('rss', "m=section&c={$s}"), 'FORUMS_TOPICS_PAGETITLE' => $toptitle, 'FORUMS_TOPICS_SHORTTITLE' => htmlspecialchars($structure['forums'][$s]['title']), 'FORUMS_TOPICS_SUBTITLE' => $structure['forums'][$s]['desc'], 'FORUMS_TOPICS_NEWTOPICURL' => cot_url('forums', "m=newtopic&s=" . $s), 'FORUMS_TOPICS_PAGES' => $pagenav['main'], 'FORUMS_TOPICS_PAGEPREV' => $pagenav['prev'], 'FORUMS_TOPICS_PAGENEXT' => $pagenav['next'], 'FORUMS_TOPICS_PAGELAST' => $pagenav['last'], 'FORUMS_TOPICS_PAGECURRENT' => $pagenav['current'], 'FORUMS_TOPICS_PAGETOTAL' => $pagenav['total'], 'FORUMS_TOPICS_PAGEONPAGE' => $pagenav['onpage'], 'FORUMS_TOPICS_PAGEENTRIES' => $pagenav['entries'], 'FORUMS_TOPICS_PRVTOPICS' => $prvtopics, 'FORUMS_TOPICS_JUMPBOX' => cot_selectbox($s, 'jumpbox', array_keys($jumpbox), array_values($jumpbox), false, 'onchange="redirect(this)"'), 'FORUMS_TOPICS_TITLE_TOPICS' => cot_rc_link($title_urls['title'], $L['forums_topics'] . ' ' . cursort($o == 'title', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_TOPICS_URL' => $title_urls['title'], 'FORUMS_TOPICS_TITLE_VIEWS' => cot_rc_link($title_urls['viewcount'], $L['Views'] . " " . cursort($o == 'viewcount', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_VIEWS_URL' => $title_urls['viewcount'], 'FORUMS_TOPICS_TITLE_POSTS' => cot_rc_link($title_urls['postcount'], $L['forums_posts'] . " " . cursort($o == 'postcount', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_POSTS_URL' => $title_urls['postcount'], 'FORUMS_TOPICS_TITLE_REPLIES' => cot_rc_link($title_urls['postcount'], $L['Replies'] . " " . cursort($o == 'postcount', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_REPLIES_URL' => $title_urls['postcount'], 'FORUMS_TOPICS_TITLE_STARTED' => cot_rc_link($title_urls['creationdate'], $L['Started'] . " " . cursort($o == 'creationdate', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_STARTED_URL' => $title_urls['creationdate'], 'FORUMS_TOPICS_TITLE_LASTPOST' => cot_rc_link($title_urls['updated'], $L['Lastpost'] . " " . cursort($o == 'updated', $w), 'rel="nofollow"'), 'FORUMS_TOPICS_TITLE_LASTPOST_URL' => $title_urls['updated'])); /* === Hook === */ foreach (cot_getextplugins('forums.topics.tags') as $pl) { include $pl; } /* ===== */ $t->parse('MAIN'); $t->out('MAIN'); require_once $cfg['system_dir'] . '/footer.php'; if ($cache && $usr['id'] === 0 && $cfg['cache_forums']) { $cache->page->write(); }
function getHirenum($invid, $show_revision = 0) { $sql = "SELECT invnum FROM hire.hire_invoices WHERE invid='{$invid}'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoice number."); $invnum = pg_fetch_result($inv_rslt, 0); if (empty($invnum)) { $sql = "SELECT invnum FROM hire.notes_reprint WHERE invid='{$invid}'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoice number."); $invnum = pg_fetch_result($inv_rslt, 0); } if (!$invnum && !$show_revision) { $invnum = divlastid('hire', USER_DIV); } if ($show_revision) { $invnum = $invnum . rev($invid); } return $invnum; }
function cash_receipt() { extract($_REQUEST); $sql = "SELECT * FROM hire.hire_invoices WHERE invid='{$invid}'"; $inv_rslt = db_exec($sql) or errDie("Unable to retrieve note."); $inv = pg_fetch_array($inv_rslt); // Retrieve customer account $sql = "SELECT accid FROM core.accounts WHERE topacc='6400' AND accnum='000'"; $acc_rslt = db_exec($sql) or errDie("Unable to retrieve account."); $cust_acc = pg_fetch_array($acc_rslt); // Retrieve cash on hand $sql = "SELECT accid FROM core.accounts WHERE topacc='7200' AND accnum='000'"; $acc_rslt = db_exec($sql) or errDie("Unable to retrieve account."); $coh_acc = pg_fetch_array($acc_rslt); $sql = "SELECT * FROM cubit.customers WHERE cusnum='{$inv['cusnum']}'"; $cust_rslt = db_exec($sql) or errDie("Unable to retrieve customer."); $cust_data = pg_fetch_array($cust_rslt); $details = "Cash Receipt for " . CUR . "{$inv['deposit_amt']} from " . ($details .= "{$cust_data['cusname']} {$cust_data['surname']}"); custledger($cust_data["cusnum"], $coh_acc, $inv["odate"], $details, $inv["deposit_amt"], "d"); custDT($inv["deposit_amt"], $cust_data["cusnum"], $inv["odate"]); $sql = "UPDATE cubit.customers SET balance=balance-'{$inv['deposit_amt']}'\r\n\t\t\tWHERE cusnum='{$cust_data['cusnum']}'"; db_exec($sql) or errDie("Unable to update customer balance."); // Retrieve company details $sql = "SELECT * FROM cubit.compinfo WHERE compname='" . COMP_NAME . "'"; $comp_rslt = db_exec($sql) or errDie("Unable to retrieve company details."); $comp_data = pg_fetch_array($comp_rslt); $OUTPUT = "<table " . TMPL_tblDflts . " style='border: 1px solid #000'>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>\r\n\t\t\t\t<b>CASH RECEIPT</b>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'><b>{$comp_data['compname']}</b></td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>{$comp_data['addr1']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>{$comp_data['addr2']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>{$comp_data['addr3']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>{$comp_data['addr4']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td align='center'>Tel: {$comp_data['tel']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td style='border-top: 1px solid #000'>Hire No: H{$inv['invid']}" . rev($inv["invid"]) . "</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>Order No.{$inv['ordno']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>Hire Date. {$inv['odate']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td style='border-top: 1px solid #000'\r\n\t\t\t\t>Cash Amount Received<br /> From {$cust_data['cusname']} {$cust_data['surname']}: " . CUR . "{$inv['deposit_amt']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td> </td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td>By: {$inv['username']}</td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<td><br /><br /></td>\r\n\t\t</tr>\r\n\t</table>"; require "../tmpl-print.php"; }