mirror of https://github.com/itflow-org/itflow
Migrated project, transfer and quote edit to the new AJAX modal function
This commit is contained in:
parent
093fd69415
commit
ccec330ceb
38
ajax.php
38
ajax.php
|
|
@ -429,44 +429,6 @@ if (isset($_GET['recurring_ticket_get_json_details'])) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Looks up info for a given quote ID from the database, used to dynamically populate modal fields
|
|
||||||
*/
|
|
||||||
if (isset($_GET['quote_get_json_details'])) {
|
|
||||||
enforceUserPermission('module_sales');
|
|
||||||
|
|
||||||
$quote_id = intval($_GET['quote_id']);
|
|
||||||
|
|
||||||
// Get quote details
|
|
||||||
$quote_sql = mysqli_query(
|
|
||||||
$mysqli,
|
|
||||||
"SELECT * FROM quotes
|
|
||||||
LEFT JOIN clients ON quote_client_id = client_id
|
|
||||||
WHERE quote_id = $quote_id LIMIT 1"
|
|
||||||
);
|
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($quote_sql)) {
|
|
||||||
$response['quote'][] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Get all income-related categories for quoting
|
|
||||||
$quote_created_at = $response['quote'][0]['quote_created_at'];
|
|
||||||
$category_sql = mysqli_query(
|
|
||||||
$mysqli,
|
|
||||||
"SELECT category_id, category_name FROM categories
|
|
||||||
WHERE category_type = 'Income' AND (category_archived_at > '$quote_created_at' OR category_archived_at IS NULL)
|
|
||||||
ORDER BY category_name"
|
|
||||||
);
|
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($category_sql)) {
|
|
||||||
$response['categories'][] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($response);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns sorted list of active clients
|
* Returns sorted list of active clients
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../includes/ajax_header.php';
|
||||||
|
|
||||||
|
$project_id = intval($_GET['id']);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM projects WHERE project_id = $project_id LIMIT 1");
|
||||||
|
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$project_prefix = nullable_htmlentities($row['project_prefix']);
|
||||||
|
$project_number = intval($row['project_number']);
|
||||||
|
$project_name = nullable_htmlentities($row['project_name']);
|
||||||
|
$project_description = nullable_htmlentities($row['project_description']);
|
||||||
|
$project_due = nullable_htmlentities($row['project_due']);
|
||||||
|
$project_created_at = nullable_htmlentities($row['project_created_at']);
|
||||||
|
$project_created_at_display = date("Y-m-d", strtotime($project_created_at));
|
||||||
|
$project_updated_at = nullable_htmlentities($row['project_updated_at']);
|
||||||
|
$project_completed_at = nullable_htmlentities($row['project_completed_at']);
|
||||||
|
$project_completed_at_display = date("Y-m-d", strtotime($project_completed_at));
|
||||||
|
$project_archived_at = nullable_htmlentities($row['project_archived_at']);
|
||||||
|
$client_id = intval($row['project_client_id']);
|
||||||
|
$project_manager = intval($row['project_manager']);
|
||||||
|
|
||||||
|
// Generate the HTML form content using output buffering.
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">
|
||||||
|
<i class="fas fa-fw fa-project-diagram mr-2"></i>Editing Project: <strong><?php echo $project_name; ?></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="project_id" value="<?php echo $project_id; ?>">
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Project Name <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-project-diagram"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="name" placeholder="Project Name" maxlength="255" value="<?php echo $project_name; ?>" required autofocus>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Description</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="description" placeholder="Description" value="<?php echo $project_description; ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Date Due <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="due_date" value="<?php echo $project_due; ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Manager</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-user-tie"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="project_manager">
|
||||||
|
<option value="0">No Manager</option>
|
||||||
|
<?php
|
||||||
|
$sql_project_managers_select = mysqli_query(
|
||||||
|
$mysqli,
|
||||||
|
"SELECT users.user_id, user_name FROM users
|
||||||
|
LEFT JOIN user_settings on users.user_id = user_settings.user_id
|
||||||
|
WHERE user_role > 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC"
|
||||||
|
);
|
||||||
|
while ($row = mysqli_fetch_array($sql_project_managers_select)) {
|
||||||
|
$user_id_select = intval($row['user_id']);
|
||||||
|
$user_name_select = nullable_htmlentities($row['user_name']); ?>
|
||||||
|
<option <?php if ($project_manager == $user_id_select) { echo "selected"; } ?> value="<?php echo $user_id_select; ?>"><?php echo $user_name_select; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="edit_project" 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="fa fa-times mr-2"></i>Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../includes/ajax_footer.php";
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../includes/ajax_header.php';
|
||||||
|
|
||||||
|
$quote_id = intval($_GET['id']);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM quotes LEFT JOIN clients ON quote_client_id = client_id WHERE quote_id = $quote_id LIMIT 1");
|
||||||
|
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$quote_id = intval($row['quote_id']);
|
||||||
|
$quote_prefix = nullable_htmlentities($row['quote_prefix']);
|
||||||
|
$quote_number = intval($row['quote_number']);
|
||||||
|
$quote_scope = nullable_htmlentities($row['quote_scope']);
|
||||||
|
$quote_date = nullable_htmlentities($row['quote_date']);
|
||||||
|
$quote_expire = nullable_htmlentities($row['quote_expire']);
|
||||||
|
$quote_discount = floatval($row['quote_discount_amount']);
|
||||||
|
$quote_created_at = nullable_htmlentities($row['quote_created_at']);
|
||||||
|
$quote_category_id = intval($row['quote_category_id']);
|
||||||
|
$client_name = nullable_htmlentities($row['client_name']);
|
||||||
|
|
||||||
|
// Generate the HTML form content using output buffering.
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title text-white"><i class="fas fa-fw fa-comment-dollar mr-2"></i>Editing quote: <span class="text-bold"><?php echo "$quote_prefix$quote_number"; ?></span> - <span class="text"><?php echo $client_name; ?></span></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="quote_id" value="<?php echo $quote_id; ?>">
|
||||||
|
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Quote Date</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="date" max="2999-12-31" value="<?php echo $quote_date; ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Expire <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="expire" max="2999-12-31" value="<?php echo $quote_expire; ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Income Category</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>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$quote_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql)) {
|
||||||
|
$category_id = intval($row['category_id']);
|
||||||
|
$category_name = nullable_htmlentities($row['category_name']);
|
||||||
|
?>
|
||||||
|
<option <?php if ($quote_category_id == $category_id) { echo "selected"; } ?> value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<div class="input-group-append">
|
||||||
|
<a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
||||||
|
</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='text' class='form-control' inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name='quote_discount' placeholder='0.00' value="<?php echo number_format($quote_discount, 2, '.', ''); ?>">
|
||||||
|
</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 $quote_scope; ?>" maxlength="255">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="edit_quote" 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>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../includes/ajax_footer.php";
|
||||||
|
|
@ -0,0 +1,263 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../includes/ajax_header.php';
|
||||||
|
|
||||||
|
$recurring_expense_id = intval($_GET['id']);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM recurring_expenses WHERE recurring_expense_id = $recurring_expense_id LIMIT 1");
|
||||||
|
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$recurring_expense_frequency = intval($row['recurring_expense_frequency']);
|
||||||
|
$recurring_expense_day = intval($row['recurring_expense_day']);
|
||||||
|
$recurring_expense_month = intval($row['recurring_expense_month']);
|
||||||
|
$recurring_expense_last_sent = nullable_htmlentities($row['recurring_expense_last_sent']);
|
||||||
|
$recurring_expense_next_date = nullable_htmlentities($row['recurring_expense_next_date']);
|
||||||
|
$recurring_expense_next_month = date('n', strtotime($row['recurring_expense_next_date']));
|
||||||
|
$recurring_expense_status = intval($row['recurring_expense_status']);
|
||||||
|
$recurring_expense_description = nullable_htmlentities($row['recurring_expense_description']);
|
||||||
|
$recurring_expense_amount = floatval($row['recurring_expense_amount']);
|
||||||
|
$recurring_expense_payment_method = nullable_htmlentities($row['recurring_expense_payment_method']);
|
||||||
|
$recurring_expense_reference = nullable_htmlentities($row['recurring_expense_reference']);
|
||||||
|
$recurring_expense_currency_code = nullable_htmlentities($row['recurring_expense_currency_code']);
|
||||||
|
$recurring_expense_created_at = nullable_htmlentities($row['recurring_expense_created_at']);
|
||||||
|
$recurring_expense_vendor_id = intval($row['recurring_expense_vendor_id']);
|
||||||
|
$recurring_expense_category_id = intval($row['recurring_expense_category_id']);
|
||||||
|
$recurring_expense_account_id = intval($row['recurring_expense_account_id']);
|
||||||
|
$recurring_expense_client_id = intval($row['recurring_expense_client_id']);
|
||||||
|
|
||||||
|
// Generate the HTML form content using output buffering.
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title text-white"><i class="fa fa-fw fa-clock mr-2"></i>Editing recurring expense</h5>
|
||||||
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
<input type="hidden" name="recurring_expense_id" value="<?php echo $recurring_expense_id; ?>">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<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-sync-alt"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="frequency" required>
|
||||||
|
<option value="1" <?php if($recurring_expense_frequency == 1) { echo "selected"; } ?>>Monthly</option>
|
||||||
|
<option value="2" <?php if($recurring_expense_frequency == 2) { echo "selected"; } ?>>Annually</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Month <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>
|
||||||
|
<select class="form-control select2" name="month" required>
|
||||||
|
<option value="">- Select a Month -</option>
|
||||||
|
<option value="1" <?php if($recurring_expense_next_month == 1) { echo "selected"; } ?>>01 - January</option>
|
||||||
|
<option value="2" <?php if($recurring_expense_next_month == 2) { echo "selected"; } ?>>02 - February</option>
|
||||||
|
<option value="3" <?php if($recurring_expense_next_month == 3) { echo "selected"; } ?>>03 - March</option>
|
||||||
|
<option value="4" <?php if($recurring_expense_next_month == 4) { echo "selected"; } ?>>04 - April</option>
|
||||||
|
<option value="5" <?php if($recurring_expense_next_month == 5) { echo "selected"; } ?>>05 - May</option>
|
||||||
|
<option value="6" <?php if($recurring_expense_next_month == 6) { echo "selected"; } ?>>06 - June</option>
|
||||||
|
<option value="7" <?php if($recurring_expense_next_month == 7) { echo "selected"; } ?>>07 - July</option>
|
||||||
|
<option value="8" <?php if($recurring_expense_next_month == 8) { echo "selected"; } ?>>08 - August</option>
|
||||||
|
<option value="9" <?php if($recurring_expense_next_month == 9) { echo "selected"; } ?>>09 - September</option>
|
||||||
|
<option value="10" <?php if($recurring_expense_next_month == 10) { echo "selected"; } ?>>10 - October</option>
|
||||||
|
<option value="11" <?php if($recurring_expense_next_month == 11) { echo "selected"; } ?>>11 - November</option>
|
||||||
|
<option value="12" <?php if($recurring_expense_next_month == 12) { echo "selected"; } ?>>12 - December</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Day <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="text" class="form-control" inputmode="numeric" pattern="(1[0-9]|2[0-8]|[1-9])" name="day" placeholder="Enter a day (1-28)" value="<?php echo $recurring_expense_day; ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Amount <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-dollar-sign"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($recurring_expense_amount, 2, '.', ''); ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Account <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-piggy-bank"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="account" required>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_accounts = mysqli_query($mysqli, "SELECT account_id, account_name, opening_balance, account_archived_at FROM accounts WHERE (account_archived_at > '$recurring_expense_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_accounts)) {
|
||||||
|
$account_id_select = intval($row['account_id']);
|
||||||
|
$account_name_select = nullable_htmlentities($row['account_name']);
|
||||||
|
$opening_balance = floatval($row['opening_balance']);
|
||||||
|
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
||||||
|
if (empty($account_archived_at)) {
|
||||||
|
$account_archived_display = "";
|
||||||
|
} else {
|
||||||
|
$account_archived_display = "Archived - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
|
$total_payments = floatval($row['total_payments']);
|
||||||
|
|
||||||
|
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_revenues);
|
||||||
|
$total_revenues = floatval($row['total_revenues']);
|
||||||
|
|
||||||
|
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_expenses);
|
||||||
|
$total_expenses = floatval($row['total_expenses']);
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<option <?php if ($recurring_expense_account_id == $account_id_select) { ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo "$account_archived_display$account_name_select"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Vendor <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-building"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="vendor" required>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND (vendor_archived_at > '$recurring_expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_select)) {
|
||||||
|
$vendor_id_select = intval($row['vendor_id']);
|
||||||
|
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||||
|
?>
|
||||||
|
<option <?php if ($recurring_expense_vendor_id == $vendor_id_select) { ?> selected <?php } ?> value="<?php echo $vendor_id_select; ?>"><?php echo $vendor_name_select; ?></option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<div class="input-group-append">
|
||||||
|
<a class="btn btn-secondary" href="vendors.php" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Description <strong class="text-danger">*</strong></label>
|
||||||
|
<textarea class="form-control" rows="6" name="description" placeholder="Enter a description" required><?php echo $recurring_expense_description; ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Reference</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-file-alt"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" name="reference" placeholder="Enter a reference" maxlength="200" value="<?php echo $recurring_expense_reference; ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>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-list"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="category" required>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_select = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Expense' AND (category_archived_at > '$recurring_expense_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_select)) {
|
||||||
|
$category_id_select = intval($row['category_id']);
|
||||||
|
$category_name_select = nullable_htmlentities($row['category_name']);
|
||||||
|
?>
|
||||||
|
<option <?php if ($recurring_expense_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">
|
||||||
|
<a class="btn btn-secondary" href="admin_category.php?category=Expense" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (isset($_GET['client_id'])) { ?>
|
||||||
|
<input type="hidden" name="client" value="<?php echo $client_id; ?>">
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
<div class="form-group col-md">
|
||||||
|
<label>Client</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="client">
|
||||||
|
<option value="">- Select Client -</option>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients ORDER BY client_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||||
|
$client_id_select = intval($row['client_id']);
|
||||||
|
$client_name_select = nullable_htmlentities($row['client_name']);
|
||||||
|
?>
|
||||||
|
<option <?php if ($recurring_expense_client_id == $client_id_select) { echo "selected"; } ?> value="<?php echo $client_id_select; ?>"><?php echo $client_name_select; ?></option>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="edit_recurring_expense" 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>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../includes/ajax_footer.php";
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../includes/ajax_header.php';
|
||||||
|
|
||||||
|
$transfer_id = intval($_GET['id']);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT transfer_created_at, expense_date AS transfer_date, expense_amount AS transfer_amount, expense_account_id AS transfer_account_from, revenue_account_id AS transfer_account_to, transfer_expense_id, transfer_revenue_id, transfer_id, transfer_method, transfer_notes FROM transfers, expenses, revenues
|
||||||
|
WHERE transfer_expense_id = expense_id
|
||||||
|
AND transfer_revenue_id = revenue_id
|
||||||
|
AND transfer_id = $transfer_id
|
||||||
|
LIMIT 1"
|
||||||
|
);
|
||||||
|
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$transfer_date = nullable_htmlentities($row['transfer_date']);
|
||||||
|
$transfer_account_from = intval($row['transfer_account_from']);
|
||||||
|
$transfer_account_to = intval($row['transfer_account_to']);
|
||||||
|
$transfer_amount = floatval($row['transfer_amount']);
|
||||||
|
$transfer_method = nullable_htmlentities($row['transfer_method']);
|
||||||
|
$transfer_notes = nullable_htmlentities($row['transfer_notes']);
|
||||||
|
$transfer_created_at = nullable_htmlentities($row['transfer_created_at']);
|
||||||
|
$expense_id = intval($row['transfer_expense_id']);
|
||||||
|
$revenue_id = intval($row['transfer_revenue_id']);
|
||||||
|
|
||||||
|
// Generate the HTML form content using output buffering.
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title"><i class="fas fa-fw fa-exchange-alt mr-2"></i>Editing Transfer</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="transfer_id" value="<?php echo $transfer_id; ?>">
|
||||||
|
<input type="hidden" name="expense_id" value="<?php echo $expense_id; ?>">
|
||||||
|
<input type="hidden" name="revenue_id" value="<?php echo $revenue_id; ?>">
|
||||||
|
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<div class="form-group col-sm">
|
||||||
|
<label>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="date" max="2999-12-31" value="<?php echo $transfer_date; ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-sm">
|
||||||
|
<label>Amount <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-dollar-sign"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" value="<?php echo number_format($transfer_amount, 2, '.', ''); ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Transfer <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-piggy-bank"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="account_from" required>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE (account_archived_at > '$transfer_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_accounts)) {
|
||||||
|
$account_id_select = intval($row['account_id']);
|
||||||
|
$account_name_select = nullable_htmlentities($row['account_name']);
|
||||||
|
$opening_balance = floatval($row['opening_balance']);
|
||||||
|
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
||||||
|
if (empty($account_archived_at)) {
|
||||||
|
$account_archived_display = "";
|
||||||
|
} else {
|
||||||
|
$account_archived_display = "Archived - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
|
$total_payments = floatval($row['total_payments']);
|
||||||
|
|
||||||
|
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_revenues);
|
||||||
|
$total_revenues = floatval($row['total_revenues']);
|
||||||
|
|
||||||
|
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id_select");
|
||||||
|
$row = mysqli_fetch_array($sql_expenses);
|
||||||
|
$total_expenses = floatval($row['total_expenses']);
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<option <?php if ($transfer_account_from == $account_id_select) { echo "selected"; } ?> value="<?php echo $account_id_select; ?>"><?php echo "$account_archived_display$account_name_select"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-arrow-right"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="account_to" required>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql2 = mysqli_query($mysqli, "SELECT * FROM accounts WHERE (account_archived_at > '$transfer_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql2)) {
|
||||||
|
$account_id2 = intval($row['account_id']);
|
||||||
|
$account_name = nullable_htmlentities($row['account_name']);
|
||||||
|
$opening_balance = floatval($row['opening_balance']);
|
||||||
|
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
||||||
|
if (empty($account_archived_at)) {
|
||||||
|
$account_archived_display = "";
|
||||||
|
} else {
|
||||||
|
$account_archived_display = "Archived - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id2");
|
||||||
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
|
$total_payments = floatval($row['total_payments']);
|
||||||
|
|
||||||
|
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id2");
|
||||||
|
$row = mysqli_fetch_array($sql_revenues);
|
||||||
|
$total_revenues = floatval($row['total_revenues']);
|
||||||
|
|
||||||
|
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id2");
|
||||||
|
$row = mysqli_fetch_array($sql_expenses);
|
||||||
|
$total_expenses = floatval($row['total_expenses']);
|
||||||
|
|
||||||
|
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<option <?php if ($transfer_account_to == $account_id2) { echo "selected"; } ?> value="<?php echo $account_id2; ?>"><?php echo "$account_archived_display$account_name"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea class="form-control" rows="5" name="notes" placeholder="Enter some notes"><?php echo $transfer_notes; ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Transfer Method</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-money-check-alt"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="transfer_method">
|
||||||
|
<option value="">- Method of Transfer -</option>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_transfer_method_select = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Payment Method' AND category_archived_at IS NULL ORDER BY category_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_transfer_method_select)) {
|
||||||
|
$category_name_select = nullable_htmlentities($row['category_name']);
|
||||||
|
?>
|
||||||
|
<option <?php if($transfer_method == $category_name_select) { echo "selected"; } ?> ><?php echo $category_name_select; ?></option>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="edit_transfer" 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="fa fa-times mr-2"></i>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../includes/ajax_footer.php";
|
||||||
|
|
@ -164,7 +164,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<i class="fas fa-ellipsis-h"></i>
|
<i class="fas fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" onclick="populateQuoteEditModal(<?php echo $quote_id ?>)" data-target="#editQuoteModal">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_quote_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $quote_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">
|
||||||
|
|
@ -203,6 +207,5 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "modals/quote_add_modal.php";
|
require_once "modals/quote_add_modal.php";
|
||||||
require_once "modals/quote_edit_modal.php";
|
|
||||||
require_once "modals/client_quote_export_modal.php";
|
require_once "modals/client_quote_export_modal.php";
|
||||||
require_once "includes/footer.php";
|
require_once "includes/footer.php";
|
||||||
|
|
|
||||||
11
expenses.php
11
expenses.php
|
|
@ -303,7 +303,16 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<input class="form-check-input bulk-select" type="checkbox" name="expense_ids[]" value="<?php echo $expense_id ?>">
|
<input class="form-check-input bulk-select" type="checkbox" name="expense_ids[]" value="<?php echo $expense_id ?>">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo $receipt_attached; ?> <a class="text-dark" href="#" title="Created: <?php echo $expense_created_at; ?>" data-toggle="modal" data-target="#editExpenseModal<?php echo $expense_id; ?>"><?php echo $expense_date; ?></a></td>
|
<td>
|
||||||
|
<?php echo $receipt_attached; ?>
|
||||||
|
<a class="text-dark" href="#" title="Created: <?php echo $expense_created_at; ?>"
|
||||||
|
data-toggle="ajax-modal"
|
||||||
|
data-modal-size="lg"
|
||||||
|
data-ajax-url="ajax/ajax_expense_edit.php"
|
||||||
|
data-ajax-id="<?php echo $expense_id; ?>">
|
||||||
|
<?php echo $expense_date; ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td><?php echo $vendor_name; ?></td>
|
<td><?php echo $vendor_name; ?></td>
|
||||||
<td><?php echo $category_name; ?></td>
|
<td><?php echo $category_name; ?></td>
|
||||||
<td><?php echo truncate($expense_description, 50); ?></td>
|
<td><?php echo truncate($expense_description, 50); ?></td>
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@
|
||||||
$content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
|
|
||||||
// Return the title and content as a JSON response
|
// Return the title and content as a JSON response
|
||||||
echo json_encode(['title' => $title, 'content' => $content]);
|
echo json_encode(['content' => $content]);
|
||||||
?>
|
?>
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
function populateQuoteEditModal(quote_id) {
|
|
||||||
|
|
||||||
// Send a GET request to ajax.php as ajax.php?quote_get_json_details=true"e_id=NUM
|
|
||||||
jQuery.get(
|
|
||||||
"ajax.php",
|
|
||||||
{quote_get_json_details: 'true', quote_id: quote_id},
|
|
||||||
function(data) {
|
|
||||||
|
|
||||||
// If we get a response from ajax.php, parse it as JSON
|
|
||||||
const response = JSON.parse(data);
|
|
||||||
|
|
||||||
// Access the quote info (one) and categories (multiple)
|
|
||||||
const quote = response.quote[0];
|
|
||||||
const categories = response.categories;
|
|
||||||
|
|
||||||
// Populate the quote modal fields
|
|
||||||
document.getElementById("editQuoteHeaderID").innerText = quote.quote_prefix + quote.quote_number;
|
|
||||||
document.getElementById("editQuoteHeaderClient").innerText = quote.client_name;
|
|
||||||
document.getElementById("editQuoteID").value = quote.quote_id;
|
|
||||||
document.getElementById("editQuoteDate").value = quote.quote_date;
|
|
||||||
document.getElementById("editQuoteExpire").value = quote.quote_expire;
|
|
||||||
document.getElementById("editQuoteScope").value = quote.quote_scope;
|
|
||||||
|
|
||||||
/* DROPDOWNS */
|
|
||||||
|
|
||||||
// Category dropdown
|
|
||||||
var categoryDropdown = document.getElementById("editQuoteCategory");
|
|
||||||
|
|
||||||
// Clear Category dropdown
|
|
||||||
var i, L = categoryDropdown.options.length -1;
|
|
||||||
for (i = L; i >= 0; i--) {
|
|
||||||
categoryDropdown.remove(i);
|
|
||||||
}
|
|
||||||
categoryDropdown[categoryDropdown.length] = new Option('- Category -', '0');
|
|
||||||
|
|
||||||
// Populate dropdown
|
|
||||||
categories.forEach(category => {
|
|
||||||
if (parseInt(category.category_id) == parseInt(quote.quote_category_id)) {
|
|
||||||
// Selected quote
|
|
||||||
categoryDropdown[categoryDropdown.length] = new Option(category.category_name, category.category_id, true, true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
categoryDropdown[categoryDropdown.length] = new Option(category.category_name, category.category_id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
<div class="modal" id="editProjectModal<?php echo $project_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-project-diagram mr-2"></i>Editing Project: <strong><?php echo $project_name; ?></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="project_id" value="<?php echo $project_id; ?>">
|
|
||||||
<div class="modal-body bg-white">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Project Name <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-project-diagram"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" name="name" placeholder="Project Name" maxlength="255" value="<?php echo $project_name; ?>" required autofocus>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Description</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" name="description" placeholder="Description" value="<?php echo $project_description; ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Date Due <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="due_date" value="<?php echo $project_due; ?>" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Manager</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-user-tie"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="project_manager">
|
|
||||||
<option value="0">No Manager</option>
|
|
||||||
<?php
|
|
||||||
$sql_project_managers_select = mysqli_query(
|
|
||||||
$mysqli,
|
|
||||||
"SELECT users.user_id, user_name FROM users
|
|
||||||
LEFT JOIN user_settings on users.user_id = user_settings.user_id
|
|
||||||
WHERE user_role > 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC"
|
|
||||||
);
|
|
||||||
while ($row = mysqli_fetch_array($sql_project_managers_select)) {
|
|
||||||
$user_id_select = intval($row['user_id']);
|
|
||||||
$user_name_select = nullable_htmlentities($row['user_name']); ?>
|
|
||||||
<option <?php if ($project_manager == $user_id_select) { echo "selected"; } ?> value="<?php echo $user_id_select; ?>"><?php echo $user_name_select; ?></option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer bg-white">
|
|
||||||
<button type="submit" name="edit_project" 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="fa fa-times mr-2"></i>Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
<script src="js/quote_edit_modal.js"></script>
|
|
||||||
<div class="modal" id="editQuoteModal" tabindex="-1">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content bg-dark">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title text-white"><i class="fas fa-fw fa-comment-dollar mr-2"></i>Editing quote: <span class="text-bold" id="editQuoteHeaderID"></span> - <span class="text" id="editQuoteHeaderClient"></span></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="quote_id" id="editQuoteID" value="">
|
|
||||||
|
|
||||||
<div class="modal-body bg-white" <?php if (lookupUserPermission('module_sales') <= 1) { echo 'inert'; } ?>>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Quote Date</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="date" id="editQuoteDate" max="2999-12-31" value="" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Expire <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="expire" id="editQuoteExpire" max="2999-12-31" value="" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Income Category</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" id="editQuoteCategory" required>
|
|
||||||
</select>
|
|
||||||
<div class="input-group-append">
|
|
||||||
<a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
|
||||||
</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='text' class='form-control' inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name='quote_discount' placeholder='0.00' value="<?php echo number_format($quote_discount, 2, '.', ''); ?>">
|
|
||||||
</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" id="editQuoteScope" placeholder="Quick description" value="" maxlength="255">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer bg-white">
|
|
||||||
<button type="submit" name="edit_quote" 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>
|
|
||||||
|
|
@ -1,234 +0,0 @@
|
||||||
<div class="modal" id="editRecurringExpenseModal<?php echo $recurring_expense_id; ?>" tabindex="-1">
|
|
||||||
<div class="modal-dialog modal-lg">
|
|
||||||
<div class="modal-content bg-dark">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-clock mr-2"></i>Editing recurring expense</h5>
|
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<form action="post.php" method="post" autocomplete="off">
|
|
||||||
<div class="modal-body bg-white">
|
|
||||||
<input type="hidden" name="recurring_expense_id" value="<?php echo $recurring_expense_id; ?>">
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<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-sync-alt"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="frequency" required>
|
|
||||||
<option value="1" <?php if($recurring_expense_frequency == 1) { echo "selected"; } ?>>Monthly</option>
|
|
||||||
<option value="2" <?php if($recurring_expense_frequency == 2) { echo "selected"; } ?>>Annually</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Month <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>
|
|
||||||
<select class="form-control select2" name="month" required>
|
|
||||||
<option value="">- Select a Month -</option>
|
|
||||||
<option value="1" <?php if($recurring_expense_next_month == 1) { echo "selected"; } ?>>01 - January</option>
|
|
||||||
<option value="2" <?php if($recurring_expense_next_month == 2) { echo "selected"; } ?>>02 - February</option>
|
|
||||||
<option value="3" <?php if($recurring_expense_next_month == 3) { echo "selected"; } ?>>03 - March</option>
|
|
||||||
<option value="4" <?php if($recurring_expense_next_month == 4) { echo "selected"; } ?>>04 - April</option>
|
|
||||||
<option value="5" <?php if($recurring_expense_next_month == 5) { echo "selected"; } ?>>05 - May</option>
|
|
||||||
<option value="6" <?php if($recurring_expense_next_month == 6) { echo "selected"; } ?>>06 - June</option>
|
|
||||||
<option value="7" <?php if($recurring_expense_next_month == 7) { echo "selected"; } ?>>07 - July</option>
|
|
||||||
<option value="8" <?php if($recurring_expense_next_month == 8) { echo "selected"; } ?>>08 - August</option>
|
|
||||||
<option value="9" <?php if($recurring_expense_next_month == 9) { echo "selected"; } ?>>09 - September</option>
|
|
||||||
<option value="10" <?php if($recurring_expense_next_month == 10) { echo "selected"; } ?>>10 - October</option>
|
|
||||||
<option value="11" <?php if($recurring_expense_next_month == 11) { echo "selected"; } ?>>11 - November</option>
|
|
||||||
<option value="12" <?php if($recurring_expense_next_month == 12) { echo "selected"; } ?>>12 - December</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Day <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="text" class="form-control" inputmode="numeric" pattern="(1[0-9]|2[0-8]|[1-9])" name="day" placeholder="Enter a day (1-28)" value="<?php echo $recurring_expense_day; ?>" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Amount <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-dollar-sign"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name="amount" value="<?php echo number_format($recurring_expense_amount, 2, '.', ''); ?>" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Account <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-piggy-bank"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="account" required>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli, "SELECT account_id, account_name, opening_balance, account_archived_at FROM accounts WHERE (account_archived_at > '$recurring_expense_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_accounts)) {
|
|
||||||
$account_id_select = intval($row['account_id']);
|
|
||||||
$account_name_select = nullable_htmlentities($row['account_name']);
|
|
||||||
$opening_balance = floatval($row['opening_balance']);
|
|
||||||
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
|
||||||
if (empty($account_archived_at)) {
|
|
||||||
$account_archived_display = "";
|
|
||||||
} else {
|
|
||||||
$account_archived_display = "Archived - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
|
||||||
$total_payments = floatval($row['total_payments']);
|
|
||||||
|
|
||||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_revenues);
|
|
||||||
$total_revenues = floatval($row['total_revenues']);
|
|
||||||
|
|
||||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_expenses);
|
|
||||||
$total_expenses = floatval($row['total_expenses']);
|
|
||||||
|
|
||||||
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
|
||||||
|
|
||||||
?>
|
|
||||||
<option <?php if ($recurring_expense_account_id == $account_id_select) { ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo "$account_archived_display$account_name_select"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Vendor <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-building"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="vendor" required>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND (vendor_archived_at > '$recurring_expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_select)) {
|
|
||||||
$vendor_id_select = intval($row['vendor_id']);
|
|
||||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
|
||||||
?>
|
|
||||||
<option <?php if ($recurring_expense_vendor_id == $vendor_id_select) { ?> selected <?php } ?> value="<?php echo $vendor_id_select; ?>"><?php echo $vendor_name_select; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<div class="input-group-append">
|
|
||||||
<a class="btn btn-secondary" href="vendors.php" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Description <strong class="text-danger">*</strong></label>
|
|
||||||
<textarea class="form-control" rows="6" name="description" placeholder="Enter a description" required><?php echo $recurring_expense_description; ?></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Reference</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-file-alt"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" name="reference" placeholder="Enter a reference" maxlength="200" value="<?php echo $recurring_expense_reference; ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>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-list"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="category" required>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_select = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Expense' AND (category_archived_at > '$recurring_expense_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_select)) {
|
|
||||||
$category_id_select = intval($row['category_id']);
|
|
||||||
$category_name_select = nullable_htmlentities($row['category_name']);
|
|
||||||
?>
|
|
||||||
<option <?php if ($recurring_expense_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">
|
|
||||||
<a class="btn btn-secondary" href="admin_category.php?category=Expense" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if (isset($_GET['client_id'])) { ?>
|
|
||||||
<input type="hidden" name="client" value="<?php echo $client_id; ?>">
|
|
||||||
<?php } else { ?>
|
|
||||||
|
|
||||||
<div class="form-group col-md">
|
|
||||||
<label>Client</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="client">
|
|
||||||
<option value="">- Client (Optional) -</option>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients ORDER BY client_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
|
||||||
$client_id_select = intval($row['client_id']);
|
|
||||||
$client_name_select = nullable_htmlentities($row['client_name']);
|
|
||||||
?>
|
|
||||||
<option <?php if ($recurring_expense_client_id == $client_id_select) { echo "selected"; } ?> value="<?php echo $client_id_select; ?>"><?php echo $client_name_select; ?></option>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer bg-white">
|
|
||||||
<button type="submit" name="edit_recurring_expense" 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>
|
|
||||||
|
|
@ -1,166 +0,0 @@
|
||||||
<div class="modal" id="editTransferModal<?php echo $transfer_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-exchange-alt mr-2"></i>Editing Transfer</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="transfer_id" value="<?php echo $transfer_id; ?>">
|
|
||||||
<input type="hidden" name="expense_id" value="<?php echo $expense_id; ?>">
|
|
||||||
<input type="hidden" name="revenue_id" value="<?php echo $revenue_id; ?>">
|
|
||||||
|
|
||||||
<div class="modal-body bg-white">
|
|
||||||
|
|
||||||
<div class="form-row">
|
|
||||||
|
|
||||||
<div class="form-group col-sm">
|
|
||||||
<label>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="date" max="2999-12-31" value="<?php echo $transfer_date; ?>" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-sm">
|
|
||||||
<label>Amount <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-dollar-sign"></i></span>
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="amount" placeholder="0.00" value="<?php echo number_format($transfer_amount, 2, '.', ''); ?>" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Transfer <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-piggy-bank"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="account_from" required>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE (account_archived_at > '$transfer_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_accounts)) {
|
|
||||||
$account_id_select = intval($row['account_id']);
|
|
||||||
$account_name_select = nullable_htmlentities($row['account_name']);
|
|
||||||
$opening_balance = floatval($row['opening_balance']);
|
|
||||||
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
|
||||||
if (empty($account_archived_at)) {
|
|
||||||
$account_archived_display = "";
|
|
||||||
} else {
|
|
||||||
$account_archived_display = "Archived - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
|
||||||
$total_payments = floatval($row['total_payments']);
|
|
||||||
|
|
||||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_revenues);
|
|
||||||
$total_revenues = floatval($row['total_revenues']);
|
|
||||||
|
|
||||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id_select");
|
|
||||||
$row = mysqli_fetch_array($sql_expenses);
|
|
||||||
$total_expenses = floatval($row['total_expenses']);
|
|
||||||
|
|
||||||
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
|
||||||
|
|
||||||
?>
|
|
||||||
<option <?php if ($transfer_account_from == $account_id_select) { echo "selected"; } ?> value="<?php echo $account_id_select; ?>"><?php echo "$account_archived_display$account_name_select"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-arrow-right"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="account_to" required>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql2 = mysqli_query($mysqli, "SELECT * FROM accounts WHERE (account_archived_at > '$transfer_created_at' OR account_archived_at IS NULL) ORDER BY account_archived_at ASC, account_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql2)) {
|
|
||||||
$account_id2 = intval($row['account_id']);
|
|
||||||
$account_name = nullable_htmlentities($row['account_name']);
|
|
||||||
$opening_balance = floatval($row['opening_balance']);
|
|
||||||
$account_archived_at = nullable_htmlentities($row['account_archived_at']);
|
|
||||||
if (empty($account_archived_at)) {
|
|
||||||
$account_archived_display = "";
|
|
||||||
} else {
|
|
||||||
$account_archived_display = "Archived - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id2");
|
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
|
||||||
$total_payments = floatval($row['total_payments']);
|
|
||||||
|
|
||||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id2");
|
|
||||||
$row = mysqli_fetch_array($sql_revenues);
|
|
||||||
$total_revenues = floatval($row['total_revenues']);
|
|
||||||
|
|
||||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id2");
|
|
||||||
$row = mysqli_fetch_array($sql_expenses);
|
|
||||||
$total_expenses = floatval($row['total_expenses']);
|
|
||||||
|
|
||||||
$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
|
|
||||||
|
|
||||||
?>
|
|
||||||
<option <?php if ($transfer_account_to == $account_id2) { echo "selected"; } ?> value="<?php echo $account_id2; ?>"><?php echo "$account_archived_display$account_name"; ?> [$<?php echo number_format($balance, 2); ?>]</option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<textarea class="form-control" rows="5" name="notes" placeholder="Enter some notes"><?php echo $transfer_notes; ?></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Transfer Method</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-money-check-alt"></i></span>
|
|
||||||
</div>
|
|
||||||
<select class="form-control select2" name="transfer_method">
|
|
||||||
<option value="">- Method of Transfer -</option>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_transfer_method_select = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Payment Method' AND category_archived_at IS NULL ORDER BY category_name ASC");
|
|
||||||
while ($row = mysqli_fetch_array($sql_transfer_method_select)) {
|
|
||||||
$category_name_select = nullable_htmlentities($row['category_name']);
|
|
||||||
?>
|
|
||||||
<option <?php if($transfer_method == $category_name_select) { echo "selected"; } ?> ><?php echo $category_name_select; ?></option>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-footer bg-white">
|
|
||||||
<button type="submit" name="edit_transfer" 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="fa fa-times mr-2"></i>Cancel</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -197,7 +197,11 @@ if (isset($_GET['project_id'])) {
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<?php if (empty($project_completed_at)) { ?>
|
<?php if (empty($project_completed_at)) { ?>
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editProjectModal<?php echo $project_id; ?>">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_project_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $project_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
@ -406,7 +410,6 @@ if (isset($_GET['project_id'])) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "modals/project_edit_modal.php";
|
|
||||||
require_once "modals/project_ticket_add_modal.php";
|
require_once "modals/project_ticket_add_modal.php";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<?php if (empty($project_completed_at)) { ?>
|
<?php if (empty($project_completed_at)) { ?>
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editProjectModal<?php echo $project_id; ?>">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_project_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $project_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
@ -295,8 +299,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require "modals/project_edit_modal.php";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
10
quote.php
10
quote.php
|
|
@ -175,7 +175,11 @@ if (isset($_GET['quote_id'])) {
|
||||||
<i class="fas fa-ellipsis-v"></i>
|
<i class="fas fa-ellipsis-v"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" onclick="populateQuoteEditModal(<?php echo $quote_id ?>)" data-target="#editQuoteModal">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_quote_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $quote_id; ?>"
|
||||||
|
>
|
||||||
<i class="fa fa-fw fa-edit text-secondary mr-2"></i>Edit
|
<i class="fa fa-fw fa-edit text-secondary mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<?php if (lookupUserPermission("module_sales") >= 2) { ?>
|
<?php if (lookupUserPermission("module_sales") >= 2) { ?>
|
||||||
|
|
@ -532,12 +536,8 @@ if (isset($_GET['quote_id'])) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once "modals/quote_edit_modal.php";
|
|
||||||
|
|
||||||
require_once "modals/quote_to_invoice_modal.php";
|
require_once "modals/quote_to_invoice_modal.php";
|
||||||
|
|
||||||
require_once "modals/quote_copy_modal.php";
|
require_once "modals/quote_copy_modal.php";
|
||||||
|
|
||||||
require_once "modals/quote_note_modal.php";
|
require_once "modals/quote_note_modal.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
quotes.php
11
quotes.php
|
|
@ -199,7 +199,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<i class="fas fa-ellipsis-h"></i>
|
<i class="fas fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" onclick="populateQuoteEditModal(<?php echo $quote_id ?>)" data-target="#editQuoteModal">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_quote_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $quote_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<?php if (lookupUserPermission("module_sales") >= 2) { ?>
|
<?php if (lookupUserPermission("module_sales") >= 2) { ?>
|
||||||
|
|
@ -228,7 +232,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
require "modals/quote_copy_modal.php";
|
require "modals/quote_copy_modal.php";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -244,8 +247,4 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "modals/quote_add_modal.php";
|
require_once "modals/quote_add_modal.php";
|
||||||
|
|
||||||
require_once "modals/quote_edit_modal.php";
|
|
||||||
|
|
||||||
require_once "includes/footer.php";
|
require_once "includes/footer.php";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,16 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editRecurringExpenseModal<?php echo $recurring_expense_id; ?>"><?php echo $recurring_expense_next_date; ?></a></td>
|
<td>
|
||||||
|
<a class="text-dark" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-modal-size = "lg"
|
||||||
|
data-ajax-url = "ajax/ajax_recurring_expense_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $recurring_expense_id; ?>"
|
||||||
|
>
|
||||||
|
<?php echo $recurring_expense_next_date; ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td><?php echo $vendor_name; ?></td>
|
<td><?php echo $vendor_name; ?></td>
|
||||||
<td><?php echo $category_name; ?></td>
|
<td><?php echo $category_name; ?></td>
|
||||||
<td><?php echo truncate($recurring_expense_description, 50); ?></td>
|
<td><?php echo truncate($recurring_expense_description, 50); ?></td>
|
||||||
|
|
@ -197,7 +206,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<i class="fas fa-ellipsis-h"></i>
|
<i class="fas fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editRecurringExpenseModal<?php echo $recurring_expense_id; ?>">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle="ajax-modal"
|
||||||
|
data-modal-size="lg"
|
||||||
|
data-ajax-url="ajax/ajax_recurring_expense_edit.php"
|
||||||
|
data-ajax-id="<?php echo $recurring_expense_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
@ -211,9 +225,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require "modals/recurring_expense_edit_modal.php";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editTransferModal<?php echo $transfer_id; ?>"><?php echo $transfer_date; ?></a></td>
|
<td>
|
||||||
|
<a class="text-dark" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_transfer_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $transfer_id; ?>"
|
||||||
|
>
|
||||||
|
<?php echo $transfer_date; ?>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td><?php echo "$account_from_archived_display$account_name_from"; ?></td>
|
<td><?php echo "$account_from_archived_display$account_name_from"; ?></td>
|
||||||
<td><?php echo "$account_to_archived_display$account_name_to"; ?></td>
|
<td><?php echo "$account_to_archived_display$account_name_to"; ?></td>
|
||||||
<td><?php echo $transfer_method_display; ?></td>
|
<td><?php echo $transfer_method_display; ?></td>
|
||||||
|
|
@ -239,7 +247,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
<i class="fas fa-ellipsis-h"></i>
|
<i class="fas fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTransferModal<?php echo $transfer_id; ?>">
|
<a class="dropdown-item" href="#"
|
||||||
|
data-toggle = "ajax-modal"
|
||||||
|
data-ajax-url = "ajax/ajax_transfer_edit.php"
|
||||||
|
data-ajax-id = "<?php echo $transfer_id; ?>"
|
||||||
|
>
|
||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
@ -253,9 +265,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require "modals/transfer_edit_modal.php";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue