ESTE ES EL CODIGO CON EL QUE OBTUBE RESULTADOS CON WINDOWS SERVER
CODIGO
<?php
$DocNum = $_REQUEST['DocNum'];
$CardName = $_REQUEST['CardName'];
$LicTradNum = $_REQUEST['LicTradNum'];
$Tel1 = $_REQUEST['Tel1'];
$Address2 = $_REQUEST['Address2'];
$f1 = $_REQUEST['f1'];
$f2 = $_REQUEST['f2'];
$f3 = $_REQUEST['f3'];
$f4 = $_REQUEST['f4'];
$f5 = $_REQUEST['f5'];
$f6 = $_REQUEST['f6'];
$f7 = $_REQUEST['f7'];
$f8 = $_REQUEST['f8'];
$m1a = $_REQUEST['m1a'];
$m1b = $_REQUEST['m1b'];
$m1c = $_REQUEST['m1c'];
$m1d = $_REQUEST['m1d'];
$m1e = $_REQUEST['m1e'];
$m2a = $_REQUEST['m2a'];
$m2b = $_REQUEST['m2b'];
$m2c = $_REQUEST['m2c'];
$m2d = $_REQUEST['m2d'];
$m2e = $_REQUEST['m2e'];
$m3a = $_REQUEST['m3a'];
$m3b = $_REQUEST['m3b'];
$m3c = $_REQUEST['m3c'];
$m3d = $_REQUEST['m3d'];
$m3e = $_REQUEST['m3e'];
$m4a = $_REQUEST['m4a'];
$m4b = $_REQUEST['m4b'];
$m4c = $_REQUEST['m4c'];
$m4d = $_REQUEST['m4d'];
$m4e = $_REQUEST['m4e'];
$m5a = $_REQUEST['m5a'];
$m5b = $_REQUEST['m5b'];
$m5c = $_REQUEST['m5c'];
$m5d = $_REQUEST['m5d'];
$m5e = $_REQUEST['m5e'];
$m6a = $_REQUEST['m6a'];
$m6b = $_REQUEST['m6b'];
$m6c = $_REQUEST['m6c'];
$m6d = $_REQUEST['m6d'];
$m6e = $_REQUEST['m6e'];
$m7a = $_REQUEST['m7a'];
$m7b = $_REQUEST['m7b'];
$m7c = $_REQUEST['m7c'];
$m7d = $_REQUEST['m7d'];
$m7e = $_REQUEST['m7e'];
$m8a = $_REQUEST['m8a'];
$m8b = $_REQUEST['m8b'];
$m8c = $_REQUEST['m8c'];
$m8d = $_REQUEST['m8d'];
$m8e = $_REQUEST['m8e'];
$m9a = $_REQUEST['m9a'];
$m9b = $_REQUEST['m9b'];
$m9c = $_REQUEST['m9c'];
$m9d = $_REQUEST['m9d'];
$m9e = $_REQUEST['m9e'];
$m10a = $_REQUEST['m10a'];
$m10b = $_REQUEST['m10b'];
$m10c = $_REQUEST['m10c'];
$m10d = $_REQUEST['m10d'];
$m10e = $_REQUEST['m10e'];
$cita = $_REQUEST['cita'];
$m11a = $_REQUEST['m11a'];
$status = 'Activa';
date_default_timezone_get('America/Guadalajara_city');
$fecha_actual=date("y-m-d H:i:s");
$conexion2 = new mysqli("localhost","root","INFO","INFO");
$query2 = "INSERT INTO INFO VALUES (
'0','$DocNum','$CardName','$LicTradNum','$Tel1','$Address2',
'$f1','$f2','$f3','$f4','$f5','$f6','$f7','$f8',
'$m1a','$m1b','$m1c','$m1d','$m1e',
'$m2a','$m2b','$m2c','$m2d','$m2e',
'$m3a','$m3b','$m3c','$m3d','$m3e',
'$m4a','$m4b','$m4c','$m4d','$m4e',
'$m5a','$m5b','$m5c','$m5d','$m5e',
'$m6a','$m6b','$m6c','$m6d','$m6e',
'$m7a','$m7b','$m7c','$m7d','$m7e',
'$m8a','$m8b','$m8c','$m8d','$m8e',
'$m9a','$m9b','$m9c','$m9d','$m9e',
'$m10a','$m10b','$m10c','$m10d','$m10e',
'$cita','$m11a','$fecha_actual','$status')";
$resultado2 = $conexion2->query($query2);
$conexion1 = new mysqli("localhost","root","INFO","INFO");
$query1 = "SELECT * FROM INFO order by id desc limit 1 ";
$resultado1 = $conexion1->query($query1);
while ($row = $resultado1->fetch_assoc()){
$domi = $row ['DocNum'];
$aMostrar=substr($domi, 0, 6);
$addressa= $aMostrar;
$dom = utf8_decode($row ['Address2']);
$aMostrar1=substr($dom, 0, 75);
$domi1= $aMostrar1;
$dom2 = utf8_decode($row ['Address2']);
$aMostrar2=substr($dom2, 75, 150);
$domi2= $aMostrar2;
$cliente = $row['CardName'];
$id = $row['id'];
$rfc = $row['LicTradNum'];
$tel = $row['Tel1'];
$ruta = $row ['cita'];
$fecha = $row ['fecha'];
$porcobrar = $row ['f1'];
$pagado = $row ['f2'];
$alregreso = $row ['f3'];
$aocurre =$row ['f7'];
$adomicilio = $row ['f4'];
$valor_declarado = $row ['f6'];
// valores de filas de producto / documentos
$m1a = $row ['m1a'];
$m1b = $row ['m1b'];
$m1c = $row ['m1c'];
$m1d = $row ['m1d'];
$m1e = $row ['m1e'];
$m2a = $row ['m2a'];
$m2b = $row ['m2b'];
$m2c = $row ['m2c'];
$m2d = $row ['m2d'];
$m2e = $row ['m2e'];
$m3a = $row ['m3a'];
$m3b = $row ['m3b'];
$m3c = $row ['m3c'];
$m3d = $row ['m3d'];
$m3e = $row ['m3e'];
$m4a = $row ['m4a'];
$m4b = $row ['m4b'];
$m4c = $row ['m4c'];
$m4d = $row ['m4d'];
$m4e = $row ['m4e'];
$m5a = $row ['m5a'];
$m5b = $row ['m5b'];
$m5c = $row ['m5c'];
$m5d = $row ['m5d'];
$m5e = $row ['m5e'];
$m6a = $row ['m6a'];
$m6b = $row ['m6b'];
$m6c = $row ['m6c'];
$m6d = $row ['m6d'];
$m6e = $row ['m6e'];
$m7a = $row ['m7a'];
$m7b = $row ['m7b'];
$m7c = $row ['m7c'];
$m7d = $row ['m7d'];
$m7e = $row ['m7e'];
$m8a = $row ['m8a'];
$m8b = $row ['m8b'];
$m8c = $row ['m8c'];
$m8d = $row ['m8d'];
$m8e = $row ['m8e'];
$m9a = $row ['m9a'];
$m9b = $row ['m9b'];
$m9c = $row ['m9c'];
$m9d = $row ['m9d'];
$m9e = $row ['m9e'];
$m10a = $row ['m10a'];
$m10b = $row ['m10b'];
$m10c = $row ['m10c'];
$m10d = $row ['m10d'];
$m10e = $row ['m10e'];
$m11a = $row ['m11a'];
echo $addressa;
echo $cliente;
}
require __DIR__ . '/autoload.php'; //Nota: si renombraste la carpeta a algo diferente de "ticket" cambia el nombre en esta línea
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\Printer;
/*echo '<script language="javascript">alert(" desea imprimir realmente ");</script>
<script>';
*/
//cariable con codigo zpl de maquetado de etiqueta con variables concatenadas pata imprimir la informacion de la pre guia
$preguia1 = '
^XA
^FO20,155^GB770,0,4^FS
^FO680,155^GB0,100,4^FS
^FT250,176^A0N,20,20^FH\^FDORDEN DE SOLICITUD DE RECOLECCION^FS
^FO20,180^GB660,0,2^FS
^FT26,201^A0N,20,20^FH\^FDFOLIO :^FS
^FO100,180^GB0,25,2^FS
^FT105,201^A0N,20,20^FH\^FD'.$addressa.'^FS
^FO240,180^GB0,25,2^FS
^FT245,201^A0N,20,20^FH\^FD PRE GUIA :^FS
^FO350,180^GB0,25,2^FS
^FT355,201^A0N,20,20^FH\^FD'.$id.'^FS
^FO470,180^GB0,50,2^FS
^FO20,205^GB450,0,2^FS
^FT26,226^A0N,20,20^FH\^FDFECHA DE ENVIO :^FS
^FO180,205^GB0,25,2^FS
^FT184,226^A0N,20,20^FH\^FD '.$id.' ^FS
^FO300,205^GB0,25,2^FS
^FT304,226^A0N,20,20^FH\^FD RUTA ^FS
^FO20,230^GB660,0,2^FS
^FO693,153
^BQN,2,3
^FD PRE GUIA ' .$id.'^FS
^FT475,223^A0N,45,22^FH\^FD'.$ruta.'^FS
^FO20,255^GB770,0,4^FS
^FO20,230
^GB660,25,25,,0^FS
^FO360,235^CF0,22,22
^FR^FDREMITENTE^FS
^FT35,277^A0N,20,20^FH\^FDINFO ^FS
^FO270,255^GB0,25,2^FS
^FT290,277^A0N,20,20^FH\^FDRFC : ^FS
^FO350,255^GB0,25,2^FS
^FT370,277^A0N,20,20^FH\^FDINFO^FS
^FO520,255^GB0,25,2^FS
^FT540,277^A0N,20,20^FH\^FDTELEFONOS: ^FS
^FO660,255^GB0,25,2^FS
^FT680,277^A0N,20,20^FH\^FDINFO^FS
^FO20,280^GB770,0,2^FS
^FT24,302^A0N,20,20^FH\^FDDOMICILIO: ^FS
^FO130,280^GB0,25,2^FS
^FT144,302^A0N,20,20^FH\^FDINFO^FS
^FO470,280^GB0,25,2^FS
^FT484,302^A0N,20,20^FH\^FDCOLONIA Y C.P.^FS
^FO630,280^GB0,25,2^FS
^FT644,302^A0N,20,20^FH\^FDINFO ^FS
^FO20,315^GB770,0,2^FS
^FO20,305
^GB770,35,35,,0^FS
^FO340,315^CF0,26,26
^FR^FDDESTINATARIO^FS
^FT26,370^A0N,25,25^FH\^FD'.$cliente.'^FS
^FO20,380^GB770,0,2^FS
^FT54,402^A0N,20,24^FH\^FDRFC:^FS
^FT160,402^A0N,20,24^FH\^FD'.$rfc.'^FS
^FT400,402^A0N,20,24^FH\^FDTELEFONOS:^FS
^FT600,402^A0N,20,24^FH\^FD'.$tel.'^FS
^FO20,405^GB770,0,2^FS
^FT360,427^A0N,20,24^FH\^FDDOMICILIO:^FS
^FO20,430^GB770,0,2^FS
^FT26,460^A0N,25,20^FH\^FD'.$domi1.'^FS
^FO20,470^GB770,0,2^FS
^FT26,500^A0N,25,20^FH\^FD'.$domi2.'^FS
^FO20,510^GB770,0,2^FS
^FO20,510
^GB770,35,35,,0^FS
^FO170,518^CF0,26,26
^FR^FDFORMA DE PAGO, ENTREGA Y ASEGURANZA^FS
^FT34,566^A0N,20,20^FH\^FDMODALIDA DE ENVIO: ^FS
^FO220,545^GB0,25,2^FS
^FT238,566^A0N,20,20^FH\^FDPOR COBRAR ^FS
^FO365,545^GB0,25,2^FS
^FT378,566^A0N,20,20^FH\^FD'.$porcobrar.'^FS
^FO395,545^GB0,25,2^FS
^FT413,566^A0N,20,20^FH\^FDPAGADO ^FS
^FO500,545^GB0,25,2^FS
^FT510,566^A0N,20,20^FH\^FD'.$pagado.'^FS
^FO530,545^GB0,25,2^FS
^FT556,566^A0N,20,20^FH\^FDCOBRAR AL REGRESO ^FS
^FO760,545^GB0,25,2^FS
^FT770,566^A0N,20,20^FH\^FD'.$alregreso.'^FS
^FO20,570^GB770,0,2^FS
^FT28,591^A0N,20,17^FH\^FDSERVICIO OCURRE^FS
^FO160,570^GB0,25,2^FS
^FT165,591^A0N,20,20^FH\^FD'.$aocurre.'^FS
^FO180,570^GB0,25,2^FS
^FT185,591^A0N,20,17^FH\^FDENTREGA A DOMICILIO^FS
^FO350,570^GB0,25,2^FS
^FT357,591^A0N,20,20^FH\^FD'.$adomicilio.'^FS
^FO375,570^GB0,25,2^FS
^FT381,591^A0N,20,20^FH\^FDVALOR DECLARADO : ^FS
^FO20,595^GB770,0,2^FS
^FO20,595
^GB770,35,35,,0^FS
^FO250,603^CF0,26,28
^FR^FDDESCRIPCION DE MERCANCIA^FS
^FT57,655^A0N,20,18^FH\^FD BULTOS^FS
^FT140,655^A0N,20,28^FH\^FD DESCRIPCION^FS
^FT325,655^A0N,20,28^FH\^FD CONTENIDO^FS
^FT495,655^A0N,20,28^FH\^FD PEDIDO^FS
^FT645,655^A0N,20,28^FH\^FDENTREGA^FS
^FO20,660^GB770,0,4^FS
^FT27,685^A0N,20,22^FH\^FD 1^FS
^FT55,685^A0N,20,22^FH\^FD '.$m1a.'^FS
^FT140,685^A0N,20,22^FH\^FD '.$m1b.'^FS
^FT325,685^A0N,20,22^FH\^FD'.$m1c.'^FS
^FT505,685^A0N,20,34^FH\^FD'.$m1d.'^FS
^FT645,685^A0N,20,38^FH\^FD'.$m1e.'^FS
^FO20,690^GB770,0,4^FS
^FT27,715^A0N,20,22^FH\^FD 2^FS
^FT55,715^A0N,20,22^FH\^FD '.$m2a.'^FS
^FT140,715^A0N,20,22^FH\^FD'.$m2b.'^FS
^FT325,715^A0N,20,22^FH\^FD'.$m2c.'^FS
^FT505,715^A0N,20,34^FH\^FD'.$m2d.'^FS
^FT645,715^A0N,20,38^FH\^FD'.$m2e.'^FS
^FO20,720^GB770,0,4^FS
^FT27,745^A0N,20,22^FH\^FD 3^FS
^FT55,745^A0N,20,22^FH\^FD '.$m3a.'^FS
^FT140,745^A0N,20,22^FH\^FD '.$m3b.'^FS
^FT325,745^A0N,20,22^FH\^FD '.$m3c.'^FS
^FT505,745^A0N,20,34^FH\^FD'.$m3d.'^FS
^FT645,745^A0N,20,38^FH\^FD'.$m3e.'^FS
^FO20,750^GB770,0,4^FS
^FT27,775^A0N,20,22^FH\^FD 4^FS
^FT55,775^A0N,20,22^FH\^FD '.$m4a.'^FS
^FT140,775^A0N,20,22^FH\^FD '.$m4b.'^FS
^FT325,775^A0N,20,22^FH\^FD '.$m4c.'^FS
^FT505,775^A0N,20,34^FH\^FD'.$m4d.'^FS
^FT645,775^A0N,20,38^FH\^FD'.$m4e.'^FS
^FO20,780^GB770,0,4^FS
^FT27,805^A0N,20,22^FH\^FD 5^FS
^FT55,805^A0N,20,22^FH\^FD '.$m5a.'^FS
^FT140,805^A0N,20,22^FH\^FD '.$m5b.'^FS
^FT325,805^A0N,20,22^FH\^FD '.$m5c.'^FS
^FT505,805^A0N,20,34^FH\^FD'.$m5d.'^FS
^FT645,805^A0N,20,38^FH\^FD'.$m5e.'^FS
^FO20,810^GB770,0,4^FS
^FT27,835^A0N,20,22^FH\^FD 6^FS
^FT55,835^A0N,20,22^FH\^FD '.$m6a.'^FS
^FT140,835^A0N,20,22^FH\^FD '.$m6b.'^FS
^FT325,835^A0N,20,22^FH\^FD '.$m6c.'^FS
^FT505,835^A0N,20,34^FH\^FD'.$m6d.'^FS
^FT645,835^A0N,20,38^FH\^FD'.$m6e.'^FS
^FO20,840^GB770,0,4^FS
^FT27,865^A0N,20,22^FH\^FD 7^FS
^FT55,865^A0N,20,22^FH\^FD '.$m7a.'^FS
^FT140,865^A0N,20,22^FH\^FD '.$m7b.'^FS
^FT325,865^A0N,20,22^FH\^FD '.$m7c.'^FS
^FT505,865^A0N,20,34^FH\^FD'.$m7d.'^FS
^FT645,865^A0N,20,38^FH\^FD'.$m7e.'^FS
^FO20,870^GB770,0,4^FS
^FT27,895^A0N,20,22^FH\^FD 8^FS
^FT55,895^A0N,20,22^FH\^FD '.$m8a.'^FS
^FT140,895^A0N,20,22^FH\^FD '.$m8b.'^FS
^FT325,895^A0N,20,22^FH\^FD '.$m8c.'^FS
^FT505,895^A0N,20,34^FH\^FD'.$m8d.'^FS
^FT645,895^A0N,20,38^FH\^FD'.$m8e.'^FS
^FO20,900^GB770,0,4^FS
^FT27,925^A0N,20,22^FH\^FD 9^FS
^FT55,925^A0N,20,22^FH\^FD '.$m9a.'^FS
^FT140,925^A0N,20,22^FH\^FD '.$m9b.'^FS
^FT325,925^A0N,20,22^FH\^FD '.$m9c.'^FS
^FT505,925^A0N,20,34^FH\^FD'.$m9d.'^FS
^FT645,925^A0N,20,38^FH\^FD'.$m9e.'^FS
^FO20,930^GB770,0,4^FS
^FT27,955^A0N,20,22^FH\^FD10^FS
^FT55,955^A0N,20,22^FH\^FD '.$m10a.'^FS
^FT140,955^A0N,20,22^FH\^FD '.$m10b.'^FS
^FT325,955^A0N,20,22^FH\^FD '.$m10c.'^FS
^FT505,955^A0N,20,34^FH\^FD'.$m10d.'^FS
^FT645,955^A0N,20,38^FH\^FD'.$m10e.'^FS
^FO20,960^GB770,0,4^FS
^FT27,985^A0N,20,22^FH\^FD11^FS
^FT55,985^A0N,20,22^FH\^FD ^FS
^FT140,985^A0N,20,22^FH\^FD ^FS
^FT325,985^A0N,20,22^FH\^FD ^FS
^FT505,985^A0N,20,34^FH\^FD ^FS
^FT645,985^A0N,20,38^FH\^FD ^FS
^FO20,990^GB770,0,4^FS
^FT27,1015^A0N,20,22^FH\^FD12^FS
^FT55,1015^A0N,20,22^FH\^FD ^FS
^FT140,1015^A0N,20,22^FH\^FD ^FS
^FT325,1015^A0N,20,22^FH\^FD ^FS
^FT505,1015^A0N,20,34^FH\^FD ^FS
^FT645,1015^A0N,20,38^FH\^FD ^FS
^FO20,1020^GB770,0,4^FS
^FT27,1045^A0N,20,22^FH\^FD13^FS
^FT55,1045^A0N,20,22^FH\^FD ^FS
^FT140,1045^A0N,20,22^FH\^FD ^FS
^FT325,1045^A0N,20,22^FH\^FD ^FS
^FT505,1045^A0N,20,34^FH\^FD ^FS
^FT645,1045^A0N,20,38^FH\^FD ^FS
^FO20,1050^GB770,0,4^FS
^FT27,1075^A0N,20,22^FH\^FD14^FS
^FT55,1075^A0N,20,22^FH\^FD ^FS
^FT140,1075^A0N,20,22^FH\^FD ^FS
^FT325,1075^A0N,20,22^FH\^FD ^FS
^FT505,1075^A0N,20,34^FH\^FD ^FS
^FT645,1075^A0N,20,38^FH\^FD ^FS
^FO20,1080^GB770,0,4^FS
^FT27,1105^A0N,20,22^FH\^FD15^FS
^FT55,1105^A0N,20,22^FH\^FD ^FS
^FT140,1105^A0N,20,22^FH\^FD ^FS
^FT325,1105^A0N,20,22^FH\^FD ^FS
^FT505,1105^A0N,20,34^FH\^FD ^FS
^FT645,1105^A0N,20,38^FH\^FD ^FS
^FO20,1110^GB770,0,4^FS
^FO50,630^GB0,480,4^FS
^FO130,630^GB0,480,4^FS
^FO320,630^GB0,480,4^FS
^FO480,630^GB0,480,4^FS
^FO610,630^GB0,480,4^FS
^FT28,1145^A0N,26,18^FH\^FD COMENTARIOS : '.$m11a.'^FS
^FO20,1155^GB774,0,4^FS
^FO280,1180^GB300,0,4^FS
^FT340,1205^A0N,20,18^FH\^FD FIRMA DE RECIBIDO :^FS
^FO100,180^GB0,25,2^FS
^FO790,155^GB0,1000,4^FS
^FO20,155^GB0,1000,4^FS
^XZ
';
//}
/*
Este ejemplo imprime un hola mundo en una impresora de tickets
en Windows.
La impresora debe estar instalada como genérica y debe estar
compartida
*/
/*
Conectamos con la impresora
*/
/*
Aquí, en lugar de "POS-58" (que es el nombre de mi impresora)
escribe el nombre de la tuya. Recuerda que debes compartirla
desde el panel de control
*/
//$nombre_impresora = "talento1";
$nombre_impresora = "preguias2";
$connector = new WindowsPrintConnector($nombre_impresora);
$printer = new Printer($connector);
$printer->setJustification(Printer::JUSTIFY_CENTER);
//$logo = EscposImage::load("logo.jpg", false);
//$printer->bitImage($logo);
/*
Imprimimos un mensaje. Podemos usar
el salto de línea o llamar muchas
veces a $printer->text()
*/
$printer->setTextSize(2, 2);
//$printer->text("Ticket con PHP");
$printer->setTextSize(2, 1);
//$printer->feed();
$printer->text($preguia);
$printer->text($preguia1); //pagina 2 por codifo zpl
/*
Hacemos que el papel salga. Es como
dejar muchos saltos de línea sin escribir nada
*/
$printer->feed(15);
/*
Cortamos el papel. Si nuestra impresora
no tiene soporte para ello, no generará
ningún error
*/
$printer->cut();
/*
Por medio de la impresora mandamos un pulso.
Esto es útil cuando la tenemos conectada
por ejemplo a un cajón
*/
$printer->pulse();
/*
Para imprimir realmente, tenemos que "cerrar"
la conexión con la impresora. Recuerda incluir esto al final de todos los archivos
*/
$printer->close();
/*echo '<script language="javascript">alert(" imprecion completada ");</script>
<script>
function redireccionarPagina() {
window.location = "HTTP://192.168.101.209:215";
}
setTimeout("redireccionarPagina()", 5000);
</script>
';*/
if($resultado1 == true) {
echo '<script language="javascript">alert("! PRE GUA IMPRESA CORRECTAMENTE!");</script>
<script>
function redireccionarPagina() {
window.location = "javascript: history.go(-1);";
}
setTimeout("redireccionarPagina()", 3000);
</script>
';
} else {
echo '<script language="javascript">alert("! no se ha podido actualizar !");</script>
<script>';
}
?>
LIBRERIA Mike42