Files
itflow/agent/modals/client/client_export.php
johnnyq b5dc8883f1 Tags stage 1: Admin > Tags rebuilt with the seven kinds in a side nav with counts, each tag shown as it looks with its description, how many records have it (and how many of those are archived) linking to the list filtered by it, and the recurring invoice lines that count by it, search by name or description, sort by name or most used, Current and Archived tabs, Edit, Merge into, Archive, Restore and Delete per tag and bulk merge, archive, restore and delete; new shared tag window with live preview, description, color swatches or any color or hex, searchable icon grid or any Font Awesome icon by name, and kind changeable only while unused; merge window that moves records onto the kept tag once each and repoints recurring seat lines; archiving now works, with archived tags kept on their records but left out of record forms, the tag picker and the list and export filters unless already chosen; tag names unique within their kind, though tags that already share a name can still be saved; delete refused while a recurring seat line counts by the tag; record forms let admins type a new tag inline, replacing the + admin window that reloaded the page and failed for non-admins, and every kind now saves through one tagSetForRecord that keeps only its own kind's tags, each once, fixing the error on a tag sent twice for clients, contacts and assets; typing an archived tag's name restores it, and the picker refuses putting an archived tag on more records; recurring line window keeps its tag once archived; pills pick dark or white text by luminance and carry the description; removes the legacy agent tag handler and tag_model files; database 3.1.3 adds tag_description and normalises stored tag colors to hex and icons to bare names; changelog updated
2026-10-17 13:59:13 -04:00

158 lines
6.3 KiB
PHP

<?php
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_client');
// Pre-filled from the clients page's current filters. Everything here is editable -
// the export runs whatever this form posts, not whatever the page happened to show.
$client_id = intval($_GET['client_id'] ?? 0);
if ($client_id) {
enforceClientAccess();
}
// Search Filter
$q_filter = $_GET['q'] ?? '';
// Showing Filter
$leads_filter = $_GET['leads'] ?? '';
// Industry Filter
$industry_filter = $_GET['industry'] ?? '';
// Referral Filter
$referral_filter = $_GET['referral'] ?? '';
// Tags Filter
$tag_filter = (isset($_GET['tags']) && is_array($_GET['tags'])) ? array_map('intval', $_GET['tags']) : [];
// Date Filter - the all-time sentinels from filter_header.php leave the fields blank
$date_from_filter = (!empty($_GET['dtf']) && $_GET['dtf'] !== '1970-01-01') ? escapeHtml($_GET['dtf']) : '';
$date_to_filter = (!empty($_GET['dtt']) && $_GET['dtt'] !== '2099-12-31') ? escapeHtml($_GET['dtt']) : '';
// Archived Filter
$archived_filter = (isset($_GET['archived']) && $_GET['archived'] == 1) ? 1 : 0;
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-download me-2"></i>Export Clients</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<?php exportTabsNav(); ?>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="modal-body">
<?php exportTabsFiltersOpen(); ?>
<div class="mb-3">
<label>Search</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-search"></i></span>
<input type="text" class="form-control" name="q" value="<?= stripslashes(escapeHtml($q_filter)) ?>" placeholder="Name, contact, address, tag">
</div>
</div>
<div class="mb-3">
<label>Showing</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-user-friends"></i></span>
<select class="form-select select2" name="leads">
<option value="">- Clients -</option>
<option <?php if ($leads_filter === '1') { echo "selected"; } ?> value="1">Leads</option>
</select>
</div>
</div>
<div class="mb-3">
<label>Industry</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-industry"></i></span>
<select class="form-select select2" name="industry">
<option value="">- All Industries -</option>
<?php
$sql_industry_filter = mysqli_query($mysqli, "SELECT DISTINCT client_type FROM clients WHERE client_type != '' ORDER BY client_type ASC");
while ($row = mysqli_fetch_assoc($sql_industry_filter)) {
$filter_industry = escapeHtml($row['client_type']);
?>
<option <?php if ($industry_filter === $row['client_type']) { echo "selected"; } ?> value="<?= $filter_industry ?>"><?= $filter_industry ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="mb-3">
<label>Referral</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-share-alt"></i></span>
<select class="form-select select2" name="referral">
<option value="">- All Referrals -</option>
<?php
$sql_referral_filter = mysqli_query($mysqli, "SELECT DISTINCT client_referral FROM clients WHERE client_referral != '' ORDER BY client_referral ASC");
while ($row = mysqli_fetch_assoc($sql_referral_filter)) {
$filter_referral = escapeHtml($row['client_referral']);
?>
<option <?php if ($referral_filter === $row['client_referral']) { echo "selected"; } ?> value="<?= $filter_referral ?>"><?= $filter_referral ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="mb-3">
<label>Tags</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-tags"></i></span>
<select class="form-select select2" name="tags[]" data-placeholder="- All Tags -" multiple>
<?= tagOptionsHtml('client', $tag_filter) ?>
</select>
</div>
</div>
<div class="mb-3">
<label>Created From</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control" name="dtf" value="<?= $date_from_filter ?>" max="2999-12-31">
</div>
</div>
<div class="mb-3">
<label>Created To</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control" name="dtt" value="<?= $date_to_filter ?>" max="2999-12-31">
</div>
</div>
<div class="mb-3">
<label>Archived</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-archive"></i></span>
<select class="form-select select2" name="archived">
<option <?php if (!$archived_filter) { echo "selected"; } ?> value="0">Active only</option>
<option <?php if ($archived_filter) { echo "selected"; } ?> value="1">Archived only</option>
</select>
</div>
</div>
<?php exportTabsColumns('clients'); ?>
</div>
<div class="modal-footer">
<?php renderExportButtons('export_clients'); ?>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';