@@ -18,4 +18,13 @@ class VisitorRepository extends BaseRepository implements DefaultRepositoryInter | |||
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(); | |||
} | |||
} |
@@ -95,6 +95,9 @@ group: | |||
lunch: Repas du midi | |||
Address: | |||
listLoopBesancon: Adresses de Besançon à spécifier (lat / long) | |||
User: | |||
item: Utilisateur | |||
None: Aucune valeur |
@@ -430,3 +430,40 @@ | |||
</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 %} |
@@ -226,29 +226,6 @@ | |||
</div> | |||
{% 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() %} | |||
{% embed '@LcShop/backend/default/block/embed_box.twig' %} | |||
{% import '@LcShop/backend/order/macros.html.twig' as order_macros %} |
@@ -19,7 +19,7 @@ | |||
<div class="lc-vue-js-container" id="lc-order-edit"> | |||
<div class="row"> | |||
<div class="col-3"> | |||
{{ order_macros.box_user_info() }} | |||
{{ macros.box_user_info(entity.user) }} | |||
</div> | |||
<div class="col-3"> | |||
{{ order_macros.box_total_order() }} |
@@ -20,7 +20,7 @@ | |||
<div class="lc-vue-js-container" id="lc-order-edit"> | |||
<div class="row"> | |||
<div class="col-3"> | |||
{{ order_macros.box_user_info() }} | |||
{{ macros.box_user_info(entity.user) }} | |||
</div> | |||
<div class="col-3"> | |||
{{ order_macros.box_total_order() }} |
@@ -23,7 +23,7 @@ | |||
{% endembed %} | |||
{% if entity.user %} | |||
{{ macros.box_info('bg-info', 'user', "field.default.user"|trans, entity.user.summary) }} | |||
{{ macros.box_user_info(entity.user) }} | |||
{% else %} | |||
{{ macros.box_info('bg-info', 'user-secret', "field.default.visitor"|trans, entity.user ? entity.user.summary : entity.visitorInfos) }} | |||
{% endif %} |
@@ -1,17 +1,18 @@ | |||
{% 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-body box-profile"> | |||
<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> | |||
<ul class="list-group list-group-unbordered"> | |||
{% if user.age < 200 %} | |||
{% 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"> ans ({{ user.birthdate|date('d/m/Y') }})</span> | |||
<span class="float-right"> {{ user.age }} ans ({{ user.birthdate|date('d/m/Y') }})</span> | |||
</li> | |||
{% endif %} | |||
@@ -51,9 +52,15 @@ | |||
</li> | |||
{% endif %} | |||
</ul> | |||
<br /> | |||
<div> | |||
<a class="btn btn-sm btn-primary float-right" href="{{ path('easyadmin', {"action" : 'edit', 'entity': 'User', 'id': user.id}) }}"> | |||
Éditer l'utilisateur | |||
</a> | |||
</div> | |||
</div> | |||
</div> | |||
{% endmacro box_info %} | |||
{% endmacro card_info %} | |||
{% macro box_rank_sum_order(user) %} |
@@ -22,7 +22,7 @@ | |||
<div class="lc-vue-js-container" id="lc-user"> | |||
<div class="row"> | |||
<div class="col-3"> | |||
{{ user_macros.box_info(entity) }} | |||
{{ user_macros.card_info(entity) }} | |||
</div> | |||
<div class="col-3"> | |||
{{ user_macros.box_rank_total_order(entity) }} | |||
@@ -44,9 +44,10 @@ | |||
{{ macros.card_end() }} | |||
{% endif %} | |||
{% if entity.tickets|length %} | |||
{% set tickets = ticketUtils.getTicketsByUser(entity) %} | |||
{% if tickets|length %} | |||
{{ macros.card_start('Ticket.listMessages', 'warning card-outline', false) }} | |||
{{ macros.list_tickets(entity.tickets) }} | |||
{{ macros.list_tickets(tickets) }} | |||
{{ macros.card_end() }} | |||
{% endif %} | |||
@@ -27,6 +27,11 @@ class TicketUtils | |||
$this->authorizationChecker = $authorizationChecker ; | |||
} | |||
public function getTicketsByUser($user){ | |||
$ticketRepo = $this->em->getRepository(TicketInterface::class); | |||
return $ticketRepo->findBy(array('user'=>$user)); | |||
} | |||
public function createTicket($params): TicketInterface | |||
{ | |||
$classTicket = $this->em->getClassMetadata(TicketInterface::class)->getName() ; |
@@ -20,6 +20,7 @@ class UserUtils | |||
protected $visitorRepository ; | |||
protected $merchantUtils ; | |||
protected $cookieChecker ; | |||
protected $visitor ; | |||
public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, | |||
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker, | |||
@@ -52,12 +53,20 @@ class UserUtils | |||
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) | |||
{ | |||
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() |