Subversion Repositories wpShopGermany4

Rev

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