Subversion Repositories wpShopGermany4

Rev

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

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