Added data-bulk to the ajax modal to allow for bulk GET collection of selected ids that have a class of bulk-select, converted expense and client bulk modals to use the the new ajax-modal

This commit is contained in:
johnnyq 2025-11-06 11:26:08 -05:00
parent 293a2b800e
commit 0cf1e338c2
20 changed files with 985 additions and 773 deletions

View File

@ -5,6 +5,7 @@ require_once '../../../includes/modal_header.php';
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-cube mr-2"></i>New License Template</h5>
<button type="button" class="close text-white" data-dismiss="modal">

View File

@ -137,27 +137,41 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-layer-group"></i><span class="d-none d-sm-inline ml-2">Action</span> (<span id="selectedCount">0</span>)
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAddTicketModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_add_ticket.php"
data-modal-size="lg"
data-bulk="true">
<i class="fas fa-fw fa-life-ring mr-2"></i>Open Tickets
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditHourlyRateModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_edit_hourly_rate.php"
data-bulk="true">
<i class="fas fa-fw fa-clock mr-2"></i>Set Hourly Rate
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditIndustryModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_edit_industry.php"
data-bulk="true">
<i class="fas fa-fw fa-briefcase mr-2"></i>Set Industry
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditReferralModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_edit_referral.php"
data-bulk="true">
<i class="fas fa-fw fa-link mr-2"></i>Set Referral
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignTagsModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_assign_tags.php"
data-bulk="true">
<i class="fas fa-fw fa-tags mr-2"></i>Assign Tags
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkSendEmailModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_email.php"
data-modal-size="lg"
data-bulk="true">
<i class="fas fa-fw fa-paper-plane mr-2"></i>Send Email
</a>
<?php if ($archived) { ?>
@ -268,7 +282,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</form>
</div>
<form id="bulkActions" action="post.php" method="post" enctype="multipart/form-data">
<form id="bulkActions" action="post.php" method="post">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<div class="table-responsive-sm">
<table class="table table-hover mb-0 text-nowrap">
@ -600,14 +614,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</tbody>
</table>
</div>
<?php
require_once "modals/client/client_bulk_edit_industry.php";
require_once "modals/client/client_bulk_edit_referral.php";
require_once "modals/client/client_bulk_edit_hourly_rate.php";
require_once "modals/client/client_bulk_assign_tags.php";
require_once "modals/client/client_bulk_add_ticket.php";
require_once "modals/client/client_bulk_email.php";
?>
</form>
<!-- Ends Card Body -->
<?php require_once "../includes/filter_footer.php"; ?>

View File

@ -94,23 +94,30 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditCategoryModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/expense/expense_bulk_edit_category.php"
data-bulk="true">
<i class="fas fa-fw fa-list mr-2"></i>Set Category
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditAccountModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/expense/expense_bulk_edit_account.php"
data-bulk="true">
<i class="fas fa-fw fa-piggy-bank mr-2"></i>Set Account
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditClientModal">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/expense/expense_bulk_edit_client.php"
data-bulk="true">
<i class="fas fa-fw fa-user mr-2"></i>Set Client
</a>
<?php if ($session_user_role == 3) { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger text-bold"
type="submit" form="bulkActions" name="bulk_delete_expenses">
<a class="dropdown-item text-danger text-bold ajax-modal" href="#"
data-modal-url="modals/expense/expense_bulk_delete.php"
data-bulk="true">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</button>
</a>
<?php } ?>
</div>
</div>
@ -193,8 +200,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div>
</form>
<hr>
<form id="bulkActions" action="post.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover">
@ -281,7 +286,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<tr>
<td class="pr-0 bg-light">
<div class="form-check">
<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="selected_ids[]" value="<?= $expense_id ?>">
</div>
</td>
<td>
@ -345,18 +350,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</tbody>
</table>
</div>
<?php require_once "modals/expense/expense_bulk_edit_category.php"; ?>
<?php require_once "modals/expense/expense_bulk_edit_account.php"; ?>
<?php require_once "modals/expense/expense_bulk_edit_client.php"; ?>
</form>
<?php require_once "../includes/filter_footer.php";
?>
<?php require_once "../includes/filter_footer.php"; ?>
</div>
</div>
<script src="../js/bulk_actions.js"></script>
<script src="/js/bulk_actions.js"></script>
<?php
require_once "modals/expense/expense_export.php";
require_once "../includes/footer.php";

View File

@ -1,18 +1,32 @@
<div class="modal" id="bulkAddTicketModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>Creating Tickets for Clients</h5>
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>New Tickets for <strong><?= $count ?></strong> Client(s)</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
<label>Subject <strong class="text-danger">*</strong></label>
<input type="text" class="form-control" name="bulk_subject" placeholder="Enter a subject" maxlength="200">
<input type="text" class="form-control" name="bulk_subject" placeholder="Enter a subject" maxlength="200" required>
</div>
<div class="form-group">
@ -28,7 +42,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
</div>
<select class="form-control select2" name="bulk_priority">
<select class="form-control select2" name="bulk_priority" required>
<option>Low</option>
<option>Medium</option>
<option>High</option>
@ -131,7 +145,7 @@
<button type="submit" name="bulk_add_client_ticket" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Create</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>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,16 +1,29 @@
<div class="modal" id="bulkAssignTagsModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-tags mr-2"></i>Bulk Assign Tags</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-tags mr-2"></i>Assign Tags for <strong><?= $count ?></strong> Clients</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<input type="hidden" name="bulk_remove_tags" value="0">
<div class="modal-body">
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" name="bulk_remove_tags" value="1">
<label class="form-check-label text-danger">Remove Existing Tags</label>
@ -43,6 +56,7 @@
<button type="submit" name="bulk_assign_client_tags" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Assign</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,13 +1,26 @@
<div class="modal" id="bulkEditHourlyRateModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-clock mr-2"></i>Bulk Edit Hourly Rate</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-clock mr-2"></i>Set Hourly Rate for <strong><?= $count ?></strong> Client(s)</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
@ -16,7 +29,7 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div>
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="bulk_rate" placeholder="0.00">
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="bulk_rate" placeholder="0.00" required>
</div>
</div>
@ -26,6 +39,7 @@
<button type="submit" name="bulk_edit_client_hourly_rate" 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>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,13 +1,26 @@
<div class="modal" id="bulkEditIndustryModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-briefcase mr-2"></i>Bulk Edit Industry</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-briefcase mr-2"></i>Set Industry for <strong><?= $count ?></strong> Client(s)</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
@ -16,16 +29,17 @@
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-briefcase"></i></span>
</div>
<input type="text" class="form-control" name="bulk_industry" placeholder="Enter an Industry" maxlength="200">
<input type="text" class="form-control" name="bulk_industry" placeholder="Enter an Industry" maxlength="200" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="bulk_edit_client_industry" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
<button type="submit" name="bulk_edit_client_industry" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Set</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,13 +1,25 @@
<div class="modal" id="bulkEditReferralModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-link mr-2"></i>Bulk Edit Referral</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-link mr-2"></i>Set Referral for <strong><?= $count ?></strong> Clients</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
@ -19,7 +31,6 @@
<select class="form-control select2" name="bulk_referral">
<option value="">- Select a Referral -</option>
<?php
$referral_sql = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Referral' AND category_archived_at IS NULL ORDER BY category_name ASC");
while ($row = mysqli_fetch_array($referral_sql)) {
$referral = nullable_htmlentities($row['category_name']); ?>
@ -39,9 +50,10 @@
</div>
<div class="modal-footer">
<button type="submit" name="bulk_edit_client_referral" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
<button type="submit" name="bulk_edit_client_referral" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Set</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,13 +1,26 @@
<div class="modal" id="bulkSendEmailModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-envelope-open mr-2"></i>Bulk Send Email</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-envelope-open mr-2"></i>Send Emails to <strong><?= $count ?></strong> Client(s)</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?><input type="hidden" name="client_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<label>From Email / <span class="text-secondary">Display Name</span></label>
@ -32,7 +45,6 @@
</div>
</div>
<label>Recipients</label>
<div class="form-row">
@ -95,6 +107,7 @@
<button type="submit" name="bulk_send_client_email" class="btn btn-primary text-bold"><i class="fas fa-paper-plane mr-2"></i>Send</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -0,0 +1,43 @@
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
// Generate the HTML form content using output buffering.
ob_start();
?>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?> <input type="hidden" name="expense_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body text-center">
<div class="mb-4" style="text-align: center;">
<i class="far fa-10x fa-times-circle text-danger mb-3 mt-3"></i>
<h2>Are you really, really, really sure?</h2>
<h6 class="mb-4 text-secondary">This will permanently delete the selected expense<?= $count == 1 ? '' : 's' ?>. and ALL associated data</b>?<br><br>This process cannot be undone.</h6>
<button type="button" class="btn btn-outline-secondary btn-lg px-5 mr-4" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger btn-lg px-5">Yes, Delete!</button>
</div>
<p class="mb-2">
This will permanently delete the selected expense<?= $count == 1 ? '' : 's' ?>.
</p>
<p class="text-muted small mb-0">
This action cannot be undone.
</p>
<button type="submit" name="bulk_delete_expenses" class="btn btn-danger btn-lg px-5"><i class="fa fa-fw fa-trash mr-2"></i>Delete</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/modal_footer.php';

View File

@ -1,12 +1,25 @@
<div class="modal" id="bulkEditAccountModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-piggy-bank mr-2"></i>Bulk Set Account</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-piggy-bank mr-2"></i>Set Account for <strong><?= $count ?></strong> Expense<?= $count == 1 ? '' : 's' ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?> <input type="hidden" name="expense_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
@ -53,6 +66,7 @@
<button type="submit" name="bulk_edit_expense_account" class="btn btn-primary text-bold"><i class="fa fa-fw fa-check mr-2"></i>Set</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,13 +1,31 @@
<div class="modal" id="bulkEditCategoryModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-list mr-2"></i>Bulk Set Category</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-list mr-2"></i>Set Category: <strong><?= $count ?></strong> Expense<?= $count == 1 ? '' : 's' ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<div class="modal-body">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php
foreach ($selected_ids as $id) { ?>
<input type="hidden" name="expense_ids[]" value="<?= $id ?>">
<?php
}
?>
<div class="form-group">
<label>Category <strong class="text-danger">*</strong></label>
@ -15,7 +33,8 @@
<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="bulk_category_id">
<select class="form-control select2" name="bulk_category_id" data-placeholder="- Select a Category -" required>
<option></option>
<?php
$sql = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Expense' AND category_archived_at IS NULL ORDER BY category_name ASC");
@ -37,6 +56,7 @@
<button type="submit" name="bulk_edit_expense_category" class="btn btn-primary text-bold"><i class="fa fa-fw fa-check mr-2"></i>Set</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -1,14 +1,31 @@
<div class="modal" id="bulkEditClientModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<?php
require_once '../../../includes/modal_header.php';
$selected_ids = array_map('intval', $_GET['selected_ids'] ?? []);
$count = count($selected_ids);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-user mr-2"></i>Bulk Set Client</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-user mr-2"></i>Set Client: <strong><?= $count ?></strong> Expense<?= $count == 1 ? '' : 's' ?></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<?php foreach ($selected_ids as $id) { ?> <input type="hidden" name="expense_ids[]" value="<?= $id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
<label>Client</label>
<div class="input-group">
@ -38,6 +55,7 @@
<button type="submit" name="bulk_edit_expense_client" class="btn btn-primary text-bold"><i class="fa fa-fw fa-check mr-2"></i>Set</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@ -38,6 +38,7 @@ ob_start();
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="modal-body">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<input type="hidden" name="expense_id" value="<?php echo $expense_id; ?>">
<div class="form-row">
@ -237,8 +238,4 @@ ob_start();
</form>
<?php
require_once '../../../includes/modal_footer.php';
?>

View File

@ -2,8 +2,7 @@
require_once '../../../includes/modal_header.php';
$ticket_id = intval($_GET['ticket_id'] ?? 0);
$client_id = intval(getFieldById('tickets', $ticket_id, 'ticket_client_id') ?? 0);
$ticket_id = intval($_GET['ticket_id']);
ob_start();
@ -16,7 +15,6 @@ ob_start();
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="modal-body">
<div class="form-group">

View File

@ -2,11 +2,17 @@
require_once '../../../includes/modal_header.php';
$ticket_id = intval($_GET['ticket_id']);
$current_client_id = intval(getFieldById('tickets', $ticket_id, 'ticket_client_id'));
$ticket_prefix = nullable_htmlentities(getFieldById('tickets', $ticket_id, 'ticket_prefix'));
$ticket_number = nullable_htmlentities(getFieldById('tickets', $ticket_id, 'ticket_number'));
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']);
$client_id = intval($row['ticket_client_id']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
@ -34,7 +40,7 @@ ob_start();
$client_id_select = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']);
?>
<option value="<?= $client_id_select ?>" <?php if ($current_client_id == $client_id_select) echo 'selected'; ?>>
<option value="<?= $client_id_select ?>" <?php if ($client_id == $client_id_select) echo 'selected'; ?>>
<?= $client_name ?>
</option>
<?php } ?>

View File

@ -1,17 +1,23 @@
<?php
require_once '../../../includes/modal_header.php';
$ticket_id = intval($_GET['ticket_id'] ?? 0);
$ticket_id = intval($_GET['ticket_id']);
$client_id = intval(getFieldById('tickets', $ticket_id, 'ticket_client_id') ?? 0);
$vendor_id = intval(getFieldById('tickets', $ticket_id, 'ticket_vendor_id') ?? 0);
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$ticket_prefix = nullable_htmlentities($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']);
$vendor_id = intval($row['ticket_vendor_id']);
$client_id = intval($row['ticket_client_id']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-building mr-2"></i>Editing ticket Vendor</h5>
<h5 class="modal-title"><i class="fa fa-fw fa-building mr-2"></i>Editing Vendor: <strong><?= "$ticket_prefix$ticket_number" ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>

View File

@ -443,22 +443,9 @@ if (isset($_POST['add_ticket_watcher'])) {
enforceUserPermission('module_support', 2);
$ticket_id = intval($_POST['ticket_id']);
$client_id = intval($_POST['client_id']);
$watcher_emails = preg_split("/,| |;/", $_POST['watcher_email']); // Split on comma, semicolon or space, we sanitize later
$notify = intval($_POST['watcher_notify'] ?? 0);
// Process each watcher in list
foreach ($watcher_emails as $watcher_email) {
if (filter_var($watcher_email, FILTER_VALIDATE_EMAIL)) {
$watcher_email = sanitizeInput($watcher_email);
mysqli_query($mysqli, "INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id");
// Notify watcher
if ($notify && !empty($config_smtp_host)) {
// Get contact/ticket details
$sql = mysqli_query($mysqli, "SELECT ticket_prefix, ticket_number, ticket_category, ticket_subject, ticket_details, ticket_priority, ticket_status_name, ticket_url_key, ticket_created_by, ticket_assigned_to, ticket_client_id FROM tickets
LEFT JOIN clients ON ticket_client_id = client_id
@ -486,6 +473,20 @@ if (isset($_POST['add_ticket_watcher'])) {
$company_name = sanitizeInput($row['company_name']);
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code']));
// Process each watcher in list
foreach ($watcher_emails as $watcher_email) {
if (filter_var($watcher_email, FILTER_VALIDATE_EMAIL)) {
$watcher_email = sanitizeInput($watcher_email);
mysqli_query($mysqli, "INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id");
// Notify watcher
if ($notify && !empty($config_smtp_host)) {
// Email content
$data = []; // Queue array

View File

@ -1,23 +1,33 @@
// Ajax Modal Load Script
//
/* Example Triggering -->
<button type="button"
class="btn btn-primary ajax-modal" // Triggers the AJAX Modal
data-modal-size = "lg" // Optional: Defaults to md
data-modal-url="modals/contact/contact_edit.php?id=id">
Edit Contact
</button>
*/
$(document).on('click', '.ajax-modal', function (e) {
e.preventDefault();
const $trigger = $(this);
const modalUrl = $trigger.data('modal-url');
let modalUrl = $trigger.data('modal-url');
const modalSize = $trigger.data('modal-size') || 'md';
const modalId = 'ajaxModal_' + new Date().getTime();
// -------- Optional bulk mode (activated via data-bulk="true") --------
if ($trigger.data('bulk') === true || $trigger.data('bulk') === 'true') {
const selector = $trigger.data('bulk-selector') || '.bulk-select:checked';
const param = $trigger.data('bulk-param') || 'selected_ids[]';
const ids = Array.from(document.querySelectorAll(selector)).map(cb => cb.value);
if (!ids.length) {
alert('Please select at least one item.');
return; // abort opening modal
}
// Merge ids into existing query string safely
const urlObj = new URL(modalUrl, window.location.href);
ids.forEach(id => urlObj.searchParams.append(param, id));
// Preserve path + updated query (avoid absolute origin for relative AJAX)
modalUrl = urlObj.pathname + (urlObj.search ? '?' + urlObj.searchParams.toString() : '');
}
// --------------------------------------------------------------------
// Show loading spinner while fetching content
const loadingSpinner = `
<div id="modal-loading-spinner" class="text-center p-5">
@ -38,7 +48,6 @@ $(document).on('click', '.ajax-modal', function (e) {
return;
}
// Build modal wrapper
const modalHtml = `
<div class="modal fade" id="${modalId}" tabindex="-1">
<div class="modal-dialog modal-${modalSize}">
@ -52,7 +61,6 @@ $(document).on('click', '.ajax-modal', function (e) {
const $modal = $('#' + modalId);
$modal.modal('show');
// Remove modal after it's closed
$modal.on('hidden.bs.modal', function () {
$(this).remove();
});

View File

@ -1,40 +1,54 @@
// Allow selecting and editing multiple records at once
// bulk_actions.js
// Allow selecting and editing multiple records at once (no <form> dependency)
var form = document.getElementById("bulkActions"); // Get the form element by its id
var checkboxes = form.querySelectorAll('input[type="checkbox"].bulk-select'); // Select only checkboxes with class "bulk-select"
var selectedCount = document.getElementById("selectedCount");
var selectAllCheckbox = document.getElementById("selectAllCheckbox"); // The "select all" checkbox
// Event listener for each checkbox
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].addEventListener("click", updateSelectedCount);
// --- Helpers ---
function getCheckboxes() {
// Always query fresh in case rows are re-rendered
return Array.from(document.querySelectorAll('input[type="checkbox"].bulk-select'));
}
function getSelectedIds() {
return getCheckboxes()
.filter(cb => cb.checked)
.map(cb => cb.value);
}
// Function to update the count of selected checkboxes
function updateSelectedCount() {
var count = 0;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
count++;
}
}
selectedCount.textContent = count; // Display the count
// Show or hide the multi-action button
document.getElementById("bulkActionButton").hidden = count === 0;
const count = getSelectedIds().length;
const selectedCountEl = document.getElementById('selectedCount');
if (selectedCountEl) {
selectedCountEl.textContent = count;
}
// Function to check/uncheck all checkboxes
const bulkBtn = document.getElementById('bulkActionButton');
if (bulkBtn) {
bulkBtn.hidden = count === 0;
}
}
// --- Select All Handling ---
function checkAll(source) {
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = source.checked;
}
updateSelectedCount(); // Update the count after changing checkbox states
getCheckboxes().forEach(cb => {
cb.checked = source.checked;
});
updateSelectedCount();
}
// Event listener for the "select all" checkbox
// Wire select-all checkbox if present
const selectAllCheckbox = document.getElementById('selectAllCheckbox');
if (selectAllCheckbox) {
selectAllCheckbox.addEventListener("click", function() {
selectAllCheckbox.addEventListener('click', function () {
checkAll(this);
});
}
// --- Per-row Checkbox Handling ---
// Use event delegation so it still works if table rows are re-rendered
document.addEventListener('click', function (e) {
const cb = e.target.closest('input[type="checkbox"].bulk-select');
if (!cb) return;
updateSelectedCount();
});
// --- Initialize count on page load ---
document.addEventListener('DOMContentLoaded', updateSelectedCount);