Guillaume 4 years ago
parent
commit
4fd965b730
6 changed files with 175 additions and 96 deletions
  1. +115
    -68
      ShopBundle/Model/ProductFamily.php
  2. +1
    -1
      ShopBundle/Model/ProductPropertyTrait.php
  3. +1
    -1
      ShopBundle/Repository/PointSaleRepository.php
  4. +22
    -21
      ShopBundle/Resources/public/js/backend/script/default/init-list.js
  5. +3
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  6. +33
    -5
      ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig

+ 115
- 68
ShopBundle/Model/ProductFamily.php View File

@@ -14,7 +14,6 @@ use Lc\ShopBundle\Context\ProductPropertyInterface;
/**
* @ORM\MappedSuperclass()
*/

abstract class ProductFamily extends AbstractDocumentEntity implements ProductPropertyInterface, PriceInterface, FilterMerchantInterface
{
use ProductPropertyTrait;
@@ -63,7 +62,7 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $warningMessageType;
protected $warningMessageType;

/**
* @ORM\Column(type="text", nullable=true)
@@ -105,6 +104,21 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
*/
protected $propertyFragrances;

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

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

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

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
@@ -128,11 +142,10 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

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

@@ -236,26 +249,26 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

public function getProductCategoryParent()
{
$productCategories = $this->getProductCategories() ;
$productCategories = $this->getProductCategories();

if(count($productCategories) > 0) {
return $productCategories[0]->getParent() ;
if (count($productCategories) > 0) {
return $productCategories[0]->getParent();
}

return false ;
return false;
}

public function getProductCategoryChild()
{
$productCategories = $this->getProductCategories() ;
$productCategories = $this->getProductCategories();

foreach($productCategories as $productCategory) {
if($productCategory->getParent()) {
return $productCategory ;
foreach ($productCategories as $productCategory) {
if ($productCategory->getParent()) {
return $productCategory;
}
}

return false ;
return false;
}

public function getSupplierTaxRate(): ?TaxRate
@@ -345,54 +358,51 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
}




private function getCheapestOrMostExpensiveProduct($comparisonFunction, $returnSelfIfNotActiveProducts)
{
$products = $this->getProducts()->getValues() ;
if(count($products) > 0) {
usort($products, $comparisonFunction) ;
return $products[0] ;
$products = $this->getProducts()->getValues();
if (count($products) > 0) {
usort($products, $comparisonFunction);
return $products[0];
}
if($returnSelfIfNotActiveProducts) {
return $this ;
}
else {
return false ;
if ($returnSelfIfNotActiveProducts) {
return $this;
} else {
return false;
}
}

public function getCheapestProduct()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceInherited() > $b->getPriceInherited() ;
},true) ;
return $this->getCheapestOrMostExpensiveProduct(function ($a, $b) {
return $a->getPriceInherited() > $b->getPriceInherited();
}, true);
}

public function getCheapestProductByUnitRef()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceByUnitRef() > $b->getPriceByUnitRef() ;
},false) ;
return $this->getCheapestOrMostExpensiveProduct(function ($a, $b) {
return $a->getPriceByUnitRef() > $b->getPriceByUnitRef();
}, false);
}

public function getMostExpensiveProductByUnitRef()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceByUnitRef() < $b->getPriceByUnitRef() ;
},false) ;
return $this->getCheapestOrMostExpensiveProduct(function ($a, $b) {
return $a->getPriceByUnitRef() < $b->getPriceByUnitRef();
}, false);
}

public function isPropertyNoveltyOnline(): ?bool
{
if($this->getPropertyNoveltyExpirationDate()) {
$now = new \DateTime() ;
if($now <= $this->getPropertyNoveltyExpirationDate()) {
return true ;
if ($this->getPropertyNoveltyExpirationDate()) {
$now = new \DateTime();
if ($now <= $this->getPropertyNoveltyExpirationDate()) {
return true;
}
}

return false ;
return false;
}

public function getPropertyNoveltyExpirationDate(): ?\DateTimeInterface
@@ -457,15 +467,15 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

public function countProperties(): bool
{
$count = 0 ;
$count = 0;

$count += (int) strlen($this->getPropertyAllergens()) > 0 ;
$count += (int) strlen($this->getPropertyComposition()) > 0 ;
$count += (int) strlen($this->getPropertyFragrances()) > 0 ;
$count += (int) strlen($this->getPropertyOrganicLabel()) > 0 ;
$count += (int) ($this->getPropertyExpirationDate() != null) ;
$count += (int)strlen($this->getPropertyAllergens()) > 0;
$count += (int)strlen($this->getPropertyComposition()) > 0;
$count += (int)strlen($this->getPropertyFragrances()) > 0;
$count += (int)strlen($this->getPropertyOrganicLabel()) > 0;
$count += (int)($this->getPropertyExpirationDate() != null);

return $count ;
return $count;
}

public function getBehaviorExpirationDate(): ?string
@@ -492,6 +502,43 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}


public function getPropertyWeightQuantity(): ?string
{
return $this->propertyWeightQuantity;
}

public function setPropertyWeightQuantity(?string $propertyWeightQuantity): self
{
$this->propertyWeightQuantity = $propertyWeightQuantity;

return $this;
}

public function getPropertyPackaging(): ?string
{
return $this->propertyPackaging;
}

public function setPropertyPackaging(?string $propertyPackaging): self
{
$this->propertyPackaging = $propertyPackaging;

return $this;
}

public function getPropertyCharacteristics(): ?string
{
return $this->propertyCharacteristics;
}

public function setPropertyCharacteristics(?string $propertyCharacteristics): self
{
$this->propertyCharacteristics = $propertyCharacteristics;

return $this;
}

public function getBehaviorAddToCart(): ?string
{
return $this->behaviorAddToCart;
@@ -506,42 +553,42 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

public function hasProductsWithVariousWeight()
{
if($this->getActiveProducts()) {
$arrayCountProducts = [] ;
$products = $this->getProducts() ;
if ($this->getActiveProducts()) {
$arrayCountProducts = [];
$products = $this->getProducts();

foreach($products as $product) {
$titleProduct = $product->getTitleInherited() ;
if(!isset($arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct] = [] ;
foreach ($products as $product) {
$titleProduct = $product->getTitleInherited();
if (!isset($arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct] = [];
}

if(!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited() ;
if (!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited();
}

if(count($arrayCountProducts[$titleProduct]) > 1) {
return true ;
if (count($arrayCountProducts[$titleProduct]) > 1) {
return true;
}
}
}

return false ;
return false;
}

public function getProductsGroupByTitle()
{
$arrayProductsGroupByTitle = [] ;
$products = $this->getProducts() ;
$arrayProductsGroupByTitle = [];
$products = $this->getProducts();

foreach($products as $product) {
$titleProduct = $product->getTitleInherited() ;
if(!isset($arrayProductsGroupByTitle[$titleProduct])) {
$arrayProductsGroupByTitle[$titleProduct] = [] ;
foreach ($products as $product) {
$titleProduct = $product->getTitleInherited();
if (!isset($arrayProductsGroupByTitle[$titleProduct])) {
$arrayProductsGroupByTitle[$titleProduct] = [];
}
$arrayProductsGroupByTitle[$titleProduct][] = $product ;
$arrayProductsGroupByTitle[$titleProduct][] = $product;
}

return $arrayProductsGroupByTitle ;
return $arrayProductsGroupByTitle;
}
}

+ 1
- 1
ShopBundle/Model/ProductPropertyTrait.php View File

@@ -31,7 +31,7 @@ trait ProductPropertyTrait
protected $availableQuantityDefault;

/**
* @ORM\Column(type="date", nullable=true)
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $propertyExpirationDate;


+ 1
- 1
ShopBundle/Repository/PointSaleRepository.php View File

@@ -24,7 +24,7 @@ class PointSaleRepository extends BaseRepository implements DefaultRepositoryInt
return $this->createQueryBuilder('e')
->where(':currentMerchant MEMBER OF e.merchants')
->andWhere('e.isPublic = 1')
->andWhere('e.status > 0')
->andWhere('e.status = 1')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent())
->getQuery()
->getResult() ;

+ 22
- 21
ShopBundle/Resources/public/js/backend/script/default/init-list.js View File

@@ -1,30 +1,31 @@
jQuery(document).ready(function () {

initDeleteAction();

initDataTable();
//generateNotice('error', 'Ceci est une notice');
$('a.action-delete').on('click', function(e) {
e.preventDefault();

$('#modal-delete').modal({ backdrop: true, keyboard: true })
.off('click', '#modal-delete-button')
.on('click', '#modal-delete-button', function () {
$('#delete-form').trigger('submit');
});
});
});

$('.action-delete').on('click', function(e) {
e.preventDefault();
const id = $(this).parents('tr').first().data('id');

$('#modal-delete').modal({ backdrop: true, keyboard: true })
.off('click', '#modal-delete-button')
.on('click', '#modal-delete-button', function () {
let deleteForm = $('#delete-form');
deleteForm.attr('action', deleteForm.attr('action').replace('__id__', id));
deleteForm.trigger('submit');
});
function initDeleteAction() {

$('.action-delete').each(function (){
$(this).on('click', function (e) {
e.preventDefault();
log('ncnecd')
const id = $(this).parents('tr').first().data('id');

$('#modal-delete').modal({backdrop: true, keyboard: true})
.off('click', '#modal-delete-button')
.on('click', '#modal-delete-button', function () {
let deleteForm = $('#delete-form');
deleteForm.attr('action', deleteForm.attr('action').replace('__id__', id));
deleteForm.trigger('submit');
});
});
});
});
}


function initDataTable() {
if ($(".table.datatable-simple").length > 0) {
@@ -64,7 +65,7 @@ function initDataTable() {
$(this).html('')
}
});
log();
var table = $(".table.datatable-simple").DataTable({
orderCellsTop: true,
order: [[$('th.sorted').data('index'), 'asc']],

+ 3
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -142,6 +142,9 @@ field:
propertyNoveltyExpirationDateActive: Marquer le produit comme "nouveauté" jusqu'au
propertyOrganicLabelActive: Marquer le produit comme "labellisé"
propertyLargeVolume: Marquer le produit comme "gros volume"
propertyCharacteristics: Caractéristiques
propertyPackaging: Conditionnement
propertyWeightQuantity: Poids/quantité
behaviorCountStockOptions:
byQuantity: Gérer le stock par quantité
byProductFamily: Gérer le stock par produit (à l'unité)

+ 33
- 5
ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig View File

@@ -48,7 +48,7 @@
</tr>
</thead>
<tbody>
<tr v-show="typeExpirationDate != ''">
<tr v-show="typeExpirationDate != null && typeExpirationDate != ''">
<td><label style="text-transform: uppercase">${typeExpirationDate}</label></td>
<td>{{ form_widget(form.propertyExpirationDate, {'attr' : {'v-model' : 'propertyExpirationDate'}}) }}</td>
</tr>
@@ -82,6 +82,30 @@
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyWeightQuantity) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyWeightQuantity, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyCharacteristics) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyCharacteristics, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyPackaging) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyPackaging, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>

</tbody>
</table>
@@ -92,15 +116,19 @@

<div class="col">


{{ form_label(form.typeExpirationDate) }}
{% for field in form.typeExpirationDate %}
{{ form_widget(field, {"attr" : {"v-model" : 'typeExpirationDate'}}) }}
{% endfor %}

{{ form_label(form.behaviorExpirationDate) }}
{% for field in form.behaviorExpirationDate %}
{{ form_widget(field, {"attr" : {"v-model" : 'behaviorExpirationDate'}}) }}
{% endfor %}

<div class="form-group" v-show="typeExpirationDate != null && typeExpirationDate != ''">
{{ form_label(form.behaviorExpirationDate) }}
{% for field in form.behaviorExpirationDate %}
{{ form_widget(field, {"attr" : {"v-model" : 'behaviorExpirationDate'}}) }}
{% endfor %}
</div>

</div>


Loading…
Cancel
Save