<?php
/* Change to the correct path if you copy this example! */
require __DIR__ . '../autoload.php';
 
 include_once('../db.php');  
 include_once('../check.php');  
 //require_once('../inc.php'); 

use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;


/**
 * Install the printer using USB printing support, and the "Generic / Text Only" driver,
 * then share it (you can use a firewall so that it can only be seen locally).
 *
 * Use a WindowsPrintConnector with the share name to print.
 *
 * Troubleshooting: Fire up a command prompt, and ensure that (if your printer is shared as
 * "Receipt Printer), the following commands work:
 *
 *  echo "Hello World" > testfile
 *  copy testfile "\\%COMPUTERNAME%\Receipt Printer"
 *  del testfile
 */
try {
    // Enter the share name for your USB printer here
     //$connector = null;
    $connector = new WindowsPrintConnector("printername");

    /* Print a "Hello world" receipt" */
    $printer = new Printer($connector);
    
    //$printer -> text(" PALS MATATU SACCO !\n ");
   // $printer -> text(" Email: palsmatatusacco@gmail.com !\n ");
   // $printer -> text(" phone: palsmatatusacco@gmail.com ");
    
    
      /* $printer -> setBarcodeHeight(80);
         $printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW);
         $printer -> barcode("9876");
         $printer -> feed(); */
   

          /* $printer -> text("Hello World!\n");
          $printer -> text("LOREM IPSUM !\n");
          $printer -> text("LOREM IPSUM!\n"); */
    /* Start the printer */
       ///$logo = EscposImage::load("example/resources/escpos-php.png", false);
      //$printer = new Printer($connector);

/* Print top logo */
 //$printer -> setJustification(Printer::JUSTIFY_CENTER);
 //$printer -> graphics($logo);

/* Name of shop */
    $date = "Monday 6th of April 2015 02:56:25 PM";
    
$printer -> setJustification(Printer::JUSTIFY_CENTER);
$printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH);
$printer -> text(" PALS MATATU SACCO \n");
$printer -> selectPrintMode();
$printer -> text(" Email: palsmatatusacco@gmail.com !\n ");
$printer -> text(" phone: 0701417861 \n ");
$printer -> feed(1);
    


/* Title of receipt */
$printer -> setEmphasis(true);
$printer -> text("SAVINGS \n");
$printer -> setEmphasis(false);
$printer -> feed(1);

$printer -> setJustification(Printer::JUSTIFY_LEFT);

$printer -> text(" PAYEE: 0701417861 \n ");
$printer -> feed(1);

$printer -> text(" PAYEE CODE: 0701417861 \n ");
$printer -> feed(1);
    
$printer -> text(" NAME: 0701417861 \n ");
$printer -> feed(1);

$printer -> text(" DATE: 0701417861 \n ");
$printer -> feed(1);
    
$printer -> text(" TIME: 0701417861 \n ");
$printer -> feed(1);
    
$printer -> text(" MODE: 0701417861 \n ");
$printer -> feed(1);





/* Footer */
$printer -> feed(2);
$printer -> setJustification(Printer::JUSTIFY_CENTER);
$printer -> text(" YOU WERE SERVED BY \n");
   // $printer -> text("For trading hours, please visit example.com\n");
   // $printer -> feed(2);
  // $printer -> text(" DATE \n". $date  );
$printer -> cut();
    
    /* Close printer */
    $printer -> close();
    
} catch (Exception $e) {   echo "Couldn't print to this printer: " . $e -> getMessage() . "\n"; }
