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("à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "ß", "'", " ", "à", "á", "ã", "ä", "&Arond;", "è", "æ", "ê", "ë", "ì", "í", "Í", "î", "ï", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ñ", "ç", "ý", "<", ">", "&", "é"); $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; $pdf->ezSetY($totalsy); for ($j = 0, $n = sizeof($order->totals); $j < $n; $j++) {
/** * 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; } } }
/** * 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(); }
$pdf->addText(540,830,10,'rechts oben'); $pdf->addText(0,5,10,'links unten'); $pdf->addText(540,5,10,'rechts unten'); */ $pdf->stream(); } else { include_once $pathvars["libraries"] . "xtra.pdf.php"; include_once $pathvars["libraries"] . "xtra.ezpdf.php"; $pdf = new Cezpdf(); $pdf->selectFont('./fonts/Helvetica.afm'); $pdf->openHere("Fit"); // Image #ezImage(image,[padding],[width],[resize],[justification],[array border]); #$pdf->addPngFromFile($pathvars["fileroot"]."/images/net/wappen.png",20,780,70); #$pdf->addPngFromFile($pathvars["fileroot"]."/images/net/auge.png",500,780,70); $pdf->addPngFromFile($pathvars["fileroot"] . "/images/net/kleines-wappen.png", 30, 780, 46); $pdf->addPngFromFile($pathvars["fileroot"] . "/images/net/auge.png", 300, 780, 70); // eine linie $pdf->line(20, 770, 560, 770); $pdf->addText(120, 790, '20', '<b>Vermessungsamt</b>'); $pdf->addText(380, 790, '20', '<i>Friedberg</i>'); // seiten nummern $pdf->ezStartPageNumbers(300, 20, 12, '', '', 1); // hier geht es los $pdf->ezSetDy(-60); // spaltenweise ausgabe an $pdf->ezColumnsStart(array("num" => 2, "gap" => 20)); // wichtig: damit der die ausgabe am spaltenbeginn steht #$pdf->ezSetDy(10); // Textblock #$pdf->ezText($text,10,array( "justification" => "full" )); // "leading"=>20, "spacing"=>1
$result = $db->query($sql); while ($redaktion = $db->fetch_array($result, 1)) { $redaktion["abnamra"] = $redaktion["abnamra"] . ", " . $redaktion["abnamvor"]; unset($redaktion["abnamvor"]); $red_or_ans[] = $redaktion; } } switch ($pdfkopf) { case "VA": // va kopf $vahead = $pdf->openObject(); $va = $data["adststelle"]; $links = 40; $center = 797; $rechts = 455; $pdf->addPngFromFile($pathvars["fileroot"] . "/images/net/wappen-klein-sw.png", $links, 780, 35); $pdf->addPngFromFile($pathvars["fileroot"] . "/images/net/auge-klein.png", $links + 150, $center + 9, 34); $pdf->addText($links + 40, $center + 13, '14', 'Vermessungsamt'); $pdf->addText($links + 186, $center + 13, '14', $va); $pdf->addText($links + 40, $center - 10, '14', 'BFD Bereich: ' . $data["adstbfd"]); $pdf->addText($rechts - 9, $center + 10, '10', '<b>Intranet-Adressverwaltung</b>'); $pdf->addText($rechts + 49, $center - 13, '10', '<b>Einzel-Auszug</b>'); $pdf->line($links, $center - 26, $rechts + 117, $center - 26); $pdf->closeObject(); $pdf->addObject($vahead, 'all'); break; case "BFD": // bfd kopf $bfdhead = $pdf->openObject(); $bfd = $data["adststelle"]; $links = 40;
function b_header(Cezpdf &$pdf, $partner_typ, $partner_id, $orientation = 'portrait', $font_file, $f_size, $logo_file = '') { $diff = array(196 => 'Adieresis', 228 => 'adieresis', 214 => 'Odieresis', 246 => 'odieresis', 220 => 'Udieresis', 252 => 'udieresis', 223 => 'germandbls'); $pdf->selectFont('Helvetica', array('encoding' => 'WinAnsiEncoding', 'differences' => $diff)); $all = $pdf->openObject(); $pdf->saveState(); $pdf->setStrokeColor(0, 0, 0, 1); if ($orientation == 'portrait') { $pdf->ezSetMargins(135, 70, 50, 50); if (!isset($_REQUEST['no_logo'])) { if ($logo_file == '') { $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png"; } if (file_exists("{$logo_file}")) { $pdf->addPngFromFile("{$logo_file}", 200, 730, 200, 80); $pdf->line(43, 725, 545, 725); $pdf->line(42, 50, 550, 50); } } else { $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png"; } $pdf->setLineStyle(0.5); $this->footer_info($partner_typ, $partner_id); $pdf->addText(43, 718, $f_size, "{$this->header_zeile}"); $pdf->ezStartPageNumbers(545, 715, $f_size, '', 'Seite {PAGENUM} von {TOTALPAGENUM}', 1); $pdf->setLineStyle(0.5); if (!isset($_REQUEST['no_logo'])) { $pdf->addText($pdf->ez['pageWidth'] / 2, 42, $f_size, "{$this->zeile1}", 0, 'center'); $pdf->addText($pdf->ez['pageWidth'] / 2, 35, $f_size, "{$this->zeile2}", 0, 'center'); } } else { $pdf->ezSetMargins(120, 40, 30, 30); $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png"; if (file_exists("{$logo_file}")) { $pdf->addPngFromFile("{$logo_file}", 320, 505, 200, 80); } else { $pdf->addText(370, 505, $f_size, "Vorschau / Druckansicht "); } $pdf->setLineStyle(0.5); $this->footer_info($partner_typ, $partner_id); $pdf->line(43, 500, 785, 500); $pdf->addText(43, 493, $f_size, "{$this->header_zeile}"); $pdf->ezStartPageNumbers(783, 493, $f_size, '', 'Seite {PAGENUM} von {TOTALPAGENUM}', 1); $pdf->setLineStyle(0.5); $pdf->line(42, 30, 785, 30); $pdf->addText($pdf->ez['pageWidth'] / 2, 23, $f_size, "{$this->zeile1}", 0, 'center'); $pdf->addText($pdf->ez['pageWidth'] / 2, 16, $f_size, "{$this->zeile2}", 0, 'center'); } $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all, 'all'); }
$diff = array(196 => 'Adieresis', 228 => 'adieresis', 214 => 'Odieresis', 246 => 'odieresis', 220 => 'Udieresis', 252 => 'udieresis', 223 => 'germandbls'); $pdf->selectFont('../classes/fonts/LiberationSans-Regular.afm', array('encoding' => 'WinAnsiEncoding', 'differences' => $diff)); if ($size == "A4" && $format == "portrait") { $mapOffset_left = $a4p_mapOffset_left; $mapOffset_bottom = $a4p_mapOffset_bottom; $header_height = $a4p_header_height; $footer_height = $a4p_footer_height; } else { $mapOffset_left = $a4l_mapOffset_left; $mapOffset_bottom = $a4l_mapOffset_bottom; $header_height = $a4l_header_height; $header_width = $a4l_header_width; } session_write_close(); $i = new weldMaps2PNG(implode("___", $array_urls), $filename); $pdf->addPngFromFile($filename, $mapOffset_left, $mapOffset_bottom, $map_width, $map_height); if ($unlink == true) { unlink($filename); } /** ****************************************************************** * user drawn elements */ $theMeasureConfigArray = array("do_fill" => FALSE, "fill_color" => array("r" => 128 / 255, "g" => 128 / 255, "b" => 128 / 255), "do_stroke" => FALSE, "stroke_color" => array("r" => 254 / 255, "g" => 1 / 255, "b" => 1 / 255), "line_style" => array("width" => 2, "cap" => 'butt', "join" => 'miter', "dash" => array(10, 6))); if ($_REQUEST["measured_x_values"] != '') { addMeasuredItem($pdf, $_REQUEST["measured_x_values"], $_REQUEST["measured_y_values"], $theMeasureConfigArray); hideElementsOutsideMapframe($pdf); } # dashed line $pdf->setLineStyle($linewidth_dashed, '', '', array(2, 2)); $pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom - $linewidth_dashed, $mapOffset_left - $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed); $pdf->line($mapOffset_left - $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed, $mapOffset_left + $map_width + $linewidth_dashed, $mapOffset_bottom + $map_height + $linewidth_dashed);
$pdf->addInfo("Title", "Sakai Conference Badges"); $pdf->addInfo("CreationDate", localtime()); $pageCount = 0; $offsetRow = 2; foreach ($people as $person) { if ($pageCount > 0 && $offsetRow == 2) { $pdf->ezNewPage(); } for ($columnOffset = 0; $columnOffset <= 1; $columnOffset++) { $left_edge = $left_margin + $badge_width * $columnOffset + $margin; $right_edge = $left_edge + $badge_width - $margin * 2; $top_edge = $top_margin + ($offsetRow + 1) * $badge_height - $margin; $bottom_edge = $top_edge - $badge_height + $margin * 2; $center = $left_edge + ($badge_width - $margin - $base_height / 2) / 2; $logoY = $top_edge - $logo_height - $base_height * 1.5; $pdf->addPngFromFile($logo_file, $left_edge + $badge_width / 2 - $logo_width / 2 - 12, $logoY, $logo_width, $logo_height); $nameString = ucfirst($person["FIRSTNAME"]) . " " . ucfirst($person["LASTNAME"]); $nameSize = 32; while ($pdf->getTextWidth($nameSize, $nameString) > $badge_width - $margin * 4) { $nameSize -= 2; } $nameX = $center - $pdf->getTextWidth($nameSize, $nameString) / 2; $nameY = $logoY - $pdf->getFontHeight($nameSize) + 6; $pdf->addText($nameX, $nameY, $nameSize, $nameString); $institutionString = $person["INSTITUTION"]; $institutionSize = 18; // while ($pdf->getTextWidth($institutionSize, $institutionString) > 568) { // $institutionSize-=2; // } // new "guesstimated" cutoff width for resizing text while ($pdf->getTextWidth($institutionSize, $institutionString) > 300) {