Subversion Repositories wpShopGermany4

Rev

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