use App\Entity\Product; | use App\Entity\Product; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
use Symfony\Component\Form\Extension\Core\Type\NumberType; | use Symfony\Component\Form\Extension\Core\Type\NumberType; | ||||
use Symfony\Component\Form\FormError; | |||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
class ProductFamilyController extends AdminController | class ProductFamilyController extends AdminController | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$entity = $easyadmin['item']; | $entity = $easyadmin['item']; | ||||
$orderShopRepo = $this->em->getRepository(OrderShopInterface::class); | |||||
$totalProductOrdered = array(); | |||||
foreach ($entity->getProducts() as $product) { | |||||
$currentWeekNumber = $this->orderUtils->getWeekNumberCurrent(); | |||||
//Les commandes sont ouvertes ont récupèrent les commandes en cours et celle de la semaine dernière | |||||
if($this->orderUtils->isOpenSale()) { | |||||
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); | |||||
$totalProductOrdered[$product->getId()][$currentWeekNumber - 1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber - 1, $product->getId()); | |||||
}else{ | |||||
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId()); | |||||
} | |||||
} | |||||
if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | ||||
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | $newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | ||||
$fieldsMetadata = $this->entity['list']['fields']; | $fieldsMetadata = $this->entity['list']['fields']; | ||||
ksort($sortableProductsField); | ksort($sortableProductsField); | ||||
$editForm->handleRequest($this->request); | $editForm->handleRequest($this->request); | ||||
if ($editForm->isSubmitted() && $editForm->isValid()) { | |||||
if( $editForm->isSubmitted() && count($entity->getProductCategories()) == 0){ | |||||
$editForm->get('productCategories')->addError(new FormError('Vous devez choisir au moins une catégorie')); | |||||
} | |||||
if ($editForm->isSubmitted() && $editForm->isValid() && count($entity->getProductCategories())>0) { | |||||
$this->processUploadedFiles($editForm); | $this->processUploadedFiles($editForm); | ||||
'entity_fields' => $fields, | 'entity_fields' => $fields, | ||||
'entity' => $entity, | 'entity' => $entity, | ||||
'delete_form' => $deleteForm->createView(), | 'delete_form' => $deleteForm->createView(), | ||||
'sortableProductsField' => $sortableProductsField | |||||
'sortableProductsField' => $sortableProductsField, | |||||
'totalProductOrdered' => $totalProductOrdered | |||||
]; | ]; | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); | return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); | ||||
$newForm->handleRequest($this->request); | $newForm->handleRequest($this->request); | ||||
if ($newForm->isSubmitted() && $newForm->isValid()) { | |||||
if( $newForm->isSubmitted() && array_search(true, $newForm->get('productCategories')->getData()->toArray())===false){ | |||||
$newForm->get('productCategories')->addError(new FormError('Vous devez choisir au moins une catégorie')); | |||||
} | |||||
if ($newForm->isSubmitted() && $newForm->isValid() && array_search(true, $newForm->get('productCategories')->getData()->toArray())!==false) { | |||||
$this->processUploadedFiles($newForm); | $this->processUploadedFiles($newForm); | ||||
$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | ||||
'entity_fields' => $fields, | 'entity_fields' => $fields, | ||||
'entity' => $entity, | 'entity' => $entity, | ||||
'categories' => $categories, | 'categories' => $categories, | ||||
'sortableProductsField' => array() | |||||
'sortableProductsField' => array(), | |||||
'totalProductOrdered' => array() | |||||
]; | ]; | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); |
protected $statusAliasAsCart = array('cart', 'waiting-payment-online', 'waiting-payment-credit', 'waiting-payment-on-delivery', 'error-payment-online'); | protected $statusAliasAsCart = array('cart', 'waiting-payment-online', 'waiting-payment-credit', 'waiting-payment-on-delivery', 'error-payment-online'); | ||||
public function countValidOrderWithReductionCredit($reductionCredit, $user){ | |||||
public function countValidOrderWithReductionCredit($reductionCredit, $user) | |||||
{ | |||||
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->select('count(e.id)'); | $query->select('count(e.id)'); | ||||
} | } | ||||
public function countValidOrderWithReductionCart($reductionCart){ | |||||
public function countValidOrderWithReductionCart($reductionCart) | |||||
{ | |||||
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->select('count(e.id)'); | $query->select('count(e.id)'); | ||||
} | } | ||||
public function countValidOrderWithReductionCartPerUser($reductionCart, $user){ | |||||
public function countValidOrderWithReductionCartPerUser($reductionCart, $user) | |||||
{ | |||||
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->select('count(e.id)'); | $query->select('count(e.id)'); | ||||
} | } | ||||
public function filterOrderValid(?QueryBuilder $query) :QueryBuilder { | |||||
public function filterOrderValid(?QueryBuilder $query): QueryBuilder | |||||
{ | |||||
$query->leftJoin('e.orderStatus', 'os'); | $query->leftJoin('e.orderStatus', 'os'); | ||||
$query->andWhere('os.alias IN (:alias)'); | $query->andWhere('os.alias IN (:alias)'); | ||||
public function filterIsOffCircuit($query, $isOffCircuit) | public function filterIsOffCircuit($query, $isOffCircuit) | ||||
{ | { | ||||
if($isOffCircuit) { | |||||
$query->andWhere('e.isOffCircuit = 1') ; | |||||
} | |||||
else { | |||||
$query->andWhere('e.isOffCircuit IS NULL OR e.isOffCircuit = 0') ; | |||||
if ($isOffCircuit) { | |||||
$query->andWhere('e.isOffCircuit = 1'); | |||||
} else { | |||||
$query->andWhere('e.isOffCircuit IS NULL OR e.isOffCircuit = 0'); | |||||
} | } | ||||
return $query ; | |||||
return $query; | |||||
} | } | ||||
public function findCartCurrent($params) | public function findCartCurrent($params) | ||||
{ | { | ||||
$query = $this->findByMerchantQuery() ; | |||||
$query = $this->findByMerchantQuery(); | |||||
if(isset($params['user'])) { | |||||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; | |||||
if (isset($params['user'])) { | |||||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']); | |||||
} | } | ||||
if(isset($params['visitor'])) { | |||||
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ; | |||||
if (isset($params['visitor'])) { | |||||
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']); | |||||
} | } | ||||
$query = $this->filterOrderCart($query); | $query = $this->filterOrderCart($query); | ||||
$query->leftJoin('e.orderReductionCarts', 'orderReductionCarts') | $query->leftJoin('e.orderReductionCarts', 'orderReductionCarts') | ||||
->addSelect('orderReductionCarts'); | ->addSelect('orderReductionCarts'); | ||||
$results = $query->getQuery()->getResult() ; | |||||
$results = $query->getQuery()->getResult(); | |||||
if($results) { | |||||
return $results[0] ; | |||||
if ($results) { | |||||
return $results[0]; | |||||
} | } | ||||
return null ; | |||||
return null; | |||||
} | } | ||||
public function findAllBy($params = []) | public function findAllBy($params = []) | ||||
{ | { | ||||
$query = $this->findByMerchantQuery() ; | |||||
$query = $this->findByMerchantQuery(); | |||||
if(isset($params['count']) && $params['count']) { | |||||
$query->select('count(e.id)') ; | |||||
if (isset($params['count']) && $params['count']) { | |||||
$query->select('count(e.id)'); | |||||
} | } | ||||
if(isset($params['dateStart']) || isset($params['dateEnd'])) { | |||||
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate' ; | |||||
if (isset($params['dateStart']) || isset($params['dateEnd'])) { | |||||
$params['dateField'] = isset($params['dateField']) ? $params['dateField'] : 'validationDate'; | |||||
} | } | ||||
if(isset($params['dateStart'])) { | |||||
$query->andWhere('e.'.$params['dateField'].' >= :dateStart')->setParameter('dateStart', $params['dateStart']) ; | |||||
if (isset($params['dateStart'])) { | |||||
$query->andWhere('e.' . $params['dateField'] . ' >= :dateStart')->setParameter('dateStart', $params['dateStart']); | |||||
} | } | ||||
if(isset($params['dateEnd'])) { | |||||
$query->andWhere('e.'.$params['dateField'].' <= :dateEnd')->setParameter('dateEnd', $params['dateEnd']) ; | |||||
if (isset($params['dateEnd'])) { | |||||
$query->andWhere('e.' . $params['dateField'] . ' <= :dateEnd')->setParameter('dateEnd', $params['dateEnd']); | |||||
} | } | ||||
if(isset($params['isCart'])) { | |||||
$query = $this->filterOrderCart($query) ; | |||||
if (isset($params['isCart'])) { | |||||
$query = $this->filterOrderCart($query); | |||||
} | } | ||||
if(isset($params['isValid'])) { | |||||
$query = $this->filterOrderValid($query) ; | |||||
if (isset($params['isValid'])) { | |||||
$query = $this->filterOrderValid($query); | |||||
} | } | ||||
if(isset($params['user'])) { | |||||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ; | |||||
if (isset($params['user'])) { | |||||
$query->andWhere('e.user = :user')->setParameter('user', $params['user']); | |||||
} | } | ||||
if(isset($params['mergeComplementaryOrderShops'])) { | |||||
$query->andWhere('e.mainOrderShop IS NULL') ; | |||||
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops') ; | |||||
if (isset($params['mergeComplementaryOrderShops'])) { | |||||
$query->andWhere('e.mainOrderShop IS NULL'); | |||||
$query->leftJoin('e.complementaryOrderShops', 'complementaryOrderShops'); | |||||
$query->leftJoin('complementaryOrderShops.orderStatus', 'complementaryOrderStatus'); | $query->leftJoin('complementaryOrderShops.orderStatus', 'complementaryOrderStatus'); | ||||
$query->andWhere('complementaryOrderStatus.alias IN (:statusAliasValid)'); | $query->andWhere('complementaryOrderStatus.alias IN (:statusAliasValid)'); | ||||
$query->setParameter('statusAliasValid', $this->statusAliasAsValid); | $query->setParameter('statusAliasValid', $this->statusAliasAsValid); | ||||
} | } | ||||
if(isset($params['excludeComplementaryOrderShops'])) { | |||||
$query->andWhere('e.mainOrderShop IS NULL') ; | |||||
if (isset($params['excludeComplementaryOrderShops'])) { | |||||
$query->andWhere('e.mainOrderShop IS NULL'); | |||||
} | } | ||||
if(isset($params['isOffCircuit'])) { | |||||
$query = $this->filterIsOffCircuit($query, true) ; | |||||
if (isset($params['isOffCircuit'])) { | |||||
$query = $this->filterIsOffCircuit($query, true); | |||||
} | } | ||||
if(isset($params['isCircuit'])) { | |||||
$query = $this->filterIsOffCircuit($query, false) ; | |||||
$query->leftJoin('e.deliveryPointSale', 'pointSale') ; | |||||
$query->andWhere('e.deliveryPointSale IS NULL OR pointSale.isDepository = 0') ; | |||||
if (isset($params['isCircuit'])) { | |||||
$query = $this->filterIsOffCircuit($query, false); | |||||
$query->leftJoin('e.deliveryPointSale', 'pointSale'); | |||||
$query->andWhere('e.deliveryPointSale IS NULL OR pointSale.isDepository = 0'); | |||||
} | } | ||||
if(isset($params['isDepository'])) { | |||||
$query = $this->filterIsOffCircuit($query, false) ; | |||||
$query->innerJoin('e.deliveryPointSale', 'pointSale') ; | |||||
$query->andWhere('pointSale.isDepository = 1') ; | |||||
if (isset($params['isDepository'])) { | |||||
$query = $this->filterIsOffCircuit($query, false); | |||||
$query->innerJoin('e.deliveryPointSale', 'pointSale'); | |||||
$query->andWhere('pointSale.isDepository = 1'); | |||||
} | } | ||||
if(isset($params['orderBy'])) { | |||||
$query->orderBy('e.'.$params['orderBy'], isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC') ; | |||||
} | |||||
else { | |||||
$query->orderBy('e.id', 'DESC') ; | |||||
if (isset($params['orderBy'])) { | |||||
$query->orderBy('e.' . $params['orderBy'], isset($params['orderByDirection']) ? $params['orderByDirection'] : 'DESC'); | |||||
} else { | |||||
$query->orderBy('e.id', 'DESC'); | |||||
} | } | ||||
$query->leftJoin('e.deliveryAvailabilityZone', 'deliveryAvailabilityZone') ; | |||||
$query->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone') ; | |||||
$query->leftJoin('e.deliveryAvailabilityZone', 'deliveryAvailabilityZone'); | |||||
$query->leftJoin('deliveryAvailabilityZone.deliverySlot', 'deliverySlotZone'); | |||||
$query->leftJoin('e.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale') ; | |||||
$query->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale') ; | |||||
$query->leftJoin('e.deliveryAvailabilityPointSale', 'deliveryAvailabilityPointSale'); | |||||
$query->leftJoin('deliveryAvailabilityPointSale.deliverySlot', 'deliverySlotPointSale'); | |||||
if(isset($params['count']) && $params['count']) { | |||||
if (isset($params['count']) && $params['count']) { | |||||
return $query->getQuery()->getSingleScalarResult(); | return $query->getQuery()->getSingleScalarResult(); | ||||
} | |||||
else { | |||||
return $query->getQuery()->getResult() ; | |||||
} else { | |||||
return $query->getQuery()->getResult(); | |||||
} | } | ||||
} | } | ||||
public function findLastOrderValidOfWeek($weekNumber){ | |||||
public function findLastOrderValidOfWeek($weekNumber) | |||||
{ | |||||
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->andWhere('e.weekNumber = :weekNumber'); | $query->andWhere('e.weekNumber = :weekNumber'); | ||||
$query->setParameter('weekNumber', $weekNumber); | $query->setParameter('weekNumber', $weekNumber); | ||||
$query->orderBy('e.validationDate','DESC'); | |||||
$query->orderBy('e.validationDate', 'DESC'); | |||||
$query->setMaxResults(1); | $query->setMaxResults(1); | ||||
return $query->getQuery()->getOneOrNullResult(); | return $query->getQuery()->getOneOrNullResult(); | ||||
} | } | ||||
public function countValidOrderProductsOfWeekByProduct(){ | |||||
public function countValidOrderProductsOfWeekByProduct($weekNumber, $productId) | |||||
{ | |||||
$query = $this->findByMerchantQuery(); | |||||
$query = $this->filterOrderValid($query); | |||||
$query->andWhere('e.weekNumber = :weekNumber'); | |||||
$query->setParameter('weekNumber', $weekNumber); | |||||
$query->leftJoin('e.orderProducts', 'orderProduct'); | |||||
$query->andWhere('orderProduct.product = :product'); | |||||
$query->setParameter('product', $productId); | |||||
$query->select('SUM(orderProduct.quantityOrder) as quantity'); | |||||
return $query->getQuery()->getOneOrNullResult(); | |||||
} | } | ||||
} | } |
/* ProductFamily */ | /* ProductFamily */ | ||||
.field-unit-quantity{border-bottom: 2px dotted #eee; padding-bottom: 10px; margin-bottom: 20px;} | .field-unit-quantity{border-bottom: 2px dotted #eee; padding-bottom: 10px; margin-bottom: 20px;} | ||||
.field-reduction-apply{border-top: 2px dotted #eee; padding-top: 10px; margin-top: 20px;} | |||||
.new-productfamily #nav-params, | .new-productfamily #nav-params, | ||||
.edit-productfamily #nav-params { | .edit-productfamily #nav-params { | ||||
.product-form.modal .form-check-label{font-style: italic; color: #666; text-align: left;} | .product-form.modal .form-check-label{font-style: italic; color: #666; text-align: left;} | ||||
.products-collection-table .inherited{color: #888; font-style: italic; font-weight: initial;} | .products-collection-table .inherited{color: #888; font-style: italic; font-weight: initial;} | ||||
.products-collection-table td{position: relative;} | .products-collection-table td{position: relative;} | ||||
.card-body.p-0 .products-collection-table tbody > tr > td:first-of-type, .card-body.p-0 .products-collection-table tbody > tr > th:first-of-type, .card-body.p-0 .products-collection-table thead > tr > td:first-of-type, .card-body.p-0 .products-collection-table thead > tr > th:first-of-type{padding-left: 0.35rem;} | |||||
.products-collection-table .btn-empty-field{position: absolute; right: 3px; font-size: 0.7rem; top: 5px; padding: 0px;} | .products-collection-table .btn-empty-field{position: absolute; right: 3px; font-size: 0.7rem; top: 5px; padding: 0px;} | ||||
#lc-product-family-edit .products-collection-table {table-layout:fixed;} | #lc-product-family-edit .products-collection-table {table-layout:fixed;} | ||||
#lc-product-family-edit .products-collection-table tr{border-bottom: 1px solid #dee2e6;} | #lc-product-family-edit .products-collection-table tr{border-bottom: 1px solid #dee2e6;} |
/* ProductFamily */ | |||||
/*function initLcTaxPriceWidget() { | |||||
lcTaxPriceInit() ; | |||||
$('#productfamily_price').change(lcTaxPriceEventPrice); | |||||
$('#productfamily_priceWithTax').change(lcTaxPriceEventPriceWithTax); | |||||
} | |||||
function lcTaxPriceInit() { | |||||
lcTaxPriceUpdate('priceWithTax') ; | |||||
$('#productfamily_price').val(parseFloat($('#productfamily_price').val()).toFixed(3)); | |||||
} | |||||
function lcTaxPriceEventPrice() { | |||||
lcTaxPriceUpdate('priceWithTax') ; | |||||
} | |||||
function lcTaxPriceEventPriceWithTax() { | |||||
lcTaxPriceUpdate('price') ; | |||||
} | |||||
function lcTaxGetTaxRate() { | |||||
taxRate = $('#productfamily_taxRate').find('option:selected').data('tax-rate-value'); | |||||
if(typeof taxRate == 'undefined') { | |||||
taxRate = 0 ; | |||||
} | |||||
return taxRate ; | |||||
} | |||||
function lcTaxPriceUpdate(priceType) { | |||||
var taxRate = lcTaxGetTaxRate() ; | |||||
if(priceType == 'priceWithTax') { | |||||
$('#productfamily_priceWithTax').val(getPriceWithTax($('#productfamily_price').val(), taxRate)); | |||||
} | |||||
else { | |||||
$('#productfamily_price').val(getPrice($('#productfamily_priceWithTax').val(), taxRate)); | |||||
} | |||||
}*/ | |||||
/** | /** | ||||
* Retourne un prix sans taxe sur base du prix avec tax | * Retourne un prix sans taxe sur base du prix avec tax | ||||
* | * | ||||
return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(2); | return parseFloat(parseFloat(priceWithoutTax) * ((taxRate/100) + 1)).toFixed(2); | ||||
} | } | ||||
function getMargin(price, buyingPrice){ | |||||
return parseFloat(price - buyingPrice).toFixed(2); | |||||
} | |||||
function getMarginPercent(price, buyingPrice){ | |||||
return parseFloat(((price - buyingPrice) / buyingPrice) * 100).toFixed(2); | |||||
} | |||||
function applyReductionPercent(price, percentage) | |||||
{ | |||||
return applyPercent(price, -percentage); | |||||
} | |||||
function applyReductionAmount(price, amount) | |||||
{ | |||||
return parseFloat(price - amount).toFixed(2); | |||||
} | |||||
function applyPercent(price, percentage) | |||||
{ | |||||
return parseFloat(price * (percentage / 100 + 1)).toFixed(2); | |||||
} | |||||
function formatNumber(number, toFixed){ | function formatNumber(number, toFixed){ | ||||
if(number)return Number(number.replace(',', '.')).toFixed(toFixed); | if(number)return Number(number.replace(',', '.')).toFixed(toFixed); |
}, | }, | ||||
computed: { | computed: { | ||||
/*priceWithTaxAndReduction:function () { | |||||
if(this.productFamily.reductionActive){ | |||||
log(this.productFamily.value); | |||||
} | |||||
}*/ | |||||
marginProfit: function () { | |||||
return getMargin(this.priceValue,this.buyingPriceValue); | |||||
}, | |||||
marginProfitPercent:function () { | |||||
return getMarginPercent(this.priceValue, this.buyingPriceValue); | |||||
}, | |||||
marginProfitWithReduction: function () { | |||||
var price = this.$parent.applyReduction(this.priceValue, this.priceWithTaxValue, this.taxRateValue, false); | |||||
return getMargin(price, this.buyingPriceValue); | |||||
}, | |||||
marginProfitPercentWithReduction:function () { | |||||
var price = this.$parent.applyReduction(this.priceValue, this.priceWithTaxValue, this.taxRateValue, false); | |||||
return getMarginPercent(price, this.buyingPriceValue); | |||||
}, | |||||
finalPriceWithTax: function () { | |||||
return getPriceWithTax(parseFloat((this.priceByRefUnitValue * this.quantityValue) / this.unitCoefficient).toFixed(4), this.taxRateValue); | |||||
}, | |||||
finalPriceWithTaxAndReduction(){ | |||||
return this.$parent.applyReduction(this.priceValue, this.priceWithTaxValue, this.taxRateValue, true); | |||||
} | |||||
}, | }, | ||||
mounted: function () { | mounted: function () { | ||||
select = setSelect2($(this.$refs[refFiltered])) | select = setSelect2($(this.$refs[refFiltered])) | ||||
}, | |||||
applyReduction: function(price, priceWithTax, taxRateValue, returnWithTax){ | |||||
if (this.reductionUnit == 'percent') { | |||||
if(returnWithTax) return applyReductionPercent(priceWithTax, this.reductionValue); | |||||
else return applyReductionPercent(price, this.reductionValue); | |||||
} else if (this.reductionUnit == 'amount'){ | |||||
if(this.reductionBehaviorTaxRate == 'tax-included') { | |||||
if(returnWithTax) return applyReductionAmount(priceWithTax, this.reductionValue); | |||||
else return getPrice(applyReductionAmount(priceWithTax, this.reductionValue), taxRateValue); | |||||
}else if(this.reductionBehaviorTaxRate == 'tax-excluded') { | |||||
if(returnWithTax) return getPriceWithTax(applyReductionAmount(price, this.reductionValue), taxRateValue); | |||||
else return applyReductionAmount(price, this.reductionValue); | |||||
} | |||||
} | |||||
} | } | ||||
}, | }, | ||||
watch: { | watch: { | ||||
}, | }, | ||||
} | } | ||||
}; | |||||
}; |
}, | }, | ||||
behaviorPriceValue: function () { | behaviorPriceValue: function () { | ||||
return this.productFamily.behaviorPrice; | return this.productFamily.behaviorPrice; | ||||
}, | |||||
finalPriceWithTax: function () { | |||||
return getPriceWithTax(parseFloat((this.priceByRefUnitValue * this.quantityValue) / this.unitCoefficient).toFixed(4), this.taxRateValue); | |||||
} | } | ||||
}, | }, | ||||
data() { | data() { | ||||
$(this.$el).find('input, select').on('keydown', function (e) { | $(this.$el).find('input, select').on('keydown', function (e) { | ||||
if (e.keyCode == 13 || e.keyCode == 9) e.preventDefault(); | if (e.keyCode == 13 || e.keyCode == 9) e.preventDefault(); | ||||
//GAUCHE | |||||
//ENTRER | |||||
if(e.keyCode == 13){ | |||||
log(e.keyCode); | |||||
$(this).blur();; | |||||
} | |||||
// shift + [+] | |||||
if (e.shiftKey && e.keyCode == 107) { | |||||
e.preventDefault() | |||||
app.$parent.addProductForm(); | |||||
} | |||||
//GAUCHE (tab + shift) | |||||
if (e.shiftKey && e.keyCode == 9) { | if (e.shiftKey && e.keyCode == 9) { | ||||
e.preventDefault(); | e.preventDefault(); | ||||
$prevField = $(this).parents('td').prevAll('td:visible').first().find('input, select'); | $prevField = $(this).parents('td').prevAll('td:visible').first().find('input, select'); | ||||
app.setFocusOnField($prevField.data('ref'), $prevField.data('y')); | app.setFocusOnField($prevField.data('ref'), $prevField.data('y')); | ||||
//DROITE (tab) | |||||
} else if (e.keyCode == '9') { | } else if (e.keyCode == '9') { | ||||
e.preventDefault(); | e.preventDefault(); | ||||
$nextField = $(this).parents('td').nextAll('td:visible').first().find('input, select'); | $nextField = $(this).parents('td').nextAll('td:visible').first().find('input, select'); | ||||
app.setFocusOnField($nextField.data('ref'), $nextField.data('y')); | app.setFocusOnField($nextField.data('ref'), $nextField.data('y')); | ||||
} | } | ||||
//BAS | |||||
//BAS (flèche bas) | |||||
if (e.keyCode == '40') { | if (e.keyCode == '40') { | ||||
y = parseInt($(this).data('y')) + 1; | y = parseInt($(this).data('y')) + 1; | ||||
if (y >= app.$parent.$refs['productForm'].length) y = 0; | if (y >= app.$parent.$refs['productForm'].length) y = 0; | ||||
app.$parent.$refs['productForm'][y].setFocusOnField($(this).data('ref'), y); | app.$parent.$refs['productForm'][y].setFocusOnField($(this).data('ref'), y); | ||||
} | } | ||||
//HAUT | |||||
//HAUT (flèche haut | |||||
if (e.keyCode == '38') { | if (e.keyCode == '38') { | ||||
y = parseInt($(this).data('y')) - 1; | y = parseInt($(this).data('y')) - 1; | ||||
if (y == -1) y = app.$parent.$refs['productForm'].length - 1; | if (y == -1) y = app.$parent.$refs['productForm'].length - 1; | ||||
} | } | ||||
}, | }, | ||||
modalProductForm: function () { | modalProductForm: function () { | ||||
$('#modal-extends-product').modal('show') | |||||
log($('#modal-extends-product-'+this.keyForm)); | |||||
$('#modal-extends-product-'+this.keyForm).modal('show') | |||||
}, | }, | ||||
}, | }, | ||||
watch: {} | watch: {} | ||||
'priceByRefUnitWithTax': this.$refs.productUnitPrice.priceByRefUnitWithTax, | 'priceByRefUnitWithTax': this.$refs.productUnitPrice.priceByRefUnitWithTax, | ||||
'taxRateValue': this.$refs.productUnitPrice.taxRateValue, | 'taxRateValue': this.$refs.productUnitPrice.taxRateValue, | ||||
'supplierTaxRateValue': this.$refs.productUnitPrice.supplierTaxRateValue, | 'supplierTaxRateValue': this.$refs.productUnitPrice.supplierTaxRateValue, | ||||
'marginProfit': this.$refs.productUnitPrice.marginProfit, | |||||
'marginProfitPercent': this.$refs.productUnitPrice.marginProfitPercent, | |||||
/*'taxRate': this.$refs.productUnitPrice.taxRate, | /*'taxRate': this.$refs.productUnitPrice.taxRate, | ||||
'supplierTaxRate': this.$refs.productUnitPrice.supplierTaxRate, | 'supplierTaxRate': this.$refs.productUnitPrice.supplierTaxRate, | ||||
} | } | ||||
}); | }); | ||||
var allowLeave = false; | |||||
$('#edit-productfamily-form').on('submit', function () { | |||||
allowLeave =true; | |||||
}) | |||||
$(window).bind('beforeunload', function(e){ | |||||
if(!allowLeave){ | |||||
return 'Êtes vous sur de vouloir quitter ?'; | |||||
} | |||||
}); | |||||
$(window).on('load', function () { | $(window).on('load', function () { | ||||
for (i = 0; i < window.formProductTemplate.length; i++) { | for (i = 0; i < window.formProductTemplate.length; i++) { |
note: Note interne | note: Note interne | ||||
parameters: Paramètres | parameters: Paramètres | ||||
initReduction: Réduction | initReduction: Réduction | ||||
export: Note à l'export | |||||
ReductionCatalog: | ReductionCatalog: | ||||
info: Informations principal | info: Informations principal | ||||
conditions: Condictions d'application | conditions: Condictions d'application | ||||
displayPriceUnitRef: Afficher le prix par unité de référence | displayPriceUnitRef: Afficher le prix par unité de référence | ||||
behaviorPrice: Travailler avec des tarifs | behaviorPrice: Travailler avec des tarifs | ||||
behaviorPriceOptions: | behaviorPriceOptions: | ||||
byPiece: À la pièce | |||||
byRefUnit: Par unité de référence | |||||
by-piece: À la pièce | |||||
by-reference-unit: Par unité de référence | |||||
behaviorCountStockOptions: | behaviorCountStockOptions: | ||||
by-measure: Gérer le stock par unité de référence | by-measure: Gérer le stock par unité de référence | ||||
by-product-family: Gérer le stock par produit (à l'unité) | by-product-family: Gérer le stock par produit (à l'unité) | ||||
natureProgres: Nature & progrès | natureProgres: Nature & progrès | ||||
behaviorExpirationDate: Gèrer | behaviorExpirationDate: Gèrer | ||||
behaviorExpirationDateOptions: | behaviorExpirationDateOptions: | ||||
productFamily: Par produit | |||||
product: Par déclinaisons | |||||
by-product-family: Par produit | |||||
by-product: Par déclinaisons | |||||
taxRate: TVA | taxRate: TVA | ||||
unit: Unité | unit: Unité | ||||
behaviorAddToCartOptions: | behaviorAddToCartOptions: |
{% macro product_field(colspan, field, field_name, field_display = false, display_suffix="",attr="") %} | |||||
{% if field_display == false %}{% set field_display = field_name %}{% endif %} | |||||
<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ field_name }}"> | |||||
<div class="value" v-show="{{ field_name }}Inherited == false" v-on:click="setFocusOnField('{{ field_name }}Inherited', keyForm)"> | |||||
<div v-if="{{ field_name }}"> | |||||
{% verbatim %}{{ {% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }} | |||||
</div> | |||||
<div v-else class="inherited"> | |||||
{% verbatim %}{{ productFamily.{% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }} | |||||
</div> | |||||
</div> | |||||
<div v-show="{{ field_name }}Inherited == true"> | |||||
{{ form_widget(field, {'attr' : {'v-model' : field_name , 'v-on:focusout': field_name~'Inherited = false', '@change' : field_name~'Updated', 'data-ref': field_name~'Inherited', ':data-y' : "keyForm" }}) }} | |||||
</div> | |||||
<button v-show="{{ field_name }}" v-on:click="{{ field_name }} = null; {{ field_name }}Inherited = false; " | |||||
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button> | |||||
</td> | |||||
{% endmacro %} | |||||
{% macro priceField(field, fieldTax, fieldName, behaviorPriceValue) %} | {% macro priceField(field, fieldTax, fieldName, behaviorPriceValue) %} | ||||
<div class="form-group field-price col-12" v-show="behaviorPrice == '{{ behaviorPriceValue }}'"> | <div class="form-group field-price col-12" v-show="behaviorPrice == '{{ behaviorPriceValue }}'"> | ||||
<div class="row"> | <div class="row"> | ||||
{% macro reductionCatalogForm(form) %} | {% macro reductionCatalogForm(form) %} | ||||
{{ _self.startCard(6, 'ReductionCatalog.info') }} | {{ _self.startCard(6, 'ReductionCatalog.info') }} | ||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.title) }} | |||||
{{ form_row(form.title, {'attr' : {":required": "reductionActive"}}) }} | |||||
</div> | </div> | ||||
{{ _self.fieldReductionUnit(form) }} | {{ _self.fieldReductionUnit(form) }} | ||||
{{ _self.fieldReductionValue(form) }} | {{ _self.fieldReductionValue(form) }} |
{{ form_start(form, {"attr": {'@change' : 'formUpdated'}}) }} | {{ form_start(form, {"attr": {'@change' : 'formUpdated'}}) }} | ||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %} | |||||
{% set formValues = form.vars.value %} | {% set formValues = form.vars.value %} | ||||
<div id="lc-product-family-edit"> | <div id="lc-product-family-edit"> | ||||
window.appProductFamilyValues = { | window.appProductFamilyValues = { | ||||
{% if formValues.title %}title: "{{ formValues.title }}",{% endif %} | {% if formValues.title %}title: "{{ formValues.title }}",{% endif %} | ||||
{% if form.behaviorCountStock.vars.value %}behaviorCountStock: "{{ form.behaviorCountStock.vars.value }}",{% endif %} | {% if form.behaviorCountStock.vars.value %}behaviorCountStock: "{{ form.behaviorCountStock.vars.value }}",{% endif %} | ||||
{% if form.behaviorStockWeek.vars.value %}behaviorStockWeek: "{{ form.behaviorStockWeek.vars.value }}",{% 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 %} |
{% trans_default_domain 'lcshop' %} | |||||
{% macro total_order_product(totalProductOrdered) %} | |||||
{% for weekNumber, weekNumberQuantity in totalProductOrdered %} | |||||
<span class="text-success"><i class="fa fa-calendar"></i> {{ weekNumber }}</span> | |||||
<span class="text-info"><i class="fa fa-shopping-basket"></i> | |||||
<strong>{{ weekNumberQuantity['quantity'] is null ? 0 : weekNumberQuantity['quantity']}}</strong></span> | |||||
<br /> | |||||
{% endfor %} | |||||
{% endmacro total_order_product %} | |||||
{% macro product_field(colspan, field, field_name, field_display = false, display_suffix="",attr="") %} | |||||
{% if field_display == false %}{% set field_display = field_name %}{% endif %} | |||||
<td {{ attr|raw }} colspan="{{ colspan }}" class="{{ field_name }}"> | |||||
<div class="value" v-show="{{ field_name }}Inherited == false" v-on:click="setFocusOnField('{{ field_name }}Inherited', keyForm)"> | |||||
<div v-if="{{ field_name }}"> | |||||
{% verbatim %}{{ {% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }} | |||||
{% if field_name == 'priceWithTax' %} | |||||
<br /> | |||||
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span> | |||||
{% endif %} | |||||
</div> | |||||
<div v-else class="inherited"> | |||||
{% verbatim %}{{ productFamily.{% endverbatim %}{{ field_display }} {% verbatim %}}}{% endverbatim %}{{ display_suffix }} | |||||
{% if field_name == 'priceWithTax' %} | |||||
<br /> | |||||
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span> | |||||
{% endif %} | |||||
</div> | |||||
</div> | |||||
<div v-show="{{ field_name }}Inherited == true"> | |||||
{{ form_widget(field, {'attr' : {'v-model' : field_name , 'v-on:focusout': field_name~'Inherited = false', '@change' : field_name~'Updated', 'data-ref': field_name~'Inherited', ':data-y' : "keyForm" }}) }} | |||||
</div> | |||||
<button v-show="{{ field_name }}" v-on:click="{{ field_name }} = null; {{ field_name }}Inherited = false; " | |||||
class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button> | |||||
</td> | |||||
{% endmacro %} | |||||
{% macro product_row(product, totalProductOrdered) %} | |||||
<tr class="lc-draggable"> | |||||
<td><i class="fa fa-fw fa-sort"></i></td> | |||||
{{ _self.product_field(4, product.title, 'title') }} | |||||
{{ _self.product_field(2, product.quantity, 'quantity') }} | |||||
{{ _self.product_field(2, product.unit, 'unit', 'unitWording') }} | |||||
{{ _self.product_field(3, product.buyingPriceByRefUnit, 'buyingPriceByRefUnit',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ _self.product_field(3, product.buyingPriceByRefUnitWithTax, 'buyingPriceByRefUnitWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ _self.product_field(3, product.buyingPrice, 'buyingPrice',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ _self.product_field(3, product.buyingPriceWithTax, 'buyingPriceWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
<td colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"> | |||||
{% verbatim %}{{ buyingPriceWithTax }}{% endverbatim %}€ | |||||
</td> | |||||
{{ _self.product_field(3, product.multiplyingFactor, 'multiplyingFactor') }} | |||||
{{ _self.product_field(3, product.priceByRefUnit, 'priceByRefUnit',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ _self.product_field(3, product.priceByRefUnitWithTax, 'priceByRefUnitWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
<td colspan="3" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"> | |||||
{% verbatim %}{{ finalPriceWithTax }}{% endverbatim %}€ | |||||
<span class="text-danger" v-show="productFamily.reductionActive">{% verbatim %}{{ finalPriceWithTaxAndReduction }}{% endverbatim %}€</span> | |||||
</td> | |||||
{{ _self.product_field(3, product.price, 'price', false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ _self.product_field(3, product.priceWithTax, 'priceWithTax', false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
<td colspan="2"> | |||||
<span v-if="productFamily.reductionActive" class="text-danger"> | |||||
{% verbatim %}{{ marginProfitWithReduction }}{% endverbatim %}€<br /> | |||||
{% verbatim %}{{ marginProfitPercentWithReduction }}{% endverbatim %}% | |||||
</span> | |||||
<span v-else> | |||||
{% verbatim %}{{ marginProfit }}{% endverbatim %}€<br /> | |||||
{% verbatim %}{{ marginProfitPercent }}{% endverbatim %}% | |||||
</span> | |||||
</td> | |||||
{{ _self.product_field(2, product.propertyExpirationDate, 'propertyExpirationDate','propertyExpirationDateValue', '', 'v-show="productFamily.behaviorExpirationDate== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') ~ '\'"') }} | |||||
{{ _self.product_field(2, product.availableQuantity, 'availableQuantity',false, '', 'v-show="productFamily.behaviorCountStock== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') ~ '\'"') }} | |||||
{{ _self.product_field(2, product.availableQuantityDefault, 'availableQuantityDefault',false, '', 'v-show="productFamily.behaviorCountStock== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') ~ '\' && productFamily.behaviorStockWeek!= \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') ~ '\'"') }} | |||||
<td colspan="2" v-show="productFamily.behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' || productFamily.behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}'"> | |||||
{{ _self.total_order_product(totalProductOrdered) }} | |||||
</td> | |||||
<td colspan="2"> | |||||
<button type="button" class="btn-remove-product btn-sm btn-info" @click="modalProductForm()"> | |||||
<i class="fa fa-edit"></i> | |||||
</button> | |||||
<button type="button" class="btn-remove-product btn-sm btn-danger" @click="deleteProductForm()"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
{{ form_widget(product.position, {'attr' : {'class': "field-position"}}) }} | |||||
<div class="modal fade show" :id="'modal-extends-product-'+keyForm"> | |||||
<div class="modal-dialog"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h4>{{ "group.ProductFamily.productsExtend"|trans }}</h4> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<div class="col"> | |||||
{{ form_row(product.exportTitle) }} | |||||
</div> | |||||
<div class="col"> | |||||
{{ form_row(product.exportNote) }} | |||||
</div> | |||||
</div> | |||||
<div class="modal-footer justify-content-between"> | |||||
<button type="button" class="btn btn-info float-right" data-dismiss="modal">Ok</button> | |||||
</div> | |||||
</div> | |||||
<!-- /.modal-content --> | |||||
</div> | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
{% endmacro %} |
<div class="form-group field-price col-12"> | <div class="form-group field-price col-12"> | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-6 align-content-center"> | |||||
<div class="col-6"> | |||||
<div class="form-widget"> | <div class="form-widget"> | ||||
{{ form_label(form.multiplyingFactor) }} | {{ form_label(form.multiplyingFactor) }} | ||||
<div class="input-group"> | <div class="input-group"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-6"> | |||||
<div class="row"> | |||||
<div class="col-12"> | |||||
<label>Marge</label> | |||||
</div> | |||||
<div class="col-6"> | |||||
<div class="form-widget"> | |||||
<div class="input-group"> | |||||
<input class="form-control" disabled :value="productFamily.marginProfit"> | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">€</span> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-6"> | |||||
<div class="form-widget"> | |||||
<div class="input-group"> | |||||
<input class="form-control" disabled :value="productFamily.marginProfitPercent"> | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">%</span> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
{{ macros.priceField(form.price, form.priceWithTax, 'price', 'by-piece') }} | {{ macros.priceField(form.price, form.priceWithTax, 'price', 'by-piece') }} | ||||
{{ macros.priceField(form.priceByRefUnit, form.priceByRefUnitWithTax, 'priceByRefUnit', 'by-reference-unit') }} | {{ macros.priceField(form.priceByRefUnit, form.priceByRefUnitWithTax, 'priceByRefUnit', 'by-reference-unit') }} | ||||
<div class="form-group field-reduction-apply col-12" v-show="reductionActive"> | |||||
<div class="row"> | |||||
<div class="col-12 align-content-center"> | |||||
<h6>Réduction appliqué</h6> | |||||
</div> | |||||
<div class="col-6"> | |||||
<div class="row"> | |||||
<div class="col-12"> | |||||
<label>Marge</label> | |||||
</div> | |||||
<div class="col-6"> | |||||
<div class="form-widget"> | |||||
<div class="input-group text-danger"> | |||||
<input class="form-control text-danger" disabled :value="marginProfitWithReduction"> | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">€</span> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-6"> | |||||
<div class="form-widget"> | |||||
<div class="input-group"> | |||||
<input class="form-control text-danger" disabled | |||||
:value="marginProfitPercentWithReduction"> | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">%</span> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-6"> | |||||
<label>Prix de vente TTC</label> | |||||
<div class="form-widget"> | |||||
<div class="input-group text-danger"> | |||||
<input class="form-control text-danger" disabled :value="finalPriceWithTaxAndReduction"> | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">€</span> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{ macros.endCard() }} | {{ macros.endCard() }} | ||||
</div> | </div> |
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %} | |||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% macro printProductRow(product) %} | |||||
<tr class="lc-draggable"> | |||||
<td><i class="fa fa-fw fa-sort"></i></td> | |||||
{{ macros.product_field(2, product.title, 'title') }} | |||||
{{ macros.product_field(1, product.quantity, 'quantity') }} | |||||
{{ macros.product_field(1, product.unit, 'unit', 'unitWording') }} | |||||
{{ macros.product_field(2, product.buyingPrice, 'buyingPrice',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.buyingPriceWithTax, 'buyingPriceWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.buyingPriceByRefUnit, 'buyingPriceByRefUnit',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.buyingPriceByRefUnitWithTax, 'buyingPriceByRefUnitWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.multiplyingFactor, 'multiplyingFactor') }} | |||||
{{ macros.product_field(2, product.priceByRefUnit, 'priceByRefUnit',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.priceByRefUnitWithTax, 'priceByRefUnitWithTax',false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') ~ '\'"') }} | |||||
<td colspan="2" v-show="productFamily.behaviorPrice == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"> | |||||
{% verbatim %}{{ finalPriceWithTax }}{% endverbatim %}€ | |||||
</td> | |||||
{{ macros.product_field(2, product.price, 'price', false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.priceWithTax, 'priceWithTax', false, '€', 'v-show="productFamily.behaviorPrice == \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') ~ '\'"') }} | |||||
{{ macros.product_field(1, product.availableQuantity, 'availableQuantity',false, '', 'v-show="productFamily.behaviorCountStock== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') ~ '\'"') }} | |||||
{{ macros.product_field(1, product.availableQuantityDefault, 'availableQuantityDefault',false, '', 'v-show="productFamily.behaviorCountStock== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') ~ '\' && productFamily.behaviorStockWeek!= \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') ~ '\'"') }} | |||||
{{ macros.product_field(2, product.propertyExpirationDate, 'propertyExpirationDate','propertyExpirationDateValue', '', 'v-show="productFamily.behaviorExpirationDate== \'' ~ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') ~ '\'"') }} | |||||
<td> | |||||
<button type="button" class="btn-remove-product btn-sm btn-info" @click="modalProductForm()"> | |||||
<i class="fa fa-edit"></i> | |||||
</button> | |||||
<button type="button" class="btn-remove-product btn-sm btn-danger" @click="deleteProductForm()"> | |||||
<i class="fa fa-trash"></i> | |||||
</button> | |||||
{{ form_widget(product.position, {'attr' : {'class': "field-position"}}) }} | |||||
<div class="modal fade show" id="modal-extends-product"> | |||||
<div class="modal-dialog"> | |||||
<div class="modal-content"> | |||||
<div class="modal-header"> | |||||
<h4>{{ "group.ProductFamily.productsExtend"|trans }}</h4> | |||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||||
<span aria-hidden="true">×</span> | |||||
</button> | |||||
</div> | |||||
<div class="modal-body"> | |||||
<div class="col"> | |||||
{{ form_row(product.exportTitle) }} | |||||
</div> | |||||
<div class="col"> | |||||
{{ form_row(product.exportNote) }} | |||||
</div> | |||||
</div> | |||||
<div class="modal-footer justify-content-between"> | |||||
<button type="button" class="btn btn-info float-right" data-dismiss="modal">Ok</button> | |||||
</div> | |||||
</div> | |||||
<!-- /.modal-content --> | |||||
</div> | |||||
</div> | |||||
</td> | |||||
</tr> | |||||
{% endmacro %} | |||||
{% import _self as formMacros %} | |||||
{#{% import _self as formMacros %}#} | |||||
<div class="row"> | <div class="row"> | ||||
{{ macros.startCard(12, 'ProductFamily.products', 'light', true) }} | {{ macros.startCard(12, 'ProductFamily.products', 'light', true) }} | ||||
<table class="table datagrid sortable lc-sortable-products products-collection-table" | |||||
:data-index="formProductArray.length" | |||||
data-prototype="{{ formMacros.printProductRow(form.products.vars.prototype)|e('html_attr') }}"> | |||||
<thead> | |||||
<tr> | |||||
<th> | |||||
</th> | |||||
<th colspan="2" class="string"> | |||||
Titre | |||||
</th> | |||||
<th colspan="1" class="string "> | |||||
Quantité | |||||
</th> | |||||
<th colspan="1" class="quantity"> | |||||
Unité | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="buyingPriceByRefUnit"> | |||||
PA HT / ${ getUnitReference() } | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="priceByRefUnit"> | |||||
PA TTC / ${ getUnitReference() } | |||||
</th> | |||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
PA HT | |||||
</th> | |||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
PA TTC | |||||
</th> | |||||
<th colspan="2" class=""> | |||||
Coef | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class=""> | |||||
PV HT / ${ getUnitReference() } | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="price"> | |||||
PV TTC / ${ getUnitReference() } | |||||
</th> | |||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
PV HT | |||||
</th> | |||||
<th colspan="2" class="price"> | |||||
PV TTC | |||||
</th> | |||||
<th v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}'"> | |||||
Stock | |||||
</th> | |||||
<th v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | |||||
Stock par défaut | |||||
</th> | |||||
<th colspan="2" class="" v-show="behaviorExpirationDate== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') }}'"> | |||||
<span style="text-transform: uppercase"> ${typeExpirationDate}</span> | |||||
</th> | |||||
<th class=""> | |||||
Action | |||||
</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody class="products-collection"> | |||||
<template v-for="(formProduct, key) in formProductArray"> | |||||
<product-form ref="productForm" v-bind:product-family="productFamily" :template="formProduct" | |||||
:key-form="key"></product-form> | |||||
</template> | |||||
</tbody> | |||||
<tfoot> | |||||
<table class="table datagrid sortable lc-sortable-products products-collection-table" | |||||
:data-index="formProductArray.length" | |||||
data-prototype="{{ product_family_macros.product_row(form.products.vars.prototype)|e('html_attr') }}"> | |||||
<thead> | |||||
<tr> | |||||
<th> | <th> | ||||
Rappel | |||||
</th> | </th> | ||||
<th colspan="2" class="string"> | |||||
${title} | |||||
<th colspan="4" class="string"> | |||||
Titre | |||||
</th> | </th> | ||||
<th colspan="1" class="string "> | |||||
${productFamily.quantity} | |||||
<th colspan="2" class="string "> | |||||
Quantité | |||||
</th> | </th> | ||||
<th colspan="1" class="quantity"> | |||||
${productFamily.unitWording} | |||||
<th colspan="2" class="quantity"> | |||||
Unité | |||||
</th> | </th> | ||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="buyingPriceByRefUnit"> | |||||
${productFamily.buyingPriceByRefUnit} | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="buyingPriceByRefUnit"> | |||||
PA HT / ${ getUnitReference() } | |||||
</th> | </th> | ||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="priceByRefUnit"> | |||||
${productFamily.buyingPriceByRefUnitWithTax} | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="priceByRefUnit"> | |||||
PA TTC / ${ getUnitReference() } | |||||
</th> | </th> | ||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
${productFamily.buyingPrice} | |||||
<th colspan="3" class="price" | |||||
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
PA HT | |||||
</th> | </th> | ||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
${productFamily.buyingPriceWithTax} | |||||
<th colspan="3" class="price"> | |||||
PA TTC | |||||
</th> | </th> | ||||
<th colspan="2" class=""> | |||||
${productFamily.multiplyingFactor} | |||||
<th colspan="3" class=""> | |||||
Coef | |||||
</th> | </th> | ||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class=""> | |||||
${productFamily.priceByRefUnit} | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class=""> | |||||
PV HT / ${ getUnitReference() } | |||||
</th> | </th> | ||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" colspan="2" class="price"> | |||||
${productFamily.priceByRefUnitWithTax} | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="price"> | |||||
PV TTC / ${ getUnitReference() } | |||||
</th> | </th> | ||||
<th colspan="2" class="price" v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
${productFamily.price} | |||||
<th colspan="3" class="price" | |||||
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
PV HT | |||||
</th> | |||||
<th colspan="3" class="price"> | |||||
PV TTC | |||||
</th> | </th> | ||||
<th colspan="2" class="price"> | |||||
${productFamily.priceWithTax} | |||||
<th colspan="2"> | |||||
Marge HT | |||||
</th> | </th> | ||||
<th v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}'"> | |||||
<th colspan="2" class="" | |||||
v-show="behaviorExpirationDate== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') }}'"> | |||||
<span style="text-transform: uppercase"> ${typeExpirationDate}</span> | |||||
</th> | </th> | ||||
<th v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}'"> | |||||
Stock | |||||
</th> | </th> | ||||
<th colspan="2" class="" v-show="behaviorExpirationDate== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') }}'"> | |||||
${propertyExpirationDate} | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | |||||
Stock par défaut | |||||
</th> | </th> | ||||
<th class=""> | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' || behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}'"> | |||||
Semaine / Commandés | |||||
</th> | </th> | ||||
</tfoot> | |||||
</table> | |||||
<button type="button" class="add_tag_link btn-add-product btn btn-default" @click="addProductForm"><span | |||||
class="fa fa-plus"></span> Ajouter une déclinaison | |||||
</button> | |||||
<div class="clearfix"></div> | |||||
{{ macros.endCard() }} | |||||
</div> | |||||
{% do form.products.setRendered %} | |||||
<script> | |||||
window.productForm = new Array(); | |||||
window.formProductTemplate = new Array(); | |||||
{% for keyForm,i in sortableProductsField %} | |||||
{% set product = form.products[i] %} | |||||
window.productForm[{{ keyForm }}] = { | |||||
{% if product.vars.value.title %}title: "{{ product.vars.value.title }}",{% endif %} | |||||
{% if product.vars.value.quantity %}quantity: "{{ product.vars.value.quantity }}",{% endif %} | |||||
{% if product.vars.value.unit %}unit: {{ product.vars.value.unit.id }},{% endif %} | |||||
{% if product.vars.value.buyingPrice %}buyingPrice: parseFloat({{ product.vars.value.buyingPrice }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.buyingPriceByRefUnit %}buyingPriceByRefUnit: parseFloat({{ product.vars.value.buyingPriceByRefUnit }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.price %}price: parseFloat({{ product.vars.value.price }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.priceByRefUnit %}priceByRefUnit: parseFloat({{ product.vars.value.priceByRefUnit }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %} | |||||
{% if product.vars.value.availableQuantityDefault %}availableQuantityDefault: parseInt({{ product.vars.value.availableQuantityDefault }}),{% endif %} | |||||
{% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %} | |||||
{#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#} | |||||
}; | |||||
window.formProductTemplate[{{ keyForm }}] = '{{ formMacros.printProductRow(product)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; | |||||
{% endfor %} | |||||
<th colspan="2" class=""> | |||||
Action | |||||
</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody class="products-collection"> | |||||
<template v-for="(formProduct, key) in formProductArray"> | |||||
<product-form ref="productForm" v-bind:product-family="productFamily" :template="formProduct" | |||||
:key-form="key"></product-form> | |||||
</template> | |||||
</tbody> | |||||
<tfoot> | |||||
<th> | |||||
Rappel | |||||
</th> | |||||
<th colspan="4" class="string"> | |||||
${title} | |||||
</th> | |||||
<th colspan="2" class="string "> | |||||
${productFamily.quantity} | |||||
</th> | |||||
<th colspan="2" class="quantity"> | |||||
${productFamily.unitWording} | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="buyingPriceByRefUnit"> | |||||
${productFamily.buyingPriceByRefUnit} | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="priceByRefUnit"> | |||||
${productFamily.buyingPriceByRefUnitWithTax} | |||||
</th> | |||||
<th colspan="3" class="price" | |||||
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
${productFamily.buyingPrice} | |||||
</th> | |||||
<th colspan="3" class="price"> | |||||
${productFamily.buyingPriceWithTax} | |||||
</th> | |||||
<th colspan="3" class=""> | |||||
${productFamily.multiplyingFactor} | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class=""> | |||||
${productFamily.priceByRefUnit} | |||||
</th> | |||||
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'" | |||||
colspan="3" class="price"> | |||||
${productFamily.priceByRefUnitWithTax} | |||||
</th> | |||||
<th colspan="3" class="price" | |||||
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'"> | |||||
${productFamily.price} | |||||
</th> | |||||
<th colspan="3" class="price"> | |||||
${productFamily.priceWithTax} | |||||
</th> | |||||
<th colspan="2" class="price"> | |||||
${productFamily.marginProfit}€<br /> | |||||
${productFamily.marginProfitPercent}% | |||||
</td> | |||||
</script> | |||||
<th colspan="2" class="" | |||||
v-show="behaviorExpirationDate== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT') }}'"> | |||||
${propertyExpirationDate} | |||||
</th> | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}'"> | |||||
</th> | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | |||||
</th> | |||||
<th colspan="2" | |||||
v-show="behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT') }}' || behaviorCountStock== '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE') }}'"> | |||||
</th> | |||||
<th colspan="2" class=""> | |||||
</th> | |||||
</tfoot> | |||||
</table> | |||||
<button type="button" class="add_tag_link btn-add-product btn btn-default" @click="addProductForm"><span | |||||
class="fa fa-plus"></span> Ajouter une déclinaison | |||||
</button> | |||||
<p> | |||||
<strong>Aide à l'utilisation - Raccourci clavier</strong> | |||||
<ul> | |||||
<li><strong>TAB</strong> : Champ suivant</li> | |||||
<li><strong>SHIFT + TAB</strong> : Champ précédent</li> | |||||
<li><strong>FLÈCHE BAS</strong> : Déclinaison suivante</li> | |||||
<li><strong>FLÈCHE HAUT</strong> : Déclinaison précédente</li> | |||||
<li><strong>SHIFT + [+]</strong> : Ajout d'une nouvelle déclinaison</li> | |||||
</ul> | |||||
</p> | |||||
<div class="clearfix"></div> | |||||
{{ macros.endCard() }} | |||||
</div> | |||||
{% do form.products.setRendered %} | |||||
<script> | |||||
window.productForm = new Array(); | |||||
window.formProductTemplate = new Array(); | |||||
{% for keyForm,i in sortableProductsField %} | |||||
{% set product = form.products[i] %} | |||||
window.productForm[{{ keyForm }}] = { | |||||
{% if product.vars.value.title %}title: "{{ product.vars.value.title }}",{% endif %} | |||||
{% if product.vars.value.quantity %}quantity: "{{ product.vars.value.quantity }}",{% endif %} | |||||
{% if product.vars.value.unit %}unit: {{ product.vars.value.unit.id }},{% endif %} | |||||
{% if product.vars.value.buyingPrice %}buyingPrice: parseFloat({{ product.vars.value.buyingPrice }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.buyingPriceByRefUnit %}buyingPriceByRefUnit: parseFloat({{ product.vars.value.buyingPriceByRefUnit }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.price %}price: parseFloat({{ product.vars.value.price }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.priceByRefUnit %}priceByRefUnit: parseFloat({{ product.vars.value.priceByRefUnit }}).toFixed(3),{% endif %} | |||||
{% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %} | |||||
{% if product.vars.value.availableQuantityDefault %}availableQuantityDefault: parseInt({{ product.vars.value.availableQuantityDefault }}),{% endif %} | |||||
{% if product.vars.value.propertyExpirationDate %}propertyExpirationDate: "{{ product.vars.value.propertyExpirationDate }}",{% endif %} | |||||
{#{% if product.vars.value.expirationDate %}expirationDate: "{{ product.vars.value.expirationDate|date('d/m/Y') }}"{% endif %}#} | |||||
}; | |||||
window.formProductTemplate[{{ keyForm }}] = '{{ product_family_macros.product_row(product, totalProductOrdered[product.vars.value.id])|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}'; | |||||
{% endfor %} | |||||
</script> | |||||
{% trans_default_domain 'lcshop' %} | {% trans_default_domain 'lcshop' %} | ||||
{% import '@LcShop/backend/productfamily/macros.html.twig' as product_family_macros %} | |||||
{% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | {% import '@LcShop/backend/default/block/macros.html.twig' as macros %} | ||||
<div class="row"> | <div class="row"> | ||||
{{ macros.startCard(8, 'ProductFamily.stock', 'light') }} | {{ macros.startCard(8, 'ProductFamily.stock', 'light') }} | ||||
</div> | </div> | ||||
{{ form_help(form.availableQuantity) }} | {{ form_help(form.availableQuantity) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div 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') }}') && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | <div 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') }}') && behaviorStockWeek!= '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE') }}'"> | ||||
{{ form_label(form.availableQuantityDefault) }} | {{ form_label(form.availableQuantityDefault) }} | ||||
{{ 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') }}' "> | |||||
{% for quantityProductsOrder in totalProductOrdered %} | |||||
{{ product_family_macros.total_order_product(quantityProductsOrder) }} | |||||
{% endfor %} | |||||
</p> | |||||
</div> | </div> | ||||
{{ macros.endCard() }} | {{ macros.endCard() }} | ||||
{{ macros.endCard() }} | {{ macros.endCard() }} | ||||
{{ macros.startCard(8, 'ProductFamily.export', 'light') }} | |||||
<div class="col"> | |||||
{{ form_row(form.exportTitle) }} | |||||
{{ form_row(form.exportNote) }} | |||||
</div> | |||||
{{ macros.endCard() }} | |||||
</div> | </div> |