public function findByUser($user) | public function findByUser($user) | ||||
{ | { | ||||
$qb = $this->findByMerchantQuery() | |||||
$qb = $this->createQueryBuilder('e') | |||||
->leftJoin('e.users', 'u') | ->leftJoin('e.users', 'u') | ||||
->having('COUNT(u.id) = 0') | ->having('COUNT(u.id) = 0') | ||||
->orHaving(':user MEMBER OF e.users') | ->orHaving(':user MEMBER OF e.users') | ||||
return $qb->getQuery()->getResult(); | return $qb->getQuery()->getResult(); | ||||
} | } | ||||
public function findByEasyAdminConfigAndUser($action, $entity, $user, $id = null) | |||||
public function findByEasyAdminConfigAndUser($crudAction, $crudControllerFqcn, $user, $entityId = null) | |||||
{ | { | ||||
$qb = $this->findByMerchantQuery(); | |||||
$qb = $this->createQueryBuilder('e'); | |||||
$qb->leftJoin('e.users', 'u'); | $qb->leftJoin('e.users', 'u'); | ||||
$qb->having('COUNT(u.id) = 0'); | $qb->having('COUNT(u.id) = 0'); | ||||
$qb->orHaving(':user MEMBER OF e.users'); | $qb->orHaving(':user MEMBER OF e.users'); | ||||
$qb->andWhere('e.done = 0'); | $qb->andWhere('e.done = 0'); | ||||
$qb->andWhere('e.entityAction LIKE :action'); | |||||
$qb->andWhere('e.entityName LIKE :entity'); | |||||
$qb->setParameter('entity', $entity); | |||||
$qb->setParameter('action', $action); | |||||
$qb->andWhere('e.crudAction LIKE :crudAction'); | |||||
$qb->andWhere('e.crudControllerFqcn LIKE :entity'); | |||||
$qb->setParameter('crudAction', $crudAction); | |||||
$qb->setParameter('crudControllerFqcn', $crudControllerFqcn); | |||||
$qb->setParameter('user', $user); | $qb->setParameter('user', $user); | ||||
if ($id) { | |||||
if ($entityId) { | |||||
$qb->andWhere('e.entityId LIKE :id'); | $qb->andWhere('e.entityId LIKE :id'); | ||||
$qb->setParameter('id', $id); | |||||
$qb->setParameter('entityId', $entityId); | |||||
} | } | ||||
$qb->orderBy('e.dateReminder', 'ASC'); | $qb->orderBy('e.dateReminder', 'ASC'); | ||||
$qb->groupBy('e.id'); | $qb->groupBy('e.id'); |
div#reminders { | |||||
ul.todo-list { | |||||
li { | |||||
div.text { | |||||
padding-left: 30px ; | |||||
} | |||||
} | |||||
} | |||||
} |
<section class="content-header"> | <section class="content-header"> | ||||
<div class="container-fluid"> | <div class="container-fluid"> | ||||
<div class="row mb-2"> | <div class="row mb-2"> | ||||
{% set reminders = sov_get_reminders() %} | |||||
{% if reminders %} | |||||
<div class="col-sm-12"> | |||||
<div id="reminders" class="card card-outline card-danger"> | |||||
<ul class="todo-list"> | |||||
{% for reminder in reminders %} | |||||
<li> | |||||
<label class="big form-check-label"> | |||||
<input type="checkbox" name="" value="1" class="form-check-input checkbox-valid-reminder" data-url="/admin/?action=setReminderDone&entity=Reminder&id=90"> | |||||
<span class="checkmark"></span> | |||||
</label> | |||||
<div class="text"> | |||||
{{ reminder.description }} | |||||
</div> | |||||
<div class="tools"> | |||||
<button type="button" class="btn-sm btn-success" data-toggle="modal" data-target="#modal-reminder-91"> | |||||
<i class="fas fa-eye"></i> | |||||
</button> | |||||
<button type="button" class="btn-sm btn-info btn-edit-reminder" data-url="/admin/?action=edit&entity=Reminder&id=91"> | |||||
<i class="fas fa-edit"></i> | |||||
</button> | |||||
</div> | |||||
</li> | |||||
{% endfor %} | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
{% endif %} | |||||
{% set has_help_message = (ea.crud.helpMessage ?? '') is not empty %} | {% set has_help_message = (ea.crud.helpMessage ?? '') is not empty %} | ||||
{% block content_header %} | {% block content_header %} | ||||
<div class="col-sm-6"> | <div class="col-sm-6"> |
namespace Lc\SovBundle\Twig; | namespace Lc\SovBundle\Twig; | ||||
use App\Repository\ReminderRepository; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\SovBundle\Factory\Reminder\ReminderFactory; | |||||
use Lc\SovBundle\Form\Reminder\ReminderAdminFormType; | |||||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | use Liip\ImagineBundle\Imagine\Cache\CacheManager; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\Form\FormFactoryInterface; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpKernel\KernelInterface; | use Symfony\Component\HttpKernel\KernelInterface; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
protected $router; | protected $router; | ||||
protected $translator; | protected $translator; | ||||
protected $translatorAdmin; | protected $translatorAdmin; | ||||
protected $formFactory; | |||||
protected $reminderFactory; | |||||
public function __construct( | public function __construct( | ||||
KernelInterface $kernel, | KernelInterface $kernel, | ||||
RequestStack $requestStack, | RequestStack $requestStack, | ||||
UrlGeneratorInterface $router, | UrlGeneratorInterface $router, | ||||
TranslatorInterface $translator, | TranslatorInterface $translator, | ||||
TranslatorAdmin $translatorAdmin, | |||||
FormFactoryInterface $formFactory, | |||||
ReminderFactory $reminderFactory | |||||
TranslatorAdmin $translatorAdmin | |||||
) { | ) { | ||||
$this->kernel = $kernel; | $this->kernel = $kernel; | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
$this->router = $router; | $this->router = $router; | ||||
$this->translator = $translator; | $this->translator = $translator; | ||||
$this->translatorAdmin = $translatorAdmin; | $this->translatorAdmin = $translatorAdmin; | ||||
$this->formFactory = $formFactory; | |||||
$this->reminderFactory = $reminderFactory; | |||||
} | } | ||||
public function getFunctions() | public function getFunctions() | ||||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | new TwigFunction('homepage_route', [$this, 'homepageRoute']), | ||||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | ||||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']), | new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']), | ||||
new TwigFunction('sov_get_form_reminder', [$this, 'getFormReminder']), | |||||
new TwigFunction('sov_get_reminders', [$this, 'getReminders']), | |||||
); | ); | ||||
} | } | ||||
return $this->parameterBag->get('lc_sov.homepage_route'); | return $this->parameterBag->get('lc_sov.homepage_route'); | ||||
} | } | ||||
public function getFormReminder() | |||||
public function getReminders() | |||||
{ | { | ||||
$reminder = $this->reminderFactory->create(); | |||||
$formReminder = $this->formFactory->create(ReminderAdminFormType::class, $reminder); | |||||
return $formReminder->createView(); | |||||
$reminders = $this->em->getRepository(ReminderInterface::class)->findAll() ; | |||||
return $reminders; | |||||
} | } | ||||
} | } |