$response = array(); | $response = array(); | ||||
foreach ($values as $value) { | foreach ($values as $value) { | ||||
$response[] = $value[$field]; | |||||
$response[] = $value[$this->utils->getFilterWithoutAssociationAlias($field, '_')]; | |||||
} | } | ||||
return new JsonResponse($response); | return new JsonResponse($response); | ||||
if ($pos = strpos($dqlFilter, 'TODAYSTART')) { | if ($pos = strpos($dqlFilter, 'TODAYSTART')) { | ||||
$date = new \DateTime(); | $date = new \DateTime(); | ||||
$dqlFilter = sprintf(str_replace('TODAYSTART', $date->format('Y-m-d').' 00:00:00', $dqlFilter)); | |||||
$dqlFilter = sprintf(str_replace('TODAYSTART', $date->format('Y-m-d') . ' 00:00:00', $dqlFilter)); | |||||
} | } | ||||
if ($pos = strpos($dqlFilter, 'TODAYEND')) { | if ($pos = strpos($dqlFilter, 'TODAYEND')) { | ||||
$date = new \DateTime(); | $date = new \DateTime(); | ||||
$dqlFilter = sprintf(str_replace('TODAYEND', $date->format('Y-m-d').' 23:59:59', $dqlFilter)); | |||||
$dqlFilter = sprintf(str_replace('TODAYEND', $date->format('Y-m-d') . ' 23:59:59', $dqlFilter)); | |||||
} | } | ||||
if ($pos = strpos($dqlFilter, 'sectionLunch')) { | if ($pos = strpos($dqlFilter, 'sectionLunch')) { | ||||
$dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter); | $dqlFilter = $this->commonDqlFilterQueryBuilder($entityClass, $dqlFilter); | ||||
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | $queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | ||||
$this->commonQueryFilter($entityClass, $queryBuilder); | $this->commonQueryFilter($entityClass, $queryBuilder); | ||||
$listFields = $this->entity['list']['fields']; | $listFields = $this->entity['list']['fields']; | ||||
$this->filtersForm = $this->createForm(ListFilterType::class, null, array( | $this->filtersForm = $this->createForm(ListFilterType::class, null, array( | ||||
$this->filtersForm->handleRequest($this->request); | $this->filtersForm->handleRequest($this->request); | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$view = $easyadmin['view']; | $view = $easyadmin['view']; | ||||
if($easyadmin['view']=='listChildren') $view = 'list'; | |||||
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters']!==false) { | |||||
if ($easyadmin['view'] == 'listChildren') $view = 'list'; | |||||
if (($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) || $this->entity[$view]['filters'] !== false) { | |||||
foreach ($listFields as $field) { | foreach ($listFields as $field) { | ||||
$field['initProperty'] = $field['property']; | |||||
$field['property'] = $this->utils->getFilterPropertyClean($field['property']); | |||||
//if ($this->filtersForm->has($field['property'])->getConfig()->getOption('AdminController')) { | //if ($this->filtersForm->has($field['property'])->getConfig()->getOption('AdminController')) { | ||||
if ($this->filtersForm->has($field['property'])) { | if ($this->filtersForm->has($field['property'])) { | ||||
switch ($field['dataType']) { | switch ($field['dataType']) { | ||||
$filter = $this->getListFilterParam($field['property']); | $filter = $this->getListFilterParam($field['property']); | ||||
//$filter = $this->filtersForm->get($field['property'])->getData(); | //$filter = $this->filtersForm->get($field['property'])->getData(); | ||||
if ($filter !== null) { | if ($filter !== null) { | ||||
if ($this->utils->hasFilterAssociation($field['initProperty'])) { | |||||
$aliasRelation = $this->utils->getFilterAssociationAlias($field['initProperty']); | |||||
if(array_search($aliasRelation, $queryBuilder->getAllAliases())===false){ | |||||
$queryBuilder->innerJoin('entity.'.$aliasRelation, $aliasRelation); | |||||
} | |||||
$queryBuilder->andWhere($field['initProperty'] . ' LIKE :' . $field['property'] . ''); | |||||
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); | |||||
} else { | |||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' LIKE :' . $field['property'] . ''); | |||||
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); | |||||
} | |||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' LIKE :' . $field['property'] . ''); | |||||
$queryBuilder->setParameter($field['property'], '%' . $filter . '%'); | |||||
} | } | ||||
break; | break; | ||||
case 'association' : | case 'association' : | ||||
$filter = $this->getListFilterParam($field['property']); | $filter = $this->getListFilterParam($field['property']); | ||||
//$filter = $this->filtersForm->get($field['property'])->getData(); | |||||
//$filter = $this->filtersForm->get($field['property'])->getData(); | |||||
if ($filter !== null) { | if ($filter !== null) { | ||||
if ($field['type_options']['multiple']) { | |||||
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ''); | |||||
} else { | |||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | |||||
} | |||||
if ($filter instanceof TreeInterface && $filter->getParent() == null) { | |||||
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); | |||||
} else { | |||||
//TODO Faut généraliser avec TreeInterface, ça ne doit pas être ici | |||||
if($field['property'] == 'productCategories') { | |||||
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'].' OR product_categories.parent = :' . $field['property']); | |||||
$queryBuilder->setParameter($field['property'], $filter); | $queryBuilder->setParameter($field['property'], $filter); | ||||
} | } | ||||
else { | |||||
if ($field['type_options']['multiple']) { | |||||
$queryBuilder->andWhere(':' . $field['property'] . ' MEMBER OF entity.' . $field['property'] . ''); | |||||
} | |||||
else { | |||||
$queryBuilder->andWhere('entity.' . $field['property'] . ' = :' . $field['property'] . ''); | |||||
} | |||||
if ($filter instanceof TreeInterface && $filter->getParent() == null) { | |||||
$queryBuilder->setParameter($field['property'], array_merge(array($filter), $filter->getChildrens()->toArray())); | |||||
} | |||||
else { | |||||
$queryBuilder->setParameter($field['property'], $filter); | |||||
} | |||||
} | |||||
} | } | ||||
break; | break; | ||||
case 'datetime': | case 'datetime': | ||||
} | } | ||||
//TODO déplacer dans LC | //TODO déplacer dans LC | ||||
if($this->entity['name']== 'OrderShopLunch' || $this->entity['name']== 'OrderShopLunchDay'){ | |||||
if ($this->entity['name'] == 'OrderShopLunch' || $this->entity['name'] == 'OrderShopLunchDay') { | |||||
$queryBuilder->addOrderBy('entity.user', 'asc'); | $queryBuilder->addOrderBy('entity.user', 'asc'); | ||||
} | } | ||||
//TODO finaliser la sauvegarde des filtres | //TODO finaliser la sauvegarde des filtres | ||||
protected function getListFilterParam($param, $extraParam = null){ | |||||
protected function getListFilterParam($param, $extraParam = null) | |||||
{ | |||||
$entityName = $this->entity['name']; | $entityName = $this->entity['name']; | ||||
$sessionParam = $entityName.$param.$extraParam; | |||||
$sessionParam = $entityName . $param . $extraParam; | |||||
//CUSTOM | //CUSTOM | ||||
if($extraParam){ | |||||
if ($extraParam) { | |||||
$value = $this->filtersForm->get($param)->get($extraParam)->getViewData(); | $value = $this->filtersForm->get($param)->get($extraParam)->getViewData(); | ||||
}else{ | |||||
} else { | |||||
$value = $this->filtersForm->get($param)->getViewData(); | $value = $this->filtersForm->get($param)->getViewData(); | ||||
} | } | ||||
if($this->request->query->get('filterClear')){ | |||||
if ($this->request->query->get('filterClear')) { | |||||
$this->session->remove($sessionParam); | $this->session->remove($sessionParam); | ||||
}else { | |||||
} else { | |||||
if ($value) { | if ($value) { | ||||
$this->session->set($sessionParam, $value); | $this->session->set($sessionParam, $value); | ||||
} else if ($this->session->get($sessionParam) && !$this->filtersForm->isSubmitted() && $this->filtersForm->get($param)) { | } else if ($this->session->get($sessionParam) && !$this->filtersForm->isSubmitted() && $this->filtersForm->get($param)) { | ||||
$value = $this->session->get($sessionParam); | $value = $this->session->get($sessionParam); | ||||
if($extraParam){ | |||||
if ($extraParam) { | |||||
if($this->filtersForm->get($param)->get($extraParam)->getConfig()->getOption('input')=='datetime'){ | |||||
if ($this->filtersForm->get($param)->get($extraParam)->getConfig()->getOption('input') == 'datetime') { | |||||
$this->filtersForm->get($param)->get($extraParam)->setData(new \DateTime($value)); | $this->filtersForm->get($param)->get($extraParam)->setData(new \DateTime($value)); | ||||
}else{ | |||||
} else { | |||||
$this->filtersForm->get($param)->get($extraParam)->setData($value); | $this->filtersForm->get($param)->get($extraParam)->setData($value); | ||||
} | } | ||||
}else { | |||||
} else { | |||||
//Champ association | //Champ association | ||||
if ($this->filtersForm->get($param)->getConfig()->getOption('class')) { | if ($this->filtersForm->get($param)->getConfig()->getOption('class')) { | ||||
$valFormated = $this->em->getRepository($this->filtersForm->get($param)->getConfig()->getOption('class'))->find($value); | $valFormated = $this->em->getRepository($this->filtersForm->get($param)->getConfig()->getOption('class'))->find($value); | ||||
} | } | ||||
} | } | ||||
if($value !== "")return $value; | |||||
if ($value !== "") return $value; | |||||
else return null; | else return null; | ||||
} | } | ||||
public function renderTemplate($actionName, $templatePath, array $parameters = []) | public function renderTemplate($actionName, $templatePath, array $parameters = []) | ||||
{ | { | ||||
} | } | ||||
protected function getListParam($param, $default =null){ | |||||
protected function getListParam($param, $default = null) | |||||
{ | |||||
$entityName = $this->entity['name']; | $entityName = $this->entity['name']; | ||||
$sessionParam = $entityName.$param; | |||||
$sessionParam = $entityName . $param; | |||||
//CUSTOM | //CUSTOM | ||||
if($param == 'maxResults'){ | |||||
$val = $this->entity['list']['max_results']; | |||||
}else{ | |||||
if ($param == 'maxResults') { | |||||
$val = $this->entity['list']['max_results']; | |||||
} else { | |||||
$val = $this->request->query->get($param, $default); | $val = $this->request->query->get($param, $default); | ||||
} | } | ||||
if(isset($_GET[$param])){ | |||||
$val = $this->request->query->get($param); | |||||
if (isset($_GET[$param])) { | |||||
$val = $this->request->query->get($param); | |||||
$this->session->set($sessionParam, $val); | $this->session->set($sessionParam, $val); | ||||
}else if($this->session->get($sessionParam)){ | |||||
$val = $this->session->get($sessionParam); | |||||
} else if ($this->session->get($sessionParam)) { | |||||
$val = $this->session->get($sessionParam); | |||||
$this->request->query->set($param, $val); | $this->request->query->set($param, $val); | ||||
} | } | ||||
$fields = $this->entity['list']['fields']; | $fields = $this->entity['list']['fields']; | ||||
$paginator = $this->findAll($this->entity['class'], $this->getListParam('page', 1), $this->getListParam('maxResults'), $this->getListParam('sortField'), $this->getListParam('sortDirection'), $this->entity['list']['dql_filter']); | |||||
$paginator = $this->findAll($this->entity['class'], $this->getListParam('page', 1), $this->getListParam('maxResults'), $this->getListParam('sortField'), $this->getListParam('sortDirection'), $this->entity['list']['dql_filter']); | |||||
$this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); | $this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); | ||||
namespace Lc\ShopBundle\Controller\Backend; | namespace Lc\ShopBundle\Controller\Backend; | ||||
use App\Entity\OrderShop; | |||||
use App\Form\Backend\Common\AddressType; | use App\Form\Backend\Common\AddressType; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||||
use FOS\UserBundle\Doctrine\UserManager; | use FOS\UserBundle\Doctrine\UserManager; | ||||
use FOS\UserBundle\Model\UserManagerInterface ; | use FOS\UserBundle\Model\UserManagerInterface ; | ||||
use Lc\ShopBundle\Context\AddressInterface; | use Lc\ShopBundle\Context\AddressInterface; | ||||
class UserController extends AdminController | class UserController extends AdminController | ||||
{ | { | ||||
public function showAction() | |||||
{ | |||||
$id = $this->request->query->get('id'); | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$entity = $easyadmin['item']; | |||||
$this->orderShoprepo = $this->em->getRepository(OrderShop::class); | |||||
/* dump($this->orderUtils->getRankTotalOrder($entity)); | |||||
die(); | |||||
dump($this->orderUtils->getRankSumOrderByUser($entity)); | |||||
dump($this->orderUtils->getRankTotalOrderByUser($entity)); | |||||
dump($this->orderUtils->getTotalSpentByUser($entity)); | |||||
dump($this->orderUtils->getAverageOrderByUser($entity)); | |||||
die();*/ | |||||
$this->dispatch(EasyAdminEvents::PRE_SHOW); | |||||
$fields = $this->entity['show']['fields']; | |||||
$deleteForm = $this->createDeleteForm($this->entity['name'], $id); | |||||
$this->dispatch(EasyAdminEvents::POST_SHOW, [ | |||||
'deleteForm' => $deleteForm, | |||||
'fields' => $fields, | |||||
'entity' => $entity, | |||||
]); | |||||
$parameters = [ | |||||
'entity' => $entity, | |||||
'fields' => $fields, | |||||
'delete_form' => $deleteForm->createView(), | |||||
]; | |||||
return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]); | |||||
} | |||||
public function createNewEntity() | public function createNewEntity() | ||||
{ | { | ||||
return $this->userManager->createUser(); | return $this->userManager->createUser(); |
) | ) | ||||
)); | )); | ||||
break; | break; | ||||
case 'text': | |||||
case 'string': | case 'string': | ||||
$builder->add($field['property'], TextType::class, array( | |||||
$builder->add(str_replace('.', '_',$field['property']), TextType::class, array( | |||||
'required' => false, | 'required' => false, | ||||
'attr'=>array( | 'attr'=>array( | ||||
'class'=> ' input-sm', | 'class'=> ' input-sm', |
*/ | */ | ||||
abstract class ReductionCredit extends AbstractEntity implements ReductionInterface, FilterMerchantInterface, StatusInterface | abstract class ReductionCredit extends AbstractEntity implements ReductionInterface, FilterMerchantInterface, StatusInterface | ||||
{ | { | ||||
const TYPE_CREDIT = 'credit' ; | |||||
const TYPE_GIFT = 'gift' ; | |||||
const TYPE_CREDIT = 'credit'; | |||||
const TYPE_GIFT = 'gift'; | |||||
use ReductionTrait; | use ReductionTrait; | ||||
protected $title; | protected $title; | ||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface") | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="reductionCredits") | |||||
*/ | */ | ||||
protected $users; | protected $users; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | ||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getType(): ?string | |||||
{ | |||||
return $this->type; | |||||
} | |||||
public function setType(string $type): self | |||||
{ | |||||
$this->type = $type; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* @return Collection|User[] | * @return Collection|User[] | ||||
*/ | */ | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getType(): ?string | |||||
{ | |||||
return $this->type; | |||||
} | |||||
public function setType(string $type): self | |||||
{ | |||||
$this->type = $type; | |||||
return $this; | |||||
} | |||||
public function getSended(): ?bool | public function getSended(): ?bool | ||||
{ | { |
protected $ticketTypesNotification = []; | protected $ticketTypesNotification = []; | ||||
/** | |||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ReductionCreditInterface", mappedBy="users") | |||||
*/ | |||||
protected $reductionCredits; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->favoriteProductFamilies = new ArrayCollection(); | $this->favoriteProductFamilies = new ArrayCollection(); | ||||
$this->userPointSales = new ArrayCollection(); | $this->userPointSales = new ArrayCollection(); | ||||
$this->userMerchants = new ArrayCollection(); | $this->userMerchants = new ArrayCollection(); | ||||
$this->reductionCredits = new ArrayCollection(); | |||||
$this->tickets = new ArrayCollection(); | |||||
} | } | ||||
public function __toString() | public function __toString() | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @return Collection|ReductionCredit[] | |||||
*/ | |||||
public function getReductionCredits(): Collection | |||||
{ | |||||
return $this->reductionCredits; | |||||
} | |||||
public function addReductionCredit(ReductionCredit $reductionCredit): self | |||||
{ | |||||
if (!$this->reductionCredits->contains($reductionCredit)) { | |||||
$this->reductionCredits[] = $reductionCredit; | |||||
$reductionCredit->addUser($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeReductionCredit(ReductionCredit $reductionCredit): self | |||||
{ | |||||
if ($this->reductionCredits->contains($reductionCredit)) { | |||||
$this->reductionCredits->removeElement($reductionCredit); | |||||
$reductionCredit->removeUser($this); | |||||
} | |||||
return $this; | |||||
} | |||||
} | } |
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | ||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\StatusInterface; | use Lc\ShopBundle\Context\StatusInterface; | ||||
use Lc\ShopBundle\Services\Utils; | |||||
class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface | class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface | ||||
{ | { | ||||
public $merchantUtils; | |||||
protected $merchantUtils; | |||||
protected $utils; | |||||
/** | /** | ||||
* @param string $entityClass The class name of the entity this repository manages | * @param string $entityClass The class name of the entity this repository manages | ||||
*/ | */ | ||||
public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils) | |||||
public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils, Utils $utils) | |||||
{ | { | ||||
$this->merchantUtils = $merchantUtils; | $this->merchantUtils = $merchantUtils; | ||||
$this->utils = $utils; | |||||
parent::__construct($entityManager, $entityManager->getClassMetadata($this->getInterfaceClass())); | parent::__construct($entityManager, $entityManager->getClassMetadata($this->getInterfaceClass())); | ||||
} | } | ||||
public function findByTerm($field, $term, $limit=10){ | public function findByTerm($field, $term, $limit=10){ | ||||
$qb = $this->findByMerchantQuery(); | $qb = $this->findByMerchantQuery(); | ||||
$qb->select('e.'.$field); | |||||
$qb->andWhere( | |||||
$qb->expr()->like('e.'.$field, ':term')); | |||||
if($this->utils->hasFilterAssociation($field, '_')){ | |||||
$aliasRelation = $this->utils->getFilterAssociationAlias($field, '_'); | |||||
$qb->innerJoin('e.'.$aliasRelation, $aliasRelation); | |||||
$qb->select($this->utils->getFilterPropertyInit($field)); | |||||
$qb->groupBy($this->utils->getFilterPropertyInit($field)); | |||||
$qb->andWhere( | |||||
$qb->expr()->like($this->utils->getFilterPropertyInit($field), ':term')); | |||||
}else { | |||||
$qb->select('e.' . $field); | |||||
$qb->groupBy('e.' . $field); | |||||
$qb->andWhere( | |||||
$qb->expr()->like('e.' . $field, ':term')); | |||||
} | |||||
$qb->setParameter('term', '%'.$term.'%'); | $qb->setParameter('term', '%'.$term.'%'); | ||||
$qb->setMaxResults($limit); | $qb->setMaxResults($limit); | ||||
public function findOneByOldUrl($url) | public function findOneByOldUrl($url) | ||||
{ | { | ||||
$qb = $this->createQueryBuilder('entity') | $qb = $this->createQueryBuilder('entity') |
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\ReductionCartInterface; | use Lc\ShopBundle\Context\ReductionCartInterface; | ||||
use Lc\ShopBundle\Services\Utils; | |||||
/** | /** | ||||
* @method ReductionCartInterface|null find($id, $lockMode = null, $lockVersion = null) | * @method ReductionCartInterface|null find($id, $lockMode = null, $lockVersion = null) | ||||
{ | { | ||||
protected $orderUtils ; | protected $orderUtils ; | ||||
public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils) | |||||
public function __construct(EntityManager $entityManager, MerchantUtilsInterface $merchantUtils, Utils $utils, OrderUtilsInterface $orderUtils) | |||||
{ | { | ||||
parent::__construct($entityManager, $merchantUtils); | |||||
parent::__construct($entityManager, $merchantUtils, $utils); | |||||
$this->orderUtils = $orderUtils ; | $this->orderUtils = $orderUtils ; | ||||
} | } | ||||
foreach($reductionCarts as $reductionCart) { | foreach($reductionCarts as $reductionCart) { | ||||
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | ||||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | && $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | ||||
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user) | |||||
&& $this->orderUtils->getReductionCartRemainingQuantityPerUser($reductionCart, $user) | |||||
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { | && ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { | ||||
$reductionCartsArray[] = $reductionCart ; | $reductionCartsArray[] = $reductionCart ; |
return VisitorInterface::class; | return VisitorInterface::class; | ||||
} | } | ||||
public function findOldVisitors($date){ | |||||
$qb = $this->createQueryBuilder('v'); | |||||
$qb->where('v.lastAccess < :date'); | |||||
$qb->andWhere('v.totalVisit = 1'); | |||||
$qb->setParameter('date', $date); | |||||
return $qb->getQuery()->getResult(); | |||||
} | |||||
} | } |
a.link-as-text{color:#333;} | a.link-as-text{color:#333;} | ||||
.badge{font-size: 90%;} | |||||
/***************************************** ADMIN SIDEBAR ***************************************/ | /***************************************** ADMIN SIDEBAR ***************************************/ | ||||
.main-sidebar p{font-size: 0.8rem;} | .main-sidebar p{font-size: 0.8rem;} |
default: Édition | default: Édition | ||||
Général: Général | Général: Général | ||||
Adresse: Adresse | Adresse: Adresse | ||||
Redelivery: | |||||
list: Liste des relivraisons | |||||
Supplier: | Supplier: | ||||
contact: Personne de contact | contact: Personne de contact | ||||
Reminder: | Reminder: | ||||
ReductionCatalog: | ReductionCatalog: | ||||
info: Informations principal | info: Informations principal | ||||
conditions: Conditions d'application | conditions: Conditions d'application | ||||
ReductionCredit: | |||||
list: Liste des avoirs | |||||
ReductionCart: | ReductionCart: | ||||
info: Informations | info: Informations | ||||
conditions: Conditions d'applications | conditions: Conditions d'applications | ||||
actions: Actions | actions: Actions | ||||
list: Liste des réductions paniers | |||||
OrderShop: | OrderShop: | ||||
redelivery: Relivraison | redelivery: Relivraison | ||||
resume: Résumé de commande | resume: Résumé de commande | ||||
tickets: Tickets relatif à la commande | tickets: Tickets relatif à la commande | ||||
orderStatusHistories: Historique de changement de statut | orderStatusHistories: Historique de changement de statut | ||||
waitingBankReturn: Commandes en attente de retour banque | waitingBankReturn: Commandes en attente de retour banque | ||||
list: Liste des commandes | |||||
Ticket: | Ticket: | ||||
listMessages: Liste des messages | listMessages: Liste des messages | ||||
list: Tickets ouverts | list: Tickets ouverts | ||||
lunch: Repas du midi | lunch: Repas du midi | ||||
Address: | Address: | ||||
listLoopBesancon: Adresses de Besançon à spécifier (lat / long) | listLoopBesancon: Adresses de Besançon à spécifier (lat / long) | ||||
User: | |||||
item: Utilisateur | |||||
None: Aucune valeur | None: Aucune valeur |
<div class="small-box {% block class %}bg-info{% endblock %}"> | |||||
<div class="inner"> | |||||
<h3>{% block value %}{% endblock %}</h3> | |||||
<p>{% block label %}{% endblock %}</p> | |||||
<div class="icon"> | |||||
<i class="fa fa-{% block icon %}bg-info{% endblock %}"></i> | |||||
</div> | |||||
</div> | |||||
</div> |
<table class="table table-condensed" id="ticket-list"> | |||||
<thead> | |||||
<tr> | |||||
<th>Sujet</th> | |||||
<th>Statut</th> | |||||
<th>Dernier message</th> | |||||
<th></th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for ticket in tickets %} | |||||
<tr> | |||||
<td>{{ ticket.subject }}</td> | |||||
<td> | |||||
{% set value = ticket.status %} | |||||
{% include '@LcShop/backend/default/field/ticket_status.html.twig' %} | |||||
</td> | |||||
<td> | |||||
{% set item = ticket %} | |||||
{% include '@LcShop/backend/default/field/ticket_last_message.html.twig' %} | |||||
</td> | |||||
<td> | |||||
<a class="btn-sm btn-success" href="{{ path('easyadmin', {id: ticket.id, entity: 'Ticket', action: 'show'}) }}"> | |||||
<i class="fas fa-eye"></i> | |||||
</a> | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro available_quantity_product %} | {% endmacro available_quantity_product %} | ||||
{# {% macro modal(title, form) %} | |||||
{% embed '@LcShop/backend/default/block/embed_modal.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block id %}{{ id }}{% endblock %} | |||||
{% block title %}{{ title }}{% endblock %} | |||||
{% block form_start %} | |||||
{{ form_start(form) }} | |||||
{% endblock %} | |||||
{% block icon %}{{ icon }}{% endblock %} | |||||
{% block label %}{{ label }}{% endblock %} | |||||
{% block value %} | |||||
{{ value }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_info %}#} | |||||
{% macro button(entity, action, id=null, class="success", title=null, icon=null) %} | |||||
{% if title %} | |||||
{% set trad = title %} | |||||
{% else %} | |||||
{% set trad = 'action.'~action %} | |||||
{% endif %} | |||||
{% if icon is null %} | |||||
{% if action=="edit" %}{% set icon = 'pen' %} | |||||
{% elseif action=="show" %}{% set icon = 'eye' %} | |||||
{% endif %} | |||||
{% endif %} | |||||
{% set param = {action : action, entity: entity, referer: app.request.requestUri} %} | |||||
{% if id %}{% set param = param|merge({id: id}) %}{% endif %} | |||||
<a class="btn-sm btn-{{ class }}" data-toggle="tooltip" title="{{ trad|trans({}, "lcshop") }}" | |||||
href="{{ path('easyadmin', param) }}"> | |||||
<i class="fas fa-{{ icon }}"></i> | |||||
</a> | |||||
{% endmacro button %} | |||||
{% macro list_tickets(tickets) %} | |||||
<table class="table table-condensed"> | |||||
<thead> | |||||
<tr> | |||||
<th>Sujet</th> | |||||
<th>Statut</th> | |||||
<th>Dernier message</th> | |||||
<th></th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for ticket in tickets %} | |||||
<tr> | |||||
<td>{{ ticket.subject }}</td> | |||||
<td> | |||||
{% set value = ticket.status %} | |||||
{% include '@LcShop/backend/default/field/ticket_status.html.twig' %} | |||||
</td> | |||||
<td> | |||||
{% set item = ticket %} | |||||
{% include '@LcShop/backend/default/field/ticket_last_message.html.twig' %} | |||||
</td> | |||||
<td> | |||||
{{ _self.button('Ticket', 'show', ticket.id) }} | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro list_tickets %} | |||||
{% macro list_reduction_credits(reductionCredits) %} | |||||
<table class="table table-condensed"> | |||||
<thead> | |||||
<tr> | |||||
<th>Titre</th> | |||||
<th>Montant</th> | |||||
<th>En ligne</th> | |||||
<th>Utilisé</th> | |||||
<th></th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for reductionCredit in reductionCredits %} | |||||
{% set isUsed = orderUtils.isReductionCreditUsed(reductionCredit) %} | |||||
<tr> | |||||
<td>{{ reductionCredit.title }}</td> | |||||
<td> | |||||
{{ reductionCredit.value|format_price(false) }} | |||||
</td> | |||||
<td> | |||||
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCredit.status} %} | |||||
</td> | |||||
<td> | |||||
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: isUsed} %} | |||||
</td> | |||||
<td> | |||||
{% if isUsed == false %} | |||||
{{ _self.button('ReductionCredit', 'edit', reductionCredit.id, 'primary') }} | |||||
{% endif %} | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro list_reduction_credits %} | |||||
{% macro list_reduction_carts(reductionCarts, user = false) %} | |||||
<table class="table table-condensed"> | |||||
<thead> | |||||
<tr> | |||||
<th>Titre</th> | |||||
<th>Montant</th> | |||||
<th>Quantité utilisé</th> | |||||
<th>Quantité restante</th> | |||||
<th>En ligne</th> | |||||
<th>Actions</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for reductionCart in reductionCarts %} | |||||
<tr> | |||||
<td>{{ reductionCart.title }}</td> | |||||
<td> | |||||
{% if reductionCart.value > 0 %} | |||||
{{ reductionCart.value }} | |||||
{% if reductionCart.unit == 'percent' %}%{% else %}€{% endif %} | |||||
{% if reductionCart.appliedTo is defined and reductionCart.appliedTo|length > 0 %} | |||||
sur | |||||
{% if reductionCart.appliedTo == 'order-products' %} | |||||
les produits | |||||
{% endif %} | |||||
{% endif %} | |||||
({% if reductionCart.behaviorTaxRate == 'tax-included' %}TTC{% else %}HT{% endif %}) | |||||
{% endif %} | |||||
{% if reductionCart.freeShipping %} | |||||
{% if reductionCart.value > 0 %}<br/>{% endif %} | |||||
Livraison offerte | |||||
{% endif %} | |||||
</td> | |||||
<td> | |||||
{% if user is not null %} | |||||
{% set totalUsed = orderUtils.getReductionCartUsedQuantityPerUser(reductionCart, user) %} | |||||
{{ totalUsed }} | |||||
{% endif %} | |||||
</td> | |||||
<td> | |||||
{% if user is not null %} | |||||
{{ reductionCart.availableQuantityPerUser - totalUsed }} | |||||
{% endif %} | |||||
</td> | |||||
<td> | |||||
{% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCart.status} %} | |||||
</td> | |||||
<td> | |||||
{{ _self.button('ReductionCart', 'edit', reductionCart.id, 'primary') }} | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro list_reduction_carts %} | |||||
{% macro box_user_info(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_box.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-info{% endblock %} | |||||
{% block icon %}user{% endblock %} | |||||
{% block label %}{{ "group.User.item"|trans({}, 'lcshop') }}{% endblock %} | |||||
{% block value %} | |||||
#{{ user.id }} | |||||
{{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} {{ user.age < 200 ? '('~user.age~' ans)' : ''}}<br /> | |||||
{{ user.email }}<br /> | |||||
<span style="margin-top: 5px; display: inline-block;"> | |||||
<span data-toggle="tooltip" data-placement="bottom" title="Nombre de commandes" class="badge badge-info"> | |||||
{{ orderUtils.countValidOrderShopByUser(user) }} <i class="fa fa-shopping-cart"></i> | |||||
</span> | |||||
<span data-toggle="tooltip" data-placement="bottom" title="Total dépensés" class="badge badge-success"> | |||||
{{ orderUtils.getTotalSpentByUser(user) }} <i class="fa fa-euro-sign"></i> | |||||
</span> | |||||
<span data-toggle="tooltip" data-placement="bottom" title="Nombre de relivraisons" class="badge badge-warning"> | |||||
{{ orderUtils.countRedeliveryByUser(user) }} <i class="fa fa-undo"></i> | |||||
</span> | |||||
<span data-toggle="tooltip" data-placement="bottom" title="Nombre d'avoirs" class="badge badge-danger"> | |||||
{{ user.reductionCredits|length }} <i class="fa fa-backspace"></i> | |||||
</span> | |||||
</span> | |||||
{% endblock %} | |||||
{% block button %} | |||||
<a class="btn btn-sm btn-secondary" href="{{ path('easyadmin', {"action" : 'show', 'entity': 'User', 'id': user.id}) }}"> | |||||
Voir la fiche | |||||
</a> | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_user_info %} |
{# {{ value|date('U')}} #} | {# {{ value|date('U')}} #} | ||||
{% if field_options.format == "d/m/Y h:i A e" or field_options.format == null %} | |||||
{% if value is not null %} | |||||
{% if field_options is not defined or field_options.format == "d/m/Y h:i A e" or field_options.format == null %} | |||||
{% set format = "d/m/Y H:i" %} | {% set format = "d/m/Y H:i" %} | ||||
{% else %} | {% else %} | ||||
{% set format = field_options.format %} | {% set format = field_options.format %} | ||||
{% endif %} | {% endif %} | ||||
<time data-timestamp="{{ value|date('U') }}" title="{{ value|date('r') }}">{{ value|date(format) }}</time> | <time data-timestamp="{{ value|date('U') }}" title="{{ value|date('r') }}">{{ value|date(format) }}</time> | ||||
{% else %} | |||||
<span class="badge badge-secondary">Non défini</span> | |||||
{% endif %} |
{% if value is not null or value is not empty %} | |||||
{{ value }} | |||||
{% else %} | |||||
<span class="badge badge-secondary">Non défini</span> | |||||
{% endif %} |
{{ priceUtils.getTotalWithTax(item)|format_price|raw }} | |||||
{{ priceUtils.getTotalWithTax(item, true)|format_price|raw }}<br /> | |||||
{{ item.statTotalWithTax }} |
{% if item.user is not null %} | |||||
<a href="{{ path('easyadmin', {"entity": 'User', 'action': "show", "id" : item.user.id})}}">{{ value }}</a> | |||||
{% else %} | |||||
{{ value }} | |||||
{% endif %} |
{% endif %} | {% endif %} | ||||
{% for field, metadata in _fields_visible_by_user %} | {% for field, metadata in _fields_visible_by_user %} | ||||
{% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %} | {% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %} | ||||
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'DESC' %} | |||||
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'ASC' %} | |||||
{% set _column_label = metadata.label|trans(_trans_parameters) %} | {% set _column_label = metadata.label|trans(_trans_parameters) %} | ||||
{% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | {% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %} | ||||
{% set isFilteredField = false %} | {% set isFilteredField = false %} | ||||
<th></th>{% endif %} | <th></th>{% endif %} | ||||
{% for field, metadata in _fields_visible_by_user %} | {% for field, metadata in _fields_visible_by_user %} | ||||
<th> | <th> | ||||
{% set field = utils.getFilterPropertyClean(field) %} | |||||
{% if filters_form[field] is defined %} | {% if filters_form[field] is defined %} | ||||
{% if filters_form[field].vars.value is not null and filters_form[field].vars.value is not empty %}{% set fieldAreNotEmpty = true %}{% endif %} | {% if filters_form[field].vars.value is not null and filters_form[field].vars.value is not empty %}{% set fieldAreNotEmpty = true %}{% endif %} | ||||
{% if metadata['dataType'] == 'datetime' or metadata['dataType'] == 'date' %} | {% if metadata['dataType'] == 'datetime' or metadata['dataType'] == 'date' %} | ||||
<div class="input-group input-group-sm"> | <div class="input-group input-group-sm"> | ||||
</div> | </div> | ||||
{% else %} | {% else %} | ||||
<div class="form-widget input-group-sm"> | <div class="form-widget input-group-sm"> | ||||
{% if metadata.dataType == 'integer' or metadata.dataType== 'string' %} | |||||
{% if metadata.dataType == 'integer' or metadata.dataType== 'string' or metadata.dataType== 'text' %} | |||||
{{ form_widget(filters_form[field], {'attr': {'autocomplete': 'off', 'data-lc-autocomplete-url' : path('easyadmin', { | {{ form_widget(filters_form[field], {'attr': {'autocomplete': 'off', 'data-lc-autocomplete-url' : path('easyadmin', { | ||||
action: 'autocomplete', | action: 'autocomplete', | ||||
field: field, | field: field, |
<span class="badge badge-{{ value.color is defined ? value.color : item.orderStatus.color }}">{{ value }}</span> |
</div> | </div> | ||||
{% endmacro %} | {% endmacro %} | ||||
{% macro box_user_info() %} | |||||
{% embed '@LcShop/backend/default/block/embed_box.twig' %} | |||||
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-info{% endblock %} | |||||
{% block icon %}credit-card{% endblock %} | |||||
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop') }}{% endblock %} | |||||
{% block value %} | |||||
<span v-if="order.user" v-html="order.user"></span> | |||||
<span v-else v-html="order.visitor"></span> | |||||
{% endblock %} | |||||
{% block button %} | |||||
<a class="btn btn-sm btn-secondary" target="_blank" :href="order.userLink"> | |||||
Voir la fiche | |||||
</a> | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_user_info %} | |||||
{% macro box_reference() %} | {% macro box_reference() %} | ||||
{% embed '@LcShop/backend/default/block/embed_box.twig' %} | {% embed '@LcShop/backend/default/block/embed_box.twig' %} | ||||
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %} | {% import '@LcShop/backend/order/macros.html.twig' as order_macros %} |
<div class="lc-vue-js-container" id="lc-order-edit"> | <div class="lc-vue-js-container" id="lc-order-edit"> | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_user_info() }} | |||||
{{ macros.box_user_info(entity.user) }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_total_order() }} | {{ order_macros.box_total_order() }} |
<div class="lc-vue-js-container" id="lc-order-edit"> | <div class="lc-vue-js-container" id="lc-order-edit"> | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_user_info() }} | |||||
{{ macros.box_user_info(entity.user) }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_total_order() }} | {{ order_macros.box_total_order() }} |
{{ item.availableQuantity - orderUtils.getReductionCartUsedQuantity(item) }} |
{% set totalUsed = orderUtils.getReductionCartUsedQuantity(item) %} | |||||
<span class="badge badge-success">{{ totalUsed }}</span> utilisé(s) | |||||
/ <span class="badge badge-primary">{{ item.availableQuantity - totalUsed }}</span> restante(s) |
{% endembed %} | {% endembed %} | ||||
{% if entity.user %} | {% if entity.user %} | ||||
{{ macros.box_info('bg-info', 'user', "field.default.user"|trans, entity.user.summary) }} | |||||
{{ macros.box_user_info(entity.user) }} | |||||
{% else %} | {% else %} | ||||
{{ macros.box_info('bg-info', 'user-secret', "field.default.visitor"|trans, entity.user ? entity.user.summary : entity.visitorInfos) }} | {{ macros.box_info('bg-info', 'user-secret', "field.default.visitor"|trans, entity.user ? entity.user.summary : entity.visitorInfos) }} | ||||
{% endif %} | {% endif %} |
{% set totalOrder = orderUtils.countValidOrderShopByUser(item) %} | |||||
{% if totalOrder > 0 %} | |||||
<span class="badge badge-success"> | |||||
{{ totalOrder }} commandes | |||||
</span> | |||||
{% else %} | |||||
<span class="badge badge-secondary"> | |||||
0 commandes | |||||
</span> | |||||
{% endif %} |
{{ orderUtils.getRankSumOrderByUser(item) }} |
{{ orderUtils.getRankTotalOrderByUser(item) }} |
{% set totalSpent = orderUtils.getTotalSpentByUser(item) %} | |||||
{% if totalSpent >0 %} | |||||
<span class="badge badge-primary"> {{ totalSpent|format_price(false) }}</span> | |||||
{% else %} | |||||
<span class="badge badge-secondary"> {{ totalSpent|format_price(false) }}</span> | |||||
{% endif %} |
{% if value|length > 0 %} | |||||
<span class="badge badge-success"> | |||||
{{ value|length }} commandes | |||||
</span> | |||||
{% else %} | |||||
<span class="badge badge-danger"> | |||||
0 commandes | |||||
</span> | |||||
{% endif %} |
{% trans_default_domain 'lcshop' %} | |||||
{% macro card_info(user) %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="card card-primary card-outline"> | |||||
<div class="card-body box-profile"> | |||||
<h3 class="profile-username"> | |||||
<i class="fa fa-user"></i> {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} | |||||
</h3> | |||||
<ul class="list-group list-group-unbordered"> | |||||
{% if user.age < 200 and user.age > 2 %} | |||||
<li class="list-group-item"> | |||||
<b> <i class="fa fa-birthday-cake"></i> Age </b> | |||||
<span class="float-right"> {{ user.age }} ans ({{ user.birthdate|date('d/m/Y') }})</span> | |||||
</li> | |||||
{% endif %} | |||||
<li class="list-group-item"> | |||||
<b> <i class="fa fa-envelope"></i> Email</b> | |||||
<span class="float-right"> {{ user.email }}</span> | |||||
</li> | |||||
<li class="list-group-item"> | |||||
<b> <i class="fa fa-phone"></i> Téléphone</b> | |||||
<span class="float-right"> {{ user.phone }}</span> | |||||
</li> | |||||
<li class="list-group-item"> | |||||
<b><i class="fa fa-fw fa-bullhorn"></i> Newsletters</b> | |||||
{% for newsletter in user.newsletters %} | |||||
<span class="badge badge-success float-right">{{ newsletter }}</span> | |||||
{% else %} | |||||
<span class="badge badge-dark float-right">Aucune</span> | |||||
{% endfor %} | |||||
</li> | |||||
<li class="list-group-item"> | |||||
<b> <i class="fa fa-users"></i> Groupes</b> | |||||
{% for group in user.groups %} | |||||
<span class="badge badge-info float-right">{{ group }}</span> | |||||
{% else %} | |||||
<span class="badge badge-dark float-right">Aucun</span> | |||||
{% endfor %} | |||||
</li> | |||||
{% if is_granted('ROLE_SUPER_ADMIN') == false %} | |||||
<li class="list-group-item"> | |||||
<b> <i class="fa fa-user-shield"></i> Roles</b> | |||||
{% for role in user.roles %} | |||||
<span class="badge badge-danger float-right">{{ role }}</span> | |||||
{% endfor %} | |||||
</li> | |||||
{% endif %} | |||||
</ul> | |||||
<br /> | |||||
<div> | |||||
<a class="btn btn-sm btn-primary float-right" href="{{ path('easyadmin', {"action" : 'edit', 'entity': 'User', 'id': user.id}) }}"> | |||||
<i class="fa fa-pen"></i> Éditer l'utilisateur | |||||
</a> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endmacro card_info %} | |||||
{% macro box_rank_sum_order(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% block class %}bg-maroon{% endblock %} | |||||
{% block icon %}cubes{% endblock %} | |||||
{% block label %} Classement par total dépensés{% endblock %} | |||||
{% block value %} | |||||
{% set rankSumOrder = orderUtils.rankSumOrderByUser(user) %} | |||||
{% if rankSumOrder %} | |||||
{{ rankSumOrder }} <small style="opacity: 0.7"> / {{ orderUtils.countUsersWithValidOrderShop() }}</small> | |||||
{% else %} | |||||
Non classé | |||||
{% endif %} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_rank_sum_order %} | |||||
{% macro box_total_spent(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-pink{% endblock %} | |||||
{% block icon %}euro-sign{% endblock %} | |||||
{% block label %} Total dépensés{% endblock %} | |||||
{% block value %} | |||||
{{ orderUtils.totalSpentByUser(user)|format_price(false) }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_total_spent %} | |||||
{% macro box_rank_total_order(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% block class %}bg-info{% endblock %} | |||||
{% block icon %}cubes{% endblock %} | |||||
{% block label %}Classement par nombre de commande {% endblock %} | |||||
{% block value %} | |||||
{% set rankTotalOrder = orderUtils.rankTotalOrderByUser(user) %} | |||||
{% if rankTotalOrder %} | |||||
{{ rankTotalOrder }} <small style="opacity: 0.7"> / {{ orderUtils.countUsersWithValidOrderShop() }}</small> | |||||
{% else %} | |||||
Non classé | |||||
{% endif %} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_rank_total_order %} | |||||
{% macro box_total_order(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-lightblue{% endblock %} | |||||
{% block icon %}shopping-cart{% endblock %} | |||||
{% block label %} Nombre de commandes{% endblock %} | |||||
{% block value %} | |||||
{{ orderUtils.countValidOrderShopByUser(user) }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_total_order %} | |||||
{% macro box_register_since(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-success{% endblock %} | |||||
{% block icon %}calendar-plus{% endblock %} | |||||
{% block label %}Date de l'inscription{% endblock %} | |||||
{% block value %} | |||||
{{ user.createdAt|date('d/m/Y H:i') }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_register_since %} | |||||
{% macro box_login_since(user) %} | |||||
{% embed '@LcShop/backend/default/block/embed_figure_box.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% block class %}bg-olive{% endblock %} | |||||
{% block icon %}calendar-check{% endblock %} | |||||
{% block label %}Date de dernière visite{% endblock %} | |||||
{% block value %} | |||||
{{ user.lastLogin|date('d/m/Y H:i') }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro box_login_since %} | |||||
{% macro list_order_product_redelivery(orderProductsRedelivery) %} | |||||
<table class="table lc-table-list table-striped"> | |||||
<thead> | |||||
<tr> | |||||
<th>Id</th> | |||||
<th>Produit</th> | |||||
<th>Quantité</th> | |||||
<th>Date de livraison</th> | |||||
<th>Statut</th> | |||||
<th></th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for orderProduct in orderProductsRedelivery %} | |||||
<tr> | |||||
<td>{{ orderProduct.id }}</td> | |||||
<td>{{ orderProduct.title }}</td> | |||||
<td>{{ orderProduct.quantityOrder }}</td> | |||||
<td> | |||||
{% include '@LcShop/backend/default/field/datetime.html.twig' with {value : orderProduct.orderShop.deliveryDate} %}</td> | |||||
<td>{% include '@LcShop/backend/order/field/order_status.html.twig' with {value : orderProduct.orderShop.orderStatus} %}</td> | |||||
<td> | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% if orderProduct.orderShop.isCart() %} | |||||
{{ macros.button('OrderProductRedelivery', 'edit', orderProduct.id, 'primary') }} | |||||
{% endif %} | |||||
{{ macros.button('OrderShop', 'show', orderProduct.orderShop.id) }} | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro list_order_product_redelivery %} | |||||
{% macro list_order_shops(orderShops) %} | |||||
<table class="table table-striped"> | |||||
<tbody> | |||||
<thead> | |||||
<tr> | |||||
<th>Id</th> | |||||
<th>WeekId</th> | |||||
<th>Numéro de semaine</th> | |||||
<th>Référence</th> | |||||
<th>Montant TTC</th> | |||||
<th>Statut</th> | |||||
<th></th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
{% for orderShop in orderShops %} | |||||
<tr> | |||||
<td>{{ orderShop.id }}</td> | |||||
<td>{{ orderShop.weekId }}</td> | |||||
<td>{{ orderShop.weekNumber }}</td> | |||||
<td>{{ orderShop.reference }}</td> | |||||
<td>{{ priceUtils.getTotalWithTax(orderShop, true)|format_price(false) }}</td> | |||||
<td>{% include '@LcShop/backend/order/field/order_status.html.twig' with {value : orderShop.orderStatus} %}</td> | |||||
<td> | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{{ macros.button('OrderShop', 'show', orderShop.id) }} | |||||
</td> | |||||
</tr> | |||||
{% endfor %} | |||||
</tbody> | |||||
</table> | |||||
{% endmacro list_order_shops %} |
{% extends '@LcShop/backend/default/show.html.twig' %} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% import '@LcShop/backend/user/macros.html.twig' as user_macros %} | |||||
{% block global_actions %} | |||||
{% if entity is not null %} | |||||
{% set action = {label : "action.user.switch", icon: 'user-secret', css_class: 'btn btn-sm btn-danger'} %} | |||||
{% include '@LcShop/backend/user/block/user-switch.html.twig' with {item: entity, is_dropdown: false, action: action, translation_domain: 'lcshop', trans_parameters: {}, item_id: entity.id}%} | |||||
<button id="btn-ticket-write-to-user" | |||||
data-url="{{ path('easyadmin', {'entity': 'Ticket', 'action': 'new'}) }}" | |||||
data-user="{{ entity.id }}" | |||||
class="btn-sm btn-success" | |||||
type="button"><i class="fa fa-pen-alt"></i> {{ "action.ticket.writeToUser"|trans }} | |||||
</button> | |||||
{% endif %} | |||||
{% endblock %} | |||||
{% block main %} | |||||
<div class="lc-vue-js-container" id="lc-user"> | |||||
<div class="row"> | |||||
<div class="col-3"> | |||||
{{ user_macros.card_info(entity) }} | |||||
</div> | |||||
<div class="col-3"> | |||||
{{ user_macros.box_rank_total_order(entity) }} | |||||
{{ user_macros.box_total_order(entity) }} | |||||
</div> | |||||
<div class="col-3"> | |||||
{{ user_macros.box_rank_sum_order(entity) }} | |||||
{{ user_macros.box_total_spent(entity) }} | |||||
</div> | |||||
<div class="col-3"> | |||||
{{ user_macros.box_register_since(entity) }} | |||||
{{ user_macros.box_login_since(entity) }} | |||||
</div> | |||||
<div class="col-6"> | |||||
{% set redeliveries = orderUtils.getRedeliveryByUser(entity) %} | |||||
{% if redeliveries|length %} | |||||
{{ macros.card_start('Redelivery.list', 'danger card-outline', true) }} | |||||
{{ user_macros.list_order_product_redelivery(redeliveries) }} | |||||
{{ macros.card_end() }} | |||||
{% endif %} | |||||
{% set tickets = ticketUtils.getTicketsByUser(entity) %} | |||||
{% if tickets|length %} | |||||
{{ macros.card_start('Ticket.listMessages', 'warning card-outline', false) }} | |||||
{{ macros.list_tickets(tickets) }} | |||||
{{ macros.card_end() }} | |||||
{% endif %} | |||||
{% if entity.reductionCredits|length %} | |||||
{{ macros.card_start('ReductionCredit.list', 'warning card-outline', false) }} | |||||
{{ macros.list_reduction_credits(entity.reductionCredits) }} | |||||
{{ macros.card_end() }} | |||||
{% endif %} | |||||
{% set reductionCartsAvailable = orderUtils.getReductionCartsAvailableByUser(entity) %} | |||||
{% if reductionCartsAvailable|length %} | |||||
{{ macros.card_start('ReductionCart.list', 'success card-outline', false) }} | |||||
{{ macros.list_reduction_carts(reductionCartsAvailable, entity) }} | |||||
{{ macros.card_end() }} | |||||
{% endif %} | |||||
</div> | |||||
<div class="col-6"> | |||||
{{ macros.card_start('OrderShop.list', 'primary card-outline', false) }} | |||||
{{ user_macros.list_order_shops(orderUtils.getOrderShops({'user': entity})) }} | |||||
{{ macros.card_end() }} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endblock %} |
public function getReductionCartRemainingQuantity($reductionCart) :float | public function getReductionCartRemainingQuantity($reductionCart) :float | ||||
{ | { | ||||
return $reductionCart->getAvailableQuantity() - $this->orderShopRepo->countValidOrderWithReductionCart(); | |||||
return $reductionCart->getAvailableQuantity() - $this->orderShopRepo->countValidOrderWithReductionCart($reductionCart); | |||||
} | } | ||||
public function getReductionCartRemainingQuantityPerUser($reductionCart) :float | |||||
public function getReductionCartUsedQuantityPerUser($reductionCart, $user) :float | |||||
{ | { | ||||
return $reductionCart->getAvailableQuantityPerUser() - $this->orderShopRepo->countValidOrderWithReductionCartPerUser(); | |||||
return $this->orderShopRepo->countValidOrderWithReductionCartPerUser($reductionCart, $user); | |||||
} | |||||
public function getReductionCartUsedQuantity($reductionCart) :float | |||||
{ | |||||
return $this->orderShopRepo->countValidOrderWithReductionCart($reductionCart); | |||||
} | |||||
public function getReductionCartRemainingQuantityPerUser($reductionCart, $user) :float | |||||
{ | |||||
if ($reductionCart->getAvailableQuantityPerUser()) { | |||||
return $reductionCart->getAvailableQuantityPerUser() - $this->orderShopRepo->countValidOrderWithReductionCartPerUser($reductionCart, $user); | |||||
} | |||||
return false; | |||||
} | } | ||||
return false ; | return false ; | ||||
} | } | ||||
/*public function getReductionCreditsAvailable($order) | |||||
{ | |||||
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class); | |||||
$reductionCredits = $reductionCreditRepo->getReductionCreditByUser($order->getUser()); | |||||
foreach ($reductionCredits as $reductionCredit){ | |||||
public function getReductionCartsAvailableByUser($user) | |||||
{ | |||||
$reductionCartRepository = $this->em->getRepository(ReductionCartInterface::class) ; | |||||
return $reductionCartRepository->findAllAvailableForUser($user); | |||||
} | |||||
} | |||||
}*/ | |||||
public function getReductionCreditsAvailableByUser($user) | public function getReductionCreditsAvailableByUser($user) | ||||
{ | { | ||||
$reductionCredits = $this->reductionCreditRepo->findReductionCreditsByUser($user) ; | $reductionCredits = $this->reductionCreditRepo->findReductionCreditsByUser($user) ; | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public function isReductionCreditUsed($reductionCredit){ | |||||
if($this->orderShopRepo->countValidOrderWithReductionCredit($reductionCredit)) { | |||||
return true; | |||||
}else{ | |||||
return false; | |||||
} | |||||
} | |||||
public function isReductionCreditAddedToOrder($orderShop, $reductionCredit) | public function isReductionCreditAddedToOrder($orderShop, $reductionCredit) | ||||
{ | { | ||||
foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) { |
return $total; | return $total; | ||||
} | } | ||||
public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float | |||||
public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false): float | |||||
{ | { | ||||
$total = $this->getMarginOrderProducts($orderShop); | |||||
if ($cache && $orderShop->getStatMarginOrderProductsWithReductions() !== null) { | |||||
return $orderShop->getStatMarginOrderProductsWithReductions(); | |||||
} else { | |||||
$total = $this->getMarginOrderProducts($orderShop); | |||||
$totalReductionAmount = 0; | |||||
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart); | |||||
} | |||||
$totalReductionAmount = 0; | |||||
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart); | |||||
} | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit); | |||||
} | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit); | |||||
} | |||||
$total -= $totalReductionAmount; | |||||
$total -= $totalReductionAmount; | |||||
return $total; | |||||
return $total; | |||||
} | |||||
} | } | ||||
public function getMarginOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float | public function getMarginOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float | ||||
return $this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop); | return $this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop); | ||||
} | } | ||||
public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop) | |||||
public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false) | |||||
{ | { | ||||
$total = $this->getTotalOrderProducts($orderShop); | |||||
$total -= $this->getTotalReductionCartsAmount($orderShop); | |||||
$total -= $this->getTotalReductionCreditsAmount($orderShop); | |||||
return $total; | |||||
if($cache && $orderShop->getStatTotalOrderProductsWithReductions()!==null){ | |||||
return $orderShop->getStatTotalOrderProductsWithReductions(); | |||||
}else { | |||||
$total = $this->getTotalOrderProducts($orderShop); | |||||
$total -= $this->getTotalReductionCartsAmount($orderShop); | |||||
$total -= $this->getTotalReductionCreditsAmount($orderShop); | |||||
return $total; | |||||
} | |||||
} | } | ||||
public function getTotalOrderProductsWithReductionCarts(OrderShopInterface $orderShop) | public function getTotalOrderProductsWithReductionCarts(OrderShopInterface $orderShop) | ||||
return $totalReductionAmount; | return $totalReductionAmount; | ||||
} | } | ||||
public function getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop) | |||||
public function getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop, $cache = false) | |||||
{ | { | ||||
$total = $this->getTotalOrderProductsWithTax($orderShop); | |||||
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop); | |||||
$total -= $this->getTotalReductionCreditsAmountWithTax($orderShop); | |||||
return $total; | |||||
if($cache && $orderShop->getStatTotalOrderProductsWithTaxAndReductions()!==null){ | |||||
return $orderShop->getStatTotalOrderProductsWithTaxAndReductions(); | |||||
}else { | |||||
$total = $this->getTotalOrderProductsWithTax($orderShop); | |||||
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop); | |||||
$total -= $this->getTotalReductionCreditsAmountWithTax($orderShop); | |||||
return $total; | |||||
} | |||||
} | } | ||||
public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop) | public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop) | ||||
public function getTotalReductions(OrderShopInterface $orderShop) | public function getTotalReductions(OrderShopInterface $orderShop) | ||||
{ | { | ||||
$total = 0 ; | |||||
$total = 0; | |||||
foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$total += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart) ; | |||||
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$total += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart); | |||||
} | } | ||||
foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit) ; | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit); | |||||
} | } | ||||
return $total ; | |||||
return $total; | |||||
} | } | ||||
public function getTotalReductionsWithTax(OrderShopInterface $orderShop) | public function getTotalReductionsWithTax(OrderShopInterface $orderShop) | ||||
{ | { | ||||
$total = 0 ; | |||||
$total = 0; | |||||
foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$total += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart) ; | |||||
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { | |||||
$total += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart); | |||||
} | } | ||||
foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit) ; | |||||
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) { | |||||
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit); | |||||
} | } | ||||
return $total ; | |||||
return $total; | |||||
} | } | ||||
} | } | ||||
$this->authorizationChecker = $authorizationChecker ; | $this->authorizationChecker = $authorizationChecker ; | ||||
} | } | ||||
public function getTicketsByUser($user){ | |||||
$ticketRepo = $this->em->getRepository(TicketInterface::class); | |||||
return $ticketRepo->findBy(array('user'=>$user)); | |||||
} | |||||
public function createTicket($params): TicketInterface | public function createTicket($params): TicketInterface | ||||
{ | { | ||||
$classTicket = $this->em->getClassMetadata(TicketInterface::class)->getName() ; | $classTicket = $this->em->getClassMetadata(TicketInterface::class)->getName() ; |
protected $visitorRepository ; | protected $visitorRepository ; | ||||
protected $merchantUtils ; | protected $merchantUtils ; | ||||
protected $cookieChecker ; | protected $cookieChecker ; | ||||
protected $visitor ; | |||||
public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, | public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, | ||||
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker, | RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker, | ||||
public function setCookieVisitor($response, $cookie) | public function setCookieVisitor($response, $cookie) | ||||
{ | { | ||||
$response->headers->setCookie(Cookie::create($this->getCookieNameVisitor(), $this->cryptCookie($cookie), 0, '/', $this->utils->getCookieDomain())); | |||||
$response->headers->setCookie(Cookie::create($this->getCookieNameVisitor(), $this->cryptCookie($cookie), new \DateTime('+2 months'), '/', $this->utils->getCookieDomain())); | |||||
} | |||||
public function updateVisitorCookie($response) | |||||
{ | |||||
$response->headers->setCookie(Cookie::create($this->getCookieNameVisitor(), $this->cryptCookie($this->getVisitorCurrent()->getCookie()), new \DateTime('+2 months'), '/', $this->utils->getCookieDomain())); | |||||
} | } | ||||
public function getVisitor($cookie) | public function getVisitor($cookie) | ||||
{ | { | ||||
return $this->visitorRepository->findOneBy(['cookie' => $cookie]) ; | |||||
if(!isset($this->visitor[$cookie])){ | |||||
$this->visitor[$cookie] = $this->visitorRepository->findOneBy(['cookie' => $cookie]) ; | |||||
} | |||||
return $this->visitor[$cookie]; | |||||
} | } | ||||
public function getVisitorCurrent() | public function getVisitorCurrent() |
use Symfony\Component\HttpFoundation\ParameterBag; | use Symfony\Component\HttpFoundation\ParameterBag; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
use Symfony\Component\Validator\Constraints\EqualTo; | use Symfony\Component\Validator\Constraints\EqualTo; | ||||
use Symfony\Component\Validator\Constraints\NotNull; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | use Symfony\Contracts\Translation\TranslatorInterface; | ||||
class Utils | class Utils | ||||
'class' => 'special-field' | 'class' => 'special-field' | ||||
], | ], | ||||
'constraints' => [ | 'constraints' => [ | ||||
new NotNull(), | |||||
new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte']) | new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte']) | ||||
], | ], | ||||
]); | ]); | ||||
return md5($key); | return md5($key); | ||||
} | } | ||||
public function getFilterPropertyClean($fieldName){ | |||||
return str_replace('.', '_', $fieldName); | |||||
} | |||||
public function getFilterPropertyInit($fieldName){ | |||||
return str_replace('_', '.', $fieldName); | |||||
} | |||||
public function hasFilterAssociation($fieldName, $needle="."){ | |||||
return strpos($fieldName, $needle); | |||||
} | |||||
public function getFilterWithoutAssociationAlias($fieldName, $needle = '.'){ | |||||
return substr($fieldName, strpos($fieldName, $needle)+1); | |||||
} | |||||
public function getFilterAssociationAlias($fieldName, $needle = '.'){ | |||||
return substr($fieldName, 0, strpos($fieldName, $needle)); | |||||
} | |||||
public function round($price, $precision = 2) | |||||
{ | |||||
return round((($price * 100)) / 100, $precision); | |||||
} | |||||
} | } |