protected EntityManagerInterface $entityManager; | protected EntityManagerInterface $entityManager; | ||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | |||||
CookieComponent $cookieComponent, | |||||
ParameterBagInterface $parameterBag | |||||
) { | |||||
EntityManagerInterface $entityManager, | |||||
CookieComponent $cookieComponent, | |||||
ParameterBagInterface $parameterBag | |||||
) | |||||
{ | |||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->cookieComponent = $cookieComponent; | $this->cookieComponent = $cookieComponent; | ||||
$this->parameterBag = $parameterBag; | $this->parameterBag = $parameterBag; | ||||
} | } | ||||
// addVisitor | // addVisitor | ||||
public function create(string $cookie, string $ip) | |||||
public function create(string $cookieValue, string $ip) | |||||
{ | { | ||||
$visitorFactory = new VisitorFactory(); | $visitorFactory = new VisitorFactory(); | ||||
$visitor = $visitorFactory->create($cookie, $ip); | |||||
$visitor = $visitorFactory->create($cookieValue, $ip); | |||||
$this->entityManager->create($visitor); | $this->entityManager->create($visitor); | ||||
$this->entityManager->flush(); | $this->entityManager->flush(); | ||||
public function update(VisitorInterface $visitor) | 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()); | $visitor->setLastAccess(new \DateTime()); | ||||
$this->entityManager->update($visitor); | $this->entityManager->update($visitor); | ||||
} | } | ||||
// setCookieVisitor | // 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 | // updateVisitorCookie | ||||
public function updateCookie($response): void | public function updateCookie($response): void | ||||
{ | { | ||||
$response->headers->setCookie( | $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() | |||||
) | |||||
); | ); | ||||
} | } | ||||
{ | { | ||||
return $this->getTicketContainer() | return $this->getTicketContainer() | ||||
->getFactory() | ->getFactory() | ||||
->setSection($this->getSectionCurrent()) | |||||
->setMerchant($this->getMerchantCurrent()) | ->setMerchant($this->getMerchantCurrent()) | ||||
->create(); | ->create(); | ||||
} | } | ||||
{ | { | ||||
return $this->getTicketContainer()->getFieldDefinition() | return $this->getTicketContainer()->getFieldDefinition() | ||||
->setMerchant($this->getMerchantCurrent()) | ->setMerchant($this->getMerchantCurrent()) | ||||
->setSection($this->getSectionCurrent()) | |||||
->getFields($pageName); | ->getFields($pageName); | ||||
} | } | ||||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\Form\FormEvent; | |||||
use Symfony\Component\Form\FormEvents; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
class EditGiftVoucherType extends AbstractType | class EditGiftVoucherType extends AbstractType | ||||
'label' => 'Date d\'activation de votre bon cadeau :', | 'label' => 'Date d\'activation de votre bon cadeau :', | ||||
'widget'=> 'single_text', | 'widget'=> 'single_text', | ||||
'help'=> 'Date à partir de laquelle la personne pourra utiliser ce bon cadeau.' | 'help'=> 'Date à partir de laquelle la personne pourra utiliser ce bon cadeau.' | ||||
//'format'=> 'dd/MM/yyyy' | |||||
]) | ]) | ||||
->add('title', TextType::class, [ | ->add('title', TextType::class, [ | ||||
'label' => 'Message personnalisé affiché dans le bon cadeau :', | 'label' => 'Message personnalisé affiché dans le bon cadeau :', | ||||
'label' => 'Offert par :', | 'label' => 'Offert par :', | ||||
'help'=> 'Sera affiché dans le bon cadeau' | '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) | public function configureOptions(OptionsResolver $resolver) | ||||
{ | { | ||||
$resolver->setDefaults([ | $resolver->setDefaults([ | ||||
// Configure your form options here | |||||
'reduction_gift' => null | |||||
]); | ]); | ||||
} | } | ||||
} | } |
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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_UNAVAILABLE = 'product-unavailable'; | ||||
const TYPE_PRODUCT_ERROR = 'product-error'; | const TYPE_PRODUCT_ERROR = 'product-error'; |
$this->leftJoin('.qualityLabels', 'qualityLabels'); | $this->leftJoin('.qualityLabels', 'qualityLabels'); | ||||
if ($addSelect) { | if ($addSelect) { | ||||
$this->addSelect('qualityLabels'); | |||||
//$this->addSelect('qualityLabels'); | |||||
} | } | ||||
} | } | ||||
return $this; | return $this; |
$i = 0; | $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]['id'] = $orderProduct->getId(); | ||||
$data['orderProducts'][$i]['product'] = $orderProduct->getProduct()->getId(); | $data['orderProducts'][$i]['product'] = $orderProduct->getProduct()->getId(); | ||||
$data['orderProducts'][$i]['quantityOrder'] = $orderProduct->getQuantityOrder(); | $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]['title'] = $orderProduct->getTitle(); | ||||
$data['orderProducts'][$i]['price'] = $this->priceSolver->getPrice($orderProduct); | $data['orderProducts'][$i]['price'] = $this->priceSolver->getPrice($orderProduct); | ||||
$data['orderProducts'][$i]['priceWithTax'] = $this->priceSolver->getPriceWithTax($orderProduct); | $data['orderProducts'][$i]['priceWithTax'] = $this->priceSolver->getPriceWithTax($orderProduct); | ||||
); | ); | ||||
$i++; | $i++; | ||||
} | } | ||||
} | |||||
// } | |||||
return $data; | return $data; | ||||
} | } |