diff --git a/client_invoices.php b/client_invoices.php
index 54b63e4e..f97da587 100644
--- a/client_invoices.php
+++ b/client_invoices.php
@@ -141,7 +141,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
diff --git a/guest_post.php b/guest_post.php
index 509981f5..e7ea681c 100644
--- a/guest_post.php
+++ b/guest_post.php
@@ -3,9 +3,9 @@
include("config.php");
include("functions.php");
-if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
+if(isset($_GET['download_invoice'], $_GET['url_key'])){
- $invoice_id = intval($_GET['pdf_invoice']);
+ $invoice_id = intval($_GET['download_invoice']);
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, companies, settings
@@ -65,6 +65,7 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
$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'];
+ $amount_paid = number_format($amount_paid, 2);
$balance = $invoice_amount - $amount_paid;
$balance = number_format($balance, 2);
@@ -482,9 +483,9 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
}
}
-if(isset($_GET['pdf_quote'], $_GET['url_key'])){
+if(isset($_GET['download_quote'], $_GET['url_key'])){
- $quote_id = intval($_GET['pdf_quote']);
+ $quote_id = intval($_GET['download_quote']);
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies, settings
diff --git a/guest_view_invoice.php b/guest_view_invoice.php
index f1d6310a..e2f7b973 100644
--- a/guest_view_invoice.php
+++ b/guest_view_invoice.php
@@ -119,7 +119,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
diff --git a/invoice.php b/invoice.php
index be1dcc4c..573d9eb1 100644
--- a/invoice.php
+++ b/invoice.php
@@ -148,7 +148,7 @@ if(isset($_GET['invoice_id'])){
Recurring
Print
-
PDF
+
Download
Send Email
">Guest URL
diff --git a/invoices.php b/invoices.php
index 6e397029..63715ab9 100644
--- a/invoices.php
+++ b/invoices.php
@@ -293,7 +293,7 @@
Copy
Send
-
PDF
+
Download
Delete
diff --git a/post.php b/post.php
index d7386b8a..3417b95a 100644
--- a/post.php
+++ b/post.php
@@ -2025,9 +2025,9 @@ if(isset($_GET['decline_quote'])){
}
-if(isset($_GET['pdf_quote'])){
+if(isset($_GET['download_quote'])){
- $quote_id = intval($_GET['pdf_quote']);
+ $quote_id = intval($_GET['download_quote']);
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies
WHERE quotes.client_id = clients.client_id
@@ -2433,9 +2433,7 @@ if(isset($_GET['pdf_quote'])){
}
};
- pdfMake.createPdf(docDefinition).open({}, window);
-
-
+ pdfMake.createPdf(docDefinition).download('');
@@ -3310,9 +3308,9 @@ if(isset($_GET['delete_revenue'])){
}
-if(isset($_GET['pdf_invoice'])){
+if(isset($_GET['download_invoice'])){
- $invoice_id = intval($_GET['pdf_invoice']);
+ $invoice_id = intval($_GET['download_invoice']);
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, companies
WHERE invoices.client_id = clients.client_id
@@ -3368,6 +3366,14 @@ if(isset($_GET['pdf_invoice'])){
$company_website = $row['company_website'];
$company_logo = base64_encode(file_get_contents($row['company_logo']));
+ //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'];
+ $amount_paid = number_format($amount_paid, 2);
+
+ $balance = $invoice_amount - $amount_paid;
+ $balance = number_format($balance, 2);
?>
@@ -3634,6 +3640,26 @@ if(isset($_GET['pdf_invoice'])){
style:'itemsFooterTotalValue'
}
],
+ [
+ {
+ text:'Paid',
+ style:'itemsFooterSubTitle'
+ },
+ {
+ text: '$',
+ style:'itemsFooterSubValue'
+ }
+ ],
+ [
+ {
+ text:'Balance',
+ style:'itemsFooterSubTitle'
+ },
+ {
+ text: '$',
+ style:'itemsFooterSubValue'
+ }
+ ],
]
}, // table
layout: 'lightHorizontalLines'
@@ -3751,9 +3777,7 @@ if(isset($_GET['pdf_invoice'])){
}
};
- pdfMake.createPdf(docDefinition).open({}, window);
-
-
+ pdfMake.createPdf(docDefinition).download('');
diff --git a/quote.php b/quote.php
index 74c0c49c..1b692b7d 100644
--- a/quote.php
+++ b/quote.php
@@ -128,7 +128,7 @@ if(isset($_GET['quote_id'])){