Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Eywek committed Oct 9, 2017
1 parent ca3b789 commit 9c90e3f
Show file tree
Hide file tree
Showing 21 changed files with 631 additions and 627 deletions.
12 changes: 11 additions & 1 deletion Config/routes.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
<?php
Router::connect('/support', array('controller' => 'ticket', 'action' => 'index', 'plugin' => 'support'));
Router::connect('/admin/support', array('controller' => 'Ticket', 'action' => 'index', 'plugin' => 'Support', 'admin' => true));
Router::connect('/support/ajax_clos', array('controller' => 'Ticket', 'action' => 'ajax_clos', 'plugin' => 'Support', 'admin' => false));
Router::connect('/admin/support/ajax_closa', array('controller' => 'Ticket', 'action' => 'ajax_closa', 'plugin' => 'Support', 'admin' => true));
Router::connect('/admin/support/ticket/*', array('controller' => 'Ticket', 'action' => 'ticket', 'plugin' => 'Support', 'admin' => true));
Router::connect('/admin/support/ajax_replya', array('controller' => 'Ticket', 'action' => 'ajax_replya', 'plugin' => 'Support', 'admin' => true));
Router::connect('/support', array('controller' => 'Ticket', 'action' => 'index', 'plugin' => 'Support'));
Router::connect('/support/ajax_create', array('controller' => 'Ticket', 'action' => 'ajax_create', 'plugin' => 'Support', 'admin' => false));
Router::connect('/support/ticket/ajax_reply', array('controller' => 'Ticket', 'action' => 'ajax_reply', 'plugin' => 'Support', 'admin' => false));
Router::connect('/support/create', array('controller' => 'Ticket', 'action' => 'create', 'plugin' => 'Support'));
Router::connect('/support/ticket/*', array('controller' => 'Ticket', 'action' => 'ticket', 'plugin' => 'Support'));

3 changes: 0 additions & 3 deletions Controller/SupportAppController.php

This file was deleted.

364 changes: 244 additions & 120 deletions Controller/TicketController.php

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions Model/ReplyTicket.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<?php
App::uses('CakeEvent', 'Event');

class ReplyTicket extends SupportAppModel {
class ReplyTicket extends AppModel {

public function afterSave($created, $options = array()) {
if($created) {
// nouvel enregistrement
$this->getEventManager()->dispatch(new CakeEvent('afterReplyToTicket', $this));
}
}

public function afterDelete($cascade = true) {
$this->getEventManager()->dispatch(new CakeEvent('afterDeleteReply', $this));
}
public $useTable = "support__reply_tickets";

}
4 changes: 0 additions & 4 deletions Model/SupportAppModel.php

This file was deleted.

16 changes: 2 additions & 14 deletions Model/Ticket.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
<?php
App::uses('CakeEvent', 'Event');

class Ticket extends SupportAppModel {
class Ticket extends AppModel {

public function afterSave($created, $options = array()) {
if($created) {
// nouvel enregistrement
$this->getEventManager()->dispatch(new CakeEvent('afterAddTicket', $this));
} else {
// on édite, donc il reviens résolu
$this->getEventManager()->dispatch(new CakeEvent('afterResolveTicket', $this));
}
}

public function afterDelete($cascade = true) {
$this->getEventManager()->dispatch(new CakeEvent('afterDeleteTicket', $this));
}
public $useTable = "support__tickets";

}
19 changes: 10 additions & 9 deletions SQL/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ public function before($event = array()) {
public function after($event = array()) {
}

public $support__reply_tickets = array(
public $support__reply_tickets = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'),
'ticket_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false),
'reply' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'author' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'author' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false,),
'created' => array('type' => 'string', 'length' => 50, 'null' => false, 'default' => null),
'type' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'unsigned' => false),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB')
);
public $support__tickets = array(

public $support__tickets = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'),
'title' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'content' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'author' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'private' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false),
'subject' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'author' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false,),
'state' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false),
'created' => array('type' => 'datetime', 'null' => false, 'default' => null),
'created' => array('type' => 'string', 'length' => 50, 'null' => false, 'default' => null),
'reponse_text' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
),
Expand Down
111 changes: 0 additions & 111 deletions Support_update.php

This file was deleted.

64 changes: 64 additions & 0 deletions View/Ticket/admin_index.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

<?php
App::import('Controller', 'TicketController');
$TicketSupport = new TicketController();
?>
<section class="content">
<div class="col-md-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><?= $title_for_layout; ?></h3>
</div>
<div class="box-body">
<table class="table">
<thead>
<tr>
<th><?= $Lang->get('SUPPORT__SUBJECT') ?></th>
<th><?= $Lang->get('SUPPORT__AUTHOR') ?></th>
<th><?= $Lang->get('SUPPORT__STATE_TITLE') ?></th>
<th><?= $Lang->get('SUPPORT__CREATED') ?></th>
<th><?= $Lang->get('SUPPORT__ACTIONS') ?></th>
</tr>
</thead>
<tbody>
<?php foreach($tickets as $ticket): ?>
<tr>
<td><?= $ticket['Ticket']['subject']; ?></td>
<td><?= $TicketSupport->getUser('pseudo', $ticket['Ticket']['author']); ?></td>
<td>
<?php
switch($ticket['Ticket']['state'])
{
case '0':
echo '<div class="label label-warning">'.$Lang->get('SUPPORT__STATE_1').'</div>';
break;
case '1':
echo '<div class="label label-info">'.$Lang->get('SUPPORT__STATE_0').'</div>';
break;
case '2':
echo '<div class="label label-success">'.$Lang->get('SUPPORT__STATE_2').'</div>';
break;
}
?>
</td>
<td><?= date('d m Y', $ticket['Ticket']['created']); ?></td>
<td>
<?php if($ticket['Ticket']['state'] == 0 || $ticket['Ticket']['state'] == 1){ ?>
<form method="post" class="form-horizontal" data-ajax="true" data-redirect-url="?" action="<?= $this->Html->url(array('controller' => 'Ticket', 'action' => 'ajax_closa')) ?>">
<a class="btn btn-primary" href="<?= $this->Html->url(array('plugin' => null, 'admin' => true, 'controller' => 'support', 'action' => 'ticket', $ticket['Ticket']['id'])); ?>">Voir</a>
<input type="hidden" name="idTicket" value="<?= $ticket['Ticket']['id']; ?>">
<button type="submit" class="btn btn-success" href="#"><?= $Lang->get('SUPPORT__CLOSE') ?></button>
</form>
<?php }else{ ?>
<a class="btn btn-primary" href="<?= $this->Html->url(array('plugin' => null, 'admin' => true, 'controller' => 'support', 'action' => 'ticket', $ticket['Ticket']['id'])); ?>">Voir</a>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="clearfix"></div>
</section>
64 changes: 64 additions & 0 deletions View/Ticket/admin_ticket.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
App::import('Controller', 'TicketController');
$TicketSupport = new TicketController();
?>
<?= $this->Html->css('Support.jquery.cleditor.css'); ?>
<section class="content">
<div class="container">
<div class="row">
<div class="col-sm-12">
<?php if($ticket['Ticket']['state'] == 0 || $ticket['Ticket']['state'] == 1){ ?>
<form method="post" class="form-horizontal" data-ajax="true" data-redirect-url="../" action="<?= $this->Html->url(array('controller' => 'Ticket', 'action' => 'ajax_closa')) ?>">
<a class="btn btn-primary" href="<?= $this->Html->url(array('controller' => 'Ticket', 'admin' => true, 'action' => 'index')) ?>"><i class="fa fa-arrow-left"></i> <?= $Lang->get('SUPPORT_BACK_TO_LIST'); ?></a>
<input type="hidden" name="idTicket" value="<?= $ticket['Ticket']['id']; ?>">
<button class="btn btn-success" type="submit"><i class="fa fa-close"></i> <?= $Lang->get('SUPPORT__CLOSE'); ?></button>
</form>
<?php }else{ ?>
<a class="btn btn-primary" href="<?= $this->Html->url(array('controller' => 'Ticket', 'admin' => true, 'action' => 'index')) ?>"><i class="fa fa-arrow-left"></i> <?= $Lang->get('SUPPORT_BACK_TO_LIST'); ?></a>
<?php }?>
<h2><?= $Lang->get('SUPPORT__PROBLEMQUESTION') ?> <?= $TicketSupport->getUser('pseudo', $ticket['Ticket']['author']); ?></h2>
<hr style="border-top: 1px solid #dedede;">
<div class="box">
<div style="word-wrap: break-word;" class="box-body">
<?= $ticket['Ticket']['reponse_text']; ?>
</div>
</div>
</div>
<div class="col-sm-12"><h2><?= $Lang->get('SUPPORT__ANSWER'); ?></h2><hr style="border-top: 1px solid #dedede;"></div>
<?php foreach($answers as $answer): ?>
<div class="col-sm-8 <?php if($answer['ReplyTicket']['type'] == 1){ ?>pull-right<?php }?>">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
<?= $Lang->get('SUPPORT__ANSWERTO') ?> <?= $TicketSupport->getUser('pseudo', $answer['ReplyTicket']['author']); ?>
</h3>
</div>
<div style="word-wrap: break-word;" class="box-body">
<?= $answer['ReplyTicket']['reply']; ?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="col-sm-12">
<h2><?= $Lang->get('SUPPORT__REPLYTICKET') ?></h2>
<hr style="border-top: 1px solid #dedede;">
<div class="box">
<div class="box-body">
<?php if(!$ticket['Ticket']['state'] == 2){ ?>
<form method="post" class="form-horizontal" data-ajax="true" data-redirect-url="../" action="<?= $this->Html->url(array('controller' => 'Ticket', 'action' => 'ajax_replya')) ?>">
<input type="hidden" name="idTicket" value="<?= $ticket['Ticket']['id']; ?>">
<textarea id="input" name="reponse_text"></textarea>
<br>
<button class="btn btn-primary" type="submit"><?= $Lang->get('SUPPORT__REPLY') ?></button>
</form>
<?php }else{ ?>
<div class="alert alert-warning"><?= $Lang->get('SUPPORT__CLOSTICKETWARNING') ?></div>
<?php }?>
</div>
</div>
</div>
</div>
</div>
</section>
<?= $this->Html->script('Support.jquery.cleditor.min.js'); ?>
<script>$(document).ready(function() { $("#input").cleditor(); }); </script>
17 changes: 17 additions & 0 deletions View/Ticket/create.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?= $this->Html->css('Support.jquery.cleditor.css'); ?>
<div class="container">
<div class="row">
<h1 style="display: inline-block;"><?= $Lang->get('SUPPORT__CREATE') ?> - <?= $Lang->get('SUPPORT__SUPPORT') ?></h1>
<hr>
<form method="post" class="form-horizontal" data-ajax="true" data-redirect-url="./" action="<?= $this->Html->url(array('controller' => 'Ticket', 'action' => 'ajax_create')) ?>">
<label><?= $Lang->get('SUPPORT__SUBJECT') ?></label>
<input type="text" name="subject" class="form-control">
<label><?= $Lang->get('SUPPORT__YOURPROBLEM') ?></label>
<textarea id="input" name="reponse_text"></textarea>
<hr>
<button class="btn btn-primary" type="submit"><?= $Lang->get('SUPPORT__CREATETICKET') ?></button>
</form>
</div>
</div>
<?= $this->Html->script('Support.jquery.cleditor.min.js'); ?>
<script>$(document).ready(function() { $("#input").cleditor(); }); </script>
Loading

0 comments on commit 9c90e3f

Please sign in to comment.