Subversion Repositories wpShopGermany4

Rev

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

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