Subversion Repositories wpShopGermany4

Rev

Rev 7258 | 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('AddanschreibenPage'))
        {
        
                function AddanschreibenPage($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_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.pdf"))
                        {
                                
                                $pagecount = $pdf->setSourceFile($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.pdf");
                                $tplidx = $pdf->importPage(1, '/MediaBox');
                                $pdf->useTemplate($tplidx, 0, 0, 210);
                        
                        }
                        else if (file_exists($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.jpg"))
                        {
                                
                                $pdf->image($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_bp.jpg", 0, 0, 210, 297, 'jpg');
                                
                        }


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

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

                                // Umrechnung von Inch zu Pixel
                                $wPix = (25.4 * $width) / 96;
                                $hPix = (25.4 * $height) / 96;

                                $leftPos = 110 - $wPix;
                                $midPos = $wPix * 2.6 - $width / 2;
                                $rightPos = 210 - $wPix;

                                $abscissa = $rightPos;
                                $ordinate = 0;

                                $transparency = str_replace("%", "", $shop->get_option('wpsg_mod_anschreiben_logo_transparency'));
                                if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);

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

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

                                if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
                                if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
                                if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }

                                $pdf->SetAlpha($alpha);
                                $pdf->image($shop->callMod('wpsg_mod_anschreiben', 'getFilePath', array(''))."wpsg_anschreiben_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
                                $pdf->SetAlpha(1);

                        }
                                
                        // Absenderadresszeile (Wird in der Konfiguration hinterlegt)
                        $pdf->SetFont('Arial', '', 6);
                        $pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter($shop->get_option("wpsg_mod_anschreiben_adressrow"), $shop->view['order']['id']));
                        
                        if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
                                
                        // Adresse des Kunden
                        $pdf->SetFont('Arial', '', 12);
                        $pdf->Text($adress_left, $adress_top, $shop->view['data']['firma']);
                        $pdf->Text($adress_left, $adress_top + 5, $shop->view['data']['vname'].' '.$shop->view['data']['name']);
                        $pdf->Text($adress_left, $adress_top + 10, $shop->view['data']['strasse'].' '.$shop->view['data']['hausnr']);
                        $pdf->Text($adress_left, $adress_top + 15, $shop->view['data']['plz'].' '.$shop->view['data']['ort']);
                        //if ($shop->get_option('wpsg_mod_anschreiben_hideCountry') != '1') $pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getShippingCountryName()));
                        if ($shop->get_option('wpsg_mod_anschreiben_hideCountry') != '1') $pdf->Text($adress_left, $adress_top + 20, $shop->view['data']['land']);
                        
                        // 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['lnr']);
                        $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, __("Lieferdatum", "wpsg"));
                        $pdf->Text($rdata_left + 170, $dndata_top + 6, wpsg_formatTimestamp($shop->view['lDatum'], true));
                        
                        if ($shop->view['oOrder']->isInnerEu())
                        {

                $pdf->SetFont('Arial', '', 9);
                $pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));

            } else if (!$shop->view['oOrder']->isInnerEu() && $shop->view['oOrder']->getShippingCountryID() != $shop->getDefaultCountry(true)) {

                        // Nicht InnerEU und Nicht Inland

                $pdf->SetFont('Arial', '', 9);
                $pdf->Text($adress_left, $rdata_top + 11.5, __("Steuerfreie Ausfuhrlieferung.", "wpsg"));

                        }
                        
                        
                        // Benutzerdefinierte Felder
                        $arTexte = $shop->callMod('wpsg_mod_anschreiben', 'getTexte', array($shop->view['data']['id'])); 
                        
                        foreach ((array)$arTexte 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");
                                                
                                }
                        
                        }
                        
                }
                
        }
        
        // 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);
        AddanschreibenPage($this, $pdf);

        $filename = $this->view['filename'].".pdf";
        
        
        $offset += 5;
        
        if ($this->view['fussText'] != "")
        {
        
                $pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $this->view['fussText']);
                $pdf->SetFont('Arial', 'B', 9);
                $offset += 10;
        
        }

    ob_end_clean();
        
        if ($this->view['preview'])
        {
                $pdf->Output($this->view['filename'], 'I');
        }
        else
        {
        
                $pdf->Output($this->callMod('wpsg_mod_anschreiben', 'getFilePath', array($this->view['order']['id'])).$this->view['filename'], 'F');
        
                if ($this->view['output'] === true) $pdf->Output($filename, 'I');
                        
        }
        
?>