Reworded PDF to just Download added balance on PDF Invoice
This commit is contained in:
+1
-1
@@ -141,7 +141,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?download_invoice=<?php echo $invoice_id; ?>">Download</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?download_quote=<?php echo $quote_id; ?>">Download</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+5
-4
@@ -3,9 +3,9 @@
|
|||||||
include("config.php");
|
include("config.php");
|
||||||
include("functions.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']);
|
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, companies, settings
|
$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");
|
$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);
|
$row = mysqli_fetch_array($sql_amount_paid);
|
||||||
$amount_paid = $row['amount_paid'];
|
$amount_paid = $row['amount_paid'];
|
||||||
|
$amount_paid = number_format($amount_paid, 2);
|
||||||
|
|
||||||
$balance = $invoice_amount - $amount_paid;
|
$balance = $invoice_amount - $amount_paid;
|
||||||
$balance = number_format($balance, 2);
|
$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']);
|
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
|
||||||
|
|
||||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies, settings
|
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies, settings
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<a class="btn btn-secondary" data-toggle="collapse" href="#collapsePreviousInvoices"><i class="fa fa-fw fa-history"></i> Invoice History</a>
|
<a class="btn btn-secondary" data-toggle="collapse" href="#collapsePreviousInvoices"><i class="fa fa-fw fa-history"></i> Invoice History</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" href="#" onclick="window.print();"><i class="fa fa-fw fa-print"></i> Print</a>
|
||||||
<a class="btn btn-primary" 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>
|
<a class="btn btn-primary" target="_blank" href="guest_post.php?download_invoice=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
|
||||||
<?php
|
<?php
|
||||||
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft" and $config_stripe_enable == 1){
|
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft" and $config_stripe_enable == 1){
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
|
|||||||
|
|
||||||
<div class="float-right">
|
<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" href="#" onclick="window.print();"><i class="fa fa-fw fa-print"></i> Print</a>
|
||||||
<a class="btn btn-primary" 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>
|
<a class="btn btn-primary" target="_blank" href="guest_post.php?download_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ if(isset($_GET['invoice_id'])){
|
|||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceRecurringModal<?php echo $invoice_id; ?>">Recurring</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceRecurringModal<?php echo $invoice_id; ?>">Recurring</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?download_invoice=<?php echo $invoice_id; ?>">Download</a>
|
||||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send Email</a>
|
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send Email</a>
|
||||||
|
|
||||||
<a class="dropdown-item" target="_blank" href="guest_view_invoice.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Guest URL</a>
|
<a class="dropdown-item" target="_blank" href="guest_view_invoice.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Guest URL</a>
|
||||||
|
|||||||
+1
-1
@@ -293,7 +293,7 @@
|
|||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">Download</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
|
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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
|
$sql = mysqli_query($mysqli,"SELECT * FROM quotes, clients, companies
|
||||||
WHERE quotes.client_id = clients.client_id
|
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('<?php echo "$quote_date-$company_name-$client_name-Quote-$quote_prefix$quote_number.pdf"; ?>');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -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
|
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, companies
|
||||||
WHERE invoices.client_id = clients.client_id
|
WHERE invoices.client_id = clients.client_id
|
||||||
@@ -3368,6 +3366,14 @@ if(isset($_GET['pdf_invoice'])){
|
|||||||
$company_website = $row['company_website'];
|
$company_website = $row['company_website'];
|
||||||
$company_logo = base64_encode(file_get_contents($row['company_logo']));
|
$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'
|
style:'itemsFooterTotalValue'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text:'Paid',
|
||||||
|
style:'itemsFooterSubTitle'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '$<?php echo $amount_paid; ?>',
|
||||||
|
style:'itemsFooterSubValue'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text:'Balance',
|
||||||
|
style:'itemsFooterSubTitle'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '$<?php echo $balance; ?>',
|
||||||
|
style:'itemsFooterSubValue'
|
||||||
|
}
|
||||||
|
],
|
||||||
]
|
]
|
||||||
}, // table
|
}, // table
|
||||||
layout: 'lightHorizontalLines'
|
layout: 'lightHorizontalLines'
|
||||||
@@ -3751,9 +3777,7 @@ if(isset($_GET['pdf_invoice'])){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pdfMake.createPdf(docDefinition).open({}, window);
|
pdfMake.createPdf(docDefinition).download('<?php echo "$invoice_date-$company_name-$client_name-Invoice-$invoice_prefix$invoice_number.pdf"; ?>');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ if(isset($_GET['quote_id'])){
|
|||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?download_quote=<?php echo $quote_id; ?>">Download</a>
|
||||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
|
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
|
||||||
<a class="dropdown-item" target="_blank" href="guest_view_quote.php?quote_id=<?php echo "$quote_id&url_key=$quote_url_key"; ?>">Guest URL</a>
|
<a class="dropdown-item" target="_blank" href="guest_view_quote.php?quote_id=<?php echo "$quote_id&url_key=$quote_url_key"; ?>">Guest URL</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|||||||
+1
-1
@@ -174,7 +174,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
||||||
<a class="dropdown-item" target="_blank" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
<a class="dropdown-item" target="_blank" href="post.php?download_quote=<?php echo $quote_id; ?>">Download</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user