mirror of https://github.com/itflow-org/itflow
Merge pull request #790 from twetech/Discounts-pt-2
Update Quotes and Recurrings with discounts
This commit is contained in:
commit
430e148815
|
|
@ -83,6 +83,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$quote_status = nullable_htmlentities($row['quote_status']);
|
||||
$quote_date = nullable_htmlentities($row['quote_date']);
|
||||
$quote_expire = nullable_htmlentities($row['quote_expire']);
|
||||
$quote_discount = floatval($row['quote_discount_amount']);
|
||||
$quote_amount = floatval($row['quote_amount']);
|
||||
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
|
||||
$quote_created_at = nullable_htmlentities($row['quote_created_at']);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
}
|
||||
$recurring_next_date = nullable_htmlentities($row['recurring_next_date']);
|
||||
$recurring_amount = floatval($row['recurring_amount']);
|
||||
$recurring_discount = floatval($row['recurring_discount_amount']);
|
||||
$recurring_currency_code = nullable_htmlentities($row['recurring_currency_code']);
|
||||
$recurring_created_at = nullable_htmlentities($row['recurring_created_at']);
|
||||
$category_id = intval($row['category_id']);
|
||||
|
|
@ -106,9 +107,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<td><?php echo $recurring_next_date; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $status_badge_color; ?>">
|
||||
<?php echo $status; ?>
|
||||
</span>
|
||||
<span class="p-2 badge badge-<?php echo $status_badge_color; ?>">
|
||||
<?php echo $status; ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ $quote_number = intval($row['quote_number']);
|
|||
$quote_status = nullable_htmlentities($row['quote_status']);
|
||||
$quote_date = nullable_htmlentities($row['quote_date']);
|
||||
$quote_expire = nullable_htmlentities($row['quote_expire']);
|
||||
$quote_discount = floatval($row['quote_discount_amount']);
|
||||
$quote_amount = floatval($row['quote_amount']);
|
||||
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
|
||||
$quote_note = nullable_htmlentities($row['quote_note']);
|
||||
|
|
@ -232,6 +233,17 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
|
|||
<div class="col-sm-3 offset-sm-2">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<?php
|
||||
if ($quote_discount > 0) {
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Discount</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $quote_discount, $quote_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$sub_total = $sub_total - $quote_discount;
|
||||
}
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Subtotal</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $sub_total, $quote_currency_code); ?></td>
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ if (isset($_POST['add_invoice_copy'])) {
|
|||
header("Location: invoice.php?invoice_id=$new_invoice_id");
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['add_invoice_recurring'])) {
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
|
|
@ -172,8 +173,6 @@ if (isset($_POST['add_invoice_recurring'])) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isset($_POST['add_recurring'])) {
|
||||
|
||||
$client = intval($_POST['client']);
|
||||
|
|
@ -210,8 +209,18 @@ if (isset($_POST['edit_recurring'])) {
|
|||
$category = intval($_POST['category']);
|
||||
$scope = sanitizeInput($_POST['scope']);
|
||||
$status = intval($_POST['status']);
|
||||
$recurring_discount = floatval($_POST['recurring_discount']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_scope = '$scope', recurring_frequency = '$frequency', recurring_next_date = '$next_date', recurring_category_id = $category, recurring_status = $status WHERE recurring_id = $recurring_id");
|
||||
//Calculate new total
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_recurring_id = $recurring_id");
|
||||
$recurring_amount = 0;
|
||||
while($row = mysqli_fetch_array($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
$recurring_amount = $recurring_amount + $item_total;
|
||||
}
|
||||
$recurring_amount = $recurring_amount - $recurring_discount;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_scope = '$scope', recurring_frequency = '$frequency', recurring_next_date = '$next_date', recurring_category_id = $category, recurring_discount_amount = $recurring_discount, recurring_amount = $recurring_amount, recurring_status = $status WHERE recurring_id = $recurring_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = '$status', history_description = 'Recurring modified', history_recurring_id = $recurring_id");
|
||||
|
||||
|
|
@ -277,14 +286,23 @@ if (isset($_POST['add_recurring_item'])) {
|
|||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = $price, item_subtotal = $subtotal, item_tax = $tax_amount, item_total = $total, item_tax_id = $tax_id, item_order = $item_order, item_recurring_id = $recurring_id");
|
||||
|
||||
//Update Recurring Balances
|
||||
//Get Discount
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring WHERE recurring_id = $recurring_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$recurring_discount = floatval($row['recurring_discount_amount']);
|
||||
|
||||
$new_recurring_amount = floatval($row['recurring_amount']) + $total;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_amount = $new_recurring_amount WHERE recurring_id = $recurring_id");
|
||||
//add up all the items
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_recurring_id = $recurring_id");
|
||||
$recurring_amount = 0;
|
||||
while($row = mysqli_fetch_array($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
$recurring_amount = $recurring_amount + $item_total;
|
||||
}
|
||||
$recurring_amount = $recurring_amount - $recurring_discount;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_amount = $recurring_amount WHERE recurring_id = $recurring_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Recurring Invoice Updated";
|
||||
|
||||
|
|
@ -509,19 +527,28 @@ if (isset($_POST['edit_item'])) {
|
|||
mysqli_query($mysqli,"UPDATE invoices SET invoice_amount = $new_invoice_amount WHERE invoice_id = $invoice_id");
|
||||
|
||||
}elseif ($quote_id > 0) {
|
||||
//Get Discount Amount
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$quote_discount = floatval($row['quote_discount_amount']);
|
||||
|
||||
//Update Quote Balances by tallying up items
|
||||
$sql_quote_total = mysqli_query($mysqli,"SELECT SUM(item_total) AS quote_total FROM invoice_items WHERE item_quote_id = $quote_id");
|
||||
$row = mysqli_fetch_array($sql_quote_total);
|
||||
$new_quote_amount = floatval($row['quote_total']);
|
||||
$new_quote_amount = floatval($row['quote_total']) - $quote_discount;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_amount = $new_quote_amount WHERE quote_id = $quote_id");
|
||||
|
||||
} else {
|
||||
//Update Invoice Balances by tallying up invoice items
|
||||
//Get Discount Amount
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring WHERE recurring_id = $recurring_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$recurring_discount = floatval($row['recurring_discount_amount']);
|
||||
|
||||
//Update Invoice Balances by tallying up invoice items
|
||||
$sql_recurring_total = mysqli_query($mysqli,"SELECT SUM(item_total) AS recurring_total FROM invoice_items WHERE item_recurring_id = $recurring_id");
|
||||
$row = mysqli_fetch_array($sql_recurring_total);
|
||||
$new_recurring_amount = floatval($row['recurring_total']);
|
||||
$new_recurring_amount = floatval($row['recurring_total']) - $recurring_discount;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_amount = $new_recurring_amount WHERE recurring_id = $recurring_id");
|
||||
|
||||
|
|
@ -990,7 +1017,7 @@ if (isset($_GET['force_recurring'])) {
|
|||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
} //End Force Recurring
|
||||
}
|
||||
|
||||
if (isset($_POST['export_client_invoices_csv'])) {
|
||||
$client_id = intval($_POST['client_id']);
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
$date = sanitizeInput($_POST['date']);
|
||||
$category = intval($_POST['category']);
|
||||
$scope = sanitizeInput($_POST['scope']);
|
||||
$invoice_discount = floatval($_POST['invoice_discount']);
|
||||
$invoice_discount = floatval($_POST['invoice_discount']);
|
||||
$recurring_discount = floatval($_POST['recurring_discount']);
|
||||
|
|
@ -143,7 +143,8 @@ if (isset($_POST['add_quote_to_invoice'])) {
|
|||
}
|
||||
|
||||
if (isset($_POST['add_quote_item'])) {
|
||||
|
||||
|
||||
include 'post/quote_model.php';
|
||||
$quote_id = intval($_POST['quote_id']);
|
||||
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
|
|
@ -168,13 +169,22 @@ if (isset($_POST['add_quote_item'])) {
|
|||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$name', item_description = '$description', item_quantity = $qty, item_price = $price, item_subtotal = $subtotal, item_tax = $tax_amount, item_total = $total, item_tax_id = $tax_id, item_order = $item_order, item_quote_id = $quote_id");
|
||||
|
||||
//Update Invoice Balances
|
||||
|
||||
//Get Discount
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes WHERE quote_id = $quote_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$new_quote_amount = floatval($row['quote_amount']) + $total;
|
||||
$quote_discount_amount = floatval($row['quote_discount_amount']);
|
||||
|
||||
|
||||
//add up the total of all items
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_quote_id = $quote_id");
|
||||
$quote_amount = 0;
|
||||
while($row = mysqli_fetch_array($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
$quote_amount = $quote_amount + $item_total;
|
||||
}
|
||||
$new_quote_amount = $quote_amount - $quote_discount_amount;
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_amount = $new_quote_amount WHERE quote_id = $quote_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Item added";
|
||||
|
|
@ -203,7 +213,17 @@ if (isset($_POST['edit_quote'])) {
|
|||
|
||||
$quote_id = intval($_POST['quote_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_expire = '$expire', quote_category_id = $category WHERE quote_id = $quote_id");
|
||||
//Calculate the new quote amount
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_quote_id = $quote_id");
|
||||
$quote_amount = 0;
|
||||
while($row = mysqli_fetch_array($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
$quote_amount = $quote_amount + $item_total;
|
||||
}
|
||||
$quote_amount = $quote_amount - $quote_discount;
|
||||
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_expire = '$expire', quote_discount_amount = '$quote_discount', quote_amount = '$quote_amount', quote_category_id = $category WHERE quote_id = $quote_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modify', log_description = '$quote_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@ $date = sanitizeInput($_POST['date']);
|
|||
$expire = sanitizeInput($_POST['expire']);
|
||||
$category = intval($_POST['category']);
|
||||
$scope = sanitizeInput($_POST['scope']);
|
||||
$quote_discount = floatval($_POST['quote_discount']);
|
||||
|
|
|
|||
12
quote.php
12
quote.php
|
|
@ -31,6 +31,7 @@ if (isset($_GET['quote_id'])) {
|
|||
$quote_date = nullable_htmlentities($row['quote_date']);
|
||||
$quote_expire = nullable_htmlentities($row['quote_expire']);
|
||||
$quote_amount = floatval($row['quote_amount']);
|
||||
$quote_discount = floatval($row['quote_discount_amount']);
|
||||
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
|
||||
$quote_note = nullable_htmlentities($row['quote_note']);
|
||||
$quote_url_key = nullable_htmlentities($row['quote_url_key']);
|
||||
|
|
@ -421,6 +422,17 @@ if (isset($_GET['quote_id'])) {
|
|||
<div class="col-sm-3 offset-sm-2">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<?php
|
||||
if ($quote_discount > 0) {
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Discount</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $quote_discount, $quote_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$sub_total = $sub_total - $quote_discount;
|
||||
}
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Subtotal</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $sub_total, $quote_currency_code); ?></td>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='form-group'>
|
||||
<label>Discount Amount</label>
|
||||
<div class='input-group'>
|
||||
<div class='input-group-prepend'>
|
||||
<span class='input-group-text'><i class='fa fa-fw fa-dollar-sign'></i></span>
|
||||
</div>
|
||||
<input type='number' class='form-control' step="0.01" name='quote_discount' placeholder='Discount Amount' value='<?php echo $quote_discount; ?>'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Scope</label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$quote_date = nullable_htmlentities($row['quote_date']);
|
||||
$quote_expire = nullable_htmlentities($row['quote_expire']);
|
||||
$quote_amount = floatval($row['quote_amount']);
|
||||
$quote_discount = floatval($row['quote_discount']);
|
||||
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
|
||||
$quote_created_at = nullable_htmlentities($row['quote_created_at']);
|
||||
$client_id = intval($row['client_id']);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ if (isset($_GET['recurring_id'])) {
|
|||
}
|
||||
$recurring_next_date = nullable_htmlentities($row['recurring_next_date']);
|
||||
$recurring_amount = floatval($row['recurring_amount']);
|
||||
$recurring_discount = floatval($row['recurring_discount_amount']);
|
||||
$recurring_currency_code = nullable_htmlentities($row['recurring_currency_code']);
|
||||
$recurring_note = nullable_htmlentities($row['recurring_note']);
|
||||
$category_id = intval($row['recurring_category_id']);
|
||||
|
|
@ -353,20 +354,32 @@ if (isset($_GET['recurring_id'])) {
|
|||
<div class="col-sm-3 offset-sm-2">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<tr class="border-bottom">
|
||||
<td>Subtotal</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $sub_total, $recurring_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php if ($total_tax > 0) { ?>
|
||||
<?php
|
||||
if ($recurring_discount > 0) {
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Discount</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $recurring_discount, $recurring_currency_code); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$sub_total = $sub_total - $invoice_discount;
|
||||
}
|
||||
?>
|
||||
<tr class="border-bottom">
|
||||
<td>Tax</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $total_tax, $recurring_currency_code); ?></td>
|
||||
<td>Subtotal</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $sub_total, $recurring_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php if ($total_tax > 0) { ?>
|
||||
<tr class="border-bottom">
|
||||
<td>Tax</td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $total_tax, $recurring_currency_code); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr class="border-bottom">
|
||||
<td><strong>Total</strong></td>
|
||||
<td class="text-right"><strong><?php echo numfmt_format_currency($currency_format, $recurring_amount, $recurring_currency_code); ?></strong></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr class="border-bottom">
|
||||
<td><strong>Total</strong></td>
|
||||
<td class="text-right"><strong><?php echo numfmt_format_currency($currency_format, $recurring_amount, $recurring_currency_code); ?></strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,98 +1,118 @@
|
|||
<div class="modal" id="editRecurringModal<?php echo $recurring_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fas fa-fw fa-redo-alt mr-2"></i>Editing Recur Invoice: <strong><?php echo "$recurring_prefix$recurring_number"; ?></strong></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
|
||||
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Scope</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="scope" placeholder="Quick description" value="<?php echo $recurring_scope; ?>">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fas fa-fw fa-redo-alt mr-2"></i>Editing Recur Invoice: <strong><?php echo "$recurring_prefix$recurring_number"; ?></strong></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Frequency <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="frequency" required>
|
||||
<option value="">- Frequency -</option>
|
||||
<option <?php if ($recurring_frequency == 'week') { echo "selected"; } ?> value="week">Weekly</option>
|
||||
<option <?php if ($recurring_frequency == 'month') { echo "selected"; } ?> value="month">Monthly</option>
|
||||
<option <?php if ($recurring_frequency == 'year') { echo "selected"; } ?> value="year">Yearly</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Next Date <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="next_date" max="2999-12-31" value="<?php echo $recurring_next_date; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Income Category <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="category" required>
|
||||
<option value="">- Category -</option>
|
||||
<?php
|
||||
|
||||
$sql_income_category = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$recurring_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_income_category)) {
|
||||
$category_id_select= intval($row['category_id']);
|
||||
$category_name_select = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_id == $category_id_select) { ?> selected <?php } ?> value="<?php echo $category_id_select; ?>"><?php echo $category_name_select; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#addQuickCategoryIncomeModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Scope</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="scope" placeholder="Quick description" value="<?php echo $recurring_scope; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Status <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="status" required>
|
||||
<option <?php if ($recurring_status == 1) { echo "selected"; } ?> value="1">Active</option>
|
||||
<option <?php if ($recurring_status == 0) { echo "selected"; } ?> value="0">InActive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Frequency <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="frequency" required>
|
||||
<option value="">- Frequency -</option>
|
||||
<option <?php if ($recurring_frequency == 'week') {
|
||||
echo "selected";
|
||||
} ?> value="week">Weekly</option>
|
||||
<option <?php if ($recurring_frequency == 'month') {
|
||||
echo "selected";
|
||||
} ?> value="month">Monthly</option>
|
||||
<option <?php if ($recurring_frequency == 'year') {
|
||||
echo "selected";
|
||||
} ?> value="year">Yearly</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Next Date <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="date" class="form-control" name="next_date" max="2999-12-31" value="<?php echo $recurring_next_date; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Income Category <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="category" required>
|
||||
<option value="">- Category -</option>
|
||||
<?php
|
||||
|
||||
$sql_income_category = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$recurring_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_income_category)) {
|
||||
$category_id_select = intval($row['category_id']);
|
||||
$category_name_select = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($category_id == $category_id_select) { ?> selected <?php } ?> value="<?php echo $category_id_select; ?>"><?php echo $category_name_select; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#addQuickCategoryIncomeModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='form-group'>
|
||||
<label>Discount Amount</label>
|
||||
<div class='input-group'>
|
||||
<div class='input-group-prepend'>
|
||||
<span class='input-group-text'><i class='fa fa-fw fa-dollar-sign'></i></span>
|
||||
</div>
|
||||
<input type='number' class='form-control' name='recurring_discount' placeholder='Discount Amount' value='<?php echo $recurring_discount; ?>'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Status <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="status" required>
|
||||
<option <?php if ($recurring_status == 1) {
|
||||
echo "selected";
|
||||
} ?> value="1">Active</option>
|
||||
<option <?php if ($recurring_status == 0) {
|
||||
echo "selected";
|
||||
} ?> value="0">InActive</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="submit" name="edit_recurring" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i> Save</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="submit" name="edit_recurring" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i> Save</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -105,6 +105,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$recurring_scope = nullable_htmlentities($row['recurring_scope']);
|
||||
$recurring_frequency = nullable_htmlentities($row['recurring_frequency']);
|
||||
$recurring_status = nullable_htmlentities($row['recurring_status']);
|
||||
$recurring_discount = floatval($row['recurring_discount_amount']);
|
||||
$recurring_last_sent = $row['recurring_last_sent'];
|
||||
if ($recurring_last_sent == 0) {
|
||||
$recurring_last_sent = "-";
|
||||
|
|
|
|||
Loading…
Reference in New Issue