Bläddra i källkod

Agregar datos de cliente, isc y envio de impresora

ronald 9 månader sedan
förälder
incheckning
5300ab7c80
1 ändrade filer med 27 tillägg och 8 borttagningar
  1. 27 8
      factura_electronica.php

+ 27 - 8
factura_electronica.php

@@ -7,15 +7,14 @@ use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
 use Mike42\Escpos\EscposImage;
 use Mike42\Escpos\PrintConnectors\FilePrintConnector;
 
-//Printer Name
-const PRINTER_NAME = 'POS-80C';
-
 $dataPrint = json_decode($_POST["dataPrint"]);
 
 if($dataPrint){
+    //Printer Name
+    $PRINTER_NAME = $dataPrint->printer ?? 'POS-80C';
     //CONFIGURACIONES
     $maxDescripcion = 25; //Maximo de caracteres por linea para la descripcion del producto
-    $iscEmpresa = "demo";
+    $iscEmpresa = $dataPrint->isc ?? "demo";
     //DATOS
     $nombreEmpresa = $dataPrint->nombre_empresa;
     $razonSocial = $dataPrint->rsocial_empresa;
@@ -23,10 +22,17 @@ if($dataPrint){
     $documentoDueno = "NRC: ".$dataPrint->nrc_empresa." | NIT: ".$dataPrint->nit_empresa;
     $direccion = $dataPrint->direcion_empresa;
 
+    $documento = strToUpper($dataPrint->documento) ?? null;
+
     $fecha = $dataPrint->fecha;
     $caja = $dataPrint->caja;
 
     $clienteNombre = $dataPrint->cliente;
+    $clienteDocumento = $dataPrint->clienteDoc ?? null;
+    if($clienteDocumento && $dataPrint->clienteDocNum){
+        $clienteDocumento = $clienteDocumento.": ".$dataPrint->clienteDocNum;
+    }
+    $clienteNRC = $dataPrint->clienteNRC ?? null;
 
     $productos = $dataPrint->productos_normal;
 
@@ -48,7 +54,7 @@ if($dataPrint){
 
 
     try {
-        $connector = new WindowsPrintConnector(PRINTER_NAME);
+        $connector = new WindowsPrintConnector($PRINTER_NAME);
         $printer = new Printer($connector);
         // ENCABEZADO
         $printer->setJustification(Printer::JUSTIFY_CENTER);
@@ -60,7 +66,14 @@ if($dataPrint){
         $printer->text("$documentoDueno\n");
         $printer->text("$direccion\n");
         $printer->text(str_repeat("-", 45) . "\n");
-        //CLIENTE
+        //DOCUMENTO
+        if($documento){
+            $printer->setEmphasis(true);
+            $printer->text("$documento\n");
+            $printer->setEmphasis(false);
+             $printer->text(str_repeat("-", 45) . "\n");
+        }
+        //GENERAL
         $printer->setJustification(Printer::JUSTIFY_LEFT);
         $printer->setEmphasis(true);
         $printer->text("Fecha: ");
@@ -70,12 +83,18 @@ if($dataPrint){
         $printer->text("  Caja: ");
         $printer->setEmphasis(false);
         $printer->text("$caja\n");
-
+        //CLIENTE
         $printer->setEmphasis(true);
         $printer->text("Cliente:\n");
         $printer->setEmphasis(false);
         $printer->text("$clienteNombre\n");
-
+        if($clienteDocumento){
+            $printer->text("$clienteDocumento\n");
+        }
+        if($clienteNRC){
+            $printer->text("NRC: $clienteNRC\n");
+        }
+        $printer->text("\n");
         //PRODUCTOS
         $printer->setEmphasis(true);
         $printer->text("Cant  Descripcion                 Precio  Total\n");