[Feature] Create Recurring Ticket - Add Asset Type Optgroups on asset selection along with make, model and assigned contact
This commit is contained in:
@@ -190,13 +190,17 @@
|
|||||||
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" name="frequency" required>
|
<select class="form-control select2" name="frequency" required>
|
||||||
<option>Three Days</option>
|
<optgroup label="Days">
|
||||||
<option>Weekly</option>
|
<option>Three Days</option>
|
||||||
<option>Biweekly</option>
|
<option>Weekly</option>
|
||||||
<option>Monthly</option>
|
<option>Biweekly</option>
|
||||||
<option>Quarterly</option>
|
</optgroup>
|
||||||
<option>Biannually</option>
|
<optgroup label="Months">
|
||||||
<option>Annually</option>
|
<option>Monthly</option>
|
||||||
|
<option>Quarterly</option>
|
||||||
|
<option>Biannually</option>
|
||||||
|
<option>Annually</option>
|
||||||
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -225,21 +229,46 @@
|
|||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" name="asset">
|
<select class="form-control select2" name="asset">
|
||||||
<option value="0">- None -</option>
|
<option value="0">- None -</option>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
|
// Query assets ordered by type, then name
|
||||||
|
$sql_assets = mysqli_query($mysqli, "
|
||||||
|
SELECT asset_id, asset_name, asset_type, asset_make, asset_model, contact_name
|
||||||
|
FROM assets
|
||||||
|
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||||
|
WHERE asset_client_id = $client_id
|
||||||
|
AND asset_archived_at IS NULL
|
||||||
|
ORDER BY asset_type ASC, asset_name ASC
|
||||||
|
");
|
||||||
|
|
||||||
|
$current_type = null; // Track which optgroup we're in
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||||
$asset_id_select = intval($row['asset_id']);
|
$asset_id_select = intval($row['asset_id']);
|
||||||
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
||||||
|
$asset_type_select = nullable_htmlentities($row['asset_type']);
|
||||||
|
$asset_make_select = nullable_htmlentities($row['asset_make']);
|
||||||
|
$asset_model_select = nullable_htmlentities($row['asset_model']);
|
||||||
|
$contact_name_select = nullable_htmlentities($row['contact_name']);
|
||||||
|
|
||||||
|
// Start new optgroup if type changes
|
||||||
|
if ($asset_type_select !== $current_type) {
|
||||||
|
if ($current_type !== null) echo "</optgroup>";
|
||||||
|
echo "<optgroup label=\"" . ($asset_type_select ?: 'Uncategorized') . "\">";
|
||||||
|
$current_type = $asset_type_select;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build full display
|
||||||
|
$full_name = $asset_name_select . ($asset_make_select ? " - $asset_make_select" . ($asset_model_select ? " $asset_model_select" : '') : '')
|
||||||
|
. ($contact_name_select ? " - ($contact_name_select)" : '');
|
||||||
?>
|
?>
|
||||||
<option value="<?php echo $asset_id_select; ?>"
|
|
||||||
<?php if (isset($_GET['asset_id']) && $asset_id_select == $_GET['asset_id']) { echo "selected"; }
|
|
||||||
?>
|
|
||||||
|
|
||||||
><?php echo $asset_name_select; ?>
|
<option value="<?= $asset_id_select ?>"><?= $full_name ?></option>
|
||||||
</option>
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php }
|
||||||
|
|
||||||
|
if ($current_type_select !== null) echo "</optgroup>";
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -252,23 +281,51 @@
|
|||||||
</div>
|
</div>
|
||||||
<select class="form-control select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
|
<select class="form-control select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<?php
|
|
||||||
|
|
||||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
|
<?php
|
||||||
|
// Query assets ordered by type then name
|
||||||
|
$sql_assets = mysqli_query($mysqli, "
|
||||||
|
SELECT asset_id, asset_name, asset_type, asset_make, asset_model, contact_name
|
||||||
|
FROM assets
|
||||||
|
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||||
|
WHERE asset_client_id = $client_id
|
||||||
|
AND asset_archived_at IS NULL
|
||||||
|
ORDER BY asset_type ASC, asset_name ASC
|
||||||
|
");
|
||||||
|
|
||||||
|
$current_type = null;
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_assets)) {
|
while ($row = mysqli_fetch_array($sql_assets)) {
|
||||||
$asset_id_select = intval($row['asset_id']);
|
$asset_id_select = intval($row['asset_id']);
|
||||||
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
$asset_name_select = nullable_htmlentities($row['asset_name']);
|
||||||
$asset_contact_name_select = nullable_htmlentities($row['contact_name']);
|
$asset_type_select = nullable_htmlentities($row['asset_type']);
|
||||||
?>
|
$asset_make_select = nullable_htmlentities($row['asset_make']);
|
||||||
<option value="<?php echo $asset_id_select; ?>"
|
$asset_model_select = nullable_htmlentities($row['asset_model']);
|
||||||
><?php echo "$asset_name_select - $asset_contact_name_select"; ?>
|
$contact_name_select = nullable_htmlentities($row['contact_name']);
|
||||||
</option>
|
|
||||||
|
|
||||||
<?php } ?>
|
// Start new optgroup if type changes
|
||||||
|
if ($asset_type_select !== $current_type) {
|
||||||
|
if ($current_type !== null) echo "</optgroup>";
|
||||||
|
echo "<optgroup label=\"" . ($asset_type_select ?: 'Uncategorized') . "\">";
|
||||||
|
$current_type = $asset_type_select;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build full display
|
||||||
|
$full_name = $asset_name_select . ($asset_make_select ? " - $asset_make_select" . ($asset_model_select ? " $asset_model_select" : '') : '')
|
||||||
|
. ($contact_name_select ? " - ($contact_name_select)" : '');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<option value="<?= $asset_id_select ?>"><?= $full_name ?></option>
|
||||||
|
|
||||||
|
<?php }
|
||||||
|
|
||||||
|
if ($current_type !== null) echo "</optgroup>";
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user