mirror of https://github.com/itflow-org/itflow
Make Client Portal Dashboard Cards Linkable, added upaid invoices with ui for option to enter card manually, pay with saved card or pay entire balance
This commit is contained in:
parent
184aba4de4
commit
3e7d7f3801
|
|
@ -180,28 +180,28 @@ if ($session_contact_primary == 1 || $session_contact_is_billing_contact) { ?>
|
|||
<div class="row">
|
||||
|
||||
<?php if ($balance > 0) { ?>
|
||||
<div class="col-sm-3 offset-1">
|
||||
<div class="card">
|
||||
<div class="col-sm-3">
|
||||
<a href="unpaid_invoices.php" class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title text-bold">Account Balance</h3>
|
||||
<h3 class="card-title text-bold text-dark">Account Balance</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="h4 text-danger"><b><?php echo numfmt_format_currency($currency_format, $balance, $session_company_currency); ?></b></div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($recurring_monthly_total > 0) { ?>
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<a href="recurring_invoices.php" class="card text-dark">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Recurring Monthly</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="h4"><b><?php echo numfmt_format_currency($currency_format, $recurring_monthly_total, $session_company_currency); ?></b></div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
|
|
@ -217,8 +217,8 @@ if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
|||
<div class="row">
|
||||
|
||||
<?php if (mysqli_num_rows($sql_domains_expiring) > 0) { ?>
|
||||
<div class="col-sm-3 offset-1">
|
||||
<div class="card">
|
||||
<div class="col-sm-3">
|
||||
<a href="domains.php" class="card text-dark">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title text-bold">Domains Expiring</h3>
|
||||
</div>
|
||||
|
|
@ -240,7 +240,7 @@ if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
|||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
@ -255,7 +255,7 @@ if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
|||
<div class="row">
|
||||
<?php if (mysqli_num_rows($sql_assigned_assets) > 0) { ?>
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<a href="assets.php" class="card text-dark">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Your Assigned Assets</h3>
|
||||
</div>
|
||||
|
|
@ -277,7 +277,7 @@ if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
|||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ $invoices_sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_clie
|
|||
<?php echo $invoice_status; ?>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
/*
|
||||
* Client Portal
|
||||
* Invoices for PTC
|
||||
*/
|
||||
|
||||
header("Content-Security-Policy: default-src 'self'");
|
||||
|
||||
require_once "includes/inc_all.php";
|
||||
|
||||
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_billing_contact) {
|
||||
header("Location: post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
||||
$invoices_sql = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_client_id = $session_client_id AND (invoice_status = 'Viewed' OR invoice_status = 'Sent' OR invoice_status = 'Partial') ORDER BY invoice_date DESC");
|
||||
|
||||
|
||||
// Saved Payment Methods
|
||||
$sql_saved_payment_methods = mysqli_query($mysqli, "
|
||||
SELECT * FROM client_saved_payment_methods
|
||||
LEFT JOIN payment_providers
|
||||
ON client_saved_payment_methods.saved_payment_provider_id = payment_providers.payment_provider_id
|
||||
WHERE saved_payment_client_id = $session_client_id
|
||||
AND payment_provider_active = 1;
|
||||
");
|
||||
|
||||
// Get Balance
|
||||
// Billing Card Queries
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE invoice_client_id = $session_client_id AND invoice_status != 'Draft' AND invoice_status != 'Cancelled' AND invoice_status != 'Non-Billable'");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = floatval($row['invoice_amounts']);
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $session_client_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = floatval($row['amount_paid']);
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<h3>Unpaid Invoices</h3>
|
||||
</div>
|
||||
<div class="col-5">
|
||||
<?php if ($config_stripe_enable) { ?>
|
||||
<button type="button" class="btn btn-success dropdown-toggle float-right" data-toggle="dropdown"><i class="fa fa-fw fa-credit-card mr-2"></i>Pay Balance <strong>(<?php echo numfmt_format_currency($currency_format, $balance, $session_company_currency); ?>)</strong></button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="//<?php echo $config_base_url ?>/guest/guest_pay_invoice_stripe.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Enter Card Manually</a>
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_saved_payment_methods) > 0) { ?>
|
||||
<h6 class="dropdown-header text-left">Pay with a Saved Card</h6>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_saved_payment_methods)) {
|
||||
$saved_payment_id = intval($row['saved_payment_id']);
|
||||
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
|
||||
$payment_provider_name = nullable_htmlentities($row['payment_provider_name']);
|
||||
?>
|
||||
|
||||
<a class="dropdown-item confirm-link" href="post.php?add_payment_by_provider=<?php echo $saved_payment_provider_id; ?>&invoice_id=<?php echo $invoice_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token']; ?>"><?php echo "$payment_provider_name | $saved_payment_description"; ?></a>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
<?php } // End Payment Provider Enable Check ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-10">
|
||||
|
||||
<table class="table tabled-bordered border border-dark">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Scope</th>
|
||||
<th>Amount</th>
|
||||
<th>Date</th>
|
||||
<th>Due</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($invoices_sql)) {
|
||||
$invoice_id = intval($row['invoice_id']);
|
||||
$invoice_prefix = nullable_htmlentities($row['invoice_prefix']);
|
||||
$invoice_number = intval($row['invoice_number']);
|
||||
$invoice_scope = nullable_htmlentities($row['invoice_scope']);
|
||||
$invoice_status = nullable_htmlentities($row['invoice_status']);
|
||||
$invoice_date = nullable_htmlentities($row['invoice_date']);
|
||||
$invoice_due = nullable_htmlentities($row['invoice_due']);
|
||||
$invoice_amount = floatval($row['invoice_amount']);
|
||||
$invoice_url_key = nullable_htmlentities($row['invoice_url_key']);
|
||||
|
||||
if (empty($invoice_scope)) {
|
||||
$invoice_scope_display = "-";
|
||||
} else {
|
||||
$invoice_scope_display = $invoice_scope;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
if (($invoice_status == "Sent" || $invoice_status == "Partial" || $invoice_status == "Viewed") && strtotime($invoice_due) + 86400 < $now) {
|
||||
$overdue_color = "text-danger font-weight-bold";
|
||||
} else {
|
||||
$overdue_color = "";
|
||||
}
|
||||
|
||||
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") {
|
||||
$invoice_badge_color = "success";
|
||||
} elseif ($invoice_status == "Cancelled") {
|
||||
$invoice_badge_color = "danger";
|
||||
} else{
|
||||
$invoice_badge_color = "secondary";
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><a target="_blank" href="//<?php echo $config_base_url ?>/guest/guest_view_invoice.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"?>"> <?php echo "$invoice_prefix$invoice_number"; ?></a></td>
|
||||
<td><?php echo $invoice_scope_display; ?></td>
|
||||
<td><?php echo numfmt_format_currency($currency_format, $invoice_amount, $session_company_currency); ?></td>
|
||||
<td><?php echo $invoice_date; ?></td>
|
||||
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
|
||||
<td>
|
||||
<?php if ($config_stripe_enable) { ?>
|
||||
<button type="button" class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown">Pay</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="//<?php echo $config_base_url ?>/guest/guest_pay_invoice_stripe.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Enter Card Manually</a>
|
||||
<?php
|
||||
if (mysqli_num_rows($sql_saved_payment_methods) > 0) { ?>
|
||||
<h6 class="dropdown-header text-left">Pay with a Saved Card</h6>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_saved_payment_methods)) {
|
||||
$saved_payment_id = intval($row['saved_payment_id']);
|
||||
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
|
||||
$payment_provider_name = nullable_htmlentities($row['payment_provider_name']);
|
||||
?>
|
||||
|
||||
<a class="dropdown-item confirm-link" href="post.php?add_payment_by_provider=<?php echo $saved_payment_provider_id; ?>&invoice_id=<?php echo $invoice_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token']; ?>"><?php echo "$payment_provider_name | $saved_payment_description"; ?></a>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
<?php } // End Payment Provider Enable Check ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
require_once "includes/footer.php";
|
||||
|
||||
Loading…
Reference in New Issue