namespace Lc\SovBundle\Component; | namespace Lc\SovBundle\Component; | ||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
class FileComponent | class FileComponent | ||||
{ | { | ||||
protected ParameterBagInterface $parameterBag; | protected ParameterBagInterface $parameterBag; | ||||
protected CacheManager $liipCacheHelper; | |||||
public function __construct(ParameterBagInterface $parameterBag) | |||||
public function __construct(ParameterBagInterface $parameterBag, CacheManager $liipCacheHelper) | |||||
{ | { | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->liipCacheHelper = $liipCacheHelper; | |||||
} | } | ||||
/** | /** |
use Lc\SovBundle\Factory\User\UserFactory; | use Lc\SovBundle\Factory\User\UserFactory; | ||||
use Lc\SovBundle\Repository\User\UserRepositoryQuery; | use Lc\SovBundle\Repository\User\UserRepositoryQuery; | ||||
use Lc\SovBundle\Repository\User\UserStore; | use Lc\SovBundle\Repository\User\UserStore; | ||||
use Lc\SovBundle\Solver\User\UserSolver; | |||||
class UserContainer | class UserContainer | ||||
{ | { | ||||
protected UserBuilder $builder; | protected UserBuilder $builder; | ||||
protected UserRepositoryQuery $repositoryQuery; | protected UserRepositoryQuery $repositoryQuery; | ||||
protected UserStore $store; | protected UserStore $store; | ||||
protected UserSolver $solver; | |||||
public function __construct( | public function __construct( | ||||
UserFactory $factory, | UserFactory $factory, | ||||
UserBuilder $builder, | UserBuilder $builder, | ||||
UserRepositoryQuery $repositoryQuery, | UserRepositoryQuery $repositoryQuery, | ||||
UserStore $store | |||||
UserStore $store, | |||||
UserSolver $solver | |||||
) { | ) { | ||||
$this->factory = $factory; | $this->factory = $factory; | ||||
$this->builder = $builder; | $this->builder = $builder; | ||||
$this->repositoryQuery = $repositoryQuery; | $this->repositoryQuery = $repositoryQuery; | ||||
$this->store = $store; | $this->store = $store; | ||||
$this->solver = $solver; | |||||
} | } | ||||
public function getFactory(): UserFactory | public function getFactory(): UserFactory | ||||
{ | { | ||||
return $this->store; | return $this->store; | ||||
} | } | ||||
public function getSolver(): UserSolver | |||||
{ | |||||
return $this->solver; | |||||
} | |||||
} | } |
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | ||||
use Lc\CaracoleBundle\Controller\Order\OrderShopAdminController; | |||||
use Lc\SovBundle\Component\EntityComponent; | use Lc\SovBundle\Component\EntityComponent; | ||||
use Lc\SovBundle\Container\ComponentContainer; | use Lc\SovBundle\Container\ComponentContainer; | ||||
use Lc\SovBundle\Container\File\FileContainer; | use Lc\SovBundle\Container\File\FileContainer; | ||||
use Symfony\Component\Form\FormInterface; | use Symfony\Component\Form\FormInterface; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | |||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | ||||
{ | { | ||||
if($responseParameters->get('global_actions')){ | |||||
if ($responseParameters->get('global_actions')) { | |||||
$this->overrideGlobalActions($responseParameters->get('global_actions')); | $this->overrideGlobalActions($responseParameters->get('global_actions')); | ||||
} | } | ||||
if($responseParameters->get('entities')){ | |||||
if ($responseParameters->get('entities')) { | |||||
$this->overrideEntitiesActions($responseParameters->get('entities')); | $this->overrideEntitiesActions($responseParameters->get('entities')); | ||||
} | } | ||||
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | ||||
{ | { | ||||
$entityClass = $this->getEntityFqcn(); | $entityClass = $this->getEntityFqcn(); | ||||
$paramListMaxResults = 'listMaxResults'; | $paramListMaxResults = 'listMaxResults'; | ||||
$paramSessionListMaxResults = $entityClass.'-'.$paramListMaxResults; | |||||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | |||||
$requestListMaxResults = $this->get(RequestStack::class)->getCurrentRequest()->get($paramListMaxResults); | $requestListMaxResults = $this->get(RequestStack::class)->getCurrentRequest()->get($paramListMaxResults); | ||||
if ($requestListMaxResults) { | if ($requestListMaxResults) { | ||||
return $responseParameters; | return $responseParameters; | ||||
} | } | ||||
public function duplicate(AdminContext $context, EntityComponent $entityComponent, TranslatorAdmin $translatorAdmin, EntityManagerInterface $em) | |||||
{ | |||||
public function duplicate( | |||||
AdminContext $context, | |||||
EntityComponent $entityComponent, | |||||
TranslatorAdmin $translatorAdmin, | |||||
EntityManagerInterface $em | |||||
) { | |||||
if (!$this->isGranted( | if (!$this->isGranted( | ||||
Permission::EA_EXECUTE_ACTION, | Permission::EA_EXECUTE_ACTION, | ||||
['action' => "duplicate", 'entity' => $context->getEntity()] | ['action' => "duplicate", 'entity' => $context->getEntity()] | ||||
} | } | ||||
if (isset($button['icon'])) { | if (isset($button['icon'])) { | ||||
$action->setIcon('fa fa-'.$button['icon']); | |||||
$action->setIcon('fa fa-' . $button['icon']); | |||||
} | } | ||||
if (isset($button['label'])) { | if (isset($button['label'])) { | ||||
if ($filterManager->isRelationField($field->getProperty())) { | if ($filterManager->isRelationField($field->getProperty())) { | ||||
$queryBuilder->select($autocompleteContext['propertyName']); | $queryBuilder->select($autocompleteContext['propertyName']); | ||||
} else { | } else { | ||||
$queryBuilder->select('entity.'.$autocompleteContext['propertyName']); | |||||
$queryBuilder->select('entity.' . $autocompleteContext['propertyName']); | |||||
} | } | ||||
$responses = array(); | $responses = array(); | ||||
return JsonResponse::fromJsonString(json_encode($responses)); | return JsonResponse::fromJsonString(json_encode($responses)); | ||||
} | } | ||||
public function createCustomForm($class, $action, $controller, $entity, $dataInOption = true, $options = array()) | |||||
{ | |||||
if ($dataInOption) { | |||||
$options['data'] = $entity; | |||||
} | |||||
$options['action'] = $this->get(AdminUrlGenerator::class) | |||||
->setAction($action) | |||||
->setController($controller) | |||||
->setEntityId($entity->getId()) | |||||
->generateUrl(); | |||||
return $this->createForm($class, null, $options); | |||||
} | |||||
} | } | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | ||||
use Lc\SovBundle\Container\Ticket\TicketContainer; | use Lc\SovBundle\Container\Ticket\TicketContainer; | ||||
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; | |||||
use Lc\SovBundle\Factory\Ticket\TicketFactory; | use Lc\SovBundle\Factory\Ticket\TicketFactory; | ||||
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | ||||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | ||||
] | ] | ||||
); | ); | ||||
$ticketMessage = $this->get(TicketContainer::class)->getFactory()->create(); | |||||
$ticketMessage = $this->get(TicketMessageContainer::class)->getFactory()->create($ticket); | |||||
$formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); | $formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); | ||||
$formAddTicketMessage->handleRequest($this->get(RequestStack::class)->getMainRequest()); | $formAddTicketMessage->handleRequest($this->get(RequestStack::class)->getMainRequest()); | ||||
namespace Lc\SovBundle\Form\Ticket; | namespace Lc\SovBundle\Form\Ticket; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
'status', | 'status', | ||||
ChoiceType::class, | ChoiceType::class, | ||||
[ | [ | ||||
'choices' => $this->translatorAdmin->transChoices(TicketModel::getStatusChoices(),'Ticket', 'status'), | |||||
'choices' => $this->translatorAdmin->transChoices(TicketSolver::getStatusChoices(),'Ticket', 'status'), | |||||
'required' => true, | 'required' => true, | ||||
'expanded' => true, | 'expanded' => true, | ||||
'label' => false, | 'label' => false, |
return $this; | return $this; | ||||
} | } | ||||
public function count(): string | |||||
public function count() | |||||
{ | { | ||||
return $this->query->getQuery() | return $this->query->getQuery() | ||||
->getSingleScalarResult(); | ->getSingleScalarResult(); | ||||
} | } | ||||
public function findOne(): ?EntityInterface | |||||
public function findOne() | |||||
{ | { | ||||
return $this->query->getQuery() | return $this->query->getQuery() | ||||
->setMaxResults(1) | ->setMaxResults(1) |
public function call(callable $fn):self; | public function call(callable $fn):self; | ||||
public function count(): string; | |||||
public function count(); | |||||
public function findOne(): ?EntityInterface; | |||||
public function findOne(); | |||||
public function find(): array; | public function find(): array; | ||||
public function filterIsDeleted():self; | public function filterIsDeleted():self; | ||||
public function filterIsOnlineAndOffline():self; | public function filterIsOnlineAndOffline():self; | ||||
} | |||||
} |
for (var key in notifications[type]) { | for (var key in notifications[type]) { | ||||
if (!currentNotifications.includes(notifications[type][key])) { | if (!currentNotifications.includes(notifications[type][key])) { | ||||
currentNotifications.push(notifications[type][key]); | currentNotifications.push(notifications[type][key]); | ||||
self.add(type, notifications[type][key]); | |||||
SovNotification.add(type, notifications[type][key]); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
} | |||||
} |
} | } | ||||
} | } | ||||
} | } | ||||
static checkFormValidity(formId){ | |||||
if(!document.getElementById(formId.substr(1)).checkValidity()){ | |||||
document.getElementById(formId.substr(1)).reportValidity() | |||||
return false; | |||||
}else{ | |||||
return true; | |||||
} | |||||
} | |||||
} | } |
{% block icon %}fa fa-user{% endblock %} | {% block icon %}fa fa-user{% endblock %} | ||||
{% block title %}Utilisateur{% endblock %} | {% block title %}Utilisateur{% endblock %} | ||||
{% block content %} | {% block content %} | ||||
{{ ticket.getUserInfosTicket() }} | |||||
{{ ticket_container.solver.getUserInfosTicket(ticket) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% endembed %} | {% endembed %} | ||||
{% endembed %} | {% endembed %} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
{% endblock %} | |||||
{% endblock %} |
{{ entity.instance.getEmail() }} | |||||
{#{{ entity.instance.getEmail() }}#} |
{% 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 }} | |||||
{#{% 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 }}#} |
{{ entity.instance.getUsername() }} | |||||
{#{{ entity.instance.user.getUsername() }}#} |
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | {{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | ||||
{% endblock content_breadcrumb %} | {% endblock content_breadcrumb %} | ||||
{% set has_batch_actions = batch_actions|length > 0 %} | |||||
{% block page_actions %} | {% block page_actions %} | ||||
{% endblock page_actions %} | {% endblock page_actions %} | ||||
<div class="info-box"> | |||||
<span class="info-box-icon {% block class %}bg-info{% endblock %}"> | |||||
<i class="fa fa-{% block icon %}bg-info{% endblock %}"></i></span> | |||||
<div class="info-box-content"> | |||||
{% block info_box %} | |||||
<span class="info-box-text">{% block label %}{% endblock %}</span> | |||||
<strong>{% block value %}{% endblock %}</strong> | |||||
{% endblock %} | |||||
<div class="float-right"> {% block button %}{% endblock %} | |||||
</div> | |||||
</div> | |||||
</div> |
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text">{% block title %}{% endblock %}</span> | <span class="info-box-text">{% block title %}{% endblock %}</span> | ||||
<span class="info-box-number">{% block content %}{% endblock %}</span> | <span class="info-box-number">{% block content %}{% endblock %}</span> | ||||
<div class="float-right"> | |||||
{% block button %}{% endblock %} | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> |
{% macro infobox(title, content, color, icon) %} | |||||
<div class="info-box"> | |||||
<!-- Apply any bg-* class to to the icon to color it --> | |||||
<span class="info-box-icon bg-{{ color }}"><i class="{{ icon }}"></i></span> | |||||
<div class="info-box-content"> | |||||
<span class="info-box-text">{{ title }}</span> | |||||
<span class="info-box-number">{{ content }}</span> | |||||
</div> | |||||
<!-- /.info-box-content --> | |||||
</div> | |||||
<!-- /.info-box --> | |||||
{% endmacro %} | |||||
{% macro infobox(title, content, color, icon, button=null) %} | |||||
{% embed '@LcSov/adminlte/embed/infobox.html.twig' %} | |||||
{% block color %}{{ color }}{% endblock %} | |||||
{% block icon %}{{ icon }}{% endblock %} | |||||
{% block title %}{{ title }}{% endblock %} | |||||
{% block content %}{{ content }}{% endblock %} | |||||
{% block button %}{{ button }}{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro %} |
{ | { | ||||
$user = $ticket->getUser(); | $user = $ticket->getUser(); | ||||
if ($user) { | if ($user) { | ||||
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail(); | |||||
return '#'.$user->getId().' '.$user->getFirstname().' '.$user->getLastname(). ' '.$user->getEmail(); | |||||
} else { | } else { | ||||
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail( | return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail( | ||||
); | ); |
{ | { | ||||
return $user->getNewsletters()->contains($newsletter); | return $user->getNewsletters()->contains($newsletter); | ||||
} | } | ||||
public function getAge(UserInterface $user): ?int | |||||
{ | |||||
if($user->getBirthdate()) { | |||||
$now = new \DateTime(); | |||||
$interval = $now->diff($user->getBirthdate()); | |||||
return $interval->y; | |||||
}else{ | |||||
return null; | |||||
} | |||||
} | |||||
} | } |