Files
Commerce/admin/factuur.php
“VeLiTi” 6f1cc27ec4 Initial commit
2025-01-30 11:43:37 +01:00

60 lines
1.6 KiB
PHP

<?php
(defined(security_key) or defined('admin') or defined('interface')) or exit;
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
$order_number = $_POST['txn_id'];
list($data,$customer_email,$order_id) = generateInvoice($pdo,$order_number);
$dompdf->loadHtml($data);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$file_name = 'Factuur - '.$order_id;
// Output the generated PDF to Browser
if (isset($_POST['email_invoice']) || $_POST['status'] == 'Paid'){
$to = $customer_email;
$subject = 'Factuur - '.$order_id;
$message = $data;
$attachment = $dompdf->output();
$attachment_name = $file_name;
$header_redirect = 'Location: index.php?page=order&id='.$order_id;
//Send to PHPMailer
send_mail_by_PHPMailer($to, $subject, $message, $attachment, $attachment_name);
header($header_redirect);
exit;
}
if (isset($_POST['email_invoice_to_admin']) || $_POST['status'] == 'Paid'){
$to = $customer_email;
$subject = 'Factuur - '.$order_id;
$message = $data;
$attachment = $dompdf->output();
$attachment_name = $file_name;
$header_redirect = 'Location: index.php?page=order&id='.$order_id;
//Send to PHPMailer
if(invoice_bookkeeping){
send_mail_by_PHPMailer(email_bookkeeping, $subject, $data, $attachment, $subject);
}
header($header_redirect);
exit;
}
if (isset($_POST['show_invoice'])){
ob_end_clean();
$dompdf->stream("Factuur.pdf", array("Attachment" => false));
exit;
}
?>