| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- use App\Enums\DocumentTypes;
- use App\Enums\TicketPriorities;
- use App\Enums\TicketStatuses;
- use App\Helpers\HtmlHelper;
- /**
- * @var Ticket $ticket
- */
- $core = Core::getInstance();
- $user = $core->getUser();
- $comments = $ticket->getComments();
- $ticket_details = array_shift($comments);
- $attachments = $ticket_details->getAttachments();
- $creator = $ticket->getCreator();
- $sale = $ticket->getSale();
- $aru = $ticket->getAruDocument();
- $render_data_row = static function(string $title, string $html): void {
- ?>
- <div class="row my-1">
- <div class="col-6 col-md-3">
- <strong><?=htmlspecialchars($title)?></strong>
- </div>
- <div class="col-6 col-md">
- <?=$html?>
- </div>
- </div>
- <?php
- };
- ?>
- <div class="card mb-3">
- <div class="card-header">
- <?=htmlspecialchars(__("Ticket #%d", $ticket->id))?>
- <span class="float-end badge bg-primary">
- <?=htmlspecialchars($ticket->getDisplayStatus())?>
- </span>
- </div>
- <div class="card-body">
- <h5>
- <?=htmlspecialchars($ticket->subject)?>
- </h5>
- <div>
- <i class="fa fa-fw fa-user-circle"></i>
- <?=htmlspecialchars($creator->getDisplayName())?> (<?=htmlspecialchars($creator->email)?>)
- </div>
- <div>
- <i class="fa fa-fw fa-map-marker"></i>
- <?=htmlspecialchars($ticket->getLocation()->name)?>
- </div>
- </div>
- <div class="card-body border-top">
- <h5><?=htmlspecialchars(__("Details"))?></h5>
- <?=$ticket_details->getHtml()?>
- </div>
- <?php
- if($attachments) {
- ?>
- <div class="card-body border-top">
- <h5><?=htmlspecialchars(__("Attachments"))?></h5>
- <?php
- foreach($attachments as $attachment) {
- $attachment->renderButton();
- }
- ?>
- </div>
- <?php
- }
- ?>
- <div class="card-body border-top">
- <h5><?=htmlspecialchars(__("Other Details"))?></h5>
- <div class="row">
- <div class="col-xl">
- <?php
- $render_data_row(__("Assigned:"), htmlspecialchars($ticket->getDisplayAssignedTo()));
- $render_data_row(__("Priority:"), $ticket->getPriorityBadgeHtml());
- $render_data_row(__("Contact Name:"), htmlspecialchars($ticket->contact_name));
- ?>
- </div>
- <div class="col-xl">
- <?php
- if($sale) {
- $render_data_row(__("Lead No."), sprintf('<a href="%s">%s</a>', htmlspecialchars($sale->getUrl()), $sale->getNumber()));
- }
- if($aru) {
- $render_data_row(__("ARU No."), sprintf('<a href="%s">%s</a>', htmlspecialchars($aru->getUrl()), $aru->number));
- }
- $render_data_row(__("Updated:"), $user->formatDateTime($ticket->getDateTimeUpdated()));
- $render_data_row(__("Created:"), $user->formatDateTime($ticket->getDateTimeCreated()));
- ?>
- </div>
- </div>
- </div>
- <div class="card-body border-top">
- <h5><?=htmlspecialchars(__("Update Ticket"))?></h5>
- <form method="post">
- <div class="row g-3">
- <div class="col-md-6 col-lg">
- <div class="mb-3">
- <label class="form-label" for="assignee"><?=htmlspecialchars(__("Assignee"))?></label>
- <select class="form-select" name="assignee" id="assignee">
- <option value=""><?=htmlspecialchars(__("Unassigned"))?></option>
- <?php
- HtmlHelper::renderOptions(User::getStaffOptions(), $ticket->assigned_user_id);
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-6 col-lg">
- <div class="mb-3">
- <label class="form-label" for="priority"><?=htmlspecialchars(__("Priority"))?></label>
- <select class="form-select" name="priority" id="priority">
- <?php
- HtmlHelper::renderOptions(TicketPriorities::options(), $ticket->priority);
- ?>
- </select>
- </div>
- </div>
- <div class="col-md-6 col-lg">
- <div class="mb-3">
- <label class="form-label" for="sale-number"><?=htmlspecialchars(__("Lead No."))?></label>
- <input class="form-control" type="number" name="sale_number" id="sale-number" value="<?=$sale ? $sale->getNumber() : ""?>" placeholder="<?=htmlspecialchars(__("Type number"))?>" />
- </div>
- </div>
- <div class="col-md-6 col-lg">
- <div class="mb-3">
- <label class="form-label" for="aru-document-number"><?=htmlspecialchars(__("ARU No."))?></label>
- <input class="form-control" type="number" name="aru_document_number" id="aru-document-number" value="<?= $aru->number ?? "" ?>" placeholder="<?=htmlspecialchars(__("Type number"))?>" />
- </div>
- </div>
- </div>
- <button type="submit" class="btn btn-primary" name="ticket_submit" value="1">
- <i class="fa fa-fw fa-save"></i>
- <?=htmlspecialchars(__("Update Ticket"))?>
- </button>
- <?php
- if(!$aru) {
- ?>
- <button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#new-document-modal" data-type="<?=DocumentTypes::ADVANCE_REPLACEMENT_UNIT?>" data-location-id="<?=$ticket->location_id?>" data-ticket-id="<?=$ticket->id?>">
- <i class="fa fa-fw fa-plus"></i>
- <?=htmlspecialchars(__("Create ARU"))?>
- </button>
- <?php
- }
- else {
- ?>
- <a class="btn btn-primary" href="<?=htmlspecialchars($aru->getUrl())?>">
- <i class="fa fa-fw fa-magnifying-glass"></i>
- <?=htmlspecialchars(__("View ARU"))?>
- </a>
- <?php
- }
- ?>
- </form>
- </div>
- </div>
- <div class="card mb-3">
- <div class="card-body">
- <h5><?=htmlspecialchars(__("Add Comment"))?></h5>
- <form method="post" enctype="multipart/form-data">
- <div class="row">
- <div class="col-lg">
- <div class="mb-3">
- <label class="form-label" for="content"><?=htmlspecialchars(__("Comment"))?></label>
- <textarea class="form-control" name="content" id="content" rows="4" placeholder="<?=htmlspecialchars(__("Type comment"))?>" required></textarea>
- </div>
- <div class="mb-3">
- <div class="form-check form-switch">
- <input class="form-check-input" name="internal" id="internal" type="checkbox" value="1" />
- <label class="form-check-label" for="internal">
- <?=htmlspecialchars(__("Internal Comment"))?>
- </label>
- </div>
- </div>
- </div>
- <div class="col-lg">
- <div class="mb-3">
- <label class="form-label" for="status"><?=htmlspecialchars(__("Status"))?></label>
- <select name="status" id="status" class="form-select">
- <option value=""><?=htmlspecialchars(__("Select Status"))?></option>
- <?php
- HtmlHelper::renderOptions(TicketStatuses::options());
- ?>
- </select>
- </div>
- <div class="mb-3">
- <label class="form-label" for="attachments"><?=htmlspecialchars(__("Attachments"))?></label>
- <input class="form-control" type="file" id="attachments" name="attachments[]" multiple />
- </div>
- </div>
- </div>
- <button type="submit" class="btn btn-success" name="comment_submit" value="1">
- <i class="fa fa-fw fa-plus"></i>
- <?=htmlspecialchars(__("Add Comment"))?>
- </button>
- </form>
- </div>
- </div>
- <h3>
- <?=htmlspecialchars(__("All Comments"))?>
- </h3>
- <?php
- if(empty($comments)) {
- ?>
- <div class="alert alert-info">
- <i class="fa fa-fw fa-info-circle"></i>
- <?=htmlspecialchars(__("No comments have been added to this ticket."))?>
- </div>
- <?php
- }
- else {
- foreach(array_reverse($comments) as $comment) {
- View::include("components/comment_card", ["comment" => $comment]);
- }
- }
|