<?php /* Print-outs using the newer graphics print command */ require __DIR__ . '/../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\EscposImage; use Mike42\Escpos\PrintConnectors\FilePrintConnector; $connector = new FilePrintConnector("php://stdout"); $printer = new Printer($connector); try { $tux = EscposImage::load("resources/tux.png", false); $printer->graphics($tux); $printer->text("Regular Tux.\n"); $printer->feed(); $printer->graphics($tux, Printer::IMG_DOUBLE_WIDTH); $printer->text("Wide Tux.\n"); $printer->feed(); $printer->graphics($tux, Printer::IMG_DOUBLE_HEIGHT); $printer->text("Tall Tux.\n"); $printer->feed(); $printer->graphics($tux, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT); $printer->text("Large Tux in correct proportion.\n"); $printer->cut(); } catch (Exception $e) { /* Images not supported on your PHP, or image file not found */ $printer->text($e->getMessage() . "\n"); } $printer->close();
// Select customer and order info $sql_orders = "select Order_id,o.cus_id,firstname as fname,lastname as lname,Date,Time,payed from orders as o LEFT JOIN customer_info as c ON o.cus_id = c.cus_id WHERE Order_id = {$id}"; $result = $mysql->query($sql_orders); $row_order = $mysql->fetch($result); if (empty($row_order['lname']) && empty($row_order['fname'])) { $cusname = 'Unknown'; } else { $cusname = $row_order['fname'] . " " . $row_order['lname']; } /* Print customer and order ID */ $printer->setJustification(Printer::JUSTIFY_CENTER); $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); $printer->text("{$cusname}\n"); $printer->selectPrintMode(); $printer->text("Order# {$id}\n"); $printer->feed(2); // Select ordered items $sql_item_detail = "SELECT Item_id,F.order_id,cus.lastname as lname,Cs.cata_name as Food_name,Cp.Cata_name,Quantity,Cs.price as Single_Price,(Cs.price*quantity)as Total_Price,F.food_id from order_food as F JOIN orders as O on F.order_id = O.order_id JOIN food_catalogue as Cs ON F.food_id = Cs.food_id JOIN food_catalogue as Cp ON Cp.food_id = Cs.catalog_id LEFT JOIN customer_info as cus ON cus.cus_id = O.cus_id WHERE F.order_id= {$id}"; $result_item_detail = $mysql->query($sql_item_detail); $sum = ''; while ($row_item_detail = $mysql->fetch($result_item_detail)) { $food_name = $row_item_detail['Food_name']; $qualtity = $row_item_detail['Quantity']; $total = $row_item_detail['Total_Price']; $sum = $sum + $total; $printer->text("{$food_name} ({$qualtity}) - {$total} RMB\n"); } $printer->feed(2); $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); $printer->text("{$sum} RMB"); $printer->selectPrintMode();
<?php require __DIR__ . '/../../autoload.php'; use Mike42\Escpos\Printer; use Mike42\Escpos\PrintConnectors\FilePrintConnector; $a = "{A012323392982"; $b = "{B012323392982"; $c = "{C" . chr(01) . chr(23) . chr(23) . chr(39) . chr(29) . chr(82); $connector = new FilePrintConnector("php://stdout"); $printer = new Printer($connector); $printer->setJustification(Printer::JUSTIFY_CENTER); $printer->setBarcodeHeight(48); $printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW); foreach (array($a, $b, $c) as $item) { $printer->barcode($item, Printer::BARCODE_CODE128); $printer->feed(1); } $printer->cut(); $printer->close();