mirror of https://github.com/itflow-org/itflow
Add Saved Payment Options to recurring invoices and details for agents
This commit is contained in:
parent
31a89c0641
commit
467c681117
|
|
@ -55,23 +55,6 @@ $recurring_invoices_sql = mysqli_query($mysqli, "SELECT * FROM recurring_invoice
|
|||
$recurring_payment_id = intval($row['recurring_payment_id']);
|
||||
$recurring_payment_recurring_invoice_id = intval($row['recurring_payment_recurring_invoice_id']);
|
||||
$recurring_payment_saved_payment_id = intval($row['recurring_payment_saved_payment_id']);
|
||||
if ($config_stripe_enable) {
|
||||
if ($recurring_payment_recurring_invoice_id) {
|
||||
$auto_pay_display = "
|
||||
Yes
|
||||
<a href='post.php?delete_recurring_payment=$recurring_payment_id' title='Remove'>
|
||||
<i class='fas fa-fw fa-times-circle'></i>
|
||||
</a>
|
||||
";
|
||||
} else {
|
||||
$auto_pay_display = "
|
||||
<a href='#' data-toggle='modal' data-target='#addRecurringPaymentModal$recurring_invoice_id'>
|
||||
Create
|
||||
</a>
|
||||
";
|
||||
//require "recurring_payment_add_modal.php";
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($recurring_invoice_scope)) {
|
||||
$recurring_invoice_scope_display = "-";
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="opening_balance" placeholder="0.00" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -1607,6 +1607,59 @@ if (isset($_GET['force_recurring'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_POST['set_recurring_payment'])) {
|
||||
|
||||
$recurring_invoice_id = intval($_POST['recurring_invoice_id']);
|
||||
$saved_payment_id = intval($_POST['saved_payment_id']);
|
||||
|
||||
// Get Recurring Invoice Info for logging and alerting
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM recurring_invoices WHERE recurring_invoice_id = $recurring_invoice_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$client_id = intval($row['recurring_invoice_client_id']);
|
||||
$recurring_invoice_prefix = sanitizeInput($row['recurring_invoice_prefix']);
|
||||
$recurring_invoice_number = intval($row['recurring_invoice_number']);
|
||||
$recurring_invoice_currency_code = sanitizeInput($row['recurring_invoice_currency_code']);
|
||||
$recurring_invoice_amount = floatval($row['recurring_invoice_amount']);
|
||||
|
||||
if ($saved_payment_id) {
|
||||
|
||||
// Get Payment provider and method
|
||||
$sql = mysqli_query($mysqli, "
|
||||
SELECT * FROM payment_providers
|
||||
LEFT JOIN client_saved_payment_methods ON saved_payment_provider_id = payment_provider_id
|
||||
WHERE saved_payment_id = $saved_payment_id
|
||||
");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$provider_id = intval($row['payment_provider_id']);
|
||||
$provider_name = sanitizeInput($row['payment_provider_name']);
|
||||
$account_id = intval($row['payment_provider_account']);
|
||||
$saved_payment_description = sanitizeInput($row['saved_payment_description']);
|
||||
|
||||
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_recurring_invoice_id = $recurring_invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO recurring_payments SET recurring_payment_currency_code = '$recurring_invoice_currency_code', recurring_payment_account_id = $account_id, recurring_payment_method = 'Credit Card', recurring_payment_recurring_invoice_id = $recurring_invoice_id, recurring_payment_saved_payment_id = $saved_payment_id");
|
||||
// Get Payment ID for reference
|
||||
$recurring_payment_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Logging
|
||||
logAction("Recurring Invoice", "Auto Payment", "$session_name created Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Automatic Payment <strong>$saved_payment_description</strong> enabled for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number";
|
||||
} else {
|
||||
// Delete
|
||||
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_recurring_invoice_id = $recurring_invoice_id");
|
||||
|
||||
// Logging
|
||||
logAction("Recurring Invoice", "Auto Payment", "$session_name removed Auto Pay for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number in the amount of " . numfmt_format_currency($currency_format, $recurring_invoice_amount, $recurring_invoice_currency_code), $client_id, $recurring_invoice_id);
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Automatic Payment <strong>Disabled</strong> for Recurring Invoice $recurring_invoice_prefix$recurring_invoice_number";
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_POST['export_invoices_csv'])) {
|
||||
if (isset($_POST['client_id'])) {
|
||||
$client_id = intval($_POST['client_id']);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ if (isset($_GET['recurring_invoice_id'])) {
|
|||
$recurring_payment_id = intval($row['recurring_payment_id']);
|
||||
$recurring_payment_recurring_invoice_id = intval($row['recurring_payment_recurring_invoice_id']);
|
||||
$recurring_payment_method = nullable_htmlentities($row['recurring_payment_method']);
|
||||
$recurring_payment_saved_payment_id = intval($row['recurring_payment_saved_payment_id']);
|
||||
|
||||
// Override Tab Title // No Sanitizing needed as this var will only be used in the tab title
|
||||
$tab_title = $row['client_name'];
|
||||
|
|
@ -137,7 +138,7 @@ if (isset($_GET['recurring_invoice_id'])) {
|
|||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-8">
|
||||
<div class="col-4">
|
||||
<?php if ($config_recurring_invoice_auto_send_invoice) { ?>
|
||||
<?php if ($recurring_invoice_email_notify) { ?>
|
||||
<a href="post.php?recurring_invoice_email_notify=0&recurring_invoice_id=<?php echo $recurring_invoice_id; ?>" class="btn btn-primary"><i class="fas fa-fw fa-bell mr-2"></i>Email Notify</a>
|
||||
|
|
@ -158,6 +159,33 @@ if (isset($_GET['recurring_invoice_id'])) {
|
|||
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<?php $sql_saved_payments = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods WHERE saved_payment_client_id = $client_id");
|
||||
if (mysqli_num_rows($sql_saved_payments) > 0) { ?>
|
||||
<form class="form" action="post.php" method="post">
|
||||
<input type="hidden" name="set_recurring_payment" value="1">
|
||||
<input type="hidden" name="recurring_invoice_id" value="<?php echo $recurring_invoice_id; ?>">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-redo-alt"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="saved_payment_id" onchange="this.form.submit()">
|
||||
<option value="0">Disabled</option>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_saved_payments)) {
|
||||
$saved_payment_id = intval($row['saved_payment_id']);
|
||||
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
|
||||
|
||||
?>
|
||||
<option <?php if ($recurring_payment_saved_payment_id == $saved_payment_id) { echo "selected"; } ?> value="<?php echo $saved_payment_id; ?>"><?php echo $saved_payment_description; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
<?php } else { ?>
|
||||
<a href="saved_payment_method.php">Add a Payment Method</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="col-4">
|
||||
<div class="dropdown dropleft text-center float-right">
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
}
|
||||
$recurring_payment_id = intval($row['recurring_payment_id']);
|
||||
$recurring_payment_recurring_invoice_id = intval($row['recurring_payment_recurring_invoice_id']);
|
||||
$recurring_payment_saved_payment_id = intval($row['recurring_payment_saved_payment_id']);
|
||||
if ($recurring_payment_recurring_invoice_id) {
|
||||
$auto_pay_display = "
|
||||
Yes
|
||||
|
|
@ -235,7 +236,28 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<td><?php echo ucwords($recurring_invoice_frequency); ?>ly</td>
|
||||
<td><?php echo $recurring_invoice_last_sent; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td><?php echo $auto_pay_display; ?></td>
|
||||
<td>
|
||||
<?php $sql_saved_payments = mysqli_query($mysqli, "SELECT * FROM client_saved_payment_methods WHERE saved_payment_client_id = $client_id");
|
||||
if (mysqli_num_rows($sql_saved_payments) > 0) { ?>
|
||||
<form class="form" action="post.php" method="post">
|
||||
<input type="hidden" name="set_recurring_payment" value="1">
|
||||
<input type="hidden" name="recurring_invoice_id" value="<?php echo $recurring_invoice_id; ?>">
|
||||
<select class="form-control select2" name="saved_payment_id" onchange="this.form.submit()">
|
||||
<option value="0">Disabled</option>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_saved_payments)) {
|
||||
$saved_payment_id = intval($row['saved_payment_id']);
|
||||
$saved_payment_description = nullable_htmlentities($row['saved_payment_description']);
|
||||
|
||||
?>
|
||||
<option <?php if ($recurring_payment_saved_payment_id == $saved_payment_id) { echo "selected"; } ?> value="<?php echo $saved_payment_id; ?>"><?php echo $saved_payment_description; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</form>
|
||||
<?php } else { ?>
|
||||
<a href="saved_payment_method.php">Add a Payment Method</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $status_badge_color; ?>">
|
||||
<?php echo $status; ?>
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@
|
|||
$contact_display = "<div><a href='contact_details.php?client_id=$client_id&contact_id=$contact_id'>$contact_name</a></div>";
|
||||
}
|
||||
|
||||
$ticket_invoice_id = intval($row['ticket_invoice_id']);
|
||||
|
||||
// Get who last updated the ticket - to be shown in the last Response column
|
||||
|
||||
// Defaults to prevent undefined errors
|
||||
|
|
@ -227,6 +229,9 @@
|
|||
<!-- Ticket Billable (if accounting enabled -->
|
||||
<?php if ($config_module_enable_accounting && lookupUserPermission("module_sales") >= 2) { ?>
|
||||
<td class="text-center">
|
||||
<?php if ($ticket_invoice_id) { ?>
|
||||
<a href="invoice.php?client_id=<?php echo $client_id; ?>&invoice_id=<?php echo $ticket_invoice_id; ?>"><span class='badge badge-pill badge-success p-2'>Invoiced</span></a>
|
||||
<?php } else { ?>
|
||||
<a href="#"
|
||||
data-toggle = "ajax-modal"
|
||||
data-ajax-url = "ajax/ajax_ticket_billable.php"
|
||||
|
|
@ -240,6 +245,7 @@
|
|||
}
|
||||
?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue