| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | session_start(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-21 14:26:03 +00:00
										 |  |  | require "config.php"; | 
					
						
							| 
									
										
										
										
											2020-03-09 15:18:28 +00:00
										 |  |  | require "PHPMailer/PHPMailer.php"; | 
					
						
							|  |  |  | require "PHPMailer/SMTP.php"; | 
					
						
							|  |  |  | require "PHPMailer/Exception.php"; | 
					
						
							| 
									
										
										
										
											2020-02-21 14:26:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #$CONVERT_CMD = "/usr/bin/pdftk";
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | require_once('TCPDF/tcpdf.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class kaformPDF extends TCPDF { | 
					
						
							|  |  |  | 	 //Page header
 | 
					
						
							|  |  |  | 	public function Header() { | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//            // Logo
 | 
					
						
							|  |  |  | 	//                    $image_file = K_PATH_IMAGES.'logo_example.jpg';
 | 
					
						
							|  |  |  | 	//                            $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
 | 
					
						
							|  |  |  | 	//                                    // Set font
 | 
					
						
							|  |  |  | 	//                                            $this->SetFont('helvetica', 'B', 20);
 | 
					
						
							|  |  |  | 	//                                                    // Title
 | 
					
						
							|  |  |  | 	//                                                            $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
 | 
					
						
							|  |  |  | 	//                                                                }
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	//                                                                    // Page footer
 | 
					
						
							|  |  |  | 	public function Footer() { | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	//                                                                                // Position at 15 mm from bottom
 | 
					
						
							|  |  |  | 	//                                                                                        $this->SetY(-15);
 | 
					
						
							|  |  |  | 	//                                                                                                // Set font
 | 
					
						
							|  |  |  | 	//                                                                                                        $this->SetFont('helvetica', 'I', 8);
 | 
					
						
							|  |  |  | 	//                                                                                                                // Page number
 | 
					
						
							|  |  |  | 	//                                                                                                                        $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
 | 
					
						
							|  |  |  | 	//                                                                                                                            }
 | 
					
						
							|  |  |  | 	//                                                                                                                            }
 | 
					
						
							|  |  |  | 	//                                                                                                                            
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | function get_adv() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	$aval = $_POST['advance']; | 
					
						
							|  |  |  | 	if (!$aval) | 
					
						
							|  |  |  | 		$aval = "0"; | 
					
						
							|  |  |  | 	$advance = floatval(str_replace(",",".",$aval)); | 
					
						
							|  |  |  | 	if ($advance < 0 ) | 
					
						
							|  |  |  | 		$advance = -$advance;	 | 
					
						
							|  |  |  | 	return $advance; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | function mkFrontPDF(){ | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | 	$comments = str_replace("\n","<BR>",$_POST['comments']); | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	$bankaddress = str_replace("\n","<BR>",$_POST['n_bankaddress']); | 
					
						
							|  |  |  | 	$address = str_replace("\n","<BR>",$_POST['n_address']); | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | 	$account_owner = $_POST['owner']; | 
					
						
							|  |  |  | 	if (!$account_owner) $account_owner = $_POST['realname']; | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | #	$aval = $_POST['advance'];
 | 
					
						
							|  |  |  | #	$advance = floatval(str_replace(",",".",$aval));
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	$aw = $_POST; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ($_POST['banktype']){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case "bank-eu": | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 		$aw = "EU-Banküberweisung"; | 
					
						
							|  |  |  | 		$aw_details = "
 | 
					
						
							|  |  |  | 		Kontoinhaber: $account_owner<br> | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 		IBAN: $_POST[iban]<br> | 
					
						
							|  |  |  | 		BIC: $_POST[bic]<br> | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 		Anmerkungen:<br> $comments<br> | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 		";
 | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	case "bank-noneu": | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 		$aw = "Non-EU-Banküberweisung"; | 
					
						
							| 
									
										
										
										
											2020-02-21 16:52:26 +00:00
										 |  |  | 		$aw_details = "
 | 
					
						
							|  |  |  | 		Kontoinhaber: $account_owner<br> | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 		Kontonummer: $_POST[n_iban]<br> | 
					
						
							|  |  |  | 		BIC/SWIFT: $_POST[n_bic]<br> | 
					
						
							|  |  |  | 		Bank: $_POST[n_ankname]<br><br> | 
					
						
							| 
									
										
										
										
											2020-02-21 16:52:26 +00:00
										 |  |  | 		Bankanschrift:<br>$bankaddress<br><br> | 
					
						
							|  |  |  | 		Anschrift des Empfängers:<br>$address<br><br> | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 		Verwendungszweck:<br> $_POST[n_purpose]<br> | 
					
						
							| 
									
										
										
										
											2020-02-21 16:52:26 +00:00
										 |  |  | 		Anmerkungen:<br> $comments<br> | 
					
						
							|  |  |  | 		";			
 | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	case "bank-paypal": | 
					
						
							|  |  |  | 		$aw = "PayPal"; | 
					
						
							|  |  |  | 		$aw_details = "PayPal Account:"; | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 	$thtml = mkTable(); | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	// create new PDF document
 | 
					
						
							|  |  |  | 	$pdf = new kaformPDF( | 
					
						
							|  |  |  | 		PDF_PAGE_ORIENTATION, PDF_UNIT, $pageLayout /*PDF_PAGE_FORMAT*/,  | 
					
						
							|  |  |  | 		true, 'UTF-8', false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set document information
 | 
					
						
							|  |  |  | /*	$pdf->SetCreator(PDF_CREATOR); | 
					
						
							|  |  |  | 	$pdf->SetAuthor('Nicola Asuni'); | 
					
						
							|  |  |  | 	$pdf->SetTitle('TCPDF Example 001'); | 
					
						
							|  |  |  | 	$pdf->SetSubject('TCPDF Tutorial'); | 
					
						
							|  |  |  | 	$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 	// set default header data
 | 
					
						
							|  |  |  | //	$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 
 | 
					
						
							|  |  |  | 	//	PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, 
 | 
					
						
							|  |  |  | //		array(0,64,255), array(0,64,128));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //	$pdf->setFooterData(array(0,64,0), array(0,64,128));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set header and footer fonts
 | 
					
						
							|  |  |  | 	$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); | 
					
						
							|  |  |  | 	$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set default monospaced font
 | 
					
						
							|  |  |  | 	$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set margins
 | 
					
						
							|  |  |  | 	$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); | 
					
						
							|  |  |  | 	$pdf->SetHeaderMargin(PDF_MARGIN_HEADER); | 
					
						
							|  |  |  | 	$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set auto page breaks
 | 
					
						
							|  |  |  | 	$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set image scale factor
 | 
					
						
							|  |  |  | 	$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set some language-dependent strings (optional)
 | 
					
						
							|  |  |  | 	if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { | 
					
						
							|  |  |  | 		require_once(dirname(__FILE__).'/lang/eng.php'); | 
					
						
							|  |  |  | 		$pdf->setLanguageArray($l); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ---------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set default font subsetting mode
 | 
					
						
							|  |  |  | 	$pdf->setFontSubsetting(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Set font
 | 
					
						
							|  |  |  | 	// dejavusans is a UTF-8 Unicode font, if you only need to
 | 
					
						
							|  |  |  | 	// print standard ASCII chars, you can use core fonts like
 | 
					
						
							|  |  |  | 	// helvetica or times to reduce file size.
 | 
					
						
							|  |  |  | 	$pdf->SetFont('dejavusans', '', 14, '', true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Add a page
 | 
					
						
							|  |  |  | 	// This method has several options, check the source code 
 | 
					
						
							|  |  |  | 	// documentation for more information.
 | 
					
						
							|  |  |  | 	$pdf->AddPage('P'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// set text shadow effect
 | 
					
						
							|  |  |  | 	$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2,  | 
					
						
							|  |  |  | 		'depth_h'=>0.2, 'color'=>array(196,196,196),  | 
					
						
							|  |  |  | 		'opacity'=>1, 'blend_mode'=>'Normal')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// calculate the overall summary
 | 
					
						
							|  |  |  | 	$sum = calcSum(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Set some content to print
 | 
					
						
							|  |  |  | 	$html =  | 
					
						
							|  |  |  | <<<EOD | 
					
						
							|  |  |  | 	<h1>Kostenerstattungsantrag über $sum EUR</h1> | 
					
						
							|  |  |  | 	<p><b>Projekt: $_POST[project]</b></p> | 
					
						
							|  |  |  | 	<hr> | 
					
						
							|  |  |  | 	<p> | 
					
						
							|  |  |  | 	  | 
					
						
							|  |  |  | 	<br> | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | <!--	Nickname: $_POST[nickname]<br> --> | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	Name: $_POST[realname]<br> | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	Telefon: $_POST[phone]<br> | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	E-Mail: $_POST[email]<br> | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	Ansprechpartner: $_POST[wmdecontact]<br> | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	</p> | 
					
						
							|  |  |  | 	<hr> | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 	<br> | 
					
						
							|  |  |  | 	<p> | 
					
						
							|  |  |  | 	Auszahlungsweg: $aw<br> | 
					
						
							|  |  |  | 	$aw_details | 
					
						
							|  |  |  | 	</p> | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 	<hr> | 
					
						
							|  |  |  | 	$thtml | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2020-02-21 15:41:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | EOD; | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #var_dump($thtml);
 | 
					
						
							|  |  |  | #die;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | // <p>WMDE Ansprechpartner: $_POST[wmdecontact]</p>
 | 
					
						
							|  |  |  | // Telefon: $_POST[phone]
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Print text using writeHTMLCell()
 | 
					
						
							|  |  |  | 	$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// ---------------------------------------------------------
 | 
					
						
							|  |  |  | 	$tn = tempnam("/tmp","kaform"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Close and output PDF document
 | 
					
						
							|  |  |  | 	// This method has several options, check the source code 
 | 
					
						
							|  |  |  | 	// documentation for more information.
 | 
					
						
							|  |  |  | 	$pdf->Output($tn, 'F'); | 
					
						
							|  |  |  | 	return $tn; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function mkSnippedPdf($key){ | 
					
						
							|  |  |  | 	$pageLayout = array(210,70); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	// create new PDF document
 | 
					
						
							|  |  |  | #	$pdf = new kaformPDF(
 | 
					
						
							|  |  |  | #		PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, 
 | 
					
						
							|  |  |  | #		true, 'UTF-8', false);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$pdf = new kaformPDF( | 
					
						
							|  |  |  | 		PDF_PAGE_ORIENTATION, PDF_UNIT, $pageLayout /*PDF_PAGE_FORMAT*/,  | 
					
						
							|  |  |  | 		true, 'UTF-8', false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$pdf->AddPage('L'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	$pos = array_search($key,array_keys($_POST['description']))+1; | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | //	echo "<br>Make Snipped for $key -> $pos<br>";
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	#	$mydesk = $_POST[desc][$key];
 | 
					
						
							|  |  |  | 	#
 | 
					
						
							|  |  |  | 	$amount = $_POST['amount'][$key]; | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	$desc = $_POST['description'][$key]; | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 13:36:54 +00:00
										 |  |  | 	$am = floatval(str_replace(",",".",$amount)); | 
					
						
							|  |  |  | 	$am =  str_replace(".",",",sprintf("%.2f",$am)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	$html =  | 
					
						
							|  |  |  | <<<EOD | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | 	<h1>Position $pos</h1> | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	<p>$desc</p><br> | 
					
						
							| 
									
										
										
										
											2020-03-09 13:36:54 +00:00
										 |  |  | 	<p>$am EUR</p><br> | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | EOD; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	// Print text using writeHTMLCell()
 | 
					
						
							|  |  |  | 	$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$tn = tempnam("/tmp","kaform"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Close and output PDF document
 | 
					
						
							|  |  |  | 	// This method has several options, check the source code 
 | 
					
						
							|  |  |  | 	// documentation for more information.
 | 
					
						
							|  |  |  | 	$pdf->Output("$tn", 'F'); | 
					
						
							|  |  |  | 	return $tn; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //var_dump($_POST);
 | 
					
						
							|  |  |  | function convert($row) { | 
					
						
							|  |  |  | 	$r = array(); | 
					
						
							|  |  |  | 	foreach ($_SESSION['files'] as $filename => $file){ | 
					
						
							|  |  |  | 		if ($file['row'] != $row) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$tn = tempnam("/tmp","kaform"); | 
					
						
							|  |  |  | 		file_put_contents("$tn",$file['content']); | 
					
						
							|  |  |  | 		array_push($r,"$tn"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return $r; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function calcSum(){ | 
					
						
							|  |  |  | 	$sum =0; | 
					
						
							| 
									
										
										
										
											2020-02-21 14:26:03 +00:00
										 |  |  | 	if (!isset($_POST['amount'])) { | 
					
						
							|  |  |  | 		echo "wrong parameters"; | 
					
						
							|  |  |  | 		die; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	foreach ($_POST['amount'] as $val){ | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | //		var_dump($val);
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 		$sum += floatval(str_replace(",",".",$val)); | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 	$sum -= get_adv(); | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 	return str_replace(".",",",sprintf("%0.2f",$sum)); | 
					
						
							|  |  |  | //	return sprintf("%.2f",$sum);
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function mkTable(){ | 
					
						
							|  |  |  | 	$html = "<br> <br><table>"; | 
					
						
							|  |  |  | 	$pos = 1; | 
					
						
							|  |  |  | 	$sum =0; | 
					
						
							|  |  |  | 	if (!isset($_POST['amount'])) { | 
					
						
							|  |  |  | 		echo "wrong parameters"; | 
					
						
							|  |  |  | 		die; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	foreach ($_POST['amount'] as $key=>$val){ | 
					
						
							|  |  |  | 		$html .='<tr>'; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$html .= "<td>$pos</td>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$html .= "<td>".$_POST['date'][$key]."</td>"; | 
					
						
							|  |  |  | 		$html .= "<td>".$_POST['description'][$key]."</td>"; | 
					
						
							|  |  |  | 		$am = floatval(str_replace(",",".",$val)); | 
					
						
							|  |  |  | 		$am =  str_replace(".",",",sprintf("%.2f",$am)); | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 		$html .= '<td align="right">'.$am." ".$_POST['currency'][$key]. "</td>"; | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 		 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$html .="</tr>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$sum += floatval(str_replace(",",".",$val)); | 
					
						
							|  |  |  | 		$pos ++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | 	$adv = get_adv(); | 
					
						
							|  |  |  | 	if ($adv) { | 
					
						
							|  |  |  | 		$html .= "<tr>"; | 
					
						
							|  |  |  | 		$html .= '<td colspan="3">'; | 
					
						
							|  |  |  | 		$html .= "Bereits erhaltener Vorschuss:"; | 
					
						
							|  |  |  | 		$html .= '</td>'; | 
					
						
							|  |  |  | 		$html .= '<td align="right">'; | 
					
						
							|  |  |  | 		$html .= sprintf("-%0.2f",$adv)." EUR"; | 
					
						
							|  |  |  | 		$html .= '</td>'; | 
					
						
							|  |  |  | 		$html .= "</tr>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$html .= '<tr>'; | 
					
						
							|  |  |  | 	$html .= '<td colspan="3">'; | 
					
						
							|  |  |  | 	$html .= "<b>Summe:</b>"; | 
					
						
							|  |  |  | 	$html .= '</td>'; | 
					
						
							|  |  |  | 	$html .= '<td align="right">'; | 
					
						
							|  |  |  | 	$html .= "<b>".calcSum()." EUR</b>"; | 
					
						
							|  |  |  | 	$html .= '</td>'; | 
					
						
							|  |  |  | 	$html .= '</tr>'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 	$html .= "</table>"; | 
					
						
							| 
									
										
										
										
											2020-03-09 13:33:04 +00:00
										 |  |  | #	$html .="<br> <br>";
 | 
					
						
							|  |  |  | #	$html .="<b>Summe: ".calcSum()."</b>";
 | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | 	return $html; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //	return str_replace(".",",",sprintf("%0.2f",$sum));
 | 
					
						
							|  |  |  | //	return sprintf("%.2f",$sum);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $pdfs = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Applicatoin starts here
 | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | //
 | 
					
						
							|  |  |  | $p = mkFrontPDF(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $file = $p; | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | #header('Content-Disposition: attachment; filename="'. basename($file) . '"');
 | 
					
						
							|  |  |  | #header('Content-Length: ' . filesize($file));
 | 
					
						
							|  |  |  | #readfile($file);
 | 
					
						
							| 
									
										
										
										
											2020-02-25 10:59:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | #var_dump($p);
 | 
					
						
							|  |  |  | #die();
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | #echo "Making Fromt PDF<BR>";
 | 
					
						
							| 
									
										
										
										
											2020-02-21 16:52:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | #echo "Did Making Fromt PDF<BR>";
 | 
					
						
							| 
									
										
										
										
											2020-02-21 16:52:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | array_push($pdfs,$p); | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | //var_dump($pdfs);
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | foreach ($_POST['description'] as $key => $val) { | 
					
						
							|  |  |  | //	echo "DREESK KEY VAL $key --> $val<br>";
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 	$p = mkSnippedPDF($key); | 
					
						
							|  |  |  | 	array_push($pdfs,$p); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$pr = convert($key); | 
					
						
							|  |  |  | 	$pdfs = array_merge($pdfs,$pr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | //var_dump($pdfs);
 | 
					
						
							| 
									
										
										
										
											2020-03-06 10:02:02 +00:00
										 |  |  | //
 | 
					
						
							|  |  |  | $resultnam = tempnam("/tmp","karesult"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $cmd = "$CONVERT_CMD"; | 
					
						
							|  |  |  | foreach ($pdfs as $filename){ | 
					
						
							|  |  |  | 	$cmd .= " $filename"; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-03-06 10:02:02 +00:00
										 |  |  | $cmd .= " cat output $resultnam.pdf"; | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | exec ($cmd); | 
					
						
							| 
									
										
										
										
											2020-03-06 12:32:24 +00:00
										 |  |  | #var_dump($_POST);
 | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 15:18:28 +00:00
										 |  |  | $file = "$resultnam.pdf"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($_POST['sendmail']=='yes'){ | 
					
						
							|  |  |  | 	$subj = "Kostenerstattungsantrag ueber".calcSum()." EUR";	 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$mail = new PHPMailer\PHPMailer\PHPMailer(); | 
					
						
							|  |  |  | 		$mail->IsSMTP();	 | 
					
						
							|  |  |  | 		$mail->setFrom("noc@wikimedia.de"); | 
					
						
							|  |  |  | 		$mail->Subject = $subj; | 
					
						
							|  |  |  | 		$mail->Body = "Kostenerstattungsantragi ..."; | 
					
						
							|  |  |  | 		$mail->AddAddress("tube@surfpoeten.de"); | 
					
						
							|  |  |  | 		$mail->AddAttachment( $file , 'antrag.pdf' ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$mail->Host = $mailHost;                 // Specify main and backup server
 | 
					
						
							|  |  |  | 		$mail->Port = $mailPort;                                     // Set the SMTP port
 | 
					
						
							|  |  |  | 		$mail->SMTPAuth = $mailSMTPAuth; | 
					
						
							|  |  |  | 		$mail->Username = $mailUsername; | 
					
						
							|  |  |  | 		$mail->Password = $mailPassword; | 
					
						
							|  |  |  | 		$mail->SMTPSecure = $mailSMTPSecure;                            // Enable encryption, 'ssl' also accepted
 | 
					
						
							|  |  |  | 		$rc = 	$mail->send(); | 
					
						
							|  |  |  | 		if (!$rc) { | 
					
						
							|  |  |  | 			echo 'Mailer Error: ' . $mail->ErrorInfo; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		echo "Dein Antrag wurde versendet"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	die; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-03-06 10:02:02 +00:00
										 |  |  | $file = "$resultnam.pdf"; | 
					
						
							| 
									
										
										
										
											2020-02-28 15:04:43 +00:00
										 |  |  | header('Content-Disposition: attachment; filename="'. basename($file) . '"'); | 
					
						
							|  |  |  | header('Content-Length: ' . filesize($file)); | 
					
						
							|  |  |  | readfile($file); | 
					
						
							| 
									
										
										
										
											2020-02-20 13:45:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 |