Ver código fonte

creation de panier [en cours]

reduction
Fab 4 anos atrás
pai
commit
56845cc1e0
22 arquivos alterados com 779 adições e 62 exclusões
  1. +186
    -0
      ShopBundle/Controller/Admin/OrderController.php
  2. +1
    -9
      ShopBundle/Controller/Admin/ProductFamilyController.php
  3. +46
    -0
      ShopBundle/Controller/ApiController.php
  4. +85
    -0
      ShopBundle/Form/OrderProductType.php
  5. +1
    -17
      ShopBundle/Form/ProductType.php
  6. +0
    -30
      ShopBundle/Form/TaxRateType.php
  7. +11
    -1
      ShopBundle/Model/OrderProduct.php
  8. +21
    -2
      ShopBundle/Model/OrderShop.php
  9. +41
    -0
      ShopBundle/Model/Product.php
  10. +1
    -0
      ShopBundle/Model/ProductFamily.php
  11. +3
    -2
      ShopBundle/Resources/config/easy_admin/base.yaml
  12. +5
    -1
      ShopBundle/Resources/config/shop_routes.yaml
  13. +5
    -0
      ShopBundle/Resources/public/css/backend/custom.css
  14. +157
    -0
      ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js
  15. +1
    -0
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-mixins.js
  16. +0
    -0
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  17. +5
    -0
      ShopBundle/Resources/views/backend/order/edit.html.twig
  18. +36
    -0
      ShopBundle/Resources/views/backend/order/form.html.twig
  19. +10
    -0
      ShopBundle/Resources/views/backend/order/new.html.twig
  20. +2
    -0
      ShopBundle/Resources/views/backend/order/panel_addresses.html.twig
  21. +47
    -0
      ShopBundle/Resources/views/backend/order/panel_cart.html.twig
  22. +115
    -0
      ShopBundle/Resources/views/backend/order/panel_orderproducts.html.twig

+ 186
- 0
ShopBundle/Controller/Admin/OrderController.php Ver arquivo

@@ -0,0 +1,186 @@
<?php

namespace Lc\ShopBundle\Controller\Admin;

use App\Entity\OrderProduct;
use App\Entity\Product;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Form\OrderProductType;
use Lc\ShopBundle\Form\ProductFamilyCategoriesType;
use Lc\ShopBundle\Form\ProductType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Response;

class OrderController extends AdminController
{

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) ;
$this->em->persist($orderProduct);

$entity->addOrderProduct($orderProduct) ;
}

$this->setUpdated($entity);

parent::updateEntity($entity);
}

public function persistEntity($entity)
{

parent::persistEntity($entity) ;
}

public function createEntityFormBuilder($entity, $view)
{
$formBuilder = parent::createEntityFormBuilder($entity, $view);

$formBuilder->add('orderProducts', CollectionType::class, array(
'label' => 'Déclinaisons',
'entry_type' => OrderProductType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
'required' => true
)
);

$userClass = $this->em->getClassMetadata(UserInterface::class);
$formBuilder->add('user', EntityType::class, array(
'class' => $userClass->name
));


$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(
'class' => $addressClass->name,
'query_builder' => function (EntityRepository $er) use ($entity) {
return $er->createQueryBuilder('a')
->where('a.user = :user')
->setParameter('user', $entity->getUser());
},
));


return $formBuilder;
}


public function getUserViaFirstStepForm($entity)
{
$userClass = $this->em->getClassMetadata(UserInterface::class);

$userChoiceForm = $this->createFormBuilder($entity)
->add('user', EntityType::class, array(
'class' => $userClass->name
))
->add('nextStep', SubmitType::class)
->getForm();
$userChoiceForm->handleRequest($this->request);
if ($userChoiceForm->isSubmitted() && $userChoiceForm->isValid()) {
return $userChoiceForm->get('user')->getData();
}

$parameters = [
'form' => $userChoiceForm->createView(),
'formView' => 'default',
'entity' => $entity,
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
}

protected function newAction()
{

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

$entity = $this->executeDynamicMethod('createNew<EntityName>Entity');

$easyadmin = $this->request->attributes->get('easyadmin');
$easyadmin['item'] = $entity;
$this->request->attributes->set('easyadmin', $easyadmin);

$fields = $this->entity['new']['fields'];

$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]);

$newForm->handleRequest($this->request);

//ETAPE 1 Choix de l'utilisateur
$user = $newForm->get('user')->getData();

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

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

/* $newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]);

$newForm->handleRequest($this->request);*/

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

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

return $this->redirectToReferrer();
}

$this->dispatch(EasyAdminEvents::POST_NEW, [
'entity_fields' => $fields,
'form' => $newForm,
'entity' => $entity
]);

$parameters = [
'form' => $newForm->createView(),
'entity_fields' => $fields,
'entity' => $entity
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
}
}


}

+ 1
- 9
ShopBundle/Controller/Admin/ProductFamilyController.php Ver arquivo

@@ -339,15 +339,7 @@ class ProductFamilyController extends AdminController
$productCategoryRepository = $this->getDoctrine()->getRepository(ProductCategoryInterface::class);
$categories = $productCategoryRepository->findAllParents();

$parameters = [
'form' => $newForm->createView(),
'entity_fields' => $fields,
'entity' => $entity,
'categories' => $categories,
'sortableProductsField' => array()
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
Method('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
}

}

+ 46
- 0
ShopBundle/Controller/ApiController.php Ver arquivo

@@ -0,0 +1,46 @@
<?php

namespace Lc\ShopBundle\Controller;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Security;

class ApiController extends AbstractController
{
protected $security;
protected $userManager;
protected $em ;
protected $utils ;

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

}

public function getEntity($entity, $id)
{


if($entity == 'product'){
$repo = $this->em->getRepository(ProductInterface::class);
$data = $repo->find($id);
$data= array(
'id' => $data->getId(),
'title' => $data->getTitleInherited(),
'price' => $data->getPriceInherited(),
'unit' => $data->getUnitInherited(),
'availableQuantity' => $data->getAvailableQuantityInherited(),
'taxRate' => $data->getTaxRateInherited(),
);
}

return new JsonResponse($data);
}

}


+ 85
- 0
ShopBundle/Form/OrderProductType.php Ver arquivo

@@ -0,0 +1,85 @@
<?php

namespace Lc\ShopBundle\Form;

use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use function PHPSTORM_META\type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrderProductType extends AbstractType
{
protected $em;
protected $utils;

public function __construct(EntityManagerInterface $entityManager, Utils $utils)
{
$this->em = $entityManager;
$this->utils = $utils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{


$productClass = $this->em->getClassMetadata(ProductInterface::class);

$builder->add('product', EntityType::class, array(
'class' => $productClass->name,
/* 'attr'=>array(
'data-widget'=> 'select2'
),*/
'choice_label'=> function($product){
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle();
}
));
$builder->add('quantity', NumberType::class, array(
'label' => 'Quantité',
'required' => false,
'attr' => [
'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)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderProductInterface::class)->getName(),
]);
}
}

+ 1
- 17
ShopBundle/Form/ProductType.php Ver arquivo

@@ -33,25 +33,12 @@ class ProductType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{

/* $builder->add('titleInherited', CheckboxType::class, array(
'mapped'=>false,
'required'=>false
));*/

$builder->add('title', TextType::class, array(
"required" => false
)) ;

/*$builder->add('unitInherited', CheckboxType::class, array(
'mapped'=>false,
'required'=>false
));*/


/* $builder->add('quantityInherited', CheckboxType::class, array(
'mapped'=>false,
'required'=>false
));*/
$builder->add('quantity', NumberType::class, array(
'label' => 'Quantité',
'required'=>false,
@@ -66,10 +53,7 @@ class ProductType extends AbstractType
'choices' => $this->utils->getUnitsListFormatedForType()
));

/* $builder->add('priceInherited', CheckboxType::class, array(
'mapped'=>false,
'required'=>false
));*/

$builder->add('price', NumberType::class, array(
'label' => 'Prix',
"required" => false

+ 0
- 30
ShopBundle/Form/TaxRateType.php Ver arquivo

@@ -1,30 +0,0 @@
<?php

namespace Lc\ShopBundle\Form;

use Lc\ShopBundle\Context\TaxRateInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TaxRateType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('value')
->add('createdAt')
->add('updatedAt')
->add('createdBy')
->add('updatedBy')
;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => TaxRateInterface::class,
]);
}
}

+ 11
- 1
ShopBundle/Model/OrderProduct.php Ver arquivo

@@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
abstract class OrderProduct extends AbstractEntity
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderProducts")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;
@@ -46,6 +46,16 @@ abstract class OrderProduct extends AbstractEntity
*/
protected $title;

public function __toString()
{
if($this->getTitle()) {
return $this->getTitle();
}else{
return $this->getProduct()->getProductFamily()->getTitle(). ' - '.$this->getProduct()->getTitle();
}

}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;

+ 21
- 2
ShopBundle/Model/OrderShop.php Ver arquivo

@@ -11,6 +11,13 @@ use Doctrine\ORM\Mapping as ORM;
*/
abstract class OrderShop extends AbstractEntity
{

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="orders")
* @ORM\JoinColumn(nullable=false)
@@ -29,12 +36,12 @@ abstract class OrderShop extends AbstractEntity
protected $comment;

/**
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", nullable=true)
*/
protected $autoPayment;

/**
* @ORM\Column(type="string", length=31)
* @ORM\Column(type="string", length=31, nullable=true)
*/
protected $meanPayment;

@@ -80,6 +87,18 @@ abstract class OrderShop extends AbstractEntity
$this->creditHistories = new ArrayCollection();
}

public function getMerchant(): ?Merchant
{
return $this->merchant;
}

public function setMerchant(?Merchant $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getUser(): ?User
{
return $this->user;

+ 41
- 0
ShopBundle/Model/Product.php Ver arquivo

@@ -27,6 +27,47 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
protected $title;


public function getPriceInherited(){
if($this->price){
return $this->price;
}else{
return $this->productFamily->getPrice();
}
}

public function getUnitInherited(){
if($this->unit){
return $this->unit;
}else{
return $this->productFamily->getUnit();
}
}

public function getTitleInherited(){
if($this->title){
return $this->title;
}else{
return $this->productFamily->getTitle();
}
}

public function getAvailableQuantityInherited(){
if($this->productFamily->getBehaviorCountStock()){
return $this->availableQuantity;
}else{
return $this->productFamily->getAvailableQuantity();
}
}

public function getTaxRateInherited(){
if($this->productFamily->getTaxRate()){
return $this->productFamily->getTaxRate()->getValue();
}else{
return $this->productFamily->getMerchant()->getTaxRate()->getValue();
}
}



public function getProductFamily(): ?ProductFamily
{

+ 1
- 0
ShopBundle/Model/ProductFamily.php Ver arquivo

@@ -269,6 +269,7 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this->behaviorCountStock;
}


public function setBehaviorCountStock(string $behaviorCountStock): self
{
$this->behaviorCountStock = $behaviorCountStock;

+ 3
- 2
ShopBundle/Resources/config/easy_admin/base.yaml Ver arquivo

@@ -14,8 +14,9 @@ easy_admin:
- '/bundles/lcshop/js/backend/script/setup-ckfinder.js'
- '/bundles/lcshop/js/backend/script/utils.js'
- '/bundles/lcshop/js/backend/script/custom.js'
- '/bundles/lcshop/js/backend/script/vuejs-mixins.js'
- '/bundles/lcshop/js/backend/script/vuejs-product-family.js'
- '/bundles/lcshop/js/backend/script/productfamily/vuejs-mixins.js'
- '/bundles/lcshop/js/backend/script/productfamily/vuejs-product-family.js'
- '/bundles/lcshop/js/backend/script/order/vuejs-order.js'
css:
- '/bundles/lcshop/css/backend/jquery-ui.min.css'
- '/bundles/lcshop/css/backend/custom.css'

+ 5
- 1
ShopBundle/Resources/config/shop_routes.yaml Ver arquivo

@@ -1,4 +1,8 @@

switch_merchant:
path: /switch-merchant
controller: Lc\ShopBundle\Controller\Admin\MerchantController::switchMerchantAction
controller: Lc\ShopBundle\Controller\Admin\MerchantController::switchMerchantAction

lc_api:
path: /api/{entity}/{id}
controller: Lc\ShopBundle\Controller\ApiController::getEntity

+ 5
- 0
ShopBundle/Resources/public/css/backend/custom.css Ver arquivo

@@ -77,6 +77,11 @@
text-align: right ;
}

/* ORDER */

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

/* Product */
.product-form-modal{display: none;}
.product-form.modal .form-check-label{font-style: italic; color: #666; text-align: left;}

+ 157
- 0
ShopBundle/Resources/public/js/backend/script/order/vuejs-order.js Ver arquivo

@@ -0,0 +1,157 @@
// Reference array sent to dynamic 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', {
mixins: [mixinTemplate],
props: ['template', 'keyForm'],
computed: {},
data() {
return Object.assign(
{
title: null,
price: null,
priceWithTax: null,
totalWithoutTax: null,
totalWithTax: null,
buyingPrice: null,
quantity: 1,
unit: null,
product: null
}/*, window.productForm[this.keyForm]*/)
},
mounted: function () {
this.setSelect2();

},
methods: {
updateLine: function (data) {
this.price = data.price;
this.priceWithTax = getPriceWithTax(this.price, data.taxRate);
this.updateQuantity();
this.$parent.updateTotalPrice();
},
updateQuantity:function(){
this.totalWithTax = this.priceWithTax * this.quantity;
this.totalWithoutTax = this.price * this.quantity;
this.$parent.updateTotalPrice();
},
setSelect2: function(){
var monSelect = $(this.$el).find('select.form-control').select2({
theme: 'bootstrap',
language: 'fr'
});
var vue = this;
monSelect.on('select2:select', function () {
this.product = monSelect.val();
$.ajax({
url: "http://localhost:8000/api/product/" + this.product,
method: "GET",
dataType: "",
success: function (response) {
vue.updateLine(response);
}
});
})
}
},
watch: {}
});


appOrder = new Vue({
el: '#lc-order-edit',
delimiters: ['${', '}'],
computed: {},
data() {
return Object.assign(
{
currentSection: 'cart',
formOrderProductArray: [],
indexOrderProductForm: 0,
invoiceAddress: null,
deliveryAddress: null,
totalWithTax:null,
totalWithoutTax:null,
sectionsArray: [
{
name: 'cart',
nameDisplay: 'Panier'
},
{
name: 'addresses',
nameDisplay: 'Livraisons & facturations'
}
]
})/*, window.appOrderProductFamilyValues)*/;
},
mounted: function () {

},
methods: {
updateTotalPrice: function () {
this.totalWithoutTax = 0;
this.totalWithTax = 0;
for (var i = 0; i < this.$refs.orderProductForm.length; i++) {
var line = this.$refs.orderProductForm[i];
this.totalWithoutTax = this.totalWithoutTax + line.totalWithoutTax;
this.totalWithTax = this.totalWithTax + line.totalWithTax;
}
},
changeSection: function (section) {
this.updateChild();
this.currentSection = section.name;
},
addOrderProductForm: function () {
var $collectionHolder = $('#order-products-list');
var prototype = $collectionHolder.data('prototype');
var newForm = prototype;
newForm = newForm.replace(/__name__/g, this.indexOrderProductForm);
this.formOrderProductArray.push(newForm);
this.indexOrderProductForm++;
//updateSortableProducts();
},

updateChild: function () {
if (typeof this.$refs.productForm !== 'undefined') {
for (i = 0; i < this.$refs.productForm.length; i++) {
this.$refs.productForm[i].updateProductForm();
this.$refs.productForm[i].updateProductView();
}
}
},
getUnitReference: function () {
if (typeof this.$refs.productUnitPrice !== 'undefined') {
return this.$refs.productUnitPrice.unitReference;
}
}
},
watch: {
title: function () {
this.updateChild()
},
}
});

ShopBundle/Resources/public/js/backend/script/vuejs-mixins.js → ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-mixins.js Ver arquivo

@@ -152,6 +152,7 @@ let mixinTemplate = {
//staticRenderFns.push(res.staticRenderFns[i]);
this.$options.staticRenderFns.push(res.staticRenderFns[i])
}

}
}
}

ShopBundle/Resources/public/js/backend/script/vuejs-product-family.js → ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js Ver arquivo


+ 5
- 0
ShopBundle/Resources/views/backend/order/edit.html.twig Ver arquivo

@@ -0,0 +1,5 @@
{% extends '@EasyAdmin/default/edit.html.twig' %}

{% block entity_form %}
{% include '@LcShop/backend/order/form.html.twig' %}
{% endblock entity_form %}

+ 36
- 0
ShopBundle/Resources/views/backend/order/form.html.twig Ver arquivo

@@ -0,0 +1,36 @@
{{ form_start(form, {"attr": {'@change' : 'formUpdated'}}) }}

<div class="lc-vue-js-container" id="lc-order-edit">

<div id="nav-params">
<button type="button" v-for="section in sectionsArray"
:class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')"
@click="changeSection(section)">
${ section.nameDisplay }
<span class="glyphicon glyphicon-triangle-bottom"></span>
</button>
</div>
<div class="form">

<script>// rendered by server
/*window.appProductFamilyValues = {
{#{% if form.vars.value.title %}title: "{{ form.vars.value.title }}",{% endif %}#}
};*/

</script>

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

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

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





+ 10
- 0
ShopBundle/Resources/views/backend/order/new.html.twig Ver arquivo

@@ -0,0 +1,10 @@
{% extends '@EasyAdmin/default/new.html.twig' %}

{% block entity_form %}

{% if formView is defined and formView == 'default'%}
{{ form(form) }}
{% else %}
{% include '@LcShop/backend/order/form.html.twig' %}
{% endif %}
{% endblock entity_form %}

+ 2
- 0
ShopBundle/Resources/views/backend/order/panel_addresses.html.twig Ver arquivo

@@ -0,0 +1,2 @@
{{ form_row(form.deliveryAddress) }}
{{ form_row(form.invoiceAddress, {"attr": {'v-model' : 'invoiceAddress', 'v-selecttwo' : 'invoiceAddress'}}) }}

+ 47
- 0
ShopBundle/Resources/views/backend/order/panel_cart.html.twig Ver arquivo

@@ -0,0 +1,47 @@
<div class="row">
<div class="field-group col-12">
<fieldset>
<legend>Stock</legend>
<div class="row">
<div class="col">
{{ form_label(form.behaviorCountStock) }}
{% for field in form.behaviorCountStock %}
{% if field.vars.value == "by-product" %}
<div v-if="activeProducts == true">
{{ form_widget(field, {"attr" : {"v-model" : 'behaviorCountStock'}}) }}
</div>
{% else %}
{{ form_widget(field, {"attr" : {"v-model" : 'behaviorCountStock'}}) }}
{% endif %}
{% endfor %}
</div>
<div class="col">
<div v-show="behaviorCountStock == 'by-product-family' || behaviorCountStock == 'by-quantity'"
class="form-group">
{{ form_label(form.availableQuantity) }}
<div class="form-widget">
<div class="input-group">
{{ form_widget(form.availableQuantity) }}
<div v-show="behaviorCountStock == 'by-quantity'" class="input-group-append">
<span class="input-group-text">${ getUnitReference() }</span>
</div>
</div>
{{ form_help(form.availableQuantity) }}
</div>

{{ form_label(form.availableQuantityDefault) }}
<div class="form-widget">
<div class="input-group">
{{ form_widget(form.availableQuantityDefault) }}
<div v-show="behaviorCountStock == 'by-quantity'" class="input-group-append">
<span class="input-group-text">${ getUnitReference() }</span>
</div>
</div>
{{ form_help(form.availableQuantityDefault) }}
</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>

+ 115
- 0
ShopBundle/Resources/views/backend/order/panel_orderproducts.html.twig Ver arquivo

@@ -0,0 +1,115 @@
{% macro printOrderProductRow(orderProduct) %}

<tr class="order-product-item">
<td colspan="2">
<div class="form-widget">
{{ form_widget(orderProduct.product, {'attr' : {'v-model' : 'product'}}) }}
</div>
</td>
<td>
<div class="form-widget">
{% verbatim %}{{ price }}{% endverbatim %}
</div>
</td>
<td>
<div class="form-widget">
{% verbatim %}{{ priceWithTax }}{% endverbatim %}
</div>
</td>
<td>
<div class="form-widget">
{{ form_widget(orderProduct.quantity, {'attr' : {'v-model' : 'quantity', '@change': 'updateQuantity'}}) }}
</div>
</td>
<td>
{% verbatim %}{{ totalWithTax }}{% endverbatim %}
</td>
<td>
<button type="button" class="btn-remove-product btn btn-default" @click="deleteProductForm()">
<i class="fa fa-trash"></i>
</button>
</td>
</tr>
{% endmacro %}


{% import _self as formMacros %}
<table id="order-products-list" class="table datagrid"
data-prototype="{{ formMacros.printOrderProductRow(form.orderProducts.vars.prototype)|e('html_attr') }}">
<thead>
<tr>
<th colspan="2">
<span>Produit</span>
</th>
<th>
<span>Prix HT à l'unité</span>
</th>
<th>
<span>Prix TTC à l'unité</span>
</th>
<th>
<span>Quantité</span>
</th>
<th>
<span>Total</span>
</th>
<th>
<span>Action</span>
</th>
</tr>
</thead>
<tbody>
<template v-for="(formProduct, key) in formOrderProductArray">

<order-product-form ref="orderProductForm" :template="formProduct" :key-form="key"></order-product-form>
</template>
<tr>
<td colspan="4"></td>
<td colspan="2">
<table>
<tr>
<th>Total without Tax</th>
<td>${totalWithoutTax}</td>
</tr>
<tr>
<th>Total</th>
<td>${totalWithTax}</td>
</tr>
</table>
</td>
<td ></td>
</tr>
</tbody>
</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>
<script>
window.orderProductForm = new Array();
</script>

{% for keyForm, orderProduct in form.orderProducts %}

<script>
window.orderProductForm[{{ keyForm }}] = {
{% if orderProduct.vars.value.title %}title: "{{ orderProduct.vars.value.title }}",{% endif %}
{% if orderProduct.vars.value.quantity %}quantity: "{{ orderProduct.vars.value.quantity }}",{% endif %}
{% if orderProduct.vars.value.unit %}unit: "{{ orderProduct.vars.value.unit }}",{% endif %}
{#{% if orderProduct.vars.value.buyingPrice %}buyingPrice: "{{ orderProduct.vars.value.buyingPrice }}",{% endif %}#}
{% if orderProduct.vars.value.price %}price: parseFloat({{ orderProduct.vars.value.price }}).toFixed(3),{% endif %}
{% if orderProduct.vars.value.product %}product: {{ orderProduct.vars.value.product.id }}{% endif %}
};
jQuery(window).on('load', function () {
var orderProductForm = '{{ formMacros.printOrderProductRow(orderProduct)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';

appOrder.formOrderProductArray.push(orderProductForm);
appOrder.indexOrderProductForm++;
});
</script>

{% endfor %}

{% do form.orderProducts.setRendered %}


Carregando…
Cancelar
Salvar