瀏覽代碼

Merge branch 'master' of https://gitea.laclic.fr/Laclic/LcShopBundle

# Conflicts:
#	ShopBundle/Resources/translations/lcshop.fr.yaml
master
Guillaume 4 年之前
父節點
當前提交
c99a691837
共有 12 個檔案被更改,包括 74 行新增77 行删除
  1. +10
    -9
      ShopBundle/Controller/Admin/ProductFamilyController.php
  2. +8
    -15
      ShopBundle/Form/ProductType.php
  3. +7
    -6
      ShopBundle/Model/SortableTrait.php
  4. +14
    -0
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  5. +0
    -13
      ShopBundle/Resources/public/js/backend/script/default/init-edit.js
  6. +2
    -1
      ShopBundle/Resources/public/js/backend/script/default/init-list.js
  7. +1
    -3
      ShopBundle/Resources/public/js/backend/script/default/init-sort.js
  8. +2
    -1
      ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js
  9. +13
    -10
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  10. +2
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  11. +7
    -2
      ShopBundle/Resources/views/backend/default/list.html.twig
  12. +8
    -17
      ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig

+ 10
- 9
ShopBundle/Controller/Admin/ProductFamilyController.php 查看文件

@@ -134,10 +134,12 @@ class ProductFamilyController extends AdminController
{
$productFamilyRequest = $this->request->request->get('productfamily');

$taxRateId = intval($productFamilyRequest['taxRate']);
if ($taxRateId > 0) {
$repo = $this->em->getRepository(TaxRateInterface::class);
$entity->setTaxRate($repo->find($taxRateId));
if(isset($productFamilyRequest['taxRate'])) {
$taxRateId = intval($productFamilyRequest['taxRate']);
if ($taxRateId > 0) {
$repo = $this->em->getRepository(TaxRateInterface::class);
$entity->setTaxRate($repo->find($taxRateId));
}
}

$unitId = intval($productFamilyRequest['unit']);
@@ -164,27 +166,26 @@ class ProductFamilyController extends AdminController

protected function processProducts($entity)
{
$repo = $this->em->getRepository(UnitInterface::class);
//si il existe un et un seul produit pour ce product family n'ajoute rien supprime rien
if (count($entity->getProducts()) == 0) {
$product = new Product();
$product->setCreatedBy($this->getUser());
$product->setUpdatedBy($this->getUser());
$product->setProductFamily($entity);
$this->em->persist($product);

$entity->addProduct($product);
} else {

foreach ($entity->getProducts() as $product) {
foreach ($entity->getProducts() as $i=>$product) {

$product->setProductFamily($entity);
$product->setCreatedBy($this->getUser());
$product->setUpdatedBy($this->getUser());
$this->em->persist($product);
$entity->addProduct($product);

// die('ncici');
}
}

}

protected function processCategories(ProductFamilyInterface $entity)

+ 8
- 15
ShopBundle/Form/ProductType.php 查看文件

@@ -10,6 +10,7 @@ use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UnitInterface;
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;
@@ -26,6 +27,7 @@ class ProductType extends AbstractType
protected $em;
protected $utils;


public function __construct(EntityManagerInterface $entityManager, Utils $utils)
{
$this->em = $entityManager;
@@ -48,25 +50,16 @@ class ProductType extends AbstractType
]
));


$this->choicesUnitsReference = [];
$unitClass = $this->em->getClassMetadata(UnitInterface::class)->getName();
foreach ($this->em->getRepository($unitClass)->findAll() as $unit) {
$choicesUnits[$unit->getWording()] = $unit->getId();
$this->choicesUnitsReference[$unit->getId()]['unit-reference'] = $unit->getUnitReference();
$this->choicesUnitsReference[$unit->getId()]['coefficient'] = $unit->getCoefficient();
}

$builder->add('unit', ChoiceType::class, array(
'label' => 'TVA du fournisseur',
'choices' => $choicesUnits,

$builder->add('unit', EntityType::class, array(
'class'=> $unitClass,
'data' => 0,
'required'=>false,
'mapped' => false,
'choice_attr' => function ($choice, $key, $value) {
'choice_attr' => function ($choice) {
return [
'data-unit-reference' => $this->choicesUnitsReference[$choice]['unit-reference'],
'data-coefficient' => $this->choicesUnitsReference[$choice]['coefficient']
'data-unit-reference' => $choice->getUnitReference(),
'data-coefficient' => $choice->getCoefficient()
];
},
));

+ 7
- 6
ShopBundle/Model/SortableTrait.php 查看文件

@@ -4,30 +4,31 @@ namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use phpDocumentor\Reflection\Types\Integer;

trait SortableTrait
{
/**
* @var string
* @ORM\Column(type="string")
* @ORM\Column(type="float")
*/
protected $position = 0;

/**
* @return string
* @return float
*/
public function getPosition(): string
public function getPosition(): float
{
return $this->position;
}

/**
* @param string $position
* @param float $position
* @return $this
*/
public function setPosition(string $position): self
public function setPosition(float $position): self
{
$this->position = $position;
return $this;
}
}
}

+ 14
- 0
ShopBundle/Resources/public/js/backend/script/default/init-common.js 查看文件

@@ -108,3 +108,17 @@ function setSelect2($select) {
return myselect;
}
}

function checkForm(){
$('form').addClass('form-sent');
//Panel vues js
if($('form').find('.panel').length){
$('form').find('.panel').each(function(i, panel){
if($(panel).find(':invalid').length){
$('#nav-params').find('.nav-item:eq('+i+')').addClass('has-invalid');
}else{
$('#nav-params').find('.nav-item:eq('+i+')').removeClass('has-invalid');
}
})
}
}

+ 0
- 13
ShopBundle/Resources/public/js/backend/script/default/init-edit.js 查看文件

@@ -15,19 +15,6 @@ jQuery(document).ready(function () {
});
});

function checkForm(){
$('form').addClass('form-sent');
//Panel vues js
if($('form').find('.panel').length){
$('form').find('.panel').each(function(i, panel){
if($(panel).find(':invalid').length){
$('#nav-params').find('.nav-item:eq('+i+')').addClass('has-invalid');
}else{
$('#nav-params').find('.nav-item:eq('+i+')').removeClass('has-invalid');
}
})
}
}

/* CKEditor */


+ 2
- 1
ShopBundle/Resources/public/js/backend/script/default/init-list.js 查看文件

@@ -64,9 +64,10 @@ function initDataTable() {
$(this).html('')
}
});
log();
var table = $(".table.datatable-simple").DataTable({
orderCellsTop: true,
order: [[$('th.sorted').data('index'), 'asc']],
fixedHeader: {
header: true,
headerOffset: $('.main-header').outerHeight(),

+ 1
- 3
ShopBundle/Resources/public/js/backend/script/default/init-sort.js 查看文件

@@ -22,11 +22,9 @@ function initLcSortableList() {

$(li).append(newForm);
$(li).find('#form_entities_' + index + '_id').val($(li).data('id'));
if ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '_' + index
if ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '.' + index
else val = index;

log($(li).find('#form_entities_' + index + '_position'));

$(li).find('#form_entities_' + index + '_position').val(val);
});


+ 2
- 1
ShopBundle/Resources/public/js/backend/script/default/vuejs-mixins.js 查看文件

@@ -92,12 +92,13 @@ let mixinPrice = {
this.priceUpdate('price');
},
setMultiplyingFactor: function () {
log('SETFACTOR')
if (this.priceWithTax && this.buyingPrice) {
this.multiplyingFactor = parseFloat(this.priceWithTaxValue / this.buyingPriceValue).toFixed(3);
}
},
priceByRefUnitUpdate: function () {

if (this.unitCoefficient && this.quantityValue) {
this.priceByRefUnit = parseFloat((this.priceValue / this.quantityValue) * this.unitCoefficient).toFixed(2);
this.priceByRefUnitWithTax = parseFloat((this.priceWithTaxValue / this.quantityValue) * this.unitCoefficient).toFixed(2);

+ 13
- 10
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js 查看文件

@@ -86,8 +86,7 @@ Vue.component('product-form', {
else return this.productFamily.unit;
},
propertyExpirationDateFormated: function () {
log(this.propertyExpirationDate)
log(this.productFamily.propertyExpirationDate)

if (this.propertyExpirationDate) return getDateFormatted(this.propertyExpirationDate, '-')
else return getDateFormatted(this.productFamily.propertyExpirationDate, '-')
}
@@ -121,12 +120,9 @@ Vue.component('product-form', {
}, window.productForm[this.keyForm])
},
mounted: function () {
//INIT VAR
//INIT VAR
updateSortableProducts();


$(this.$el).find('select').each(function (i, select) {
log($(select).parents('td'));
setSelect2($(select));
});

@@ -136,7 +132,12 @@ Vue.component('product-form', {
this.updateProductView();
},
methods: {
updateLine: function(){
this.changePriceWithTax();
this.changeBuyingPriceWithTax();
},
updateProductForm: function () {

this.changePriceWithTax();
this.changeBuyingPriceWithTax();
//EDIT UNIT
@@ -144,7 +145,8 @@ Vue.component('product-form', {

updateProductView: function () {

if (this.unitValue == 'piece') {

/*if (this.unitValue == 'piece') {
$('.priceByRefUnit').hide();
} else {
$('.priceByRefUnit').show();
@@ -154,7 +156,7 @@ Vue.component('product-form', {
} else {
$('.products-collection-table').find('.stock').show();
$('#product-item-' + this.keyForm).find('.stock').html(this.availableQuantity + ' / ' + this.unitReference);
}
}*/
},
saveProductForm: function () {
this.updateProductView();
@@ -167,7 +169,8 @@ Vue.component('product-form', {
},
},
watch: {
titleInherited: function (val) {
/*titleInherited: function (val) {

if (val) this.title = null;
},
unitInherited: function (val) {
@@ -178,7 +181,7 @@ Vue.component('product-form', {
},
priceInherited: function (val) {
if (val) this.price = null;
},
},*/
}
});


+ 2
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml 查看文件

@@ -121,6 +121,8 @@ field:
subscribeNewsletter: S'inscrire à la newsletter
send: Envoyer

Supplier:
user: Utilisateur lié

ProductFamily:
taxRateInherited: Utiliser la TVA par défaut

+ 7
- 2
ShopBundle/Resources/views/backend/default/list.html.twig 查看文件

@@ -114,11 +114,14 @@
{% block table_head %}

<tr>
{% set i=0 %}
{% if _has_batch_actions %}
<th width="1px"><span><input type="checkbox" class="form-batch-checkbox-all"></span></th>
<th data-index="{{ i }}" width="1px"><span><input type="checkbox" class="form-batch-checkbox-all"></span></th>
{% set i=1 %}
{% endif %}

{% for field, metadata in _fields_visible_by_user %}

{% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %}
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'DESC' %}
{% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
@@ -136,13 +139,15 @@
{% endif %}

{#<th class="{{ isSortingField ? 'sorted' }} {{ metadata.virtual ? 'virtual' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" >#}
<th data-searchable="{{ searchable }}" >
<th data-index="{{ i }}" class="{{ isSortingField ? 'sorted' }}" data-searchable="{{ searchable }}" >

{% if metadata.sortable %}
{{ metadata.fieldName|lc_trad(_entity_config['name']) }}
{% else %}
<span>{{ metadata.fieldName|lc_trad(_entity_config['name']) }}</span>
{% endif %}
</th>
{% set i= i +1 %}
{% endfor %}

{% if _list_item_actions|length > 0 %}

+ 8
- 17
ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig 查看文件

@@ -28,7 +28,7 @@
</div>
</div>
<div v-show="quantityInherited == true">
{{ form_widget(product.quantity, {'attr' : {'v-model' : 'quantity', 'v-on:focusout': 'quantityInherited = false'}}) }}
{{ form_widget(product.quantity, {'attr' : {'v-model' : 'quantity', 'v-on:focusout': 'quantityInherited = false', '@change' : 'updateLine'}}) }}
</div>
</td>

@@ -42,7 +42,7 @@
</div>
</div>
<div v-show="unitInherited == true">
{{ form_widget(product.unit, {'attr' : {'v-model' : 'unit', 'v-on:focusout': 'unitInherited = false'}}) }}
{{ form_widget(product.unit, {'attr' : {'v-model' : 'unit', 'v-on:focusout': 'unitInherited = false', '@change' : 'updateLine'}}) }}
</div>
</td>

@@ -115,22 +115,12 @@
</div>
</td>

<td colspan="2" class="priceByRefUnit">
<div v-if="priceByRefUnit">
{# <td colspan="2" class="priceByRefUnit">
{% verbatim %}{{ priceByRefUnit }}€{% endverbatim %}
</div>
<div v-else class="inherited">
{% verbatim %}{{ productFamily.priceByRefUnit }}€{% endverbatim %}
</div>
</td>
<td colspan="2" class="priceByRefUnit priceByRefUnitWithTax">
<div v-if="priceByRefUnitWithTax">
{% verbatim %}{{ priceByRefUnitWithTax }}€{% endverbatim %}
</div>
<div v-else class="inherited">
{% verbatim %}{{ productFamily.priceByRefUnitWithTax }}€{% endverbatim %}
</div>
</td>
</td>#}


<td v-show="productFamily.behaviorCountStock== 'by-product'" class="stock availableQuantity " v-on:click="availableQuantityInherited = true">
@@ -220,12 +210,12 @@
<th colspan="2" class="price">
PV TTC
</th>
<th colspan="2" class="priceByRefUnit">
{# <th colspan="2" class="priceByRefUnit">
PV HT / ${ getUnitReference() }
</th>
<th colspan="2" class="priceByRefUnit">
PV TTC / ${ getUnitReference() }
</th>
</th>#}

<th v-show="behaviorCountStock== 'by-product'">
Stock
@@ -270,7 +260,7 @@
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 }}",{% endif %}
{% if product.vars.value.unit %}unit: {{ product.vars.value.unit.id }},{% endif %}
{% if product.vars.value.buyingPrice %}buyingPrice: "{{ product.vars.value.buyingPrice }}",{% endif %}
{% if product.vars.value.price %}price: parseFloat({{ product.vars.value.price }}).toFixed(3),{% endif %}
{% if product.vars.value.availableQuantity %}availableQuantity: parseInt({{ product.vars.value.availableQuantity }}),{% endif %}
@@ -279,5 +269,6 @@
};
window.formProductTemplate[{{ keyForm }}] = '{{ formMacros.printProductRow(product)|replace({"\n":' ', "\r":' ', "'" : "\\'"})|raw }}';
{% endfor %}

</script>


Loading…
取消
儲存