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 = "SELECT invid, invnum, customers.surname, hire_invid,\r\n\t\t\t\textract('epoch' FROM reprint_invoices.odate) AS e_date\r\n\t\t\t\tFROM hire.reprint_invoices\r\n\t\t\t\t\tLEFT JOIN cubit.customers\r\n\t\t\t\t\t\tON reprint_invoices.cusnum=customers.cusnum\r\n\t\t\tWHERE reprint_invoices.odate BETWEEN '{$from_date}' AND '{$to_date}'\r\n\t\t\tORDER BY invnum DESC";
    $reprint_rslt = db_exec($sql) or errDie("Unable to retrieve reprints.");
    $reprint_out = "";
    while ($reprint_data = pg_fetch_array($reprint_rslt)) {
        if (!$reprint_data["invnum"]) {
            continue;
        }
        $reprint_out .= "<tr class='" . bg_class() . "'>\r\n\t\t\t<td>H{$reprint_data['invnum']}" . rrev($reprint_data["invid"]) . "</td>\r\n\t\t\t<td>{$reprint_data['surname']}</td>\r\n\t\t\t<td>" . date("d-m-Y", $reprint_data["e_date"]) . "</td>\r\n\t\t\t<td>\r\n\t\t\t\t<a href='javascript:printer" . "(\"hire/hire_note_reprint.php?invid={$reprint_data['invid']}\")'>\r\n\t\t\t\t\tReprint\r\n\t\t\t\t</a>\r\n\t\t\t</td>\r\n\t\t</tr>";
    }
    if (empty($reprint_out)) {
        $reprint_out = "\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='4'><li>No results found.</li></td>\r\n\t\t</tr>";
    }
    $OUTPUT = "<center>\r\n\t<h3>View Hire Note Reprints</h3>\r\n\t<form method='post' action='" . SELF . "'>\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr><th colspan='4'>Date Range</th></tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\r\n\t\t\t<td>&nbsp; <b>To</b> &nbsp;</td>\r\n\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\r\n\t\t\t<td>\r\n\t\t\t\t<input type='submit' value='Select' 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>Hire No</th>\r\n\t\t\t<th>Customer</th>\r\n\t\t\t<th>Date</th>\r\n\t\t\t<th>Reprint</th>\r\n\t\t</tr>\r\n\t\t{$reprint_out}\r\n\t</table>";
    return $OUTPUT;
}
function cash_receipt()
{
    extract($_REQUEST);
    $sql = "SELECT * FROM hire.reprint_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 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['invnum']}" . rrev($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>&nbsp;</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";
}