Subversion Repositories wpShopGermany4

Rev

Rev 8069 | Rev 8072 | 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);
615
            $pdf->Cell(15, 8, _('Anteilig'), 1, 0, 'C');
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
 
8068 karl 630
        // Gebühr
8069 daniel 631
        if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0) {
8068 karl 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
            $label = __('Bearbeitungsgebühr', 'wpsg');
638
 
639
            if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
640
 
641
            $pdf->setXY($prod_left + 10, $prod_top + $offset + $sum_multi_offset);
8069 daniel 642
            $pdf->Cell( (($bTaxCol)?87:102), 8, $label, 1, 0, 'L');
8068 karl 643
 
8069 daniel 644
            if ($bTaxCol) {
8068 karl 645
 
8069 daniel 646
                if ($bNoTax) {
647
 
8068 karl 648
                    $mwst = 0;
8069 daniel 649
 
650
                } else {
8068 karl 651
 
652
                    $mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
653
 
654
                }
655
 
656
                $pdf->setXY($prod_left + 97, $prod_top + $offset + $sum_multi_offset);
657
                $pdf->Cell(15, 8, $mwst, 1, 0, 'C');
658
 
659
            }
660
 
661
            $pdf->setXY($prod_left + 112, $prod_top + $offset + $sum_multi_offset);
662
            $pdf->Cell(15, 8, '1', 1, 0, 'C');
663
 
664
            $pdf->setXY($prod_left + 127, $prod_top + $offset + $sum_multi_offset);
665
            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
666
 
667
            $pdf->setXY($prod_left + 152, $prod_top + $offset + $sum_multi_offset);
668
            $pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
669
 
670
            $offset += 8;
671
 
672
        }
673
 
674
        // Bestellbetrag einer einzelnen Bestellung
8069 daniel 675
        if ($bNoTax) {
676
 
8068 karl 677
            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (NETTO):", "wpsg"));
678
			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
8069 daniel 679
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
680
 
681
        } else  {
682
 
8068 karl 683
            $pdf->Text($prod_left + 115, $prod_top + $offset + $sum_multi_offset + 6, __("Bestellbetrag (BRUTTO):", "wpsg"));
684
			$pdf->setXY($prod_left + 140, $prod_top + $offset + $sum_multi_offset + 1);
8069 daniel 685
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
686
 
8068 karl 687
        }
688
 
689
        $sum_multi_offset += ($offset + 30);
8069 daniel 690
 
8068 karl 691
    } // FOREACH ORDER END
8069 daniel 692
 
693
	$arCalculation = $this->view['arCalculationSum'];
8068 karl 694
 
8069 daniel 695
	$offset = $sum_multi_offset - 30;
696
 
8068 karl 697
	$pdf->SetFont('Arial', '', 9);
698
 
8069 daniel 699
	if ($this->view['kunde']['ustidnr'] != "") {
700
 
701
		$offset += 13;
702
 
8068 karl 703
		$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
704
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
705
		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
8069 daniel 706
 
8068 karl 707
	}
708
 
709
	$offset += 10;
710
 
8069 daniel 711
	$offset = $checkPageBreak($this, $offset, 6);
712
 
713
	if ($this->get_option('wpsg_kleinunternehmer')) {
714
 
8068 karl 715
		$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
716
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
717
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8071 daniel 718
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8069 daniel 719
 
8068 karl 720
		$offset += 5;
721
 
8069 daniel 722
	} else {
8068 karl 723
 
8069 daniel 724
		if ($bNoTax) {
8068 karl 725
 
726
			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
727
			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("BRUTTOBETRAG", "wpsg"));
728
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 729
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 730
			$offset += 5;
731
 
732
			$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
733
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
734
			$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
735
 
8069 daniel 736
		} else {
8068 karl 737
 
738
			$pdf->Text($prod_left, $prod_top + $offset + 10, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
739
 
740
			$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("NETTOBETRAG GESAMT", "wpsg"));
741
			$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 742
			$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 743
 
8069 daniel 744
			if (sizeof($arCalculation['tax']) >= 1) {
8068 karl 745
 
8069 daniel 746
				foreach ($arCalculation['tax'] as $k => $mw) {
8068 karl 747
 
8069 daniel 748
					if ($k === 0) continue;
749
 
8068 karl 750
					$offset += 5;
8069 daniel 751
 
752
					$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. ", "wpsg").wpsg_ff($mw['tax_value'], '%'));
8068 karl 753
					$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
754
					$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
755
 
756
				}
757
 
758
			}
759
 
8069 daniel 760
			if (sizeof($arCalculation['tax']) > 1) {
8068 karl 761
 
762
				$offset += 5;
763
				$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("MwSt. GESAMT", "wpsg"));
764
				$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
8069 daniel 765
				$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['tax'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 766
 
767
			}
768
 
769
		}
770
 
771
	}
772
 
773
	// Wertgutschein
774
	if ($arCalculation['sum']['topay_brutto'] !== $arCalculation['sum']['brutto']) {
775
 
776
		$offset += 5;
777
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("Bruttobetrag GESAMT", "wpsg"));
778
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
779
 
780
		$pdf->setFont('Arial', '', '9');
8069 daniel 781
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 782
		$pdf->setFont('Arial', '', '9');
783
 
8071 daniel 784
		foreach ($this->view['multi_data']['order_data'] as $order_data) {
785
 
786
			$arCalculationOrder = $order_data['arCalculation'];
8068 karl 787
 
8071 daniel 788
            foreach ($arCalculationOrder['coupon'] as $c) {
8068 karl 789
 
790
                $offset += 5;
791
                $pdf->Text($prod_left + 80, $prod_top + $offset + 10, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
792
                $pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
793
 
794
                $pdf->setFont('Arial', '', '9');
795
                $pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
796
                $pdf->setFont('Arial', '', '9');
797
 
798
            }
799
 
800
        }
801
 
802
		$offset += 5;
803
		$pdf->setFont('Arial', 'B', '9');
804
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("ZU ZAHLEN", "wpsg"));
805
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
806
 
807
		/* Endbetrag wird fett ausgegeben */
808
		$pdf->setFont('Arial', 'B', '9');
8069 daniel 809
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 810
		$pdf->setFont('Arial', '', '9');
811
 
812
	} else {
813
 
814
		$offset += 5;
815
		$pdf->Text($prod_left + 80, $prod_top + $offset + 10, __("GESAMTSUMME", "wpsg"));
816
		$pdf->setXY($prod_left + 140, $prod_top + $offset + 10 - 5);
817
		/* Endbetrag wird fett ausgegeben */
818
		$pdf->setFont('Arial', 'B', '9');
8069 daniel 819
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
8068 karl 820
		$pdf->setFont('Arial', '', '9');
821
 
822
	}
823
 
824
	if ($this->get_option('wpsg_kleinunternehmer') == '1')
825
	{
826
 
827
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 15, 5, $this->get_option('wpsg_kleinunternehmer_text'));
828
		$offset += 15;
829
 
830
	}
831
 
832
	if ($this->hasMod('wpsg_mod_deliverynote'))
833
	{
834
 
835
		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($data['id']));
836
		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($data['id']));
837
 
838
		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
839
		if ($delivery_date !== false && sizeof($arDN_order) == 1)
840
		{
841
 
842
			$offset += 10;
843
 
844
			$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset + 10, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
845
 
846
			$offset += 5;
847
 
848
		}
849
 
850
	}
851
 
852
	$offset += 5;
853
 
854
	if ($this->view['fussText'] != "")
855
	{
856
 
857
		//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));
858
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 10, 5, $this->view['fussText']);
859
		$pdf->SetFont('Arial', 'B', 9);
860
		$offset += 10;
861
 
862
	}
863
 
864
	$shipping_adress = false;
865
 
866
	$offset += 5;
867
 
868
	$filename = $this->view['filename'].".pdf";
8069 daniel 869
 
870
	if ($this->view['preview']) {
8068 karl 871
 
8069 daniel 872
		//$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array('multi')).$filename, 'F');
873
		$pdf->Output();
8068 karl 874
 
8069 daniel 875
	    exit;
8068 karl 876
 
877
	} else {
878
 
8071 daniel 879
		$pdf->Output($this->view['file_path'], 'F');
8068 karl 880
 
881
	}
8069 daniel 882