function print_job($job) { global $sql; $settings = new settings_tool(); $speed = $sql->q1($settings->single_query(-1, $this->name . '.speed', $_SESSION['uid'], 0)); if (!isset($speed)) { $speed = 5; } $density = $sql->q1($settings->single_query(-1, $this->name . '.density', $_SESSION['uid'], 0)); if (!isset($density)) { $density = 4; } $ipp_host = $sql->q1($settings->single_query(-1, $this->name . '.ipp_host', $_SESSION['uid'], 0)); if (!isset($ipp_host)) { $ipp_host = 'localhost'; } $ipp_printer = $sql->q1($settings->single_query(-1, $this->name . '.ipp_printer', $_SESSION['uid'], 0)); if (!isset($ipp_printer)) { $ipp_printer = '/printers/TLP2824_'; } $ipp = new PrintIPP(); $ipp->setHost($ipp_host); $ipp->setPrinterURI($ipp_printer); $ipp->setData("\nS" . $speed . "\nD" . $density . "\n" . $job); $ipp->setRawText(); $ipp->printJob(); }
function print_prenote($folio, $ip) { require_once 'printIPP/PrintIPP.php'; try { $ipp = new PrintIPP(); $ipp->setHost($ip); $ipp->setPrinterURI($ip); $ipp->setCharset("UTF-8"); $ipp->setData($folio . ".pdf"); if (($status = $ipp->printJob($folio)) == "successfull-ok") { return true; } else { error_log($status); return false; } } catch (Exception $ex) { error_log('ex...' + $ex->getErrorFormatted()); return false; } }
<?php set_include_path($_SERVER['DOCUMENT_ROOT']); require_once 'lib/ipp/PrintIPP.php'; require_once 'lib/utils.php'; $ipp_host = $_GET["host"]; $ipp_printer = $_GET["printer"]; $task = $_GET["task"]; $json = file_get_contents("http://api.dveri.ru/?method=CRM&json=" . urlencode('{"packet":{"ACTION":"BarCodeAPI.GetTask","DATA":{"taskId":"' . js_escape($task) . '"}},"protocol":"0.3"}')); header("Content-type: text/plain; charset=\"UTF-8\""); $a = json_decode($json, true); if (is_null($a)) { print "F**k the f*****g m**********r off!!!!!\n"; print "This is not JSON:\n"; print $json; exit; } if ($a["packet"]["RESULT"] == "OK") { $ipp = new PrintIPP(); $ipp->setHost($ipp_host); $ipp->setPrinterURI($ipp_printer); $ipp->setData($printjob); $ipp->setRawText($a["packet"]["DATA"]["Result"]); $ipp->printJob(); } else { print "Something bad has happened...\n"; print $a["packet"]["RESULT"] . "\n"; print $a["packet"]["ERRORMSG"] . "\n"; }