Sends email with attached PDF now
This commit is contained in:
parent
24aefba7e3
commit
90e8ff8580
7
ka.php
7
ka.php
|
@ -221,7 +221,7 @@ Grund für abweichende Kontoinhabende Person"></textarea>
|
|||
<input id="a_amount" type="text" name="amount" placeholder="Betrag*"/>
|
||||
</div>
|
||||
<div class="is-col">
|
||||
<select id="a_currency" name="currency" >
|
||||
<select disabled id="a_currency" name="currency" >
|
||||
<option value="EUR">EUR</option>
|
||||
<option value="USD">USD</option>
|
||||
<option value="CHF">CHF</option>
|
||||
|
@ -291,15 +291,16 @@ Grund für abweichende Kontoinhabende Person"></textarea>
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<button onclick="addTableRow();"
|
||||
<button onclick="downloadDocument(true);"
|
||||
class="button is-green">Antrag elektronisch versenden</button>
|
||||
|
||||
<button type="button" onclick="downloadDocument();"
|
||||
<button type="button" onclick="downloadDocument(false);"
|
||||
class="button is-orange">Herunterladen</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="banktype" name="banktype"/>
|
||||
<input type="hidden" id="sendmail" name="sendmail"/>
|
||||
|
||||
<!-- <input type="submit" style="display:none" name="submitButton" /> -->
|
||||
</form>
|
||||
|
|
22
kaform.js
22
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;
|
||||
|
|
32
submit.php
32
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<br>";
|
||||
#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));
|
||||
|
|
Loading…
Reference in New Issue