コード例 #1
0
ファイル: Invoice_s3.php プロジェクト: digideskio/oscmax2
 $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++) {
     $totaltext = str_replace($vilains, $cools, $order->totals[$j]['title']);
     $fullstop = stripos($totaltext, ".");
     // Cuts shipping title at first '.' and replaces with :
     if ($fullstop != '0') {
         $totaltext = substr($totaltext, 0, $fullstop);
コード例 #2
0
ファイル: Packing-Slip.php プロジェクト: digideskio/oscmax2
 $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->setPreferences(array("HideToolbar" => 'false', "HideWindowUI" => 'false'));
 $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(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(0.5);
 $pdf->Rectangle(300, 745, 250, 70);
 $pdf->addText(310, 785, GENERAL_FONT_SIZE, TEXT_PACKED_BY);
 $pdf->addText(310, 760, GENERAL_FONT_SIZE, TEXT_VERIFIED_BY);
 // line between header order number and order date
 $pdf->setLineStyle(0.5);
 $pdf->line(LEFT_MARGIN, $y, LINE_LENGTH, $y);
 $pdf->ezSetY($y);
 $dup_y = $y;
 // order number
 $y = $pdf->ezText("<b>" . TEXT_ORDER_NUMBER . " </b>" . $orders['orders_prefix'] . $orders['orders_id'] . "\n\n", SUB_HEADING_FONT_SIZE);
 // order date
 if ($_POST['show_order_date']) {
     $pdf->ezSetY($dup_y);
     $pdf->ezText("<b>" . TEXT_ORDER_DATE . " </b>" . date(TEXT_ORDER_FORMAT, strtotime($order->info['date_purchased'])) . "\n\n", SUB_HEADING_FONT_SIZE, array('justification' => 'right'));
 }
 // sold to info in left rectangle
コード例 #3
0
 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;
 }