//Print ticket method include sc_url_library("sys","Mike42","autoload.php"); $wimpresora = ''; $wlogo = ''; $wempresa = ''; $wcuit = ''; $wptovta = ''; $winicio = ''; $wdomicilio = ''; $wtel = ''; $wletra = ''; $wcondiva = ''; //Lookup printer $check_sql ="SELECT `impresoras`.`nombre_imp` FROM `cajas_descrip` INNER JOIN `impresoras` ON (`cajas_descrip`.`idimpre` = `impresoras`.`idimpre`) where caja = [wcaja]"; sc_lookup(rs, $check_sql); if (isset({rs[0][0]})) // Row found { $wimpresora = {rs[0][0]}; } if($wimpresora=='') { sc_alert('No se encontrĂ³ el nombre de la impresora para la Caja [wcaja]'); } $check_sql = "SELECT id, logo, empresa, cuit, ptovta, inicio, domicilio, tel, letra, condiva.Condicion, img_print FROM parametros LEFT JOIN condiva ON condiva.`IdCondIVA`= parametros.`idcondiva` WHERE id=1"; sc_lookup(rs, $check_sql); if (isset({rs[0][0]})) // Row found { //$wid = {rs[0][0]}; $wlogo = {rs[0][1]}; $wempresa = {rs[0][2]}; $wcuit = {rs[0][3]}; $wptovta = {rs[0][4]}; $winicio = {rs[0][5]}; $wdomicilio = {rs[0][6]}; $wtel = {rs[0][7]}; $wletra = {rs[0][8]}; $wcondiva = {rs[0][9]}; $wimp_print = {rs[0][10]}; } //Lookup client data $wnomclie =''; $wcondivacli=''; $wcuitcli=''; $check_sql = "SELECT `clientes`.`nombre`, `condiva`.`Condicion`, `clientes`.`cuit` FROM `clientes` LEFT JOIN `condiva` ON (`clientes`.`idcondiva` = `condiva`.`IdCondIVA`) WHERE `clientes`.`idcliente`={idcliente}"; sc_lookup(rs, $check_sql); if (isset({rs[0][0]})) // Row found { $wnomclie = {rs[0][0]}; $wcondivacli= {rs[0][1]}; $wcuitcli = {rs[0][2]}; } if($wnomclie==0) { $wnomclie = "Cons. final"; } $wcae={cae}; //Lookup items $items=""; $array_items=array(); $check_sql = "SELECT ROUND(`pedidosarticulos`.`cantidad`,0) AS cant, `articulos`.`desc_art`, ROUND(`pedidosarticulos`.`precio`*`pedidosarticulos`.`cantidad`,2) AS total FROM `pedidosarticulos` INNER JOIN `articulos` ON (`pedidosarticulos`.`cod_art` = `articulos`.`cod_art`) WHERE `pedidosarticulos`.`idpedido`= {idpedido}"; sc_select(rs, $check_sql); if (false == {rs}) // Error while accessing database { sc_error_message('Error while accessing database.'); } else { while(!$rs->EOF) { $items=array("cant"=>$rs->fields[0], "desc" => $rs->fields[1] , "tot" => $rs->fields[2]); array_push($array_items,$items); $rs->MoveNext(); } $rs->Close(); } //Lookup pay type $items=""; $array_pago=array(); $check_sql = "SELECT `formaspago`.`forma_pago`, `cajas`.`importe` FROM `cajas` LEFT JOIN `formaspago` ON (`cajas`.`idfpago` = `formaspago`.`idfpago`) WHERE `cajas`.`idpedido`= {idpedido}"; sc_select(rs, $check_sql); if (false == {rs}) // Error while accessing database { sc_error_message('Error while accessing database.'); } else { while(!$rs->EOF) { $items=array("desc" => $rs->fields[0] , "tot" => $rs->fields[1]); array_push($array_pago,$items); $rs->MoveNext(); } $rs->Close(); } $connector = new Mike42\Escpos\PrintConnectors\WindowsPrintConnector($wimpresora); $printer = new Mike42\Escpos\Printer($connector); $printer->setJustification(Mike42\Escpos\Printer::JUSTIFY_CENTER); if($wlogo!='') { $printer->setJustification(Mike42\Escpos\Printer::JUSTIFY_LEFT); $wlogo = "../_lib/img/" . $wlogo; $wimg = Mike42\Escpos\EscposImage::load($wlogo, false); if($wimp_print=='G') { $printer->graphics($wimg); } else { $printer -> bitImage($wimg); //Funciona en Hasar 250 } } $wptovta=sprintf("%04d",$wptovta); $wnumtkt=sprintf("%08d",{nroticket}); $printer->setTextSize(2, 1); $printer->setEmphasis(true); $printer->text($wempresa . "\n"); $printer->setEmphasis(false); $printer->setJustification(Mike42\Escpos\Printer::JUSTIFY_LEFT); $printer->setTextSize(1, 1); $printer->text("CUIT: " . $wcuit . "\n"); $printer->text("IVA " . $wcondiva . "\n"); $winicio = date("d/m/Y", strtotime($winicio)); $printer->text("Inicio actividades: " . $winicio . "\n"); $printer->text($wdomicilio . "\n"); $printer->setJustification(Mike42\Escpos\Printer::JUSTIFY_LEFT); $printer->text("TIQUE FACTURA $wletra $wptovta-$wnumtkt" . "\n"); $wfecha_tkt = date("d/m/Y", strtotime({fticket})); $printer->text("Fecha: " . $wfecha_tkt . "\n"); $printer->text($wnomclie . "\n"); if($wcuitcli!='') { $printer->text("C.U.I.T.: " . $wcuitcli . "\n"); } if($wcondivacli!='Consumidor final' and $wnomclie != "Cons. final") { $printer->text("I.V.A.: " . $wcondivacli . "\n"); } $printer->feed(1); $printer->setTextSize(2, 1); $printer->text("-------------------------------" . "\n"); $printer->setJustification(Mike42\Escpos\Printer::JUSTIFY_LEFT); $printer->text("CANT DESCRIPCION IMPORTE\n"); $printer->text("-------------------------------"."\n"); $itm=$array_items; foreach ( $itm as $var ) { $line = sprintf('%3.0f %-16.16s %9.2f', $var['cant'], $var['desc'], $var['tot']); $printer->text($line . "\n"); } $printer->text("-------------------------------"."\n"); //$printer->setJustification(Printer::JUSTIFY_RIGHT if({descuento}>0) { $line = sprintf('%-20.20s %9.2f', "Subtotal: ", {subtotal}); $printer->text($line . "\n"); $line = sprintf('%-20.20s %9.2f', "Descuento: ", {descuento}); $printer->text($line . "\n"); //$printer->text("Descuento: " . $descuento . "\n"); } $printer->setEmphasis(true); $line = sprintf('%-20.20s %9.2f', "TOTAL: ", {total}); $printer->text($line . "\n"); //$printer->text("TOTAL: " . $total . "\n"); $printer->setEmphasis(false); //$printer->setJustification(Printer::JUSTIFY_LEFT); $printer->setTextSize(1, 1); $printer->feed(); $printer->text("Recibimos:" . "\n"); $pag=$array_pago; foreach ( $pag as $var ) { //$line = sprintf('%3.0f %-16.16s %9.2f', $var['cant'], $var['desc'], $var['tot']); $line = sprintf('%-20.20s %9.2f', $var['desc'], $var['tot']); $printer->text($line . "\n"); } $printer->feed(); $printer->setTextSize(1, 2); $printer->text("CAE: " . $cae . "\n"); $vtocae = date("d/m/Y", strtotime({cae_vto})); $printer->text("Fecha Vto. CAE: " . $vtocae . "\n"); $printer->feed(10); $printer->cut(); $printer->pulse(); $printer->close();