Selaa lähdekoodia

[Administration] Support : vue ticket

feature/souke
Guillaume Bourgeois 1 vuosi sitten
vanhempi
commit
7b44080199
11 muutettua tiedostoa jossa 448 lisäystä ja 285 poistoa
  1. +18
    -8
      backend/controllers/SupportController.php
  2. +13
    -8
      backend/views/support/index.php
  3. +72
    -2
      backend/views/support/view.php
  4. +281
    -258
      backend/web/css/screen.css
  5. +1
    -3
      backend/web/sass/_adminlte.scss
  6. +10
    -0
      backend/web/sass/screen.scss
  7. +4
    -0
      backend/web/sass/support/_index.scss
  8. +19
    -0
      backend/web/sass/support/_view.scss
  9. +2
    -1
      common/logic/Ticket/Ticket/Model/Ticket.php
  10. +17
    -0
      common/logic/Ticket/Ticket/Service/TicketSolver.php
  11. +11
    -5
      common/logic/Ticket/TicketMessage/Service/TicketMessageBuilder.php

+ 18
- 8
backend/controllers/SupportController.php Näytä tiedosto

@@ -41,6 +41,7 @@ namespace backend\controllers;
use common\logic\Ticket\Ticket\Model\TicketSearch;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\helpers\Html;
use yii\web\NotFoundHttpException;

class SupportController extends BackendController
@@ -81,12 +82,15 @@ class SupportController extends BackendController

public function actionCreate()
{
$userCurrent = $this->getUserCurrent();
$ticketManager = $this->getTicketManager();
$ticket = $ticketManager->instanciateTicket($this->getProducerCurrent(), $this->getUserCurrent());
$ticketMessageManager = $this->getTicketMessageManager();
$ticket = $ticketManager->instanciateTicket($this->getProducerCurrent(), $userCurrent);

if ($ticket->load(\Yii::$app->request->post()) && $ticketManager->saveCreate($ticket)) {
$ticketMessageManager->createTicketMessage($ticket, $userCurrent, $ticket->message);
$this->setFlash('success', 'Le ticket a bien été créé.');
return $this->redirect(['index']);
return $this->redirect(['view', 'id' => $ticket->id]);
} else {
return $this->render('create', [
'ticket' => $ticket,
@@ -96,10 +100,17 @@ class SupportController extends BackendController

public function actionView(int $id)
{
$ticketManager = $this->getTicketManager();
$ticketMessageManager = $this->getTicketMessageManager();
$ticket = $this->findTicket($id);
$ticketMessage = $ticketMessageManager->instanciateTicketMessage($ticket, $this->getUserCurrent());

if ($ticketMessage->load(\Yii::$app->request->post()) && $ticketMessageManager->saveCreate($ticketMessage)) {
return $this->redirect(['view', 'id' => $ticket->id, '#' => 'bottom']);
}

return $this->render('view', [
'ticket' => $ticket
'ticket' => $ticket,
'ticketMessageResponse' => $ticketMessage
]);
}

@@ -108,7 +119,7 @@ class SupportController extends BackendController
$ticketManager = $this->getTicketManager();
$ticket = $this->findTicket($id);
$ticketManager->closeTicket($ticket);
$this->addFlash('success', "Le ticket a bien été fermé.");
$this->addFlash('success', "Le ticket <strong>".Html::encode($ticket->subject)."</strong> a bien été fermé.");
return $this->redirect(['index']);
}

@@ -126,10 +137,9 @@ class SupportController extends BackendController
$ticketManager = $this->getTicketManager();
$ticket = $ticketManager->findOneTicketById($id);

if($ticket && $ticketManager->hasTicketAccess($ticket, $this->getUserCurrent())) {
if ($ticket && $ticketManager->hasTicketAccess($ticket, $this->getUserCurrent())) {
return $ticket;
}
else {
} else {
throw new NotFoundHttpException("Le ticket est introuvable.");
}
}

+ 13
- 8
backend/views/support/index.php Näytä tiedosto

@@ -49,7 +49,6 @@ $this->addBreadcrumb($this->getTitle());

?>
<div class="support-index">

<div>
<div class="col-md-4">
<div class="info-box">
@@ -85,27 +84,34 @@ $this->addBreadcrumb($this->getTitle());

<div class="clr"></div>

<div class="box">
<div class="box box-table-tickets">
<div class="box-header with-border">
<h3 class="box-title">Tickets</h3>
</div>

<div class="box-body">
<?= GridView::widget([
'summary' => '',
'filterModel' => $searchTicket,
'dataProvider' => $dataProviderTicket,
'columns' => [
[
'attribute' => 'created_at',
'value' => function ($ticket) {
return date('d/m/Y', strtotime($ticket->created_at));
}
],
[
'attribute' => 'subject',
'format' => 'raw',
'value' => function($ticket) {
'value' => function ($ticket) {
return Html::a($ticket->subject, ['support/view', 'id' => $ticket->id]);
}
],
[
'attribute' => 'status',
'filter' => [Ticket::STATUS_OPEN => 'Ouvert', Ticket::STATUS_CLOSED => 'Fermé'],
'value' => function($ticket) {
'value' => function ($ticket) {
$label = $ticket->status == Ticket::STATUS_OPEN ? 'Ouvert' : 'Fermé';
return $label;
}
@@ -117,17 +123,16 @@ $this->addBreadcrumb($this->getTitle());
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'close-open' => function ($url, $ticket) use ($ticketManager) {
if($ticketManager->isTicketOpen($ticket)) {
if ($ticketManager->isTicketOpen($ticket)) {
$title = 'Fermer';
$url = ['support/close', 'id' => $ticket->id];
$glyphicon = 'glyphicon-folder-close';
}
else {
} else {
$title = 'Ré-ouvrir';
$url = ['support/open', 'id' => $ticket->id];
$glyphicon = 'glyphicon-folder-open';
}
return Html::a('<span class="glyphicon '.$glyphicon.'"></span>', $url, [
return Html::a('<span class="glyphicon ' . $glyphicon . '"></span>', $url, [
'title' => $title, 'class' => 'btn btn-default'
]);
}

+ 72
- 2
backend/views/support/view.php Näytä tiedosto

@@ -1,10 +1,80 @@
<?php

use common\logic\Ticket\Ticket\Wrapper\TicketManager;
use common\logic\User\User\Wrapper\UserManager;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$ticketManager = TicketManager::getInstance();
$this->setTitle('Support');
$this->addBreadcrumb($this->getTitle());
$userManager = UserManager::getInstance();
$this->setTitle('Voir un ticket');

$this->addBreadcrumb(['label' => 'Support', 'url' => ['support/index']]);
$this->addBreadcrumb('Voir un ticket');

?>
<div class="ticket-view">
<div class="box box-solid">
<div class="box-body">
<table class="table">
<tbody>
<tr>
<td><strong>Sujet</strong></td>
<td><?= Html::encode($ticket->subject); ?></td>
</tr>
<tr>
<td><strong>Ouverture</strong></td>
<td><?= $ticketManager->getTicketDateCreatedAtFormat($ticket); ?></td>
</tr>
<tr>
<td><strong>Statut</strong></td>
<td><?= $ticketManager->getTicketStatusLabelAsHtml($ticket); ?></td>
</tr>
</tbody>
</table>
</div>
</div>

<ul class="timeline">
<?php foreach($ticket->ticketMessages as $key => $ticketMessage): ?>
<li>
<?php if ($key === array_key_last($ticket->ticketMessages)): ?>
<a name="bottom"></a>
<?php endif; ?>
<a name="<?= $ticketMessage->id ?>"></a>
<i class="fa fa-user <?= $userManager->isAdmin($ticketMessage->user) ? 'bg-orange' : 'bg-aqua'; ?>"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> <?= date('d/m/Y à H:i', strtotime($ticketMessage->created_at)) ?></span>
<h3 class="timeline-header">Guillaume Bourgeois</h3>
<div class="timeline-body">
<?= nl2br($ticketMessage->message); ?>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>

<div class="box box-success">
<div class="box-header">
<h3 class="box-title"><i class="fa fa-comments"></i> Répondre</h3>
</div>
<div class="box-body">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($ticketMessageResponse, 'message')->textarea(['rows' => 6]); ?>
<div class="form-group">
<?= Html::submitButton('Répondre', ['class' => 'btn btn-success btn-sm']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>

<div class="box box-danger">
<div class="box-header">
<h3 class="box-title"><i class="fa fa-folder"></i> Cliquez ici si vous souhaitez fermer le ticket</h3>
</div>
<div class="box-body">
<?= Html::a('Fermer le ticket', ['support/close', 'id' => $ticket->id], ['class' => 'btn btn-danger btn-sm']) ?>
</div>
</div>

</div>

+ 281
- 258
backend/web/css/screen.css
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 3
backend/web/sass/_adminlte.scss Näytä tiedosto

@@ -134,10 +134,8 @@ body.skin-black {
}
}
a {
color: $color1 ;
color: darken($color1, 5) ;
}
.btn {

+ 10
- 0
backend/web/sass/screen.scss Näytä tiedosto

@@ -58,6 +58,14 @@ a {
}
}

.float-right {
float: right;
}

.float-left {
float: left;
}

#block-demo {
padding: 10px 0px ;
background-color: $color2 ;
@@ -1521,4 +1529,6 @@ a.btn, button.btn {
@import "document/_form.scss" ;
@import "document/_index.scss" ;
@import "development/_index.scss" ;
@import "support/_index.scss";
@import "support/_view.scss";
@import "_responsive.scss" ;

+ 4
- 0
backend/web/sass/support/_index.scss Näytä tiedosto

@@ -0,0 +1,4 @@

.support-index {

}

+ 19
- 0
backend/web/sass/support/_view.scss Näytä tiedosto

@@ -0,0 +1,19 @@

.ticket-view {

.table {
tr:first-child td {
border-top: 0px none;
}
}

.timeline {
&::before {
background: transparent none;
}

li, .timeline-item {
margin-right: 0px;
}
}
}

+ 2
- 1
common/logic/Ticket/Ticket/Model/Ticket.php Näytä tiedosto

@@ -82,7 +82,8 @@ class Ticket extends ActiveRecordCommon
'id_user' => 'Utilisateur',
'subject' => 'Sujet',
'status' => 'Statut',
'created_at' => 'Date de création',
'created_at' => 'Ouverture',
'updated_at' => 'Modification',
];
}


+ 17
- 0
common/logic/Ticket/Ticket/Service/TicketSolver.php Näytä tiedosto

@@ -31,4 +31,21 @@ class TicketSolver extends AbstractSolver
{
return $ticket->status == Ticket::STATUS_CLOSED;
}

public function getTicketDateCreatedAtFormat(Ticket $ticket)
{
return date('d/m/Y', strtotime($ticket->created_at));
}

public function getTicketStatusLabelAsHtml(Ticket $ticket)
{
$classLabel = 'label-success';
$statusLabel = 'Ouvert';
if($this->isTicketClosed($ticket)) {
$classLabel = 'label-danger';
$statusLabel = 'Fermé';
}

return '<span class="label '.$classLabel.'">'.$statusLabel.'</span>';
}
}

+ 11
- 5
common/logic/Ticket/TicketMessage/Service/TicketMessageBuilder.php Näytä tiedosto

@@ -3,20 +3,26 @@
namespace common\logic\Ticket\TicketMessage\Service;

use common\logic\AbstractBuilder;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\Ticket\TicketMessage\Model\TicketMessage;
use common\logic\User\User\Model\User;

class TicketMessageBuilder extends AbstractBuilder
{
public function instanciateTicketMessage(): TicketMessage
public function instanciateTicketMessage(Ticket $ticket, User $user, string $message = ''): TicketMessage
{
$ticket = new TicketMessage();
$ticketMessage = new TicketMessage();

return $ticket;
$ticketMessage->populateTicket($ticket);
$ticketMessage->populateUser($user);
$ticketMessage->message = $message;

return $ticketMessage;
}

public function createTicketMessage(): TicketMessage
public function createTicketMessage(Ticket $ticket, User $user, string $message): TicketMessage
{
$ticketMessage = $this->instanciateTicketMessage();
$ticketMessage = $this->instanciateTicketMessage($ticket, $user, $message);
$this->saveCreate($ticketMessage);

return $ticketMessage;

Loading…
Peruuta
Tallenna