Subversion Repositories wpShopGermany4

Rev

Rev 6751 | Rev 6843 | 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'], '%');
511
 
512
				}
513
 
514
				/*
515
				if ($this->arShipping[$this->view['data']['type_shipping']]['mwst'] == '0')
516
				{
517
 
518
					$mwst = __('anteilig', 'wpsg');
519
 
520
				}
521
				else
522
				{
523
 
524
					$mwst = wpsg_ff($this->arShipping[$this->view['data']['type_shipping']]['mwst_value'], '%');
525
 
526
				}
527
				*/
528
 
529
			}
530
 
531
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
532
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
533
 
534
		}
535
 
536
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
537
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
538
 
539
		$pdf->setXY($prod_left + 127, $prod_top + $offset);
540
		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
541
 
542
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
543
		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_shipping'], $this->get_option('wpsg_currency')), 1, 0, 'R');
544
 
545
		$offset += 8;
546
 
547
		// Zusammengesetzte Versandarten darstellen
548
		/*
549
		if (wpsg_isSizedArray($this->view['basket']['shipping']['methods'])) {
550
 
551
			foreach ($this->view['basket']['shipping']['methods'] as $shipping) {
552
 
553
				$pdf->SetFont('Arial', '', 9);
554
				$pdf->setXY($prod_left, $prod_top + $offset);
555
				$pdf->Cell(10, 8, '', 1, 0, 'C'); $pnr ++;
556
 
557
				$pdf->setXY($prod_left + 10, $prod_top + $offset);
558
				$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $this->getShippingName($shipping), 1, 0, 'L');
559
 
560
				if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
561
				{
562
 
563
					if ($this->view['basket']['shipping'][$shipping]['tax_rata'] == 1) { $mwst = __('Anteilig', 'wpsg'); }
564
					else { $mwst = wpsg_ff($this->view['basket']['shipping'][$shipping]['mwst'], '%'); }
565
 
566
					$pdf->setXY($prod_left + 97, $prod_top + $offset);
567
					$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
568
 
569
				}
570
 
571
				$pdf->setXY($prod_left + 112, $prod_top + $offset);
572
				$pdf->Cell(15, 8, '1', 1, 0, 'C');
573
 
574
				$pdf->setXY($prod_left + 127, $prod_top + $offset);
575
				$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
576
 
577
				$pdf->setXY($prod_left + 152, $prod_top + $offset);
578
				$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['shipping'][$shipping]['preis_shipping_brutto'], $this->get_option('wpsg_currency')), 1, 0, 'R');
579
 
580
				$offset += 8;
581
 
582
			}
583
 
584
		}
585
		*/
586
 
587
 
588
	}
589
 
590
	// Zahlungskosten
591
	if ($this->view['basket']['sum']['preis_payment'] != '' && $this->view['basket']['sum']['preis_payment'] != 0)
592
	{
593
 
594
		$pdf->SetFont('Arial', '', 9);
595
		$pdf->setXY($prod_left, $prod_top + $offset);
596
		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
597
 
598
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
599
		$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');
600
 
601
		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
602
		{
603
 
604
			if ($this->arPayment[$this->view['data']['type_payment']]['mwst_null'] == '1' && $this->view['basket']['noMwSt'] == '1')
605
			{
606
				$mwst = 0;
607
			}
608
			else
609
			{
610
 
611
				if (isset($this->view['basket']['payment']['tax_rata']) && $this->view['basket']['payment']['tax_rata'] === true)
612
				{
613
 
614
					$mwst = __('anteilig', 'wpsg');
615
 
616
				}
617
				else
618
				{
619
 
620
					$mwst = wpsg_ff($this->arPayment[$this->view['basket']['checkout']['payment']]['mwst_value'], '%');
621
 
622
				}
623
 
624
				/*
625
				if ($this->arPayment[$this->view['data']['type_payment']]['mwst'] == '0')
626
				{
627
 
628
					$mwst = __('anteilig', 'wpsg');
629
 
630
				}
631
				else
632
				{
633
 
634
					$mwst = wpsg_ff($this->arPayment[$this->view['data']['type_payment']]['mwst_value'], '%');
635
 
636
				}
637
				*/
638
 
639
			}
640
 
641
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
642
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
643
 
644
		}
645
 
646
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
647
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
648
 
649
		$pdf->setXY($prod_left + 127, $prod_top + $offset);
650
		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
651
 
652
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
653
		$pdf->Cell(25, 8, wpsg_ff($this->view['basket']['sum']['preis_payment'], $this->get_option('wpsg_currency')), 1, 0, 'R');
654
 
655
		$offset += 8;
656
 
657
	}
658
 
659
	// Gebühr
660
	if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0)
661
	{
662
 
663
		$pdf->SetFont('Arial', '', 9);
664
		$pdf->setXY($prod_left, $prod_top + $offset);
665
		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
666
 
667
		$label = __('Bearbeitungsgebühr', 'wpsg');
668
 
669
		if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
670
 
671
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
672
		$pdf->Cell( ((sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')?87:102), 8, $label, 1, 0, 'L');
673
 
674
		if (sizeof($this->view['basket']['mwst']) >= 1 || $this->get_option('wpsg_showMwstAlways') == '1')
675
		{
676
 
677
			if ($this->view['basket']['noMwSt'] == '1')
678
			{
679
				$mwst = 0;
680
			}
681
			else
682
			{
683
 
684
 
685
				$mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
686
 
687
			}
688
 
689
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
690
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
691
 
692
		}
693
 
694
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
695
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
696
 
697
		$pdf->setXY($prod_left + 127, $prod_top + $offset);
698
		$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
699
 
700
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
701
		$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
702
 
703
		$offset += 8;
704
 
705
	}
706
 
707
	$pdf->SetFont('Arial', '', 9);
708
 
709
	if ($this->view['kunde']['ustidnr'] != "")
710
	{
711
		$offset += 10;
712
		$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
713
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
714
		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
715
	}
716
 
717
	$offset += 10;
718
	if ($this->get_option('wpsg_kleinunternehmer'))
719
	{
720
 
721
		$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
722
		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Summe", "wpsg"));
723
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
724
		$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');
725
		$offset += 5;
726
 
727
	}
728
	else
729
	{
730
 
731
		if ($this->view['basket']['noMwSt'] == '1')
732
		{
733
 
734
			$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
735
			$pdf->Text($prod_left + 100, $prod_top + $offset, __("BRUTTOBETRAG", "wpsg"));
736
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
737
			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
738
			$offset += 5;
739
 
740
			$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
741
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
742
			$pdf->Cell(37, 8, wpsg_ff(0, $this->get_option('wpsg_currency')), 0, 0, 'R');
743
 
744
		}
745
		else
746
		{
747
 
748
			$pdf->Text($prod_left, $prod_top + $offset, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg"));
749
 
750
			$pdf->Text($prod_left + 100, $prod_top + $offset, __("NETTOBETRAG", "wpsg"));
751
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
752
			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_netto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
753
 
754
			if (sizeof($this->view['basket']['mwst']) >= 1)
755
			{
756
 
757
				foreach ($this->view['basket']['mwst'] as $mw)
758
				{
759
 
760
					$offset += 5;
761
					$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['value'], '%'));
762
					$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
763
					$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
764
 
765
				}
766
 
767
			}
768
 
769
			if (sizeof($this->view['basket']['mwst']) > 1)
770
			{
771
 
772
				$offset += 5;
773
				$pdf->Text($prod_left + 100, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
774
				$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
775
				$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');
776
 
777
			}
778
 
779
		}
780
 
781
	}
782
 
783
	// Rabatt
784
	if ($this->view['basket']['sum']['preis_rabatt'] > 0)
785
	{
786
 
787
		$offset += 5;
788
 
789
		$pdf->Text($prod_left + 100, $prod_top + $offset, __("Rabatt", "wpsg"));
790
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
791
		$pdf->Cell(37, 8, '-'.wpsg_ff($this->view['basket']['sum']['preis_rabatt'], $this->get_option('wpsg_currency')), 0, 0, 'R');
792
 
793
	}
794
 
795
	$offset += 5;
796
	$pdf->Text($prod_left + 100, $prod_top + $offset, __("SUMME", "wpsg"));
797
	$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
798
	$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['sum']['preis_gesamt_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
799
 
800
	if ($this->get_option('wpsg_kleinunternehmer') == '1')
801
	{
802
 
803
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset + 5, 5, $this->get_option('wpsg_kleinunternehmer_text'));
804
		$offset += 15;
805
 
806
	}
807
 
808
	if ($this->hasMod('wpsg_mod_deliverynote'))
809
	{
810
 
811
		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($this->view['data']['id']));
812
		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($this->view['data']['id']));
813
 
814
		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
815
		if ($delivery_date !== false && sizeof($arDN_order) == 1)
816
		{
817
 
818
			$offset += 10;
819
 
820
			$pdf->wpsg_MultiCell($prod_left, $prod_top + $offset, 5, wpsg_translate(__('Lieferung: #1#', 'wpsg'), date('d.m.Y', $delivery_date)));
821
 
822
			$offset += 5;
823
 
824
		}
825
 
826
	}
827
 
828
	$offset += 5;
829
 
830
	if ($this->view['fussText'] != "")
831
	{
832
 
833
		//$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, utf8_encode($this->view['fussText']));
834
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $this->view['fussText']);
835
		$pdf->SetFont('Arial', 'B', 9);
836
		$offset += 10;
837
 
838
	}
839
 
840
	$shipping_adress = false;
841
 
842
	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'])))
843
	{
844
 
845
		$pdf->setFont('Arial', 'B', 9);
846
		$pdf->Text($prod_left, $prod_top + $offset, __("Lieferanschrift", "wpsg").":");
847
		$offset += 5;
848
 
849
		$pdf->setFont('Arial', '', 9);
850
 
851
		$shipping_adress = "";
852
		if ($this->view['data']['shipping_firma'] != "")
853
		{
854
			$shipping_adress .= $this->view['data']['shipping_firma']."\r\n";
855
		}
856
		$shipping_adress .= $this->view['data']['shipping_vname'].' '.$this->view['data']['shipping_name']."\r\n";
857
		$shipping_adress .= $this->view['data']['shipping_strasse']."\r\n";
858
		//$shipping_adress .= $this->view['data']['shipping_land']['kuerzel'].'-';
859
 
860
		$shipping_adress .= $this->view['data']['shipping_plz'].' '.$this->view['data']['shipping_ort']."\r\n";
861
		$shipping_adress .= $this->view['data']['shipping_land']['name'];
862
 
863
 
864
		$start = $pdf->getY();
865
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $shipping_adress, 0, 'L', 0, 100);
866
		$offset += $pdf->getY() - $start;
867
 
868
		$shipping_adress = true;
869
 
870
	}
871
 
872
 
873
	$offset += 5;
874
 
875
	// Bestellvariablen
876
	if ($this->hasMod('wpsg_mod_ordervars') && $this->get_option('wpsg_mod_rechnungen_showov') == '1')
877
	{
878
 
879
		$bvars = @unserialize($this->view['data']['bvars']);
880
		if (!is_array($bvars)) $bvars = array();
881
 
882
		$strBVars = "";
883
		foreach ($bvars as $bvars_id => $bvars_value)
884
		{
885
 
886
			$bvars = $this->db->fetchRow("SELECT * FROM `".wpsg_q(WPSG_TBL_ORDERVARS)."` WHERE `id` = '".wpsg_q($bvars_id)."' ORDER BY `pos` ASC, `id` ASC ");
887
 
888
			if ($bvars['typ'] == "1") // Auswahl
889
			{
890
				if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
891
			}
892
			else if ($bvars['typ'] == "2") // Texteingabe
893
			{
894
				if (trim($bvars_value) == "") $bvars_value = __("Keine Angabe", "wpsg");
895
			}
896
			else if ($bvars['typ'] == "3") // Checkbox
897
			{
898
				if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
899
			}
900
 
901
			$bvars_name = $this->callMod('wpsg_mod_ordervars', 'getNameById', array($bvars_id));
902
			$strBVars .= "\r\n".$bvars_name.": ".$bvars_value;
903
 
904
		}
905
 
906
		$pdf->SetFont('Arial', 'B', 9);
907
		$pdf->Text($prod_left, $prod_top + $offset, __("Angaben während der Bestellung", "wpsg").":");
908
		$pdf->SetFont('Arial', '', 9);
909
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $strBVars);
910
 
911
	}
912
 
913
	if (!file_exists($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id']))))
914
	{
915
 
916
		mkdir($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'])), 0777, true);
917
 
918
	}
919
 
920
	$this->callMods('wpsg_mod_rechnungen_pdf', array(&$pdf, &$this->view['data']['id'], &$this->view['preview'], &$this->view['invoice']));
921
 
922
	$filename = $this->view['filename'].".pdf";
923
 
924
	if ($this->view['preview'])
925
	{
926
		$pdf->Output($filename, 'I');
927
	}
928
	else
929
	{
930
 
931
		$pdf->Output($this->callMod('wpsg_mod_rechnungen', 'getFilePath', array($this->view['data']['id'])).$filename, 'F');
932
 
933
		// Hier wird der Dateiname an FPD übergeben. Er soll sich aus der Rechnungsnummer ergeben, auch wenn das Dokument über die ID gespeichert ist.
934
		if ($this->view['output'] === true) $pdf->Output($this->view['filename_out'], 'I');
935
 
936
	}
937
 
938
?>