@@ -586,7 +586,7 @@ class OrderShopBuilder | |||
public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2) | |||
{ | |||
$productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek); | |||
$productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek, $this->productSolver); | |||
$productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver); | |||
$productsSalesStatistic->populateProperties($this->orderShopStore); | |||
@@ -595,4 +595,4 @@ class OrderShopBuilder | |||
} | |||
} | |||
} |
@@ -331,5 +331,9 @@ trait AdminControllerTrait | |||
return $duplicateAction; | |||
} | |||
public function getCurrentSection(){ | |||
return $this->get(SectionResolver::class)->getCurrent(); | |||
} | |||
} | |||
@@ -209,11 +209,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $behaviorStockCycle; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $availabilityRenewedThisWeek; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
@@ -580,18 +575,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
public function getAvailabilityRenewedThisWeek(): ?bool | |||
{ | |||
return $this->availabilityRenewedThisWeek; | |||
} | |||
public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self | |||
{ | |||
$this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek; | |||
return $this; | |||
} | |||
public function getBehaviorDisplaySale(): ?string | |||
{ | |||
return $this->behaviorDisplaySale; |
@@ -32,10 +32,7 @@ class ProductFamilyStore extends AbstractStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
if($this->section) { | |||
$query->filterBySection($this->section); | |||
} | |||
$query->filterBySection($this->section); | |||
return $query; | |||
} | |||
@@ -1,7 +1,8 @@ | |||
import Chart from 'chart'; | |||
export class CaracStatistics { | |||
static initBtnShowTotalOrderProduct(){ | |||
$('.lc-show-products-sales-statistic').unbind('click').on('click', function (){ | |||
$btn = $(this); | |||
var $btn = $(this); | |||
var url = $(this).data('url'); | |||
$('#modal-products-sales-statistic').remove(); | |||
$.ajax({ | |||
@@ -11,7 +12,7 @@ export class CaracStatistics { | |||
success: function (response) { | |||
$('body').append(response.data); | |||
$('#modal-products-sales-statistic').modal('show'); | |||
initModalProductsSalesStatistic(response.statistics); | |||
CaracStatistics.initModalProductsSalesStatistic(response.statistics); | |||
} | |||
}); | |||
}); | |||
@@ -27,7 +28,7 @@ export class CaracStatistics { | |||
$('#table-products-sales-statistic-'+$(this).data('property-name')).show() | |||
if (chart) chart.destroy(); | |||
$(this).removeClass('btn-secondary'); | |||
chart = drawProductsSalesStatistic(statistics,$(this).data('property-name')) | |||
chart = CaracStatistics.drawProductsSalesStatistic(statistics,$(this).data('property-name')) | |||
}); | |||
$('.btn-products-sales-statistic').first().click(); | |||
@@ -16,6 +16,8 @@ menu: | |||
flash_message: | |||
error: | |||
formValidation: Une erreur est survenue lors de la soumission du formulaire | |||
settings_saved: Paramètres mis à jour | |||
duplicateToOtherMerchant: "Le document a bien été dupliqué sur le marchand : %merchant%" | |||
duplicateToOtherSection: "Le document a bien été dupliqué sur la section : %section%" | |||
@@ -24,6 +26,7 @@ action: | |||
favorite: Définir comme favoris | |||
duplicateToOtherMerchant: Dupliquer sur un autre marchand | |||
duplicateToOtherSection: Dupliquer sur une autre section | |||
editProductFamily: Éditer le produit | |||
setting_definition: | |||
merchant: |
@@ -1,7 +1,6 @@ | |||
{% embed "@LcSov/adminlte/embed/modal.twig" %} | |||
{% import '@LcCaracole/admin/product/macro/product_family_macro.html.twig' as pfm %} | |||
{% trans_default_domain 'lcshop' %} | |||
{% block size %}modal-lg{% endblock %} | |||
{% block id %}modal-products-sales-statistic{% endblock %} | |||
{% block title %}Total ventes/semaines : {{ productFamily.title }}{% endblock %} |
@@ -99,7 +99,6 @@ class ProductPriceSolver | |||
$solver = $this->getSolver($product); | |||
if ($solver->getBehaviorPriceInherited($product) == 'by-piece') { | |||
dump($product); | |||
return $solver->getBuyingPriceInherited($product); | |||
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') { | |||
if ($solver->getQuantityInherited($product) > 0) { |
@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | |||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||
use Lc\CaracoleBundle\Solver\Product\ProductSolver; | |||
use Lc\CaracoleBundle\Statistic\Statistic; | |||
class ProductsSalesStatistic extends Statistic | |||
@@ -17,12 +18,14 @@ class ProductsSalesStatistic extends Statistic | |||
protected $productFamily; | |||
protected $cycleNumbers = array(); | |||
protected $productIds = array(); | |||
protected ProductSolver $productSolver; | |||
public function __construct(EntityManagerInterface $entityManager, $productFamily, $nbCycle) | |||
public function __construct(EntityManagerInterface $entityManager, $productFamily, $nbCycle, ProductSolver $productSolver) | |||
{ | |||
parent::__construct($entityManager); | |||
$this->nbCycle = $nbCycle; | |||
$this->productFamily = $productFamily; | |||
$this->productSolver = $productSolver; | |||
$this->createProperties(); | |||
} | |||
@@ -76,7 +79,8 @@ class ProductsSalesStatistic extends Statistic | |||
$this->setData($result['productId'], $result['cycleNumber'], $result['quantity']); | |||
$product = $this->productIds[$result['productId']]; | |||
if ($this->productFamily->getBehaviorDisplaySale() == ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE) { | |||
$ratioByMeasure = $product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient(); | |||
$ratioByMeasure = $this->productSolver->getQuantityInherited($product) / $this->productSolver->getUnitInherited($product)->getCoefficient(); | |||
$this->setData('total_sales', $result['cycleNumber'], intval($result['quantity']) * $ratioByMeasure); | |||
} else { | |||
$this->setData('total_sales', $result['cycleNumber'], intval($result['quantity'])); |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Twig; | |||
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Lc\CaracoleBundle\Repository\Config\TaxRateStore; | |||
use Lc\CaracoleBundle\Repository\Config\UnitStore; | |||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | |||
use Lc\CaracoleBundle\Repository\Reminder\ReminderStore; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\CaracoleBundle\Resolver\VisitorResolver; | |||
use Lc\SovBundle\Solver\Setting\SettingSolver; | |||
use Symfony\Component\Security\Core\Security; | |||
use Twig\Extension\AbstractExtension; | |||
use Twig\TwigFunction; | |||
class ToolsTwigExtension extends AbstractExtension | |||
{ | |||
public function getFunctions() | |||
{ | |||
return array( | |||
new TwigFunction('die', [$this, 'simuleDie']), | |||
); | |||
} | |||
public function simuleDie(string $message = null) | |||
{ | |||
die($message); | |||
} | |||
} |