Updated Email Quote and Invoice Templates, Invoice and Quote Guest view fully work, along with the ability for a guest to approve or reject a quote. PDF are no longer attached to emails they are provided as a link within an email and are recorded when viewed. Once viewed they can be printed or Downloaded as a PDF from the guest view pages. New option config_recurring_auto_email to automatically email the invoice on auto generated recurring Invoices

This commit is contained in:
root 2019-06-02 00:52:56 -04:00
parent d2bad1a4ba
commit 59882a3af5
12 changed files with 1037 additions and 318 deletions

BIN
D Normal file

Binary file not shown.

View File

@ -17,7 +17,7 @@
$config_default_payment_account = "";
$config_default_net_terms = 7;
$sql = mysqli_query($mysqli,"SELECT * FROM settings");
$sql = mysqli_query($mysqli,"SELECT * FROM settings WHERE company_id = 1");
$row = mysqli_fetch_array($sql);
$config_start_page = $row['config_start_page'];
@ -43,6 +43,10 @@
$config_mail_from_name = $row['config_mail_from_name'];
$config_account_balance_threshold = $row['config_account_balance_threshold'];
$config_quote_email_subject = $row['config_quote_email_subject'];
$config_recurring_email_auto_send = $row['config_recurring_email_auto_send'];
$config_api_key = $row['config_api_key'];
$_SESSION['alert_message'] = '';

View File

@ -1,4 +1,14 @@
<?php include("config.php"); ?>
<?php include("functions.php"); ?>
<?php
require("vendor/PHPMailer-6.0.7/src/PHPMailer.php");
require("vendor/PHPMailer-6.0.7/src/SMTP.php");
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
?>
<?php
@ -108,7 +118,10 @@ while($row = mysqli_fetch_array($sql_recurring)){
$row = mysqli_fetch_array($sql_invoice_number);
$new_invoice_number = $row['invoice_number'] + 1;
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = $new_invoice_number, invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', client_id = $client_id");
//Generate a unique URL key for clients to access
$url_key = keygen();
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = $new_invoice_number, invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', client_id = $client_id");
$new_invoice_id = mysqli_insert_id($mysqli);
@ -128,10 +141,73 @@ while($row = mysqli_fetch_array($sql_recurring)){
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = '$item_price', item_subtotal = '$item_subtotal', item_tax = '$item_tax', item_total = '$item_total', invoice_id = $new_invoice_id");
}
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'INVOICE Generated from Recurring!', invoice_id = $new_invoice_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Invoice Generated from Recurring!', invoice_id = $new_invoice_id");
//update the recurring invoice with the new dates
mysqli_query($mysqli,"UPDATE recurring SET recurring_last_sent = CURDATE(), recurring_next_date = DATE_ADD(CURDATE(), INTERVAL 1 $recurring_frequency) , invoice_id = $new_invoice_id WHERE recurring_id = $recurring_id");
if($config_recurring_email_auto_send == 1){
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
WHERE invoices.client_id = clients.client_id
AND invoices.invoice_id = $new_invoice_id"
);
$row = mysqli_fetch_array($sql);
$invoice_number = $row['invoice_number'];
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_url_key = $row['invoice_url_key'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$mail = new PHPMailer(true);
try{
//Mail Server Settings
//$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $config_smtp_username; // SMTP username
$mail->Password = $config_smtp_password; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = $config_smtp_port; // TCP port to connect to
//Recipients
$mail->setFrom($config_mail_from_email, $config_mail_from_name);
$mail->addAddress("$client_email", "$client_name"); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Invoice $invoice_number";
$mail->Body = "Hello $client_name,<br><br>Please view the details of the invoice below.<br><br>Invoice: $invoice_number<br>Issue Date: $invoice_date<br>Total: $$invoice_amount<br>Due Date: $invoice_due<br><br><br>To view your invoice online click <a href='https://$base_url/guest_view_invoice.php?invoice_id=$new_invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$config_company_name<br>$config_company_phone";
$mail->send();
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Auto Emailed Invoice!', invoice_id = $new_invoice_id");
//Update Invoice Status to Sent
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Sent', client_id = $client_id WHERE invoice_id = $new_invoice_id");
}catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Failed to send Invoice!', invoice_id = $new_invoice_id");
}
}
}
?>

View File

@ -204,11 +204,243 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output();
$mpdf->Output("$invoice_date-$config_company_name-Invoice$invoice_number.pdf",'D');
}else{
echo "GTFO!!!";
}
}
?>
if(isset($_GET['pdf_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['pdf_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients
WHERE quotes.client_id = clients.client_id
AND quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
$row = mysqli_fetch_array($sql);
$quote_id = $row['quote_id'];
$quote_number = $row['quote_number'];
$quote_status = $row['quote_status'];
$quote_date = $row['quote_date'];
$quote_amount = $row['quote_amount'];
$quote_note = $row['quote_note'];
$quote_url_key = $row['quote_url_key'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
if(mysqli_num_rows($sql) == 1){
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
$items .= "
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
";
}
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="15%"><img width="75" height="75" src=" '.$config_invoice_logo.' "></img></td>
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
<td width="35%" style="text-align: right;">Quote No.<br /><span style="font-weight: bold; font-size: 12pt;"> QUO-'.$quote_number.' </span></td>
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: '.$quote_date.'</div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">TO:</span><br /><br /><b> '.$client_name.' </b><br />'.$client_address.'<br />'.$client_city.' '.$client_state.' '.$client_zip.' <br /><br> '.$client_email.' <br /> '.$client_phone.'</td>
<td width="65%">&nbsp;</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
'.$items.'
<tr>
<td class="blanktotal" colspan="4" rowspan="3"><h4>Notes</h4> '.$quote_note.' </td>
<td class="totals">Subtotal:</td>
<td class="totals cost">$ '.number_format($sub_total,2).' </td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($quote_amount,2).' </td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;"> '.$config_quote_footer.' </div>
</body>
</html>
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("$config_company_name - Quote");
$mpdf->SetAuthor("$config_company_name");
$mpdf->SetWatermarkText("Quote");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output("$quote_date-$config_company_name-Quote$quote_number.pdf",'D');
}else{
echo "GTFO!!!";
}
}
if(isset($_GET['approve_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['approve_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
WHERE quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
if(mysqli_num_rows($sql) == 1){
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', quote_id = $quote_id");
$_SESSION['alert_message'] = "Quote approved";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}else{
echo "GTFO!!";
}
}
if(isset($_GET['reject_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['reject_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
WHERE quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
if(mysqli_num_rows($sql) == 1){
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', quote_id = $quote_id");
$_SESSION['alert_message'] = "Quote rejected";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}else{
echo "GTFO!!";
}
}
?>

446
guest_post_old.php Normal file
View File

@ -0,0 +1,446 @@
<?php
include("config.php");
include("functions.php");
$mpdf_path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $mpdf_path . '/vendor/autoload.php';
if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
$invoice_id = intval($_GET['pdf_invoice']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
WHERE invoices.client_id = clients.client_id
AND invoices.invoice_id = $invoice_id
AND invoices.invoice_url_key = '$url_key'"
);
$row = mysqli_fetch_array($sql);
$invoice_id = $row['invoice_id'];
$invoice_number = $row['invoice_number'];
$invoice_status = $row['invoice_status'];
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_note = $row['invoice_note'];
$invoice_category_id = $row['category_id'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
if(mysqli_num_rows($sql) == 1){
//Mark downloaded in history
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice downloaded', invoice_id = $invoice_id");
$sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC");
//Add up all the payments for the invoice and get the total amount paid to the invoice
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql_amount_paid);
$amount_paid = $row['amount_paid'];
$balance = $invoice_amount - $amount_paid;
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
$invoice_items .= "
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
";
}
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="15%"><img width="75" height="75" src=" '.$config_invoice_logo.' "></img></td>
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
<td width="35%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;"> INV-'.$invoice_number.' </span></td>
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: '.$invoice_date.'</div>
<div style="text-align: right">Due: '.$invoice_due.'</div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">BILL TO:</span><br /><br /><b> '.$client_name.' </b><br />'.$client_address.'<br />'.$client_city.' '.$client_state.' '.$client_zip.' <br /><br> '.$client_email.' <br /> '.$client_phone.'</td>
<td width="65%">&nbsp;</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
'.$invoice_items.'
<tr>
<td class="blanktotal" colspan="4" rowspan="5"><h4>Notes</h4> '.$invoice_note.' </td>
<td class="totals">Subtotal:</td>
<td class="totals cost">$ '.number_format($sub_total,2).' </td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($invoice_amount,2).' </td>
</tr>
<tr>
<td class="totals">Paid:</td>
<td class="totals cost">$ '.number_format($amount_paid,2).' </td>
</tr>
<tr>
<td class="totals"><b>Balance:</b></td>
<td class="totals cost"><b>$ '.number_format($balance,2).' </b></td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;"> '.$config_invoice_footer.' </div>
</body>
</html>
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("$config_company_name - Invoice");
$mpdf->SetAuthor("$config_company_name");
if($invoice_status == 'Paid'){
$mpdf->SetWatermarkText("Paid");
}
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output("$invoice_date-$config_company_name-Invoice$invoice_number.pdf",'D');
}else{
echo "GTFO!!!";
}
}
if(isset($_GET['pdf_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['pdf_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients
WHERE quotes.client_id = clients.client_id
AND quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
$row = mysqli_fetch_array($sql);
$quote_id = $row['quote_id'];
$quote_number = $row['quote_number'];
$quote_status = $row['quote_status'];
$quote_date = $row['quote_date'];
$quote_amount = $row['quote_amount'];
$quote_note = $row['quote_note'];
$quote_url_key = $row['quote_url_key'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
if(mysqli_num_rows($sql) == 1){
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
$items .= "
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
";
}
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="15%"><img width="75" height="75" src=" '.$config_invoice_logo.' "></img></td>
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
<td width="35%" style="text-align: right;">Quote No.<br /><span style="font-weight: bold; font-size: 12pt;"> QUO-'.$quote_number.' </span></td>
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: '.$quote_date.'</div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">TO:</span><br /><br /><b> '.$client_name.' </b><br />'.$client_address.'<br />'.$client_city.' '.$client_state.' '.$client_zip.' <br /><br> '.$client_email.' <br /> '.$client_phone.'</td>
<td width="65%">&nbsp;</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
'.$items.'
<tr>
<td class="blanktotal" colspan="4" rowspan="3"><h4>Notes</h4> '.$quote_note.' </td>
<td class="totals">Subtotal:</td>
<td class="totals cost">$ '.number_format($sub_total,2).' </td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($quote_amount,2).' </td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;"> '.$config_quote_footer.' </div>
</body>
</html>
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("$config_company_name - Quote");
$mpdf->SetAuthor("$config_company_name");
$mpdf->SetWatermarkText("Quote");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output("$quote_date-$config_company_name-Quote$quote_number.pdf",'D');
}else{
echo "GTFO!!!";
}
}
if(isset($_GET['approve_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['approve_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
WHERE quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
if(mysqli_num_rows($sql) == 1){
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', quote_id = $quote_id");
$_SESSION['alert_message'] = "Quote approved";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}else{
echo "GTFO!!";
}
}
if(isset($_GET['reject_quote'], $_GET['url_key'])){
$quote_id = intval($_GET['reject_quote']);
$url_key = $_GET['url_key'];
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
WHERE quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
if(mysqli_num_rows($sql) == 1){
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id");
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', quote_id = $quote_id");
$_SESSION['alert_message'] = "Quote rejected";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}else{
echo "GTFO!!";
}
}
?>

View File

@ -84,12 +84,12 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
</div>
<div class="col-md-6">
<div class="float-right">
<a class="btn btn-primary" href="#" onclick="window.print();">Print</a>
<a class="btn btn-primary" href="guest_post.php?pdf_invoice=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>">PDF</a>
<a class="btn btn-primary" href="#" onclick="window.print();"><i class="fa fa-fw fa-print"></i> Print</a>
<a class="btn btn-primary" download target="_blank" href="guest_post.php?pdf_invoice=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
<?php
if($invoice_status != "Paid" or $invoice_status != "Cancelled" or $invoice_status != "Draft"){
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft"){
?>
<a class="btn btn-primary" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">Pay</a>
<a class="btn btn-success" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card"></i> Pay Online</a>
<?php } ?>
</div>
</div>

235
guest_view_quote.php Normal file
View File

@ -0,0 +1,235 @@
<?php include("guest_header.php"); ?>
<?php
if(isset($_GET['quote_id'], $_GET['url_key'])){
$url_key = $_GET['url_key'];
$quote_id = intval($_GET['quote_id']);
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients
WHERE quotes.client_id = clients.client_id
AND quotes.quote_id = $quote_id
AND quotes.quote_url_key = '$url_key'"
);
$row = mysqli_fetch_array($sql);
$quote_id = $row['quote_id'];
$quote_number = $row['quote_number'];
$quote_status = $row['quote_status'];
$quote_date = $row['quote_date'];
$quote_amount = $row['quote_amount'];
$quote_note = $row['quote_note'];
$category_id = $row['category_id'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
$client_net_terms = $row['client_net_terms'];
if($client_net_terms == 0){
$client_net_terms = $config_default_net_terms;
}
if(mysqli_num_rows($sql) == 1){
//Mark viewed in history
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', quote_id = $quote_id");
//Set Badge color based off of quote status
if($quote_status == "Sent"){
$quote_badge_color = "warning text-white";
}elseif($quote_status == "Viewed"){
$quote_badge_color = "primary";
}elseif($quote_status == "Approved"){
$quote_badge_color = "success";
}elseif($quote_status == "Cancelled"){
$quote_badge_color = "danger";
}else{
$quote_badge_color = "secondary";
}
?>
<div class="row d-print-none">
<div class="col-md-6">
<h2>Quote <?php echo $quote_number; ?><span class="p-2 ml-2 badge badge-<?php echo $quote_badge_color; ?>"><?php echo $quote_status; ?></span></h2>
</div>
<div class="col-md-6">
<div class="float-right">
<a class="btn btn-primary" href="#" onclick="window.print();"><i class="fa fa-fw fa-print"></i> Print</a>
<a class="btn btn-primary" download target="_blank" href="guest_post.php?pdf_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
<?php
if($quote_status == "Draft" or $quote_status == "Sent"){
?>
<a class="btn btn-success" href="guest_post.php?approve_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-thumbs-up"></i> Approve</a>
<a class="btn btn-danger" href="guest_post.php?reject_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-thumbs-down"></i> Reject</a>
<?php } ?>
</div>
</div>
</div>
<hr>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Quote To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right">QUO-<?php echo $quote_number; ?></div></li>
<li class="mb-1"><strong>Quote Date:</strong> <div class="float-right"><?php echo $quote_date; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
<th>Product</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $invoice_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right">$<?php echo number_format($item_price,2); ?></td>
<td class="text-right">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right">$<?php echo number_format($item_total,2); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div><?php echo $quote_note; ?></div>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right">$<?php echo number_format($quote_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Total</strong></td>
<td class="text-right"><strong>$<?php echo number_format($quote_amount,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
}else{
echo "GTFO";
}
}else{
echo "GTFO";
} ?>
<?php include("guest_footer.php");

BIN
moogoo.pdf Normal file

Binary file not shown.

327
post.php
View File

@ -354,6 +354,17 @@ if(isset($_POST['edit_ticket'])){
}
if(isset($_GET['delete_ticket'])){
$ticket_id = intval($_GET['delete_ticket']);
mysqli_query($mysqli,"DELETE FROM tickets WHERE ticket_id = $ticket_id");
$_SESSION['alert_message'] = "Ticket deleted";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if(isset($_POST['add_vendor'])){
$client_id = intval($_POST['client_id']);
@ -1319,148 +1330,7 @@ if(isset($_GET['email_quote'])){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
$items .= "
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
";
}
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="15%"><img width="75" height="75" src=" '.$config_invoice_logo.' "></img></td>
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
<td width="35%" style="text-align: right;">Quote No.<br /><span style="font-weight: bold; font-size: 12pt;"> QUO-'.$quote_number.' </span></td>
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: '.$quote_date.'</div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">TO:</span><br /><br /><b> '.$client_name.' </b><br />'.$client_address.'<br />'.$client_city.' '.$client_state.' '.$client_zip.' <br /><br> '.$client_email.' <br /> '.$client_phone.'</td>
<td width="65%">&nbsp;</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
'.$items.'
<tr>
<td class="blanktotal" colspan="4" rowspan="3"><h4>Notes</h4> '.$quote_note.' </td>
<td class="totals">Subtotal:</td>
<td class="totals cost">$ '.number_format($sub_total,2).' </td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($quote_amount,2).' </td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;"> '.$config_quote_footer.' </div>
</body>
</html>
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("$config_company_name - Quote");
$mpdf->SetAuthor("$config_company_name");
$mpdf->SetWatermarkText("Quote");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output("uploads/$quote_date-$config_company_name-Quote$quote_number.pdf", 'F');
$base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$mail = new PHPMailer(true);
@ -1484,13 +1354,13 @@ if(isset($_GET['email_quote'])){
// Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->addAttachment("uploads/$quote_date-$config_company_name-Quote$quote_number.pdf"); // Optional name
//$mail->addAttachment("uploads/$quote_date-$config_company_name-Quote$quote_number.pdf"); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "Quote $quote_number - $quote_date";
$mail->Body = "Hello $client_name,<br><br>Attached to this email is the Quote you requested. You can approve or disapprove this quote by clicking here.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>$config_company_phone";
$mail->Subject = "Quote";
$mail->Body = "Hello $client_name,<br><br>Thank you for your inquiry, we are pleased to provide you with the following estimate.<br><br><br>Total Cost: $$quote_amount<br><br><br>View and accept your estimate online <a href='https://$base_url/guest_view_quote.php?quote_id=$quote_id&url_key=$quote_url_key'>here</a><br><br><br>~<br>$config_company_name<br>$config_company_phone";
$mail->send();
echo 'Message has been sent';
@ -1512,7 +1382,6 @@ if(isset($_GET['email_quote'])){
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
unlink("uploads/$quote_date-$config_company_name-Quote$quote_number.pdf");
}
if(isset($_POST['add_recurring'])){
@ -1971,6 +1840,7 @@ if(isset($_GET['email_invoice'])){
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_url_key = $row['invoice_url_key'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
@ -1983,6 +1853,7 @@ if(isset($_GET['email_invoice'])){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_website = $row['client_website'];
$base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
$sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC");
@ -1993,159 +1864,6 @@ if(isset($_GET['email_invoice'])){
$balance = $invoice_amount - $amount_paid;
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id ORDER BY item_id ASC");
while($row = mysqli_fetch_array($sql_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
$invoice_items .= "
<tr>
<td align='center'>$item_name</td>
<td>$item_description</td>
<td align='center'>$item_quantity</td>
<td class='cost'>$$item_price</td>
<td class='cost'>$$item_tax</td>
<td class='cost'>$$item_total</td>
</tr>
";
}
$html = '
<html>
<head>
<style>
body {font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
table.items {
border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
border-left: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
text-align: center;
border: 0.1mm solid #000000;
font-variant: small-caps;
}
.items td.blanktotal {
background-color: #EEEEEE;
border: 0.1mm solid #000000;
background-color: #FFFFFF;
border: 0mm none #000000;
border-top: 0.1mm solid #000000;
border-right: 0.1mm solid #000000;
}
.items td.totals {
text-align: right;
border: 0.1mm solid #000000;
}
.items td.cost {
text-align: "." center;
}
</style>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="15%"><img width="75" height="75" src=" '.$config_invoice_logo.' "></img></td>
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
<td width="35%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;"> INV-'.$invoice_number.' </span></td>
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<div style="text-align: right">Date: '.$invoice_date.'</div>
<div style="text-align: right">Due: '.$invoice_due.' </div>
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">BILL TO:</span><br /><br /><b> '.$client_name.' </b><br />'.$client_address.'<br />'.$client_city.' '.$client_state.' '.$client_zip.' <br /><br> '.$client_email.' <br /> '.$client_phone.'</td>
<td width="65%">&nbsp;</td>
</tr></table>
<br />
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="28%">Product</td>
<td width="28%">Description</td>
<td width="10%">Qty</td>
<td width="10%">Price</td>
<td width="12%">Tax</td>
<td width="12%">Total</td>
</tr>
</thead>
<tbody>
'.$invoice_items.'
<tr>
<td class="blanktotal" colspan="4" rowspan="5"><h4>Notes</h4> '.$invoice_note.' </td>
<td class="totals">Subtotal:</td>
<td class="totals cost">$ '.number_format($sub_total,2).' </td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">$ '.number_format($total_tax,2).' </td>
</tr>
<tr>
<td class="totals">Total:</td>
<td class="totals cost">$ '.number_format($invoice_amount,2).' </td>
</tr>
<tr>
<td class="totals">Paid:</td>
<td class="totals cost">$ '.number_format($amount_paid,2).' </td>
</tr>
<tr>
<td class="totals"><b>Balance:</b></td>
<td class="totals cost"><b>$ '.number_format($balance,2).' </b></td>
</tr>
</tbody>
</table>
<div style="text-align: center; font-style: italic;"> '.$config_invoice_footer.' </div>
</body>
</html>
';
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 5,
'margin_right' => 5,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("$config_company_name - Invoice");
$mpdf->SetAuthor("$config_company_name");
if($invoice_status == 'Paid'){
$mpdf->SetWatermarkText("Paid");
}
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output("uploads/$invoice_date-$config_company_name-Invoice$invoice_number.pdf", 'F');
$mail = new PHPMailer(true);
try{
@ -2168,20 +1886,20 @@ if(isset($_GET['email_invoice'])){
// Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->addAttachment("uploads/$invoice_date-$config_company_name-Invoice$invoice_number.pdf"); // Optional name
//$mail->addAttachment("uploads/$invoice_date-$config_company_name-Invoice$invoice_number.pdf"); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
if($invoice_status == 'Paid'){
$mail->Subject = "Copy of Invoice $invoice_number";
$mail->Body = "Hello $client_name,<br><br>Attached to this email is a copy of your invoice marked <b>paid</b>.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
$mail->Subject = "Invoice $invoice_number Copy";
$mail->Body = "Hello $client_name,<br><br>Please click on the link below to see your invoice marked <b>paid</b>.<br><br><a href='https://$base_url/guest_view_invoice.php?invoice_id=$invoice_id&url_key=$invoice_url_key'>Invoice Link</a><br><br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
}else{
$mail->Subject = "Invoice $invoice_number - $invoice_date - Due on $invoice_due";
$mail->Body = "Hello $client_name,<br><br>Attached to this email is your invoice. Please make all checks payable to $config_company_name and mail to <br><br>$config_company_address<br>$config_company_city $config_company_state $config_company_zip<br><br>before <b>$invoice_due</b>.<br><br>If you have any questions please contact us at the number below.<br><br>~<br>$config_company_name<br>Automated Billing Department<br>$config_company_phone";
$mail->Subject = "Invoice $invoice_number";
$mail->Body = "Hello $client_name,<br><br>Please view the details of the invoice below.<br><br>Invoice: $invoice_number<br>Issue Date: $invoice_date<br>Total: $$invoice_amount<br>Balance Due: $$balance<br>Due Date: $invoice_due<br><br><br>To view your invoice online click <a href='https://$base_url/guest_view_invoice.php?invoice_id=$invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$config_company_name<br>$config_company_phone";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
}
@ -2205,7 +1923,6 @@ if(isset($_GET['email_invoice'])){
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
unlink("uploads/$invoice_date-$config_company_name-Invoice$invoice_number.pdf");
}
if(isset($_GET['pdf_invoice'])){

View File

@ -195,8 +195,8 @@ if(isset($_GET['quote_id'])){
<td></td>
<td><input type="text" class="form-control" name="name"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" style="text-align: center;" name="qty"></td>
<td><input type="text" class="form-control" style="text-align: right;" name="price"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>

View File

@ -9,11 +9,20 @@
</ol>
<!-- Page Content -->
<h1>PHP SELF: <?php echo basename($_SERVER['PHP_SELF']); ?></h1>
<h1>PHP SELF basename: <?php echo basename($_SERVER['PHP_SELF']); ?></h1>
<h1>PHP SELF: <?php echo $_SERVER['PHP_SELF']; ?></h1>
<hr>
<h3>PHP URI: <?php echo $_SERVER['REQUEST_URI']; ?></h1>
<h3>PHP URI: <?php echo $_SERVER['REQUEST_URI']; ?></h3>
<h3>PHP Server_name: <?php echo $_SERVER['SERVER_NAME']; ?></h3>
<h3>PHP HTTP_HOST: <?php echo $_SERVER['HTTP_HOST']; ?></h3>
<h3><?php echo $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']); ?></h3>
<h1>basename _FILE_ : <?php echo basename(__FILE__); ?></h1>
<h1>User Agent: <?php echo $_SERVER['HTTP_USER_AGENT']; ?>
<p>This is a great starting point for new custom pages.</p>
<h3><?php echo $config_quote_email_subject; ?></h3>
<?php include("footer.php"); ?>

View File

@ -69,7 +69,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>">Details</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTicketModal<?php echo $ticket_id; ?>">Edit</a>
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
<a class="dropdown-item" href="post.php?delete_ticket=<?php echo $ticket_id; ?>">Delete</a>
</div>
</div>
</td>