mirror of https://github.com/itflow-org/itflow
Reworded PDF to just Download added balance on PDF Invoice
This commit is contained in:
parent
a3590c215a
commit
e71b851dd7
|
|
@ -141,7 +141,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<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>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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>
|
||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
<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-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
|
||||
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">
|
||||
<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 class="card-body">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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" target="_blank" href="guest_view_invoice.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Guest URL</a>
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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>
|
||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>">Delete</a>
|
||||
</div>
|
||||
|
|
|
|||
44
post.php
44
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('<?php echo "$quote_date-$company_name-$client_name-Quote-$quote_prefix$quote_number.pdf"; ?>');
|
||||
|
||||
</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
|
||||
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: '$<?php echo $amount_paid; ?>',
|
||||
style:'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
text:'Balance',
|
||||
style:'itemsFooterSubTitle'
|
||||
},
|
||||
{
|
||||
text: '$<?php echo $balance; ?>',
|
||||
style:'itemsFooterSubValue'
|
||||
}
|
||||
],
|
||||
]
|
||||
}, // table
|
||||
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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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" 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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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>
|
||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue