<?php | |||||
namespace Lc\SovBundle\Controller\Reminder; | |||||
use Lc\SovBundle\Controller\AbstractAdminController; | |||||
use Symfony\Component\HttpFoundation\Response; | |||||
abstract class ReminderController extends AbstractAdminController | |||||
{ | |||||
public function renderTemplate($actionName, $templatePath, array $parameters = []) | |||||
{ | |||||
if ($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) { | |||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||||
$response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent(); | |||||
return new Response(json_encode($response)); | |||||
} else { | |||||
return parent::renderTemplate($actionName, $templatePath, $parameters); | |||||
} | |||||
} | |||||
protected function redirectToReferrer() | |||||
{ | |||||
$action = $this->request->query->get('action'); | |||||
if ($action == 'new') { | |||||
$this->utils->addFlash('success', 'success.reminder.add'); | |||||
} elseif ($action == 'edit') { | |||||
$this->utils->addFlash('success', 'success.reminder.edit'); | |||||
} elseif ($action == ' setReminderDone') { | |||||
$this->utils->addFlash('success', 'success.reminder.done'); | |||||
} | |||||
if ($this->request->isXmlHttpRequest()) { | |||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | |||||
return new Response(json_encode($response)); | |||||
} else { | |||||
return parent::redirectToReferrer(); | |||||
} | |||||
} | |||||
public function setReminderDoneAction() | |||||
{ | |||||
$id = $this->request->query->get('id'); | |||||
$done = $this->request->query->get('done'); | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$reminder = $easyadmin['item']; | |||||
$reminder->setDone($done); | |||||
$this->em->persist($reminder); | |||||
$this->em->flush(); | |||||
return $this->redirectToReferrer(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Controller\Setting; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |||||
class SettingAdminController extends AbstractController | |||||
{ | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct( | |||||
EntityManagerInterface $em, | |||||
TranslatorAdmin $translatorAdmin | |||||
) | |||||
{ | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Model\Reminder; | |||||
interface ReminderInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Model\Reminder; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||||
use Lc\SovBundle\Model\User\UserInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class ReminderModel extends AbstractLightEntity | |||||
{ | |||||
/** | |||||
* temporary fields (do not delete) | |||||
*/ | |||||
public $relatedPage; | |||||
/** | |||||
* @ORM\Column(type="string", length=255) | |||||
*/ | |||||
protected $title; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $description; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $entityName; | |||||
/** | |||||
* @ORM\Column(type="integer", nullable=true) | |||||
*/ | |||||
protected $entityId; | |||||
/** | |||||
* @ORM\Column(type="string", length=255, nullable=true) | |||||
*/ | |||||
protected $entityAction; | |||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||||
*/ | |||||
protected $users; | |||||
/** | |||||
* @ORM\Column(type="date", nullable=true) | |||||
*/ | |||||
protected $dateReminder; | |||||
/** | |||||
* @ORM\Column(type="boolean", nullable=false) | |||||
*/ | |||||
protected $done; | |||||
public function __construct() | |||||
{ | |||||
$this->users = new ArrayCollection(); | |||||
$this->done = false; | |||||
} | |||||
public function getTitle(): ?string | |||||
{ | |||||
return $this->title; | |||||
} | |||||
public function setTitle(string $title): self | |||||
{ | |||||
$this->title = $title; | |||||
return $this; | |||||
} | |||||
public function getDescription(): ?string | |||||
{ | |||||
return $this->description; | |||||
} | |||||
public function setDescription(?string $description): self | |||||
{ | |||||
$this->description = $description; | |||||
return $this; | |||||
} | |||||
public function getEntityName(): ?string | |||||
{ | |||||
return $this->entityName; | |||||
} | |||||
public function setEntityName(?string $entityName): self | |||||
{ | |||||
$this->entityName = $entityName; | |||||
return $this; | |||||
} | |||||
public function getEntityAction(): ?string | |||||
{ | |||||
return $this->entityAction; | |||||
} | |||||
public function setEntityAction(?string $entityAction): self | |||||
{ | |||||
$this->entityAction = $entityAction; | |||||
return $this; | |||||
} | |||||
public function getEntityId(): ?int | |||||
{ | |||||
return $this->entityId; | |||||
} | |||||
public function setEntityId(?int $entityId): self | |||||
{ | |||||
$this->entityId = $entityId; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|UserInterface[] | |||||
*/ | |||||
public function getUsers(): Collection | |||||
{ | |||||
return $this->users; | |||||
} | |||||
public function addUser(UserInterface $user): self | |||||
{ | |||||
if (!$this->users->contains($user)) { | |||||
$this->users[] = $user; | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeUser(UserInterface $user): self | |||||
{ | |||||
if ($this->users->contains($user)) { | |||||
$this->users->removeElement($user); | |||||
} | |||||
return $this; | |||||
} | |||||
public function getDateReminder(): ?\DateTimeInterface | |||||
{ | |||||
return $this->dateReminder; | |||||
} | |||||
public function setDateReminder(?\DateTimeInterface $dateReminder): self | |||||
{ | |||||
$this->dateReminder = $dateReminder; | |||||
return $this; | |||||
} | |||||
public function getDone(): ?bool | |||||
{ | |||||
return $this->done; | |||||
} | |||||
public function setDone(?bool $done): self | |||||
{ | |||||
$this->done = $done; | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Model\Setting; | |||||
interface SettingInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Model\Setting; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
*/ | |||||
abstract class SettingModel | |||||
{ | |||||
/** | |||||
* @ORM\Column(type="string", length=63) | |||||
*/ | |||||
protected $name; | |||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $text; | |||||
/** | |||||
* @ORM\Column(type="datetime", nullable=true) | |||||
*/ | |||||
protected $date; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity=FileInterface::class, cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $file; | |||||
public function getValue() | |||||
{ | |||||
if ($this->getText()) { | |||||
return $this->getText(); | |||||
} elseif ($this->getDate()) { | |||||
return $this->getDate(); | |||||
} elseif ($this->getFile()) { | |||||
return $this->getFile(); | |||||
} | |||||
} | |||||
public function getName(): ?string | |||||
{ | |||||
return $this->name; | |||||
} | |||||
public function setName(string $name): self | |||||
{ | |||||
$this->name = $name; | |||||
return $this; | |||||
} | |||||
public function getText(): ?string | |||||
{ | |||||
return $this->text; | |||||
} | |||||
public function setText($text): self | |||||
{ | |||||
$this->text = $text; | |||||
return $this; | |||||
} | |||||
public function getDate(): ?\DateTimeInterface | |||||
{ | |||||
return $this->date; | |||||
} | |||||
public function setDate(?\DateTimeInterface $date): self | |||||
{ | |||||
$this->date = $date; | |||||
return $this; | |||||
} | |||||
public function getFile(): ?FileInterface | |||||
{ | |||||
return $this->file; | |||||
} | |||||
public function setFile(?FileInterface $file): self | |||||
{ | |||||
$this->file = $file; | |||||
return $this; | |||||
} | |||||
} |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class GroupUserModel extends AbstractLightEntity implements FilterMerchantInterface | |||||
abstract class GroupUserModel extends AbstractLightEntity | |||||
{ | { | ||||
/** | /** |
<?php | |||||
namespace Lc\SovBundle\Repository\Reminder; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||||
/** | |||||
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method ReminderInterface[] findAll() | |||||
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class ReminderRepository extends AbstractRepository | |||||
{ | |||||
public function getInterfaceClass() | |||||
{ | |||||
return ReminderInterface::class; | |||||
} | |||||
public function findByUser($user) | |||||
{ | |||||
$qb = $this->findByMerchantQuery() | |||||
->leftJoin('e.users', 'u') | |||||
->having('COUNT(u.id) = 0') | |||||
->orHaving(':user MEMBER OF e.users') | |||||
->andWhere('e.done = 0') | |||||
->setParameter('user', $user) | |||||
->orderBy('e.dateReminder', 'ASC') | |||||
->groupBy('e.id'); | |||||
return $qb->getQuery()->getResult(); | |||||
} | |||||
public function findByEasyAdminConfigAndUser($action, $entity, $user, $id = null) | |||||
{ | |||||
$qb = $this->findByMerchantQuery(); | |||||
$qb->leftJoin('e.users', 'u'); | |||||
$qb->having('COUNT(u.id) = 0'); | |||||
$qb->orHaving(':user MEMBER OF e.users'); | |||||
$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->setParameter('user', $user); | |||||
if ($id) { | |||||
$qb->andWhere('e.entityId LIKE :id'); | |||||
$qb->setParameter('id', $id); | |||||
} | |||||
$qb->orderBy('e.dateReminder', 'ASC'); | |||||
$qb->groupBy('e.id'); | |||||
return $qb->getQuery()->getResult(); | |||||
} | |||||
} |
<?php | |||||
namespace Lc\SovBundle\Repository\Setting; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | |||||
use Lc\SovBundle\Model\Setting\SettingInterface; | |||||
/** | |||||
* @method SettingInterface|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method SettingInterface|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method SettingInterface[] findAll() | |||||
* @method SettingInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class SettingRepository extends AbstractRepository | |||||
{ | |||||
public function getInterfaceClass() | |||||
{ | |||||
return SettingInterface::class; | |||||
} | |||||
} |
namespace Lc\SovBundle\Repository\User; | namespace Lc\SovBundle\Repository\User; | ||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
use Lc\SovBundle\Repository\AbstractRepository; | use Lc\SovBundle\Repository\AbstractRepository; | ||||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||||
/** | /** | ||||
* @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method GroupUserInterface|null find($id, $lockMode = null, $lockVersion = null) |