use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
class CitiesController extends AbstractController | |||||
class AddressApiController extends AbstractController | |||||
{ | { | ||||
protected $utils ; | protected $utils ; | ||||
$this->utils = $utils ; | $this->utils = $utils ; | ||||
} | } | ||||
public function index(Request $request) : JsonResponse | |||||
public function cities(Request $request) : JsonResponse | |||||
{ | { | ||||
$term = $request->get('term') ; | $term = $request->get('term') ; | ||||
$context = $request->get('context') ; | $context = $request->get('context') ; | ||||
return new JsonResponse($return) ; | return new JsonResponse($return) ; | ||||
} | } | ||||
public function addresses(Request $request) : JsonResponse | |||||
{ | |||||
$return = [] ; | |||||
$address = $request->get('address') ; | |||||
$context = $request->get('context') ; | |||||
$results = $this->utils->callAddressApi($address) ; | |||||
foreach($results as $result) { | |||||
if($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) { | |||||
$streetNameNumber = $result->getStreetNumber().' '.$result->getStreetName() ; | |||||
$return[] = [ | |||||
'label' => $streetNameNumber, | |||||
'value' => $streetNameNumber, | |||||
'latitude' => $result->getCoordinates()->getLatitude(), | |||||
'longitude' => $result->getCoordinates()->getLongitude() | |||||
] ; | |||||
} | |||||
} | |||||
if($context == 'frontend') { | |||||
$return = [ | |||||
'items' => $return | |||||
] ; | |||||
} | |||||
return new JsonResponse($return) ; | |||||
} | |||||
} | } |
if ($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) { | if ($this->filtersForm->isSubmitted() && $this->filtersForm->isValid()) { | ||||
foreach ($listFields as $field) { | foreach ($listFields as $field) { | ||||
if ($this->filtersForm->has($field['property'])) { | |||||
if ($this->filtersForm->has($field['property'])) { | |||||
switch ($field['dataType']) { | switch ($field['dataType']) { | ||||
case 'option': | case 'option': | ||||
case 'integer': | case 'integer': | ||||
foreach ($positionForm->get('entities')->getData() as $elm) { | foreach ($positionForm->get('entities')->getData() as $elm) { | ||||
$this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); | ||||
$entity = $repo->find($elm['id']); | $entity = $repo->find($elm['id']); | ||||
$entity->setPosition($elm['position']); | $entity->setPosition($elm['position']); | ||||
$this->em->persist($entity); | $this->em->persist($entity); | ||||
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | ||||
$latsPos = $elm['position']; | $latsPos = $elm['position']; | ||||
} | } | ||||
dump($latsPos); | |||||
//die(); | |||||
//die(); | //die(); | ||||
//to do récupérer les élements hors ligne et incrémenter position | //to do récupérer les élements hors ligne et incrémenter position | ||||
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | /*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | ||||
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ; | return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ; | ||||
} | } | ||||
public function duplicateOtherHubAction(){ | |||||
$id = $this->request->query->get('id'); | |||||
$hubAlias = $this->request->query->get('hub'); | |||||
$refererUrl = $this->request->query->get('referer', ''); | |||||
$user = $this->security->getUser() ; | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); | |||||
$hub= $this->em->getRepository(MerchantInterface::class)->findOneByDevAlias($hubAlias); | |||||
$newEntity = clone $entity ; | |||||
if($newEntity instanceof ImageInterface){ | |||||
$newEntity->setImage(null); | |||||
} | |||||
if ($hub) { | |||||
$newEntity->setMerchant($hub); | |||||
$user->setMerchant($hub); | |||||
$this->em->persist($user); | |||||
} | |||||
$this->em->persist($newEntity) ; | |||||
$this->em->flush() ; | |||||
$redirectUrl = $hub->getMerchantConfig('url').substr($this->generateUrl('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]),1).'&hubredirection=true'; | |||||
return $this->redirect($redirectUrl) ; | |||||
} | |||||
} | } | ||||
$em->persist($user); | $em->persist($user); | ||||
$em->flush(); | $em->flush(); | ||||
return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard') ; | |||||
return $this->redirect($merchant->getMerchantConfig('url').'admin/dashboard?hubredirection=true') ; | |||||
} | } | ||||
} | } | ||||
], | ], | ||||
]); | ]); | ||||
$this->utils->addFlash('success', 'success.order.removeReductionCredit'); | |||||
$this->utils->addFlash('success', 'success.order.sendPaymentLink'); | |||||
} else { | } else { | ||||
$this->utils->addFlash('error', $formOrderSendPaymentLink->getErrors()); | $this->utils->addFlash('error', $formOrderSendPaymentLink->getErrors()); | ||||
} | } |
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Lc\ShopBundle\Context\TaxRateInterface; | use Lc\ShopBundle\Context\TaxRateInterface; | ||||
use Lc\ShopBundle\Form\Backend\Common\AbstractEditPositionType; | |||||
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType; | use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType; | ||||
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType; | use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType; | ||||
use Lc\ShopBundle\Model\ProductFamily; | use Lc\ShopBundle\Model\ProductFamily; | ||||
//hack utilisé pour filter sur les catégories lors du tri des produits par sous cat | |||||
//A améliorer à l'occas | |||||
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) | |||||
{ | |||||
$productCategoryId = false; | |||||
if (isset($dqlFilter['productCategoryId'])) $productCategoryId = $dqlFilter['productCategoryId']; | |||||
if(isset($dqlFilter['filter']))$dqlFilter = $dqlFilter['filter']; | |||||
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | |||||
$queryBuilder->leftJoin('entity.productCategories', 'product_categories'); | |||||
if ($productCategoryId) { | |||||
$queryBuilder->andWhere('product_categories.id = :cat'); | |||||
$queryBuilder->setParameter('cat', $productCategoryId); | |||||
} | |||||
return $queryBuilder; | |||||
} | |||||
public function sortByProductCategoryAction(){ | |||||
$this->dispatch(EasyAdminEvents::PRE_LIST); | |||||
$entity = null; | |||||
//Replace this with query builder function, do not use finAll of easyAdmin | |||||
if ($this->request->query->get('productCategoryId')) { | |||||
if(!is_array($this->entity['list']['dql_filter'])) { | |||||
$this->entity['list']['dql_filter'] = array('filter' => $this->entity['list']['dql_filter']); | |||||
} | |||||
$this->entity['list']['dql_filter']['productCategoryId'] = $this->request->query->get('productCategoryId'); | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
$entity = $easyadmin['item']; | |||||
}else{ | |||||
throw new \ErrorException('Action impossible') ; | |||||
} | |||||
if ($this->entity['list']['dql_filter']['filter']) $this->entity['list']['dql_filter']['filter'] .= sprintf(' AND entity.status = 1'); | |||||
else $this->entity['list']['dql_filter']['filter'] .= sprintf(' entity.status = 1'); | |||||
$fields = $this->entity['list']['fields']; | |||||
$paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), 500, 'position', 'asc', $this->entity['list']['dql_filter']); | |||||
$this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); | |||||
$positionForm = $this->createFormBuilder(array('entities', $paginator->getCurrentPageResults())) | |||||
->add('entities', CollectionType::class, array( | |||||
'required' => true, | |||||
'allow_add' => true, | |||||
'entry_type' => AbstractEditPositionType::class, | |||||
)) | |||||
->getForm(); | |||||
$positionForm->handleRequest($this->request); | |||||
if ($positionForm->isSubmitted() && $positionForm->isValid()) { | |||||
$class = $this->entity['class']; | |||||
$repo = $this->em->getRepository($class); | |||||
$latsPos = 0; | |||||
foreach ($positionForm->get('entities')->getData() as $elm) { | |||||
$this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); | |||||
$entity = $repo->find($elm['id']); | |||||
$entity->setPosition($elm['position']); | |||||
$this->em->persist($entity); | |||||
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | |||||
$latsPos = $elm['position']; | |||||
} | |||||
//die(); | |||||
//to do récupérer les élements hors ligne et incrémenter position | |||||
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | |||||
$latsPos++; | |||||
$offlineEntity->setPosition($latsPos); | |||||
$this->em->persist($offlineEntity); | |||||
}*/ | |||||
$this->em->flush(); | |||||
$this->addFlash('success', 'Position modifié', array(), 'mweb'); | |||||
return $this->redirectToReferrer(); | |||||
} | |||||
$parameters = [ | |||||
'paginator' => $paginator, | |||||
'fields' => $fields, | |||||
'batch_form' => $this->createBatchForm($this->entity['name'])->createView(), | |||||
'delete_form_template' => $this->createDeleteForm($this->entity['name'], '__id__')->createView(), | |||||
'postion_form' => $positionForm->createView(), | |||||
'entity' => $entity, | |||||
'sortable' => true | |||||
]; | |||||
return $this->executeDynamicMethod('render<EntityName>Template', ['sortable', "@LcShop/backend/default/sortable.html.twig", $parameters]); | |||||
} | |||||
} | } | ||||
if($this->request->isXmlHttpRequest()) { | if($this->request->isXmlHttpRequest()) { | ||||
$response['flashMessages'] = $this->utils->getFlashMessages(); | $response['flashMessages'] = $this->utils->getFlashMessages(); | ||||
return new Response(json_encode($response)); | return new Response(json_encode($response)); | ||||
}else{ | |||||
return parent::redirectToReferrer(); | |||||
} | } | ||||
} | } | ||||
use FOS\UserBundle\Model\UserManagerInterface; | use FOS\UserBundle\Model\UserManagerInterface; | ||||
use Lc\ShopBundle\Form\Backend\Ticket\TicketMessageType; | use Lc\ShopBundle\Form\Backend\Ticket\TicketMessageType; | ||||
use Lc\ShopBundle\Form\Backend\Ticket\TicketStatusType; | use Lc\ShopBundle\Form\Backend\Ticket\TicketStatusType; | ||||
use Lc\ShopBundle\Model\Ticket; | |||||
use Lc\ShopBundle\Services\UtilsManager; | use Lc\ShopBundle\Services\UtilsManager; | ||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
} | } | ||||
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) | |||||
{ | |||||
$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter); | |||||
if ($this->filtersForm->get('status')->getData() === null) { | |||||
$queryBuilder->andWhere('entity.status LIKE :open OR entity.status LIKE :beingprocessed'); | |||||
$queryBuilder->setParameter('open', Ticket::TICKET_STATUS_OPEN); | |||||
$queryBuilder->setParameter('beingprocessed', Ticket::TICKET_STATUS_BEING_PROCESSED); | |||||
} | |||||
return $queryBuilder; | |||||
} | |||||
public function showAction() | public function showAction() | ||||
{ | { | ||||
$this->dispatch(EasyAdminEvents::PRE_SHOW); | $this->dispatch(EasyAdminEvents::PRE_SHOW); |
<?php | |||||
namespace Lc\ShopBundle\EventSubscriber; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | |||||
use Lc\ShopBundle\Context\FilterMerchantInterface; | |||||
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||||
use Lc\ShopBundle\Context\SortableInterface; | |||||
use Lc\ShopBundle\Context\StatusInterface; | |||||
use Lc\ShopBundle\Context\TreeInterface; | |||||
use Lc\ShopBundle\Services\Utils; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
use Symfony\Component\EventDispatcher\GenericEvent; | |||||
class InitializeEventSubscriber implements EventSubscriberInterface | |||||
{ | |||||
public $merchantUtils; | |||||
public $utils; | |||||
public function __construct(MerchantUtilsInterface $merchantUtils, Utils $utils) | |||||
{ | |||||
$this->merchantUtils = $merchantUtils; | |||||
$this->utils = $utils; | |||||
} | |||||
public static function getSubscribedEvents() | |||||
{ | |||||
return array( | |||||
'easy_admin.post_initialize' => array('postInitialize'), | |||||
); | |||||
} | |||||
public function postInitialize(GenericEvent $event) | |||||
{ | |||||
$request = $event->getArgument('request'); | |||||
if($request->query->get('hubredirection')){ | |||||
$this->utils->addFlash('alert', "Vous êtes maintenant sur le hub de ".$this->merchantUtils->getMerchantCurrent()->getTitle()); | |||||
} | |||||
} | |||||
} |
'translation_domain' => 'lcshop', | 'translation_domain' => 'lcshop', | ||||
]) ; | ]) ; | ||||
} | } | ||||
else { | |||||
// captcha (honey pot) | |||||
$builder->add('body', TextType::class, [ | |||||
'label' => 'Body', | |||||
'required' => false, | |||||
]) ; | |||||
} | |||||
$builder->add('subject', TextType::class, [ | $builder->add('subject', TextType::class, [ | ||||
'label' => 'Sujet' | 'label' => 'Sujet' |
: void | : void | ||||
{ | { | ||||
dump('ncnnc'); | |||||
$level = $this->getLogLevel($evt); | $level = $this->getLogLevel($evt); | ||||
$message = $evt->getMessage(); | $message = $evt->getMessage(); | ||||
{ | { | ||||
$count = 0; | $count = 0; | ||||
$count += (int)strlen($this->getPropertyAllergens()) > 0; | |||||
$count += (int)strlen($this->getPropertyComposition()) > 0; | |||||
$count += (int)strlen($this->getPropertyFragrances()) > 0; | |||||
$count += (int)strlen($this->getPropertyOrganicLabel()) > 0; | $count += (int)strlen($this->getPropertyOrganicLabel()) > 0; | ||||
$count += (int)strlen($this->getPropertyWeight()) > 0; | |||||
$count += (int)strlen($this->getPropertyFragrances()) > 0; | |||||
$count += (int)strlen($this->getPropertyComposition()) > 0; | |||||
$count += (int)strlen($this->getPropertyAllergens()) > 0; | |||||
$count += (int)strlen($this->getPropertyAlcoholLevel()) > 0; | |||||
$count += (int)strlen($this->getPropertyCharacteristics()) > 0; | |||||
$count += (int)strlen($this->getPropertyFeature()) > 0; | |||||
$count += (int)strlen($this->getPropertyPackaging()) > 0; | |||||
$count += (int)strlen($this->getPropertyQuantity()) > 0; | |||||
$count += (int)strlen($this->getPropertyVariety()) > 0; | |||||
$count += (int)($this->getPropertyExpirationDate() != null); | $count += (int)($this->getPropertyExpirationDate() != null); | ||||
return $count; | return $count; |
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->getName(); | |||||
return $this->getSummary(); | |||||
} | } | ||||
public function getSummary() | public function getSummary() |
$query->innerJoin('e.products', 'pfp'); | $query->innerJoin('e.products', 'pfp'); | ||||
$query->addSelect('pfp') ; | $query->addSelect('pfp') ; | ||||
$query->orderBy('e.position', 'ASC'); | |||||
return $query ; | return $query ; | ||||
} | } | ||||
$query->setParameter('category', $category->getId()); | $query->setParameter('category', $category->getId()); | ||||
$query->andWhere('e.status = 1'); | $query->andWhere('e.status = 1'); | ||||
$query->orderBy('e.position', 'ASC'); | |||||
return $query->getQuery()->getResult() ; | return $query->getQuery()->getResult() ; | ||||
} | } |
$('#lc-flash-messages .notice').each(function (i, notice) { | $('#lc-flash-messages .notice').each(function (i, notice) { | ||||
generateNotice($(notice).find('.type').html(), $(notice).find('.message').html()); | generateNotice($(notice).find('.type').html(), $(notice).find('.message').html()); | ||||
}); | }); | ||||
$('#lc-flash-alert .modal').each(function (i, modal) { | |||||
$(modal).modal('show'); | |||||
}); | |||||
} | } | ||||
function initButtonConfirm() { | function initButtonConfirm() { |
prototype = $('#form_entities').data('prototype'); | prototype = $('#form_entities').data('prototype'); | ||||
$('.lc-sortable tr.lc-draggable').each(function (index, li) { | $('.lc-sortable tr.lc-draggable').each(function (index, li) { | ||||
// instead be a number based on how many items we have | // instead be a number based on how many items we have | ||||
var newForm = prototype.replace(/__name__/g, index); | var newForm = prototype.replace(/__name__/g, index); | ||||
$(li).append(newForm); | $(li).append(newForm); | ||||
$(li).find('#form_entities_' + index + '_id').val($(li).data('id')); | $(li).find('#form_entities_' + index + '_id').val($(li).data('id')); | ||||
if ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '.' + index | |||||
else val = index; | |||||
if ($('.lc-sortable').data('parent-position') !== '') { | |||||
//Ajout d'un 0 initial pour les nuémros <10 | |||||
indexAsString = index.toString().padStart(2, '0'); | |||||
val = $('.lc-sortable').data('parent-position') + '.' + indexAsString | |||||
} else { | |||||
val = index; | |||||
} | |||||
$(li).find('#form_entities_' + index + '_position').val(val); | $(li).find('#form_entities_' + index + '_position').val(val); | ||||
}); | }); | ||||
computed: {}, | computed: {}, | ||||
mounted: function () { | mounted: function () { | ||||
this.setFields() | this.setFields() | ||||
log(this); | |||||
}, | }, | ||||
methods: { | methods: { | ||||
setFields: function () { | setFields: function () { |
behaviorExpirationDate: null, | behaviorExpirationDate: null, | ||||
propertyAllergens: null, | propertyAllergens: null, | ||||
propertyOrganicLabelActive: false, | propertyOrganicLabelActive: false, | ||||
propertyOrganicLabel: null, | |||||
propertyNoveltyExpirationDateActive: false, | propertyNoveltyExpirationDateActive: false, | ||||
propertyNoveltyExpirationDate:null, | |||||
activeProducts: false, | activeProducts: false, | ||||
formProducts: {}, | formProducts: {}, | ||||
title: function () { | title: function () { | ||||
this.updateChild() | this.updateChild() | ||||
}, | }, | ||||
propertyNoveltyExpirationDateActive: function () { | |||||
if(!this.propertyNoveltyExpirationDateActive){ | |||||
this.propertyNoveltyExpirationDate = null; | |||||
} | |||||
}, | |||||
propertyOrganicLabelActive: function () { | |||||
if(!this.propertyOrganicLabelActive){ | |||||
this.propertyOrganicLabel = null; | |||||
$(this.$refs['propertyOrganicLabel']).val('').trigger('change'); | |||||
} | |||||
} | |||||
} | } | ||||
}); | }); | ||||
// Reference array sent to dynamic staticRenderFns | |||||
var staticRenderFns = []; | |||||
appOrder = new Vue({ | |||||
el: '#lc-supplier-edit', | |||||
delimiters: ['${', '}'], | |||||
data() { | |||||
return Object.assign( | |||||
{ | |||||
addressType: null, | |||||
currentSection:'general', | |||||
sectionsArray: [ | |||||
{ | |||||
name: 'general', | |||||
nameDisplay: 'Général' | |||||
}, | |||||
{ | |||||
name: 'address', | |||||
nameDisplay: 'Adresse' | |||||
}, | |||||
{ | |||||
name: 'seo', | |||||
nameDisplay: 'SEO' | |||||
} | |||||
] | |||||
}, window.addressValues); | |||||
}, | |||||
mounted: function () {}, | |||||
methods: { | |||||
changeSection: function (section) { | |||||
this.currentSection = section.name; | |||||
}, | |||||
}, | |||||
watch: {} | |||||
}); | |||||
send: Envoyer | send: Envoyer | ||||
duplicate: Dupliquer | duplicate: Dupliquer | ||||
duplicateOtherHub: Dupliquer sur un autre hub | duplicateOtherHub: Dupliquer sur un autre hub | ||||
sortProductFamily: Trier les produits de cette catégorie | |||||
group: | group: | ||||
main: Général | main: Général | ||||
address: Adresse | address: Adresse | ||||
addReductionCredit: L'avoir a bien été généré | addReductionCredit: L'avoir a bien été généré | ||||
removeReductionCredit: L'avoir a bien été généré | removeReductionCredit: L'avoir a bien été généré | ||||
removeReductionCart: La réduction a bien été supprimé | removeReductionCart: La réduction a bien été supprimé | ||||
sendPaymentLink: Le lien de paiement a bien été envoyé | |||||
credit: | credit: | ||||
debited: Le compte prépayé a bien été débité | debited: Le compte prépayé a bien été débité | ||||
added: Le compte a bien été crédité | added: Le compte a bien été crédité |
{% if is_dropdown %} | {% if is_dropdown %} | ||||
<a class="btn dropdown-item {{ action.css_class|default('btn-default') }}" href="{{ action_href }}" target="{{ action.target }}"> | |||||
{%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%} | |||||
{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }} | |||||
</a> | |||||
<a class="btn dropdown-item {{ action.css_class|default('btn-default') }}" | |||||
href="{{ action_href }}{{ action.hub is defined ? '&hub='~action.hub : '' }}" target="{{ action.target }}"> | |||||
{%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%} | |||||
{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }} | |||||
</a> | |||||
{% else %} | {% else %} | ||||
<a class="btn {{ is_dropdown|default(false) ? 'dropdown-item' }} {{ action.css_class|default('btn-default') }}" data-toggle="tooltip" | |||||
{% if action.hub is defined %} | |||||
{% set trad = action.label~action.hub|uc_first %} | |||||
{% else %} | |||||
{% set trad = action.label %} | |||||
{% endif %} | |||||
<a class="btn {{ is_dropdown|default(false) ? 'dropdown-item' }} {{ action.css_class|default('btn-default') }}" | |||||
data-toggle="tooltip" | |||||
title="{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }}" | title="{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }}" | ||||
href="{{ action_href }}" target="{{ action.target }}"> | |||||
href="{{ action_href }}{{ action.hub is defined ? '&hub='~action.hub : '' }}" target="{{ action.target }}"> | |||||
{%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%} | {%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%} | ||||
</a> | </a> | ||||
{% endif %} | {% endif %} |
{% for merchant in get_merchants() %} | |||||
{% if merchant != merchantUtils.getMerchantUser %} | |||||
{% set action = action|merge({ 'hub': merchant.devAlias }) %} | |||||
{% include '@LcShop/backend/default/block/action.html.twig' %} | |||||
{% endif %} | |||||
{% endfor %} |
<i class="fa fa-{% block icon %}bg-info{% endblock %}"></i></span> | <i class="fa fa-{% block icon %}bg-info{% endblock %}"></i></span> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
{% block infoBox %} | |||||
<span class="info-box-text">{% block label %}{% endblock %}</span> | <span class="info-box-text">{% block label %}{% endblock %}</span> | ||||
<strong>{% block value %}{% endblock %}</strong> | <strong>{% block value %}{% endblock %}</strong> | ||||
{% endblock %} | |||||
<div class="float-right"> {% block button %}{% endblock %} | <div class="float-right"> {% block button %}{% endblock %} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> |
{% if app.session is not null and app.session.started %} | {% if app.session is not null and app.session.started %} | ||||
{% set _flash_messages = app.session.flashbag.all %} | {% set _flash_messages = app.session.flashbag.all %} | ||||
{% if _flash_messages['alert'] is defined and _flash_messages['alert']|length > 0 %} | |||||
<div id="lc-flash-alert"> | |||||
{% for alert in _flash_messages['alert'] %} | |||||
<div class="modal fade"> | |||||
<div class="modal-dialog"> | |||||
<div class="modal-content bg-danger"> | |||||
<div class="modal-header"> | |||||
<h4 class="modal-title">{{ alert|trans|striptags }}</h4> | |||||
</div> | |||||
<div class="modal-footer align-right"> | |||||
<button type="button" data-dismiss="modal" class="btn btn-outline-light">OK</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endfor %} | |||||
</div> | |||||
{% endif %} | |||||
{% if _flash_messages|length > 0 %} | {% if _flash_messages|length > 0 %} | ||||
<div id="lc-flash-messages"> | <div id="lc-flash-messages"> | ||||
{% for label, messages in _flash_messages %} | {% for label, messages in _flash_messages %} | ||||
{% for message in messages %} | |||||
<div class="notice"> | |||||
<span class="type">{{ label }}</span> | |||||
<span class="message"> {{ message|trans|striptags }}</span> | |||||
</div> | |||||
{% endfor %} | |||||
{% if label != 'alert' %} | |||||
{% for message in messages %} | |||||
<div class="notice"> | |||||
<span class="type">{{ label }}</span> | |||||
<span class="message"> {{ message|trans|striptags }}</span> | |||||
</div> | |||||
{% endfor %} | |||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
</div> | </div> | ||||
{% endif %} | {% endif %} |
<ul class="navbar-nav ml-auto lc-navbar"> | <ul class="navbar-nav ml-auto lc-navbar"> | ||||
{% set _user_name = easyadmin_read_property(app.user, easyadmin_config('user.name_property_path'))|default('user.unnamed'|trans(domain = 'EasyAdminBundle')) %} | |||||
{% set _user_name = app.user.name %} | |||||
{% set _logout_path = easyadmin_logout_path() %} | {% set _logout_path = easyadmin_logout_path() %} | ||||
<li class="content-top navbar-custom-menu"> | <li class="content-top navbar-custom-menu"> | ||||
{% block header_custom_menu %} | {% block header_custom_menu %} |
{% endif %} | {% endif %} | ||||
{% macro no_stock(behaviorStockWeek) %} | {% macro no_stock(behaviorStockWeek) %} | ||||
<span class="badge badge-danger"> | |||||
<span class="badge badge-warning"> | |||||
{{ _self.badge_stock_renewable(behaviorStockWeek) }} | {{ _self.badge_stock_renewable(behaviorStockWeek) }} | ||||
Pas de stock | Pas de stock | ||||
</span> | </span> | ||||
{% macro badge_stock_start(value) %} | {% macro badge_stock_start(value) %} | ||||
{% if value > 0 %} | {% if value > 0 %} | ||||
{% set badge_class = 'badge-success' %} | {% set badge_class = 'badge-success' %} | ||||
{% elseif value == 0%} | |||||
{% set badge_class = 'badge-warning' %} | |||||
{% else %} | {% else %} | ||||
{% set badge_class = 'badge-danger' %} | |||||
{% set badge_class = 'badge-secondary' %} | |||||
{% endif %} | {% endif %} | ||||
<span class="badge {{ badge_class }}"> | <span class="badge {{ badge_class }}"> | ||||
{% endmacro %} | {% endmacro %} |
{% trans_default_domain 'EasyAdminBundle' %} | {% trans_default_domain 'EasyAdminBundle' %} | ||||
<div class="custom-control custom-switch" data-propertyname="{{ field_options.property }}"> | |||||
<div class="custom-control custom-switch custom-switch-on-success custom-switch-off-danger" data-propertyname="{{ field_options.property }}"> | |||||
<input type="checkbox" class="custom-control-input" id="customSwitch{{ item.id }}-{{ field_options.property }}" {{ value == true ? 'checked' }}> | <input type="checkbox" class="custom-control-input" id="customSwitch{{ item.id }}-{{ field_options.property }}" {{ value == true ? 'checked' }}> | ||||
<label class="custom-control-label" for="customSwitch{{ item.id }}-{{ field_options.property }}">{{ 'label.true'|trans }}</label> | |||||
<label class="custom-control-label" for="customSwitch{{ item.id }}-{{ field_options.property }}">{{ field_options.label }}</label> | |||||
</div> | </div> | ||||
{# | {# | ||||
{% for val in value %} | |||||
<span class="badge badge-secondary">{{ val.getSummary }}</span> | |||||
{% endfor %} |
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.deliveryTaxRate) }} | {{ form_row(form.deliveryTaxRate) }} | ||||
</div> | </div> | ||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['bike-delivery']) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.merchantConfigs['bike-delivery-url-map']) }} | |||||
</div> | |||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
</div> | </div> | ||||
</div> | </div> |
<th colspan="2"> | <th colspan="2"> | ||||
<span>Produits / Producteurs</span> | <span>Produits / Producteurs</span> | ||||
</th> | </th> | ||||
<th v-if="order.countComplementaryOrderShops > 0">Compléments</th> | |||||
<th> | |||||
<span v-if="order.countComplementaryOrderShops > 0">Compléments</span> | |||||
</th> | |||||
<th> | <th> | ||||
<span>Prix HT à l'unité</span> | |||||
<span>Prix achat HT </span> | |||||
</th> | |||||
<th> | |||||
<span>Prix HT</span> | |||||
</th> | </th> | ||||
<th> | <th> | ||||
<span>Prix TTC à l'unité </span> | |||||
<span>Prix TTC </span> | |||||
</th> | </th> | ||||
<th> | <th> | ||||
<span>Marge </span> | <span>Marge </span> | ||||
{% macro productsTemplate(form_order_products=null) %} | {% macro productsTemplate(form_order_products=null) %} | ||||
<tr :class=" orderProduct.isRedelivery ? 'redelivery order-product-item' : 'order-product-item'"> | <tr :class=" orderProduct.isRedelivery ? 'redelivery order-product-item' : 'order-product-item'"> | ||||
<td :class="editionMode ? '' : 'hidden'"> | <td :class="editionMode ? '' : 'hidden'"> | ||||
<input type="checkbox" :value="orderProduct.id" class="order-product-checkbox" /> | |||||
<input type="checkbox" :value="orderProduct.id" class="order-product-checkbox"/> | |||||
</td> | </td> | ||||
<td colspan="2"> | <td colspan="2"> | ||||
<a :href="orderProduct.editLink" target="_blank"> | <a :href="orderProduct.editLink" target="_blank"> | ||||
<img :src="orderProduct.image" :alt="orderProduct.title" /> | |||||
{% verbatim %}{{orderProduct.title}}{% endverbatim %} | |||||
<span v-show="orderProduct.hasRedelivery"> | |||||
- <i class="fa fa-undo" data-toggle="tooltip" :title="orderProduct.redeliveryOrderShop" ></i> | |||||
<img :src="orderProduct.image" :alt="orderProduct.title"/> | |||||
{% verbatim %}{{orderProduct.title}}{% endverbatim %} | |||||
<span v-show="orderProduct.hasRedelivery"> | |||||
- <i class="fa fa-undo" data-toggle="tooltip" :title="orderProduct.redeliveryOrderShop"></i> | |||||
</span> | </span> | ||||
<span v-show="orderProduct.isRedelivery"> | |||||
- <i class="fa fa-undo" data-toggle="tooltip" title="Ce produit est une relivraison" ></i> | |||||
<span v-show="orderProduct.isRedelivery"> | |||||
- <i class="fa fa-undo" data-toggle="tooltip" title="Ce produit est une relivraison"></i> | |||||
</span> | </span> | ||||
</a> | </a> | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<span v-if="orderProduct.complementaryReference"> {% verbatim %}{{orderProduct.complementaryReference}}{% endverbatim %}</span> | |||||
<span v-if="orderProduct.complementaryReference"> {% verbatim %}{{orderProduct.complementaryReference}}{% endverbatim %}</span> | |||||
</td> | |||||
<td> | |||||
{% verbatim %}{{orderProduct.buyingPrice}}{% endverbatim %} € | |||||
</td> | </td> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.price}}{% endverbatim %}€ | {% verbatim %}{{orderProduct.price}}{% endverbatim %}€ | ||||
</td> | </td> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€ | |||||
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %} € | |||||
</td> | </td> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.totalMargin}}{% endverbatim %}€ / | |||||
{% verbatim %}{{orderProduct.marginPercent}}{% endverbatim %}% | |||||
{% verbatim %}{{orderProduct.totalMargin}}{% endverbatim %} € / | |||||
{% verbatim %}{{orderProduct.marginPercent}}{% endverbatim %} % | |||||
</td> | </td> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %} | {% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %} | ||||
{% endif %} | {% endif %} | ||||
</td> | </td> | ||||
<td> | <td> | ||||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %}€ | |||||
{% verbatim %}{{orderProduct.totalWithTaxAndReduction}}{% endverbatim %} € | |||||
</td> | </td> | ||||
<td :class="editionMode ? '' : 'hidden'"> | <td :class="editionMode ? '' : 'hidden'"> | ||||
<div class="dropdown" :class="editionMode ? '' : 'hidden'"> | |||||
<button class="btn-sm btn-info dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-expanded="false"> | |||||
<div class="dropdown" :class="editionMode ? '' : 'hidden'"> | |||||
<button class="btn-sm btn-info dropdown-toggle" type="button" id="dropdownMenu" | |||||
data-toggle="dropdown" aria-expanded="false"> | |||||
Actions | Actions | ||||
</button> | </button> | ||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu"> | <div class="dropdown-menu" aria-labelledby="dropdownMenu"> | ||||
<button v-show="modalExist('#modal-add-redelivery-order-product') && orderProduct.hasRedelivery == false" type="button" class="dropdown-item" @click="modalAddRedeliveryOrderProduct"> | |||||
<button v-show="modalExist('#modal-add-redelivery-order-product') && orderProduct.hasRedelivery == false" | |||||
type="button" class="dropdown-item" @click="modalAddRedeliveryOrderProduct"> | |||||
Générer une relivraison | Générer une relivraison | ||||
</button> | </button> | ||||
<button v-show="modalExist('#modal-add-reduction-credit')" type="button" class="dropdown-item" @click="modalAddReductionCredit" > | |||||
<button v-show="modalExist('#modal-add-reduction-credit')" type="button" class="dropdown-item" | |||||
@click="modalAddReductionCredit"> | |||||
Générer un avoir | Générer un avoir | ||||
</button> | </button> | ||||
</div> | </div> | ||||
<tbody> | <tbody> | ||||
<tr> | <tr> | ||||
<th>Total produits TTC</th> | <th>Total produits TTC</th> | ||||
<td>${order.totalOrderProductsWithTax}€</td> | |||||
<td>${order.totalOrderProductsWithTax} €</td> | |||||
</tr> | </tr> | ||||
<template v-for="(orderReductionCart, key) in order.orderReductionCarts"> | <template v-for="(orderReductionCart, key) in order.orderReductionCarts"> | ||||
<tr> | <tr> | ||||
<i class="fa fa-trash"></i> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> | ||||
<td>${orderReductionCart.amount}€</td> | |||||
<td>${orderReductionCart.amount} €</td> | |||||
</tr> | </tr> | ||||
</template> | </template> | ||||
<template v-for="(orderReductionCredit, key) in order.orderReductionCredits"> | <template v-for="(orderReductionCredit, key) in order.orderReductionCredits"> | ||||
<i class="fa fa-trash"></i> | <i class="fa fa-trash"></i> | ||||
</button> | </button> | ||||
</th> | </th> | ||||
<td>${orderReductionCredit.amount}€</td> | |||||
<td>${orderReductionCredit.amount} €</td> | |||||
</tr> | </tr> | ||||
</template> | </template> | ||||
<tr> | <tr> | ||||
<th>Total produits après réductions TTC</th> | <th>Total produits après réductions TTC</th> | ||||
<td>${order.totalOrderProductsWithTaxAndReductions}€</td> | |||||
<td>${order.totalOrderProductsWithTaxAndReductions} €</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<th>Total marge produits</th> | <th>Total marge produits</th> | ||||
<td>${order.totalMargin}€ <br /> ${order.totalMarginPercent}%</td> | |||||
<td>${order.totalMargin} € <br/> ${order.totalMarginPercent} %</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<th>Frais de livraisons TTC</th> | <th>Frais de livraisons TTC</th> | ||||
<td>${order.deliveryPriceWithTaxAndReduction}€</td> | |||||
<td>${order.deliveryPriceWithTaxAndReduction} €</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<th>Total TTC</th> | <th>Total TTC</th> | ||||
<td>${order.totalWithTax}€</td> | |||||
<td>${order.totalWithTax} €</td> | |||||
</tr> | </tr> | ||||
</tbody> | </tbody> | ||||
{% macro box_user_info() %} | {% macro box_user_info() %} | ||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% set value = ' <a v-if="order.user" :href="order.userLink" target="_blank" v-html="order.user"></a> | |||||
<span v-else v-html="order.visitor"></span>' %} | |||||
{{ macros.box_info('bg-info', 'user',"field.default.user"|trans({}, 'lcshop'), value) }} | |||||
{% 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 %} | {% endmacro box_user_info %} | ||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% block class %}bg-info{% endblock %} | {% block class %}bg-info{% endblock %} | ||||
{% block icon %}credit-card{% endblock %} | {% block icon %}credit-card{% endblock %} | ||||
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop')}}{% endblock %} | |||||
{% block label %}{{ "field.OrderShop.reference"|trans({}, 'lcshop') }}{% endblock %} | |||||
{% block value %} | {% block value %} | ||||
${order.reference}<br /> | |||||
${order.reference}<br/> | |||||
<span v-if="order.countComplementaryOrderShops > 0"> | <span v-if="order.countComplementaryOrderShops > 0"> | ||||
${order.countComplementaryOrderShops} commande(s) complémentaire(s) | ${order.countComplementaryOrderShops} commande(s) complémentaire(s) | ||||
</span> | </span> | ||||
{% endblock %} | {% endblock %} | ||||
{% block button %} | |||||
{{ order_macros.order_modal_button('#modal-order-delivery-address') }} | |||||
{% endblock %} | |||||
{% endembed %} | {% endembed %} | ||||
{% endmacro %} | {% endmacro %} | ||||
{% macro box_total_order() %} | {% macro box_total_order() %} | ||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% 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-danger{% endblock %} | |||||
{% block icon %}euro-sign{% endblock %} | |||||
{% block infoBox %} | |||||
<table style="width: 100%"> | |||||
<tr> | |||||
<td> | |||||
Total produits TTC :<i class="icon info" data-toggle="tooltip" title="Après reduction"></i> | |||||
</td> | |||||
<td> | |||||
<strong class="float-right"> ${order.totalOrderProductsWithTaxAndReductions} €</strong><br/> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td> | |||||
Total marge produits : | |||||
</td> | |||||
<td> | |||||
<strong class="float-right">${order.totalMargin} € / ${order.totalMarginPercent} %</strong><br/> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td> | |||||
Frais de livraisons TTC : | |||||
</td> | |||||
<td> | |||||
<strong class="float-right">${order.deliveryPriceWithTaxAndReduction} €</strong><br/> | |||||
</td> | |||||
</tr> | |||||
<tr> | |||||
<td> | |||||
Total commandes : | |||||
</td> | |||||
<td> | |||||
<strong class="float-right"> ${order.totalWithTax} €</strong><br/> | |||||
</td> | |||||
</tr> | |||||
</table> | |||||
{{ macros.box_info('bg-danger', 'euro-sign',"field.OrderShop.total"|trans({}, 'lcshop'), ' ${order.totalWithTax} €') }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
{% endmacro %} | {% endmacro %} | ||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% block class %}bg-success{% endblock %} | {% block class %}bg-success{% endblock %} | ||||
{% block icon %}map-marked-alt{% endblock %} | {% block icon %}map-marked-alt{% endblock %} | ||||
{% block label %}{{ "field.default.deliveryAddress"|trans({}, 'lcshop')}}{% endblock %} | |||||
{% block label %}{{ "field.default.deliveryAddress"|trans({}, 'lcshop') }}{% endblock %} | |||||
{% block value %} | {% block value %} | ||||
<div v-if="order.deliveryAddress"> | <div v-if="order.deliveryAddress"> | ||||
<address v-html="order.deliveryAddress"> | <address v-html="order.deliveryAddress"> | ||||
</div>' %} | </div>' %} | ||||
{{ macros.card_start("OrderShop.payment", 'danger card-outline', false, tools) }} | {{ macros.card_start("OrderShop.payment", 'danger card-outline', false, tools) }} | ||||
<table class="table table-striped" style="margin-bottom: 15px"> | |||||
<tbody> | |||||
<thead> | |||||
<table class="table table-striped" style="margin-bottom: 15px"> | |||||
<tbody> | |||||
<thead> | |||||
<tr> | |||||
<th v-if="order.countComplementaryOrderShops > 0">Référence</th> | |||||
<th>Mode de règlement</th> | |||||
<th>Date</th> | |||||
<th>Montant</th> | |||||
<th>Actions</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<template v-for="(orderPayment, i) in order.orderPayments"> | |||||
<tr> | <tr> | ||||
<th v-if="order.countComplementaryOrderShops > 0">Référence</th> | |||||
<th>Mode de règlement</th> | |||||
<th>Date</th> | |||||
<th>Montant</th> | |||||
<th>Actions</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<template v-for="(orderPayment, i) in order.orderPayments"> | |||||
<tr> | |||||
<td v-if="order.countComplementaryOrderShops > 0"> | |||||
${orderPayment.orderReference} | |||||
</td> | |||||
<td>${orderPayment.meanPaymentText}</td> | |||||
<td>${orderPayment.paidAtText}</td> | |||||
<td>${orderPayment.amount}</td> | |||||
<td v-if="order.countComplementaryOrderShops > 0"> | |||||
${orderPayment.orderReference} | |||||
</td> | |||||
<td>${orderPayment.meanPaymentText}</td> | |||||
<td>${orderPayment.paidAtText}</td> | |||||
<td>${orderPayment.amount}</td> | |||||
<td> | |||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-pen"></i> | |||||
</button> | |||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" | |||||
type="button" class="btn-sm btn-danger" | |||||
@click="modalDeleteOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
</td> | |||||
</tr> | |||||
</template> | |||||
</tbody> | |||||
</table> | |||||
<div class="col-11"> | |||||
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }} | |||||
<td> | |||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" | |||||
class="btn-sm btn-info" type="button" @click="editOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-pen"></i> | |||||
</button> | |||||
<button v-show="orderPayment.editable && editionMode && modalExist('#modal-delete-order-payment')" | |||||
type="button" class="btn-sm btn-danger" | |||||
@click="modalDeleteOrderPayment(orderPayment.id)"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
</td> | |||||
</tr> | |||||
</template> | |||||
</tbody> | |||||
</table> | |||||
<div class="col-11"> | |||||
{{ _self.order_modal_button('#modal-order-payment', 'btn-info', "action.order.addOrderPayment") }} | |||||
<strong class="float-right">Total règlement : ${order.totalOrderPaid} €</strong> | |||||
<strong class="float-right">Total règlement : ${order.totalOrderPaid} €</strong> | |||||
{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#} | |||||
</div> | |||||
{#TODO: afficher si la commande est règlé et afficher une alerte si le montant des paiments est supérieur au montant total de la commande#} | |||||
</div> | |||||
{{ macros.card_end() }} | {{ macros.card_end() }} | ||||
{% endmacro %} | {% endmacro %} | ||||
<td>Facture</td> | <td>Facture</td> | ||||
<td>${orderDocument.reference}</td> | <td>${orderDocument.reference}</td> | ||||
<td> | <td> | ||||
<a :href="'./?entity=Document&action=downloadInvoice&id='+orderDocument.id" class="btn-sm btn-default">Télécharger</a> | |||||
<a :href="'./?entity=Document&action=downloadInvoice&id='+orderDocument.id" | |||||
class="btn-sm btn-default">Télécharger</a> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
</template> | </template> | ||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% block class %}bg-success{% endblock %} | {% block class %}bg-success{% endblock %} | ||||
{% block icon %}info{% endblock %} | {% block icon %}info{% endblock %} | ||||
{% block label %}{{ "field.OrderShop.status"|trans({}, 'lcshop')}}{% endblock %} | |||||
{% block label %}{{ "field.OrderShop.status"|trans({}, 'lcshop') }}{% endblock %} | |||||
{% block value %} | {% block value %} | ||||
<strong> ${order.orderStatus}</strong> | <strong> ${order.orderStatus}</strong> | ||||
{% endblock %} | {% endblock %} |
{{ order_macros.box_user_info() }} | {{ order_macros.box_user_info() }} | ||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_validation_date() }} | |||||
{{ order_macros.box_total_order() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_total_order() }} | |||||
{{ order_macros.box_validation_date() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> |
{{ order_macros.box_user_info() }} | {{ order_macros.box_user_info() }} | ||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_validation_date() }} | |||||
{{ order_macros.box_total_order() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_total_order() }} | |||||
{{ order_macros.box_validation_date() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> |
{{ order_macros.box_user_info() }} | {{ order_macros.box_user_info() }} | ||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_validation_date() }} | |||||
{{ order_macros.box_total_order() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_total_order() }} | |||||
{{ order_macros.box_validation_date() }} | |||||
</div> | </div> | ||||
<div class="col-3"> | <div class="col-3"> | ||||
{{ order_macros.box_status() }} | {{ order_macros.box_status() }} | ||||
</div> | </div> |
{% if item.getChildrens()|length == 0 %} | |||||
<a class="btn {{ is_dropdown|default(false) ? 'dropdown-item' }} {{ action.css_class|default('btn-default') }}" data-toggle="tooltip" | |||||
title="{{ action.label|trans(arguments = trans_parameters|merge({ '%entity_id%': item_id }), domain = translation_domain) }}" | |||||
href="{{ path('easyadmin', {action: 'sortByProductCategory', entity: 'ProductFamily', productCategoryId: item.id, referer: app.request.requestUri|url_encode }) }}" target="{{ action.target }}"> | |||||
{%- if action.icon %}<i class="fa fa-fw fa-{{ action.icon }}"></i> {% endif -%} | |||||
</a> | |||||
{% endif %} |
{% if formValues.availableQuantity %}availableQuantity: "{{ formValues.availableQuantity }}",{% endif %} | {% if formValues.availableQuantity %}availableQuantity: "{{ formValues.availableQuantity }}",{% endif %} | ||||
{% if formValues.availableQuantityDefault %}availableQuantityDefault: "{{ formValues.availableQuantityDefault }}",{% endif %} | {% if formValues.availableQuantityDefault %}availableQuantityDefault: "{{ formValues.availableQuantityDefault }}",{% endif %} | ||||
{% if formValues.propertyOrganicLabel %}propertyOrganicLabelActive: true,{% endif %} | {% if formValues.propertyOrganicLabel %}propertyOrganicLabelActive: true,{% endif %} | ||||
{% if formValues.propertyOrganicLabel %}propertyOrganicLabel: "{{ formValues.propertyOrganicLabel }}",{% endif %} | |||||
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | {% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | ||||
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDate: "{{ formValues.propertyNoveltyExpirationDate|date('Y-m-d') }}",{% endif %} | |||||
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | {% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | ||||
{% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | {% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | ||||
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %} | {% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %} |
<td>{{ form_widget(form.propertyNoveltyExpirationDateActive, {"attr" : {'v-model' : 'propertyNoveltyExpirationDateActive'}}) }}</td> | <td>{{ form_widget(form.propertyNoveltyExpirationDateActive, {"attr" : {'v-model' : 'propertyNoveltyExpirationDateActive'}}) }}</td> | ||||
<td> | <td> | ||||
<div v-show="propertyNoveltyExpirationDateActive == true"> | <div v-show="propertyNoveltyExpirationDateActive == true"> | ||||
{{ form_widget(form.propertyNoveltyExpirationDate) }} | |||||
{{ form_widget(form.propertyNoveltyExpirationDate, {"attr" : {'v-model' : 'propertyNoveltyExpirationDate'}}) }} | |||||
</div> | </div> | ||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<td>{{ form_widget(form.propertyOrganicLabelActive, {"attr" : {'v-model' : 'propertyOrganicLabelActive' } }) }}</td> | <td>{{ form_widget(form.propertyOrganicLabelActive, {"attr" : {'v-model' : 'propertyOrganicLabelActive' } }) }}</td> | ||||
<td> | <td> | ||||
<div class="form-widget" v-show="propertyOrganicLabelActive == true"> | <div class="form-widget" v-show="propertyOrganicLabelActive == true"> | ||||
{{ form_widget(form.propertyOrganicLabel) }} | |||||
{{ form_widget(form.propertyOrganicLabel, {"attr" : {'v-model' : 'propertyOrganicLabel', 'ref': 'propertyOrganicLabel'}}) }} | |||||
</div> | </div> | ||||
</td> | </td> | ||||
</tr> | </tr> |
{{ form_help(form.availableQuantityDefault) }} | {{ form_help(form.availableQuantityDefault) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<p v-show="behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY') }}' || behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}' "> | |||||
<p v-show="behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY') }}' || behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}' || behaviorCountStock == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED') }}' "> | |||||
{{ product_family_macros.total_order_product_family(totalProductOrdered['total'], entity) }} | {{ product_family_macros.total_order_product_family(totalProductOrdered['total'], entity) }} | ||||
</p> | </p> | ||||
</div> | </div> |
{% extends app.request.query.get('action') == 'edit' ? '@LcShop/backend/default/edit.html.twig' : '@LcShop/backend/default/new.html.twig' %} | |||||
{% block entity_form %} | |||||
{% include '@LcShop/backend/supplier/form.html.twig' %} | |||||
{% endblock entity_form %} | |||||
{% block script_javascript %} | |||||
{{ parent() }} | |||||
{% include '@LcShop/backend/default/block/script-vuejs.html.twig' %} | |||||
<script src="{{ asset('bundles/lcshop/js/backend/script/supplier/vuejs-supplier.js') }}"></script> | |||||
{% endblock %} |
{{ form_start(form) }} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
{% set formValues = form.vars.value %} | |||||
<div id="lc-supplier-edit"> | |||||
<div class="card card-light"> | |||||
<div class="lc-vue-js-container card-header p-0 border-bottom-0"> | |||||
<ul class="nav nav-tabs" id="nav-params"> | |||||
<li class="nav-item" v-for="section in sectionsArray"> | |||||
<button type="button" | |||||
:class="'btn '+((currentSection == section.name) ? 'btn btn-primary' : 'btn ')" | |||||
@click="changeSection(section)"> | |||||
${ section.nameDisplay } | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
</button> | |||||
</li> | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
<div class="form "> | |||||
<div v-show="currentSection == 'general'" class="panel panel-default"> | |||||
{% include '@LcShop/backend/supplier/panel_general.html.twig' %} | |||||
</div> | |||||
<div v-show="currentSection == 'address'" class="panel panel-default"> | |||||
{% include '@LcShop/backend/supplier/panel_address.html.twig' %} | |||||
</div> | |||||
<div v-show="currentSection == 'seo'" class="panel panel-default"> | |||||
{% include '@LcShop/backend/supplier/panel_seo.html.twig' %} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{ form_end(form) }} | |||||
{% trans_default_domain 'lcshop' %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="row"> | |||||
<div class="col-8"> | |||||
{{ macros.card_start('Merchant.address','light') }} | |||||
{% do form.address.civility.setRendered %} | |||||
{% do form.address.firstname.setRendered %} | |||||
{% do form.address.lastname.setRendered %} | |||||
{% do form.address.phone.setRendered %} | |||||
{% do form.address.latitude.setRendered %} | |||||
{% do form.address.longitude.setRendered %} | |||||
{% do form.address.deliveryInfos.setRendered %} | |||||
{% include '@LcShop/backend/default/block/form_address.html.twig' with {'form' : form.address}%} | |||||
{{ macros.card_end() }} | |||||
</div> | |||||
</div> |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="row"> | |||||
<div class="col-8"> | |||||
{{ macros.card_start('Merchant.main','light') }} | |||||
<div class="col-12"> | |||||
{{ form_row(form.title) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.subtitle) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.kmsHub) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.imageFile) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.description) }} | |||||
</div> | |||||
{{ macros.card_end() }} | |||||
</div> | |||||
</div> |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | |||||
<div class="row"> | |||||
<div class="col-8"> | |||||
{{ macros.card_start('Merchant.seo','light') }} | |||||
<div class="col-12"> | |||||
{{ form_row(form.metaTitle) }} | |||||
</div> | |||||
<div class="col-12"> | |||||
{{ form_row(form.metaDescription) }} | |||||
</div> | |||||
{{ macros.card_end() }} | |||||
</div> | |||||
</div> |
use App\Entity\UserMerchant; | use App\Entity\UserMerchant; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\MerchantInterface; | |||||
use Lc\ShopBundle\Context\UserMerchantInterface; | use Lc\ShopBundle\Context\UserMerchantInterface; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
return false ; | return false ; | ||||
} | } | ||||
public function getOrderProductsByProductFamilyInCart($productFamily) | |||||
{ | |||||
$arrayOrderProducts = [] ; | |||||
$orderShop = $this->getCartCurrent() ; | |||||
if($orderShop) { | |||||
foreach($orderShop->getOrderProducts() as $orderProduct) { | |||||
if($orderProduct->getProduct()->getProductFamily() == $productFamily) { | |||||
$arrayOrderProducts[] = $orderProduct ; | |||||
} | |||||
} | |||||
} | |||||
return $arrayOrderProducts ; | |||||
} | |||||
public function groupOrderProductsByProductFamily($orderProducts) | public function groupOrderProductsByProductFamily($orderProducts) | ||||
{ | { | ||||
$orderProductsByProductFamily = []; | $orderProductsByProductFamily = []; |
<?php | |||||
namespace Lc\ShopBundle\Services ; | |||||
class PointLocationUtils { | |||||
var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices? | |||||
function pointLocation() { | |||||
} | |||||
function pointInPolygon($point, $polygon, $pointOnVertex = true) { | |||||
$this->pointOnVertex = $pointOnVertex; | |||||
// Transform string coordinates into arrays with x and y values | |||||
$point = $this->pointStringToCoordinates($point); | |||||
$vertices = array(); | |||||
foreach ($polygon as $vertex) { | |||||
$vertices[] = $this->pointStringToCoordinates($vertex); | |||||
} | |||||
// Check if the point sits exactly on a vertex | |||||
if ($this->pointOnVertex == true and $this->pointOnVertex($point, $vertices) == true) { | |||||
return "vertex"; | |||||
} | |||||
// Check if the point is inside the polygon or on the boundary | |||||
$intersections = 0; | |||||
$vertices_count = count($vertices); | |||||
for ($i=1; $i < $vertices_count; $i++) { | |||||
$vertex1 = $vertices[$i-1]; | |||||
$vertex2 = $vertices[$i]; | |||||
if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary | |||||
return "boundary"; | |||||
} | |||||
if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) { | |||||
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; | |||||
if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal) | |||||
return "boundary"; | |||||
} | |||||
if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) { | |||||
$intersections++; | |||||
} | |||||
} | |||||
} | |||||
// If the number of edges we passed through is odd, then it's in the polygon. | |||||
if ($intersections % 2 != 0) { | |||||
return "inside"; | |||||
} else { | |||||
return "outside"; | |||||
} | |||||
} | |||||
function pointOnVertex($point, $vertices) { | |||||
foreach($vertices as $vertex) { | |||||
if ($point == $vertex) { | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
function pointStringToCoordinates($pointString) { | |||||
$coordinates = explode(" ", $pointString); | |||||
return array("x" => $coordinates[0], "y" => $coordinates[1]); | |||||
} | |||||
} |
class OrderProductPriceUtils | class OrderProductPriceUtils | ||||
{ | { | ||||
use PriceUtilsTrait ; | |||||
use PriceUtilsTrait; | |||||
protected $productPriceUtils ; | |||||
protected $productPriceUtils; | |||||
public function __construct(ProductPriceUtils $productPriceUtils) | public function __construct(ProductPriceUtils $productPriceUtils) | ||||
{ | { | ||||
$this->productPriceUtils = $productPriceUtils ; | |||||
$this->productPriceUtils = $productPriceUtils; | |||||
} | } | ||||
public function getPrice(OrderProductInterface $orderProduct) | |||||
public function getPrice(OrderProductInterface $orderProduct, $round = false) | |||||
{ | { | ||||
return $orderProduct->getPrice(); | |||||
if ($round) { | |||||
return $this->round($orderProduct->getPrice()); | |||||
} else { | |||||
return $orderProduct->getPrice(); | |||||
} | |||||
} | } | ||||
public function getBuyingPrice(OrderProductInterface $orderProduct) | |||||
public function getBuyingPrice(OrderProductInterface $orderProduct, $round = false) | |||||
{ | { | ||||
return $orderProduct->getBuyingPrice(); | |||||
if ($round) { | |||||
return $this->round($orderProduct->getBuyingPrice()); | |||||
} else { | |||||
return $orderProduct->getBuyingPrice(); | |||||
} | |||||
} | } | ||||
public function getPriceWithTax(OrderProductInterface $orderProduct) | public function getPriceWithTax(OrderProductInterface $orderProduct) | ||||
} | } | ||||
public function getPriceWithReduction(OrderProductInterface $orderProduct) | |||||
public function getPriceWithReduction(OrderProductInterface $orderProduct, $round = true) | |||||
{ | { | ||||
return $this->applyReductionCatalog( | return $this->applyReductionCatalog( | ||||
$orderProduct, | $orderProduct, | ||||
$this->getPriceWithTax($orderProduct), | $this->getPriceWithTax($orderProduct), | ||||
1, | 1, | ||||
null, | null, | ||||
false | |||||
false, | |||||
$round | |||||
); | ); | ||||
} | } | ||||
public function getMargin(OrderProductInterface $orderProduct) | public function getMargin(OrderProductInterface $orderProduct) | ||||
{ | { | ||||
return $this->getPriceWithReduction($orderProduct) - $this->getBuyingPrice($orderProduct); | |||||
return $this->round($this->getPriceWithReduction($orderProduct, false) - $this->getBuyingPrice($orderProduct)); | |||||
} | } | ||||
public function getMarginPercent(OrderProductInterface $orderProduct) | public function getMarginPercent(OrderProductInterface $orderProduct) | ||||
{ | { | ||||
if($this->getBuyingPrice($orderProduct)) { | |||||
if ($this->getBuyingPrice($orderProduct)) { | |||||
return $this->round(($this->getMargin($orderProduct) / $this->getPriceWithReduction($orderProduct)) * 100); | return $this->round(($this->getMargin($orderProduct) / $this->getPriceWithReduction($orderProduct)) * 100); | ||||
}else{ | |||||
} else { | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//inclus toujours les réductions catalogues | //inclus toujours les réductions catalogues | ||||
public function getTotalTaxes(OrderProductInterface $orderProduct){ | |||||
public function getTotalTaxes(OrderProductInterface $orderProduct) | |||||
{ | |||||
return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct); | return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct); | ||||
} | } | ||||
} | } |
return round((($price * $percent)) / 100, 2); | return round((($price * $percent)) / 100, 2); | ||||
} | } | ||||
public function applyReductionCatalog($entity, $price, $priceWithTax, $quantity = 1, $reductionCatalog = null, $withTax = true): ?float | |||||
public function applyReductionCatalog($entity, $price, $priceWithTax, $quantity = 1, $reductionCatalog = null, $withTax = true, $round = true): ?float | |||||
{ | { | ||||
if ($reductionCatalog) { | if ($reductionCatalog) { | ||||
} else { | } else { | ||||
$priceReturn = $this->applyPercentNegative($priceWithTax, $entity->getTaxRateInherited()->getValue()); | $priceReturn = $this->applyPercentNegative($priceWithTax, $entity->getTaxRateInherited()->getValue()); | ||||
} | } | ||||
if($round){ | |||||
return $this->round($priceReturn); | |||||
}else{ | |||||
return $priceReturn; | |||||
} | |||||
return $this->round($priceReturn); | |||||
} | } | ||||
<?php | |||||
namespace Lc\ShopBundle\Services; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | |||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | |||||
use Lc\ShopBundle\Context\ProductInterface; | |||||
use Lc\ShopBundle\Context\ProductPropertyInterface; | |||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||||
class PriceUtilsOld | |||||
{ | |||||
public function getPrice($entity) | |||||
{ | |||||
if ($entity instanceof ProductPropertyInterface) { | |||||
if ($entity->getBehaviorPriceInherited() == 'by-piece') { | |||||
return $entity->getPriceInherited(); | |||||
} elseif ($entity->getBehaviorPriceInherited() == 'by-reference-unit') { | |||||
if ($entity->getQuantityInherited() > 0) { | |||||
return $entity->getPriceByRefUnitInherited() * ($entity->getQuantityInherited() / $entity->getUnitInherited()->getCoefficient()); | |||||
} | |||||
} | |||||
} | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $entity->getPrice(); | |||||
} | |||||
return null; | |||||
} | |||||
public function getPriceWithTax($entity) | |||||
{ | |||||
return $this->applyTax( | |||||
$this->getPrice($entity), | |||||
$entity->getTaxRateInherited()->getValue() | |||||
); | |||||
} | |||||
public function getPriceWithTaxAndReduction($entity) | |||||
{ | |||||
return $this->getPriceWithTaxAndReductionCatalog( | |||||
$entity, | |||||
$this->getPrice($entity), | |||||
$this->getPriceWithTax($entity) | |||||
); | |||||
} | |||||
public function getPriceByRefUnit($entity) | |||||
{ | |||||
if ($entity instanceof ProductPropertyInterface) { | |||||
if ($entity->getBehaviorPriceInherited() == 'by-piece') { | |||||
return ($this->getPrice($entity) * $entity->getUnitInherited()->getCoefficient()) / $entity->getQuantityInherited(); | |||||
} elseif ($entity->getBehaviorPriceInherited() == 'by-reference-unit') { | |||||
return $entity->getPriceByRefUnitInherited(); | |||||
} | |||||
} | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return ($this->getPrice($entity) * $entity->getUnitInherited()->getCoefficient()) / $entity->getQuantityProduct(); | |||||
} | |||||
return null; | |||||
} | |||||
public function getPriceByRefUnitWithTax($entity) | |||||
{ | |||||
return $this->applyTax( | |||||
$this->getPriceByRefUnit($entity), | |||||
$entity->getTaxRateInherited()->getValue() | |||||
); | |||||
} | |||||
public function getPriceByRefUnitWithTaxAndReduction($entity) | |||||
{ | |||||
return $this->getPriceWithTaxAndReductionCatalog( | |||||
$entity, | |||||
$this->getPriceByRefUnit($entity), | |||||
$this->getPriceByRefUnitWithTax($entity) | |||||
); | |||||
} | |||||
public function getTotal($entity) | |||||
{ | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $entity->getQuantityOrder() * $this->getPrice($entity); | |||||
} | |||||
if ($entity instanceof OrderShopInterface) { | |||||
$total = 0; | |||||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||||
$total += $this->getTotal($orderProduct); | |||||
} | |||||
return $total; | |||||
} | |||||
return null; | |||||
} | |||||
public function getTotalWithTax($entity) | |||||
{ | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $this->applyTax( | |||||
$this->getTotal($entity), | |||||
$entity->getTaxRateInherited()->getValue() | |||||
); | |||||
} | |||||
if ($entity instanceof OrderShopInterface) { | |||||
$total = 0; | |||||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||||
$total += $this->getTotalWithTax($orderProduct); | |||||
} | |||||
return $total; | |||||
} | |||||
//C'est bizzare ce truc là | |||||
//if($entity instanceof OrderShopInterface) { | |||||
// return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ; | |||||
//} | |||||
return null; | |||||
} | |||||
public function getTotalWithTaxAndReduction($entity) | |||||
{ | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $this->getPriceWithTaxAndReductionCatalog( | |||||
$entity, | |||||
$this->getTotal($entity), | |||||
$this->getTotalWithTax($entity) | |||||
); | |||||
} | |||||
if ($entity instanceof OrderShopInterface) { | |||||
return $this->getTotalOrderProductsWithTaxAndReduction($entity->getOrderProducts(), true, true); | |||||
} | |||||
} | |||||
public function getTotalWithReduction($entity) | |||||
{ | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $this->getPriceWithReductionCatalog( | |||||
$entity, | |||||
$this->getTotal($entity), | |||||
$this->getTotalWithTax($entity) | |||||
); | |||||
} | |||||
if ($entity instanceof OrderShopInterface) { | |||||
return $this->getTotalOrderProductsWithReduction($entity->getOrderProducts(), true, true); | |||||
} | |||||
} | |||||
public function getTotalOrderProductsWithReductionCart(OrderShopInterface $order) | |||||
{ | |||||
$this->_getTotalOrderProductsWithReductionCartGeneric($order, false); | |||||
} | |||||
public function getTotalOrderProductsWithTaxAndReductionCart(OrderShopInterface $order) | |||||
{ | |||||
$this->_getTotalOrderProductsWithReductionCartGeneric($order, true); | |||||
} | |||||
private function _getTotalOrderProductsWithReductionCartGeneric(OrderShopInterface $order, $withTax = true) | |||||
{ | |||||
if ($withTax) { | |||||
$priceToReturn = $this->getTotalOrderProductsWithTaxAndReductionCatalog($order); | |||||
} | |||||
else { | |||||
$priceToReturn = $this->getTotalOrderProductsWithReductionCatalog($order); | |||||
} | |||||
foreach ($order->getOrderReductionCarts() as $orderReductionCart) { | |||||
if ($orderReductionCart->getUnit() == 'percent') { | |||||
$priceToReturn = $this->applyReductionPercent( | |||||
$priceToReturn, | |||||
$orderReductionCart->getValue | |||||
); | |||||
} else if ($orderReductionCart->getUnit() == 'amount') { | |||||
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-inlcluded') { | |||||
$priceToReturn = | |||||
$this->applyReductionAmount( | |||||
$priceToReturn, | |||||
$orderReductionCart->getValue() | |||||
); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public function getTotalOrderProducts($entity) | |||||
{ | |||||
return $this->getSumOrderProductsDispatch($entity); | |||||
} | |||||
public function getTotalOrderProductsWithTax($entity) | |||||
{ | |||||
return $this->getSumOrderProductsDispatch($entity, true); | |||||
} | |||||
public function getTotalOrderProductsWithReduction($entity) | |||||
{ | |||||
return $this->getTotalOrderProductsWithReductionCatalog($entity); | |||||
} | |||||
public function getTotalOrderProductsWithTaxAndReduction($entity) | |||||
{ | |||||
return $this->getTotalOrderProductsWithTaxAndReductionCatalog($entity); | |||||
} | |||||
public function getTotalOrderProductsWithReductionCatalog($entity) | |||||
{ | |||||
return $this->getSumOrderProductsDispatch($entity, false, true); | |||||
} | |||||
public function getTotalOrderProductsWithTaxAndReductionCatalog($entity) | |||||
{ | |||||
return $this->getSumOrderProductsDispatch($entity, true, true); | |||||
} | |||||
public function getSumOrderProductsDispatch($entity, $withTax = false, $withReductionCatalog = false) | |||||
{ | |||||
if ($entity instanceof OrderShopInterface) { | |||||
return $this->getSumOrderProducts($entity->getOrderProducts(), $withTax, $withReductionCatalog); | |||||
} | |||||
if ($entity instanceof Collection || is_array($entity)) { | |||||
return $this->getSumOrderProducts($entity, $withTax, $withReductionCatalog); | |||||
} | |||||
} | |||||
public function getSumOrderProducts($orderProducts, $withTax = false, $withReductionCatalog = false) | |||||
{ | |||||
$total = 0; | |||||
foreach ($orderProducts as $orderProduct) { | |||||
if ($withTax && $withReductionCatalog) { | |||||
$total += $this->getTotalWithTaxAndReduction($orderProduct); | |||||
} elseif ($withTax) { | |||||
$total += $this->getTotalWithTax($orderProduct); | |||||
} elseif ($withReductionCatalog) { | |||||
$total += $this->getTotalWithReduction($orderProduct); | |||||
} else { | |||||
$total += $this->getTotal($orderProduct); | |||||
} | |||||
} | |||||
return $total; | |||||
} | |||||
public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null) | |||||
{ | |||||
return $this->getPriceWithReductionCatalogGeneric($entity, $price, $priceWithTax, $reductionCatalog, true); | |||||
} | |||||
public function getPriceWithReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null) | |||||
{ | |||||
return $this->getPriceWithReductionCatalogGeneric($entity, $price, $priceWithTax, $reductionCatalog, false); | |||||
} | |||||
public function getPriceWithReductionCatalogGeneric($entity, $price, $priceWithTax, $reductionCatalog = null, $withTax = true): ?float | |||||
{ | |||||
if ($reductionCatalog) { | |||||
$reductionCatalogValue = $reductionCatalog->getValue(); | |||||
$reductionCatalogUnit = $reductionCatalog->getUnit(); | |||||
$reductionCatalogBehaviorTaxRate = $reductionCatalog->getBehaviorTaxRate(); | |||||
} else { | |||||
if ($entity instanceof ProductPropertyInterface) { | |||||
$reductionCatalog = $entity->getReductionCatalogInherited(); | |||||
if ($reductionCatalog) { | |||||
$reductionCatalogValue = $reductionCatalog->getValue(); | |||||
$reductionCatalogUnit = $reductionCatalog->getUnit(); | |||||
$reductionCatalogBehaviorTaxRate = $reductionCatalog->getBehaviorTaxRate(); | |||||
} | |||||
} | |||||
if ($entity instanceof OrderProductInterface) { | |||||
$orderProductReductionCatalog = $entity->getOrderProductReductionCatalog(); | |||||
if ($orderProductReductionCatalog) { | |||||
$reductionCatalogValue = $orderProductReductionCatalog->getValue(); | |||||
$reductionCatalogUnit = $orderProductReductionCatalog->getUnit(); | |||||
$reductionCatalogBehaviorTaxRate = $orderProductReductionCatalog->getBehaviorTaxRate(); | |||||
} | |||||
} | |||||
} | |||||
if (isset($reductionCatalogValue) && isset($reductionCatalogUnit) && isset($reductionCatalogBehaviorTaxRate)) { | |||||
if ($reductionCatalogUnit == 'percent') { | |||||
$priceWithTax = $this->applyReductionPercent( | |||||
$priceWithTax, | |||||
$reductionCatalogValue | |||||
); | |||||
} elseif ($reductionCatalogUnit == 'amount') { | |||||
if ($reductionCatalogBehaviorTaxRate == 'tax-excluded') { | |||||
$priceWithTax = $this->applyTax( | |||||
$this->applyReductionAmount( | |||||
$price, | |||||
$reductionCatalogValue | |||||
), | |||||
$entity->getTaxRateInherited()->getValue() | |||||
); | |||||
} elseif ($reductionCatalogBehaviorTaxRate == 'tax-included') { | |||||
$priceWithTax = $this->applyReductionAmount( | |||||
$priceWithTax, | |||||
$reductionCatalogValue | |||||
); | |||||
} | |||||
} | |||||
} | |||||
if ($withTax) { | |||||
$priceReturn = $priceWithTax; | |||||
} else { | |||||
$priceReturn = $this->applyPercentNegative($priceWithTax, $entity->getTaxRateInherited()->getValue()); | |||||
} | |||||
return $this->round($priceReturn); | |||||
} | |||||
public function getTotalTaxes($entity) | |||||
{ | |||||
if ($entity instanceof OrderProductInterface) { | |||||
return $this->getTotalWithReduction($entity) * ($entity->getTaxRateInherited()->getValue() / 100); | |||||
} | |||||
if ($entity instanceof OrderShopInterface) { | |||||
$totalTaxes = 0; | |||||
foreach ($entity->getOrderProducts() as $orderProduct) { | |||||
$totalTaxes += $this->getTotalTaxes($orderProduct); | |||||
} | |||||
return $totalTaxes; | |||||
} | |||||
return 0; | |||||
} | |||||
public function applyTax($price, $taxRateValue) | |||||
{ | |||||
return $this->round($this->applyPercent($price, $taxRateValue)); | |||||
} | |||||
public function applyReductionPercent($price, $percentage) | |||||
{ | |||||
return $this->applyPercent($price, -$percentage); | |||||
} | |||||
public function applyReductionAmount($price, $amount) | |||||
{ | |||||
return $price - $amount; | |||||
} | |||||
public function applyPercent($price, $percentage) | |||||
{ | |||||
return $price * ($percentage / 100 + 1); | |||||
} | |||||
public function applyPercentNegative($price, $percentage) | |||||
{ | |||||
return $price / ($percentage / 100 + 1); | |||||
} | |||||
public function round($price) | |||||
{ | |||||
return round((($price * 100)) / 100, 2); | |||||
} | |||||
} | |||||
$this->em->flush() ; | $this->em->flush() ; | ||||
} | } | ||||
} | |||||
} |
use Cocur\Slugify\Slugify; | use Cocur\Slugify\Slugify; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager; | use EasyCorp\Bundle\EasyAdminBundle\Configuration\ConfigManager; | ||||
use Geocoder\Model\Coordinates; | |||||
use Geocoder\Provider\Addok\Addok; | |||||
use Geocoder\Query\GeocodeQuery; | |||||
use Geocoder\Query\ReverseQuery; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\PageInterface; | use Lc\ShopBundle\Context\PageInterface; | ||||
use Lc\ShopBundle\Context\PointSaleInterface; | use Lc\ShopBundle\Context\PointSaleInterface; | ||||
use Lc\ShopBundle\Context\UserPointSaleInterface; | use Lc\ShopBundle\Context\UserPointSaleInterface; | ||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | use Liip\ImagineBundle\Imagine\Cache\CacheManager; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\HttpClient\HttplugClient; | |||||
use Symfony\Component\HttpFoundation\ParameterBag; | use Symfony\Component\HttpFoundation\ParameterBag; | ||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | use Symfony\Contracts\Translation\TranslatorInterface; | ||||
return $result; | return $result; | ||||
} | } | ||||
public function getGeocoderProvider() | |||||
{ | |||||
$symfonyClient = new HttplugClient(); | |||||
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr') ; | |||||
return $provider ; | |||||
} | |||||
public function callAddressApi($query) | |||||
{ | |||||
$provider = $this->getGeocoderProvider() ;; | |||||
$query = GeocodeQuery::create($query)->withData('type', 'housenumber'); | |||||
$results = $provider->geocodeQuery($query); | |||||
return $results->all() ; | |||||
} | |||||
public function callReverseAddressApi($latitude, $longitude) | |||||
{ | |||||
$provider = $this->getGeocoderProvider() ;; | |||||
$query = ReverseQuery::create(new Coordinates($latitude, $longitude)); | |||||
$results = $provider->reverseQuery($query); | |||||
return $results->all() ; | |||||
} | |||||
public function getZipByCity($city, $code = null) | public function getZipByCity($city, $code = null) | ||||
{ | { | ||||
$zip = null; | $zip = null; |
protected $mailUtils ; | protected $mailUtils ; | ||||
protected $ticketUtils ; | protected $ticketUtils ; | ||||
protected $statisticsUtils; | protected $statisticsUtils; | ||||
protected $pointLocationUtils ; | |||||
public function __construct( | public function __construct( | ||||
Utils $utils, | Utils $utils, | ||||
CreditUtils $creditUtils, | CreditUtils $creditUtils, | ||||
DocumentUtils $documentUtils, | DocumentUtils $documentUtils, | ||||
MailUtils $mailUtils, | MailUtils $mailUtils, | ||||
TicketUtils $ticketUtils | |||||
TicketUtils $ticketUtils, | |||||
PointLocationUtils $pointLocationUtils | |||||
) | ) | ||||
{ | { | ||||
$this->utils = $utils ; | $this->utils = $utils ; | ||||
$this->documentUtils = $documentUtils ; | $this->documentUtils = $documentUtils ; | ||||
$this->mailUtils = $mailUtils ; | $this->mailUtils = $mailUtils ; | ||||
$this->ticketUtils = $ticketUtils ; | $this->ticketUtils = $ticketUtils ; | ||||
$this->pointLocationUtils = $pointLocationUtils ; | |||||
} | } | ||||
public function getUtils(): Utils | public function getUtils(): Utils | ||||
return $this->ticketUtils ; | return $this->ticketUtils ; | ||||
} | } | ||||
public function getPointLocationUtils(): PointLocationUtils | |||||
{ | |||||
return $this->pointLocationUtils ; | |||||
} | |||||
} | } |