<?php
include_once("../../../php/sessionStart.php"); 
include_once("../../../php/db/dbExec.php");
include_once('../../../php/functions.php');
include_once("../../../php/fpdf/functions.php");
include_once('../../../php/timezone.php');
include_once('../../../php/maxExecTime.php');
//include_once('../ws/COFIDI/wsExec.php');

$empCod=utf8_decode($_SESSION["empCod"]);
$empNom=TRIM(utf8_decode($_SESSION["empNom"]));
$empNomc=utf8_decode($_SESSION["empNomc"]);
$empDir=utf8_decode($_SESSION["empDir"]);
$empNit=$_SESSION["empNit"];
$usuNom = utf8_decode($_SESSION['usuNom']);

$numdoc=$_GET["numdoc"];
$seriedoc=$_GET["selTipoCod"];
$TdocNom=$_GET["TdocNom"];
$totLetras=$_GET["totLetras"];
$idinterno=$_GET["idinterno"];

$arrayError=array();

# QUERYS
$sFactura = "SELECT *, 
    TRIM(fac.fact_nom) AS fact_nom,
    TRIM(fac.fact_dir) AS fact_dir,
    TRIM(fac.fact_tel) AS fact_tel,
    TRIM(fac.fact_nit) AS fact_nit,
    TRIM(vend.vend_nom) AS vend_nom
    FROM facturas fac
    LEFT JOIN vendedor vend ON fac.fact_vend=vend.vend_cod
    WHERE fact_emp='$empCod' AND fact_transac='$idinterno'";

$sFact_det = "SELECT * FROM fact_det WHERE factd_emp='$empCod' AND factd_transac='$idinterno'";

# EJECUCION DE QUERYS
$db = new dbExec();

$func = new functions();

$select["facturas"] = $db->query($sFactura);
$select["fact_det"] = $db->query($sFact_det);

$rec = $db->fetchAssoc($select["facturas"]);

$lineWidth=19.5;
$lineHeight=0.4;

class generatePDF extends PDF_MC_Table {
    function Header() {
    }
    
    function Footer() { 
        // Posición: a 1,5 cm del final
    /*    $func = new functions();
        $this->SetY(-2);
        $this->SetFont("Arial","I",7);
        $this->Cell(0,1,strftime("%d/%m/%Y %T"),0,0,"L");   */
    }
}

# GENERAR PDF
//$pdf = new generatePDF("P", "cm", "A4");
$pdf = new generatePDF("P", "cm", "Letter");

include('../felPrint/ENVIO.php');

$pdf->Output(utf8_decode("Envios").".pdf","I");

//$emailAttachment = $pdf->Output('','I');
$db->close();
?>