Compare commits
6 Commits
8d0b903d34
...
2a3465fff8
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a3465fff8 | |||
| 5565d92e1e | |||
| 6abea313a4 | |||
| 58aa4746a5 | |||
| 63c90eed0e | |||
| 71ae5178fd |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
||||
composer.lock
|
||||
lib/
|
||||
downloads/
|
||||
app/.env.cfg
|
||||
public/tmp/
|
||||
storage/
|
||||
public/test.php
|
||||
app/config/.env.cfg
|
||||
app/.env.cfg
|
||||
62
app/config/routes.ini
Normal file
62
app/config/routes.ini
Normal file
@ -0,0 +1,62 @@
|
||||
[routes]
|
||||
|
||||
; home
|
||||
GET /=HomeController->display
|
||||
|
||||
; auth
|
||||
GET /login=AuthController->showLoginForm
|
||||
POST /login=AuthController->login
|
||||
GET /logout=AuthController->logout
|
||||
|
||||
; tickets - CRUD (CREATE, READ, UPDATE, DELETE)
|
||||
GET /tickets=TicketController->index
|
||||
GET /ticket/@id=TicketController->view
|
||||
GET /ticket/create=TicketController->createForm
|
||||
POST /ticket/create=TicketController->create
|
||||
GET /ticket/@id/edit=TicketController->editForm
|
||||
POST /ticket/@id/update=TicketController->update
|
||||
GET /ticket/@id/delete=TicketController->delete
|
||||
; additional routes - comments
|
||||
POST /ticket/@id/comment=CommentController->create
|
||||
GET /ticket/@id/comment/@comment_id/delete=CommentController->delete
|
||||
GET /ticket/@id/comments=CommentController->index
|
||||
; route for linking a child to a parent
|
||||
POST /ticket/@id/add-subtask=TicketController->addSubtask
|
||||
|
||||
; attachments
|
||||
GET /ticket/@id/attachments=AttachmentController->index
|
||||
POST /ticket/@id/attachments/upload=AttachmentController->upload
|
||||
GET /attachment/@id/download=AttachmentController->download
|
||||
GET /attachment/@id/delete=AttachmentController->delete
|
||||
|
||||
; knowledgebase
|
||||
GET /kb=KBController->index
|
||||
GET /kb/@id=KBController->view
|
||||
GET /kb/create=KBController->createForm
|
||||
POST /kb/create=KBController->create
|
||||
GET /kb/@id/edit=KBController->editForm
|
||||
POST /kb/@id/update=KBController->update
|
||||
|
||||
; tags
|
||||
GET /tags=TagController->index
|
||||
GET /tag/create=TagController->createForm
|
||||
POST /tag/create=TagController->create
|
||||
|
||||
; parsedown preview
|
||||
POST /parsedown/preview=ParsedownPreview->view
|
||||
|
||||
; dashboard
|
||||
GET /dashboard=DashboardController->index
|
||||
|
||||
; projects
|
||||
GET /projects=ProjectController->index
|
||||
GET /project/@id=ProjectController->view
|
||||
GET /project/create=ProjectController->createForm
|
||||
POST /project/create=ProjectController->create
|
||||
GET /project/@id/edit=ProjectController->editForm
|
||||
POST /project/@id/update=ProjectController->update
|
||||
|
||||
; additional routes - user
|
||||
GET /users=UserController->index
|
||||
GET /user/@id/edit=UserController->editForm
|
||||
POST /user/@id/update=UserController->update
|
||||
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
@ -67,6 +67,17 @@ class BulmaFormHelper extends \Prefab {
|
||||
}
|
||||
|
||||
static function build_h_field_select($label, $name, $options, $selected){
|
||||
$opts = json_decode(str_replace("'", '"', $options));
|
||||
$opts_string = "";
|
||||
foreach($opts as $k => $v){
|
||||
if($v == $selected){
|
||||
$selected_str = " selected";
|
||||
} else {
|
||||
$selected_str = "";
|
||||
}
|
||||
$opts_string .= '<option'.$selected_str.'>'.$v.'</option>';
|
||||
}
|
||||
|
||||
$string =
|
||||
'<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
@ -75,7 +86,9 @@ class BulmaFormHelper extends \Prefab {
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="select">
|
||||
$options
|
||||
<select id="'.$name.'" name="'.$name.'">
|
||||
'.$opts_string.'
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
// this isn't the way to do it, but nevermind!
|
||||
|
||||
class BulmaForm {
|
||||
|
||||
public static function horizontal_field_input($label = "%label%", $name = "%name%", $value=""){
|
||||
$string = '
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label">%label%</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<input class="input" type="text" name="%name%" value="%value%">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$string = str_replace('%label%', $label, $string);
|
||||
$string = str_replace('%name%', $name, $string);
|
||||
$string = str_replace('%value%', $value, $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function horizontal_field_textarea($label = "%label%", $name = "%name%", $value=""){
|
||||
$string = '
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label">%label%</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<textarea class="textarea" type="text" name="%name%">%value%</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$string = str_replace('%label%', $label, $string);
|
||||
$string = str_replace('%name%', $name, $string);
|
||||
$string = str_replace('%value%', $value, $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function horizontal_field_select($label="%label%", $name="%name%", $options=[], $selected=0){
|
||||
$string = '
|
||||
<div class="field is-horizontal">
|
||||
<div class="field-label is-normal">
|
||||
<label class="label">%label%</label>
|
||||
</div>
|
||||
<div class="field-body">
|
||||
<div class="field">
|
||||
<div class="select">
|
||||
<select name="%name%">
|
||||
%options%
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$string = str_replace('%label%', $label, $string);
|
||||
$string = str_replace('%name%', $name, $string);
|
||||
$opts_str = ''; $i=0;
|
||||
foreach($options as $v){
|
||||
$opts_str .= '<option'.($i==$selected ? ' selected="selected" ' : '').'>'.$v.'</option>';
|
||||
$i++;
|
||||
}
|
||||
$string = str_replace('%options%', $opts_str, $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -11,7 +11,7 @@ $htmlpurifier = \HTMLPurifier::instance();
|
||||
$md = \Parsedown::instance();
|
||||
$md->setSafeMode(true);
|
||||
|
||||
$f3->config('../app/.env.cfg');
|
||||
$f3->config('../app/config/.env.cfg');
|
||||
$f3->set('DEBUG', 3); // development debug
|
||||
$f3->set('CACHE', FALSE);
|
||||
|
||||
@ -26,76 +26,4 @@ $f3->set('DB', new \DB\SQL(
|
||||
new \DB\SQL\Session($f3->get('DB'));
|
||||
$f3->set('SESSION.status', 'running');
|
||||
|
||||
// Routing and Controller Setup
|
||||
|
||||
// home
|
||||
$f3->route('GET /', 'HomeController->display');
|
||||
|
||||
// auth
|
||||
$f3->route('GET /login', 'AuthController->showLoginForm');
|
||||
$f3->route('POST /login', 'AuthController->login');
|
||||
$f3->route('GET /logout', 'AuthController->logout');
|
||||
|
||||
// Example protected route
|
||||
$f3->route('GET /dashboard', function($f3){
|
||||
if(!$f3->exists('SESSION.user')){
|
||||
$f3->reroute('/login');
|
||||
}
|
||||
echo 'Welcome to the dashboard' . $f3->get('SESSION.username');
|
||||
echo '<a href="/logout">logout</a>';
|
||||
|
||||
});
|
||||
|
||||
// tickets - CRUD (CREATE, READ, UPDATE, DELETE)
|
||||
$f3->route('GET /tickets', 'TicketController->index'); // view all tickets
|
||||
$f3->route('GET /ticket/@id', 'TicketController->view'); // view ticket details
|
||||
$f3->route('GET /ticket/create', 'TicketController->createForm'); // show form to create
|
||||
$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'); //
|
||||
// additional routes - comments
|
||||
$f3->route('POST /ticket/@id/comment', 'CommentController->create');
|
||||
$f3->route('GET /ticket/@id/comment/@comment_id/delete', 'CommentController->delete');
|
||||
$f3->route('GET /ticket/@id/comments', 'CommentController->index');
|
||||
// route for linking a child to a parent
|
||||
$f3->route('POST /ticket/@id/add-subtask', 'TicketController->addSubtask');
|
||||
|
||||
// attachments
|
||||
$f3->route('GET /ticket/@id/attachments', 'AttachmentController->index');
|
||||
$f3->route('POST /ticket/@id/attachments/upload', 'AttachmentController->upload');
|
||||
$f3->route('GET /attachment/@id/download', 'AttachmentController->download');
|
||||
$f3->route('GET /attachment/@id/delete', 'AttachmentController->delete');
|
||||
|
||||
// knowledgebase
|
||||
$f3->route('GET /kb', 'KBController->index');
|
||||
$f3->route('GET /kb/@id', 'KBController->view');
|
||||
$f3->route('GET /kb/create', 'KBController->createForm');
|
||||
$f3->route('POST /kb/create', 'KBController->create');
|
||||
$f3->route('GET /kb/@id/edit', 'KBController->editForm');
|
||||
$f3->route('POST /kb/@id/update', 'KBController->update'); // should this be update - "crud"?
|
||||
|
||||
// tags
|
||||
$f3->route('GET /tags', 'TagController->index');
|
||||
$f3->route('GET /tag/create', 'TagController->createForm');
|
||||
$f3->route('POST /tag/create', 'TagController->create');
|
||||
|
||||
// parsedown preview
|
||||
$f3->route('POST /parsedown/preview', 'ParsedownPreview->view');
|
||||
|
||||
// dashboard
|
||||
$f3->route('GET /dashboard', 'DashboardController->index');
|
||||
|
||||
// projects
|
||||
$f3->route('GET /projects', 'ProjectController->index');
|
||||
$f3->route('GET /project/@id', 'ProjectController->view');
|
||||
$f3->route('GET /project/create', 'ProjectController->createForm');
|
||||
$f3->route('POST /project/create', 'ProjectController->create');
|
||||
$f3->route('GET /project/@id/edit', 'ProjectController->editForm');
|
||||
$f3->route('POST /project/@id/update', 'ProjectController->update');
|
||||
|
||||
// additional routes - user
|
||||
$f3->route('GET /users', 'UserController->index');
|
||||
$f3->route('GET /user/@id/edit', 'UserController->editForm');
|
||||
$f3->route('POST /user/@id/update', 'UserController->update');
|
||||
|
||||
$f3->run();
|
||||
@ -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; }
|
||||
|
||||
|
||||
@ -6,8 +6,9 @@
|
||||
<bulma type="H_FIELD_INPUT" label="Title:" name="title" value=""></bulma>
|
||||
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value=""></bulma>
|
||||
|
||||
{{ BulmaForm::horizontal_field_select('Priority:', 'priority', ['Low', 'Medium', 'High'])}}
|
||||
{{ BulmaForm::horizontal_field_select('Status:', 'status', ['New', 'In Progress', 'On Hold', 'Completed'])}}
|
||||
|
||||
<bulma type="H_FIELD_SELECT" label="Priority:" name="priority" options="['Low', 'Medium', 'High']" selected="Medium"></bulma>
|
||||
<bulma type="H_FIELD_SELECT" label="Status:" name="status" options="['New', 'In Progress', 'On Hold', 'Completed']" selected="New"></bulma>
|
||||
|
||||
<!-- custom fields -->
|
||||
<hr>
|
||||
|
||||
@ -5,8 +5,9 @@
|
||||
<bulma type="H_FIELD_INPUT" label="Title:" name="title" value="{{@ticket.title}}"></bulma>
|
||||
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value="{{@ticket.description}}"></bulma>
|
||||
|
||||
{{ BulmaForm::horizontal_field_select('Priority:', 'priority', ['Low', 'Medium', 'High'])}}
|
||||
{{ BulmaForm::horizontal_field_select('Status:', 'status', ['New', 'In Progress', 'On Hold', 'Completed'])}}
|
||||
|
||||
<bulma type="H_FIELD_SELECT" label="Priority:" name="priority" options="['Low', 'Medium', 'High']" selected="{{@ticket.priority}}"></bulma>
|
||||
<bulma type="H_FIELD_SELECT" label="Status:" name="status" options="['New', 'In Progress', 'On Hold', 'Completed']" selected="{{@ticket.status}}"></bulma>
|
||||
|
||||
|
||||
<div class="block">
|
||||
|
||||
@ -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