Browse Source

creation d'une commande

reduction
Fab 4 years ago
parent
commit
52c23da987
14 changed files with 363 additions and 143 deletions
  1. +41
    -26
      ShopBundle/Controller/Admin/OrderController.php
  2. +0
    -3
      ShopBundle/Controller/ApiController.php
  3. +2
    -22
      ShopBundle/Form/OrderProductType.php
  4. +5
    -0
      ShopBundle/Model/PointSale.php
  5. +0
    -4
      ShopBundle/Repository/BaseRepository.php
  6. +7
    -25
      ShopBundle/Repository/PointSaleRepository.php
  7. +18
    -0
      ShopBundle/Resources/public/css/backend/custom.css
  8. +106
    -37
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  9. +1
    -0
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-mixins.js
  10. +8
    -1
      ShopBundle/Resources/views/backend/default/layout.html.twig
  11. +5
    -0
      ShopBundle/Resources/views/backend/order/form.html.twig
  12. +28
    -2
      ShopBundle/Resources/views/backend/order/panel_addresses.html.twig
  13. +123
    -12
      ShopBundle/Resources/views/backend/order/panel_delivery.html.twig
  14. +19
    -11
      ShopBundle/Resources/views/backend/order/panel_orderproducts.html.twig

+ 41
- 26
ShopBundle/Controller/Admin/OrderController.php View File

use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Context\AddressInterface; use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface; use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface; use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface; use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Form\OrderProductType; use Lc\ShopBundle\Form\OrderProductType;
use Lc\ShopBundle\Form\ProductFamilyCategoriesType; use Lc\ShopBundle\Form\ProductFamilyCategoriesType;
use Lc\ShopBundle\Form\ProductType; use Lc\ShopBundle\Form\ProductType;
use Lc\ShopBundle\Model\PointSale;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType; use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;


class OrderController extends AdminController class OrderController extends AdminController
{ {

public function updateEntity($entity) public function updateEntity($entity)
{ {
foreach($entity->getOrderProducts() as $orderProduct) {
$orderProduct->setCreatedBy($this->getUser()) ;
$orderProduct->setUpdatedBy($this->getUser()) ;
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate()) ;
$orderProduct->setOrderShop($entity) ;

foreach ($entity->getOrderProducts() as $orderProduct) {
//dump($orderProduct);
$orderProduct->setCreatedBy($this->getUser());
$orderProduct->setUpdatedBy($this->getUser());
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate());
$orderProduct->setOrderShop($entity);

$this->em->persist($orderProduct); $this->em->persist($orderProduct);


$entity->addOrderProduct($orderProduct) ;
$entity->addOrderProduct($orderProduct);
} }


$this->setUpdated($entity); $this->setUpdated($entity);


public function persistEntity($entity) public function persistEntity($entity)
{ {
foreach ($entity->getOrderProducts() as $orderProduct) {

$orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited());
$orderProduct->setTitle($orderProduct->getProduct()->getTitleInherited());
$orderProduct->setPrice($orderProduct->getProduct()->getPriceInherited());
if ($orderProduct->getProduct()->getProductFamily()->getTaxRate()) {
$orderProduct->setTaxRate($orderProduct->getProduct()->getProductFamily()->getTaxRate());
} else {
$orderProduct->setTaxRate($this->security->getUser()->getMerchant()->getTaxRate());
}

$orderProduct->setOrderShop($entity);
$orderProduct->setCreatedBy($this->getUser());
$orderProduct->setUpdatedBy($this->getUser());
$this->em->persist($orderProduct);
$entity->addOrderProduct($orderProduct);


parent::persistEntity($entity) ;
}


parent::persistEntity($entity);
} }


public function createEntityFormBuilder($entity, $view) public function createEntityFormBuilder($entity, $view)




$addressClass = $this->em->getClassMetadata(AddressInterface::class); $addressClass = $this->em->getClassMetadata(AddressInterface::class);
$formBuilder->add('invoiceAddress', EntityType::class, array(
'class' => $addressClass->name,
'query_builder' => function (EntityRepository $er) use ($entity) {
return $er->createQueryBuilder('a')
->where('a.user = :user')
->setParameter('user', $entity->getUser());
},
));


$formBuilder->add('deliveryAddress', EntityType::class, array(
$formBuilder->add('invoiceAddress', EntityType::class, array(
'class' => $addressClass->name, 'class' => $addressClass->name,
'placeholder' => '',
'query_builder' => function (EntityRepository $er) use ($entity) { 'query_builder' => function (EntityRepository $er) use ($entity) {
return $er->createQueryBuilder('a') return $er->createQueryBuilder('a')
->where('a.user = :user') ->where('a.user = :user')
}, },
)); ));



return $formBuilder; return $formBuilder;
} }




protected function newAction() protected function newAction()
{ {

$this->dispatch(EasyAdminEvents::PRE_NEW); $this->dispatch(EasyAdminEvents::PRE_NEW);


$entity = $this->executeDynamicMethod('createNew<EntityName>Entity'); $entity = $this->executeDynamicMethod('createNew<EntityName>Entity');
//ETAPE 1 Choix de l'utilisateur //ETAPE 1 Choix de l'utilisateur
$user = $newForm->get('user')->getData(); $user = $newForm->get('user')->getData();


if($user == null){
if ($user == null) {
$user = $this->getUserViaFirstStepForm($entity); $user = $this->getUserViaFirstStepForm($entity);
} }


if (!$user instanceof UserInterface) return $user; if (!$user instanceof UserInterface) return $user;
else{
else {
$entity->setUser($user); $entity->setUser($user);


/* $newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]);
$newForm->handleRequest($this->request);*/
//réinitialise le formulaire pour charger les adresses en fonction de l'utilisateur sélectionné
$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]);
$newForm->handleRequest($this->request);


//dump( $entity); //dump( $entity);
//dump( $entity); //dump( $entity);


if ($newForm->isSubmitted() && $newForm->isValid()) { if ($newForm->isSubmitted() && $newForm->isValid()) {
dump($entity);
die();
/*dump($entity);
die();*/
//$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); //$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]);
$this->executeDynamicMethod('persist<EntityName>Entity', [$entity, $newForm]); $this->executeDynamicMethod('persist<EntityName>Entity', [$entity, $newForm]);
$this->dispatch(EasyAdminEvents::POST_PERSIST, ['entity' => $entity]); $this->dispatch(EasyAdminEvents::POST_PERSIST, ['entity' => $entity]);

+ 0
- 3
ShopBundle/Controller/ApiController.php View File

public function __construct(EntityManagerInterface $entityManager) public function __construct(EntityManagerInterface $entityManager)
{ {
$this->em = $entityManager; $this->em = $entityManager;

} }


public function getEntity($entity, $id) public function getEntity($entity, $id)
{ {


if($entity == 'product'){ if($entity == 'product'){
$repo = $this->em->getRepository(ProductInterface::class); $repo = $this->em->getRepository(ProductInterface::class);
$data = $repo->find($id); $data = $repo->find($id);

+ 2
- 22
ShopBundle/Form/OrderProductType.php View File



$builder->add('product', EntityType::class, array( $builder->add('product', EntityType::class, array(
'class' => $productClass->name, 'class' => $productClass->name,
/* 'attr'=>array(
'data-widget'=> 'select2'
),*/
'placeholder'=> '',

'choice_label'=> function($product){ 'choice_label'=> function($product){
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle(); return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle();
} }
)); ));
$builder->add('quantity', NumberType::class, array( $builder->add('quantity', NumberType::class, array(
'label' => 'Quantité', 'label' => 'Quantité',
'required' => false,
'attr' => [ 'attr' => [
'append_html' => 'g' 'append_html' => 'g'
] ]
)); ));


$builder->add('unit', HiddenType::class,array(
'data'=>'L',
));
$builder->add('title', HiddenType::class,array(
'data'=>'Mon litre de pont',
));

$builder->add('price', NumberType::class,array(
'attr'=> array(
'readonly'=> 'readonly'
)
));


//$builder->add('buyingPrice', NumberType::class);



} }


public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)

+ 5
- 0
ShopBundle/Model/PointSale.php View File

*/ */
protected $address; protected $address;



public function labelAdminChoice(){
return $this->getTitle();
}

public function __construct() public function __construct()
{ {
$this->merchant = new ArrayCollection(); $this->merchant = new ArrayCollection();

+ 0
- 4
ShopBundle/Repository/BaseRepository.php View File

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Component\Form\Exception\LogicException;


class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface class BaseRepository extends EntityRepository implements ServiceEntityRepositoryInterface
{ {
} }


public function filterByMerchant($merchant){ public function filterByMerchant($merchant){
dump($merchant);
return $this->createQueryBuilder('e') return $this->createQueryBuilder('e')
->where('e.merchant = :currentMerchant') ->where('e.merchant = :currentMerchant')
->setParameter('currentMerchant', $merchant->getId()) ->setParameter('currentMerchant', $merchant->getId())

+ 7
- 25
ShopBundle/Repository/PointSaleRepository.php View File

use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface; use Lc\ShopBundle\Context\ProductCategoryInterface;


/** /**
* @method ProductCategoryInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductCategoryInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductCategoryInterface[] findAll()
* @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method PointSaleInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method PointSaleInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method PointSaleInterface[] findAll()
* @method PointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class ProductCategoryRepository extends BaseRepository
class PointSaleRepository extends BaseRepository
{ {
public function __construct(EntityManager $entityManager) public function __construct(EntityManager $entityManager)
{ {


parent::__construct($entityManager, ProductCategoryInterface::class);
parent::__construct($entityManager, PointSaleInterface::class);
} }




public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder
{

return $e->createQueryBuilder('e')
->where('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.position', 'ASC');
}

public function findAllParents()
{
return $this->createQueryBuilder('e')
->where('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.position', 'ASC')
->getQuery()
->getResult();
}



// /** // /**
// * @return ProductCategory[] Returns an array of ProductCategory objects // * @return ProductCategory[] Returns an array of ProductCategory objects

+ 18
- 0
ShopBundle/Resources/public/css/backend/custom.css View File

/* STRUCTURE */
.wrapper{margin: 0; grid-column-gap:0px; grid-row-gap:0;}
.main-header {box-shadow: 0 1px 1px rgba(0,0,0,0.05); background: #fff; border-bottom: solid 1px #e0e0e0;}
.main-header .navbar{width: var(--sidebar-width); text-align:center; border-right: solid 1px #e0e0e0;}

body.easyadmin-sidebar-width-compact .main-sidebar{width: 50px;}
body.easyadmin-sidebar-width-compact .main-header .navbar{width: 50px;}

#sidebar-resizer-handler{width: 50px;}
.resizer-handler{cursor: pointer; display: block; opacity: 1; }

.main-header #header-logo {display: inline-block; margin: auto; padding: 3px 0; }

.main-sidebar{border-right:solid 1px #e0e0e0; /*background: #222d32;*/ }
/*.sidebar-menu .fa{color: #fff;}
.sidebar-menu a{color: #fff;}*/
/* Général */ /* Général */


.input-group-text { .input-group-text {


/* ORDER */ /* ORDER */


.table-order-summary{width: 100%;}

/*.select2-container--bootstrap .select2-selection{max-width: none;}*/ /*.select2-container--bootstrap .select2-selection{max-width: none;}*/
/*.order-product-item{margin: 15px 0; padding: 0;}*/ /*.order-product-item{margin: 15px 0; padding: 0;}*/



+ 106
- 37
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js View File

// Reference array sent to dynamic staticRenderFns // Reference array sent to dynamic staticRenderFns
var staticRenderFns = []; var staticRenderFns = [];


/*
Vue.directive('selecttwo', {
twoWay: true,
bind: function (el, binding, vnode) {
log(el)
log(binding)
log(this)

$(el).select2({
theme: 'bootstrap',
language: '{{ _select2_locale }}'
});
$(el).select2().on("select2:select", function(e) {
this.set($(el).val());
}.bind(binding));
},
update: function(el, ov) {
log(el)
;
$(el).trigger("change");
}
});
*/

Vue.component('order-product-form', { Vue.component('order-product-form', {
mixins: [mixinTemplate], mixins: [mixinTemplate],
props: ['template', 'keyForm'], props: ['template', 'keyForm'],
quantity: 1, quantity: 1,
unit: null, unit: null,
product: null product: null
}/*, window.productForm[this.keyForm]*/)
}, window.orderProductForm[this.keyForm])
}, },
mounted: function () { mounted: function () {
this.setSelect2(); this.setSelect2();
this.updateQuantity();


}, },
methods: { methods: {
this.updateQuantity(); this.updateQuantity();
this.$parent.updateTotalPrice(); this.$parent.updateTotalPrice();
}, },
updateQuantity:function(){
this.totalWithTax = this.priceWithTax * this.quantity;
this.totalWithoutTax = this.price * this.quantity;
updateQuantity: function () {
this.totalWithTax = parseFloat(this.priceWithTax * this.quantity).toFixed(3);
this.totalWithoutTax = parseFloat(this.price * this.quantity).toFixed(3);
this.$parent.updateTotalPrice(); this.$parent.updateTotalPrice();
}, },
setSelect2: function(){
setSelect2: function () {
var select = $(this.$el).find('select.form-control');

var monSelect = $(this.$el).find('select.form-control').select2({ var monSelect = $(this.$el).find('select.form-control').select2({
theme: 'bootstrap', theme: 'bootstrap',
language: 'fr'
debug: true,
placeholder: "Select an option"
}); });

var vue = this; var vue = this;
monSelect.on('select2:select', function () {
monSelect.on('select2:select', function (e) {
//dispatch event pour que le select soit "submitable"
var event = new Event('change');
e.target.dispatchEvent(event);

this.product = monSelect.val(); this.product = monSelect.val();

$.ajax({ $.ajax({
url: "http://localhost:8000/api/product/" + this.product,
url: DOMAIN + "/api/product/" + this.product,
method: "GET", method: "GET",
dataType: "", dataType: "",
success: function (response) { success: function (response) {
} }
}); });
}) })
},
deleteProductForm: function () {
if (confirm('Êtes-vous sur de cette action ?')) {
this.$parent.formOrderProductArray.splice(this.keyForm, 1);
}
} }
}, },
watch: {} watch: {}
}); });




Vue.component('delivery-availability-choice', {
mixins: [mixinTemplate],
props: ['template', 'key', 'name', 'id'],
data() {
return {
id: -1,
deliveryAvailability: null, // Have to assign to this variable**
deliveryAvailabilities: null, // Have to assign to this variable**
selected_category: "",
value: null,
label: null
};
},
mounted() {
},
methods: {
updateDeliveryAvailability() {
log(this.deliveryAvailability);
/*log('bnfbf');
var self = this;
$.ajax({
url: DOMAIN+"/admin/delivery-availaibility/14",
method: "POST",
dataType: "",
success: function (response) {
self.categories = response.categories;
}
});*/

}
}
});

appOrder = new Vue({ appOrder = new Vue({
el: '#lc-order-edit', el: '#lc-order-edit',
delimiters: ['${', '}'], delimiters: ['${', '}'],
currentSection: 'cart', currentSection: 'cart',
formOrderProductArray: [], formOrderProductArray: [],
indexOrderProductForm: 0, indexOrderProductForm: 0,
formDeliveryAvailabilityLargeArray: [],
formDeliveryAvailabilityShortArray: [],
indexDeliveryAvailability: null,
invoiceAddress: null, invoiceAddress: null,
deliveryAddress: null, deliveryAddress: null,
totalWithTax:null,
totalWithoutTax:null,
deliveryType: null,
deliveryPointSale: null,
deliveryAvailability: 'niche',
totalWithTax: null,
totalWithoutTax: null,
sectionsArray: [ sectionsArray: [
{ {
name: 'cart', name: 'cart',
}, },
{ {
name: 'addresses', name: 'addresses',
nameDisplay: 'Livraisons & facturations'
nameDisplay: 'Adresses'
},
{
name: 'delivery',
nameDisplay: 'Livraisons'
} }
] ]
})/*, window.appOrderProductFamilyValues)*/; })/*, window.appOrderProductFamilyValues)*/;
this.totalWithTax = 0; this.totalWithTax = 0;
for (var i = 0; i < this.$refs.orderProductForm.length; i++) { for (var i = 0; i < this.$refs.orderProductForm.length; i++) {
var line = this.$refs.orderProductForm[i]; var line = this.$refs.orderProductForm[i];
this.totalWithoutTax = this.totalWithoutTax + line.totalWithoutTax;
this.totalWithTax = this.totalWithTax + line.totalWithTax;
this.totalWithoutTax = parseFloat(parseFloat(this.totalWithoutTax) + parseFloat(line.totalWithoutTax)).toFixed(2);
this.totalWithTax = parseFloat(parseFloat(this.totalWithTax) + parseFloat(line.totalWithTax)).toFixed(2);
} }
}, },
changeSection: function (section) { changeSection: function (section) {
this.updateChild(); this.updateChild();
this.currentSection = section.name; this.currentSection = section.name;

this.addDeliveryAvailabilityChoice();
},
addDeliveryAvailabilityChoice: function () {
$.ajax({
url: DOMAIN + "/admin/delivery-availaibility/" + this.deliveryAddress,
method: "POST",
dataType: "",
success: function (response) {
for (i = 0; i < response.large.length; i++) {
slot = response.large[i];
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype');
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label );

appOrder.formDeliveryAvailabilityLargeArray.push(deliveryAvailabilityForm);
appOrder.indexDeliveryAvailability++;
}

for (i = 0; i < response.short.length; i++) {
slot = response.short[i];
var deliveryAvailabilityForm = $('#delivery-availability-short').data('prototype');
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__id__/g, "{{ form.deliveryAvailabilityZone.vars.id }}_"+slot.id );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__name__/g, "{{ form.deliveryAvailabilityZone.vars.full_name }}" );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__value__/g, slot.id );
deliveryAvailabilityForm = deliveryAvailabilityForm.replace(/__label__/g, slot.label );

appOrder.formDeliveryAvailabilityShortArray.push(deliveryAvailabilityForm);
appOrder.indexDeliveryAvailability++;
}
}
});

}, },
addOrderProductForm: function () { addOrderProductForm: function () {
var $collectionHolder = $('#order-products-list'); var $collectionHolder = $('#order-products-list');

+ 1
- 0
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-mixins.js View File

template: { template: {
immediate: true, // makes the watcher fire on first render, too. immediate: true, // makes the watcher fire on first render, too.
handler() { handler() {
log(this.template);
if (this.template) { if (this.template) {
var res = Vue.compile(this.template); var res = Vue.compile(this.template);



+ 8
- 1
ShopBundle/Resources/views/backend/default/layout.html.twig View File

{% endblock header_logo %} {% endblock header_logo %}
</div> </div>
</nav> </nav>
<div id="sidebar-resizer-handler" class="resizer-handler resizer-handler-left">
<i class="fa fa-arrows-alt-h"></i>
</div>


<div id="switch-merchant"> <div id="switch-merchant">
{% if is_granted('ROLE_ADMIN') %} {% if is_granted('ROLE_ADMIN') %}
{{ include(_entity_config is defined ? _entity_config.templates.flash_messages : '@EasyAdmin/default/flash_messages.html.twig') }} {{ include(_entity_config is defined ? _entity_config.templates.flash_messages : '@EasyAdmin/default/flash_messages.html.twig') }}
{% endblock flash_messages %} {% endblock flash_messages %}


<div id="sidebar-resizer-handler" class="resizer-handler resizer-handler-left"></div>


{% block content %} {% block content %}
<div class="content"> <div class="content">
</div> </div>
{% endblock wrapper_wrapper %} {% endblock wrapper_wrapper %}


{#Initilisation des varibles requis dans le JS #}

<script>
const DOMAIN = "{{ app.request.getSchemeAndHttpHost() }}";
</script>
{% block body_javascript %}{% endblock body_javascript %} {% block body_javascript %}{% endblock body_javascript %}


{% block body_custom_javascript %} {% block body_custom_javascript %}

+ 5
- 0
ShopBundle/Resources/views/backend/order/form.html.twig View File



<div id="nav-params"> <div id="nav-params">
<button type="button" v-for="section in sectionsArray" <button type="button" v-for="section in sectionsArray"
v-if="(section.name == 'delivery' && deliveryType == 'at-home' && deliveryAddress>0) || (section.name != 'delivery')"
:class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')" :class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')"
@click="changeSection(section)"> @click="changeSection(section)">
${ section.nameDisplay } ${ section.nameDisplay }
{% include '@LcShop/backend/order/panel_addresses.html.twig' %} {% include '@LcShop/backend/order/panel_addresses.html.twig' %}
</div> </div>


<div v-show="currentSection == 'delivery'" class="panel panel-default">
{% include '@LcShop/backend/order/panel_delivery.html.twig' %}
</div>

</div> </div>
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}

+ 28
- 2
ShopBundle/Resources/views/backend/order/panel_addresses.html.twig View File

{{ form_row(form.deliveryAddress) }}
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }}
<div class="row">
<div class="field-group col-12">
<fieldset>
<legend>Livraisons & facturation</legend>
<div class="row" >

<div class="col">
{{ form_label(form.deliveryType) }}
{% for field in form.deliveryType %}

{{ form_widget(field, {"attr" : {"v-model" : 'deliveryType'}}) }}
{% endfor %}

</div>
<div class="col" v-if="deliveryType == 'at-home'">
{{ form_row(form.deliveryAddress, {"attr": {'v-model' : 'deliveryAddress'}}) }}
</div>
<div class="col" v-else-if="deliveryType == 'point-sale'">
{{ form_row(form.deliveryPointSale, {"attr": {'v-model' : 'deliveryPointSale'}}) }}
</div>

<div class="col">
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }}
</div>
</div>
</fieldset>
</div>
</div>

+ 123
- 12
ShopBundle/Resources/views/backend/order/panel_delivery.html.twig View File

{#
<div class="row"> <div class="row">
<div class="field-group col-12"> <div class="field-group col-12">
<fieldset> <fieldset>
<legend>Livraisons & facturation</legend>
<legend>Livraisons</legend>
<div class="row"> <div class="row">
<delivery-choice ref="delivery-choice"></delivery-choice>
#}
{#<div class="col">
{{ form_label(form.deliveryAvailabilityZoneShort) }}
<div class="delivery-availability-short">
{% for field in form.deliveryAvailabilityZoneShort %}
{{ form_widget(field, {"attr" : {"v-model" : 'deliveryAvailability'}}) }}
{% endfor %}
</div>
</div>
<div class="col"> <div class="col">
{{ form_label(form.deliveryType) }}
{% for field in form.deliveryType %}
{{ form_label(form.deliveryAvailabilityZoneLarge) }}
<div class="delivery-availability-large">
{% for field in form.deliveryAvailabilityZoneLarge %}
{{ form_widget(field, {"attr" : {"v-model" : 'deliveryAvailability'}}) }}
{% endfor %}
</div>
${deliveryAvailability}
</div>#}{#


{{ form_widget(field, {"attr" : {"v-model" : 'deliveryType'}}) }}
{% endfor %}
</div>
</fieldset>
</div>
</div>
#}



{#
{% macro printDeliveryAvailabitlityRow(slot) %}
<div class="form-check">
<input type="radio" v-model="deliveryAvailability" id="{% verbatim %}{{ id }}{% endverbatim %}_20" name="{% verbatim %}{{ name }}{% endverbatim %}" class="form-check-input" value="{% verbatim %}{{ value }}{% endverbatim %}">
<label class="form-check-label" for="{% verbatim %}{{ id }}{% endverbatim %}_20"></label>
</div>
{% endmacro %}
{% import _self as formMacros %}

<div class="row">
<div class="field-group col-12">
<fieldset>
<legend>Livraisons</legend>
<div class="row">
<div class="col">
{{ form_label(form.deliveryAvailabilityZone) }}

<div id="delivery-availabilities-choice">

<template v-for="(deliveryAvailability, key) in formDeliveryAvailabilityArray">
<delivery-availability-choice ref="delivery-choice" :template="deliveryAvailability" :key="key" :name="{{ form.deliveryAvailabilityZone.vars.full_name }}" :id="{{ form.deliveryAvailabilityZone.vars.id }}" >

</delivery-availability-choice>
</template>
</div>
</div> </div>
<div class="col" v-if="deliveryType == 'at-home'">
{{ form_row(form.deliveryAddress, {"attr": {'v-model' : 'deliveryAddress'}}) }}
</div>
<div class="col" v-else-if="deliveryType == 'point-sale'">
{{ form_row(form.deliveryPointSale, {"attr": {'v-model' : 'deliveryPointSale'}}) }}
</div>
#}{# <div class="col">
{{ form_label(form.deliveryAvailabilityZoneLarge) }}
<div class="delivery-availability-large">
{% for field in form.deliveryAvailabilityZoneLarge %}
{{ form_widget(field, {"attr" : {"v-model" : 'deliveryAvailability'}}) }}
{% endfor %}
</div>
${deliveryAvailability}
</div>#}{#
</div>
</fieldset>
</div>

<div class="clearfix"></div>

#}{#{% for keyForm, deliveryAvailabilityField in form.deliveryAvailabilityZoneShort %}

<script>
jQuery(window).on('load', function () {
var deliveryAvailabilityForm = '{{ formMacros.printDeliveryAvailabitlityRow(deliveryAvailabilityField)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';

appOrder.formDeliveryAvailabilityArray.push(deliveryAvailabilityForm);
appOrder.indexDeliveryAvailability++;
});
</script>


{% endfor %}#}{#

</div>#}


{% macro printDeliveryAvailabitlityChoice() %}
<div class="form-check">
<input type="radio" v-model="deliveryAvailability" id="__id__" name="__name__" class="form-check-input" value="__value__" @change="updateDeliveryAvailability">
<label class="form-check-label" for="__id__">__label__</label>

</div>
{% endmacro %}
{% import _self as formMacros %}

<div class="row">
<div class="field-group col-12">
<fieldset>
<legend>Livraisons</legend>
<div class="row">
<div class="col"> <div class="col">
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }}
{{ form_label(form.deliveryAvailabilityZone) }}

<div id="delivery-availability-short" data-prototype='{{ formMacros.printDeliveryAvailabitlityChoice()|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'>

<template v-for="(deliveryAvailability, key) in formDeliveryAvailabilityLargeArray">
<delivery-availability-choice ref="delivery-choice" :template="deliveryAvailability" :key="key" >

</delivery-availability-choice>
</template>
BLOP
<template v-for="(deliveryAvailability, key) in formDeliveryAvailabilityShortArray">
<delivery-availability-choice ref="delivery-choice" :template="deliveryAvailability" :key="key" >

</delivery-availability-choice>
</template>
</div>
</div> </div>
{# <div class="col">
{{ form_label(form.deliveryAvailabilityZoneLarge) }}
<div class="delivery-availability-large">
{% for field in form.deliveryAvailabilityZoneLarge %}
{{ form_widget(field, {"attr" : {"v-model" : 'deliveryAvailability'}}) }}
{% endfor %}
</div>
${deliveryAvailability}
</div>#}
</div> </div>
</fieldset> </fieldset>
</div> </div>

<div class="clearfix"></div>
</div> </div>
{##}

+ 19
- 11
ShopBundle/Resources/views/backend/order/panel_orderproducts.html.twig View File

</td> </td>
<td> <td>
<div class="form-widget"> <div class="form-widget">
{% verbatim %}{{ price }}{% endverbatim %}
{% verbatim %}{{ price }}{% endverbatim %}
</div> </div>
</td> </td>
<td> <td>
<div class="form-widget"> <div class="form-widget">
{% verbatim %}{{ priceWithTax }}{% endverbatim %}
{% verbatim %}{{ priceWithTax }}{% endverbatim %}
</div> </div>
</td> </td>
<td> <td>
</div> </div>
</td> </td>
<td> <td>
{% verbatim %}{{ totalWithTax }}{% endverbatim %}
{% verbatim %}{{ totalWithTax }}{% endverbatim %}
</td> </td>
<td> <td>
<button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()"> <button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()">


<order-product-form ref="orderProductForm" :template="formProduct" :key-form="key"></order-product-form> <order-product-form ref="orderProductForm" :template="formProduct" :key-form="key"></order-product-form>
</template> </template>
<tr>
<td colspan="7">

<button type="button" class="add_tag_link btn-add-product btn btn-default" @click="addOrderProductForm"><span
class="fa fa-plus"></span> Ajouter un produit
</button>
</td>
</tr>
<tr> <tr>
<td colspan="4"></td> <td colspan="4"></td>
<td colspan="2">
<table>
<td colspan="3">
<table class="sub-table table-order-summary">
<tr> <tr>
<th>Total without Tax</th> <th>Total without Tax</th>
<td>${totalWithoutTax}</td>
<td>${totalWithoutTax}€</td>
<td ></td>
</tr> </tr>
<tr> <tr>
<th>Total</th> <th>Total</th>
<td>${totalWithTax}</td>
<td>${totalWithTax}€</td>
<td ></td>
</tr> </tr>
</table> </table>
</td> </td>
<td ></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>


<button type="button" class="add_tag_link btn-add-product btn btn-default" @click="addOrderProductForm"><span
class="fa fa-plus"></span> Ajouter un produit
</button>

<div class="clearfix"></div> <div class="clearfix"></div>
<script> <script>
window.orderProductForm = new Array(); window.orderProductForm = new Array();

Loading…
Cancel
Save