soft delete for tickets
This commit is contained in:
parent
8d0b903d34
commit
71ae5178fd
@ -149,4 +149,21 @@ class TicketController extends BaseController implements CRUD {
|
||||
$this->f3->reroute('/ticket/' . $parent_id);
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$this->requireLogin();
|
||||
|
||||
$ticket_id = (int)$this->f3->get('PARAMS.id');
|
||||
$ticket_mapper = new Ticket($this->getDB());
|
||||
$ticket = $ticket_mapper->findById($ticket_id);
|
||||
|
||||
if(!$ticket){
|
||||
$this->f3->set('SESSION.error', 'Ticket not found');
|
||||
$this->f3->reroute('/tickets');
|
||||
}
|
||||
|
||||
$ticket->softDelete();
|
||||
$this->f3->reroute('/tickets');
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,7 +11,10 @@ class Ticket extends \DB\SQL\Mapper {
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->db->exec(
|
||||
'SELECT * FROM tickets ORDER BY created_at DESC'
|
||||
'SELECT *
|
||||
FROM tickets
|
||||
WHERE recycled = 0
|
||||
ORDER BY created_at DESC'
|
||||
);
|
||||
}
|
||||
|
||||
@ -48,6 +51,11 @@ class Ticket extends \DB\SQL\Mapper {
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function softDelete():void {
|
||||
$this->recycled = 1;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function attachments(){
|
||||
$attachment = new Attachment($this->db);
|
||||
return $attachment->findWithUserByTicketId($this->id);
|
||||
|
||||
@ -53,6 +53,7 @@ $f3->route('GET /ticket/create', 'TicketController->createForm'); // show form t
|
||||
$f3->route('POST /ticket/create', 'TicketController->create'); // save
|
||||
$f3->route('GET /ticket/@id/edit', 'TicketController->editForm'); // edit ticket
|
||||
$f3->route('POST /ticket/@id/update', 'TicketController->update'); //
|
||||
$f3->route('GET /ticket/@id/delete', 'TicketController->delete');
|
||||
// additional routes - comments
|
||||
$f3->route('POST /ticket/@id/comment', 'CommentController->create');
|
||||
$f3->route('GET /ticket/@id/comment/@comment_id/delete', 'CommentController->delete');
|
||||
|
||||
@ -4,6 +4,7 @@ html, body, #sidebar, #page,#base_body {
|
||||
}
|
||||
|
||||
#page { min-height: calc(100vh - 170px - 52px) }
|
||||
i.fa { font-weight: 100 !important ; }
|
||||
|
||||
.table th.th-icon { width: 2rem; }
|
||||
|
||||
|
||||
@ -21,7 +21,12 @@
|
||||
<td>{{@ticket.priority}}</td>
|
||||
<td>{{@ticket.created_at}}</td>
|
||||
<td>
|
||||
<a href="/ticket/{{@ticket.id}}/edit"><i class="fa fa-edit"></i></a>
|
||||
<a class="button is-link is-small" href="/ticket/{{@ticket.id}}/edit">
|
||||
<i class="fa fa-edit"></i></a>
|
||||
<a class="button is-danger is-small"
|
||||
href="/ticket/{{@ticket.id}}/delete"
|
||||
onclick="return confirm('Are you sure you want to delete this ticket?');">
|
||||
<i class="fa fa-trash-can"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
</repeat>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user