@@ -16,20 +16,21 @@ class VisitorBuilder | |||
protected EntityManagerInterface $entityManager; | |||
public function __construct( | |||
EntityManagerInterface $entityManager, | |||
CookieComponent $cookieComponent, | |||
ParameterBagInterface $parameterBag | |||
) { | |||
EntityManagerInterface $entityManager, | |||
CookieComponent $cookieComponent, | |||
ParameterBagInterface $parameterBag | |||
) | |||
{ | |||
$this->entityManager = $entityManager; | |||
$this->cookieComponent = $cookieComponent; | |||
$this->parameterBag = $parameterBag; | |||
} | |||
// addVisitor | |||
public function create(string $cookie, string $ip) | |||
public function create(string $cookieValue, string $ip) | |||
{ | |||
$visitorFactory = new VisitorFactory(); | |||
$visitor = $visitorFactory->create($cookie, $ip); | |||
$visitor = $visitorFactory->create($cookieValue, $ip); | |||
$this->entityManager->create($visitor); | |||
$this->entityManager->flush(); | |||
@@ -37,9 +38,11 @@ class VisitorBuilder | |||
public function update(VisitorInterface $visitor) | |||
{ | |||
$totalVisit = $visitor->getTotalVisit() + 1; | |||
if($visitor->getLastAccess() < new \DateTime('-1 hour')) { | |||
$totalVisit = $visitor->getTotalVisit() + 1; | |||
$visitor->setTotalVisit($totalVisit); | |||
} | |||
$visitor->setTotalVisit($totalVisit); | |||
$visitor->setLastAccess(new \DateTime()); | |||
$this->entityManager->update($visitor); | |||
@@ -47,30 +50,32 @@ class VisitorBuilder | |||
} | |||
// setCookieVisitor | |||
public function setCookie($response, $cookie): void | |||
public function setCookie($response, $cookieValue): Cookie | |||
{ | |||
$response->headers->setCookie( | |||
Cookie::create( | |||
$this->parameterBag->get('app.cookie_name_visitor'), | |||
$this->cookieComponent->cryptCookie($cookie), | |||
new \DateTime('+2 months'), | |||
'/', | |||
$this->cookieComponent->getCookieDomain() | |||
) | |||
$cookie = Cookie::create( | |||
$this->parameterBag->get('app.cookie_name_visitor'), | |||
$this->cookieComponent->cryptCookie($cookieValue), | |||
new \DateTime('+2 months'), | |||
'/', | |||
$this->cookieComponent->getCookieDomain() | |||
); | |||
$response->headers->setCookie($cookie); | |||
return $cookie; | |||
} | |||
// updateVisitorCookie | |||
public function updateCookie($response): void | |||
{ | |||
$response->headers->setCookie( | |||
Cookie::create( | |||
$this->parameterBag->get('app.cookie_name_visitor'), | |||
$this->cookieComponent->cryptCookie($this->getVisitorCurrent()->getCookie()), | |||
new \DateTime('+2 months'), | |||
'/', | |||
$this->cookieComponent->getCookieDomain() | |||
) | |||
Cookie::create( | |||
$this->parameterBag->get('app.cookie_name_visitor'), | |||
$this->cookieComponent->cryptCookie($this->getVisitorCurrent()->getCookie()), | |||
new \DateTime('+2 months'), | |||
'/', | |||
$this->cookieComponent->getCookieDomain() | |||
) | |||
); | |||
} | |||
@@ -16,7 +16,6 @@ abstract class TicketAdminController extends SovTicketAdminController | |||
{ | |||
return $this->getTicketContainer() | |||
->getFactory() | |||
->setSection($this->getSectionCurrent()) | |||
->setMerchant($this->getMerchantCurrent()) | |||
->create(); | |||
} | |||
@@ -25,7 +24,6 @@ abstract class TicketAdminController extends SovTicketAdminController | |||
{ | |||
return $this->getTicketContainer()->getFieldDefinition() | |||
->setMerchant($this->getMerchantCurrent()) | |||
->setSection($this->getSectionCurrent()) | |||
->getFields($pageName); | |||
} | |||
@@ -7,6 +7,8 @@ use Symfony\Component\Form\Extension\Core\Type\DateType; | |||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
use Symfony\Component\Form\FormBuilderInterface; | |||
use Symfony\Component\Form\FormEvent; | |||
use Symfony\Component\Form\FormEvents; | |||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class EditGiftVoucherType extends AbstractType | |||
@@ -18,7 +20,6 @@ class EditGiftVoucherType extends AbstractType | |||
'label' => 'Date d\'activation de votre bon cadeau :', | |||
'widget'=> 'single_text', | |||
'help'=> 'Date à partir de laquelle la personne pourra utiliser ce bon cadeau.' | |||
//'format'=> 'dd/MM/yyyy' | |||
]) | |||
->add('title', TextType::class, [ | |||
'label' => 'Message personnalisé affiché dans le bon cadeau :', | |||
@@ -32,12 +33,31 @@ class EditGiftVoucherType extends AbstractType | |||
'label' => 'Offert par :', | |||
'help'=> 'Sera affiché dans le bon cadeau' | |||
]); | |||
$builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) use ($options) { | |||
if (isset($options['reduction_gift']) && $options['reduction_gift']) { | |||
$reductionGift = $options['reduction_gift']; | |||
$form = $event->getForm(); | |||
if (!$form->isSubmitted()) { | |||
if ($reductionGift->getActivationDate()) { | |||
$form->get('activationDate')->setData($reductionGift->getActivationDate()); | |||
} | |||
if ($reductionGift->getUsers()->count()) { | |||
$form->get('email')->setData($reductionGift->getUsers()[0]->getEmail()); | |||
} | |||
if ($reductionGift->getOwnerName()) { | |||
$form->get('ownerName')->setData($reductionGift->getOwnerName()); | |||
} | |||
$form->get('title')->setData($reductionGift->getTitle()); | |||
} | |||
} | |||
}); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
// Configure your form options here | |||
'reduction_gift' => null | |||
]); | |||
} | |||
} |
@@ -13,7 +13,7 @@ use Lc\SovBundle\Model\Ticket\TicketModel as SovTicketModel; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class TicketModel extends SovTicketModel implements FilterSectionInterface, FilterMerchantInterface | |||
abstract class TicketModel extends SovTicketModel implements FilterMerchantInterface | |||
{ | |||
const TYPE_PRODUCT_UNAVAILABLE = 'product-unavailable'; | |||
const TYPE_PRODUCT_ERROR = 'product-error'; |
@@ -55,7 +55,7 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery | |||
$this->leftJoin('.qualityLabels', 'qualityLabels'); | |||
if ($addSelect) { | |||
$this->addSelect('qualityLabels'); | |||
//$this->addSelect('qualityLabels'); | |||
} | |||
} | |||
return $this; |
@@ -59,13 +59,13 @@ class OrderShopTransformer | |||
$i = 0; | |||
$orderProductsByParentCategory = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||
foreach ($orderProductsByParentCategory as $labelCategory => $orderProducts) { | |||
foreach ($orderProducts as $orderProduct) { | |||
// $orderProductsByParentCategory = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||
// foreach ($orderProductsByParentCategory as $labelCategory => $orderProducts) { | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
$data['orderProducts'][$i]['id'] = $orderProduct->getId(); | |||
$data['orderProducts'][$i]['product'] = $orderProduct->getProduct()->getId(); | |||
$data['orderProducts'][$i]['quantityOrder'] = $orderProduct->getQuantityOrder(); | |||
$data['orderProducts'][$i]['labelCategory'] = $labelCategory; | |||
// $data['orderProducts'][$i]['labelCategory'] = $labelCategory; | |||
$data['orderProducts'][$i]['title'] = $orderProduct->getTitle(); | |||
$data['orderProducts'][$i]['price'] = $this->priceSolver->getPrice($orderProduct); | |||
$data['orderProducts'][$i]['priceWithTax'] = $this->priceSolver->getPriceWithTax($orderProduct); | |||
@@ -78,7 +78,7 @@ class OrderShopTransformer | |||
); | |||
$i++; | |||
} | |||
} | |||
// } | |||
return $data; | |||
} |