Browse Source

Produit stock negatif

feature/export_comptable
Fab 4 years ago
parent
commit
599eb48885
6 changed files with 91 additions and 6 deletions
  1. +7
    -5
      ShopBundle/Controller/Backend/AdminController.php
  2. +3
    -0
      ShopBundle/Repository/ProductFamilyRepository.php
  3. +33
    -0
      ShopBundle/Repository/ProductRepository.php
  4. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +31
    -0
      ShopBundle/Resources/views/backend/default/block/list_products.html.twig
  6. +16
    -1
      ShopBundle/Resources/views/backend/default/block/macros.html.twig

+ 7
- 5
ShopBundle/Controller/Backend/AdminController.php View File

$latsPos = $elm['position']; $latsPos = $elm['position'];


} }
dump($latsPos);
//die(); //die();
//to do récupérer les élements hors ligne et incrémenter position //to do récupérer les élements hors ligne et incrémenter position
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { /*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
} }


public function createNewEntity(){
/* public function createNewEntity(){
$idDuplicate = $this->request->query->get('duplicate', null); $idDuplicate = $this->request->query->get('duplicate', null);
if($idDuplicate){ if($idDuplicate){
$easyadmin = $this->request->attributes->get('easyadmin'); $easyadmin = $this->request->attributes->get('easyadmin');
return new $entityFullyQualifiedClassName(); return new $entityFullyQualifiedClassName();
} }


}
}*/


public function duplicateAction(){ public function duplicateAction(){
$id = $this->request->query->get('id'); $id = $this->request->query->get('id');
$refererUrl = $this->request->query->get('referer', ''); $refererUrl = $this->request->query->get('referer', '');




$entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id); $entity= $this->em->getRepository($easyadmin['entity']['class'])->find($id);


$newProductFamily = clone $entity ;
$newEntity = clone $entity ;


$this->em->persist($newProductFamily) ;
$this->em->persist($newEntity) ;
$this->em->flush() ; $this->em->flush() ;


return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newProductFamily->getId(), 'referer' =>$refererUrl ]) ;
return $this->redirectToRoute('easyadmin', ['entity' => $easyadmin['entity']['name'], 'action' => 'edit', 'id' =>$newEntity->getId(), 'referer' =>$refererUrl ]) ;
} }
} }



+ 3
- 0
ShopBundle/Repository/ProductFamilyRepository.php View File

use Lc\ShopBundle\Context\DefaultRepositoryInterface; use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface; use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface; use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Model\ProductFamily;


/** /**
* @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null) * @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null)
} }






} }

+ 33
- 0
ShopBundle/Repository/ProductRepository.php View File



use Lc\ShopBundle\Context\DefaultRepositoryInterface; use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\ProductInterface; use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Model\ProductFamily;


/** /**
* @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null) * @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null)
return ProductInterface::class; return ProductInterface::class;
} }



public function findProductByAvailabilitiesNegative()
{
$qb = $this->createQueryBuilder('e');
$qb->innerJoin('e.productFamily', 'productFamily');
$qb->addSelect('productFamily');
$qb->where('productFamily.merchant = :currentMerchant');
$qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId());

$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->andX(
$qb->expr()->orX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
),
'productFamily.availableQuantity < 0 '
),
$qb->expr()->andX(
'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
'e.availableQuantity < 0 '
)
)
);
$qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY);
$qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
$qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
$qb->groupBy('productFamily.id');

return $qb->getQuery()->getResult();
}

} }

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

parameters: Paramètres parameters: Paramètres
initReduction: Réduction initReduction: Réduction
export: Note à l'export export: Note à l'export
stockNegative: Produits stocks négatif
ReductionCatalog: ReductionCatalog:
info: Informations principal info: Informations principal
conditions: Conditions d'application conditions: Conditions d'application

+ 31
- 0
ShopBundle/Resources/views/backend/default/block/list_products.html.twig View File

{% import '@LcShop/backend/default/block/macros.html.twig' as macros %}
<table class="table table-condensed">
<thead>
<tr>
<th>Produits</th>
<th>Stock</th>
<th></th>
</tr>
</thead>
<tbody>
{% for product in product_availabilities_negative %}
<tr>
<td>
{{ product.productFamily.title }}
{% if product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT") %}
- {{ product.title }}
{% endif %}
</td>
<td>
{{ macros.available_quantity_product(product) }}
</td>
<td>
<a class="btn-sm btn-primary" href="{{ path('easyadmin', {'action' : 'edit', 'entity': 'ProductFamily', 'id' : product.productFamily.id }) }}#stock">
<i class="fa fa-pen"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>


+ 16
- 1
ShopBundle/Resources/views/backend/default/block/macros.html.twig View File

</div> </div>
{% endmacro form_widget_append %} {% endmacro form_widget_append %}


{#{% macro modal(title, form) %}
{% macro available_quantity_product(product) %}

{% if product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY") %}
{{ product.productFamily.availableQuantity }}
{% elseif product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE") %}
{{ product.productFamily.availableQuantity }}
/ {{ product.productFamily.unit.unitReference }}

{% elseif product.productFamily.behaviorCountStock == constant("Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT") %}
{{ product.availableQuantity }}

{% endif %}

{% endmacro available_quantity_product %}

{# {% macro modal(title, form) %}
{% embed '@LcShop/backend/default/block/embed_modal.twig' %} {% embed '@LcShop/backend/default/block/embed_modal.twig' %}
{% trans_default_domain 'lcshop' %} {% trans_default_domain 'lcshop' %}
{% block id %}{{ id }}{% endblock %} {% block id %}{{ id }}{% endblock %}

Loading…
Cancel
Save