Subversion Repositories wpShopGermany4

Rev

Rev 7306 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7256 thomas 1
<?php
2
 
3
	/**
4
	 * FPDF Template für die Generierung des Lieferscheins
5
	 */
7352 daniel 6
 
7
	require_once WPSG_PATH_LIB.'FPDF_1.81/fpdf.php';
8
	require_once WPSG_PATH_LIB.'FPDI_2.2.0/autoload.php';
7256 thomas 9
	require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
10
 
11
	global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
12
 
7258 daniel 13
	if (!function_exists('addCoverLetterPage')) {
7256 thomas 14
 
7258 daniel 15
		function addCoverLetterPage($shop, $pdf) {
7256 thomas 16
 
17
			global $absender_left, $absender_top, $adress_left, $adress_top, $dndata_left, $dndata_top;
18
 
19
			$rdata_left = 0;
20
			$pdf->AddPage();
21
 
7258 daniel 22
			if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.pdf")) {
7256 thomas 23
 
7258 daniel 24
				$pdf->setSourceFile($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.pdf");
7256 thomas 25
				$tplidx = $pdf->importPage(1, '/MediaBox');
26
				$pdf->useTemplate($tplidx, 0, 0, 210);
27
 
7258 daniel 28
			} else if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.jpg")) {
7256 thomas 29
 
7258 daniel 30
				$pdf->image($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_bp.jpg", 0, 0, 210, 297, 'jpg');
7256 thomas 31
 
32
			}
33
 
7258 daniel 34
			if (file_exists($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg")) {
7256 thomas 35
 
7258 daniel 36
				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg");
7256 thomas 37
 
38
				// Umrechnung von Inch zu Pixel
39
				$wPix = (25.4 * $width) / 96;
40
				$hPix = (25.4 * $height) / 96;
7258 daniel 41
 
42
				$transparency = str_replace("%", "", $shop->get_option('wpsg_mod_coverletter_logo_transparency'));
7256 thomas 43
				if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
44
 
45
				$alpha = 1;
7258 daniel 46
				if (wpsg_isSizedString($transparency) && $transparency !== "100") $alpha = "0.$transparency";
47
				if (wpsg_isSizedString($transparency) && $transparency === "100") $alpha = $transparency;
7256 thomas 48
 
7306 daniel 49
				/*
7258 daniel 50
				$logo_pos = $shop->get_option('wpsg_mod_coverletter_logo_position');
7256 thomas 51
 
7258 daniel 52
				if(isset($logo_pos) && $logo_pos === "left") { $abscissa = 0; }
53
				if(isset($logo_pos) && $logo_pos === "center") { $abscissa = 105 - ($wPix / 2); }
54
				if(isset($logo_pos) && $logo_pos === "right") { $abscissa = 210 - $wPix; }
7306 daniel 55
				*/
56
 
57
				$logox = intval($shop->get_option('wpsg_mod_coverletter_logo_x'));
58
				$logoy = intval($shop->get_option('wpsg_mod_coverletter_logo_y'));
7256 thomas 59
 
60
				$pdf->SetAlpha($alpha);
7306 daniel 61
				$pdf->image($shop->callMod('wpsg_mod_coverletter', 'getFilePath', array(''))."wpsg_coverletter_logo.jpg", $logox, $logoy, $wPix, $hPix);
7256 thomas 62
				$pdf->SetAlpha(1);
63
 
64
			}
7258 daniel 65
 
7256 thomas 66
			// Adresse des Kunden
67
			$pdf->SetFont('Arial', '', 12);
7258 daniel 68
			$pdf->Text($adress_left, $adress_top, $shop->view['data']['company']);
69
			$pdf->Text($adress_left, $adress_top + 5, $shop->view['data']['firstname'].' '.$shop->view['data']['name']);
70
			$pdf->Text($adress_left, $adress_top + 10, $shop->view['data']['street'].' '.$shop->view['data']['hnr']);
71
			$pdf->Text($adress_left, $adress_top + 15, $shop->view['data']['zip'].' '.$shop->view['data']['city']);
72
			$pdf->Text($adress_left, $adress_top + 20, $shop->view['data']['country']);
7256 thomas 73
 
74
			// Daten
75
			$pdf->SetFont('Arial', 'B', 16);
76
			$pdf->Text($dndata_left, $dndata_top, $shop->view['title']);
77
			$pdf->SetFont('Arial', 'B', 9);
7258 daniel 78
			$pdf->Text($dndata_left, $dndata_top + 6, $shop->view['clnr']);
7256 thomas 79
			$pdf->SetFont('Arial', '', 9);
80
 
7285 thomas 81
			$pdf->Text($rdata_left + 100, $dndata_top, __("Kunden-Nr.", "wpsg"));
7256 thomas 82
			$pdf->Text($rdata_left + 100, $dndata_top + 6, (($shop->view['customer']['knr'] != '')?$shop->view['customer']['knr']:$shop->view['customer']['id']));
83
 
84
			$pdf->Text($rdata_left + 125, $dndata_top, __("Best. Nr.", "wpsg"));
85
			$pdf->Text($rdata_left + 125, $dndata_top + 6, ((trim($shop->view['order']['onr']) != '')?$shop->view['order']['onr']:$shop->view['order']['id']));
86
 
87
			$pdf->Text($rdata_left + 145, $dndata_top, __("Bestelldatum", "wpsg"));
88
			$pdf->Text($rdata_left + 145, $dndata_top + 6, wpsg_formatTimestamp(strtotime($shop->view['order']['cdate']), true));
89
 
7258 daniel 90
			$pdf->Text($rdata_left + 170, $dndata_top, __("Datum", "wpsg"));
91
			$pdf->Text($rdata_left + 170, $dndata_top + 6, wpsg_formatTimestamp(time(), true));
92
 
93
			foreach ($shop->view['arTexts'] as $text) {
7256 thomas 94
 
7258 daniel 95
				if (isset($text['aktiv']) && $text['aktiv'] == 1) {
7256 thomas 96
 
97
					$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
98
					$pdf->wpsg_SetTextColor($text['color']);
99
					$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
100
					$pdf->wpsg_SetTextColor("#000000");
101
 
102
				}
103
 
104
			}
105
 
7258 daniel 106
			// Text
107
			$pdf->setFont('Arial', '', 10);
108
			$pdf->wpsg_MultiCell($dndata_left - 1, $dndata_top + 12, 4, $shop->view['text']);
109
 
7256 thomas 110
		}
111
 
112
	}
113
 
114
	// Positionierung der Absenderadresszeile
115
	$absender_left				= 25;
116
	$absender_top				= 50;
117
 
118
	// Positionierung der Zieladress
119
	$adress_left 				= 25;
120
	$adress_top					= 55;
121
 
122
	// Positionierund des Lieferscheinkopfes
123
	$dndata_left				= 25;
124
	$dndata_top					= 90;
125
 
126
	// Positionierung der Produktdaten
127
	$prod_left					= 25;
128
	$prod_top					= 105;
129
 
130
	// Anzahl an Produkten pro Seite
131
	$prod_break					= 10;
132
 
133
	$pdf = new wpsg_fpdf();
134
	$pdf->SetAutoPageBreak(true, 5);
7258 daniel 135
	addCoverLetterPage($this, $pdf);
7256 thomas 136
 
137
	$offset += 5;
7258 daniel 138
 
7256 thomas 139
    ob_end_clean();
140
 
7258 daniel 141
	if ($this->view['preview']) {
142
 
7256 thomas 143
		$pdf->Output($this->view['filename'], 'I');
7258 daniel 144
 
145
	} else {
7256 thomas 146
 
7258 daniel 147
		$pdf->Output($this->view['filename'], 'F');
7256 thomas 148
 
7258 daniel 149
		if ($this->view['output'] === true) $pdf->Output($this->view['filename'], 'I');
7256 thomas 150
 
151
	}
7258 daniel 152