@@ -3,15 +3,18 @@ | |||
namespace Lc\SovBundle\Component; | |||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
class FileComponent | |||
{ | |||
protected ParameterBagInterface $parameterBag; | |||
protected CacheManager $liipCacheHelper; | |||
public function __construct(ParameterBagInterface $parameterBag) | |||
public function __construct(ParameterBagInterface $parameterBag, CacheManager $liipCacheHelper) | |||
{ | |||
$this->parameterBag = $parameterBag; | |||
$this->liipCacheHelper = $liipCacheHelper; | |||
} | |||
/** |
@@ -6,6 +6,7 @@ use Lc\SovBundle\Builder\User\UserBuilder; | |||
use Lc\SovBundle\Factory\User\UserFactory; | |||
use Lc\SovBundle\Repository\User\UserRepositoryQuery; | |||
use Lc\SovBundle\Repository\User\UserStore; | |||
use Lc\SovBundle\Solver\User\UserSolver; | |||
class UserContainer | |||
{ | |||
@@ -13,17 +14,20 @@ class UserContainer | |||
protected UserBuilder $builder; | |||
protected UserRepositoryQuery $repositoryQuery; | |||
protected UserStore $store; | |||
protected UserSolver $solver; | |||
public function __construct( | |||
UserFactory $factory, | |||
UserBuilder $builder, | |||
UserRepositoryQuery $repositoryQuery, | |||
UserStore $store | |||
UserStore $store, | |||
UserSolver $solver | |||
) { | |||
$this->factory = $factory; | |||
$this->builder = $builder; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
$this->solver = $solver; | |||
} | |||
public function getFactory(): UserFactory | |||
@@ -45,4 +49,9 @@ class UserContainer | |||
{ | |||
return $this->store; | |||
} | |||
public function getSolver(): UserSolver | |||
{ | |||
return $this->solver; | |||
} | |||
} |
@@ -36,6 +36,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | |||
use Lc\CaracoleBundle\Controller\Order\OrderShopAdminController; | |||
use Lc\SovBundle\Component\EntityComponent; | |||
use Lc\SovBundle\Container\ComponentContainer; | |||
use Lc\SovBundle\Container\File\FileContainer; | |||
@@ -68,6 +69,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormInterface; | |||
use Symfony\Component\HttpFoundation\JsonResponse; | |||
use Symfony\Component\HttpFoundation\RequestStack; | |||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | |||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||
@@ -104,10 +106,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | |||
{ | |||
if($responseParameters->get('global_actions')){ | |||
if ($responseParameters->get('global_actions')) { | |||
$this->overrideGlobalActions($responseParameters->get('global_actions')); | |||
} | |||
if($responseParameters->get('entities')){ | |||
if ($responseParameters->get('entities')) { | |||
$this->overrideEntitiesActions($responseParameters->get('entities')); | |||
} | |||
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { | |||
@@ -186,7 +188,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
{ | |||
$entityClass = $this->getEntityFqcn(); | |||
$paramListMaxResults = 'listMaxResults'; | |||
$paramSessionListMaxResults = $entityClass.'-'.$paramListMaxResults; | |||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | |||
$requestListMaxResults = $this->get(RequestStack::class)->getCurrentRequest()->get($paramListMaxResults); | |||
if ($requestListMaxResults) { | |||
@@ -325,9 +327,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
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( | |||
Permission::EA_EXECUTE_ACTION, | |||
['action' => "duplicate", 'entity' => $context->getEntity()] | |||
@@ -713,7 +718,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
} | |||
if (isset($button['icon'])) { | |||
$action->setIcon('fa fa-'.$button['icon']); | |||
$action->setIcon('fa fa-' . $button['icon']); | |||
} | |||
if (isset($button['label'])) { | |||
@@ -761,7 +766,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
if ($filterManager->isRelationField($field->getProperty())) { | |||
$queryBuilder->select($autocompleteContext['propertyName']); | |||
} else { | |||
$queryBuilder->select('entity.'.$autocompleteContext['propertyName']); | |||
$queryBuilder->select('entity.' . $autocompleteContext['propertyName']); | |||
} | |||
$responses = array(); | |||
@@ -773,6 +778,20 @@ abstract class AbstractAdminController extends EaAbstractCrudController | |||
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); | |||
} | |||
} | |||
@@ -15,6 +15,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use Lc\SovBundle\Container\Ticket\TicketContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; | |||
use Lc\SovBundle\Factory\Ticket\TicketFactory; | |||
use Lc\SovBundle\Factory\Ticket\TicketFactoryInterface; | |||
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory; | |||
@@ -144,7 +145,7 @@ class TicketAdminController extends AbstractAdminController | |||
] | |||
); | |||
$ticketMessage = $this->get(TicketContainer::class)->getFactory()->create(); | |||
$ticketMessage = $this->get(TicketMessageContainer::class)->getFactory()->create($ticket); | |||
$formAddTicketMessage = $this->createForm(TicketMessageFormType::class, $ticketMessage); | |||
$formAddTicketMessage->handleRequest($this->get(RequestStack::class)->getMainRequest()); | |||
@@ -3,6 +3,7 @@ | |||
namespace Lc\SovBundle\Form\Ticket; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\SovBundle\Solver\Ticket\TicketSolver; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
@@ -29,7 +30,7 @@ class TicketStatusType extends AbstractType | |||
'status', | |||
ChoiceType::class, | |||
[ | |||
'choices' => $this->translatorAdmin->transChoices(TicketModel::getStatusChoices(),'Ticket', 'status'), | |||
'choices' => $this->translatorAdmin->transChoices(TicketSolver::getStatusChoices(),'Ticket', 'status'), | |||
'required' => true, | |||
'expanded' => true, | |||
'label' => false, |
@@ -48,13 +48,13 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface | |||
return $this; | |||
} | |||
public function count(): string | |||
public function count() | |||
{ | |||
return $this->query->getQuery() | |||
->getSingleScalarResult(); | |||
} | |||
public function findOne(): ?EntityInterface | |||
public function findOne() | |||
{ | |||
return $this->query->getQuery() | |||
->setMaxResults(1) |
@@ -11,9 +11,9 @@ interface RepositoryQueryInterface | |||
public function call(callable $fn):self; | |||
public function count(): string; | |||
public function count(); | |||
public function findOne(): ?EntityInterface; | |||
public function findOne(); | |||
public function find(): array; | |||
@@ -44,4 +44,4 @@ interface RepositoryQueryInterface | |||
public function filterIsDeleted():self; | |||
public function filterIsOnlineAndOffline():self; | |||
} | |||
} |
@@ -17,7 +17,7 @@ export class SovNotification { | |||
for (var key in notifications[type]) { | |||
if (!currentNotifications.includes(notifications[type][key])) { | |||
currentNotifications.push(notifications[type][key]); | |||
self.add(type, notifications[type][key]); | |||
SovNotification.add(type, notifications[type][key]); | |||
} | |||
} | |||
} | |||
@@ -43,4 +43,4 @@ export class SovNotification { | |||
}); | |||
} | |||
} | |||
} |
@@ -97,4 +97,13 @@ export class SovTools { | |||
} | |||
} | |||
} | |||
static checkFormValidity(formId){ | |||
if(!document.getElementById(formId.substr(1)).checkValidity()){ | |||
document.getElementById(formId.substr(1)).reportValidity() | |||
return false; | |||
}else{ | |||
return true; | |||
} | |||
} | |||
} |
@@ -27,7 +27,7 @@ | |||
{% block icon %}fa fa-user{% endblock %} | |||
{% block title %}Utilisateur{% endblock %} | |||
{% block content %} | |||
{{ ticket.getUserInfosTicket() }} | |||
{{ ticket_container.solver.getUserInfosTicket(ticket) }} | |||
{% endblock %} | |||
{% endembed %} | |||
@@ -93,4 +93,4 @@ | |||
{% endembed %} | |||
</div> | |||
</div> | |||
{% endblock %} | |||
{% endblock %} |
@@ -1 +1 @@ | |||
{{ entity.instance.getEmail() }} | |||
{#{{ entity.instance.getEmail() }}#} |
@@ -1,7 +1,7 @@ | |||
{% 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 }}#} |
@@ -1 +1 @@ | |||
{{ entity.instance.getUsername() }} | |||
{#{{ entity.instance.user.getUsername() }}#} |
@@ -16,7 +16,7 @@ | |||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | |||
{% endblock content_breadcrumb %} | |||
{% set has_batch_actions = batch_actions|length > 0 %} | |||
{% block page_actions %} | |||
{% endblock page_actions %} | |||
@@ -1,15 +0,0 @@ | |||
<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> |
@@ -4,5 +4,8 @@ | |||
<div class="info-box-content"> | |||
<span class="info-box-text">{% block title %}{% endblock %}</span> | |||
<span class="info-box-number">{% block content %}{% endblock %}</span> | |||
<div class="float-right"> | |||
{% block button %}{% endblock %} | |||
</div> | |||
</div> | |||
</div> |
@@ -1,12 +1,9 @@ | |||
{% 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 %} |
@@ -47,7 +47,7 @@ class TicketSolver | |||
{ | |||
$user = $ticket->getUser(); | |||
if ($user) { | |||
return '#'.$user->getId().' '.$user->getName().' '.$user->getEmail(); | |||
return '#'.$user->getId().' '.$user->getFirstname().' '.$user->getLastname(). ' '.$user->getEmail(); | |||
} else { | |||
return strtoupper($ticket->getVisitorLastname()).' '.$ticket->getVisitorFirstname().' '.$ticket->getVisitorEmail( | |||
); |
@@ -50,4 +50,16 @@ class UserSolver | |||
{ | |||
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; | |||
} | |||
} | |||
} |