require_once "../ConectarSolo.php";
$l = Conectarse("webpmm");
ini_set('post_max_size', '512M');
ini_set('upload_max_filesize', '512M');
ini_set('memory_limit', '500M');
ini_set('max_execution_time', 600);
ini_set('limit', -1);
include 'class.ezpdf.php';
$pdf = new Cezpdf('LETTER', 'portrait');
#					 t, b, l, r
$pdf->ezSetMargins(50, 70, 50, 50);
#w = 612 h = 792
$pdf->setColor(0.16, 0.38, 0.61);
$pdf->selectFont('fonts/Helvetica.afm');
$img = ImageCreatefromjpeg('../img/logo.jpg');
$pdf->addImage($img, 50, 697, 47, 50);
$pdf->addText(110, 722, 24, '<b>ENTREGAS PUNTUALES</b>');
$pdf->setColor(0.79, 0.67, 0.11);
$pdf->addText(110, 702, 16, '<b>Soporte de Factura ' . $_GET[folio] . '</b>');
$pdf->line(50, 690, 560, 690);
$pdf->setColor(0.25, 0.25, 0.25);
$pdf->ezText("\n\n\n\n{$f->fechaactual}", 12, array('justification' => 'right'));
#detallado superior
$s = "SELECT fd.*,SUBSTRING(CONCAT(cc.nombre,' ',cc.paterno,' ',cc.materno),1,25) cliente,gv.totalpaquetes,\n\t\tDATE_FORMAT(fd.fecha,'%d/%m/%Y') AS fecha\n\t\tFROM facturadetalle fd\n\t\tINNER JOIN guiasventanilla gv ON fd.folio=gv.id\n\t\tINNER JOIN catalogocliente cc ON gv.iddestinatario=cc.id\n\t\tWHERE fd.factura = '{$_GET['folio']}'\n\t\tUNION\n\t\tSELECT fd.*,SUBSTRING(CONCAT(cc.nombre,' ',cc.paterno,' ',cc.materno),1,25) cliente,ge.totalpaquetes,\n\t\tDATE_FORMAT(fd.fecha,'%d/%m/%Y') AS fecha\n\t\tFROM facturadetalle fd\n\t\tINNER JOIN guiasempresariales ge ON fd.folio=ge.id\n\t\tINNER JOIN catalogocliente cc ON ge.iddestinatario=cc.id\n\t\tWHERE fd.factura = '{$_GET['folio']}'";
$rx = mysql_query($s, $l) or die($s);
$registros = mysql_num_rows($rx);
if ($registros > 0) {
    $pdf->setColor(0.79, 0.67, 0.11);
    $pdf->ezText("<b>DETALLADO DE FACTURA, GUIAS</b>\n", 12, array('justification' => 'left'));
    $pdf->setColor(0.25, 0.25, 0.25);
    $s = "SELECT fd.*,SUBSTRING(CONCAT(cc.nombre,' ',cc.paterno,' ',cc.materno),1,25) cliente,gv.totalpaquetes,\n\t\tDATE_FORMAT(fd.fecha,'%d/%m/%Y') AS fecha\n\t\tFROM facturadetalle fd\n\t\tINNER JOIN guiasventanilla gv ON fd.folio=gv.id\n\t\tINNER JOIN catalogocliente cc ON gv.iddestinatario=cc.id\n\t\tWHERE fd.factura = '{$_GET['folio']}'\n\t\tUNION\n\t\tSELECT fd.*,SUBSTRING(CONCAT(cc.nombre,' ',cc.paterno,' ',cc.materno),1,25) cliente,ge.totalpaquetes,\n\t\tDATE_FORMAT(fd.fecha,'%d/%m/%Y') AS fecha\n\t\tFROM facturadetalle fd\n\t\tINNER JOIN guiasempresariales ge ON fd.folio=ge.id\n\t\tINNER JOIN catalogocliente cc ON ge.iddestinatario=cc.id\n\t\tWHERE fd.factura = '{$_GET['folio']}'";
Beispiel #2
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;
         }
     }
 }
 function printPDF($p_params)
 {
     $pbConfig = new PluginBarcodeConfig();
     // create barcodes
     $ext = 'png';
     $type = $p_params['type'];
     $size = $p_params['size'];
     $orientation = $p_params['orientation'];
     $codes = array();
     if ($type == 'QRcode') {
         $codes = $p_params['codes'];
     } else {
         if (isset($p_params['code'])) {
             if (isset($p_params['nb']) and $p_params['nb'] > 1) {
                 $this->create($p_params['code'], $type, $ext);
                 for ($i = 1; $i <= $p_params['nb']; $i++) {
                     $codes[] = $p_params['code'];
                 }
             } else {
                 if (!$this->create($p_params['code'], $type, $ext)) {
                     Session::addMessageAfterRedirect(__('The generation of some bacodes produced errors.', 'barcode'));
                 }
                 $codes[] = $p_params['code'];
             }
         } elseif (isset($p_params['codes'])) {
             $codes = $p_params['codes'];
             foreach ($codes as $code) {
                 if ($code != '') {
                     $this->create($code, $type, $ext);
                 }
             }
         } else {
             // TODO : erreur ?
             //         print_r($p_params);
             return 0;
         }
     }
     // create pdf
     // x is horizontal axis and y is vertical
     // x=0 and y=0 in bottom left hand corner
     $config = $pbConfig->getConfigType($type);
     require_once GLPI_ROOT . "/plugins/barcode/lib/ezpdf/class.ezpdf.php";
     $pdf = new Cezpdf($size, $orientation);
     $pdf->selectFont(GLPI_ROOT . "/plugins/barcode/lib/ezpdf/fonts/Helvetica.afm");
     $pdf->ezStartPageNumbers($pdf->ez['pageWidth'] - 30, 10, 10, 'left', '{PAGENUM} / {TOTALPAGENUM}') . ($width = $config['maxCodeWidth']);
     $height = $config['maxCodeHeight'];
     $marginH = $config['marginHorizontal'];
     $marginV = $config['marginVertical'];
     $heightimage = $height;
     if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) {
         // Add logo to barcode
         $heightLogomax = 20;
         $imgSize = getimagesize(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png');
         $logoWidth = $imgSize[0];
         $logoHeight = $imgSize[1];
         if ($logoHeight > $heightLogomax) {
             $ratio = 100 * $heightLogomax / $logoHeight;
             $logoHeight = $heightLogomax;
             $logoWidth = $logoWidth * ($ratio / 100);
         }
         if ($logoWidth > $width) {
             $ratio = 100 * $width / $logoWidth;
             $logoWidth = $width;
             $logoHeight = $logoHeight * ($ratio / 100);
         }
         $heightyposText = $height - $logoHeight;
         $heightimage = $heightyposText;
     }
     $first = true;
     foreach ($codes as $code) {
         if ($first) {
             $x = $pdf->ez['leftMargin'];
             $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height;
             $first = false;
         } else {
             if ($x + $width + $marginH > $pdf->ez['pageWidth']) {
                 // new line
                 $x = $pdf->ez['leftMargin'];
                 if ($y - $height - $marginV < $pdf->ez['bottomMargin']) {
                     // new page
                     $pdf->ezNewPage();
                     $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height;
                 } else {
                     $y -= $height + $marginV;
                 }
             }
         }
         if ($code != '') {
             if ($type == 'QRcode') {
                 $imgFile = $code;
             } else {
                 $imgFile = $this->docsPath . $code . '_' . $type . '.' . $ext;
             }
             if (file_exists($imgFile)) {
                 $imgSize = getimagesize($imgFile);
                 $imgWidth = $imgSize[0];
                 $imgHeight = $imgSize[1];
                 if ($imgWidth > $width) {
                     $ratio = 100 * $width / $imgWidth;
                     $imgWidth = $width;
                     $imgHeight = $imgHeight * ($ratio / 100);
                 }
                 if ($imgHeight > $heightimage) {
                     $ratio = 100 * $heightimage / $imgHeight;
                     $imgHeight = $heightimage;
                     $imgWidth = $imgWidth * ($ratio / 100);
                 }
                 $image = imagecreatefrompng($imgFile);
                 if ($imgWidth < $width) {
                     $pdf->addImage($image, $x + ($width - $imgWidth) / 2, $y, $imgWidth, $imgHeight);
                 } else {
                     $pdf->addImage($image, $x, $y, $imgWidth, $imgHeight);
                 }
                 if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) {
                     $logoimg = imagecreatefrompng(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png');
                     $pdf->addImage($logoimg, $x + ($width - $logoWidth) / 2, $y + $heightyposText, $logoWidth, $logoHeight);
                 }
                 if ($p_params['border']) {
                     $pdf->Rectangle($x, $y, $width, $height);
                 }
             }
         }
         $x += $width + $marginH;
         $y -= 0;
     }
     $file = $pdf->ezOutput();
     $pdfFile = $_SESSION['glpiID'] . '_' . $type . '.pdf';
     file_put_contents($this->docsPath . $pdfFile, $file);
     return '/files/_plugins/barcode/' . $pdfFile;
 }
        //{die ('ERROR AL guardarO'. mysql_error());}
        header("Location:../notificaciones/4.php");
    }
    header("Location:../notificaciones/5.php");
}
/* ***IMPRIMIR*** ***IMPRIMIR*** ***IMPRIMIR*** ***IMPRIMIR*** ***IMPRIMIR*** ***IMPRIMIR***  */
if ($_POST['radio'] == 'Imprimir') {
    require_once 'lib/ezpdf.php';
    $sql = "SELECT * FROM  conductor WHERE cedulaCon='{$_POST['cedulaCon']}'";
    //result
    $resSql = mysql_query($sql) or die("<br>Error consulta</br>" . mysql_error());
    $pdf = new Cezpdf('A3');
    $pdf->selectFont('fonts/Helvetica.afm');
    //$pdf->ezText('<b>Colegio </b>',20,array('justification'=>'left'));
    while ($row = mysql_fetch_row($resSql)) {
        $data[] = array('Nombre' => $row[1], 'Apellido' => $row[2], 'C.I' => $row[3], 'Tipo de Licencia' => $row[4], 'Telefono' => $row[5], 'Modelo de Veh' => $row[6], 'Placa de Veh' => $row[7], 'Año' => $row[8], 'Ruta Asiganada' => $row[9]);
    }
    $options = array('shadeCol' => array(10.2, 10.2, 10.2), 'xOrientation' => 'center', 'width' => 800);
    $titles = array('ID' => array('justification' => 'center'), 'Nombre' => array('justification' => 'center', 'width' => '30'), 'Apellido' => array('justification' => 'center', 'width' => '30'), 'C.I' => array('justification' => 'center', 'width' => '30'), 'Tipo de Licencia' => array('justification' => 'center', 'width' => '30'), 'Modelo de Veh' => array('justification' => 'center', 'width' => '30'), 'Placa del Veh' => array('justification' => 'center', 'width' => '30'), 'Año' => array('justification' => 'center', 'width' => '30'), 'Ruta Asignada' => array('justification' => 'center', 'width' => '30'));
    $txttitle = "Colegio Cardenal JH Quintero" . "\n";
    //$pdf->ezImage($image="../img/logo.png", $pad = 0,$width = 200,$resize = 'none',$just = 'left',$border = '');
    //$pdf->addImage($img="logo.png",$x=80,$y=0,$w=200,$h=0,$quality=75);
    $pdf->ezImage("logo.png", 0, 420, 'none', 'left');
    $pdf->ezText($txttitle, 20);
    $pdf->ezText('Fecha: ' . date('d/m/Y') . "\n", 10);
    $pdf->ezText('Hora: ' . date('H:i:s') . "\n\n", 10);
    $pdf->addImage($img, 120, 300, 400, 400);
    ob_end_clean();
    $pdf->ezTable($data);
    $pdf->ezStream();
}