| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- namespace App;
- use RuntimeException;
- /**
- * @var int $id
- */
- $core = Core::getInstance();
- $core->addBreadcrumb("/tickets", __("Tickets"));
- $user = $core->getUser();
- $ticket = Ticket::get($id);
- if(!$ticket) {
- throw new RuntimeException(__("Ticket not found."));
- }
- $core->addBreadcrumb("/tickets/$id", $ticket->subject);
- $request = Request::fromRequest();
- $submit = $request->int("submit");
- if($submit) {
- $content = $request->string("content");
- $internal = (int) $request->int("internal");
- $status = $request->int("status");
- $attachments = Request::getFileArray("attachments", true);
- $comment = new TicketComment();
- $comment->ticket_id = $ticket->id;
- $comment->user_id = $user->id;
- $comment->content = $content;
- $comment->internal = $internal;
- $comment->dts_created = Database::dts();
- $comment->commit();
- $ticket->status = $status;
- $ticket->commit();
- foreach($attachments as $attachment) {
- $comment->addAttachment($attachment);
- }
- Session::addAlert("success", __("Comment added successfully."));
- Http::redirect($ticket->getUrl());
- }
- View::include("header");
- View::include("ticket", compact("ticket"));
- View::include("footer");
|