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(); | |||||
} | |||||
} | } |
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 |
</table> | </table> | ||||
{% endmacro list_reduction_carts %} | {% 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 %} |
</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() }} |
{% 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 %} |
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% macro box_info(user) %} | |||||
{% macro card_info(user) %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="card card-primary card-outline"> | <div class="card card-primary card-outline"> | ||||
<div class="card-body box-profile"> | <div class="card-body box-profile"> | ||||
<h3 class="profile-username"> | <h3 class="profile-username"> | ||||
<i class="fa fa-user"></i> {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} {{ user.age < 200 ? '('~user.age~' ans)' : ''}} | |||||
<i class="fa fa-user"></i> {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} | |||||
</h3> | </h3> | ||||
<ul class="list-group list-group-unbordered"> | <ul class="list-group list-group-unbordered"> | ||||
{% if user.age < 200 %} | |||||
{% if user.age < 200 and user.age > 2 %} | |||||
<li class="list-group-item"> | <li class="list-group-item"> | ||||
<b> <i class="fa fa-birthday-cake"></i> Age </b> | <b> <i class="fa fa-birthday-cake"></i> Age </b> | ||||
<span class="float-right"> ans ({{ user.birthdate|date('d/m/Y') }})</span> | |||||
<span class="float-right"> {{ user.age }} ans ({{ user.birthdate|date('d/m/Y') }})</span> | |||||
</li> | </li> | ||||
{% endif %} | {% endif %} | ||||
</li> | </li> | ||||
{% endif %} | {% endif %} | ||||
</ul> | </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> | ||||
</div> | </div> | ||||
{% endmacro box_info %} | |||||
{% endmacro card_info %} | |||||
{% macro box_rank_sum_order(user) %} | {% macro box_rank_sum_order(user) %} |
<div class="lc-vue-js-container" id="lc-user"> | <div class="lc-vue-js-container" id="lc-user"> | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ user_macros.box_info(entity) }} | |||||
{{ user_macros.card_info(entity) }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ user_macros.box_rank_total_order(entity) }} | {{ user_macros.box_rank_total_order(entity) }} | ||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
{% endif %} | {% endif %} | ||||
{% if entity.tickets|length %} | |||||
{% set tickets = ticketUtils.getTicketsByUser(entity) %} | |||||
{% if tickets|length %} | |||||
{{ macros.card_start('Ticket.listMessages', 'warning card-outline', false) }} | {{ macros.card_start('Ticket.listMessages', 'warning card-outline', false) }} | ||||
{{ macros.list_tickets(entity.tickets) }} | |||||
{{ macros.list_tickets(tickets) }} | |||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
{% endif %} | {% endif %} | ||||
$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() |