diff --git a/client_invoices.php b/client_invoices.php
index d626d627..3a80aa13 100644
--- a/client_invoices.php
+++ b/client_invoices.php
@@ -104,6 +104,8 @@ $total_pages = ceil($total_found_rows / 10);
//Set Badge color based off of invoice status
if($invoice_status == "Sent"){
$invoice_badge_color = "warning";
+ }elseif($invoice_status == "Viewed"){
+ $invoice_badge_color = "info";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){
diff --git a/guest_view_invoice.php b/guest_view_invoice.php
index 66a570ae..724a14e2 100644
--- a/guest_view_invoice.php
+++ b/guest_view_invoice.php
@@ -59,6 +59,10 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
//Mark viewed in history
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id");
+ //Update status to Viewed only if invoice_status = "Sent"
+ if($invoice_status == 'Sent'){
+ mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Viewed' WHERE 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");
diff --git a/guest_view_quote.php b/guest_view_quote.php
index 86d2971d..dafba0df 100644
--- a/guest_view_quote.php
+++ b/guest_view_quote.php
@@ -59,11 +59,16 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
//Mark viewed in history
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
+ //Update status to Viewed only if invoice_status = "Sent"
+ if($quote_status == 'Sent'){
+ mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Viewed' WHERE 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";
+ $quote_badge_color = "info";
}elseif($quote_status == "Approved"){
$quote_badge_color = "success";
}elseif($quote_status == "Cancelled"){
diff --git a/invoice.php b/invoice.php
index 85c2507d..971145bd 100644
--- a/invoice.php
+++ b/invoice.php
@@ -59,6 +59,8 @@ if(isset($_GET['invoice_id'])){
//Set Badge color based off of invoice status
if($invoice_status == "Sent"){
$invoice_badge_color = "warning text-white";
+ }elseif($invoice_status == "Viewed"){
+ $invoice_badge_color = "info";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){
diff --git a/invoices.php b/invoices.php
index f380ffdc..45bd87f8 100644
--- a/invoices.php
+++ b/invoices.php
@@ -200,6 +200,8 @@
if($invoice_status == "Sent"){
$invoice_badge_color = "warning text-white";
+ }elseif($invoice_status == "Viewed"){
+ $invoice_badge_color = "info";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){
diff --git a/post.php b/post.php
index 8d75d4a5..87e51fd1 100644
--- a/post.php
+++ b/post.php
@@ -1861,6 +1861,7 @@ if(isset($_POST['add_payment'])){
$payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']));
$reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']));
$email_receipt = intval($_POST['email_receipt']);
+ $base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
//Check to see if amount entered is greater than the balance of the invoice
if($amount > $balance){
@@ -1879,6 +1880,7 @@ if(isset($_POST['add_payment'])){
$row = mysqli_fetch_array($sql);
$invoice_amount = $row['invoice_amount'];
$invoice_number = $row['invoice_number'];
+ $invoice_url_key = $row['invoice_url_key'];
$client_name = $row['client_name'];
$client_email = $row['client_email'];
@@ -1914,8 +1916,8 @@ if(isset($_POST['add_payment'])){
// Content
$mail->isHTML(true); // Set email format to HTML
- $mail->Subject = "Payment Recieved";
- $mail->Body = "Hello $client_name,
We have recieved your payment in the amount of $$formatted_amount and it has been applied to your account. Please keep this email as a receipt for your records.
Amount: $$formatted_amount
Balance: $formatted_invoice_balance
Thank you for your business!
~
$config_company_name
$config_company_phone";
+ $mail->Subject = "Payment Recieved - Invoice $invoice_number";
+ $mail->Body = "Hello $client_name,
We have recieved your payment in the amount of $$formatted_amount for invoice
$invoice_number. Please keep this email as a receipt for your records.
Amount: $$formatted_amount
Balance: $formatted_invoice_balance
Thank you for your business!
~
$config_company_name
$config_company_phone";
$mail->send();
echo 'Message has been sent';
@@ -1950,8 +1952,8 @@ if(isset($_POST['add_payment'])){
// Content
$mail->isHTML(true); // Set email format to HTML
- $mail->Subject = "Payment Recieved";
- $mail->Body = "Hello $client_name,
We have recieved your payment in the amount of $$formatted_amount and it has been applied to your account. Please keep this email as a receipt for your records.
Amount: $$formatted_amount
Balance: $formatted_invoice_balance
Thank you for your business!
~
$config_company_name
$config_company_phone";
+ $mail->Subject = "Partial Payment Recieved - Invoice $invoice_number";
+ $mail->Body = "Hello $client_name,
We have recieved partial payment in the amount of $$formatted_amount and it has been applied to invoice
$invoice_number. Please keep this email as a receipt for your records.
Amount: $$formatted_amount
Balance: $formatted_invoice_balance
Thank you for your business!
~
$config_company_name
$config_company_phone";
$mail->send();
echo 'Message has been sent';