コード例 #1
1
ファイル: barcodes_tmp.php プロジェクト: vladisslav2011/nb
 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();
 }
コード例 #2
0
ファイル: print-gate.php プロジェクト: vladisslav2011/nb
<?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";
}