Browse Source

listing message

feature/tickets
charly 3 years ago
parent
commit
e07102c1cd
9 changed files with 100 additions and 8 deletions
  1. +45
    -7
      Controller/Ticket/TicketAdminController.php
  2. +19
    -0
      Factory/Ticket/TicketFactory.php
  3. +14
    -0
      Model/Ticket/TicketModel.php
  4. +4
    -0
      Resources/config/routes.yaml
  5. +1
    -1
      Resources/translations/admin.fr.yaml
  6. +1
    -0
      Resources/views/admin/ticket/index-email.html.twig
  7. +7
    -0
      Resources/views/admin/ticket/index-lastmessage.html.twig
  8. +8
    -0
      Resources/views/admin/ticket/index-status.html.twig
  9. +1
    -0
      Resources/views/admin/ticket/index-username.html.twig

+ 45
- 7
Controller/Ticket/TicketAdminController.php View File

namespace Lc\SovBundle\Controller\Ticket; namespace Lc\SovBundle\Controller\Ticket;


use App\Entity\Ticket\Ticket; use App\Entity\Ticket\Ticket;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Model\Ticket\TicketInterface; use Lc\SovBundle\Model\Ticket\TicketInterface;


public function configureFields(string $pageName): iterable public function configureFields(string $pageName): iterable
{ {

return [ return [
TextField::new('id')->hideOnForm(),
DateField::new('createdAt')->setFormat('short')->hideOnForm(),
TextField::new('visitorFirstName')->hideOnForm(),
TextField::new('visitorLastName')->hideOnForm(),
TextField::new('visitorEmail')->hideOnForm(),
IntegerField::new('id')
->hideOnForm(),
DateField::new('createdAt')->setFormat('short')
->hideOnForm(),
TextField::new('visitorFirstName')
->setTemplatePath('@LcSov/admin/ticket/index-username.html.twig')
->hideOnForm(),
TextField::new('visitorEmail')
->setTemplatePath('@LcSov/admin/ticket/index-email.html.twig')
->hideOnForm(),
AssociationField::new('user') AssociationField::new('user')
->hideOnIndex(), ->hideOnIndex(),
TextField::new('subject'), TextField::new('subject'),
TextField::new('lastMessage')
->setTemplatePath('@LcSov/admin/ticket/index-lastmessage.html.twig')
->hideOnForm(),
ChoiceField::new('type') ChoiceField::new('type')
->autocomplete() ->autocomplete()
->setChoices( ->setChoices(
'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM, 'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM,
] ]
), ),
StatusField::new('status')->setRequired(false)->hideOnForm(),
ChoiceField::new('status')
->autocomplete()
->setChoices(
[
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_OPEN => Ticket::TICKET_STATUS_OPEN,
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_BEING_PROCESSED => Ticket::TICKET_STATUS_BEING_PROCESSED,
'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_CLOSED => Ticket::TICKET_STATUS_CLOSED,
]
)
->setTemplatePath('@LcSov/admin/ticket/index-status.html.twig')
->hideOnForm(),
]; ];
} }

// public function configureCrud(Crud $crud): Crud
// {
// $crud
// ->overrideTemplate('layout', '@LcSov/admin/layout.html.twig');
//// ->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig');
//
// return parent::configureCrud($crud);
// }

public function configureActions(Actions $actions): Actions
{
$actions
->add(Crud::PAGE_INDEX, Action::DETAIL);
// ->remove(Crud::PAGE_EDIT, Action::EDIT);
return parent::configureActions($actions);
}
} }

+ 19
- 0
Factory/Ticket/TicketFactory.php View File

<?php

namespace Lc\SovBundle\Factory\Ticket;

use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;

class TicketFactory extends AbstractFactory
{
public function getEntityClass()
{
return TicketInterface::class;
}

public function create($params = array())
{
return parent::create($params);
}
}

+ 14
- 0
Model/Ticket/TicketModel.php View File

} }
} }


public function getEmail()
{
if ($this->getUser()) {
return $this->getUser()->getEmail();
} else {
return $this->getVisitorEmail();
}
}

public function getVisitorInfos() public function getVisitorInfos()
{ {
return strtoupper($this->getVisitorLastname()) . ' ' . $this->getVisitorFirstname( return strtoupper($this->getVisitorLastname()) . ' ' . $this->getVisitorFirstname(
) . ' (' . $this->getVisitorEmail() . ')'; ) . ' (' . $this->getVisitorEmail() . ')';
} }


public function getLastMessage()
{
return $this->getTicketMessages()->last();
}

public function getType(): ?string public function getType(): ?string
{ {
return $this->type; return $this->type;

+ 4
- 0
Resources/config/routes.yaml View File

path: /admin/setting/global path: /admin/setting/global
controller: Lc\SovBundle\Controller\Setting\SettingAdminController::manageGlobal controller: Lc\SovBundle\Controller\Setting\SettingAdminController::manageGlobal


sov_admin_create_ticket:
path: /admin/ticket/create
controller: Lc\SovBundle\Controller\Ticket\TicketAdminController::createTicket


+ 1
- 1
Resources/translations/admin.fr.yaml View File

position: Position position: Position
description: Description description: Description
file: Fichier file: Fichier
status: Statut
status: Status
email: Email email: Email
value: Valeur value: Valeur
metaTitle: Meta title metaTitle: Meta title

+ 1
- 0
Resources/views/admin/ticket/index-email.html.twig View File

{{ entity.instance.getEmail() }}

+ 7
- 0
Resources/views/admin/ticket/index-lastmessage.html.twig View File

{% set ticketMessage = entity.instance.getLastMessage() %}
{% if ticketMessage.answerByAdmin != true %}
<span class="badge badge-danger">
New
</span>
{% endif %}
{{ ticketMessage.createdAt|date('d/m/Y H:i') }} par {{ ticketMessage.createdBy }} {{ ticketMessage.message }}

+ 8
- 0
Resources/views/admin/ticket/index-status.html.twig View File

{% set status = entity.instance.status %}
{% if status == 'open' %}
<span class="badge badge-success">{{ entity.instance.status|trans }}</span>
{% elseif status == 'being-processed' %}
<span class="badge badge-warning">{{ entity.instance.status|trans }}</span>
{% elseif status == 'closed' %}
<span class="badge badge-danger">{{ entity.instance.status|trans }}</span>
{% endif %}

+ 1
- 0
Resources/views/admin/ticket/index-username.html.twig View File

{{ entity.instance.getUsername() }}

Loading…
Cancel
Save