From 90e8ff8580d49fbe5969e2fd71c86260fa1534f4 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83> Date: Mon, 9 Mar 2020 15:18:28 +0000 Subject: [PATCH] Sends email with attached PDF now --- ka.php | 7 ++++--- kaform.js | 22 ++++++++++++++++++++-- submit.php | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/ka.php b/ka.php index bfcb2e5..31f5e89 100644 --- a/ka.php +++ b/ka.php @@ -221,7 +221,7 @@ Grund für abweichende Kontoinhabende Person">
- @@ -291,15 +291,16 @@ Grund für abweichende Kontoinhabende Person">
- - + diff --git a/kaform.js b/kaform.js index e9e5ba3..0bf57c3 100644 --- a/kaform.js +++ b/kaform.js @@ -30,7 +30,7 @@ function disableCurrency() document.getElementById("a_currency").disabled=true; } else { - document.getElementById("a_currency").disabled=false; + document.getElementById("a_currency").disabled=true; } } @@ -301,7 +301,17 @@ function check_field(fieldid,message){ // // // -function downloadDocument() +// +function downloadDocument2(){ + downloadDocument(true); +} + +function downloadDocument1(){ + downloadDocument(false); +} + + +function downloadDocument(mail) { /* if (!check_field("nickname", "Bitte gib deinen Nicknamen an!")) return; @@ -351,6 +361,14 @@ function downloadDocument() return; }; + if (mail){ + document.getElementById('sendmail').value="yes"; + + } + else{ + document.getElementById('sendmail').value="no"; + + } document.getElementById('banktype').value=banktype; diff --git a/submit.php b/submit.php index 1b01d0f..f4fab8a 100644 --- a/submit.php +++ b/submit.php @@ -2,6 +2,9 @@ session_start(); require "config.php"; +require "PHPMailer/PHPMailer.php"; +require "PHPMailer/SMTP.php"; +require "PHPMailer/Exception.php"; #$CONVERT_CMD = "/usr/bin/pdftk"; @@ -405,8 +408,33 @@ $cmd .= " cat output $resultnam.pdf"; exec ($cmd); #var_dump($_POST); -#echo "CMD: $cmd
"; -#die; +$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; +} $file = "$resultnam.pdf"; header('Content-Disposition: attachment; filename="'. basename($file) . '"'); header('Content-Length: ' . filesize($file));