Files
itflow/agent/modals/ticket/ticket_edit_asset.php

54 lines
1.9 KiB
PHP

<?php
require_once '../../../includes/modal_header.php';
enforceUserPermission('module_support', 2);
// The ticket, after the module and client checks - or the modal's error
$row = ticketForModal($_GET['id'] ?? 0, 2, true);
$ticket_id = intval($row['ticket_id']);
$client_name = escapeHtml($row['client_name']);
$ticket_prefix = escapeHtml($row['ticket_prefix']);
$ticket_number = intval($row['ticket_number']);
$asset_id = intval($row['ticket_asset_id']);
$client_id = intval($row['ticket_client_id']);
// A ticket with no client is internal work - nobody's assets
if (!$client_id) {
echo json_encode(['error' => 'This ticket has no client, so no assets.']);
exit;
}
// Its assets in one field, for one or many - its main one, and the others
$other_asset_ids = ticketOtherAssetIds($ticket_id, $asset_id);
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-desktop me-2"></i>Assets <small class="ms-1 opacity-75"><?= "$ticket_prefix$ticket_number" ?></small></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="ticket_id" value="<?= $ticket_id ?>">
<div class="modal-body">
<div class="mb-3">
<?= ticketAssetsFieldHtml($client_id, $asset_id, $other_asset_ids) ?>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="edit_ticket_asset" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i>Save</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';