Beispiel #1
0
<?php

/*
$Id$

  osCmax e-Commerce
  http://www.oscmax.com

  Copyright 2000 - 2011 osCmax

  Released under the GNU General Public License
*/
// set paper type and size
if ($pageloop == "0") {
    $pdf = new Cezpdf(A4, portrait);
} else {
    $currencies = new currencies();
    $pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
    $pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
    // logo image  set to right of the above .. change first number to move sideways
    $pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'christmascard.jpg', 0, 0, 590, 820);
    $pdf->addText(330, 330, GENERAL_FONT_SIZE, TEXT_DEAR);
    $pdf->addText(350, 310, GENERAL_FONT_SIZE, $order->billing['name']);
    $pdf->addText(350, 290, GENERAL_FONT_SIZE, TEXT_THX_CHRISMAS);
    //require(BATCH_PRINT_INC . 'templates/' . 'grid.php');
}
function creaPDF($colname_factura, $tmpName)
{
    global $database_f4, $f4, $interface, $setsProlec, $url_dir;
    $FWK_PDFFONTS = 'pdf/fonts/';
    $FWK_PDFDEFAULTFONT = '/face5/' . $url_dir . '/f4/extensiones/pdf/fonts/Helvetica.afm';
    $FWK_PDFCOURIERFONT = 'pdf/fonts/Courier.afm';
    // Obtener factura y sus anexos
    $TIPOSCOMPROBANTEMXP = array(1 => "Factura", 3 => "Nota de Cr.", 2 => "NOTA DE DEBITO");
    mysql_select_db($database_f4, $f4);
    $query_factura = sprintf("SELECT  facturas.idfactura,  facturas.idempresa,  facturas.idsello,\n\tfacturas.serie, facturas.folio, archivo,\n\tdate_format( facturas.timestampemision, '%%d/%%m/%%Y %%T') as timestampemision,\n\tfacturas.noaprob, facturas.rfccliente, facturas.estatus, facturas.sello, facturas.cadena, facturas.factura,\n\tfacturas.idif, facturas.tipocfd, empresa.bu\n\tFROM facturas inner join empresa on (facturas.idempresa=empresa.idempresa)\n\tWHERE facturas.idfactura = %s", $colname_factura);
    $factura = mysql_query($query_factura, $f4);
    $row_factura = mysql_fetch_assoc($factura);
    $totalRows_factura = mysql_num_rows($factura);
    print_r($row_factura);
    mysql_select_db($database_f4, $f4);
    $query_partida = sprintf("SELECT * FROM face_partidas WHERE face_factura_idface_factura = %s ORDER BY numero ASC", $row_factura['idif']);
    $partidas = mysql_query($query_partida, $f4);
    $partidasArray = array();
    while ($partRow = mysql_fetch_assoc($partidas)) {
        array_push($partidasArray, $partRow);
    }
    $dom = new DOMDocument();
    $dom->loadXML(base64_decode($row_factura['factura']));
    $NS = "http://www.sat.gob.mx/cfd/2";
    $NSP = "";
    $xp = new DOMXPath($dom);
    $nsElems = $dom->getElementsByTagNameNS($NS, 'Comprobante');
    if ($nsElems->item(0) != null) {
        $xp->registerNamespace("C", "http://www.sat.gob.mx/cfd/2");
        $NSP = "C:";
    }
    $comprobanteNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante");
    foreach ($elements as $comprobanteNode) {
    }
    $emisorNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Emisor");
    foreach ($elements as $emisorNode) {
    }
    $emisordomicilioNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Emisor/" . $NSP . "DomicilioFiscal");
    foreach ($elements as $emisordomicilioNode) {
    }
    $expedidoNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Emisor/" . $NSP . "ExpedidoEn");
    foreach ($elements as $expedidoNode) {
    }
    $receptorNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Receptor");
    foreach ($elements as $receptorNode) {
    }
    $receptordomicilioNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Receptor/" . $NSP . "Domicilio");
    foreach ($elements as $receptordomicilioNode) {
    }
    $conceptoNode = null;
    $conceptos = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Conceptos/" . $NSP . "Concepto");
    $impuestosNode = null;
    $elements = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Impuestos");
    foreach ($elements as $impuestosNode) {
    }
    $trasladoNode = null;
    $traslados = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Impuestos/" . $NSP . "Traslados/" . $NSP . "Traslado");
    $retencionNode = null;
    $retenciones = $xp->query("/" . $NSP . "Comprobante/" . $NSP . "Impuestos/" . $NSP . "Retenciones/" . $NSP . "Retencion");
    mysql_select_db($database_f4, $f4);
    $query_empresa = sprintf("SELECT * FROM empresa WHERE idempresa = %s", $row_factura['idempresa']);
    $empresa = mysql_query($query_empresa, $f4);
    $row_empresa = mysql_fetch_assoc($empresa);
    mysql_select_db($database_f4, $f4);
    $query_sello = sprintf("SELECT * FROM sellos WHERE idsello = %s", $row_factura['idsello']);
    $sello = mysql_query($query_sello, $f4);
    $row_sello = mysql_fetch_assoc($sello);
    mysql_select_db($database_f4, $f4);
    $query_sucursal = "SELECT * FROM sucursales WHERE sucursal = '" . $row_sello['sucursal'] . "'";
    $sucursal = mysql_query($query_sucursal, $f4);
    $row_sucursal = mysql_fetch_assoc($sucursal);
    $totalRows_sucursal = mysql_num_rows($sucursal);
    //descuentos
    $desc1 = 0.0;
    $desc2 = 0.0;
    //==================================================================================================================
    // Crea el documento pdf
    $pdf = new Cezpdf('LETTER', 'portrait');
    //'LETTER' (612.00,792.00)
    $pdf->ezSetMargins(100, 30, 30, 30);
    //$pdf->selectFont($FWK_PDFDEFAULTFONT);
    $pdf->setLineStyle(0.7, '', '', '', 0);
    $pdf->openHere('Fit');
    if ($row_factura['tipocfd'] == 3) {
        $pdf->setStrokeColor(255, 0, 0);
    }
    if ($row_factura['tipocfd'] == 2) {
        $pdf->setStrokeColor(0, 255, 0);
    }
    // Inicia numeracin de páginas.
    $pdf->ezStartPageNumbers(400, 50, 10, 'left', '{PAGENUM} of {TOTALPAGENUM}', 1);
    $pagina = 1;
    $primeraPagina = $pdf->currentPage;
    // i. Agrega el logo de la empresa
    $logofile = "logos/prueba_logo.jpg";
    //TENDRA QUE VENIR DE UN PARAMETRO EN LA BD.
    $pdf->addJpegFromFile($logofile, 30, 655, 200);
    // i. Agrega la leyenda "cancelada"
    if ($row_factura['estatus'] == 0) {
        $pdf->setColor(0.9, 0.9, 0.9);
        $pdf->addText(180, 200, 65, "<b>CANCELADA</b>", -45);
        $pdf->setColor(0, 0, 0);
    }
    // ------------------------------------------ENCABEZADO ------------------------------------------
    //ENCABEZADO DE LA FACTURA
    $tipoDocto = $TIPOSCOMPROBANTEMXP[$row_factura['tipocfd']];
    $emisor = utf8_decode($emisorNode->getAttribute('rfc')) . "\n";
    $emisor .= utf8_decode($emisordomicilioNode->getAttribute('calle') . " " . $emisordomicilioNode->getAttribute('noExterior') . " " . $emisordomicilioNode->getAttribute('noInterior')) . "\n";
    $emisor .= utf8_decode($emisordomicilioNode->getAttribute('colonia'));
    if ($emisordomicilioNode->getAttribute('localidad') != "") {
        $emisor .= "\n" . utf8_decode($emisordomicilioNode->getAttribute('localidad'));
    }
    if ($emisordomicilioNode->getAttribute('municipio') != "") {
        $emisor .= "\n" . utf8_decode($emisordomicilioNode->getAttribute('municipio'));
    }
    if ($emisordomicilioNode->getAttribute('estado') != "") {
        $emisor .= ", " . utf8_decode($emisordomicilioNode->getAttribute('estado'));
    }
    if ($emisordomicilioNode->getAttribute('codigoPostal') != "") {
        $emisor .= "\nCP " . utf8_decode($emisordomicilioNode->getAttribute('codigoPostal'));
    }
    $emisor .= " " . utf8_decode($emisordomicilioNode->getAttribute('pais'));
    $sucursal = "";
    if ($row_sucursal['sucursal'] != "Principal_") {
        $sucursal = "Sucursal " . utf8_decode($row_sucursal['sucursal']) . "\n";
        $sucursal .= utf8_decode($expedidoNode->getAttribute('calle') . " " . $expedidoNode->getAttribute('noExterior') . " " . $expedidoNode->getAttribute('noInterior')) . "\n";
        $sucursal .= utf8_decode($expedidoNode->getAttribute('colonia')) . "\n";
        $sucursal .= utf8_decode($expedidoNode->getAttribute('municipio')) . ", " . utf8_decode($expedidoNode->getAttribute('estado')) . "\n";
        $sucursal .= "CP " . utf8_decode($expedidoNode->getAttribute('codigoPostal')) . " " . utf8_decode($expedidoNode->getAttribute('pais'));
    }
    ////////// i. Nombre del emisor
    $tableData = array(array("dato" => "<b>Obintel S.A. de C.V.</b>"));
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 200));
    $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 9, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 240, 'xOrientation' => 'right', 'width' => 200, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla nombre del emisor
    $pdf->ezSetY(714);
    $pdf->ezTable($tableData, $colNames, "", $options);
    ////////// i. Datos del emisor y de la sucursal
    $tableData = array(array("emisor" => $emisor, "espacio" => "", "sucursal" => $sucursal));
    $colOptions = array("emisor" => array('justification' => 'left', 'width' => 205), "espacio" => array('justification' => 'left', 'width' => 10), "sucursal" => array('justification' => 'left', 'width' => 120));
    $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 240, 'xOrientation' => 'right', 'width' => 335, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla
    $pdf->ezSetDy(-6);
    $pdf->ezTable($tableData, "", "", $options);
    ////////// i. Datos del documento
    $foliodocto = rellena("0", 6, $comprobanteNode->getAttribute('folio'));
    $seriedocto = $comprobanteNode->getAttribute('serie');
    if (!empty($seriedocto)) {
        $foliodocto = $seriedocto . "-" . rellena("0", 6, $comprobanteNode->getAttribute('folio'));
    }
    $fechastr = $comprobanteNode->getAttribute('fecha');
    $fechatok = explode("T", $fechastr);
    $toksf = explode("-", $fechatok[0]);
    $fechastr = $toksf[2] . "-" . $toksf[1] . "-" . $toksf[0] . " " . $fechatok[1];
    $ncert = $comprobanteNode->getAttribute('noCertificado');
    $aprob = $comprobanteNode->getAttribute('anoAprobacion') . "-" . $comprobanteNode->getAttribute('noAprobacion');
    $tableData = array(array("dato" => "<b>" . $tipoDocto . "</b>"), array("dato" => "<b>" . $foliodocto . "</b>"), array("dato" => "Fecha"), array("dato" => $fechastr), array("dato" => "Certificado"), array("dato" => $ncert), array("dato" => "Año y No. Aprobación"), array("dato" => $aprob));
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 120));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(1, 1, 1), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 455, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla datos del documento
    //$pdf->ezSetDy(-12);
    $pdf->ezTable($tableData, "", "", $options);
    ////////// i. Datos del cliente
    $tableData = array(array("dato" => "<b>Cliente</b>"), array("dato" => utf8_decode($receptorNode->getAttribute('nombre'))), array("dato" => utf8_decode($receptorNode->getAttribute('rfc'))), array("dato" => utf8_decode($receptordomicilioNode->getAttribute('calle')) . " " . utf8_decode($receptordomicilioNode->getAttribute('noExterior')) . " " . utf8_decode($receptordomicilioNode->getAttribute('noInterior')) . " " . utf8_decode($receptordomicilioNode->getAttribute('colonia'))), array("dato" => utf8_decode($receptordomicilioNode->getAttribute('municipio')) . ", " . utf8_decode($receptordomicilioNode->getAttribute('estado'))), array("dato" => utf8_decode($receptordomicilioNode->getAttribute('estado'))), array("dato" => utf8_decode($receptordomicilioNode->getAttribute('codigoPostal'))));
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 410));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla datos del cliente
    $pdf->ezSetDy(84);
    $pdf->ezTable($tableData, "", "", $options);
    $actualY = $pdf->y;
    $pdf->setColor(0, 0, 0);
    $pdf->filledRectangle(30, $actualY - 30, 540, 18);
    $pdf->ezSetY($actualY - 15);
    $pdf->setColor(1, 1, 1);
    $pdf->ezText("<b>Cant</b>", 7, array('left' => 18, 'justification' => 'left'));
    $pdf->ezSetY($actualY - 15);
    $pdf->ezText("<b>Descripción</b>", 7, array('left' => 55, 'justification' => 'left'));
    $pdf->ezSetY($actualY - 15);
    $pdf->ezText("<b>Unitario</b>", 7, array('left' => 448, 'justification' => 'left'));
    $pdf->ezSetY($actualY - 15);
    $pdf->ezText("<b>Importe</b>", 7, array('left' => 513, 'justification' => 'left'));
    ////////// i. Partidas
    $tableData = array();
    $renglones = 0;
    $rowData = array("cantidad" => "", "descripcion" => "", "unitario" => "", "importe" => "");
    $partidaCnt = 0;
    foreach ($conceptos as $conceptoNode) {
        $partidaCnt++;
        $renglones += 2;
        $currentObj = array();
        $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode->getAttribute('cantidad'))), 0);
        $currentObj["descripcion"] = utf8_decode($conceptoNode->getAttribute('descripcion'));
        $currentObj["unitario"] = number_format($conceptoNode->getAttribute('valorUnitario'), 2);
        $currentObj["importe"] = number_format(doubleval($conceptoNode->getAttribute('importe')), 2);
        array_push($tableData, $currentObj);
    }
    $currentObj = array();
    $currentObj["cantidad"] = "";
    $currentObj["descripcion"] = "";
    $currentObj["unitario"] = "";
    $currentObj["importe"] = "";
    if ($renglones < 10) {
        for ($renglones; $renglones < 10; $renglones++) {
            array_push($tableData, $currentObj);
        }
    }
    $colNames = array("cantidad" => "<b>Cant</b>", "descripcion" => "<b>Descripción</b>", "unitario" => "<b>Unitario</b>", "importe" => "<b>Precio</b>");
    $colOptions = array("cantidad" => array('justification' => 'center', 'width' => 50), "descripcion" => array('justification' => 'left', 'width' => 370), "unitario" => array('justification' => 'right', 'width' => 60), "importe" => array('justification' => 'right', 'width' => 60));
    $options = array('showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 4, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla partidas
    $pdf->ezSetDy(11);
    $pdf->ezTable($tableData, $colNames, "", $options);
    ////////// i. Cantidad con letra
    $cadena = covertirNumLetras(number_format($comprobanteNode->getAttribute('total'), 2, ".", ''));
    $tableData = array(array("dato" => "<b>Total con letra</b>\n" . trim($cadena)));
    $colNames = array("dato" => "<b>Cant</b>");
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 420));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 10, 'colGap' => 10, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla cantidad con letra
    $pdf->ezSetDy(0);
    $pdf->ezTable($tableData, $colNames, "", $options);
    ////////// i. Totales
    $f_importe = "\$" . number_format($comprobanteNode->getAttribute('subTotal'), 2);
    $f_iva_T = $impuestosNode->getAttribute('totalImpuestosTrasladados');
    $f_total = "\$" . number_format($comprobanteNode->getAttribute('total'), 2);
    $tableData = array();
    $rowData = array("leyenda" => "", "cantidad" => "");
    $subtotal = array("dato" => "Subtotal", "valor" => $f_importe);
    array_push($tableData, $subtotal);
    foreach ($traslados as $trasladoNode) {
        $tasaImpuesto = array();
        $tasaImpuesto_t = number_format($trasladoNode->getAttribute('tasa'), 0);
        $tasaImpuesto["dato"] = $trasladoNode->getAttribute('impuesto') . " " . $tasaImpuesto_t . "%";
        $tasaImpuesto["valor"] = "\$" . number_format($trasladoNode->getAttribute('importe'), 2);
        array_push($tableData, $tasaImpuesto);
    }
    foreach ($retenciones as $retencionNode) {
        $tasaImpuesto = array();
        $tasaImpuesto_t = number_format($retencionNode->getAttribute('tasa'), 0);
        $tasaImpuesto["dato"] = "Ret. " . $retencionNode->getAttribute('impuesto') . " " . $tasaImpuesto_t . "%";
        $tasaImpuesto["valor"] = "\$" . number_format($retencionNode->getAttribute('importe'), 2);
        array_push($tableData, $tasaImpuesto);
    }
    $total = array("dato" => "<b>Total</b>", "valor" => "<b>" . $f_total . "</b>");
    array_push($tableData, $total);
    $colNames = array("dato" => "<b>Cant</b>", "valor" => "Precio");
    $colOptions = array("dato" => array('justification' => 'right', 'width' => 60), "valor" => array('justification' => 'right', 'width' => 60));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 3, 'colGap' => 5, 'xPos' => 455, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla totales
    $pdf->ezSetDy(36);
    $pdf->ezTable($tableData, $colNames, "", $options);
    ////////// i. Sello
    $tableData = array(array("dato" => "<b>Sello Digital</b>\n" . $row_factura['sello']));
    $colNames = array("dato" => "<b>Cant</b>");
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 400));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 10, 'colGap' => 10, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla sello
    $pdf->ezSetDy(-5);
    $pdf->ezTable($tableData, $colNames, "", $options);
    ////////// i. Cadena original
    $tableData = array(array("dato" => "<b>Cadena Original</b>\n" . utf8_decode(utf8_decode($row_factura['cadena']))));
    $colNames = array("dato" => "<b>Cant</b>");
    $colOptions = array("dato" => array('justification' => 'left', 'width' => 400));
    $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 10, 'colGap' => 10, 'xPos' => 40, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
    // Dibuja la tabla cadena original
    $pdf->ezSetDy(-5);
    $pdf->ezTable($tableData, $colNames, "", $options);
    // Leyendas
    $pdf->ezSetDy(-12);
    $leyendas = 'EFECTOS FISCALES AL PAGO. PAGO EN UNA SOLA EXHIBICION. ESTE DOCUMENTO ES UNA IMPRESION DE UN COMPROBANTE FISCAL DIGITAL';
    $pdf->setColor(0.5, 0.5, 0.5);
    $pdf->ezText($leyendas, 5, array('left' => 0, 'justification' => 'left'));
    $pdf->setColor(0, 0, 0);
    //REGRESA PARA PONER ENCABEZADO EN PAGINAS 2 ->
    if ($pdf->ezPageCount > 1) {
        $datos = array();
        $datos['logo'] = $logofile;
        $datos['totalPaginas'] = $pdf->ezPageCount;
        $datos['tipoDocto'] = $tipoDocto;
        $datos['foliodocto'] = $foliodocto;
        $datos['fechastr'] = $fechastr;
        for ($pn = 2; $pn <= $pdf->ezPageCount; $pn++) {
            $datos['paginaActual'] = $pn;
            //a partir de la segunda pagina.
            $pdf->reopenObject($pdf->ezPages[$pn]);
            headerDoc($pdf, $datos);
        }
    }
    //ESCRIBE REPORTE AL ARCHIVO.
    //================================================================================
    $pdfcode = $pdf->output();
    //save the file
    if ($tmpName) {
        $nombrePDF = tempnam("tmp/", 'face5') . ".pdf";
        $nombreToks = explode("/", $nombrePDF);
        if (count($nombreToks) < 2) {
            $nombreToks = explode("\\", $nombrePDF);
        }
        $lastTok = count($nombreToks) - 1;
        $nombrePDF = $nombreToks[$lastTok];
        $archivoPDF = "tmp/" . $nombrePDF;
        $archivos = array($nombrePDF, $archivoPDF);
    } else {
        $nombrePDF = $tipoDocto . "_" . $row_factura['serie'] . $row_factura['folio'] . ".pdf";
        $archivoPDF = "tmp/" . $nombrePDF;
        $archivos = array($nombrePDF, $archivoPDF);
    }
    $fp = fopen($archivoPDF, 'w');
    fwrite($fp, $pdfcode);
    fclose($fp);
    return $archivos;
}
<?php

header('Content-Type: application/json');
error_reporting(0);
require_once 'conexion.php';
require_once '../plugins/ezpdf/Cezpdf.php';
conectarse();
$pdf = new Cezpdf('a4');
$tmp = array('b' => 'Helvetica-Bold', 'i' => 'Courier-Oblique', 'bi' => 'Helvetica-BoldOblique', 'ib' => 'Helvetica-BoldOblique', 'bb' => 'Times-Roman');
$pdf->setFontFamily('Helvetica', $tmp);
$pdf->selectFont('fonts/Helvetica.afm');
$pdf->ezSetCmMargins(1.5, 1, 2, 3);
$pdf->addJpegFromFile("../img/o.jpg", 50, 750, 100);
$folio = trim($_GET['folio']);
$result = mysql_query("select folio,fecha,c.nombre_contacto,total,\n\tconcat(nombre,' ',e.apellido_paterno,' ',e.apellido_materno) as nombre \n\tfrom ventas v inner join clientes c on c.matricula = v.cliente \n\tinner join empleados e on e.matricula = v.empleado \n\twhere v.status = 'PAGADA' and folio = '" . $folio . "' ");
while ($datatmp = mysql_fetch_array($result)) {
    $datos = $datatmp['nombre_contacto'];
    $total = $datatmp['total'];
    $emp = $datatmp['nombre'];
    $data[] = array_merge($datatmp, array('folio'));
}
$options = array('shadeHeadingCol' => array(0.6, 0.6, 0.5), 'shadeCol' => array(0.9, 0.9, 0.9), 'xOrientation' => 'right', 'width' => 70, 'fontSize' => 8, 'xPos' => 480);
$titlef = array('folio' => '<b>Folio</b>');
$titles = array('fecha' => '<b>Fecha</b>');
$titlet = array('total' => '<b>Total</b>');
$pdf->ezText("\n", 10);
$pdf->ezTable($data, $titlef, '', $options);
$pdf->ezText("\n", 10);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n", 10);
$pdf->addText(50, 700, 12, "<b>Atendio: </b>\n");
 function saldenliste_mv_pdf($monat, $jahr)
 {
     ob_clean();
     // ausgabepuffer leeren
     /* PDF AUSGABE */
     //include_once ('pdfclass/class.ezpdf.php');
     $pdf = new Cezpdf('a4', 'portrait');
     $pdf->selectFont('Helvetica.afm');
     $pdf->ezSetCmMargins(4.5, 0, 0, 0);
     /* Kopfzeile */
     $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
     $pdf->setLineStyle(0.5);
     $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de");
     $pdf->line(42, 750, 550, 750);
     /* Footer */
     $pdf->line(42, 50, 550, 50);
     $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG *  Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim");
     $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin * BLZ: 100  800  00 * Konto-Nr.: 05 804 000 00 * Steuernummer: 24/582/61188");
     $pdf->addInfo('Title', "Saldenliste {$objekt_name} {$monatname} {$jahr}");
     $pdf->addInfo('Author', $_SESSION[username]);
     $pdf->ezStartPageNumbers(550, 755, 7, '', "Seite {PAGENUM} von {TOTALPAGENUM}");
     // echo "Monatsbericht Mieter - Monatsbericht Kostenkonten<br>";
     // echo "<h3>Aktuelle Mieterstatistik mit ausgezogene Mieter<br></h3>";
     $s = new statistik();
     $jahr = $_REQUEST[jahr];
     if (empty($jahr)) {
         $jahr = date("Y");
     } else {
         if (strlen($jahr) < 4) {
             $jahr = date("Y");
         }
     }
     // $jahr_monat = date("Y-m");
     // $jahr = date("Y");
     $monat = $_REQUEST[monat];
     if (empty($monat)) {
         $monat = date("m");
     } else {
         if (strlen($monat) < 2) {
             $monat = '0' . $monat;
         }
     }
     // $monat = '04';
     $jahr_monat = $jahr . '-' . $monat;
     // $jahr_vormonat = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
     // $jahr_vormonat = date("Y-m",$jahr_vormonat);
     $bg = new berlussimo_global();
     $link = "?daten=mietvertrag_raus&mietvertrag_raus=saldenliste";
     $bg->objekt_auswahl_liste($link);
     $bg->monate_jahres_links($jahr, $link);
     if (isset($_SESSION['objekt_id'])) {
         $objekt_id = $_SESSION['objekt_id'];
         $einheit_info = new einheit();
         $o = new objekt();
         $objekt_name = $o->get_objekt_name($objekt_id);
         $monatname = monat2name($monat);
         $pdf->addText(70, 755, 10, "Saldenliste {$objekt_name} {$monatname} {$jahr}");
         $pdf->ezSetDy(25);
         $pdf->ezSetCmMargins(3, 3, 3, 3);
         $text_options = array(left => 0, justification => 'left');
         $pdf->ezText("<b>Einheit</b>", 8, $text_options);
         $pdf->ezSetDy(9);
         $text_options = array(left => 100, justification => 'left');
         $pdf->ezText("<b>Mieter</b>", 8, $text_options);
         $pdf->ezSetDy(9);
         $text_options = array(left => 270, justification => 'left');
         $pdf->ezText("<b>Einzug</b>", 8, $text_options);
         $pdf->ezSetDy(9);
         $text_options = array(left => 320, justification => 'left');
         $pdf->ezText("<b>Auszug</b>", 8, $text_options);
         $pdf->ezSetDy(9);
         $text_options = array(right => 0, justification => 'right');
         $pdf->ezText("<b>SALDO EUR</b>", 8, $text_options);
         /* Aktuell bzw. gewünschten Monat berechnen */
         $ob = new objekt();
         $einheiten_array = $ob->einheiten_objekt_arr($objekt_id);
         // $einheiten_array = $s->vermietete_monat_jahr($jahr_monat,$objekt_id, '');
         /*
          * echo "<pre>";
          * print_r($einheiten_array);
          * echo "<h1> EINHEITEN: $anzahl_aktuell</h1>";
          * $mv_array = $einheit_info->get_mietvertrag_ids('7');
          * print_r($mv_array);
          */
         $summe_sv = 0;
         $summe_mieten = 0;
         $summe_umlagen = 0;
         $summe_akt_gsoll = 0;
         $summe_g_zahlungen = 0;
         $summe_saldo_neu = 0;
         $anzahl_aktuell = count($einheiten_array);
         $miete = new miete();
         $zeilen_pro_seite = 60;
         $aktuelle_zeile = 0;
         for ($i = 0; $i < $anzahl_aktuell; $i++) {
             $mv_array = $einheit_info->get_mietvertraege_bis("" . $einheiten_array[$i]['EINHEIT_ID'] . "", $jahr, $monat);
             $mv_anzahl = count($mv_array);
             if (is_array($mv_array)) {
                 for ($b = 0; $b < $mv_anzahl; $b++) {
                     $mv_id = $mv_array[$b]['MIETVERTRAG_ID'];
                     $mk = new mietkonto();
                     $mieter_ids = $mk->get_personen_ids_mietvertrag($mv_id);
                     for ($a = 0; $a < count($mieter_ids); $a++) {
                         $mieter_daten_arr[] = $mk->get_person_infos($mieter_ids[$a][PERSON_MIETVERTRAG_PERSON_ID]);
                     }
                     // $miete->mietkonto_berechnung_monatsgenau($mv_id, $jahr, $monat);
                     $end_saldoo = $miete->saldo_berechnen_monatsgenau($mv_id, $monat, $jahr);
                     $zeile = $zeile + 1;
                     $einheit_kurzname = $einheiten_array[$i]['EINHEIT_KURZNAME'];
                     $vn = RTRIM(LTRIM($mieter_daten_arr['0']['0']['PERSON_VORNAME']));
                     $nn = RTRIM(LTRIM($mieter_daten_arr['0']['0']['PERSON_NACHNAME']));
                     $akt_gesamt_soll = $miete->saldo_vormonat_stand + $miete->sollmiete_warm;
                     $this->get_mietvertrag_infos_aktuell($mv_id);
                     $l_tag_akt_monat = letzter_tag_im_monat($monat, $jahr);
                     $l_datum = "{$jahr}-{$monat}-{$l_tag_akt_monat}";
                     if ($this->mietvertrag_bis == '0000-00-00' or $this->mietvertrag_bis > $l_datum) {
                         $mv_bis = 'aktuell';
                     } else {
                         $mv_bis = date_mysql2german($this->mietvertrag_bis);
                     }
                     $mv_von = date_mysql2german($this->mietvertrag_von);
                     $end_saldoo = nummer_punkt2komma($end_saldoo);
                     if ($mv_bis == 'aktuell') {
                         // echo "$zeile. $einheit_kurzname $nn $vn SALDO NEU: $end_saldoo <br>";
                         $pdf->ezSetCmMargins(3, 3, 3, 3);
                         $text_options = array(left => 0, justification => 'left');
                         $pdf->ezText("{$einheit_kurzname}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 100, justification => 'left');
                         $pdf->ezText("{$nn} {$vn}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 270, justification => 'left');
                         $pdf->ezText("{$mv_von}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 320, justification => 'left');
                         $pdf->ezText("", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(right => 0, justification => 'right');
                         $pdf->ezText("{$end_saldoo}", 8, $text_options);
                         $aktuelle_zeile++;
                     } else {
                         // echo "<b>$zeile. $einheit_kurzname $nn $vn SALDO NEU: $end_saldoo € BEENDET AM :$mv_bis €</b><br>";
                         $pdf->ezSetCmMargins(3, 3, 3, 3);
                         $text_options = array(left => 0, justification => 'left');
                         $pdf->ezText("{$einheit_kurzname}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 100, justification => 'left');
                         $pdf->ezText("{$nn} {$vn}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 270, justification => 'left');
                         $pdf->ezText("{$mv_von}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 320, justification => 'left');
                         $pdf->ezText("{$mv_bis}", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(right => 0, justification => 'right');
                         $pdf->ezText("{$end_saldoo}", 8, $text_options);
                         $aktuelle_zeile++;
                     }
                     if ($zeilen_pro_seite == $aktuelle_zeile) {
                         $pdf->ezNewPage();
                         /* Kopfzeile */
                         $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
                         $pdf->setLineStyle(0.5);
                         $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de");
                         $pdf->line(42, 750, 550, 750);
                         /* Footer */
                         $pdf->line(42, 50, 550, 50);
                         $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG *  Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim");
                         $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin * BLZ: 100  800  00 * Konto-Nr.: 05 804 000 00 * Steuernummer: 24/582/61188");
                         $pdf->addInfo('Title', "Saldenliste {$objekt_name} {$monatname} {$jahr}");
                         $pdf->addText(70, 755, 10, "Saldenliste  {$objekt_name} {$monatname} {$jahr}");
                         $pdf->ezStartPageNumbers(550, 755, 7, '', "Seite {PAGENUM} von {TOTALPAGENUM}");
                         /* Überschriftzeile */
                         $pdf->ezSetDy(-18);
                         $pdf->ezSetCmMargins(3, 3, 3, 3);
                         $text_options = array(left => 0, justification => 'left');
                         $pdf->ezText("<b>Einheit</b>", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 100, justification => 'left');
                         $pdf->ezText("<b>Mieter</b>", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 270, justification => 'left');
                         $pdf->ezText("<b>Einzug</b>", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(left => 320, justification => 'left');
                         $pdf->ezText("<b>Auszug</b>", 8, $text_options);
                         $pdf->ezSetDy(9);
                         $text_options = array(right => 0, justification => 'right');
                         $pdf->ezText("<b>SALDO EUR</b>", 8, $text_options);
                         $aktuelle_zeile = 0;
                     }
                     unset($mieter_daten_arr);
                     unset($nn);
                     unset($vn);
                 }
                 // end if is_array mv_ids
             }
         }
         // hinweis_ausgeben("Saldenliste mit Vormieter für $objekt_name wurde erstellt<br>");
         ob_clean();
         // ausgabepuffer leeren
         $pdf->ezStopPageNumbers();
         $pdf->ezStream();
         /* Falls kein Objekt ausgewählt */
     } else {
         echo "Objekt auswählen";
     }
 }
Beispiel #5
0
        $b = new buchen();
        $link = "?daten=buchen&option=konto";
        $form = new formular();
        $form->fieldset("Monatsbericht", 'monatsbericht');
        $b->monatsbericht_mit_ausgezogenen();
        $form->fieldset_ende();
        break;
    case "test":
        ob_clean();
        // ausgabepuffer leeren
        //include_once ('pdfclass/class.ezpdf.php');
        $pdf = new Cezpdf('a4', 'portrait');
        $pdf->ezSetCmMargins(4.5, 2.5, 2.5, 2.5);
        $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm';
        $text_schrift = 'pdfclass/fonts/Arial.afm';
        $pdf->addJpegFromFile('includes/logos/hv_logo198_80.jpg', 450, 780, 100, 42);
        $pdf->setLineStyle(0.5);
        $pdf->selectFont($berlus_schrift);
        $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin");
        $pdf->line(42, 750, 550, 750);
        $seite = $pdf->ezGetCurrentPageNumber();
        $alle_seiten = $pdf->ezPageCount;
        $data55 = array(array('num' => 1, 'name' => 'gandalf', 'type' => 'wizard'), array('num' => 2, 'name' => 'bilbo', 'type' => 'hobbit', 'url' => 'http://www.ros.co.
nz/pdf/'), array('num' => 3, 'name' => 'frodo', 'type' => 'hobbit'), array('num' => 4, 'name' => 'saruman', 'type' => 'bad
dude', 'url' => 'http://sourceforge.net/projects/pdf-php'), array('num' => 5, 'name' => 'sauron', 'type' => 'really bad dude'));
        $pdf->ezTable($data55);
        // header('Content-type: application/pdf');
        // header('Content-Disposition: attachment; filename="downloaded.pdf"');
        // $output = $pdf->Output();
        // $len = strlen($output);
        // header("Content-type: application/pdf"); // wird von MSIE ignoriert
Beispiel #6
0
session_start();
if (empty($_SESSION['username']) and empty($_SESSION['passuser'])) {
    echo "<link href='style.css' rel='stylesheet' type='text/css'>\n <center>Untuk mengakses modul, Anda harus login <br>";
    echo "<a href=../../index.php><b>LOGIN</b></a></center>";
} else {
    include "class.ezpdf.php";
    include "../../../config/koneksi.php";
    include "rupiah.php";
    $pdf = new Cezpdf();
    // Set margin dan font
    $pdf->ezSetCmMargins(3, 3, 3, 3);
    $pdf->selectFont('fonts/Courier.afm');
    $all = $pdf->openObject();
    // Tampilkan logo
    $pdf->setStrokeColor(0, 0, 0, 1);
    $pdf->addJpegFromFile('logo.jpg', 20, 800, 69);
    // Teks di tengah atas untuk judul header
    $pdf->addText(220, 820, 16, '<b>Laporan Penjualan</b>');
    $pdf->addText(200, 800, 18, '<b>Toko Komputer Wincom</b>');
    // Garis atas untuk header
    $pdf->line(10, 795, 578, 795);
    // Garis bawah untuk footer
    $pdf->line(10, 50, 578, 50);
    // Teks kiri bawah
    $pdf->addText(30, 34, 8, 'Dicetak tgl:' . date('d-m-Y, H:i:s'));
    $pdf->closeObject();
    // Tampilkan object di semua halaman
    $pdf->addObject($all, 'all');
    // Baca input tanggal yang dikirimkan user
    $mulai = $_POST[thn_mulai] . '-' . $_POST[bln_mulai] . '-' . $_POST[tgl_mulai];
    $selesai = $_POST[thn_selesai] . '-' . $_POST[bln_selesai] . '-' . $_POST[tgl_selesai];
Beispiel #7
0
    /**
     * gera um pdf dos laudos
	 *
	 * @param array $r
     */
	function pdfLaudos($rs){
	
		//error_reporting(E_ALL);
		set_time_limit(1800);
		include 'lib/php/classes/class.ezpdf.php';
		
		$pdf = new Cezpdf('a4','portrait');
		$pdf -> ezSetMargins(50,70,50,50);
		$all = $pdf->openObject();
		$pdf->saveState();
		$pdf->setStrokeColor(0,0,0,1);
		$pdf->restoreState();
		$pdf->closeObject();
		$pdf->addObject($all,'all');
		$mainFont = './fonts/Courier.afm';
		$codeFont = './fonts/Courier.afm';
		$pdf->selectFont($mainFont);
		$n_rows = sizeof($rs);

		$c = 0;
		$t=945;
		$fator = 25;
		foreach($rs as $id => $r){
			$o = new Interpretacao($r["int_id"]);
			
			$hos = new Hospital($o->get("hos_id"));
			$hos_nome = $hos->get("hos_nome");
			
			$con = new Convenio($o->get("con_id"));
			$con_nome = $con->get("con_nome");
			
			$exa = new Exame($o->get("exa_id"));
			$exa_nome = $exa->get("exa_nome");
			
			$pdf->ezText($hos_nome,18,array('justification'=>'center')); 
			$pdf->ezText(" ",20,array('justification'=>'left'));
			$pdf->ezText("PACIENTE      : ".$r["int_paciente_prontuario"]."   ".$r["int_paciente_nome"],10,array('justification'=>'left'));

			if ($r["int_paciente_nascimento"] == "0000-00-00")
				$pdf->ezText("NASCIMENTO    :                                   SEXO: ".$r["int_paciente_sexo"],10,array('justification'=>'left'));
			else
				$pdf->ezText("NASCIMENTO    : ".Formatacao::formatBrData($r["int_paciente_nascimento"])."                        SEXO: ".$r["int_paciente_sexo"],10,array('justification'=>'left'));
		
			$pdf->ezText("CONVÊNIO      : ".$con_nome,10,array('justification'=>'left'));
			$pdf->ezText("EXAME         : ".$exa_nome,10,array('justification'=>'left'));

			$pdf->ezText(" ",20,array('justification'=>'left'));

			$pdf->ezText("                                                  DATA: ".Formatacao::formatBrDataHoraminSeg($r["int_data_interpretacao"]),10,array('justification'=>'left'));
			$pdf->ezText("N DO EXAME               : ".$r["int_opcional"],10,array('justification'=>'left'));
			$pdf->ezText("MÉDICO REQUISITANTE      : ".$r["int_requisitante"],10,array('justification'=>'left'));
			$pdf->ezText("EXAME INTERPRETADO POR   : 9679 Ernesto Sousa Nunes",10,array('justification'=>'left'));
			$pdf->ezText("TÉCNICO RX               : ".$r["int_tecnico_rx"],10,array('justification'=>'left'));
			
			$pdf->ezText(" ",20,array('justification'=>'left'));
			
			$pdf->ezText("I N T E R P R E T A Ç Ã O",18,array('justification'=>'center')); 
			
			$pdf->ezText(" ",20,array('justification'=>'left'));
			
			$vet_txt = split("\n",$r["int_texto"]);
			
			$pdf->ezText("============================================================================",10,array('justification'=>'left'));
			
			$pdf->ezText(" ",8,array('justification'=>'left'));
			
			foreach($vet_txt as $linha){
				$pdf->ezText("      ".$linha,10,array('justification'=>'left'));
			}
			$pdf->ezText(" ",8,array('justification'=>'left'));
			
			$pdf->ezText("============================================================================",10,array('justification'=>'left'));
			
			$pdf->ezText("              Exame interpretado por: 9676 - Dr. Ernesto Sousa Nunes",10,array('justification'=>'left'));
			$pdf->addJpegFromFile('ass.jpg',250, 0);
			$pdf->openHere('Fit');
			if ($c+1 < $n_rows)
				$pdf->ezNewPage();
			$c++;
			
			$o->informaImpressao();
			//$sql = "update laudo set LAU_DATA_EXPORTACAO = now() where LAU_ID = ".$r["LAU_ID"]." LIMIT 1";
			//$up = mysql_query($sql, $db) or die(mysql_error());
		 }
		
		$pdfcode = $pdf->Output();
		//$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
		//$cont = trim($pdfcode);
		$fh = fopen("laudos_prontos.pdf", 'w+');
		fwrite($fh, $pdfcode);
		fclose($fh);
		?><script language="javascript">document.location.href="laudos_prontos.pdf";</script><?

	}
 /**
  * Crea un pdf con el estado de cuenta de el cliente especificado
  * @param Array $args,  $args['id_cliente'=>12[,'tipo_venta'=> 'credito | contado | saldo'] ], por default obtiene todas las compras del cliente
  */
 public static function imprimirEstadoCuentaCliente($args)
 {
     //verificamos que se haya especificado el id del cliente
     if (!isset($args['id_cliente'])) {
         Logger::log("Error al obtener el estado de cuenta, no se ha especificado un cliente.");
         die('{"success": false, "reason": "Error al obtener el estado de cuenta, no se ha especificado un cliente."}');
     }
     //verificamos que el cliente exista
     if (!($cliente = ClienteDAO::getByPK($args['id_cliente']))) {
         Logger::log("Error al obtener el estado de cuenta, no se tiene registro del cliente {$args['id_cliente']}.");
         die('{"success": false, "reason": "Error al obtener el estado de cuenta, no se tiene registro del cliente ' . $args['id_cliente'] . '"}');
     }
     //obtenemos los datos del emisor
     $estado_cuenta = estadoCuentaCliente($args);
     //buscar los datos del emisor
     if (!($emisor = PosConfigDAO::getByPK('emisor'))) {
         Logger::log("no encuentro los datos del emisor");
         die("no encuentro los datos del emisor");
     }
     $emisor = json_decode($emisor->getValue())->emisor;
     $sucursal = SucursalDAO::getByPK($_SESSION['sucursal']);
     if (!$sucursal) {
         die("Sucursal invalida");
     }
     include_once 'librerias/ezpdf/class.pdf.php';
     include_once 'librerias/ezpdf/class.ezpdf.php';
     $pdf = new Cezpdf();
     $pdf->selectFont('../server/librerias/ezpdf/fonts/Helvetica.afm');
     //margenes de un centimetro para toda la pagina
     $pdf->ezSetMargins(1, 1, 1, 1);
     /*
      * LOGO
      */
     if (!($logo = PosConfigDAO::getByPK('url_logo'))) {
         Logger::log("Verifique la configuracion del pos_config, no se encontro el camṕo 'url_logo'");
         die("Verifique la configuracion del POS, no se encontro el url del logo");
     }
     //addJpegFromFile(imgFileName,x,y,w,[h])
     //detectamos el tipo de imagen del logo
     if (substr($logo->getValue(), -3) == "jpg" || substr($logo->getValue(), -3) == "JPG" || substr($logo->getValue(), -4) == "jpeg" || substr($logo->getValue(), -4) == "JPEG") {
         $pdf->addJpegFromFile($logo->getValue(), puntos_cm(2), puntos_cm(25.5), puntos_cm(3.5));
     } elseif (substr($logo->getValue(), -3) == "png" || substr($logo->getValue(), -3) == "PNG") {
         $pdf->addPngFromFile($logo->getValue(), puntos_cm(2), puntos_cm(25.5), puntos_cm(3.5));
     } else {
         Logger::log("Verifique la configuracion del pos_config, la extension de la imagen del logo no es compatible");
         die("La extension de la imagen usada para el logo del negocio no es valida.");
     }
     /*     * ************************
      * ENCABEZADO
      * ************************* */
     $e = "<b>" . self::readableText($emisor->nombre) . "</b>\n";
     $e .= formatAddress($emisor);
     $e .= "RFC: " . $emisor->rfc . "\n\n";
     //datos de la sucursal
     $e .= "<b>Lugar de expedicion</b>\n";
     $e .= self::readableText($sucursal->getDescripcion()) . "\n";
     $e .= formatAddress($sucursal);
     $datos = array(array("emisor" => $e));
     $pdf->ezSetY(puntos_cm(28.6));
     $opciones_tabla = array();
     $opciones_tabla['showLines'] = 0;
     $opciones_tabla['showHeadings'] = 0;
     $opciones_tabla['shaded'] = 0;
     $opciones_tabla['fontSize'] = 8;
     $opciones_tabla['xOrientation'] = 'right';
     $opciones_tabla['xPos'] = puntos_cm(7.3);
     $opciones_tabla['width'] = puntos_cm(11);
     $opciones_tabla['textCol'] = array(0, 0, 0);
     $opciones_tabla['titleFontSize'] = 12;
     $opciones_tabla['rowGap'] = 3;
     $opciones_tabla['colGap'] = 3;
     $pdf->ezTable($datos, "", "", $opciones_tabla);
     $cajero = UsuarioDAO::getByPK($_SESSION['userid'])->getNombre();
     $datos = array(array("col" => "<b>Cajero</b>"), array("col" => self::readableText($cajero)), array("col" => "<b>Cliente</b>"), array("col" => self::readableText($cliente->getRazonSocial())), array("col" => "<b>Limite de  Credito</b>"), array("col" => FormatMoney($estado_cuenta->limite_credito, DONT_USE_HTML)), array("col" => "<b>Saldo</b>"), array("col" => FormatMoney($estado_cuenta->saldo, DONT_USE_HTML)));
     $pdf->ezSetY(puntos_cm(28.8));
     $opciones_tabla['xPos'] = puntos_cm(12.2);
     $opciones_tabla['width'] = puntos_cm(6);
     $opciones_tabla['showLines'] = 0;
     $opciones_tabla['shaded'] = 2;
     $opciones_tabla['shadeCol'] = array(1, 1, 1);
     //$opciones_tabla['shadeCol2'] = array(0.054901961, 0.756862745, 0.196078431);
     $opciones_tabla['shadeCol2'] = array(0.8984375, 0.95703125, 0.99609375);
     $pdf->ezTable($datos, "", "", $opciones_tabla);
     //roundRect($pdf, puntos_cm(12.2), puntos_cm(28.8), puntos_cm(6), puntos_cm(4.25));
     /**
      * ESTADO DE CUENTA
      */
     $elementos = array(array('id_venta' => 'Venta', 'fecha' => 'Fecha', 'sucursal' => 'Sucursal', 'cajero' => 'Cajero', 'tipo_venta' => 'Tipo', 'tipo_pago' => 'Pago', 'total' => 'Total', 'pagado' => 'Pagado', 'saldo' => 'Saldo'));
     foreach ($estado_cuenta->array_ventas as $venta) {
         $array_venta = array();
         $array_venta['id_venta'] = $venta['id_venta'];
         $array_venta['fecha'] = $venta['fecha'];
         $array_venta['sucursal'] = self::readableText($venta['sucursal']);
         $array_venta['cajero'] = self::readableText($venta['cajero']);
         $array_venta['cancelada'] = self::readableText($venta['cancelada']);
         $array_venta['tipo_venta'] = self::readableText($venta['tipo_venta']);
         $array_venta['tipo_pago'] = self::readableText($venta['tipo_pago']);
         $array_venta['total'] = FormatMoney($venta['total'], DONT_USE_HTML);
         $array_venta['pagado'] = FormatMoney($venta['pagado'], DONT_USE_HTML);
         $array_venta['saldo'] = FormatMoney($venta['saldo'], DONT_USE_HTML);
         array_push($elementos, $array_venta);
     }
     $pdf->ezText("", 8, array('justification' => 'center'));
     $pdf->ezSetY(puntos_cm(24));
     $opciones_tabla['xPos'] = puntos_cm(2);
     $opciones_tabla['width'] = puntos_cm(16.2);
     $pdf->ezTable($elementos, "", "Estado de Cuenta", $opciones_tabla);
     //roundRect($pdf, puntos_cm(2), puntos_cm(24.3), puntos_cm(16.2), puntos_cm(3.2));
     /*     * ************************
      * notas de abajo
      * ************************* */
     $pdf->setLineStyle(1);
     $pdf->setStrokeColor(0.3359375, 0.578125, 0.89453125);
     $pdf->line(puntos_cm(2), puntos_cm(1.3), puntos_cm(18.2), puntos_cm(1.3));
     $pdf->addText(puntos_cm(2), puntos_cm(1.0), 7, "Fecha de impresion: " . date("d/m/y") . " " . date("H:i:s"));
     //addJpegFromFile(imgFileName,x,y,w,[h])
     //$pdf->addJpegFromFile("../www/media/logo_simbolo.jpg", puntos_cm(15.9), puntos_cm(.25), 25);
     $pdf->addText(puntos_cm(16.7), puntos_cm(0.6), 8, "caffeina.mx");
     $pdf->ezStream();
 }
<?php

header('Content-Type: application/json');
error_reporting(0);
require_once 'conexion.php';
require_once '../ezpdf/Cezpdf.php';
conectarse();
$pdf = new Cezpdf('a4');
$tmp = array('b' => 'Helvetica-Bold', 'i' => 'Courier-Oblique', 'bi' => 'Helvetica-BoldOblique', 'ib' => 'Helvetica-BoldOblique', 'bb' => 'Times-Roman');
$pdf->setFontFamily('Helvetica', $tmp);
$pdf->selectFont('fonts/Helvetica.afm');
$pdf->ezSetCmMargins(1.5, 1, 2, 3);
$pdf->addJpegFromFile("../img/libro.jpg", 50, 750, 60);
$result = mysql_query("select matricula,\n\tconcat(nombre,' ',apellido_paterno,' ',apellido_materno) as nombre,\n\tconcat(calle,' ',numero,' ',colonia,'') as direccion,ciudad,estado,telefono,celular,sueldo,tipo\n\t\t\t\t\t\tfrom empleados \n\t\t\t\t\t\twhere status = 'ACTIVO'  ");
while ($datatmp = mysql_fetch_array($result)) {
    $data[] = array_merge($datatmp, array('matricula'));
}
$options = array('shadeHeadingCol' => array(0.6, 0.6, 0.5), 'shadeCol' => array(0.9, 0.9, 0.9), 'xOrientation' => 'center', 'width' => 550, 'fontSize' => 8, 'xPos' => 'center');
$titles = array('matricula' => '<b>ID</b>', 'nombre' => '<b>NOMBRE</b>', 'direccion' => '<b>DIRECCIÓN</b>', 'ciudad' => '<b>CIUDAD</b>', 'estado' => '<b>ESTADO</b>', 'telefono' => '<b>TELÉFONO</b>', 'celular' => '<b>CELULAR</b>', 'sueldo' => '<b>SUELDO</b>', 'tipo' => '<b>TIPO</b>');
$pdf->ezText("\n\n\n\n\n", 10);
$pdf->ezTable($data, $titles, '', $options);
//cabecera del pdf (objeto para todas las páginas)
$all = $pdf->openObject();
$pdf->saveState();
$pdf->line($pdf->ez['leftMargin'], $pdf->ez['bottomMargin'] + 10, $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'], $pdf->ez['bottomMargin'] + 10);
//the bottom line
$pdf->addText(200, 790, 12, "<b>Distribuciones y Representaciones Arvizu </b>\n");
$pdf->addText(230, 770, 12, "<i>!Leer Aumenta el Saber! </i>\n");
$pdf->addText(240, 740, 12, "<b>Listado Empleados </b>\n");
$pdf->ezText("\n\n\n", 10);
$pdf->addText(50, 30, 8, "<b>Fecha: </b>\n" . date("d/m/Y"));
Beispiel #10
0
    // the cell padding effect
    define('PRODUCT_TABLE_LEFT_MARGIN', '2');
    // Height of the product listing rectangles
    define('PRODUCT_TABLE_ROW_HEIGHT', '11');
    // The column sizes are where the product listing columns start on the
    // PDF page, if you make the TABLE HEADER FONT SIZE any larger you will
    // need to tweak these values to prevent text from clashing together
    define('PRODUCTS_COLUMN_SIZE', '165');
    define('PRODUCT_LISTING_BKGD_COLOR', GREY);
    define('MODEL_COLUMN_SIZE', '37');
    define('PRICING_COLUMN_SIZES', '67');
    $currencies = new currencies();
    $pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
    $pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
    //watermark
    $pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'watermark.jpg', 30, 110, 550, 550);
    // company name and details pulled from the my store address and phone number
    // in admin configuration mystore
    //$pdf->addJpegFromFile('./invoicelogo.jpg',23,150,567,567);
    //$pdf->addText(132,489,70,"YOUR WATERMARK",-45);
    $y = $pdf->ezText(STORE_NAME_ADDRESS, COMPANY_HEADER_FONT_SIZE);
    $y -= 10;
    // logo image  set to right of the above .. change first number to move sideways
    $pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'invoicelogo.jpg', 480, 730, 85, 85);
    // line between header and rest of page
    $pdf->setLineStyle(1);
    $pdf->line(LEFT_MARGIN, $y, LINE_LENGTH, $y);
    $pdf->ezSetY($y);
    $dup_y = $y;
    $pos -= SECTION_DIVIDER;
}
error_reporting(0);
include 'class.ezpdf.php';
include "rupiah.php";
include "../../Inc/koneksi.php";
include "../../Inc/fungsi_indotgl.php";
include "../../Inc/library.php";
$pdf = new Cezpdf();
// Set margin dan font
$pdf->ezSetCmMargins(3, 3, 3, 3);
$pdf->selectFont('fonts/Courier.afm');
$all = $pdf->openObject();
$pemilik = mysql_fetch_array(mysql_query("select nm_perusahaan,alamat from bigbook_perusahaan")) or die("gagal");
// Tampilkan logo
$pdf->setStrokeColor(0, 0, 0, 1);
$pdf->addJpegFromFile('$pemilik[logo]', 20, 785, 69);
// Teks di tengah atas untuk judul header
$pdf->addText(150, 820, 16, '<b>Laporan Stok Bulan' . tgl_indo(date("Ymd")) . '</b>');
$pdf->addText(200, 800, 14, '<b>' . $pemilik[nm_perusahaan] . '</b>');
// Garis atas untuk header
$pdf->line(10, 780, 578, 780);
// Garis bawah untuk footer
$pdf->line(10, 50, 578, 50);
// Teks kiri bawah
$pdf->addText(30, 34, 8, 'Dicetak tgl:' . date('d-m-Y, H:i:s'));
$pdf->closeObject();
// Tampilkan object di semua halaman
$pdf->addObject($all, 'all');
// Baca input tanggal yang dikirimkan user
$qmin = mysql_fetch_array(mysql_query("select min(bulan) as bulan, min(tahun) as tahun from master_laporan"));
$pertamax = $qmin['bulan'];
 function pdf_header($partner_id)
 {
     $pdf = new Cezpdf('a4', 'portrait');
     $pdf->ezSetCmMargins(4.5, 1, 1, 1);
     $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm';
     $text_schrift = 'pdfclass/fonts/Arial.afm';
     $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
     // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw1.jpg', 300, 500, 250, 150);
     $pdf->setLineStyle(0.5);
     $pdf->selectFont($berlus_schrift);
     $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin");
     $pdf->line(42, 750, 550, 750);
     $pdf->selectFont($berlus_schrift);
     $pdf->ezSetCmMargins(1, 1, 1, 1);
     $pdf->setLineStyle(0.5);
     $pdf->line(42, 50, 550, 50);
     $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG |  Fontanestr. 1 | 14193 Berlin | Inhaber Wolfgang Wehrheim");
     $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin | BLZ: 100  800  00 | Konto-Nr.: 05 804 000 00 | Steuernummer: 24/582/61188");
     return $pdf;
 }
 $mieter_ids = $buchung->get_personen_ids_mietvertrag($mietvertrag_id);
 // $buchung->array_anzeigen($mieter_ids);
 // ####Personendaten zu Person_id holen#######
 for ($i = 0; $i < count($mieter_ids); $i++) {
     $mieter_daten_arr[] = $buchung->get_person_infos($mieter_ids[$i]['PERSON_MIETVERTRAG_PERSON_ID']);
 }
 // ##überschrift##############################
 $heute = date("Y-m-d");
 $heute_deutsch = $buchung->date_mysql2german($heute);
 // ##erste seite
 $pdf = new Cezpdf('a4', 'portrait');
 $pdf->ezSetCmMargins(4.3, 0, 1.5, 2.5);
 $berlus_schrift = 'Times-Roman.afm';
 $text_schrift = 'Helvetica.afm';
 // links,
 $pdf->addJpegFromFile('includes/logos/Slogo_78_31.jpg', 190, 730, 200, 80);
 $pdf->setLineStyle(0.5);
 // line(x1,y1,x2,y2) /links anfang hoehe weite hoehe
 $pdf->line(42, 722, 550, 722);
 $pdf->selectFont($berlus_schrift);
 $pdf->ezText("BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin", 7);
 $pdf->ezSetDy(-20);
 $pdf->selectFont($berlus_schrift);
 $pdf->addText(400, 680, 10, 'Telefon (030) 89784477');
 $pdf->addText(400, 665, 10, 'Telefax (030) 89784479');
 $pdf->addText(400, 650, 10, 'Email:	 info@berlus.de');
 $pdf->addText(400, 635, 10, '<c:uline><b>Sprechzeiten</b></c:uline>');
 $pdf->addText(400, 620, 10, 'Dienstag:');
 $pdf->addText(455, 620, 10, '9:00-12:00');
 $pdf->addText(400, 605, 10, 'Donnerstag:');
 $pdf->addText(450, 605, 10, '14:00-17:00');
Beispiel #14
0
 function kosten_einnahmen_pdf($geldkontos_arr, $monat, $jahr)
 {
     $anzahl_konten = count($geldkontos_arr);
     $datum_jahresanfang = "01.01.{$jahr}";
     if ($anzahl_konten) {
         ob_clean();
         // ausgabepuffer leeren
         /* PDF AUSGABE */
         //include_once ('pdfclass/class.ezpdf.php');
         $pdf = new Cezpdf('a4', 'portrait');
         $pdf->selectFont('Helvetica.afm');
         $pdf->ezSetCmMargins(4.5, 0, 0, 0);
         /* Kopfzeile */
         $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
         $pdf->setLineStyle(0.5);
         $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de");
         $pdf->line(42, 750, 550, 750);
         /* Footer */
         $pdf->line(42, 50, 550, 50);
         $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG *  Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim");
         $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin * BLZ: 100  800  00 * Konto-Nr.: 05 804 000 00 * Steuernummer: 24/582/61188");
         $pdf->addInfo('Title', "Monatsbericht {$objekt_name} {$monatname} {$jahr}");
         $pdf->addInfo('Author', $_SESSION['username']);
         $pdf->ezStartPageNumbers(100, 760, 8, '', 'Seite {PAGENUM} von {TOTALPAGENUM}', 1);
         $g_kosten_jahr = 0.0;
         /* Schleife für jedes Geldkonto bzw. Zeilenausgabe */
         for ($a = 0; $a < $anzahl_konten; $a++) {
             $geldkonto_id = $geldkontos_arr[$a]['GELDKONTO_ID'];
             $objekt_name = $geldkontos_arr[$a]['OBJEKT_NAME'];
             $this->kontostand_tagesgenau_bis($geldkonto_id, $datum_jahresanfang);
             $kontostand_jahresanfang = $this->summe_konto_buchungen;
             $this->summe_kontobuchungen_jahr_monat($geldkonto_id, '80001', $jahr, $monat);
             $summe_mieteinnahmen_monat = $this->summe_konto_buchungen;
             $this->summe_miete_jahr($geldkonto_id, '80001', $jahr, $monat);
             $summe_mieteinnahmen_jahr = $this->summe_konto_buchungen;
             $this->summe_kosten_jahr_monat($geldkonto_id, '80001', $jahr, $monat);
             $summe_kosten_monat = $this->summe_konto_buchungen;
             $this->summe_kosten_jahr($geldkonto_id, '80001', $jahr, $monat);
             $summe_kosten_jahr = $this->summe_konto_buchungen;
             /*
              * if($monat < 12){
              * $monat_neu = $monat + 1;
              * $jahr_neu = $jahr;
              * }
              * if($monat == 12){
              * $monat_neu = 1;
              * $jahr_neu = $jahr +1;
              * }
              */
             $monat = sprintf('%02d', $monat);
             $letzter_tag_m = letzter_tag_im_monat($monat, $jahr);
             $datum_bis = "{$letzter_tag_m}.{$monat}.{$jahr}";
             $this->kontostand_tagesgenau_bis($geldkonto_id, $datum_bis);
             $kontostand_heute = $this->summe_konto_buchungen;
             $monatname = monat2name($monat);
             /* Gesamtsummen bilden */
             $g_kontostand_ja = $g_kontostand_ja + $kontostand_jahresanfang;
             $g_me_monat = $g_me_monat + $summe_mieteinnahmen_monat;
             $g_me_jahr = $g_me_jahr + $summe_mieteinnahmen_jahr;
             $g_kosten_monat = $g_kosten_monat + $summe_kosten_monat;
             $g_kosten_jahr += $summe_kosten_jahr;
             $g_kontostand_akt = $g_kontostand_akt + $kontostand_heute;
             $kontostand_jahresanfang = nummer_punkt2komma($kontostand_jahresanfang);
             $summe_mieteinnahmen_monat = nummer_punkt2komma($summe_mieteinnahmen_monat);
             $summe_mieteinnahmen_jahr = nummer_punkt2komma($summe_mieteinnahmen_jahr);
             $summe_kosten_monat = nummer_punkt2komma($summe_kosten_monat);
             $summe_kosten_jahr = nummer_punkt2komma($summe_kosten_jahr);
             $kontostand_heute = nummer_punkt2komma($kontostand_heute);
             // echo "<b>$kontostand_jahresanfang| $summe_mieteinnahmen_monat|$summe_mieteinnahmen_jahr|$summe_kosten_monat|$summe_kosten_jahr|$kontostand_heute</b><br>";
             $table_arr[$a]['OBJEKT_NAME'] = $objekt_name;
             $table_arr[$a]['KONTOSTAND1_1'] = $kontostand_jahresanfang;
             $table_arr[$a]['ME_MONAT'] = $summe_mieteinnahmen_monat;
             $table_arr[$a]['ME_JAHR'] = $summe_mieteinnahmen_jahr;
             $table_arr[$a]['KOSTEN_MONAT'] = $summe_kosten_monat;
             $table_arr[$a]['KOSTEN_JAHR'] = $summe_kosten_jahr;
             $table_arr[$a]['KONTOSTAND_AKTUELL'] = "<b>{$kontostand_heute}</b>";
         }
         // end for
         /* Summenzeile hinzufügen */
         $table_arr[$a]['OBJEKT_NAME'] = "<b>Summe incl. FON</b>";
         $table_arr[$a]['KONTOSTAND1_1'] = '<b>' . nummer_punkt2komma($g_kontostand_ja) . '</b>';
         $table_arr[$a]['ME_MONAT'] = '<b>' . nummer_punkt2komma($g_me_monat) . '</b>';
         $table_arr[$a]['ME_JAHR'] = '<b>' . nummer_punkt2komma($g_me_jahr) . '</b>';
         $table_arr[$a]['KOSTEN_MONAT'] = '<b>' . nummer_punkt2komma($g_kosten_monat) . '</b>';
         $table_arr[$a]['KOSTEN_JAHR'] = '<b>' . nummer_punkt2komma($g_kosten_jahr) . '</b>';
         $table_arr[$a]['KONTOSTAND_AKTUELL'] = '<b>' . nummer_punkt2komma($g_kontostand_akt) . '</b>';
         $pdf->ezTable($table_arr, array('OBJEKT_NAME' => 'Objekt', 'KONTOSTAND1_1' => "Kontostand {$datum_jahresanfang}", 'ME_MONAT' => "Mieten Einnahmen {$monatname}", 'ME_JAHR' => "Mieten Einnahmen {$jahr}", 'KOSTEN_MONAT' => "Kosten {$monatname}", 'KOSTEN_JAHR' => "Kosten {$jahr}", 'KONTOSTAND_AKTUELL' => "Kontostand"), '<b>Kosten & Einnahmen / Objekt (Tabellarische übersicht)</b>', array('shaded' => 0, 'width' => '500', 'justification' => 'right', 'cols' => array('KONTOSTAND1_1' => array('justification' => 'right'), 'ME_MONAT' => array('justification' => 'right'), 'ME_MONAT' => array('justification' => 'right'), 'ME_JAHR' => array('justification' => 'right'), 'KOSTEN_MONAT' => array('justification' => 'right'), 'KOSTEN_JAHR' => array('justification' => 'right'), 'KONTOSTAND_AKTUELL' => array('justification' => 'right'))));
         ob_clean();
         // ausgabepuffer leeren
         header("Content-type: application/pdf");
         // wird von MSIE ignoriert
         $pdf->ezStream();
     } else {
         echo "Keine Daten Error 65922";
     }
 }
 if ($order->delivery != $order->billing) {
     // right rounded rectangle around ship to info
     $pdf->setStrokeColor(0, 0, 0);
     $pdf->setLineStyle(1);
     $pdf->roundedRectangle(228, 400, 190, 100, 10, $f = 0);
     // ship to info in middle column
     $pdf->addText(MIDDLE_COLUMN_START, $y, SUB_HEADING_FONT_SIZE, "<b>" . ENTRY_SHIP_TO . "</b>");
     $pos = $y;
     $indent = MIDDLE_COLUMN_START + TEXT_BLOCK_INDENT;
     //  $address_array=explode('<br>',tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'));
     foreach ($delivery_address_array as $key => $value) {
         $pdf->addText($indent, $pos -= IPS_LEADING, IPS_FONT_SIZE, $value);
     }
 }
 // logo image  set to right below store name/address.. change first number to move sideways
 $pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'integrated_logo.jpg', 450, 400, 55, 40);
 $pos = $y;
 $address_array = explode('<br>', str_replace("\r\n", "<br>", STORE_NAME_ADDRESS));
 foreach ($address_array as $key => $value) {
     // echo $value.'<br>' ;
     $pdf->addText(RIGHT_COLUMN_START, $pos -= IPS_LEADING, IPS_FONT_SIZE, $value);
 }
 $pdf->addText(RIGHT_COLUMN_START, $pos -= IPS_LEADING, IPS_FONT_SIZE, WEBSITE);
 // phone and email statments .. added blank lines if turned off so as to maintain layout
 //if ($_POST['show_phone'] || $_POST['show_email'] ) {
 $pos -= SECTION_DIVIDER;
 $pdf->ezSetY($pos - 20);
 //if ($_POST['show_phone']) {
 $pos = $pdf->ezText("<b>" . ENTRY_PHONE . "</b> " . $order->customer['telephone'], IPS_FONT_SIZE);
 //}  if ($_POST['show_email']) {
 $pos = $pdf->ezText("<b>" . ENTRY_EMAIL . "</b> " . $order->customer['email_address'], IPS_FONT_SIZE);
 function hv_pdf_kopf()
 {
     //include_once ('pdfclass/class.ezpdf.php');
     $pdf = new Cezpdf('a4', 'portrait');
     $pdf->ezSetCmMargins(4.5, 1, 1, 1);
     $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm';
     $text_schrift = 'pdfclass/fonts/Arial.afm';
     $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
     // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw1.jpg', 300, 500, 250, 150);
     $pdf->setLineStyle(0.5);
     $pdf->selectFont($berlus_schrift);
     $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de");
     $pdf->line(42, 750, 550, 750);
 }
function creaPDF($ids, $tmpName, $path, $PATHQR, $tmp = "")
{
    require dirname(dirname(dirname(__FILE__))) . '/f4/configuracion/utils.php';
    require dirname(dirname(dirname(__FILE__))) . '/f4/configuracion/importeco.php';
    require dirname(dirname(dirname(__FILE__))) . "/gui/QRCode/qr_imgV2.php";
    $data = "";
    $facturaController = new FacturaController($path);
    $selloController = new SelloController($path);
    $empresaController = new EmpresaController($path);
    $sucursalController = new SucursalController($path);
    $FWK_PDFFONTS = 'pdf/fonts/';
    $FWK_PDFDEFAULTFONT = 'pdf/fonts/Helvetica.afm';
    $FWK_PDFCOURIERFONT = 'pdf/fonts/Courier.afm';
    // Obtener factura y sus anexos
    $TIPOSCOMPROBANTEMXP = array(1 => "Factura", 3 => "Nota de Cr.", 2 => "NOTA DE DEBITO");
    $idconsulta = "";
    $idconsulta = explode(",", trim($ids));
    foreach ($idconsulta as $valor) {
        if (is_null($valor) || $valor == "") {
            array_pop($idconsulta);
        }
    }
    $contadorTotalPaginas = count($idconsulta);
    $contadorPagina = 1;
    // Crea el documento pdf
    $pdf = new Cezpdf('LETTER', 'portrait');
    foreach ($idconsulta as $idfactura) {
        $data['idfactura'] = $idfactura;
        $factura = $facturaController->execute('facturaParaPdf', $data);
        $row_factura = $factura['respuesta'];
        $info_xtra = json_decode($row_factura["info_xtra"]);
        $data['idfacefactura'] = $factura['respuesta']['idface_factura'];
        $data['idempresa'] = $factura['respuesta']['idempresa'];
        $data['idsello'] = $factura['respuesta']['idsello'];
        $version = $factura['respuesta']['version'];
        $addenda = $facturaController->execute('datosAddenda', $data);
        $row_addenda = $addenda['respuesta'];
        $empresa = $empresaController->execute('allId', $data);
        $row_empresa = $empresa['respuesta'];
        $sello = $selloController->execute('obtenerPorIdsello', $data);
        $row_sello = $sello['respuesta'];
        $data['sucursal'] = $sello['respuesta']['sucursal'];
        $sucursal = $sucursalController->execute('nombreSucIdempresa', $data);
        $row_sucursal = $sucursal['respuesta'];
        $xmlArray = xml2array(base64_decode($row_factura['factura']));
        $attr = "_attr";
        if ($version === "3.2") {
            $NSP = "cfdi:";
        } else {
            $NSP = "";
        }
        $comprobante = $NSP . "Comprobante";
        $emisor = $NSP . "Emisor";
        $emisorDomFiscal = $NSP . "DomicilioFiscal";
        $emisorExpedidoEn = $NSP . "ExpedidoEn";
        $receptor = $NSP . "Receptor";
        $domicilio = $NSP . "Domicilio";
        $concepto = $NSP . "Conceptos";
        $conceptoTag = $NSP . "Concepto";
        $impuestos = $NSP . "Impuestos";
        $traslado = $NSP . "Traslados";
        $trasladoTag = $NSP . "Traslado";
        $retencion = $NSP . "Retenciones";
        $retencionTag = $NSP . "Retencion";
        //INICIALIZACIONES
        $comprobanteNode = null;
        $emisorNode = null;
        $emisordomicilioNode = null;
        $expedidoNode = null;
        $receptorNode = null;
        $receptordomicilioNode = null;
        $conceptoNode = null;
        $impuestosNode = null;
        $trasladoNode = null;
        $retencionNode = null;
        // -------------------------------------------------chs --------------------------------------------------------------
        $comprobanteNode = $xmlArray[$comprobante . $attr];
        $emisorNode = $xmlArray[$comprobante][$emisor . $attr];
        $emisordomicilioNode = $xmlArray[$comprobante][$emisor][$emisorDomFiscal . $attr];
        $expedidoNode = isset($xmlArray[$comprobante][$emisor][$emisorExpedidoEn . $attr]) ? $xmlArray[$comprobante][$emisor][$emisorExpedidoEn . $attr] : "";
        $receptorNode = $xmlArray[$comprobante][$receptor . $attr];
        $receptordomicilioNode = $xmlArray[$comprobante][$receptor][$domicilio . $attr];
        $conceptos = $xmlArray[$comprobante][$concepto];
        $impuestosNode = $xmlArray[$comprobante][$impuestos . $attr];
        $traslados = $xmlArray[$comprobante][$impuestos][$traslado];
        $retenciones = isset($xmlArray[$comprobante][$impuestos][$retencion][$retencionTag . $attr]) ? $xmlArray[$comprobante][$impuestos][$retencion][$retencionTag . $attr] : "";
        $regimenFiscal = $xmlArray[$comprobante][$emisor]["cfdi:RegimenFiscal_attr"]["Regimen"];
        // ---------------------------------------------------------------------------------------------------------------
        //descuentos
        $desc1 = 0.0;
        $desc2 = 0.0;
        //==================================================================================================================
        $pdf->ezSetMargins(100, 30, 30, 30);
        $pdf->selectFont($FWK_PDFDEFAULTFONT);
        $pdf->setLineStyle(0.7, '', '', '', 0);
        $pdf->openHere('Fit');
        if ($row_factura['tipocfd'] == 3) {
            $pdf->setStrokeColor(255, 0, 0);
        }
        if ($row_factura['tipocfd'] == 2) {
            $pdf->setStrokeColor(0, 255, 0);
        }
        // Inicia numeracin de paginas.
        $pagina = 1;
        $pdf->ezStartPageNumbers(500, 15, 10, '', '{PAGENUM} de {TOTALPAGENUM}', 1);
        $primeraPagina = $pdf->currentPage;
        // i. Agrega el logo de la empresa
        $pathToLogo = $path == "../" ? "../f4/extensiones/" : "";
        $logofile = "logos/f.jpg";
        //TENDRA QUE VENIR DE UN PARAMETRO EN LA BD.
        /*if(isset($row_empresa['rfc']) && !empty($row_empresa['rfc']))
        		$logofile="logos/".$row_empresa['rfc'].".jpg";*/
        if (isset($sucursal["respuesta"]["sucursal"]) && !empty($sucursal["respuesta"]["sucursal"])) {
            $logofile = "logos/" . strtolower($sucursal["respuesta"]["sucursal"]) . ".jpg";
        }
        error_log($logofile);
        if ($comprobanteNode['serie'] == "X") {
            $logofile = "logos/wingu-xpress.jpg";
        }
        $pdf->addJpegFromFile($pathToLogo . $logofile, 30, 705, 140);
        // i. Agrega la leyenda "cancelada"
        if ($row_factura['estatus'] == 0) {
            $pdf->setColor(0.9, 0.9, 0.9);
            $pdf->addText(180, 200, 65, "<b>CANCELADA</b>", -45);
            $pdf->setColor(0, 0, 0);
        }
        // ------------------------------------------ENCABEZADO ------------------------------------------
        //ENCABEZADO DE LA FACTURA
        $tipoDocto = $row_factura['tipodocumento'];
        $tipoDocto1 = $row_factura['tipodocumento'] == "FACTURA" ? "FACTURA" : "";
        $tipoDocto2 = $row_factura['tipodocumento'] == "NOTA CARGO" ? "FACTURA" : "";
        $tipoDocto3 = $row_factura['tipodocumento'] == "NOTA CREDITO" ? "NOTA DE CREDITO" : "";
        $emisor = utf8_decode($emisorNode['nombre'] . "\n" . $emisorNode['rfc']) . "\n";
        $noInterior = isset($emisordomicilioNode['noInterior']) ? $emisordomicilioNode['noInterior'] : "";
        $noExterior = isset($emisordomicilioNode['noExterior']) ? $emisordomicilioNode['noExterior'] : "";
        $emisor .= utf8_decode($emisordomicilioNode['calle'] . " {$noExterior}");
        $emisor .= utf8_decode($emisordomicilioNode['colonia']);
        if (isset($emisordomicilioNode['localidad'])) {
            $emisor .= "\n" . utf8_decode($emisordomicilioNode['localidad']);
        }
        if ($emisordomicilioNode['municipio'] != "" && isset($emisordomicilioNode['municipio'])) {
            $emisor .= "\n" . utf8_decode($emisordomicilioNode['municipio']);
        }
        if ($emisordomicilioNode['estado'] != "" && isset($emisordomicilioNode['estado'])) {
            $emisor .= ", " . utf8_decode($emisordomicilioNode['estado']);
        }
        if ($emisordomicilioNode['codigoPostal'] != "" && isset($emisordomicilioNode['codigoPostal'])) {
            $emisor .= "\nCP " . utf8_decode($emisordomicilioNode['codigoPostal']);
        }
        $emisor .= " " . utf8_decode($emisordomicilioNode['pais']);
        $telefono = isset($row_empresa['telefono']) ? $row_empresa['telefono'] : "";
        $emisor .= "\nTel: " . $telefono . "\n";
        $mail = isset($row_empresa['mail']) ? $row_empresa['mail'] : "";
        $emisor .= "\n" . $mail;
        $emisor1 = utf8_decode($emisorNode['nombre']);
        $sucursal = "";
        if ($expedidoNode != "") {
            if (utf8_decode($row_sucursal['sucursal']) == "Q") {
                $tipoSucursal = utf8_decode('Querétaro');
            } else {
                if (utf8_decode($row_sucursal['sucursal']) == "F") {
                    $tipoSucursal = utf8_decode('5/6');
                } else {
                    if (utf8_decode($row_sucursal['sucursal']) == "S") {
                        $tipoSucursal = utf8_decode('Santa Fe');
                    }
                }
            }
            $sucursal = "Sucursal " . $tipoSucursal . "\n";
            if (utf8_decode($row_sucursal['sucursal']) != "S") {
                $noInteriorExpedido = isset($expedidoNode['noInterior']) ? $expedidoNode['noInterior'] : "";
                $sucursal .= utf8_decode($expedidoNode['calle'] . " " . $expedidoNode['noExterior'] . " ") . "\n";
                $sucursal .= utf8_decode($expedidoNode['colonia']) . "\n";
                $sucursal .= utf8_decode($expedidoNode['municipio']) . ", " . utf8_decode($expedidoNode['estado']) . "\n";
                $sucursal .= "CP " . utf8_decode($expedidoNode['codigoPostal']) . " " . utf8_decode($expedidoNode['pais']);
            }
        }
        ////////// i. Nombre del emisor
        $colNames = array();
        $tableData = array(array("dato" => $emisor1));
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 200));
        $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 9, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 200, 'xOrientation' => 'right', 'width' => 200, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla nombre del emisor
        $pdf->ezSetY(765);
        $pdf->ezTable($tableData, $colNames, "", $options);
        ////////// i. Datos del emisor y de la sucursal
        $tableData = array(array("emisor" => $emisor, "espacio" => "", "sucursal" => $sucursal));
        $colOptions = array("emisor" => array('justification' => 'left', 'width' => 150), "espacio" => array('justification' => 'left', 'width' => 3), "sucursal" => array('justification' => 'left', 'width' => 100));
        $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 190, 'xOrientation' => 'right', 'width' => 335, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla
        $pdf->ezTable($tableData, "", "", $options);
        ////////// i. Datos del documento
        $foliodocto = rellena("0", 6, $comprobanteNode['folio']);
        $seriedocto = $comprobanteNode['serie'];
        if (!empty($seriedocto)) {
            $foliodocto = $seriedocto . "-" . rellena("0", 6, $comprobanteNode['folio']);
        }
        $fechastr = $comprobanteNode['fecha'];
        $fechatok = explode("T", $fechastr);
        $toksf = explode("-", $fechatok[0]);
        $fechastr = $toksf[2] . "-" . $toksf[1] . "-" . $toksf[0] . " " . $fechatok[1];
        $fechastrcfdi = $row_factura['FechaTimbrado'];
        $ncert = $comprobanteNode['noCertificado'];
        $aprob = $row_factura['noCertificadoSAT'];
        //chs
        $tableData = array(array("dato" => "<b>" . $tipoDocto1 . $tipoDocto2 . $tipoDocto3 . "</b>"), array("dato" => "<b>" . $foliodocto . "</b>"), array("dato" => "FECHA DE EMISION"), array("dato" => $fechastr), array("dato" => "LUGAR DE EXPEDICION"), array("dato" => utf8_decode($info_xtra->LugarExpedicion)), array("dato" => "FECHA DE CERTIFICACION"), array("dato" => $fechastrcfdi), array("dato" => "No. de Serie del Certificado del Emisor"), array("dato" => $ncert), array("dato" => "No. de Serie del Certificado del SAT"), array("dato" => $aprob), array("dato" => "Folio Fiscal"), array("dato" => $row_factura['uuid']));
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 120));
        /*JASR*/
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(1, 1, 1), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 455, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla datos del documento
        $pdf->ezSetDy(70);
        $pdf->ezTable($tableData, "", "", $options);
        ////////// i. Datos del cliente
        $noInterior = isset($receptordomicilioNode['noInterior']) ? utf8_decode($receptordomicilioNode['noInterior']) : "";
        $municipio = isset($receptordomicilioNode['municipio']) ? $receptordomicilioNode['municipio'] : "";
        $localidadCliente = isset($receptordomicilioNode['localidad']) ? utf8_decode($receptordomicilioNode['localidad']) : "";
        $tableData1 = array(array("cliente" => "<b>Cliente</b>"), array("cliente" => utf8_decode($receptorNode['nombre'])), array("cliente" => "RFC: " . utf8_decode($receptorNode['rfc'])), array("cliente" => utf8_decode($receptordomicilioNode['calle']) . " " . utf8_decode($receptordomicilioNode['noExterior']) . " {$noInterior} "), array("cliente" => utf8_decode($receptordomicilioNode['colonia']) . " " . $localidadCliente), array("cliente" => utf8_decode($municipio) . ", " . utf8_decode($receptordomicilioNode['estado']) . "  " . utf8_decode($receptordomicilioNode['codigoPostal']) . " \n" . utf8_decode($receptordomicilioNode['pais'])), array("cliente" => utf8_decode("Atención: " . $info_xtra->Receptor->contacto . "         Cliente: " . $info_xtra->Receptor->noCliente)), array("cliente" => utf8_decode("Tel: " . $info_xtra->Receptor->telefono)));
        $formaDePago = isset($comprobanteNode['formaDePago']) ? $comprobanteNode['formaDePago'] : "PAGO EN UNA SOLA EXHIBICION";
        $metodoPago = isset($comprobanteNode['metodoDePago']) ? $comprobanteNode['metodoDePago'] : "No Identificado";
        $numeroCuentaPago = isset($comprobanteNode['NumCtaPago']) ? $comprobanteNode['NumCtaPago'] : "No Identificado";
        $tableData2 = array(array("expedido" => "Expedido en: " . utf8_decode($info_xtra->LugarExpedicion)), array("expedido" => "Forma de Pago: " . utf8_decode($formaDePago)), array("expedido" => "Metodo de Pago: " . utf8_decode($metodoPago)), array("expedido" => "No. de Cuenta: " . utf8_decode($numeroCuentaPago)), array("expedido" => "Condiciones de Pago: " . utf8_decode($comprobanteNode['condicionesDePago'])), array("expedido" => "Regimen Fiscal: " . utf8_decode(preg_replace("/Ii/", "II", ucwords(strtolower($regimenFiscal))))), array("expedido" => "Tipo de Cambio: " . $comprobanteNode['TipoCambio'] . "  Moneda: " . $comprobanteNode['Moneda']), array("expedido" => "Elaboro: " . utf8_decode($info_xtra->Vendedor)), array("expedido" => utf8_decode("Póliza: " . $info_xtra->NumeroPoliza . "          SAP No: " . $info_xtra->NumeroPedido)));
        $tableData = array();
        $aux = count($tableData1) >= count($tableData2) ? $tableData1 : $tableData2;
        $cont = 0;
        foreach ($aux as $arr) {
            array_push($tableData, array("cliente" => $tableData1[$cont]["cliente"], "expedido" => $tableData2[$cont]["expedido"]));
            $cont++;
        }
        $colNames = array("cliente" => "", "expedido" => "");
        $colOptions = array("cliente" => array('justification' => 'left', 'width' => 205), "expedido" => array('justification' => 'left', 'width' => 205));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        $pdf->ezSetDy(125);
        $pdf->ezTable($tableData, $colNames, "", $options);
        //encabezado
        //error_log(print_r($info_xtra,true));
        $tableData = array(array("dato" => utf8_decode($info_xtra->Consumo->NotaEncabezado)));
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 540));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        $pdf->ezSetDy(-10);
        $pdf->ezTable($tableData, "", "", $options);
        $actualY = $pdf->y;
        $pdf->setColor(0, 0, 0);
        $pdf->filledRectangle(30, $actualY - 30, 540, 18);
        $pdf->ezSetY($actualY - 15);
        $pdf->setColor(1, 1, 1);
        $pdf->ezText("<b>Codigo</b>", 7, array('left' => 25, 'justification' => 'left'));
        $pdf->ezSetY($actualY - 15);
        $pdf->ezText("<b>Descripcion</b>", 7, array('left' => 180, 'justification' => 'left'));
        $pdf->ezSetY($actualY - 15);
        $pdf->ezText("<b>Cant</b>", 7, array('left' => 361, 'justification' => 'left'));
        $pdf->ezSetY($actualY - 15);
        $pdf->ezText("<b>Unidad</b>", 7, array('left' => 398, 'justification' => 'left'));
        $pdf->ezSetY($actualY - 15);
        $pdf->ezText("<b>Unitario</b>", 7, array('left' => 445, 'justification' => 'left'));
        $pdf->ezSetY($actualY - 15);
        $pdf->ezText("<b>Importe</b>", 7, array('left' => 497, 'justification' => 'left'));
        ////////// i. Partidas
        $tableData = array();
        $renglones = 0;
        $rowData = array("codigo" => "", "cantidad" => "", "unidad" => "", "descripcion" => "", "unitario" => "", "importe" => "");
        $partidaCnt = 0;
        $cantidadArrayConceptos = count($conceptos);
        foreach ($conceptos as $key => $conceptoNode) {
            if (stristr($key, $attr) && $cantidadArrayConceptos == 2) {
                $partidaCnt++;
                $renglones += 2;
                $currentObj = array();
                $descripcion = $conceptoNode['descripcion'];
                $totalPalabras = strlen($descripcion);
                $totalCaracteres = 4800;
                if ($totalPalabras >= $totalCaracteres) {
                    $pagDesc = ceil($totalPalabras / $totalCaracteres);
                    $aux = 1;
                    $array = array();
                    for ($i = 1; $i <= $pagDesc; $i++) {
                        if ($i == $pagDesc) {
                            $array[] = $totalPalabras;
                        } else {
                            $val = $aux += $totalCaracteres;
                            $array[] = $val;
                        }
                    }
                    $desc = array();
                    $o = 0;
                    foreach ($array as $valor) {
                        $desc[] = substr($descripcion, $o, $valor);
                        $o += $valor - $o;
                    }
                    $cont = 1;
                    foreach ($desc as $descripcionexp) {
                        $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo;
                        $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode['cantidad'])), 2);
                        //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] :  "No Aplica";
                        $currentObj["unidad"] = $conceptoNode['unidad'];
                        //)) ? $conceptoNode['unidad'] :  "No Aplica";
                        $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($descripcionexp) . "\n" . utf8_decode($info_xtra->Consumo->partidas[$partidaCnt - 1]->nota));
                        if ($info_xtra->TipoImpresion == "KI2") {
                            $contPartidas = count($info_xtra->Consumo->partidas);
                            for ($i = 1; $i < $contPartidas; $i++) {
                                $currentObj["descripcion"] .= $info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " \$" . $info_xtra->Consumo->partidas[$i]->valorUnitario . " \n";
                            }
                        }
                        $currentObj["unitario"] = number_format($conceptoNode['valorUnitario'], 2);
                        $currentObj["importe"] = number_format(doubleval($conceptoNode['importe']), 2);
                        $for = $cont++;
                        log_action("for:::" . $for);
                        if ($for > 1) {
                            $currentObj["codigo"] = "";
                            $currentObj["cantidad"] = "";
                            $currentObj["unidad"] = "";
                            $currentObj["unitario"] = "";
                            $currentObj["importe"] = "";
                        }
                        array_push($tableData, $currentObj);
                    }
                } else {
                    $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo;
                    $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode['cantidad'])), 2);
                    //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] :  "No Aplica";
                    $currentObj["unidad"] = $conceptoNode['unidad'];
                    //)) ? $conceptoNode['unidad'] :  "No Aplica";
                    $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($descripcion) . "\n" . utf8_decode($info_xtra->Consumo->partidas[$partidaCnt - 1]->nota));
                    if ($info_xtra->TipoImpresion == "KI2") {
                        $contPartidas = count($info_xtra->Consumo->partidas);
                        for ($i = 1; $i < $contPartidas; $i++) {
                            $currentObj["descripcion"] .= utf8_decode($info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " " . $info_xtra->Consumo->partidas[$i]->valorUnitario) . " \n";
                        }
                    }
                    $currentObj["unitario"] = number_format($conceptoNode['valorUnitario'], 2);
                    $currentObj["importe"] = number_format(doubleval($conceptoNode['importe']), 2);
                    array_push($tableData, $currentObj);
                }
            } else {
                foreach ($conceptoNode as $key1 => $conceptoNode1) {
                    log_action(print_r($key1, TRUE));
                    if (stristr($key1, $attr)) {
                        $partidaCnt++;
                        $renglones += 2;
                        $currentObj = array();
                        $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo;
                        $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode1['cantidad'])), 2);
                        //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] :  "No Aplica";
                        $currentObj["unidad"] = $conceptoNode1['unidad'];
                        //)) ? $conceptoNode['unidad'] :  "No Aplica";
                        $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($conceptoNode1['descripcion'] . "\n" . $info_xtra->Consumo->partidas[$partidaCnt - 1]->nota));
                        if ($info_xtra->TipoImpresion == "KI2") {
                            $contPartidas = count($info_xtra->Consumo->partidas);
                            for ($i = 1; $i < $contPartidas; $i++) {
                                $currentObj["descripcion"] .= $info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " \$" . $info_xtra->Consumo->partidas[$i]->valorUnitario . " \n";
                            }
                        }
                        $currentObj["unitario"] = number_format($conceptoNode1['valorUnitario'], 2);
                        $currentObj["importe"] = number_format(doubleval($conceptoNode1['importe']), 2);
                        array_push($tableData, $currentObj);
                    }
                }
                //fin foreach 2  chs 20130705
            }
        }
        $currentObj = array();
        $currentObj["codigo"] = "";
        $currentObj["cantidad"] = "";
        $currentObj["unidad"] = "";
        $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($row_factura["fnotas"]));
        $currentObj["unitario"] = "";
        $currentObj["importe"] = "";
        array_push($tableData, $currentObj);
        if (isset($row_addenda['cl_fld1'])) {
            $currentObj = array();
            $currentObj["cantidad"] = "";
            $currentObj["descripcion"] = $row_addenda['cl_fld1'];
            if (!empty($row_addenda['cl_fld2'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld2'];
            }
            if (!empty($row_addenda['cl_fld3'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld3'];
            }
            if (!empty($row_addenda['cl_fld4'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld4'];
            }
            if (!empty($row_addenda['cl_fld5'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld5'];
            }
            if (!empty($row_addenda['cl_fld6'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld6'];
            }
            if (!empty($row_addenda['cl_fld7'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld7'];
            }
            if (!empty($row_addenda['cl_fld8'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld8'];
            }
            if (!empty($row_addenda['cl_fld9'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld9'];
            }
            if (!empty($row_addenda['cl_fld10'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld10'];
            }
            if (!empty($row_addenda['cl_fld11'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld11'];
            }
            if (!empty($row_addenda['cl_fld12'])) {
                $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld12'];
            }
            $currentObj["unitario"] = "";
            $currentObj["importe"] = "";
            array_push($tableData, $currentObj);
        }
        $currentObj = array();
        $currentObj["codigo"] = "";
        $currentObj["cantidad"] = "";
        $currentObj["unidad"] = "";
        $currentObj["descripcion"] = "";
        $currentObj["unitario"] = "";
        $currentObj["importe"] = "";
        if ($info_xtra->TipoImpresion == "KI2") {
            for ($renglones; $renglones < 10 - count($info_xtra->Consumo->partidas) * 0.95; $renglones++) {
                array_push($tableData, $currentObj);
            }
        } else {
            if ($renglones < 10) {
                for ($renglones; $renglones < 10; $renglones++) {
                    array_push($tableData, $currentObj);
                }
            }
        }
        $colNames = array("codigo" => "", "descripcion" => "", "cantidad" => "", "unidad" => "", "unitario" => "", "importe" => "");
        $colOptions = array("codigo" => array('justification' => 'center', 'width' => 70), "descripcion" => array('justification' => 'left', 'width' => 280), "cantidad" => array('justification' => 'center', 'width' => 40), "unidad" => array('justification' => 'left', 'width' => 40), "unitario" => array('justification' => 'right', 'width' => 55), "importe" => array('justification' => 'right', 'width' => 55));
        $options = array('showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 4, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla partidas
        $pdf->ezSetDy(11);
        $pdf->ezTable($tableData, $colNames, "", $options);
        ////////// i. Cantidad con letra
        $cadena = covertirNumLetras(number_format($comprobanteNode['total'], 2, ".", ''));
        if ($comprobanteNode['Moneda'] == "USD") {
            $cadena = str_replace("M.N.", "USD", $cadena);
            $cadena = str_replace("PESOS", "DOLARES", $cadena);
            $cadena = str_replace("PESO", "DOLAR", $cadena);
        }
        $tableData = array(array("dato" => "<b>Nota:</b>\n" . utf8_decode($info_xtra->Consumo->notaAlPie)), array("dato" => "<b>Total con letra</b>\n" . trim($cadena)));
        $colNames = array("dato" => "<b>Cant</b>");
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 390));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 2.5, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla cantidad con letra
        $pdf->ezSetDy(0);
        $pdf->ezTable($tableData, "", "", $options);
        ////////// i. Totales
        $f_importe = "\$" . number_format($comprobanteNode['subTotal'], 2);
        //$f_iva_T=$conceptoNode['totalImpuestosTrasladados'];
        $f_total = "\$" . number_format($comprobanteNode['total'], 2);
        $tableData = array();
        $rowData = array("leyenda" => "", "cantidad" => "");
        $subtotal = array("dato" => "Subtotal", "valor" => $f_importe);
        array_push($tableData, $subtotal);
        foreach ($traslados as $key => $trasladoNode) {
            if ($key === $trasladoTag . $attr) {
                $tasaImpuesto = array();
                $tasaImpuesto_t = number_format($trasladoNode['tasa'], 0);
                $tasaImpuesto["dato"] = $trasladoNode['impuesto'] . " " . $tasaImpuesto_t . "%";
                $tasaImpuesto["valor"] = "\$" . number_format($trasladoNode['importe'], 2);
                //array_push($tableData,$tasaImpuesto);
            }
        }
        if (!empty($retenciones)) {
            foreach ($retenciones as $key => $retencionNode) {
                if ($key === $retencionTag . $attr) {
                    $tasaImpuesto = array();
                    $tasaImpuesto_t = number_format($retencionNode['tasa'], 2);
                    $tasaImpuesto["dato"] = "Ret. " . $retencionNode['impuesto'];
                    $tasaImpuesto["valor"] = "\$" . number_format($retencionNode['importe'], 2);
                    //array_push($tableData,$tasaImpuesto);
                }
            }
        }
        //fin if empty
        $iva = array("dato" => "<b>IVA</b>", "valor" => "<b>\$ " . number_format($info_xtra->TotalImpuestosTrasladados, 2) . "</b>");
        array_push($tableData, $iva);
        $total = array("dato" => "<b>Total</b>", "valor" => "<b>" . $f_total . "</b>");
        array_push($tableData, $total);
        $colNames = array("dato" => "<b>Cant</b>", "valor" => "Importe");
        $colOptions = array("dato" => array('justification' => 'right', 'width' => 55), "valor" => array('justification' => 'right', 'width' => 95));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(91, 21, 0), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 3, 'colGap' => 5, 'xPos' => 425, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla totales
        $pdf->ezSetDy(42.5);
        $pdf->ezTable($tableData, $colNames, "", $options);
        $rfce = $row_empresa['rfc'];
        $rfcr = $receptorNode['rfc'];
        $total = $comprobanteNode['total'];
        $uuidsat = $row_factura['uuid'];
        $cadenaQRCode = sprintf("?re=%s&rr=%s&tt=%s&id=%s", $rfce, $rfcr, $total, $uuidsat);
        /*QR Code: Para usar qr_imgV2():  qr_imgV2(d,e,s,v,t);
          d= datos        Cadena o datos a ser codificados.
          e= ECC level    Puede ser L,M,Q,H  (default M)
          s= module size  Para imagen JPEG:8; para PNG:4
          v= version      1-40   8 recomendado.
          t= image type   "J":imagen jpeg, "P" o culaquier otra cosa: imagen PNG */
        $img_filename = qr_imgV2($cadenaQRCode, "M", 8, 8, "J", $PATHQR);
        //v:7-13 8 parece adecuado.
        //$pdf->addJpegFromFile($img_filename,495,$pdf->y,90); //100
        //$pdf->addJpegFromFile($img_filename,32,170,130); //100
        $pdf->addJpegFromFile($img_filename, 32, $pdf->y - 140, 130);
        //100
        unlink($img_filename);
        ////////// i. Sello
        if ($version === "3.2") {
            $tableData = array(array("dato" => "<b>Sello Digital del Emisor</b>\n" . $row_factura['sello']), array("dato" => "<b>Sello Digital del SAT</b>\n" . $row_factura['selloSAT']));
        } else {
            $tableData = array(array("dato" => "<b>Sello Digital</b>\n" . $row_factura['sello']));
        }
        $colNames = array("dato" => "<b>Cant</b>");
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 400));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 175, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla sello
        $pdf->ezSetDy(-10);
        $pdf->ezTable($tableData, $colNames, "", $options);
        /*$pdf->setColor(91,21,0);
        		$pdf->filledRectangle(30,167,134,151);
        		$pdf->setColor(1,1,1);	
        		$pdf->filledRectangle(31,167.5,132.3,149.5);*/
        ////////// i. Cadena original
        $columnaCadena = "";
        if ($version === "3.2") {
            $columnaCadena = sprintf("||1.0|%s|%s|%s|%s||", $row_factura['uuid'], $row_factura['FechaTimbrado'], $row_factura['selloCFD'], $row_factura['noCertificadoSAT']);
        } else {
            $columnaCadena = sprintf("%s", $row_factura['cadena']);
        }
        $tableData = array(array("dato" => "<b>Cadena original del complemento de certificacion digital del SAT</b>\n" . $columnaCadena), array("dato" => "<b>Folio Fiscal</b>\n" . $row_factura['uuid']));
        $colNames = array("dato" => "<b>Cant</b>");
        $colOptions = array("dato" => array('justification' => 'left', 'width' => 400));
        $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 175, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3);
        // Dibuja la tabla cadena original
        $pdf->ezSetDy(-5);
        $pdf->ezTable($tableData, $colNames, "", $options);
        // Leyendas
        $pdf->ezSetDy(-12);
        $leyendas = "ESTE DOCUMENTO ES UNA REPRESENTACION IMPRESA DE UN CFDI.\n";
        $pdf->setColor(0.5, 0.5, 0.5);
        $pdf->ezText($leyendas, 5, array('left' => 50, 'justification' => 'center'));
        $pdf->setColor(0, 0, 0);
        $pdf->ezStream(array("filename" => $row_factura['folio'] . "_" . str_replace(" ", "-", $receptorNode['nombre'])));
        //Necesario para que funcione ezStartPageNumbers
        //REGRESA PARA PONER ENCABEZADO EN PAGINAS 2 ->
        if ($contadorPagina != $contadorTotalPaginas) {
            $pdf->ezNewPage();
            $pdf->ezSetDy(-12);
        }
        $contadorPagina++;
    }
    //fin del foreach para la creacion del objeto pdf
    //ESCRIBE REPORTE AL ARCHIVO.
    //================================================================================
    $pdfcode = $pdf->output();
    error_log($tmpName);
    if ($tmpName === 2 || !$tmpName) {
        $tmpName = !$tmpName ? $tmpName : true;
    } else {
        exit($pdfcode);
    }
    //save the file
    if ($tmpName) {
        $nombrePDF = tempnam($tmp . "tmp/", 'face5') . ".pdf";
        $nombreToks = explode("/", $nombrePDF);
        if (count($nombreToks) < 2) {
            $nombreToks = explode("\\", $nombrePDF);
        }
        $lastTok = count($nombreToks) - 1;
        $nombrePDF = $nombreToks[$lastTok];
        $archivoPDF = $tmp . "tmp/" . $nombrePDF;
        $archivos = array($nombrePDF, $archivoPDF);
        error_log(print_R($archivos, true));
    } else {
        $nombrePDF = $tipoDocto . "_" . $row_factura['serie'] . $row_factura['folio'] . ".pdf";
        //$archivoPDF ="tmp/".$nombrePDF;//chs 20130705
        $archivoPDF = $tmp . "tmp/" . $nombrePDF;
        $archivos = array($nombrePDF, $archivoPDF);
        error_log(2);
        ob_flush();
        ob_clean();
    }
    global $SITE_ROOT;
    error_log($archivoPDF);
    @file_put_contents($SITE_ROOT . "gui/" . $archivoPDF, $pdfcode);
    /*$fp = fopen($archivoPDF,'w+');
    		fwrite($fp,$pdfcode);
    		fclose($fp);*/
    return $archivos;
}
error_reporting(0);
include 'class.ezpdf.php';
include "rupiah.php";
include "../../Inc/koneksi.php";
include "../../Inc/fungsi_indotgl.php";
include "../../Inc/library.php";
$pdf = new Cezpdf();
// Set margin dan font
$pdf->ezSetCmMargins(3, 3, 3, 3);
$pdf->selectFont('fonts/Courier.afm');
$all = $pdf->openObject();
$pemilik = mysql_fetch_array(mysql_query("select nm_perusahaan,alamat from bigbook_perusahaan")) or die("gagal");
// Tampilkan logo
$pdf->setStrokeColor(0, 0, 0, 1);
$pdf->addJpegFromFile('logo.jpg', 20, 785, 69);
// Teks di tengah atas untuk judul header
$pdf->addText(150, 820, 16, '<b>Laporan Penjualan Bulan' . tgl_indo(date("Ymd")) . '</b>');
$pdf->addText(200, 800, 14, '<b>' . $pemilik[nm_perusahaan] . '</b>');
// Garis atas untuk header
$pdf->line(10, 795, 578, 795);
// Garis bawah untuk footer
$pdf->line(10, 50, 578, 50);
// Teks kiri bawah
$pdf->addText(30, 34, 8, 'Dicetak tgl:' . date('d-m-Y, H:i:s'));
$pdf->closeObject();
// Tampilkan object di semua halaman
$pdf->addObject($all, 'all');
// Baca input tanggal yang dikirimkan user
$mulai = $_GET[tgl1];
$selesai = $_GET[tgl2];
Beispiel #19
0
 // need to tweak these values to prevent text from clashing together
 define('PRODUCTS_COLUMN_SIZE', '165');
 define('PRODUCT_LISTING_BKGD_COLOR', GREY);
 define('MODEL_COLUMN_SIZE', '37');
 define('PRICING_COLUMN_SIZES', '67');
 $vilains = array("&#224;", "&#225;", "&#226;", "&#227;", "&#228;", "&#229;", "&#230;", "&#231;", "&#232;", "&#233;", "&#234;", "&#235;", "&#236;", "&#237;", "&#238;", "&#239;", "&#240;", "&#241;", "&#242;", "&#243;", "&#244;", "&#245;", "&#246;", "&#247;", "&#248;", "&#249;", "&#250;", "&#251;", "&#252;", "&#253;", "&#254;", "&#255;", "&#223;", "&#39;", "&nbsp;", "&agrave;", "&aacute;", "&atilde;", "&auml;", "&Arond;", "&egrave;", "&aelig;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&Iacute;", "&icirc;", "&iuml;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&ntilde;", "&ccedil;", "&yacute;", "&lt;", "&gt;", "&amp;");
 $cools = array('à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'ß', '\'', ' ', 'à', 'á', 'ã', 'ä', 'å', 'è', 'æ', 'ê', 'ë', 'ì', 'í', 'î', 'Î', 'ï', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ñ', 'ç', 'ý', '<', '>', '&');
 $currencies = new currencies();
 $pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
 $pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
 // company name and details pulled from the my store address and phone number
 // in admin configuration mystore
 $y = $pdf->ezText(STORE_NAME_ADDRESS, COMPANY_HEADER_FONT_SIZE);
 $y -= 10;
 // logo image  set to right of the above .. change first number to move sideways
 $pdf->addJpegFromFile('../images/' . 'store_logo.jpg', 365, 730, 85, 80);
 // extra info boxs to be used by staff
 $pdf->setStrokeColor(0, 0, 0);
 $pdf->setLineStyle(1);
 $pdf->roundedRectangle(470, 730, 85, 85, 10, $f = 0);
 $pdf->rectangle(535, 748, 10, 10);
 $pdf->rectangle(535, 769, 10, 10);
 $pdf->rectangle(535, 790, 10, 10);
 $pdf->addText(480, 790, GENERAL_FONT_SIZE, TEXT_BANK);
 $pdf->addText(480, 769, GENERAL_FONT_SIZE, TEXT_POST);
 $pdf->addText(480, 748, GENERAL_FONT_SIZE, TEXT_SALES);
 // line between header order number and order date
 $pdf->setLineStyle(1);
 $pdf->line(LEFT_MARGIN, $y, LINE_LENGTH, $y);
 $pdf->ezSetY($y);
 $dup_y = $y;
Beispiel #20
0
 // PDF page, if you make the TABLE HEADER FONT SIZE any larger you will
 // need to tweak these values to prevent text from clashing together
 define('PRODUCTS_COLUMN_SIZE', '320');
 define('PRODUCT_LISTING_BKGD_COLOR', '1,1,1');
 define('MODEL_COLUMN_SIZE', '87');
 define('PRICING_COLUMN_SIZES', '67');
 $vilains = array("&#224;", "&#225;", "&#226;", "&#227;", "&#228;", "&#229;", "&#230;", "&#231;", "&#232;", "&#233;", "&#234;", "&#235;", "&#236;", "&#237;", "&#238;", "&#239;", "&#240;", "&#241;", "&#242;", "&#243;", "&#244;", "&#245;", "&#246;", "&#247;", "&#248;", "&#249;", "&#250;", "&#251;", "&#252;", "&#253;", "&#254;", "&#255;", "&#223;", "&#39;", "&nbsp;", "&agrave;", "&aacute;", "&atilde;", "&auml;", "&Arond;", "&egrave;", "&aelig;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&Iacute;", "&icirc;", "&iuml;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&ntilde;", "&ccedil;", "&yacute;", "&lt;", "&gt;", "&amp;", "&eacute;");
 $cools = array('à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'ß', '\'', ' ', 'à', 'á', 'ã', 'ä', 'å', 'è', 'æ', 'ê', 'ë', 'ì', 'í', 'î', 'Î', 'ï', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ñ', 'ç', 'ý', '<', '>', '&', 'é');
 $currencies = new currencies();
 //$pdf->setPreferences(array("HideToolbar" => 'false', "HideWindowUI" => 'false'));
 $pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
 $pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
 // logo image
 list($w, $h) = getimagesize(HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'templates/' . DIR_WS_TEMPLATES_DEFAULT . '/images/' . STORE_LOGO);
 if (stristr(STORE_LOGO, '.png') === FALSE) {
     $pdf->addJpegFromFile(HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'templates/' . DIR_WS_TEMPLATES_DEFAULT . '/images/' . STORE_LOGO, 30, 730, $w, $h);
 } else {
     $pdf->addPngFromFile(HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'templates/' . DIR_WS_TEMPLATES_DEFAULT . '/images/' . STORE_LOGO, 30, 730, $w, $h);
 }
 // invoice number and box
 $pdf->setStrokeColor(0, 0, 0);
 $pdf->setLineStyle(0.5);
 $pdf->Rectangle(390, 793, 175, 20);
 $y = $pdf->ezText("<b>" . str_replace($vilains, $cools, TEXT_ORDER_NUMBER) . " </b>" . $orders['orders_prefix'] . $orders['orders_id'] . "\n\n", SUB_HEADING_FONT_SIZE, array('aleft' => '400'));
 // company name and details pulled from the my store address and phone number
 // in admin configuration mystore
 $y += 10;
 $y = $pdf->ezText(STORE_NAME_ADDRESS, COMPANY_HEADER_FONT_SIZE, array('aleft' => '400'));
 $y -= 10;
 // Add in the order titles
 $totalsy = 230;
Beispiel #21
0
 /**
  * add a given image to the document
  * 
  * @param CezShowimageParameter $params image parameter
  * @param float $x horizontal position
  * @param float $y vertical position
  * @param $w width
  * @param $h height
  * @param $quality image quality
  * @access protected
  */
 function addImage(&$params, $x = 0, $y = 0, $w = 0, $h = 0, $quality = 75)
 {
     if ($params->isUrl()) {
         if (function_exists('imagecreatefrompng')) {
             switch ($params->getImageType()) {
                 case 3:
                     // png
                     $image = imagecreatefrompng($params->getFilename());
                     break;
                 case 2:
                     // jpeg
                     $image = imagecreatefromjpeg($params->getFilename());
                     break;
                 case 1:
                     // gif
                     $image = imagecreatefromgif($params->getFilename());
                     break;
             }
             parent::addImage($image, $x, $y, $params->getWidth(), $params->getHeight());
         }
     } else {
         // check for image type, currently only png and jpeg supported
         switch ($params->getImageType()) {
             case 3:
                 // png
                 parent::addPngFromFile($params->getFilename(), $x, $y, $params->getWidth(), $params->getHeight());
                 break;
             case 2:
                 // jpeg
                 parent::addJpegFromFile($params->getFilename(), $x, $y, $params->getWidth(), $params->getHeight());
                 break;
             case 1:
                 // gif
                 parent::addGifFromFile($params->getFilename(), $x, $y, $params->getWidth(), $params->getHeight());
                 break;
         }
     }
 }
     }
 }
 //EOFOR
 $pos -= SECTION_DIVIDER;
 if ($orders['comments']) {
     $pdf->ezSetY($pos);
     $pdf->ezText("<b>Comments:</b>\n" . $orders['comments'], GENERAL_FONT_SIZE);
 }
 // start a new page for invoice
 $pdf->ezNewPage();
 // company name and details pulled from the my store address and phone number
 // in admin configuration mystore
 $y = $pdf->ezText(STORE_NAME_ADDRESS, COMPANY_HEADER_FONT_SIZE);
 $y -= 10;
 // logo image  set to right of the above .. change first number to move sideways
 $pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'invoicelogo.jpg', 365, 730, 85, 85);
 // extra info boxs to be used by staff
 $pdf->setStrokeColor(0, 0, 0);
 $pdf->setLineStyle(1);
 $pdf->roundedRectangle(470, 730, 85, 85, 10, $f = 0);
 $pdf->rectangle(535, 748, 10, 10);
 $pdf->rectangle(535, 769, 10, 10);
 $pdf->rectangle(535, 790, 10, 10);
 $pdf->addText(480, 790, GENERAL_FONT_SIZE, TEXT_BANK);
 $pdf->addText(480, 769, GENERAL_FONT_SIZE, TEXT_POST);
 $pdf->addText(480, 748, GENERAL_FONT_SIZE, TEXT_SALES);
 // line between header order number and order date
 $pdf->setLineStyle(1);
 $pdf->line(LEFT_MARGIN, $y, LINE_LENGTH, $y);
 $pdf->ezSetY($y);
 $dup_y = $y;
Beispiel #23
-4
 function berechnung_anzeigen($leerstand_arr, $vermietete_arr, $monat, $jahr)
 {
     echo '<pre>';
     // print_r($vermietete_arr);
     $anzahl_vermietete = count($vermietete_arr);
     $mv = new mietvertrag();
     $m = new mietkonto();
     $haeuser = array();
     $gsollmiete_vermietet = 0;
     for ($a = 0; $a < $anzahl_vermietete; $a++) {
         $einheit_id = $vermietete_arr[$a]['EINHEIT_ID'];
         $haus_str = $vermietete_arr[$a]['HAUS_STRASSE'];
         $haus_nr = $vermietete_arr[$a]['HAUS_NUMMER'];
         $haus_str_nr = $haus_str . ' ' . $haus_nr;
         if (!in_array($haus_str_nr, $haeuser)) {
             $haeuser[] = $haus_str_nr;
         }
         $mv->get_mietvertrag_infos_aktuell($einheit_id);
         $summe_f_monatlich = $m->summe_forderung_monatlich($mv->mietvertrag_id, $monat, $jahr);
         $gsollmiete_vermietet = $gsollmiete_vermietet + $summe_f_monatlich;
     }
     $anzahl_leer = count($leerstand_arr);
     $gsollmiete_leer = 0;
     for ($b = 0; $b < $anzahl_leer; $b++) {
         $einheit_id = $leerstand_arr[$b]['EINHEIT_ID'];
         $haus_str = $leerstand_arr[$b]['HAUS_STRASSE'];
         $haus_nr = $leerstand_arr[$b]['HAUS_NUMMER'];
         $haus_str_nr = $haus_str . ' ' . $haus_nr;
         if (!in_array($haus_str_nr, $haeuser)) {
             $haeuser[] = $haus_str_nr;
         }
         $sollmiete_leer = $this->get_sollmiete_leerstand($einheit_id);
         $gsollmiete_leer = $gsollmiete_leer + $sollmiete_leer;
     }
     // print_r($haeuser);
     $g_summe = $gsollmiete_vermietet + $gsollmiete_leer;
     $g_summe_a = nummer_punkt2komma($g_summe);
     $gsollmiete_vermietet_a = nummer_punkt2komma($gsollmiete_vermietet);
     $gsollmiete_leer_a = nummer_punkt2komma($gsollmiete_leer);
     $v_geb = $g_summe / 100 * 5;
     $brutto_vgeb = $v_geb * 1.19;
     $mwst_eur = $v_geb / 100 * 19;
     $mwst_eur = nummer_punkt2komma($mwst_eur);
     $brutto_vgeb_a = nummer_punkt2komma($brutto_vgeb);
     $v_geb_a = nummer_punkt2komma($v_geb);
     if (!isset($_REQUEST['pdf'])) {
         echo "{$gsollmiete_vermietet_a} €   GESAMT SOLL VERMIETET<br>";
         echo "{$gsollmiete_leer_a} €   GESAMT SOLL LEER<br>";
         echo " {$g_summe_a} €   GESAMT SOLL<br>";
         echo " {$v_geb_a} €   NETTO VERWALTERGEBÜHR 5%<br>";
         echo " <b>{$brutto_vgeb_a} €   INKL. 19% MWST VERWALTERGEBÜHR 5%</b><hr>";
     } else {
         /* PDF AUSGABE */
         ob_clean();
         // ausgabepuffer leeren
         header("Content-type: application/pdf");
         // wird von MSIE ignoriert
         //include_once ('pdfclass/class.ezpdf.php');
         $pdf = new Cezpdf('a4', 'portrait');
         $pdf->ezSetCmMargins(4.5, 1, 1, 1);
         $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm';
         $text_schrift = 'pdfclass/fonts/Arial.afm';
         $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
         // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw1.jpg', 300, 500, 250, 150);
         $pdf->setLineStyle(0.5);
         $pdf->selectFont($berlus_schrift);
         $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin");
         $pdf->line(42, 750, 550, 750);
         $monatsname = monat2name($monat);
         $pdf->addText(42, 720, 12, "Berechnungsbogen für die Verwaltergebühr {$monatsname} {$jahr}");
         $pdf->addText(42, 650, 10, "Gesamtsoll aus vermieteten Einheiten");
         $pdf->addText(300, 650, 10, "{$gsollmiete_vermietet_a} €");
         $pdf->addText(42, 635, 10, "Gesamtsoll aus leerstehenden Einheiten");
         $pdf->addText(300, 635, 10, "{$gsollmiete_leer_a} €");
         $pdf->setLineStyle(0.5);
         $pdf->line(42, 630, 350, 630);
         $pdf->addText(42, 620, 10, "<b>Gesamtsoll");
         $pdf->addText(300, 620, 10, "{$g_summe_a} €</b>");
         $pdf->addText(42, 595, 10, "5% Verwaltergebühr");
         $pdf->addText(300, 595, 10, "{$v_geb_a} €");
         $pdf->addText(42, 585, 10, "+ 19% MWSt");
         $pdf->addText(300, 585, 10, "{$mwst_eur} €");
         $pdf->setLineStyle(0.5);
         $pdf->line(42, 580, 350, 580);
         $pdf->addText(42, 570, 10, "<b>Verwaltergebühr brutto");
         $pdf->addText(300, 570, 10, "{$brutto_vgeb_a} €</b>");
         /* Häuser */
         $pdf->addText(42, 480, 10, "In diese Berechnung wurden folgende Häuser einbezogen:");
         $text_xpos = 460;
         for ($c = 0; $c < count($haeuser); $c++) {
             $haus = $haeuser[$c];
             $pdf->addText(42, $text_xpos, 10, "<b>{$haus}</b>");
             $text_xpos = $text_xpos - 10;
             if ($text_xpos == 100) {
                 $pdf->ezNewPage();
                 $text_xpos = 650;
                 $pdf->ezSetCmMargins(4.5, 1, 1, 1);
                 $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm';
                 $text_schrift = 'pdfclass/fonts/Arial.afm';
                 $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100);
                 // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw.jpg', 450, 780, 100, 42);
                 $pdf->setLineStyle(0.5);
                 $pdf->selectFont($berlus_schrift);
                 $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin");
                 $pdf->line(42, 750, 550, 750);
                 $pdf->addText(42, 720, 12, "Berechnungsbogen für die Verwaltergebühr {$monat}/{$jahr}");
             }
         }
         $pdf->ezStream();
     }
 }