Subversion Repositories wpShopGermany4

Rev

Rev 8274 | Rev 8301 | 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
 
8274 karl 202
		$discount_value = abs($this->view['basket']['arCalculation']['sum']['discount_netto']);
8167 karl 203
		$shipping_cost = $this->view['basket']['arCalculation']['sum']['shipping_netto'];
204
		$payment_cost = $this->view['basket']['arCalculation']['sum']['payment_netto'];
205
 
206
	} else {
207
 
8274 karl 208
		$discount_value = abs($this->view['basket']['arCalculation']['sum']['discount_brutto']);
8167 karl 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
	{
8280 daniel 219
 
8144 karl 220
		$product = wpsg_product::getInstance($p['product_id']);
8280 daniel 221
		if (($p['product_key']??'') !== '') $product->setProductKey($p['product_key']);
8144 karl 222
 
1093 daniel 223
		if (!$bKopf)
224
		{
8144 karl 225
 
1093 daniel 226
			$pdf->SetFont('Arial', 'B', 9);
227
			$pdf->setXY($prod_left, $prod_top);
228
			$pdf->Cell(10, 8, __("Nr.", "wpsg"), 1, 0, 'C');
7243 daniel 229
 
1093 daniel 230
			$pdf->setXY($prod_left + 10, $prod_top);
8144 karl 231
			$pdf->Cell( (($bTaxCol)?87:102), 8, "Name", 1, 0, 'L');
8056 karl 232
 
8144 karl 233
			if ($bTaxCol)
1093 daniel 234
			{
7243 daniel 235
 
1093 daniel 236
				$pdf->setXY($prod_left + 97, $prod_top);
3024 daniel 237
				$pdf->Cell(15, 8, __("MwSt.", "wpsg"), 1, 0, 'C');
7243 daniel 238
 
1093 daniel 239
			}
7243 daniel 240
 
1093 daniel 241
			$pdf->setXY($prod_left + 112, $prod_top);
242
			$pdf->Cell(15, 8, __("Menge", "wpsg"), 1, 0, 'C');
7243 daniel 243
 
1093 daniel 244
			$pdf->setXY($prod_left + 127, $prod_top);
245
			$pdf->Cell(25, 8, __("Einzelpreis", "wpsg"), 1, 0, 'R');
7243 daniel 246
 
1093 daniel 247
			$pdf->setXY($prod_left + 152, $prod_top);
248
			$pdf->Cell(25, 8, __("Gesamtpreis", "wpsg"), 1, 0, 'R');
7243 daniel 249
 
7094 florian 250
			$offset = 8;
1093 daniel 251
			$bKopf = true;
7243 daniel 252
 
1093 daniel 253
		}
7243 daniel 254
 
1093 daniel 255
		$pdf->SetFont('Arial', '', 9);
256
		$pdf->setXY($prod_left, $prod_top + $offset);
7243 daniel 257
 
8189 karl 258
		if ($this->get_option('wpsg_mod_rechnungen_anr') == '1') $pdf->Cell(10, 8, $product->getNr(), 0, 0, 'C');
259
		else $pdf->Cell(10, 8, $pnr.".", 0, 0, 'C');
7243 daniel 260
 
8280 daniel 261
		if ($this->get_option('wpsg_rechnungen_pdetailname') == '1') $produkt_text = $product->getProductName(true);
262
		else $produkt_text = $product->getProductName(false);
8082 karl 263
 
8144 karl 264
		$produktBeschreibung = trim(strip_tags($product->getShortDescription()));
7243 daniel 265
 
1093 daniel 266
		if ($this->isOtherLang())
7094 florian 267
		{
7243 daniel 268
 
8144 karl 269
			$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 270
 
1093 daniel 271
			if (is_array($trans_db) && sizeof($trans_db) > 0)
272
			{
7243 daniel 273
 
1093 daniel 274
				$produkt_text = $trans_db['name'];
1671 daniel 275
				$produktBeschreibung = trim(strip_tags($trans_db['beschreibung']));
7243 daniel 276
 
1093 daniel 277
			}
7243 daniel 278
 
1093 daniel 279
		}
7243 daniel 280
 
1093 daniel 281
		$height = 0; // Höhe der Zeile für den Rahmen
7243 daniel 282
 
1093 daniel 283
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
7243 daniel 284
 
8167 karl 285
		// Produktvariablen
1671 daniel 286
		if ($this->hasMod('wpsg_mod_productvars') && $this->get_option("wpsg_mod_rechnungen_showpv") == "1")
1093 daniel 287
		{
8167 karl 288
 
8179 daniel 289
			$arPV = $this->callMod('wpsg_mod_productvars', 'getAllProductVarValues', array($this->view['data']['id'], $p['product_index']));
8167 karl 290
 
3709 daniel 291
			if (wpsg_isSizedArray($arPV))
1093 daniel 292
			{
7243 daniel 293
 
7094 florian 294
				foreach ($arPV as $pv)
3709 daniel 295
				{
7243 daniel 296
 
3709 daniel 297
					$produkt_text .= "\r\n".$pv['name'].': '.$pv['value'];
298
					$height += 5;
7243 daniel 299
 
3709 daniel 300
				}
7243 daniel 301
 
3709 daniel 302
			}
7243 daniel 303
 
1093 daniel 304
		}
7243 daniel 305
 
7094 florian 306
		if ($this->get_option('wpsg_mod_rechnungen_anr') === '2')
307
		{
7243 daniel 308
 
8144 karl 309
			$anr = $this->getProductAnr($product->getProductKey());
7094 florian 310
			$produkt_text .= "\r\n".wpsg_translate(__('Artikelnummer: #1#', 'wpsg'), $anr);
7243 daniel 311
 
7094 florian 312
		}
7243 daniel 313
 
1678 daniel 314
		$produkt_text_cell_width = 102;
8189 karl 315
		if ($bTaxCol) $produkt_text_cell_width = 87;
7243 daniel 316
 
1093 daniel 317
		$produkt_text_width = $pdf->GetStringWidth($produkt_text);
1678 daniel 318
		//$produkt_text_cell_width = (($this->arMwSt == "-1")?87:102);
7243 daniel 319
 
1671 daniel 320
		$height += 5 * ceil($produkt_text_width / $produkt_text_cell_width) + 3;
7243 daniel 321
 
1678 daniel 322
		$height_y = $pdf->getY();
5382 daniel 323
		$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 324
 
1678 daniel 325
		//$height += 3 + 5 + $pdf->getY() - $height_y;
1093 daniel 326
		//$pdf->Cell((($this->arMwSt == "-1")?102:87), 8, $produkt_text, 0, 0, 'L');
8065 daniel 327
 
8144 karl 328
		if ($bTaxCol) {
8167 karl 329
 
7094 florian 330
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
8189 karl 331
			$pdf->Cell(15, 8, (($bNoTax)?'0.00 %':wpsg_ff($this->view['basket']['arCalculation']['tax'][$p['tax_key']]['tax_value'], '%')), 0, 0, 'C');
8065 daniel 332
 
1093 daniel 333
		}
7243 daniel 334
 
1093 daniel 335
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
8144 karl 336
		$pdf->Cell(15, 8, $p['amount'], 0, 0, 'C');
7243 daniel 337
 
8189 karl 338
		if ( ( wpsg_ShopController::get_option('wpsg_preisangaben') == WPSG_NETTO ) || $bNoTax ) $preis_single = $p['netto_calculated_single'];
339
		else $preis_single =  $p['brutto_calculated_single'];
7243 daniel 340
 
1093 daniel 341
		$pdf->setXY($prod_left + 127, $prod_top + $offset);
8178 karl 342
		$pdf->Cell(25, 8, wpsg_ff($preis_single, $this->get_option('wpsg_currency')), 0, 0, 'R');
7243 daniel 343
 
1093 daniel 344
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
8178 karl 345
		$pdf->Cell(25, 8, wpsg_ff($preis_single * $p['amount'], $this->get_option('wpsg_currency')), 0, 0, 'R');
7243 daniel 346
 
1093 daniel 347
		/**
348
		 * Produktbeschreibung anzeigen Ja/Nein
349
		 */
350
		$pBeschreibungHeight = 0;
8144 karl 351
		if ($this->get_option("wpsg_rechnungen_pbeschreibung") == "1" && trim(strip_tags($product->getShortDescription())) != '')
1093 daniel 352
		{
8167 karl 353
 
7094 florian 354
			$produktBeschreibung = nl2br($produktBeschreibung);
1237 daniel 355
			preg_match_all('/\<br \/\>/', $produktBeschreibung, $treffer);
356
			$produktBeschreibung = strip_tags($produktBeschreibung);
7243 daniel 357
 
7094 florian 358
			$pBeschreibungWidth = $pdf->getStringWidth($produktBeschreibung);
1237 daniel 359
			$pBeschreibungHeight = 5 * (ceil($pBeschreibungWidth / $produkt_text_cell_width) + @sizeof($treffer[0]));
7243 daniel 360
 
1093 daniel 361
			$pdf->SetFont('Arial', 'I', 9);
7243 daniel 362
 
1678 daniel 363
			$cellY = $pdf->getY();
7094 florian 364
			$pdf->wpsg_MultiCell($prod_left + 10, $prod_top + $height + $offset - 1, 5, $produktBeschreibung, 0, 'L', 0, $produkt_text_cell_width);
1678 daniel 365
			$pBeschreibungHeight = $pdf->getY() - $cellY - $height + 1;
1093 daniel 366
			$pdf->SetFont('Arial', '', 9);
7243 daniel 367
 
7094 florian 368
		}
7243 daniel 369
 
1093 daniel 370
		$height += $pBeschreibungHeight;
7243 daniel 371
 
5765 thomas 372
		/**
373
		 * Produktattribute ?
374
		 */
375
		if ($this->get_option('wpsg_rechnungen_produktattribute') == '1')
376
		{
7243 daniel 377
 
8144 karl 378
			$attributeInfo = $this->callMod('wpsg_mod_produktattribute', 'getProductAttributeByProductId', array($this->getProduktId($p['product_id'])));
7243 daniel 379
 
5765 thomas 380
			foreach ($attributeInfo as $pa)
381
			{
7243 daniel 382
 
8167 karl 383
				if ($pa['value'] == "") $pa['value'] = "Keine Angabe";
5765 thomas 384
				$pa_text = $pa['name'].': '.$pa['value'];
385
				$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 386
 
5765 thomas 387
			}
7094 florian 388
		}
7243 daniel 389
 
1125 daniel 390
		/**
7094 florian 391
		 * Variante ?
1125 daniel 392
		 */
8144 karl 393
		if (preg_match('/pv_(.*)/', $p['product_key']))
1125 daniel 394
		{
7243 daniel 395
 
8144 karl 396
			$variInfo = $this->callMod('wpsg_mod_productvariants', 'getVariantenInfoArray', array($p['product_key']));
7243 daniel 397
 
7094 florian 398
			$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 399
 
2877 daniel 400
			//$height += 5;
7243 daniel 401
 
1125 daniel 402
		}
7243 daniel 403
 
8167 karl 404
		if ($this->hasMod('wpsg_mod_deliverynote') && ($this->get_option('wpsg_rechnungen_deliverynote') == '1'))
5046 daniel 405
		{
7243 daniel 406
 
5046 daniel 407
			$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($this->view['data']['id']));
7243 daniel 408
 
5046 daniel 409
			if (sizeof($arDN_order) > 1)
410
			{
7243 daniel 411
 
7094 florian 412
				$deliveryTimeProduct = $this->callMod('wpsg_mod_deliverynote', 'getProductDeliveryTime', array($this->view['data']['id'], $p['product_index']));
7243 daniel 413
 
5046 daniel 414
				if ($deliveryTimeProduct !== false)
415
				{
7243 daniel 416
 
5382 daniel 417
					$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 418
 
5046 daniel 419
				}
7243 daniel 420
 
5046 daniel 421
			}
7243 daniel 422
 
5046 daniel 423
		}
7243 daniel 424
 
1093 daniel 425
		// Jetzt die Rahmen zeichnen
426
		$pdf->Rect($prod_left, $prod_top + $offset, 10, $height);
7243 daniel 427
 
8144 karl 428
		$pdf->Rect($prod_left + 10, $prod_top + $offset, (($bTaxCol)?87:102), $height);
7243 daniel 429
 
8189 karl 430
		if ($bTaxCol) $pdf->Rect($prod_left + 97, $prod_top + $offset, 15, $height);
7243 daniel 431
 
1093 daniel 432
		$pdf->Rect($prod_left + 112, $prod_top + $offset, 15, $height);
433
		$pdf->Rect($prod_left + 127, $prod_top + $offset, 25, $height);
434
		$pdf->Rect($prod_left + 152, $prod_top + $offset, 25, $height);
7243 daniel 435
 
1093 daniel 436
		$offset += $height;
7243 daniel 437
 
1093 daniel 438
		$pnr ++;
439
		$count ++;
7243 daniel 440
 
8189 karl 441
		if ($bNoTax) $price = $p['netto'];
442
		else $price = $p['brutto'];
8144 karl 443
 
444
		$summe += $price * $p['amount'];
7243 daniel 445
 
8144 karl 446
		if ($pdf->getY() > 220 || ($count >= $prod_break && sizeof($this->view['basket']['arCalculation']['product']) > ($pnr - 1)))
1093 daniel 447
		{
7243 daniel 448
 
1093 daniel 449
			AddRechnungPage($this, $pdf);
450
			$bKopf = false; $offset = 0; $count = 0;
7243 daniel 451
 
1093 daniel 452
		}
7243 daniel 453
 
1094 daniel 454
	} // produkte
7243 daniel 455
 
8274 karl 456
	if (wpsg_isSizedArray($this->view['basket']['arCalculation']['voucher']))
457
	{
7490 daniel 458
 
459
		foreach ($this->view['basket']['arCalculation']['voucher'] as $v) {
8144 karl 460
 
7490 daniel 461
			$pdf->SetFont('Arial', '', 9);
462
			$pdf->setXY($prod_left, $prod_top + $offset);
463
			$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
464
 
465
			$pdf->setXY($prod_left + 10, $prod_top + $offset);
8144 karl 466
			$pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Gutschein (#1#)', 'wpsg'), $v['code']), 1, 0, 'L');
7490 daniel 467
 
8144 karl 468
			if ($bTaxCol)
7490 daniel 469
			{
470
 
471
				$mwst = __('anteilig', 'wpsg');
472
 
473
				$pdf->setXY($prod_left + 97, $prod_top + $offset);
474
				$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
475
 
476
			}
477
 
478
			$pdf->setXY($prod_left + 112, $prod_top + $offset);
479
			$pdf->Cell(15, 8, '1', 1, 0, 'C');
480
 
481
			$gs_value_einzel = wpsg_ff($v[$taxdisplay.'_single'], $this->get_option('wpsg_currency'));
482
			$gs_value_gesamt = wpsg_ff($v[$taxdisplay], $this->get_option('wpsg_currency'));
483
 
484
			$pdf->setXY($prod_left + 127, $prod_top + $offset);
485
			$pdf->Cell(25, 8, $gs_value_einzel, 1, 0, 'R');
486
 
487
			$pdf->setXY($prod_left + 152, $prod_top + $offset);
488
			$pdf->Cell(25, 8, $gs_value_gesamt, 1, 0, 'R');
489
 
490
			$offset += 8;
491
 
492
		}
493
 
494
	}
8144 karl 495
 
1094 daniel 496
	// Versandkosten
8274 karl 497
	if ( ($shipping_cost != '') && ($shipping_cost != 0) )
1094 daniel 498
	{
7243 daniel 499
 
1094 daniel 500
		$pdf->SetFont('Arial', '', 9);
501
		$pdf->setXY($prod_left, $prod_top + $offset);
502
		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
7243 daniel 503
 
1094 daniel 504
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
8144 karl 505
		$pdf->Cell( (($bTaxCol)?87:102), 8, wpsg_translate(__('Versandkosten "#1#"', 'wpsg'), $this->view['oOrder']->getShippingLabel()), 1, 0, 'L');
7243 daniel 506
 
8144 karl 507
		if ($bTaxCol)
1094 daniel 508
		{
8144 karl 509
 
8189 karl 510
			if ($this->arShipping[$this->view['data']['type_shipping']]['mwst_null'] == '1' && $bNoTax) $mwst = wpsg_ff(0.00, '%');
511
			else {
7243 daniel 512
 
8189 karl 513
				if ($this->view['basket']['arCalculation']['shipping'][0]['tax_key'] === '0') $mwst = _('anteilig');
514
				else {
8144 karl 515
 
7642 daniel 516
					$mwst = wpsg_ff($this->view['basket']['arCalculation']['shipping'][0]['tax'], '%');
517
					$mwst = wpsg_ff($this->view['basket']['arCalculation']['tax'][$this->view['basket']['arCalculation']['shipping'][0]['tax_key']]['tax_value'], '%');
1416 daniel 518
 
519
				}
7243 daniel 520
 
1165 daniel 521
			}
7243 daniel 522
 
1094 daniel 523
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
3024 daniel 524
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
7243 daniel 525
 
1094 daniel 526
		}
7243 daniel 527
 
1094 daniel 528
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
7094 florian 529
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
7243 daniel 530
 
1094 daniel 531
		$pdf->setXY($prod_left + 127, $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
 
1094 daniel 534
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
8144 karl 535
		$pdf->Cell(25, 8, wpsg_ff($shipping_cost, $this->get_option('wpsg_currency')), 1, 0, 'R');
7243 daniel 536
 
8144 karl 537
		$offset += 8;
7243 daniel 538
 
1093 daniel 539
	}
7243 daniel 540
 
1094 daniel 541
	// Zahlungskosten
8144 karl 542
	if ( ($payment_cost != '') && ($payment_cost != 0) )
1094 daniel 543
	{
7243 daniel 544
 
1094 daniel 545
		$pdf->SetFont('Arial', '', 9);
546
		$pdf->setXY($prod_left, $prod_top + $offset);
547
		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
7243 daniel 548
 
1094 daniel 549
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
8144 karl 550
		$pdf->Cell( (($bTaxCol)?87:102), 8, $this->arPayment[$this->view['data']['type_payment']]['name'], 1, 0, 'L');
7243 daniel 551
 
8144 karl 552
		if ($bTaxCol)
1094 daniel 553
		{
7243 daniel 554
 
8144 karl 555
			if ($this->arPayment[$this->view['data']['type_payment']]['mwst_null'] == '1' && $bNoTax)
1165 daniel 556
			{
8144 karl 557
 
558
				$mwst = wpsg_ff(0.00, '%');
559
 
560
			} else {
7243 daniel 561
 
7642 daniel 562
				if ($this->view['basket']['arCalculation']['payment'][0]['tax_key'] === '0') {
8144 karl 563
 
7642 daniel 564
					$mwst = _('anteilig');
8144 karl 565
 
7642 daniel 566
				} else {
8144 karl 567
 
7642 daniel 568
					$mwst = wpsg_ff($this->view['basket']['arCalculation']['payment'][0]['tax'], '%');
569
					$mwst = wpsg_ff($this->view['basket']['arCalculation']['tax'][$this->view['basket']['arCalculation']['payment'][0]['tax_key']]['tax_value'], '%');
8144 karl 570
 
4126 daniel 571
				}
7243 daniel 572
 
1165 daniel 573
			}
8144 karl 574
 
1094 daniel 575
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
3024 daniel 576
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
7243 daniel 577
 
1094 daniel 578
		}
7243 daniel 579
 
1094 daniel 580
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
7094 florian 581
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
7243 daniel 582
 
1094 daniel 583
		$pdf->setXY($prod_left + 127, $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
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
8144 karl 587
		$pdf->Cell(25, 8, wpsg_ff($payment_cost, $this->get_option('wpsg_currency')), 1, 0, 'R');
7243 daniel 588
 
1094 daniel 589
		$offset += 8;
7243 daniel 590
 
1094 daniel 591
	}
7243 daniel 592
 
2759 daniel 593
	// Gebühr
5934 hartmut 594
	if (wpsg_tf(wpsg_getStr($this->view['storno_fee'])) > 0)
2759 daniel 595
	{
7243 daniel 596
 
2759 daniel 597
		$pdf->SetFont('Arial', '', 9);
598
		$pdf->setXY($prod_left, $prod_top + $offset);
599
		$pdf->Cell(10, 8, $pnr.'.', 1, 0, 'C'); $pnr ++;
7243 daniel 600
 
4301 daniel 601
		$label = __('Bearbeitungsgebühr', 'wpsg');
7243 daniel 602
 
4301 daniel 603
		if (strpos($this->view['storno_fee'], '%') !== false) $label .= ' ('.wpsg_ff($this->view['storno_fee'], '%').')';
7243 daniel 604
 
2759 daniel 605
		$pdf->setXY($prod_left + 10, $prod_top + $offset);
8144 karl 606
		$pdf->Cell( (($bTaxCol)?87:102), 8, $label, 1, 0, 'L');
7243 daniel 607
 
8144 karl 608
		if ($bTaxCol)
2759 daniel 609
		{
7243 daniel 610
 
8189 karl 611
			if ($bNoTax) $mwst = wpsg_ff(0.00, '%');
612
			else $mwst = wpsg_ff($this->view['storno_fee_tax_value'], '%');
7243 daniel 613
 
2759 daniel 614
			$pdf->setXY($prod_left + 97, $prod_top + $offset);
4301 daniel 615
			$pdf->Cell(15, 8, $mwst, 1, 0, 'C');
7243 daniel 616
 
2759 daniel 617
		}
7243 daniel 618
 
2759 daniel 619
		$pdf->setXY($prod_left + 112, $prod_top + $offset);
7094 florian 620
		$pdf->Cell(15, 8, '1', 1, 0, 'C');
7243 daniel 621
 
2759 daniel 622
		$pdf->setXY($prod_left + 127, $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
		$pdf->setXY($prod_left + 152, $prod_top + $offset);
4301 daniel 626
		$pdf->Cell(25, 8, '-'.wpsg_ff($this->view['storno_fee_value'], $this->get_option('wpsg_currency')), 1, 0, 'R');
7243 daniel 627
 
2759 daniel 628
		$offset += 8;
7243 daniel 629
 
2759 daniel 630
	}
7243 daniel 631
 
1093 daniel 632
	$pdf->SetFont('Arial', '', 9);
7243 daniel 633
 
1093 daniel 634
	if ($this->view['kunde']['ustidnr'] != "")
635
	{
636
		$offset += 10;
637
		$pdf->Text($prod_left, $prod_top + $offset, __("Ihre Umsatzsteuer-Identifikationsnummer:", "wpsg"));
638
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
639
		$pdf->Cell(37, 8, $this->view['kunde']['ustidnr'], 0, 0, 'R');
640
	}
7243 daniel 641
 
8167 karl 642
	$offset += 10; // Abstand zwischen Tabelle und Auswertung
643
 
8240 karl 644
	if ( ($this->get_option('wpsg_kleinunternehmer') == '1') || ($this->view['oCalculationOrder']->getTaxMode() === \wpsg\wpsg_calculation::TAXMODE_SMALLBUSINESS) )
1093 daniel 645
	{
7243 daniel 646
 
1093 daniel 647
		$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
7490 daniel 648
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
1093 daniel 649
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8144 karl 650
		$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 651
		if ( !$bNoTax || ($arCalculation['sum']['topay_brutto'] != $arCalculation['sum']['brutto']) ) $offset += 5;
652
 
8144 karl 653
	} else {
7243 daniel 654
 
8144 karl 655
		if ($bNoTax)
1093 daniel 656
		{
7243 daniel 657
 
3024 daniel 658
			$pdf->Text($prod_left, $prod_top + $offset, __("Es ergibt sich folgender Gesamtbetrag", "wpsg").':');
8144 karl 659
			$pdf->Text($prod_left + 80, $prod_top + $offset, __("Summe", "wpsg"));
3024 daniel 660
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8144 karl 661
			$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 662
			//if ( !$bNoTax || ($arCalculation['sum']['topay_brutto'] != $arCalculation['sum']['brutto']) )
663
			$offset += 5;
8144 karl 664
 
8243 karl 665
			if ( !(($this->view['oOrder']->isInnerEu() || $deliverycountrytax) && ($this->view['oCalculationOrder']->getTaxMode() === \wpsg\wpsg_calculation::TAXMODE_B2B)) ) {
8144 karl 666
 
667
				if (sizeof($this->view['basket']['arCalculation']['tax']) >= 1)
668
				{
669
 
670
					$mw_count = 0;
671
					foreach ($this->view['basket']['arCalculation']['tax'] as $mw)
672
					{
673
 
8167 karl 674
						if ( $mw['tax_value'] > 0 && $mw['sum'] > 0 ) {
8144 karl 675
 
676
							$offset += 5;
677
							$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['tax_value'], '%'));
678
							$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
679
							$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
680
 
681
							$mw_count++;
682
 
683
						}
684
 
685
					}
686
 
687
				}
688
 
689
				if ($mw_count >= 2)
690
				{
691
 
692
					$offset += 5;
693
					$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
694
					$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
695
					$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');
696
 
697
				}
7243 daniel 698
 
8167 karl 699
			} else if ( !($arCalculation['sum']['topay_brutto'] != $arCalculation['sum']['brutto']) ) $offset -= 5;
700
 
8144 karl 701
		} else {
8167 karl 702
 
703
			$pdf->Text($prod_left, $prod_top + $offset, __("Der Gesamtbetrag setzt sich wie folgt zusammen", "wpsg").':');
7243 daniel 704
 
7490 daniel 705
			$pdf->Text($prod_left + 80, $prod_top + $offset, __("NETTOBETRAG", "wpsg"));
3024 daniel 706
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8144 karl 707
			$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 708
 
8144 karl 709
			if (sizeof($this->view['basket']['arCalculation']['tax']) >= 1)
1093 daniel 710
			{
8144 karl 711
 
712
				$mw_count = 0;
713
				foreach ($this->view['basket']['arCalculation']['tax'] as $mw)
3024 daniel 714
				{
8144 karl 715
 
8167 karl 716
					if ( $mw['tax_value'] > 0 && $mw['sum'] > 0) {
8144 karl 717
 
718
						$offset += 5;
719
						$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. ", "wpsg").wpsg_ff($mw['tax_value'], '%'));
720
						$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
721
						$pdf->Cell(37, 8, wpsg_ff($mw['sum'], $this->get_option('wpsg_currency')), 0, 0, 'R');
7243 daniel 722
 
8144 karl 723
						$mw_count++;
724
 
725
					}
726
 
3024 daniel 727
				}
7243 daniel 728
 
1093 daniel 729
			}
7243 daniel 730
 
8144 karl 731
			if ($mw_count >= 2)
3601 daniel 732
			{
7243 daniel 733
 
3601 daniel 734
				$offset += 5;
7490 daniel 735
				$pdf->Text($prod_left + 80, $prod_top + $offset, __("MwSt. GESAMT", "wpsg"));
3601 daniel 736
				$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8144 karl 737
				$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 738
 
3601 daniel 739
			}
7243 daniel 740
 
7094 florian 741
		}
7243 daniel 742
 
1628 david 743
	}
7243 daniel 744
 
1327 daniel 745
	// Rabatt
8144 karl 746
	if ($discount_value > 0)
1327 daniel 747
	{
8274 karl 748
 
1327 daniel 749
		$offset += 5;
7490 daniel 750
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("Rabatt", "wpsg"));
1327 daniel 751
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8144 karl 752
		$pdf->Cell(37, 8, '-'.wpsg_ff($discount_value, $this->get_option('wpsg_currency')), 0, 0, 'R');
7243 daniel 753
 
1327 daniel 754
	}
8144 karl 755
 
7490 daniel 756
	// Wertgutschein
8144 karl 757
	if ( $arCalculation['sum']['topay_brutto'] != $arCalculation['sum']['brutto'] ) {
8167 karl 758
 
759
		if (!$bNoTax) {
7490 daniel 760
 
8167 karl 761
			$offset += 5;
762
			$pdf->Text($prod_left + 80, $prod_top + $offset, __("SUMME", "wpsg"));
763
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
764
 
765
			$pdf->setFont('Arial', '', '9');
766
			$pdf->Cell(37, 8, wpsg_ff($this->view['basket']['arCalculation']['sum']['brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
767
			$pdf->setFont('Arial', '', '9');
7490 daniel 768
 
8167 karl 769
		} else if (!($mw_count >= 2)) $offset -= 5;
770
 
7490 daniel 771
		foreach ($arCalculation['coupon'] as $c) {
772
 
773
			$offset += 5;
774
			$pdf->Text($prod_left + 80, $prod_top + $offset, __('Wertgutschein', 'wpsg').' '.((wpsg_isSizedString($c['code']))?'('.$c['code'].')':''));
775
			$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
776
 
777
			$pdf->setFont('Arial', '', '9');
778
			$pdf->Cell(37, 8, wpsg_ff($c[$taxdisplay], $this->get_option('wpsg_currency')), 0, 0, 'R');
779
			$pdf->setFont('Arial', '', '9');
780
 
781
		}
782
 
783
		$offset += 5;
784
		$pdf->setFont('Arial', 'B', '9');
785
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("ZU ZAHLEN", "wpsg"));
786
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
787
 
788
		/* Endbetrag wird fett ausgegeben */
789
		$pdf->setFont('Arial', 'B', '9');
790
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
791
		$pdf->setFont('Arial', '', '9');
792
 
793
	} else {
7243 daniel 794
 
8167 karl 795
		$offset += 5;
8144 karl 796
		$pdf->setFont('Arial', 'B', '9');
797
		$pdf->Text($prod_left + 80, $prod_top + $offset, __("GESAMTSUMME", "wpsg"));
7490 daniel 798
		$pdf->setXY($prod_left + 140, $prod_top + $offset - 5);
8240 karl 799
 
7490 daniel 800
		/* Endbetrag wird fett ausgegeben */
8144 karl 801
		$pdf->Cell(37, 8, wpsg_ff($arCalculation['sum']['topay_brutto'], $this->get_option('wpsg_currency')), 0, 0, 'R');
7490 daniel 802
		$pdf->setFont('Arial', '', '9');
803
 
804
	}
7244 thomas 805
 
8144 karl 806
	if (($this->get_option('wpsg_kleinunternehmer') == '1') || ($this->view['oCalculationOrder']->getTaxMode() === \wpsg\wpsg_calculation::TAXMODE_SMALLBUSINESS) )
1093 daniel 807
	{
8167 karl 808
 
809
		$offset += 3;
810
		$pdf->setFont('Arial', '', '8');
811
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, '('.$this->get_option('wpsg_kleinunternehmer_text').')');
812
		$offset += 8;
7243 daniel 813
 
1093 daniel 814
	}
8167 karl 815
 
816
	$offset += 5;
7243 daniel 817
 
8167 karl 818
	if ($this->hasMod('wpsg_mod_deliverynote') && ($this->get_option('wpsg_rechnungen_deliverynote') == '1'))
5046 daniel 819
	{
7243 daniel 820
 
5046 daniel 821
		$arDN_order = $this->callMod('wpsg_mod_deliverynote', 'loadDeliveryNotesFromOrder', array($this->view['data']['id']));
822
		$delivery_date = $this->callMod('wpsg_mod_deliverynote', 'getDeliveryTime', array($this->view['data']['id']));
8167 karl 823
 
5046 daniel 824
		// Wenn es ein Gesamtlieferdatum gibt und nur einen Lieferschein, dann unter der Bestellung anzeigen
825
		if ($delivery_date !== false && sizeof($arDN_order) == 1)
826
		{
7243 daniel 827
 
8167 karl 828
			$pdf->setFont('Arial', 'B', '9');
829
			$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, __('Lieferung:', 'wpsg'));
830
			$pdf->setFont('Arial', '', '9');
831
			$pdf->wpsg_MultiCell($prod_left + 16, $prod_top + $offset, 5, wpsg_translate(__('#1#', 'wpsg'), date('d.m.Y', $delivery_date)));
832
			$offset += 8;
7243 daniel 833
 
5046 daniel 834
		}
7243 daniel 835
 
5046 daniel 836
	}
7243 daniel 837
 
1093 daniel 838
	if ($this->view['fussText'] != "")
839
	{
7243 daniel 840
 
8167 karl 841
		$pdf->setFont('Arial', '', '9');
5382 daniel 842
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $this->view['fussText']);
8167 karl 843
		$offset += 8;
7243 daniel 844
 
1093 daniel 845
	}
7243 daniel 846
 
8167 karl 847
	$offset += 10;
848
 
1093 daniel 849
	$shipping_adress = false;
7847 daniel 850
	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 851
 
1093 daniel 852
		$pdf->setFont('Arial', 'B', 9);
853
		$pdf->Text($prod_left, $prod_top + $offset, __("Lieferanschrift", "wpsg").":");
8167 karl 854
		$offset += 2;
7243 daniel 855
 
7094 florian 856
		$pdf->setFont('Arial', '', 9);
7243 daniel 857
 
8167 karl 858
			$shipping_adress = "";
859
			if ($this->view['data']['shipping_firma'] != "")
860
			{
861
				$shipping_adress .= $this->view['data']['shipping_firma']."\r\n";
862
			}
863
			$shipping_adress .= $this->view['data']['shipping_vname'].' '.$this->view['data']['shipping_name']."\r\n";
864
			$shipping_adress .= $this->view['data']['shipping_strasse'].' '.$this->view['data']['shipping_nr']."\r\n";
865
			// $shipping_adress .= $this->view['data']['shipping_land']['kuerzel'].'-';
866
 
867
			$shipping_adress .= $this->view['data']['shipping_plz'].' '.$this->view['data']['shipping_ort']."\r\n";
868
			$shipping_adress .= $this->view['data']['shipping_land']['name'];
7243 daniel 869
 
1093 daniel 870
		$start = $pdf->getY();
5382 daniel 871
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset, 5, $shipping_adress, 0, 'L', 0, 100);
1093 daniel 872
		$offset += $pdf->getY() - $start;
7243 daniel 873
 
1093 daniel 874
		$shipping_adress = true;
7243 daniel 875
 
1093 daniel 876
	}
7243 daniel 877
 
1093 daniel 878
	// Bestellvariablen
1671 daniel 879
	if ($this->hasMod('wpsg_mod_ordervars') && $this->get_option('wpsg_mod_rechnungen_showov') == '1')
1093 daniel 880
	{
8167 karl 881
 
882
		$pdf->SetFont('Arial', 'B', 9);
883
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset - 7, 5, __("Angaben während der Bestellung", "wpsg").":");
7243 daniel 884
 
8167 karl 885
		$pdf->SetFont('Arial', '', 9);
886
 
887
			$bvars = @unserialize($this->view['data']['bvars']);
888
			if (!is_array($bvars)) $bvars = array();
7243 daniel 889
 
8167 karl 890
			$strBVars = "";
891
			foreach ($bvars as $bvars_id => $bvars_value)
1093 daniel 892
			{
8167 karl 893
 
894
				$bvars = $this->db->fetchRow("SELECT * FROM `".wpsg_q(WPSG_TBL_ORDERVARS)."` WHERE `id` = '".wpsg_q($bvars_id)."' ORDER BY `pos` ASC, `id` ASC ");
895
 
896
				if ($bvars['typ'] == "1") // Auswahl
897
				{
898
					if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
899
				}
900
				else if ($bvars['typ'] == "2") // Texteingabe
901
				{
902
					if (trim($bvars_value) == "") $bvars_value = __("Keine Angabe", "wpsg");
903
				}
904
				else if ($bvars['typ'] == "3") // Checkbox
905
				{
906
					if ($bvars_value <= 0) $bvars_value = __("Keine Angabe", "wpsg");
907
				}
908
 
909
				$bvars_name = $this->callMod('wpsg_mod_ordervars', 'getNameById', array($bvars_id));
910
				$strBVars .= "\r\n".$bvars_name.": ".$bvars_value;
911
 
1093 daniel 912
			}
7243 daniel 913
 
8167 karl 914
		$pdf->wpsg_MultiCell($prod_left - 1, $prod_top + $offset - 6, 5, $strBVars);
915
 
7094 florian 916
	}
7243 daniel 917
 
4837 daniel 918
	$this->callMods('wpsg_mod_rechnungen_pdf', array(&$pdf, &$this->view['data']['id'], &$this->view['preview'], &$this->view['invoice']));
7243 daniel 919
 
1125 daniel 920
	$filename = $this->view['filename'].".pdf";
7243 daniel 921
 
7094 florian 922
	ob_end_clean();
7243 daniel 923
 
6901 daniel 924
	if ($this->view['preview']) {
7243 daniel 925
 
1093 daniel 926
		$pdf->Output($filename, 'I');
7243 daniel 927
 
6901 daniel 928
	} else {
7243 daniel 929
 
8214 daniel 930
		$pdf->Output($oInvoice->getFilePath(), 'F');
7243 daniel 931
 
4841 daniel 932
		// Hier wird der Dateiname an FPD übergeben. Er soll sich aus der Rechnungsnummer ergeben, auch wenn das Dokument über die ID gespeichert ist.
933
		if ($this->view['output'] === true) $pdf->Output($this->view['filename_out'], 'I');
7243 daniel 934
 
7094 florian 935
	}
936