diff --git a/D b/D new file mode 100644 index 00000000..3e0aab11 Binary files /dev/null and b/D differ diff --git a/config.php b/config.php index 48cd7a97..af151b40 100644 --- a/config.php +++ b/config.php @@ -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'] = ''; diff --git a/cron.php b/cron.php index 2cff8545..b50b73a0 100644 --- a/cron.php +++ b/cron.php @@ -1,4 +1,14 @@ + + 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,

Please view the details of the invoice below.

Invoice: $invoice_number
Issue Date: $invoice_date
Total: $$invoice_amount
Due Date: $invoice_due


To view your invoice online click here


~
$config_company_name
$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"); + } + } } ?> \ No newline at end of file diff --git a/guest_post.php b/guest_post.php index 7cae3eed..e1ae486e 100644 --- a/guest_post.php +++ b/guest_post.php @@ -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!!!"; } } -?> \ No newline at end of file +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 .= " + + $item_name + $item_description + $item_quantity + $$item_price + $$item_tax + $$item_total + + "; + + } + + $html = ' + + + + + + +
Date: '.$quote_date.'
+ + + + +
TO:

'.$client_name.'
'.$client_address.'
'.$client_city.' '.$client_state.' '.$client_zip.'

'.$client_email.'
'.$client_phone.'
 
+
+ + + + + + + + + + + + + '.$items.' + + + + + + + + + + + + + + +
ProductDescriptionQtyPriceTaxTotal

Notes

'.$quote_note.'
Subtotal:$ '.number_format($sub_total,2).'
Tax:$ '.number_format($total_tax,2).'
Total:$ '.number_format($quote_amount,2).'
+
'.$config_quote_footer.'
+ + + '; + + $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!!"; + } + +} + +?> \ No newline at end of file diff --git a/guest_post_old.php b/guest_post_old.php new file mode 100644 index 00000000..8a5dfbdc --- /dev/null +++ b/guest_post_old.php @@ -0,0 +1,446 @@ +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 .= " + + $item_name + $item_description + $item_quantity + $$item_price + $$item_tax + $$item_total + + "; + + } + + $html = ' + + + + + + +
Date: '.$invoice_date.'
+
Due: '.$invoice_due.'
+ + + + +
BILL TO:

'.$client_name.'
'.$client_address.'
'.$client_city.' '.$client_state.' '.$client_zip.'

'.$client_email.'
'.$client_phone.'
 
+
+ + + + + + + + + + + + + '.$invoice_items.' + + + + + + + + + + + + + + + + + + + + + + +
ProductDescriptionQtyPriceTaxTotal

Notes

'.$invoice_note.'
Subtotal:$ '.number_format($sub_total,2).'
Tax:$ '.number_format($total_tax,2).'
Total:$ '.number_format($invoice_amount,2).'
Paid:$ '.number_format($amount_paid,2).'
Balance:$ '.number_format($balance,2).'
+
'.$config_invoice_footer.'
+ + + '; + + $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 .= " + + $item_name + $item_description + $item_quantity + $$item_price + $$item_tax + $$item_total + + "; + + } + + $html = ' + + + + + + +
Date: '.$quote_date.'
+ + + + +
TO:

'.$client_name.'
'.$client_address.'
'.$client_city.' '.$client_state.' '.$client_zip.'

'.$client_email.'
'.$client_phone.'
 
+
+ + + + + + + + + + + + + '.$items.' + + + + + + + + + + + + + + +
ProductDescriptionQtyPriceTaxTotal

Notes

'.$quote_note.'
Subtotal:$ '.number_format($sub_total,2).'
Tax:$ '.number_format($total_tax,2).'
Total:$ '.number_format($quote_amount,2).'
+
'.$config_quote_footer.'
+ + + '; + + $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!!"; + } + +} + +?> \ No newline at end of file diff --git a/guest_view_invoice.php b/guest_view_invoice.php index dcfdd64d..0e5da773 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -84,12 +84,12 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
- Print - PDF + Print + Download - Pay + Pay Online
diff --git a/guest_view_quote.php b/guest_view_quote.php new file mode 100644 index 00000000..5f0fc90e --- /dev/null +++ b/guest_view_quote.php @@ -0,0 +1,235 @@ + + +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"; + } + + ?> + +
+
+

Quote

+
+
+ +
+
+ +
+ +
+
+
+
+ From +
+
+
    +
  • +
  • +
  • +
  • +
  • +
+
+
+
+
+
+
+ Quote To +
+
+
    +
  • +
  • +
  • +
  • +
  • +
+
+
+
+
+
+
+ Details +
+
+
    +
  • Quote Number:
    QUO-
  • +
  • Quote Date:
  • +
+
+
+
+
+ + + +
+
+
+
+ Items +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProductDescriptionQtyPriceTaxTotal
$$$
+
+
+
+ +
+
+
+
+ Notes +
+
+
+
+
+
+ +
+ + + + + + + 0){ ?> + + + + + + 0){ ?> + + + + + + + + + + +
Subtotal$
Discount$
Tax$
Total$
+
+
+ + + + - $item_name - $item_description - $item_quantity - $$item_price - $$item_tax - $$item_total - - "; - - } - - $html = ' - - - - - - -
Date: '.$quote_date.'
- - - - -
TO:

'.$client_name.'
'.$client_address.'
'.$client_city.' '.$client_state.' '.$client_zip.'

'.$client_email.'
'.$client_phone.'
 
-
- - - - - - - - - - - - - '.$items.' - - - - - - - - - - - - - - -
ProductDescriptionQtyPriceTaxTotal

Notes

'.$quote_note.'
Subtotal:$ '.number_format($sub_total,2).'
Tax:$ '.number_format($total_tax,2).'
Total:$ '.number_format($quote_amount,2).'
-
'.$config_quote_footer.'
- - - '; - - $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,

Attached to this email is the Quote you requested. You can approve or disapprove this quote by clicking here.

If you have any questions please contact us at the number below.

~
$config_company_name
$config_company_phone"; + $mail->Subject = "Quote"; + $mail->Body = "Hello $client_name,

Thank you for your inquiry, we are pleased to provide you with the following estimate.


Total Cost: $$quote_amount


View and accept your estimate online here


~
$config_company_name
$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 .= " - - $item_name - $item_description - $item_quantity - $$item_price - $$item_tax - $$item_total - - "; - - } - - $html = ' - - - - - - -
Date: '.$invoice_date.'
-
Due: '.$invoice_due.'
- - - - -
BILL TO:

'.$client_name.'
'.$client_address.'
'.$client_city.' '.$client_state.' '.$client_zip.'

'.$client_email.'
'.$client_phone.'
 
-
- - - - - - - - - - - - - '.$invoice_items.' - - - - - - - - - - - - - - - - - - - - - - -
ProductDescriptionQtyPriceTaxTotal

Notes

'.$invoice_note.'
Subtotal:$ '.number_format($sub_total,2).'
Tax:$ '.number_format($total_tax,2).'
Total:$ '.number_format($invoice_amount,2).'
Paid:$ '.number_format($amount_paid,2).'
Balance:$ '.number_format($balance,2).'
-
'.$config_invoice_footer.'
- - - '; - - $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,

Attached to this email is a copy of your invoice marked paid.

If you have any questions please contact us at the number below.

~
$config_company_name
Automated Billing Department
$config_company_phone"; + $mail->Subject = "Invoice $invoice_number Copy"; + $mail->Body = "Hello $client_name,

Please click on the link below to see your invoice marked paid.

Invoice Link


~
$config_company_name
Automated Billing Department
$config_company_phone"; }else{ - $mail->Subject = "Invoice $invoice_number - $invoice_date - Due on $invoice_due"; - $mail->Body = "Hello $client_name,

Attached to this email is your invoice. Please make all checks payable to $config_company_name and mail to

$config_company_address
$config_company_city $config_company_state $config_company_zip

before $invoice_due.

If you have any questions please contact us at the number below.

~
$config_company_name
Automated Billing Department
$config_company_phone"; + $mail->Subject = "Invoice $invoice_number"; + $mail->Body = "Hello $client_name,

Please view the details of the invoice below.

Invoice: $invoice_number
Issue Date: $invoice_date
Total: $$invoice_amount
Balance Due: $$balance
Due Date: $invoice_due


To view your invoice online click here


~
$config_company_name
$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'])){ diff --git a/quote.php b/quote.php index 42172002..f95dc35c 100644 --- a/quote.php +++ b/quote.php @@ -195,8 +195,8 @@ if(isset($_GET['quote_id'])){ - +