소스 검색

Intégration app product édition avancé

packProduct
Fabien Normand 3 년 전
부모
커밋
5dcf788b27
5개의 변경된 파일171개의 추가작업 그리고 105개의 파일을 삭제
  1. +40
    -36
      EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php
  2. +0
    -3
      Model/Product/ProductFamilyInterface.php
  3. +0
    -3
      Model/Product/ProductInterface.php
  4. +67
    -63
      Resources/assets/app/admin/product/app.product.js
  5. +64
    -0
      Resources/assets/functions/statistic.js

+ 40
- 36
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php 파일 보기

@@ -4,6 +4,8 @@ namespace Lc\CaracoleBundle\EventSubscriber\Product;

use Doctrine\ORM\EntityManagerInterface;

use Lc\CaracoleBundle\Container\Product\ProductContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
@@ -12,26 +14,29 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
{
protected $em;
protected $adminUrlGenerator;
protected EntityManagerInterface $em;
protected ProductFamilyContainer $productFamilyContainer;
protected ProductContainer $productContainer;

public function __construct(EntityManagerInterface $entityManager)
public function __construct(EntityManagerInterface $entityManager, ProductFamilyContainer $productFamilyContainer, ProductContainer $productContainer)
{
$this->em = $entityManager;
$this->productFamilyContainer = $productFamilyContainer;
$this->productContainer = $productContainer;
}

public static function getSubscribedEvents()
{
return [
EntityManagerEvent::PRE_UPDATE_EVENT => ['processBeforePersistProductFamily'],
EntityManagerEvent::PRE_CREATE_EVENT => ['processBeforePersistProductFamily'],
EntityManagerEvent::PRE_UPDATE_EVENT => ['processBeforePersistProductFamily'],
EntityManagerEvent::PRE_CREATE_EVENT => ['processBeforePersistProductFamily'],
];
}

public function processBeforePersistProductFamily(EntityManagerEvent $event)
{
$entity = $event->getEntity();
if($entity instanceof ProductFamilyInterface) {
if ($entity instanceof ProductFamilyInterface) {
$this->processProducts($entity);
$this->processPrice($entity);
$this->processReductionCatalog($entity);
@@ -48,9 +53,9 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
if ($reductionCatalog->getValue() && $reductionCatalog->getBehaviorTaxRate() && $reductionCatalog->getUnit()) {
//$reductionCatalog->setSection($entity->getSection());
$reductionCatalog->setProductFamily($entity);
if(is_null($reductionCatalog->getId())) {
if (is_null($reductionCatalog->getId())) {
$this->em->create($reductionCatalog);
}else {
} else {
$this->em->update($reductionCatalog);
}
}
@@ -75,12 +80,12 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface

//Récupère le product origin
$originProducts = $this->em->getRepository(ProductInterface::class)
->findBy(
array(
'productFamily' => $entity->getId(),
'originProduct' => true,
)
);
->findBy(
array(
'productFamily' => $entity->getId(),
'originProduct' => true,
)
);

if (count($originProducts) > 1) {
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab');
@@ -111,8 +116,7 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface

if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) {
$product->setTitle(
str_replace('.', ',', $product->getQuantityInherited()).$product->getUnitInherited(
)->getWording()
str_replace('.', ',', $this->productContainer->getSolver()->getQuantityInherited($product)) . $this->productContainer->getSolver()->getUnitInherited($product)->getWording()
);
}

@@ -121,24 +125,24 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
}
}

/* protected function processCategories(ProductFamilyInterface $entity)
{
$productCategoryRepository = $this->em->getRepository(ProductCategoryInterface::class);
$productCategories = $entity->getProductCategories();
$entity->initProductCategories();
foreach ($productCategories as $key => $bool) {
if (is_bool($bool) && $bool) {
if (strpos($key, 'category_children_') !== false) {
$idCategory = (int)str_replace('category_children_', '', $key);
} else {
$idCategory = (int)str_replace('category_', '', $key);
}
$category = $productCategoryRepository->find($idCategory);
$entity->addProductCategory($category);
}
}
}*/
/* protected function processCategories(ProductFamilyInterface $entity)
{
$productCategoryRepository = $this->em->getRepository(ProductCategoryInterface::class);
$productCategories = $entity->getProductCategories();
$entity->initProductCategories();
foreach ($productCategories as $key => $bool) {
if (is_bool($bool) && $bool) {
if (strpos($key, 'category_children_') !== false) {
$idCategory = (int)str_replace('category_children_', '', $key);
} else {
$idCategory = (int)str_replace('category_', '', $key);
}
$category = $productCategoryRepository->find($idCategory);
$entity->addProductCategory($category);
}
}
}*/
}

+ 0
- 3
Model/Product/ProductFamilyInterface.php 파일 보기

@@ -2,9 +2,6 @@

namespace Lc\CaracoleBundle\Model\Product;

/**
* @ORM\MappedSuperclass()
*/
interface ProductFamilyInterface
{


+ 0
- 3
Model/Product/ProductInterface.php 파일 보기

@@ -5,9 +5,6 @@ namespace Lc\CaracoleBundle\Model\Product;

use Lc\CaracoleBundle\Model\Order\OrderShopInterface;

/**
* @ORM\MappedSuperclass()
*/
interface ProductInterface
{


+ 67
- 63
Resources/assets/app/admin/product/app.product.js 파일 보기

@@ -1,65 +1,69 @@
jQuery(document).ready(function () {
initBtnShowTotalOrderProduct();
});

function initBtnShowTotalOrderProduct(){
$('.lc-show-products-sales-statistic').unbind('click').on('click', function (){
$btn = $(this);
var url = $(this).data('url');
$('#modal-products-sales-statistic').remove();
$.ajax({
url: url,
method: "POST",
dataType: "json",
success: function (response) {
$('body').append(response.data);
$('#modal-products-sales-statistic').modal('show');
initModalProductsSalesStatistic(response.statistics);
}
});
});
}
function initModalProductsSalesStatistic(statistics) {
var chart = null;
$('.btn-products-sales-statistic').off('click');
$('.btn-products-sales-statistic').on('click', function () {
$('.table-products-sales-statistic').hide();
$('.btn-products-sales-statistic').addClass('btn-secondary').removeClass('btn-primary');
$(this).removeClass('btn-secondary').addClass('btn-primary');

$('#table-products-sales-statistic-'+$(this).data('property-name')).show()
if (chart) chart.destroy();
$(this).removeClass('btn-secondary');
chart = drawProductsSalesStatistic(statistics,$(this).data('property-name'))
});
$('.btn-products-sales-statistic').first().click();

}
import { CaracStatistics } from '../../../functions/statistic.js';
global.CaracStatistics = CaracStatistics;

function drawProductsSalesStatistic(statictics, propertyName) {

var options = {
bezierCurve : false,
tooltips: {
callbacks: {
label: (item) => item.yLabel ,
},
},
};

chart = new Chart(document.getElementById("chart"), {
"type": "line",
"data": {
"labels": Object.values(statictics.label),
"datasets": [{
"label": "Vente de produits / semaine",
"data": Object.values(statictics.data[propertyName].data),
"fill": false,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": options
});
return chart;
}
jQuery(document).ready(function () {
CaracStatistics.initBtnShowTotalOrderProduct();
});
//
// function initBtnShowTotalOrderProduct(){
// $('.lc-show-products-sales-statistic').unbind('click').on('click', function (){
// $btn = $(this);
// var url = $(this).data('url');
// $('#modal-products-sales-statistic').remove();
// $.ajax({
// url: url,
// method: "POST",
// dataType: "json",
// success: function (response) {
// $('body').append(response.data);
// $('#modal-products-sales-statistic').modal('show');
// initModalProductsSalesStatistic(response.statistics);
// }
// });
// });
// }
// function initModalProductsSalesStatistic(statistics) {
// var chart = null;
// $('.btn-products-sales-statistic').off('click');
// $('.btn-products-sales-statistic').on('click', function () {
// $('.table-products-sales-statistic').hide();
// $('.btn-products-sales-statistic').addClass('btn-secondary').removeClass('btn-primary');
// $(this).removeClass('btn-secondary').addClass('btn-primary');
//
// $('#table-products-sales-statistic-'+$(this).data('property-name')).show()
// if (chart) chart.destroy();
// $(this).removeClass('btn-secondary');
// chart = drawProductsSalesStatistic(statistics,$(this).data('property-name'))
// });
// $('.btn-products-sales-statistic').first().click();
//
// }
//
// function drawProductsSalesStatistic(statictics, propertyName) {
//
// var options = {
// bezierCurve : false,
// tooltips: {
// callbacks: {
// label: (item) => item.yLabel ,
// },
// },
// };
//
// chart = new Chart(document.getElementById("chart"), {
// "type": "line",
// "data": {
// "labels": Object.values(statictics.label),
// "datasets": [{
// "label": "Vente de produits / semaine",
// "data": Object.values(statictics.data[propertyName].data),
// "fill": false,
// "borderColor": "rgb(75, 192, 192)",
// "lineTension": 0.1
// }]
// },
// "options": options
// });
// return chart;
// }

+ 64
- 0
Resources/assets/functions/statistic.js 파일 보기

@@ -0,0 +1,64 @@
export class CaracStatistics {
static initBtnShowTotalOrderProduct(){
$('.lc-show-products-sales-statistic').unbind('click').on('click', function (){
$btn = $(this);
var url = $(this).data('url');
$('#modal-products-sales-statistic').remove();
$.ajax({
url: url,
method: "POST",
dataType: "json",
success: function (response) {
$('body').append(response.data);
$('#modal-products-sales-statistic').modal('show');
initModalProductsSalesStatistic(response.statistics);
}
});
});
}
static initModalProductsSalesStatistic(statistics) {
var chart = null;
$('.btn-products-sales-statistic').off('click');
$('.btn-products-sales-statistic').on('click', function () {
$('.table-products-sales-statistic').hide();
$('.btn-products-sales-statistic').addClass('btn-secondary').removeClass('btn-primary');
$(this).removeClass('btn-secondary').addClass('btn-primary');

$('#table-products-sales-statistic-'+$(this).data('property-name')).show()
if (chart) chart.destroy();
$(this).removeClass('btn-secondary');
chart = drawProductsSalesStatistic(statistics,$(this).data('property-name'))
});
$('.btn-products-sales-statistic').first().click();

}

static drawProductsSalesStatistic(statictics, propertyName) {

var options = {
bezierCurve : false,
tooltips: {
callbacks: {
label: (item) => item.yLabel ,
},
},
};

chart = new Chart(document.getElementById("chart"), {
"type": "line",
"data": {
"labels": Object.values(statictics.label),
"datasets": [{
"label": "Vente de produits / semaine",
"data": Object.values(statictics.data[propertyName].data),
"fill": false,
"borderColor": "rgb(75, 192, 192)",
"lineTension": 0.1
}]
},
"options": options
});
return chart;
}

}

Loading…
취소
저장