Subversion Repositories wpShopGermany4

Rev

Rev 8071 | Rev 8073 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8068 karl 1
<?php
2
 
3
	/**
4
	 * Template für die PDF Rechnung
5
	 */
6
 
7
	require_once WPSG_PATH_LIB.'FPDF_1.81/fpdf.php';
8
	require_once WPSG_PATH_LIB.'FPDI_2.2.0/autoload.php';
9
 
10
	require_once WPSG_PATH_LIB.'wpsg_fpdf.class.php';
11
 
8069 daniel 12
	global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $rhead_left, $rhead_top, $sum_multi_offset, $pdf;
13
 
8068 karl 14
	// Positionierung der Absenderadresszeile
15
	$absender_left				= 25;
16
	$absender_top				= 50;
17
 
18
	// Positionierung der Zieladress
19
	$adress_left 				= 25;
20
	$adress_top					= 55;
21
 
22
	// Positionierung des Rechnungskopfes
23
	$rdata_left					= 25;
24
	$rdata_top					= 90;
25
 
26
    // Positionierung des Teilrechnungskopfes
27
    $rhead_left					= 25;
28
	$rhead_top					= 110;
29
 
30
	// Positionierung der Produktdaten
31
	$prod_left					= 25;
32
	$prod_top					= 120;
33
 
34
	// Anzahl an Produkten pro Seite
35
	$prod_break					= $this->get_option('wpsg_rechnungen_pdfperpage');
36
 
37
	$arCalculation = $this->view['basket']['arCalculation'];
38
    $data = $this->view['multi_data']['orders'][0]['data'];
39
    $sum = $this->view['multi_data']['orders'][0]['sum'];
40
 
41
	if ($this->getFrontendTaxView() === WPSG_NETTO) $taxdisplay = 'netto';
42
	else $taxdisplay = 'brutto';
43
 
8069 daniel 44
	if (!function_exists('AddRechnungPage')) {
8068 karl 45
 
8069 daniel 46
		function AddRechnungPage($shop, $pdf) {
8068 karl 47
 
48
			global $absender_left, $absender_top, $adress_left, $adress_top, $rdata_left, $rdata_top, $offset, $sum_multi_offset;
49
 
50
			$pdf->AddPage();
51
            $sum_multi_offset = 0;
52
 
53
			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf")) {
54
 
55
				$pdf->setSourceFile($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.pdf");
56
				$tplidx = $pdf->importPage(1, '/MediaBox');
57
				$pdf->useTemplate($tplidx, 0, 0, 210);
58
 
59
			} else if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg")) {
60
 
61
				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_bp.jpg", 0, 0, 210, 297, 'jpg');
62
 
63
			}
64
 
65
 
66
			if (file_exists($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg"))
67
			{
68
 
69
				list($width, $height, $type, $attr) = getimagesize($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg");
70
 
71
				// Umrechnung von Inch zu Pixel
72
				$wPix = (25.4 * (int)$width) / 96;
73
				$hPix = (25.4 * (int)$height) / 96;
74
 
75
				$leftPos = 110 - $wPix;
76
				$midPos = $wPix * 2.6 - $width / 2;
77
				$rightPos = 210 - $wPix;
78
 
79
				$abscissa = $rightPos;
80
				$ordinate = 0;
81
 
82
				$transparency = str_replace("%", "", $shop->get_option('wpsg_rechnungen_logo_transparency'));
83
				if($transparency !== "100") $transparency = str_replace(array("0", "00"), "", $transparency);
84
 
85
				$alpha = 1;
86
				if(!is_null($transparency) && $transparency !== "100") $alpha = "0.$transparency";
87
				if(!is_null($transparency) && $transparency === "100") $alpha = $transparency;
88
 
89
				$logo_pos = $shop->get_option('wpsg_rechnungen_logo_position');
90
 
91
				if(isset($logo_pos) && $logo_pos === "left") { $abscissa = $leftPos; $ordinate = 20; }
92
				if(isset($logo_pos) && $logo_pos === "center") { $abscissa = $midPos; $ordinate = 20; }
93
				if(isset($logo_pos) && $logo_pos === "right") { $abscissa = $rightPos; }
94
 
95
				$pdf->SetAlpha($alpha);
96
				$pdf->image($shop->callMod('wpsg_mod_rechnungen', 'getFilePath', array(''))."wpsg_rechnungen_logo.jpg", $abscissa, $ordinate, $wPix, $hPix);
97
				$pdf->SetAlpha(1);
98
 
99
			}
100
 
101
			// Absenderadresszeile (Wird in der Konfiguration hinterlegt)
102
			$pdf->SetFont('Arial', '', 6);
103
			$pdf->Text($absender_left, $absender_top, $shop->replaceUniversalPlatzhalter(__($shop->get_option("wpsg_rechnungen_adresszeile"), 'wpsg'), $data['id']));
104
 
105
			if (wpsg_getStr($shop->view['kunde']['kuerzel']) != "") $shop->view['kunde']['kuerzel'] = $shop->view['kunde']['kuerzel'].'-';
106
 
107
			// Adresse des Kunden
108
			$pdf->SetFont('Arial', '', 12);
109
			$pdf->Text($adress_left, $adress_top, $shop->view['kunde']['firma']);
110
			$pdf->Text($adress_left, $adress_top + 5, $shop->view['kunde']['vname'].' '.$shop->view['kunde']['name']);
111
			$pdf->Text($adress_left, $adress_top + 10, $shop->view['kunde']['strasse'].' '.wpsg_getStr($shop->view['kunde']['nr']));
112
			$pdf->Text($adress_left, $adress_top + 15, $shop->view['kunde']['plz'].' '.$shop->view['kunde']['ort']);
113
			if ($shop->get_option("wpsg_mod_rechnungen_hideCountry") == '0')
114
				$pdf->Text($adress_left, $adress_top + 20, strtoupper($shop->view['oOrder']->getInvoiceCountryName()));
115
 
116
			// Rechnungsdaten
117
			$pdf->SetFont('Arial', 'B', 16);
118
			$pdf->Text($rdata_left, $rdata_top, __('Rechnung', 'wpsg'));
119
			$pdf->SetFont('Arial', 'B', 9);
120
			$pdf->Text($rdata_left, $rdata_top + 6, $shop->view['rnr']);
121
			$pdf->SetFont('Arial', '', 9);
122
 
123
            // Fälligkeitsdatum
124
			if (isset($shop->view['faelligkeitdatum']))
125
			{
126
 
127
				$pdf->Text($rdata_left + 35, $rdata_top, __("Fällig am", "wpsg"));
128
				$pdf->Text($rdata_left + 35, $rdata_top + 6, $shop->view['faelligkeitdatum']);
129
 
130
			}
131
 
132
            // Kunden-Nr
133
			$pdf->Text($rdata_left + 55, $rdata_top, __("Kunden-Nr", "wpsg"));
134
			$pdf->Text($rdata_left + 55, $rdata_top + 6, (($shop->view['kunde']['knr'] != '')?$shop->view['kunde']['knr']:$shop->view['kunde']['id']));
135
 
136
            // Datum
137
            $pdf->Text($rdata_left + 75, $rdata_top, __("Datum", "wpsg"));
138
			$pdf->Text($rdata_left + 75, $rdata_top + 6, $shop->view['rDatum']);
139
 
140
            // InnerEu Hinweistext
8069 daniel 141
            if ($shop->view['oOrder']->isInnerEu()) {
8068 karl 142
 
143
				$pdf->SetFont('Arial', '', 9);
144
				$pdf->Text($adress_left, $rdata_top + 11.5, __("Innergemeinschaftliche Lieferung.", "wpsg"));
145
 
146
			}
147
 
148
            // Benutzerdefinierte Felder
149
			$arTexte = $shop->callMod('wpsg_mod_rechnungen', 'getRechnungstexte', array($data['id']));
150
 
151
			foreach ((array)$arTexte as $text)
152
			{
153
 
154
				if (isset($text['aktiv']) && $text['aktiv'] == 1)
155
				{
156
 
157
					$pdf->SetFont('Arial', 'B', ((intval($text['fontsize']) > 0)?intval($text['fontsize']):10));
158
					$pdf->wpsg_SetTextColor($text['color']);
159
					$pdf->wpsg_MultiCell($text['x'], $text['y'], 5, $text['text']);
160
					$pdf->wpsg_SetTextColor("#000000");
161
 
162
				}
163
 
164
			}
165
 
166
		}
167
 
168
	}
169
 
170
    // wpsg_debug($this->view['basket']); // DEBUG
171
    // wpsg_debug($this->view['kunde']); // DEBUG
172
    // wpsg_debug($this->view['data']); // DEBUG
173
    // wpsg_debug($this->view['multi_data']['orders']); // DEBUG
174
 
175
    $pdf = new wpsg_fpdf();
8069 daniel 176
    //$pdf->SetAutoPageBreak(true, 5);
8068 karl 177
    AddRechnungPage($this, $pdf);
178
 
8069 daniel 179
	$checkPageBreak = function($shop, $offset, $lines) use ($pdf, $prod_top) {
180
 
181
		if ($prod_top + $offset + ($lines * 5) > 290) {
182
 
183
			AddRechnungPage($this, $pdf);
184
 
185
			return 0;
186
 
187
		} else return $offset;
188
 
189
	};
190
 
8068 karl 191
    $rhead_count = 1;
192
    $sum_multi_offset = 0;
193
    $orders = $this->view['multi_data']['orders'];
8071 daniel 194
 
8069 daniel 195
	// moMwSt
196
	$bNoTax = false;
197
 
198
	$bTaxCol = false;
199
	if ($this->get_option('wpsg_showMwstAlways') === '1') $bTaxCol = true;
200
	else {
201
 
202
		foreach ($this->view['multi_data']['order_data'] as $order_data) {
203
 
204
			if (sizeof($order_data['arCalculation']['tax']) > 1) { $bTaxCol = true; break; }
205
 
206
		}
207
 
208
	}
209
 
8068 karl 210
    // FOREACH ORDER START
8069 daniel 211
    foreach ($this->view['multi_data']['order_data'] as $order_data) {
8068 karl 212
 
8069 daniel 213
		/** @var wpsg_order $oOrder */
214
		$oOrder = $order_data['oOrder'];
215
 
216
		/** @var \wpsg\wpsg_calculation $arCalculation */
217
		$arCalculation = $order_data['arCalculation'];
218
 
8068 karl 219
        // Sammelrechnung Zähler
220
        $pdf->SetFont('Arial', 'B', 12);
221
        $pdf->Text($rhead_left, $rhead_top + $sum_multi_offset, $rhead_count);
222
        $pdf->Text($rhead_left + 6, $rhead_top + $sum_multi_offset, __("Bestellung", "wpsg"));
223
        $rhead_count++;
224
        $pdf->SetFont('Arial', '', 9);
225
 
226
        // Zahlungsbedingung anzeigen
8069 daniel 227
        $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset, __("Zahlungsbedingungen", "wpsg"));
228
        $pdf->Text($rhead_left + 120, $rhead_top + $sum_multi_offset + 6, $oOrder->getPaymentLabel());
229
 
8068 karl 230
        // Bestellnummer anzeigen
231
        $pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset, __("Best. Nr.", "wpsg"));
8069 daniel 232
        $pdf->Text($rhead_left + 155, $rhead_top + $sum_multi_offset + 6, $oOrder->getNr());
8068 karl 233
 
234
        $summe = 0;
235
 
236
        $bKopf = false; $pnr = 1; $offset = 0; $count = 0;
237
 
8069 daniel 238
        foreach ($oOrder->getOrderProducts() as $oOrderProduct) {
8068 karl 239
 
8069 daniel 240
			$product_id = $oOrderProduct->getProductId();
241
 
242
            if (!$bKopf) {
8068 karl 243
 
244
                $pdf->SetFont('Arial', 'B', 9);
245
                $pdf->setXY($prod_left, $prod_top + $sum_multi_offset);
246
                $pdf->Cell(10, 8, __("Nr.", "wpsg"), 1, 0, 'C');
247
 
248
                $pdf->setXY($prod_left + 10, $prod_top + $sum_multi_offset);
8069 daniel 249
 
250
				$pdf->Cell((($bTaxCol)?87:102), 8, "Name", 1, 0, 'L');
251
 
252
                if ($bTaxCol) {
8068 karl 253
 
254
                    $pdf->setXY($prod_left + 97, $prod_top + $sum_multi_offset);
255
                    $pdf->Cell(15, 8, __("MwSt.", "wpsg"), 1, 0, 'C');
256
 
257
                }
258
 
259
                $pdf->setXY($prod_left + 112, $prod_top + $sum_multi_offset);
260
                $pdf->Cell(15, 8, __("Menge", "wpsg"), 1, 0, 'C');
261
 
262
                $pdf->setXY($prod_left + 127, $prod_top + $sum_multi_offset);
263
                $pdf->Cell(25, 8, __("Einzelpreis", "wpsg"), 1, 0, 'R');
264
 
265
                $pdf->setXY($prod_left + 152, $prod_top + $sum_multi_offset);
266
                $pdf->Cell(25, 8, __("Gesamtpreis", "wpsg"), 1, 0, 'R');
267
 
268
                $offset = 8;
269
                $bKopf = true;
270
 
271
            }
272
 
273
            $pdf->SetFont('Arial', '', 9);
274
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
275
 
8069 daniel 276
            if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') {
8068 karl 277
 
8069 daniel 278
                $pdf->Cell(10, 8,  $oOrderProduct->getProduct()->getProductNr(), 0, 0, 'C');
8068 karl 279
 
8069 daniel 280
            } else {
8068 karl 281
 
282
                $pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
283
 
284
            }
285
 
286
            /* Wenn Detailname vorhanden, wird der Detailname auf Rechnung verwendet */
8069 daniel 287
            $produkt_text = $this->getProductName($product_id, true);
8068 karl 288
 
8069 daniel 289
            $produktBeschreibung = trim(strip_tags($oOrderProduct->getProduct()->getShortDescription()));
8068 karl 290
 
8069 daniel 291
            if ($this->isOtherLang()) {
8068 karl 292
 
8069 daniel 293
                $trans_db = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_parent` = '".wpsg_q($product_id)."' AND `lang_code` = '".wpsg_q($this->getCurrentLanguageCode())."'");
8068 karl 294
 
8069 daniel 295
                if (is_array($trans_db) && sizeof($trans_db) > 0) {
8068 karl 296
 
297
                    $produkt_text = $trans_db['name'];
298
                    $produktBeschreibung = trim(strip_tags($trans_db['beschreibung']));
299
 
300
                }
301
 
302
            }
303
 
304
            $height = 0; // Höhe der Zeile für den Rahmen
305
 
306
            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
307
 
308
            // Produktvariablen
8069 daniel 309
            if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1") {
8068 karl 310
 
8069 daniel 311
                $arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($oOrder->getId(), $oOrderProduct->getProductIndex()));
8068 karl 312
 
8069 daniel 313
                if (wpsg_isSizedArray($arPV)) {
8068 karl 314
 
8069 daniel 315
                    foreach ($arPV as $pv) {
8068 karl 316
 
317
                        $produkt_text .= "\r\n".$pv['name'].': '.$pv['value'];
318
                        $height += 5;
319
 
320
                    }
321
 
322
                }
323
 
324
            }
325
 
8069 daniel 326
            if ($this->get_option('wpsg_mod_rechnungen_anr') === '2') {
8068 karl 327
 
8069 daniel 328
                $anr = $this->getProductAnr($oOrderProduct->getProductKey());
8068 karl 329
                $produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr);
330
 
331
            }
8069 daniel 332
 
333
            if ($bTaxCol) $produkt_text_cell_width = 87;
334
			else $produkt_text_cell_width = 102;
8068 karl 335
 
336
            $produkt_text_width = $pdf->GetStringWidth($produkt_text);
337
 
338
            $height += 5 * ceil($produkt_text_width / $produkt_text_cell_width) + 3;
339
 
340
            $height_y = $pdf->getY();
341
            $height = 2 + $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $offset + 1.5 + $sum_multi_offset, 5, $produkt_text, 0, 'L', 0, $produkt_text_cell_width);
8069 daniel 342
 
343
            if ($bTaxCol) {
8068 karl 344
 
345
                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
8069 daniel 346
                $pdf->Cell(15, 8, (($bNoTax)?'0.00 %':wpsg_ff($oOrderProduct->getTaxValue(), '%')), 0, 0, 'C');
8068 karl 347
 
348
            }
349
 
350
            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
8069 daniel 351
            $pdf->Cell(15, 8, $oOrderProduct->getAmount(), 0, 0, 'C');
8068 karl 352
 
8069 daniel 353
            $preis = $oOrderProduct->getPrice(wpsg_ShopController::getShop()->getFrontendTaxview());
8068 karl 354
 
355
            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
356
            $pdf->Cell(25, 8, wpsg_ff($preis, $this->get_option('wpsg_currency')), 0, 0, 'R');
357
 
358
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
8069 daniel 359
            $pdf->Cell(25, 8, wpsg_ff($oOrderProduct->getPriceSum(wpsg_ShopController::getShop()->getFrontendTaxview()), $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 360
 
361
            /**
362
             * Produktbeschreibung anzeigen Ja/Nein
363
             */
364
            $pBeschreibungHeight = 0;
8069 daniel 365
            if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($p['beschreibung'])) != '') {
8068 karl 366
 
367
                $produktBeschreibung = nl2br($produktBeschreibung);
368
                preg_match_all('/\<br \/\>/', $produktBeschreibung, $treffer);
369
                $produktBeschreibung = strip_tags($produktBeschreibung);
370
 
371
                $pBeschreibungWidth = $pdf->getStringWidth($produktBeschreibung);
372
                $pBeschreibungHeight = 5 * (ceil($pBeschreibungWidth / $produkt_text_cell_width) + @sizeof($treffer[0]));
373
 
374
                $pdf->SetFont('Arial', 'I', 9);
375
 
376
                $cellY = $pdf->getY();
377
                $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 1 + $sum_multi_offset, 5, $produktBeschreibung, 0, 'L', 0, $produkt_text_cell_width);
378
                $pBeschreibungHeight = $pdf->getY() - $cellY - $height + 1;
379
                $pdf->SetFont('Arial', '', 9);
380
 
381
            }
382
 
383
            $height += $pBeschreibungHeight;
384
 
385
            /**
386
             * Produktattribute ?
387
             */
8069 daniel 388
            if ($this->get_option('wpsg_rechnungen_produktattribute') == '1') {
8068 karl 389
 
390
                $attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($p['id'])));
391
 
8069 daniel 392
                foreach ($attributeInfo as $pa) {
8068 karl 393
 
394
                    $pa_text = $pa['name'].': '.$pa['value'];
395
                    $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, $pa_text, 0, 'L', 0, $produkt_text_cell_width);
396
 
397
                }
398
            }
399
 
400
            /**
401
             * Variante ?
402
             */
8069 daniel 403
            if (preg_match('/pv_(.*)/', $p['productkey'])) {
8068 karl 404
 
405
                $variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['productkey']));
406
 
407
                $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Variante: #1#', 'wpsg'), $variInfo['key']), 0, 'L', 0, $produkt_text_cell_width);
408
 
409
                //$height += 5;
410
 
411
            }
412
 
413
            /**
414
             * Lieferschein ?
415
             */
8069 daniel 416
            if ($this->hasMod('wpsg_mod_deliverynote')) {
8068 karl 417
 
8069 daniel 418
                $arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($oOrder->getId()));
8068 karl 419
 
8069 daniel 420
                if (sizeof($arDN_order) > 1) {
8068 karl 421
 
8069 daniel 422
                    $deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($oOrder->getId(), $oOrderProduct->getProductIndex()));
8068 karl 423
 
8069 daniel 424
                    if ($deliveryTimeProduct !== false) {
8068 karl 425
 
426
                        $height += $pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 0.5 + $sum_multi_offset, 5, wpsg_translate(__('Lieferdatum: #1#', 'wpsg'), date('d.m.Y', $deliveryTimeProduct)), 0, 'L', 0, $produkt_text_cell_width);
427
 
428
                    }
429
 
430
                }
431
 
432
            }
433
 
434
            // Jetzt die Rahmen zeichnen
435
            $pdf->Rect($prod_left, $prod_top + $offset + $sum_multi_offset, 10, $height);
436
 
8069 daniel 437
            $pdf->Rect($prod_left + 10, $prod_top + $offset + $sum_multi_offset, (($bTaxCol == '1')?87:102), $height);
8068 karl 438
 
8069 daniel 439
            if ($bTaxCol) {
8068 karl 440
 
441
                $pdf->Rect($prod_left + 97, $prod_top + $offset + $sum_multi_offset, 15, $height);
442
 
443
            }
444
 
445
            $pdf->Rect($prod_left + 112, $prod_top + $offset + $sum_multi_offset, 15, $height);
446
            $pdf->Rect($prod_left + 127, $prod_top + $offset + $sum_multi_offset, 25, $height);
447
            $pdf->Rect($prod_left + 152, $prod_top + $offset + $sum_multi_offset, 25, $height);
448
 
449
            $offset += $height;
450
 
451
            $pnr ++;
452
            $count ++;
453
 
454
            $summe += $p['price'] * $p['menge'];
455
 
8069 daniel 456
            if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($oOrder->getOrderProducts()) > ($pnr - 1))) {
8068 karl 457
 
458
                AddRechnungPage($this, $pdf);
459
                $bKopf = false; $count = 0; $offset = 0;
460
 
461
            }
462
 
463
        } // produkte
8069 daniel 464
 
8068 karl 465
        // Gutschein
8069 daniel 466
        if (wpsg_isSizedArray($arCalculation['voucher'])) {
8068 karl 467
 
8069 daniel 468
            foreach ($arCalculation['voucher'] as $v) {
8068 karl 469
 
470
                $pdf->SetFont('Arial', '', 9);
471
                $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
472
                $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
473
 
474
                $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
8069 daniel 475
                $pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L');
8068 karl 476
 
8069 daniel 477
                if ($bTaxCol) {
8068 karl 478
 
479
                    $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
8069 daniel 480
                    $pdf->Cell(15, 8,  __('anteilig', 'wpsg'), 1, 0, 'C');
8068 karl 481
 
482
                }
483
 
484
                $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
485
                $pdf->Cell(15, 8, '1', 1, 0, 'C');
486
 
487
                $gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
488
                $gs_value_gesamt = wpsg_ff($v[$taxdisplay], $this->get_option('wpsg_currency'));
489
 
490
                $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
491
                $pdf->Cell(25, 8, $gs_value_einzel, 1, 0, 'R');
492
 
493
                $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
494
                $pdf->Cell(25, 8, $gs_value_gesamt, 1, 0, 'R');
495
 
496
                $offset += 8;
497
 
498
            }
499
 
500
        }
501
 
502
        // Versandkosten
8069 daniel 503
	    $cost_shipping = ((wpsg_ShopController::getShop()->getFrontendTaxview() === WPSG_BRUTTO)?$arCalculation['sum']['shipping_brutto']:$arCalculation['sum']['shipping_netto']);
504
 
505
        if ($arCalculation['sum']['shipping_brutto'] > 0) {
8068 karl 506
 
507
            $pdf->SetFont('Arial', '', 9);
508
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
509
            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
510
 
511
            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
8069 daniel 512
            $pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $oOrder->getShippingLabel()), 1, 0, 'L');
8068 karl 513
 
8069 daniel 514
            if ($bTaxCol) {
515
 
516
                if ($bNoTax) {
8068 karl 517
 
518
                    $mwst = 0;
519
 
8069 daniel 520
                } else {
8068 karl 521
 
8069 daniel 522
                    if ($arCalculation['shipping'][0]['tax_key'] === '0') {
8068 karl 523
 
524
                        $mwst = _('anteilig');
525
 
526
                    } else {
527
 
8069 daniel 528
                        $mwst = wpsg_ff($arCalculation['shipping'][0]['tax'], '%');
529
                        $mwst = wpsg_ff($arCalculation['tax'][$arCalculation['shipping'][0]['tax_key']]['tax_value'], '%');
8068 karl 530
 
531
                    }
532
 
533
                }
8069 daniel 534
 
8068 karl 535
                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
536
                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
537
 
538
            }
539
 
540
            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
541
            $pdf->Cell(15, 8, '1', 1, 0, 'C');
542
 
543
            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
8069 daniel 544
            $pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
8068 karl 545
 
546
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
8069 daniel 547
            $pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
8068 karl 548
 
549
            $offset += 8;
550
 
551
        }
552
 
553
        // Zahlungskosten
8069 daniel 554
	    $cost_payment = ((wpsg_ShopController::getShop()->getFrontendTaxview() === WPSG_BRUTTO)?$arCalculation['sum']['payment_brutto']:$arCalculation['sum']['payment_netto']);
555
 
556
        if ($cost_payment > 0) {
8068 karl 557
 
558
            $pdf->SetFont('Arial', '', 9);
559
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
560
            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
561
 
562
            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
8069 daniel 563
            $pdf->Cell( (($bTaxCol)?87:102), 8, $oOrder->getPaymentLabel(), 1, 0, 'L');
8068 karl 564
 
8069 daniel 565
            if ($bTaxCol) {
8068 karl 566
 
8069 daniel 567
                if ($bNoTax) {
568
 
8068 karl 569
                    $mwst = 0;
8069 daniel 570
 
571
                } else {
8068 karl 572
 
8069 daniel 573
                    if ($arCalculation['payment'][0]['tax_key'] === '0') {
8068 karl 574
 
575
                        $mwst = _('anteilig');
576
 
577
                    } else {
578
 
8069 daniel 579
                        $mwst = wpsg_ff($arCalculation['payment'][0]['tax'], '%');
580
                        $mwst = wpsg_ff($arCalculation['tax'][$arCalculation['payment'][0]['tax_key']]['tax_value'], '%');
8068 karl 581
 
582
                    }
583
 
584
                }
585
 
586
                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
587
                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
588
 
589
            }
590
 
591
            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
592
            $pdf->Cell(15, 8, '1', 1, 0, 'C');
593
 
594
            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
8069 daniel 595
            $pdf->Cell(25, 8, wpsg_ff($cost_payment, $this->get_option('wpsg_currency')), 1, 0, 'R');
8068 karl 596
 
597
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
8069 daniel 598
            $pdf->Cell(25, 8, wpsg_ff($cost_payment, $this->get_option('wpsg_currency')), 1, 0, 'R');
8068 karl 599
 
600
            $offset += 8;
601
 
602
        }
603
 
8069 daniel 604
		// Rabatt
605
	    if ($arCalculation['sum']['discount_brutto'] < 0) {
606
 
607
			$pdf->SetFont('Arial', '', 9);
608
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
609
            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
610
 
611
			$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
612
            $pdf->Cell( (($bTaxCol)?87:102), 8, _('Rabatt'), 1, 0, 'L');
613
 
614
			$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
8072 daniel 615
            $pdf->Cell(15, 8, _('anteilig'), 1, 0, 'C');
8069 daniel 616
 
617
			$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
618
            $pdf->Cell(15, 8, '1', 1, 0, 'C');
619
 
620
			$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
621
            $pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['discount_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
622
 
623
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
624
            $pdf->Cell(25, 8, wpsg_ff($arCalculation['sum']['discount_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
625
 
626
			$offset += 8;
627
 
628
	    }
629
 
8072 daniel 630
		// Wertgutschein
631
		foreach ($arCalculation['coupon'] as $c) {
632
 
633
			$pdf->SetFont('Arial', '', 9);
634
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
635
            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
636
 
637
			$pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
638
            $pdf->Cell( (($bTaxCol)?87:102), 8, _('Wertgutschein').' ('.$c['code'].')', 1, 0, 'L');
639
 
640
			$pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
641
            $pdf->Cell(15, 8, _('anteilig'), 1, 0, 'C');
642
 
643
			$pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
644
            $pdf->Cell(15, 8, $c['amount'], 1, 0, 'C');
645
 
646
			$pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
647
            $pdf->Cell(25, 8, wpsg_ff($c[$taxdisplay.'_single'], $this->get_option('wpsg_currency')), 1, 0, 'R');
648
 
649
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
650
            $pdf->Cell(25, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 1, 0, 'R');
651
 
652
			$offset += 8;
653
 
654
		}
655
 
8068 karl 656
        // Gebühr
8069 daniel 657
        if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0) {
8068 karl 658
 
659
            $pdf->SetFont('Arial', '', 9);
660
            $pdf->setXY($prod_left, $prod_top + $offset + $sum_multi_offset);
661
            $pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
662
 
663
            $label = __('Bearbeitungsgebühr', 'wpsg');
664
 
665
            if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
666
 
667
            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
8069 daniel 668
            $pdf->Cell( (($bTaxCol)?87:102), 8, $label, 1, 0, 'L');
8068 karl 669
 
8069 daniel 670
            if ($bTaxCol) {
8068 karl 671
 
8069 daniel 672
                if ($bNoTax) {
673
 
8068 karl 674
                    $mwst = 0;
8069 daniel 675
 
676
                } else {
8068 karl 677
 
678
                    $mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
679
 
680
                }
681
 
682
                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
683
                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
684
 
685
            }
686
 
687
            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
688
            $pdf->Cell(15, 8, '1', 1, 0, 'C');
689
 
690
            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
691
            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
692
 
693
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
694
            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
695
 
696
            $offset += 8;
697
 
698
        }
8072 daniel 699
 
8068 karl 700
        // Bestellbetrag einer einzelnen Bestellung
8069 daniel 701
        if ($bNoTax) {
702
 
8068 karl 703
            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (NETTO):", "wpsg"));
704
			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
8072 daniel 705
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8069 daniel 706
 
707
        } else  {
708
 
8068 karl 709
            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (BRUTTO):", "wpsg"));
710
			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
8072 daniel 711
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8069 daniel 712
 
8068 karl 713
        }
714
 
715
        $sum_multi_offset += ($offset + 30);
8069 daniel 716
 
8068 karl 717
    } // FOREACH ORDER END
8069 daniel 718
 
719
	$arCalculation = $this->view['arCalculationSum'];
8068 karl 720
 
8069 daniel 721
	$offset = $sum_multi_offset - 30;
722
 
8068 karl 723
	$pdf->SetFont('Arial', '', 9);
724
 
8069 daniel 725
	if ($this->view['kunde']['ustidnr'] != "") {
726
 
727
		$offset += 13;
728
 
8068 karl 729
		$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
730
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
731
		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
8069 daniel 732
 
8068 karl 733
	}
734
 
735
	$offset += 10;
736
 
8069 daniel 737
	$offset = $checkPageBreak($this, $offset, 6);
738
 
739
	if ($this->get_option('wpsg_kleinunternehmer')) {
740
 
8068 karl 741
		$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
742
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
743
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8071 daniel 744
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8069 daniel 745
 
8068 karl 746
		$offset += 5;
747
 
8069 daniel 748
	} else {
8068 karl 749
 
8069 daniel 750
		if ($bNoTax) {
8068 karl 751
 
752
			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
753
			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("BRUTTOBETRAG", "wpsg"));
754
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 755
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 756
			$offset += 5;
757
 
758
			$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
759
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
760
			$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
761
 
8069 daniel 762
		} else {
8068 karl 763
 
764
			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
765
 
766
			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("NETTOBETRAG GESAMT", "wpsg"));
767
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 768
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 769
 
8069 daniel 770
			if (sizeof($arCalculation['tax']) >= 1) {
8068 karl 771
 
8069 daniel 772
				foreach ($arCalculation['tax'] as $k => $mw) {
8068 karl 773
 
8069 daniel 774
					if ($k === 0) continue;
775
 
8068 karl 776
					$offset += 5;
8069 daniel 777
 
778
					$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. ", "wpsg").wpsg_ff($mw['tax_value'], '%'));
8068 karl 779
					$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
780
					$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
781
 
782
				}
783
 
784
			}
785
 
8069 daniel 786
			if (sizeof($arCalculation['tax']) > 1) {
8068 karl 787
 
788
				$offset += 5;
789
				$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. GESAMT", "wpsg"));
790
				$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 791
				$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['tax'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 792
 
793
			}
794
 
795
		}
796
 
797
	}
798
 
799
	// Wertgutschein
800
	if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
801
 
802
		$offset += 5;
803
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Bruttobetrag GESAMT", "wpsg"));
804
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
805
 
806
		$pdf->setFont('Arial', '', '9');
8069 daniel 807
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 808
		$pdf->setFont('Arial', '', '9');
809
 
8071 daniel 810
		foreach ($this->view['multi_data']['order_data'] as $order_data) {
811
 
812
			$arCalculationOrder = $order_data['arCalculation'];
8068 karl 813
 
8071 daniel 814
            foreach ($arCalculationOrder['coupon'] as $c) {
8068 karl 815
 
816
                $offset += 5;
817
                $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
818
                $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
819
 
820
                $pdf->setFont('Arial', '', '9');
821
                $pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
822
                $pdf->setFont('Arial', '', '9');
823
 
824
            }
825
 
826
        }
827
 
828
		$offset += 5;
829
		$pdf->setFont('Arial', 'B', '9');
830
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("ZU ZAHLEN", "wpsg"));
831
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
832
 
833
		/* Endbetrag wird fett ausgegeben */
834
		$pdf->setFont('Arial', 'B', '9');
8069 daniel 835
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 836
		$pdf->setFont('Arial', '', '9');
837
 
838
	} else {
839
 
840
		$offset += 5;
841
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("GESAMTSUMME", "wpsg"));
842
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
843
		/* Endbetrag wird fett ausgegeben */
844
		$pdf->setFont('Arial', 'B', '9');
8069 daniel 845
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 846
		$pdf->setFont('Arial', '', '9');
847
 
848
	}
849
 
850
	if ($this->get_option('wpsg_kleinunternehmer') == '1')
851
	{
852
 
853
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 15, 5, $this->get_option('wpsg_kleinunternehmer_text'));
854
		$offset += 15;
855
 
856
	}
857
 
858
	if ($this->hasMod('wpsg_mod_deliverynote'))
859
	{
860
 
861
		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($data['id']));
862
		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($data['id']));
863
 
864
		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
865
		if ($delivery_date !== false && sizeof($arDN_order) == 1)
866
		{
867
 
868
			$offset += 10;
869
 
870
			$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset + 10, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
871
 
872
			$offset += 5;
873
 
874
		}
875
 
876
	}
877
 
878
	$offset += 5;
879
 
880
	if ($this->view['fussText'] != "")
881
	{
882
 
883
		//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));
884
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $this->view['fussText']);
885
		$pdf->SetFont('Arial', 'B', 9);
886
		$offset += 10;
887
 
888
	}
889
 
890
	$shipping_adress = false;
891
 
892
	$offset += 5;
893
 
894
	$filename = $this->view['filename'].".pdf";
8069 daniel 895
 
896
	if ($this->view['preview']) {
8068 karl 897
 
8069 daniel 898
		//$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array('multi')).$filename, 'F');
899
		$pdf->Output();
8068 karl 900
 
8069 daniel 901
	    exit;
8068 karl 902
 
903
	} else {
904
 
8071 daniel 905
		$pdf->Output($this->view['file_path'], 'F');
8068 karl 906
 
907
	}
8069 daniel 908