Added Bulk Net Terms editing in clients

This commit is contained in:
johnnyq
2026-03-02 22:43:14 -05:00
parent 918b40afbe
commit 9d9ebe7b9e
3 changed files with 92 additions and 0 deletions

View File

@@ -152,6 +152,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-clock mr-2"></i>Set Hourly Rate
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_edit_net_terms.php"
data-bulk="true">
<i class="fas fa-fw fa-calendar mr-2"></i>Set Net Terms
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/client/client_bulk_edit_industry.php"
data-bulk="true">

View File

@@ -0,0 +1,52 @@
<?php
require_once '../../../includes/modal_header.php';
$client_ids = array_map('intval', $_GET['client_ids'] ?? []);
$count = count($client_ids);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-calendar mr-2"></i>Set Net Terms 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 ($client_ids as $client_id) { ?><input type="hidden" name="client_ids[]" value="<?= $client_id ?>"><?php } ?>
<div class="modal-body">
<div class="form-group">
<label>Invoice Net Terms</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="net_terms">
<option value="">- Net Terms -</option>
<?php foreach ($net_terms_array as $net_term_value => $net_term_name) { ?>
<option value="<?php echo $net_term_value; ?>">
<?php echo $net_term_name; ?>
</option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="bulk_edit_client_net_terms" 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>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -945,6 +945,40 @@ if (isset($_POST['bulk_edit_client_hourly_rate'])) {
}
if (isset($_POST['bulk_edit_client_net_terms'])) {
validateCSRFToken($_POST['csrf_token']);
enforceUserPermission('module_client', 2);
$net_terms = intval($_POST['net_terms']);
if (isset($_POST['client_ids'])) {
$count = count($_POST['client_ids']);
foreach($_POST['client_ids'] as $client_id) {
$client_id = intval($client_id);
$sql = mysqli_query($mysqli,"SELECT client_name FROM clients WHERE client_id = $client_id");
$row = mysqli_fetch_assoc($sql);
$client_name = sanitizeInput($row['client_name']);
mysqli_query($mysqli,"UPDATE clients SET client_net_terms = $net_terms WHERE client_id = $client_id");
logAction("Client", "Edit", "$session_name set net terms to $net_terms days for $client_name", $client_id);
}
logAction("Client", "Bulk Edit", "$session_name set the net terms to $net_terms days for $count client(s)", $client_id);
flash_alert("Set Net Term to <strong>$net_terms days</strong> for <strong>$count</strong> client(s)");
}
redirect();
}
if (isset($_POST['bulk_assign_client_tags'])) {
validateCSRFToken($_POST['csrf_token']);