Subversion Repositories wpShopGermany4

Rev

Rev 7256 | Rev 7285 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

        /**
         * FPDF Template für die Generierung des Lieferscheins
         */

        require_once WPSG_PATH_LIB.'fpdf/fpdf.php';
        require_once WPSG_PATH_LIB.'fpdf/fpdi.php';
        require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
        
        global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
                        
        if (!function_exists('addCoverLetterPage')) {
        
                function addCoverLetterPage($shop, $pdf) {
        
                        global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
                                                        
                        $rdata_left = 0;
                        $pdf->AddPage();
                        
                        if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.pdf")) {
                                
                                $pdf->setSourceFile($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.pdf");
                                $tplidx = $pdf->importPage(1, '/MediaBox');
                                $pdf->useTemplate($tplidx, 0, 0, 210);
                        
                        } else if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.jpg")) {
                                
                                $pdf->image($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.jpg", 0, 0, 210, 297, 'jpg');
                                
                        }

                        if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg")) {

                                list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg");

                                // Umrechnung von Inch zu Pixel
                                $wPix = (25.4 * $width) / 96;
                                $hPix = (25.4 * $height) / 96;
  
                                $transparency = str_replace("%", "", $shop->get_option('wpsg_mod_coverletter_logo_transparency'));
                                if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);

                                $alpha = 1;
                                if (wpsg_isSizedString($transparency) && $transparency !== "100") $alpha = "0.$transparency";
                                if (wpsg_isSizedString($transparency) && $transparency === "100") $alpha = $transparency;

                                $logo_pos = $shop->get_option('wpsg_mod_coverletter_logo_position');

                                if(isset($logo_pos) && $logo_pos === "left") { $abscissa = 0; }
                                if(isset($logo_pos) && $logo_pos === "center") { $abscissa = 105 - ($wPix / 2); }
                                if(isset($logo_pos) && $logo_pos === "right") { $abscissa = 210 - $wPix; }

                                $pdf->SetAlpha($alpha);
                                $pdf->image($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg", $abscissa, 0, $wPix, $hPix);
                                $pdf->SetAlpha(1);

                        }
                                                                
                        // Adresse des Kunden
                        $pdf->SetFont('Arial', '', 12);
                        $pdf->Text($adress_left, $adress_top, $shop->view['data']['company']);
                        $pdf->Text($adress_left, $adress_top + 5, $shop->view['data']['firstname'].' '.$shop->view['data']['name']);
                        $pdf->Text($adress_left, $adress_top + 10, $shop->view['data']['street'].' '.$shop->view['data']['hnr']);
                        $pdf->Text($adress_left, $adress_top + 15, $shop->view['data']['zip'].' '.$shop->view['data']['city']);
                        $pdf->Text($adress_left, $adress_top + 20, $shop->view['data']['country']);
                        
                        // Daten
                        $pdf->SetFont('Arial', 'B', 16);
                        $pdf->Text($dndata_left, $dndata_top, $shop->view['title']);
                        $pdf->SetFont('Arial', 'B', 9);
                        $pdf->Text($dndata_left, $dndata_top + 6, $shop->view['clnr']);
                        $pdf->SetFont('Arial', '', 9);
                        
                        $pdf->Text($rdata_left + 100, $dndata_top, __("Kunden-Nr", "wpsg"));
                        $pdf->Text($rdata_left + 100, $dndata_top + 6, (($shop->view['customer']['knr'] != '')?$shop->view['customer']['knr']:$shop->view['customer']['id']));
                                
                        $pdf->Text($rdata_left + 125, $dndata_top, __("Best. Nr.", "wpsg"));
                        $pdf->Text($rdata_left + 125, $dndata_top + 6, ((trim($shop->view['order']['onr']) != '')?$shop->view['order']['onr']:$shop->view['order']['id']));
                        
                        $pdf->Text($rdata_left + 145, $dndata_top, __("Bestelldatum", "wpsg"));
                        $pdf->Text($rdata_left + 145, $dndata_top + 6, wpsg_formatTimestamp(strtotime($shop->view['order']['cdate']), true));
                                
                        $pdf->Text($rdata_left + 170, $dndata_top, __("Datum", "wpsg"));
                        $pdf->Text($rdata_left + 170, $dndata_top + 6, wpsg_formatTimestamp(time(), true));
                                                
                        foreach ($shop->view['arTexts'] as $text) {
                        
                                if (isset($text['aktiv']) && $text['aktiv'] == 1) {
                                                
                                        $pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
                                        $pdf->wpsg_SetTextColor($text['color']);
                                        $pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
                                        $pdf->wpsg_SetTextColor("#000000");
                                                
                                }
                        
                        }
                        
                        // Text
                        $pdf->setFont('Arial', '', 10);
                        $pdf->wpsg_MultiCell($dndata_left - 1, $dndata_top + 12, 4, $shop->view['text']); 
                        
                }
                
        }
        
        // Positionierung der Absenderadresszeile
        $absender_left                          = 25;
        $absender_top                           = 50;
        
        // Positionierung der Zieladress
        $adress_left                            = 25;
        $adress_top                                     = 55;
        
        // Positionierund des Lieferscheinkopfes
        $dndata_left                            = 25;
        $dndata_top                                     = 90;
        
        // Positionierung der Produktdaten
        $prod_left                                      = 25;
        $prod_top                                       = 105;
        
        // Anzahl an Produkten pro Seite
        $prod_break                                     = 10;
        
        $pdf = new wpsg_fpdf();
        $pdf->SetAutoPageBreak(true, 5);
        addCoverLetterPage($this, $pdf);

        $offset += 5;
         
    ob_end_clean();
        
        if ($this->view['preview']) {
                
                $pdf->Output($this->view['filename'], 'I');
                
        } else {
        
                $pdf->Output($this->view['filename'], 'F');
        
                if ($this->view['output'] === true) $pdf->Output($this->view['filename'], 'I');
                        
        }