| arlista.file.actualise-product-data: | arlista.file.actualise-product-data: | ||||
| path: "/files/{mid}/list/actualise-product-data" | path: "/files/{mid}/list/actualise-product-data" | ||||
| defaults: | defaults: | ||||
| _controller: '\Drupal\arlista\Controller\ProductController::actualiseProductData' | |||||
| _controller: '\Drupal\arlista\Controller\ProductController::actualiseModifiedProductDataOfFile' | |||||
| _title: "Termék adatok aktivizálása" | _title: "Termék adatok aktivizálása" | ||||
| requirements: | requirements: | ||||
| _permission: "arlista manage_pricelists" | _permission: "arlista manage_pricelists" | ||||
| arlista.product.list.file.update.category: | arlista.product.list.file.update.category: | ||||
| path: "product/list/file/update/category" | path: "product/list/file/update/category" | ||||
| defaults: | defaults: | ||||
| _controller: '\Drupal\arlista\Controller\CategoryController::updateProductCategory' | |||||
| _controller: '\Drupal\arlista\Controller\CategoryController::updateAxicoId' | |||||
| _title: "Termékcsoport update" | _title: "Termékcsoport update" | ||||
| requirements: | requirements: | ||||
| _permission: "arlista manage_pricelists" | _permission: "arlista manage_pricelists" | ||||
| arlista.product.list.file.update.component: | arlista.product.list.file.update.component: | ||||
| path: "product/list/file/update/component" | path: "product/list/file/update/component" | ||||
| defaults: | defaults: | ||||
| _controller: '\Drupal\arlista\Controller\ComponentController::updateProductComponent' | |||||
| _controller: '\Drupal\arlista\Controller\ComponentController::updateAxicoId' | |||||
| _title: "Komponens update" | _title: "Komponens update" | ||||
| requirements: | requirements: | ||||
| _permission: "arlista manage_pricelists" | _permission: "arlista manage_pricelists" | ||||
| arlista.warranty.category.manufacturer.fetch: | arlista.warranty.category.manufacturer.fetch: | ||||
| path: "warranty/category/manufacturer/fetch" | path: "warranty/category/manufacturer/fetch" | ||||
| defaults: | defaults: | ||||
| _controller: '\Drupal\arlista\Controller\CategoryController::getAxicoIdwarranty' | |||||
| _controller: '\Drupal\arlista\Controller\CategoryController::getAxicoIdWarranty' | |||||
| _title: "Fetch warranty for category and manufacturer" | _title: "Fetch warranty for category and manufacturer" | ||||
| requirements: | requirements: | ||||
| _permission: "arlista manage_pricelists" | _permission: "arlista manage_pricelists" |
| abstract class ArlistaAbstractController extends ControllerBase { | abstract class ArlistaAbstractController extends ControllerBase { | ||||
| private $axicoIdWarrantyFactory; | |||||
| private $categoryFactory; | |||||
| private $fileFactory; | |||||
| private $manufacturerFactory; | |||||
| private $sheetSettingFactory; | |||||
| private $cacheService; | |||||
| private $spreadSheetFactory; | |||||
| private $productFactory; | |||||
| private $calculationFactory; | |||||
| private $response; | |||||
| private $responseBody; | |||||
| private $admin; | |||||
| public function __construct(CategoryFactory $categoryFactory, | |||||
| private $axicoIdWarrantyFactory; | |||||
| private $categoryFactory; | |||||
| private $fileFactory; | |||||
| private $manufacturerFactory; | |||||
| private $sheetSettingFactory; | |||||
| private $cacheService; | |||||
| private $spreadSheetFactory; | |||||
| private $productFactory; | |||||
| private $calculationFactory; | |||||
| private ?JsonResponse $response; | |||||
| private ?ResponseBody $responseBody; | |||||
| private $admin; | |||||
| public function __construct(CategoryFactory $categoryFactory, | |||||
| FileFactory $fileFactory, ManufacturerFactory $manufacturerFactory, | FileFactory $fileFactory, ManufacturerFactory $manufacturerFactory, | ||||
| SheetSettingFactory $SheetSettingFactory, CacheService $cacheService, | SheetSettingFactory $SheetSettingFactory, CacheService $cacheService, | ||||
| SpreadSheetFactory $spreadSheetFactory, ProductFactory $productFactory, | SpreadSheetFactory $spreadSheetFactory, ProductFactory $productFactory, | ||||
| CalculationFactory $calculationFactory, AxicoIdWarrantyFactory $axicoIdWarrantyFactory) { | CalculationFactory $calculationFactory, AxicoIdWarrantyFactory $axicoIdWarrantyFactory) { | ||||
| $this->categoryFactory = $categoryFactory; | |||||
| $this->fileFactory = $fileFactory; | |||||
| $this->manufacturerFactory = $manufacturerFactory; | |||||
| $this->sheetSettingFactory = $SheetSettingFactory; | |||||
| $this->cacheService = $cacheService; | |||||
| $this->spreadSheetFactory = $spreadSheetFactory; | |||||
| $this->productFactory = $productFactory; | |||||
| $this->calculationFactory = $calculationFactory; | |||||
| $this->axicoIdWarrantyFactory = $axicoIdWarrantyFactory; | |||||
| $this->response = new JsonResponse(); | |||||
| $this->response->headers->set('Content-Type', 'application/json'); | |||||
| $this->responseBody = new ResponseBody(); | |||||
| $this->responseBody->setTime(date("Y-m-d H:i:s")); | |||||
| $this->admin = \Drupal\user\Entity\User::load($this->currentUser()->id())->hasRole('administrator'); | |||||
| } | |||||
| /** | |||||
| * {@inheritdoc} | |||||
| */ | |||||
| public static function create(ContainerInterface $container) { | |||||
| return new static( | |||||
| $container->get('arlista.category.factory'), | |||||
| $container->get('arlista.file.factory'), | |||||
| $container->get('arlista.manufacturer.factory'), | |||||
| $container->get('arlista.sheet-setting.factory'), | |||||
| $container->get('arlista.cache-service'), | |||||
| $container->get('arlista.spread-sheet.factory'), | |||||
| $container->get('arlista.product.factory'), | |||||
| $container->get('arlista.calculation.factory'), | |||||
| $container->get('arlista.warranty.factory'), | |||||
| ); | |||||
| } | |||||
| public function getAxicoIdWarrantyFactory(): AxicoIdWarrantyFactory { | |||||
| return $this->axicoIdWarrantyFactory; | |||||
| } | |||||
| public function getCategoryFactory(): CategoryFactory { | |||||
| return $this->categoryFactory; | |||||
| } | |||||
| public function getFileFactory(): FileFactory { | |||||
| return $this->fileFactory; | |||||
| } | |||||
| public function getManufacturerFactory(): ManufacturerFactory { | |||||
| return $this->manufacturerFactory; | |||||
| } | |||||
| public function getSheetSettingFactory(): SheetSettingFactory { | |||||
| return $this->sheetSettingFactory; | |||||
| } | |||||
| public function getCacheService(): CacheService { | |||||
| return $this->cacheService; | |||||
| } | |||||
| public function getSpreadSheetFactory(): SpreadSheetFactory { | |||||
| return $this->spreadSheetFactory; | |||||
| } | |||||
| public function getProductFactory(): ProductFactory { | |||||
| return $this->productFactory; | |||||
| } | |||||
| public function getCalculationFactory(): CalculationFactory { | |||||
| return $this->calculationFactory; | |||||
| } | |||||
| public function getResponse(): JsonResponse { | |||||
| return $this->response; | |||||
| } | |||||
| public function getResponseBody(): ResponseBody { | |||||
| return $this->responseBody; | |||||
| } | |||||
| public function isAdmin(): bool { | |||||
| return $this->admin; | |||||
| } | |||||
| public function updateProductInOtherFiles(Product $product): void { | |||||
| $sameUploadedProductsInDifferentFiles = $this->getProductFactory()->findSameUploadedProductInDifferentFilesByFabricId($product->getFabricId(), $product->getUploadedFileId()); | |||||
| /* @var $sameProductInOtherFiles Product */ | |||||
| foreach ($sameUploadedProductsInDifferentFiles as $sameProductInOtherFiles) { | |||||
| $sameProductInOtherFiles->setParentComponentId($product->getParentComponentId()); | |||||
| $sameProductInOtherFiles->setParentManufacturerId($product->getParentManufacturerId()); | |||||
| $sameProductInOtherFiles->setParentCategoryId($product->getParentCategoryId()); | |||||
| $sameProductInOtherFiles->copyPrices($sameProductInOtherFiles); | |||||
| $sameProductInOtherFiles->setAxicoId($product->getAxicoId()); | |||||
| $sameProductInOtherFiles->setWorkFlow(WorkFlow::ACTIVATED); | |||||
| $sameProductInOtherFiles->setCorrectStatus(Status::CORRECT_IMPORTED); | |||||
| $sameProductInOtherFiles->setWarranty($product->getWarranty()); | |||||
| $this->getProductFactory()->save($sameProductInOtherFiles); | |||||
| $this->cacheService->resetCache(['arlista_product_edit_form', 'uploaded', $product->getId()]); | |||||
| } | |||||
| } | |||||
| $this->categoryFactory = $categoryFactory; | |||||
| $this->fileFactory = $fileFactory; | |||||
| $this->manufacturerFactory = $manufacturerFactory; | |||||
| $this->sheetSettingFactory = $SheetSettingFactory; | |||||
| $this->cacheService = $cacheService; | |||||
| $this->spreadSheetFactory = $spreadSheetFactory; | |||||
| $this->productFactory = $productFactory; | |||||
| $this->calculationFactory = $calculationFactory; | |||||
| $this->axicoIdWarrantyFactory = $axicoIdWarrantyFactory; | |||||
| $this->response = new JsonResponse(); | |||||
| $this->response->headers->set('Content-Type', 'application/json'); | |||||
| $this->responseBody = new ResponseBody(); | |||||
| $this->responseBody->setTime(date("Y-m-d H:i:s")); | |||||
| $this->admin = \Drupal\user\Entity\User::load($this->currentUser()->id())->hasRole('administrator'); | |||||
| } | |||||
| /** | |||||
| * {@inheritdoc} | |||||
| */ | |||||
| public static function create(ContainerInterface $container) { | |||||
| return new static( | |||||
| $container->get('arlista.category.factory'), | |||||
| $container->get('arlista.file.factory'), | |||||
| $container->get('arlista.manufacturer.factory'), | |||||
| $container->get('arlista.sheet-setting.factory'), | |||||
| $container->get('arlista.cache-service'), | |||||
| $container->get('arlista.spread-sheet.factory'), | |||||
| $container->get('arlista.product.factory'), | |||||
| $container->get('arlista.calculation.factory'), | |||||
| $container->get('arlista.warranty.factory'), | |||||
| ); | |||||
| } | |||||
| public function getAxicoIdWarrantyFactory(): AxicoIdWarrantyFactory { | |||||
| return $this->axicoIdWarrantyFactory; | |||||
| } | |||||
| public function getCategoryFactory(): CategoryFactory { | |||||
| return $this->categoryFactory; | |||||
| } | |||||
| public function getFileFactory(): FileFactory { | |||||
| return $this->fileFactory; | |||||
| } | |||||
| public function getManufacturerFactory(): ManufacturerFactory { | |||||
| return $this->manufacturerFactory; | |||||
| } | |||||
| public function getSheetSettingFactory(): SheetSettingFactory { | |||||
| return $this->sheetSettingFactory; | |||||
| } | |||||
| public function getCacheService(): CacheService { | |||||
| return $this->cacheService; | |||||
| } | |||||
| public function getSpreadSheetFactory(): SpreadSheetFactory { | |||||
| return $this->spreadSheetFactory; | |||||
| } | |||||
| public function getProductFactory(): ProductFactory { | |||||
| return $this->productFactory; | |||||
| } | |||||
| public function getCalculationFactory(): CalculationFactory { | |||||
| return $this->calculationFactory; | |||||
| } | |||||
| public function getResponse(): JsonResponse { | |||||
| return $this->response; | |||||
| } | |||||
| public function getResponseBody(): ResponseBody { | |||||
| return $this->responseBody; | |||||
| } | |||||
| public function resetResponse(): void { | |||||
| $this->response = new JsonResponse(); | |||||
| } | |||||
| public function resetResponseBody(): void { | |||||
| $this->responseBody = new ResponseBody(); | |||||
| } | |||||
| public function resetResponseState(): void { | |||||
| $this->resetResponseBody(); | |||||
| $this->resetResponse(); | |||||
| } | |||||
| public function isAdmin(): bool { | |||||
| return $this->admin; | |||||
| } | |||||
| public function updateProductInOtherFiles(Product $product): void { | |||||
| $sameUploadedProductsInDifferentFiles = $this->getProductFactory()->findSameUploadedProductInDifferentFilesByFabricId($product->getFabricId(), $product->getUploadedFileId()); | |||||
| /* @var $sameProductInOtherFiles Product */ | |||||
| foreach ($sameUploadedProductsInDifferentFiles as $sameProductInOtherFiles) { | |||||
| $sameProductInOtherFiles->setParentComponentId($product->getParentComponentId()); | |||||
| $sameProductInOtherFiles->setParentManufacturerId($product->getParentManufacturerId()); | |||||
| $sameProductInOtherFiles->setParentCategoryId($product->getParentCategoryId()); | |||||
| $sameProductInOtherFiles->copyPrices($sameProductInOtherFiles); | |||||
| $sameProductInOtherFiles->setAxicoId($product->getAxicoId()); | |||||
| $sameProductInOtherFiles->setWorkFlow(WorkFlow::ACTIVATED); | |||||
| $sameProductInOtherFiles->setCorrectStatus(Status::CORRECT_IMPORTED); | |||||
| $sameProductInOtherFiles->setWarranty($product->getWarranty()); | |||||
| $this->getProductFactory()->save($sameProductInOtherFiles); | |||||
| $this->cacheService->resetCache(['arlista_product_edit_form', 'uploaded', $product->getId()]); | |||||
| } | |||||
| } | |||||
| } | } |
| namespace Drupal\arlista\Controller; | namespace Drupal\arlista\Controller; | ||||
| use Drupal\arlista\Controller\ArlistaAbstractController; | use Drupal\arlista\Controller\ArlistaAbstractController; | ||||
| use Symfony\Component\HttpFoundation\Request; | |||||
| use Drupal\arlista\Entity\WorkFlow; | |||||
| class AxicoIdController extends ArlistaAbstractController { | |||||
| public function setAxicoId(Request $request) { | |||||
| $this->getResponseBody()->setFid($request->request->get('fid')); | |||||
| $this->getResponseBody()->setMessage('Sikertelen cikkszámozás'); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($request->request->get('fid')); | |||||
| if (empty($uploadedFile) || empty($request->request->get('fid'))) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| use Drupal\arlista\Entity\Product; | |||||
| use Drupal\arlista\Entity\Manufacturer; | |||||
| abstract class AxicoIdController extends ArlistaAbstractController { | |||||
| public function getAxicoIdResultContainer(Product $product, ?Manufacturer $manufacturer, int $revokeAxicoId): array { | |||||
| return [ | |||||
| 'products' => [$product], | |||||
| 'manufacturer' => $manufacturer, | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdCopied' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'axicoIdRevoked' => 0, | |||||
| 'revokeAxicoId' => $revokeAxicoId, | |||||
| 'revokedProducts' => [], | |||||
| ]; | |||||
| } | } | ||||
| if (empty($uploadedFile->getTotalProducts() < 1)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájl nem tartalmaz termékeket'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $products = $this->getProductFactory()->findProductsByUploadedFileId($uploadedFile->getId()); | |||||
| if (empty($products)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájlhoz kapcsolódó termékek nem találhatóak'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| public function actualiseProduct($result): void { | |||||
| $this->getProductFactory()->actualiseProducts($result); | |||||
| $this->updateProductInOtherFiles($result['products'][0]); | |||||
| } | } | ||||
| $result = [ | |||||
| 'products' => $products, | |||||
| 'manufacturer' => $this->getManufacturerFactory()->find($uploadedFile->getParentManufacturerId()), | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoIdMissing' => 0, | |||||
| 'optionValues' => [], | |||||
| 'status' => false, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| if (!$result['status']) { | |||||
| $this->getResponseBody()->setMessage('A fájl egyik munkalapja sem tartalmazott sorszámozható terméket - ellenőrizze a konfigurációkat'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile->setWorkFlow(WorkFlow::NUMBERED); | |||||
| $this->getFileFactory()->save($uploadedFile); | |||||
| unset($result['products'], $result['manufacturer']); | |||||
| $this->getResponseBody()->setMessage('Sikeres sorszámozás'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| } | } |
| namespace Drupal\arlista\Controller; | namespace Drupal\arlista\Controller; | ||||
| use Drupal\arlista\Controller\ArlistaAbstractController; | |||||
| use Drupal\arlista\Controller\AxicoIdController; | |||||
| use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
| use Symfony\Component\HttpFoundation\Response; | |||||
| use Drupal\arlista\Entity\Product; | use Drupal\arlista\Entity\Product; | ||||
| class CategoryController extends ArlistaAbstractController { | |||||
| public function updateProductCategory(Request $request) { | |||||
| $this->getResponseBody()->setFid($request->request->get('fid')); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($request->request->get('fid')); | |||||
| if (empty($uploadedFile) || empty($request->request->get('fid'))) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| class CategoryController extends AxicoIdController { | |||||
| public function updateAxicoId(Request $request): Response { | |||||
| $this->resetResponseState(); | |||||
| $this->getResponseBody()->setFid($request->request->get('fid')); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($request->request->get('fid')); | |||||
| if (empty($uploadedFile) || empty($request->request->get('fid'))) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if (strpos($request->request->get('cid'), "-")) { | |||||
| $array = explode("-", $request->request->get('cid')); | |||||
| $cid = $array[1]; | |||||
| } else { | |||||
| $cid = $request->request->get('cid'); | |||||
| } | |||||
| /* @var $product Product */ | |||||
| $product = $this->getProductFactory()->find($request->request->get('pid')); | |||||
| $revokeAxicoId = (int) $request->request->get('revokeAxicoId'); | |||||
| if (!$cid || $revokeAxicoId) { | |||||
| $manufacturer = null; | |||||
| $result = $this->getAxicoIdResultContainer($product, $manufacturer, $revokeAxicoId); | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } else { | |||||
| /* @var $category Category */ | |||||
| $category = $this->getProductFactory()->getCategoryFactory()->find($cid); | |||||
| $product->setParentComponentId(null); | |||||
| $product->setParentManufacturerId($request->request->get('mid')); | |||||
| $product->setParentCategoryId($category->getId()); | |||||
| $product = $this->getProductFactory()->save($product); | |||||
| $manufacturer = $this->getManufacturerFactory()->find($request->request->get('mid')); | |||||
| $result = $this->getAxicoIdResultContainer($product, $manufacturer, $revokeAxicoId); | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } | |||||
| if (!$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen termékcsoport frissítés'); | |||||
| $this->getResponseBody()->setSuccess(0); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if (count($result['products']) === 1) { | |||||
| $this->actualiseProduct($result); | |||||
| } | |||||
| unset($result['products'], $result['manufacturer'], $result['revokedProducts']); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponseBody()->setMessage('Sikeres termékcsoport frissítés'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | } | ||||
| if (strpos($request->request->get('cid'), "-")) { | |||||
| $array = explode("-", $request->request->get('cid')); | |||||
| $cid = $array[1]; | |||||
| } else { | |||||
| $cid = $request->request->get('cid'); | |||||
| } | |||||
| public function getAxicoIdWarranty(Request $request): Response { | |||||
| $mid = $request->request->get('mid'); | |||||
| $cid = $request->request->get('cid'); | |||||
| /* @var $product Product */ | |||||
| $product = $this->getProductFactory()->find($request->request->get('pid')); | |||||
| $revokeAxicoId = (int) $request->request->get('revokeAxicoId'); | |||||
| if (!$cid || $revokeAxicoId) { | |||||
| $result = [ | |||||
| 'products' => [$product], | |||||
| 'manufacturer' => null, | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdCopied' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'revokeAxicoId' => $revokeAxicoId, | |||||
| 'revokedProducts' => [], | |||||
| 'axicoIdRevoked' => 0, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } else { | |||||
| /* @var $category Category */ | |||||
| $category = $this->getProductFactory()->getCategoryFactory()->find($cid); | |||||
| $product->setParentComponentId(null); | |||||
| $product->setParentManufacturerId($request->request->get('mid')); | |||||
| $product->setParentCategoryId($category->getId()); | |||||
| $product = $this->getProductFactory()->save($product); | |||||
| $result = [ | |||||
| 'products' => [$product], | |||||
| 'manufacturer' => $product->getParentManufacturerId(), | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdCopied' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'revokeAxicoId' => $revokeAxicoId, | |||||
| 'revokedProducts' => [], | |||||
| 'axicoIdRevoked' => 0, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } | |||||
| $category = $this->getCategoryFactory()->find($cid); | |||||
| $manufacturer = $this->getManufacturerFactory()->find($mid); | |||||
| if (!$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen termékcsoport frissítés'); | |||||
| $this->getResponseBody()->setSuccess(0); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->findByAxicoIdName($manufacturer->getAxicoIdName() . $category->getAxicoIdName()); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponseBody()->setMessage('Sikeres találat'); | |||||
| $this->getResponseBody()->setData($axicoIdWarranty->getDefaultWarranty()); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| if (count($result['products']) === 1) { | |||||
| $this->updateProductInOtherFiles($result['products'][0]); | |||||
| return $this->getResponse(); | |||||
| } | } | ||||
| unset($result['products'], $result['manufacturer'], $result['revokedProducts']); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponseBody()->setMessage('Sikeres frissítés'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| public function getAxicoIdwarranty(Request $request) { | |||||
| $mid = $request->request->get('mid'); | |||||
| $cid = $request->request->get('cid'); | |||||
| $category = $this->getCategoryFactory()->find($cid); | |||||
| $manufacturer = $this->getManufacturerFactory()->find($mid); | |||||
| $axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->findByAxicoIdName($manufacturer->getAxicoIdName() . $category->getAxicoIdName()); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponseBody()->setMessage('Sikeres találat'); | |||||
| $this->getResponseBody()->setData($axicoIdWarranty->getDefaultWarranty()); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| } | } |
| namespace Drupal\arlista\Controller; | namespace Drupal\arlista\Controller; | ||||
| use Drupal\arlista\Controller\ArlistaAbstractController; | |||||
| use Drupal\arlista\Controller\AxicoIdController; | |||||
| use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
| use Drupal\arlista\Entity\Product; | use Drupal\arlista\Entity\Product; | ||||
| use Symfony\Component\HttpFoundation\Response; | |||||
| class ComponentController extends ArlistaAbstractController { | |||||
| class ComponentController extends AxicoIdController { | |||||
| public function updateProductComponent(Request $request) { | |||||
| public function updateAxicoId(Request $request): Response { | |||||
| $this->getResponseBody()->setFid($request->request->get('fid')); | |||||
| $this->resetResponseState(); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $this->getResponseBody()->setFid($request->request->get('fid')); | |||||
| $uploadedFile = $this->getFileFactory()->find($request->request->get('fid')); | |||||
| if (empty($uploadedFile) || empty($request->request->get('fid'))) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| /* @var $product Product */ | |||||
| $product = $this->getProductFactory()->find($request->request->get('pid')); | |||||
| $uploadedFile = $this->getFileFactory()->find($request->request->get('fid')); | |||||
| if (empty($uploadedFile) || empty($request->request->get('fid'))) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $revokeAxicoId = (int) $request->request->get('revokeAxicoId'); | |||||
| $cmpId = (int) $request->request->get('cmpId'); | |||||
| if (!$cmpId && $revokeAxicoId) { | |||||
| $result = [ | |||||
| 'products' => [$product], | |||||
| 'manufacturer' => null, | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'axicoIdRevoked' => 0, | |||||
| 'revokeAxicoId' => $revokeAxicoId, | |||||
| 'revokedProducts' => [], | |||||
| ]; | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } else { | |||||
| $component = $this->getProductFactory()->getComponentFactory()->find($cmpId); | |||||
| $product->setParentComponentId($component->getId()); | |||||
| $product->setParentManufacturerId($component->getParentManufacturerId()); | |||||
| $product = $this->getProductFactory()->save($product); | |||||
| $result = [ | |||||
| 'products' => [$product], | |||||
| 'manufacturer' => $this->getManufacturerFactory()->find($request->request->get('mid')), | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'axicoIdRevoked' => 0, | |||||
| 'revokeAxicoId' => $revokeAxicoId, | |||||
| 'revokedProducts' => [], | |||||
| ]; | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } | |||||
| /* @var $product Product */ | |||||
| $product = $this->getProductFactory()->find($request->request->get('pid')); | |||||
| if (!$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen kompononens csoport frissítés'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $revokeAxicoId = (int) $request->request->get('revokeAxicoId'); | |||||
| $cmpId = (int) $request->request->get('cmpId'); | |||||
| if (!$cmpId && $revokeAxicoId) { | |||||
| $manufacturer = null; | |||||
| $result = $this->getAxicoIdResultContainer($product, $manufacturer, $revokeAxicoId); | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } else { | |||||
| $component = $this->getProductFactory()->getComponentFactory()->find($cmpId); | |||||
| $product->setParentComponentId($component->getId()); | |||||
| $product->setParentManufacturerId($component->getParentManufacturerId()); | |||||
| $product = $this->getProductFactory()->save($product); | |||||
| $manufacturer = $this->getManufacturerFactory()->find($component->getParentManufacturerId()); | |||||
| $result = $this->getAxicoIdResultContainer($product, $manufacturer); | |||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | |||||
| } | |||||
| if (count($result['products']) === 1) { | |||||
| $this->updateProductInOtherFiles($result['products'][0]); | |||||
| } | |||||
| if (!$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen kompononens csoport frissítés'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| unset($result['products'], $result['manufacturer'], $result['revokedProducts']); | |||||
| if (count($result['products']) === 1) { | |||||
| $this->actualiseProduct($result); | |||||
| } | |||||
| $this->getResponseBody()->setMessage('Sikeres frissítés'); | |||||
| $result['status'] = 1; | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| unset($result['products'], $result['manufacturer'], $result['revokedProducts']); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $this->getResponseBody()->setMessage('Sikeres kompononens csoport frissítés'); | |||||
| $result['status'] = 1; | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| } | } |
| class ProductController extends ArlistaAbstractController { | class ProductController extends ArlistaAbstractController { | ||||
| public function compareProducts(Request $request) { | |||||
| $fid = $request->request->get('fid'); | |||||
| $this->getResponseBody()->setFid($fid); | |||||
| $this->getResponseBody()->setMessage('Sikertelen szinkronizáció'); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($fid); | |||||
| if (empty($uploadedFile) || empty($fid)) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if (empty($uploadedFile->getTotalProducts() < 1)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájl nem tartalmaz termékeket'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $products = $this->getProductFactory()->findProductsByUploadedFileId($uploadedFile->getId()); | |||||
| if (empty($products)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájlhoz kapcsolódó termékek nem találhatóak'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $result = [ | |||||
| 'products' => $products, | |||||
| 'manufacturer' => $this->getManufacturerFactory()->find($uploadedFile->getParentManufacturerId()), | |||||
| 'totalCompared' => 0, | |||||
| 'unchanged' => 0, | |||||
| 'changed' => 0, | |||||
| 'newProduct' => 0, | |||||
| 'status' => false, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->compareProducts($result); | |||||
| if ($result['total'] === 0 || !$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Nincs sorszámozott és szinkronizálható termék - ellenőrizze a konfigurációkat'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| public function actualiseModifiedProductDataOfFile(Request $request) { | |||||
| $fid = $request->request->get('fid'); | |||||
| $this->getResponseBody()->setFid($fid); | |||||
| $this->getResponseBody()->setMessage('Sikertelen aktualizáció'); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($fid); | |||||
| if (empty($uploadedFile) || empty($fid)) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if (empty($uploadedFile->getTotalProducts() < 1)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájl nem tartalmaz termékeket'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $products = $this->getProductFactory()->findProductsByUploadedFileId($uploadedFile->getId()); | |||||
| if (empty($products)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájlhoz kapcsolódó termékek nem találhatóak'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $modifiedProducts = []; | |||||
| /* @var $product Product */ | |||||
| foreach ($products as $product) { | |||||
| if ($product->getModifiedAt() > $uploadedFile->getModifiedAt()) { | |||||
| $modifiedProducts[] = $product; | |||||
| } | |||||
| } | |||||
| $result = [ | |||||
| 'products' => $modifiedProducts, | |||||
| 'manufacturer' => $this->getManufacturerFactory()->find($uploadedFile->getParentManufacturerId()), | |||||
| 'totalNumbered' => 0, | |||||
| 'axicoIdCopied' => 0, | |||||
| 'axicoIdContinued' => 0, | |||||
| 'axicoIdGenerated' => 0, | |||||
| 'axicoId' => [], | |||||
| 'axicoIdMissing' => 0, | |||||
| 'status' => false, | |||||
| 'axicoIdRevoked' => 0, | |||||
| 'newProduct' => 0, | |||||
| 'updatedProduct' => 0, | |||||
| 'revokeAxicoId' => 0, | |||||
| 'revokedProducts' => [], | |||||
| 'totalActualised' => 0, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->actualiseProducts($result); | |||||
| if ($result['totalActualised'] === 0 || !$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Nincs aktualizálható termék - ellenőrizze a konfigurációkat'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile->setWorkFlow(WorkFlow::ACTIVATED); | |||||
| $this->getFileFactory()->save($uploadedFile); | |||||
| unset($result['products'], $result['manufacturer']); | |||||
| $this->getResponseBody()->setMessage('Sikeres aktualizáció'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | } | ||||
| $uploadedFile->setWorkFlow(WorkFlow::COMPARED); | |||||
| $this->getFileFactory()->save($uploadedFile); | |||||
| unset($result['products'], $result['manufacturer']); | |||||
| $this->getResponseBody()->setMessage('Sikeres szinkronizáció'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| public function actualiseProductData(Request $request) { | |||||
| $fid = $request->request->get('fid'); | |||||
| $this->getResponseBody()->setFid($fid); | |||||
| $this->getResponseBody()->setMessage('Sikertelen aktualizáció'); | |||||
| if ($this->currentUser->isAnonymous() || !$this->isAdmin()) { | |||||
| $this->getResponseBody()->setMessage('Sikertelen azonosítás'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile = $this->getFileFactory()->find($fid); | |||||
| if (empty($uploadedFile) || empty($fid)) { | |||||
| $this->getResponseBody()->setMessage('Nincs ilyen fájl'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| if (empty($uploadedFile->getTotalProducts() < 1)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájl nem tartalmaz termékeket'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $products = $this->getProductFactory()->findProductsByUploadedFileId($uploadedFile->getId()); | |||||
| if (empty($products)) { | |||||
| $this->getResponseBody()->setMessage('A feltöltött fájlhoz kapcsolódó termékek nem találhatóak'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $modifiedProducts = []; | |||||
| /* @var $product Product */ | |||||
| foreach ($products as $product) { | |||||
| if ($product->getModifiedAt() > $uploadedFile->getModifiedAt()) { | |||||
| $modifiedProducts[] = $product; | |||||
| } | |||||
| } | |||||
| $result = [ | |||||
| 'products' => $modifiedProducts, | |||||
| 'manufacturer' => $this->getManufacturerFactory()->find($uploadedFile->getParentManufacturerId()), | |||||
| 'totalActualised' => 0, | |||||
| 'newProduct' => 0, | |||||
| 'updatedProduct' => 0, | |||||
| 'status' => false, | |||||
| ]; | |||||
| $result = $this->getProductFactory()->actualiseProducts($result); | |||||
| if ($result['totalActualised'] === 0 || !$result['status']) { | |||||
| $this->getResponseBody()->setMessage('Nincs aktualizálható termék - ellenőrizze a konfigurációkat'); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| $uploadedFile->setWorkFlow(WorkFlow::ACTIVATED); | |||||
| $this->getFileFactory()->save($uploadedFile); | |||||
| unset($result['products'], $result['manufacturer']); | |||||
| $this->getResponseBody()->setMessage('Sikeres aktualizáció'); | |||||
| $this->getResponseBody()->setData($result); | |||||
| $this->getResponseBody()->setSuccess(1); | |||||
| $this->getResponse()->setData($this->getResponseBody()->toArray()); | |||||
| return $this->getResponse(); | |||||
| } | |||||
| } | } |
| private ?int $parentCategoryId = null; | private ?int $parentCategoryId = null; | ||||
| private ?int $parentComponentId = null; | private ?int $parentComponentId = null; | ||||
| private ?int $currentCount = 1; | private ?int $currentCount = 1; | ||||
| private ?int $revoked = 0; | |||||
| /* | /* | ||||
| * This tells if this axico id is next in the line | * This tells if this axico id is next in the line | ||||
| * | * | ||||
| public function close() { | public function close() { | ||||
| $this->nextCount = 0; | $this->nextCount = 0; | ||||
| $this->revoked = 0; | |||||
| } | } | ||||
| public function addToCurrentCount($count) { | public function addToCurrentCount($count) { | ||||
| public function getNextCount(): ?int { | public function getNextCount(): ?int { | ||||
| return $this->nextCount; | return $this->nextCount; | ||||
| } | } | ||||
| public function getRevoked(): ?int { | |||||
| return $this->revoked; | |||||
| } | |||||
| public function getProductId(): ?int { | public function getProductId(): ?int { | ||||
| return $this->productId; | return $this->productId; | ||||
| public function setNextCount(?int $nextCount): void { | public function setNextCount(?int $nextCount): void { | ||||
| $this->nextCount = $nextCount; | $this->nextCount = $nextCount; | ||||
| } | } | ||||
| public function setRevoked(?int $revoked): void { | |||||
| $this->revoked = $revoked; | |||||
| } | |||||
| public function setProductId(?int $productId): void { | public function setProductId(?int $productId): void { | ||||
| $this->productId = $productId; | $this->productId = $productId; |
| $this->setSheetIndex($product->getSheetIndex()); | $this->setSheetIndex($product->getSheetIndex()); | ||||
| } | } | ||||
| public function isSorted(): bool { | |||||
| public function isAxicoProductGroupSorted(): bool { | |||||
| return !empty($this->getParentCategoryId()) || !empty($this->getParentComponentId()); | return !empty($this->getParentCategoryId()) || !empty($this->getParentComponentId()); | ||||
| } | } | ||||
| use Drupal\Core\Session\AccountInterface; | use Drupal\Core\Session\AccountInterface; | ||||
| use stdClass; | use stdClass; | ||||
| class AxicoIdFactory extends AbstractFactory | |||||
| { | |||||
| class AxicoIdFactory extends AbstractFactory { | |||||
| use AxicoIdTrait; | use AxicoIdTrait; | ||||
| public function __construct(Connection $connection, AccountInterface $currentUser, | public function __construct(Connection $connection, AccountInterface $currentUser, | ||||
| TimeInterface $time) { | |||||
| TimeInterface $time) { | |||||
| parent::__construct($connection, $currentUser, $time, 'axico_id'); | parent::__construct($connection, $currentUser, $time, 'axico_id'); | ||||
| } | } | ||||
| public function create(): AxicoId | |||||
| { | |||||
| public function create(): AxicoId { | |||||
| return new AxicoId(); | return new AxicoId(); | ||||
| } | } | ||||
| public function createForCategory(int $manufacturerId, int $categoryId): AxicoId | |||||
| { | |||||
| public function createForCategory(int $manufacturerId, int $categoryId): AxicoId { | |||||
| $axicoIdEntity = $this->create(); | $axicoIdEntity = $this->create(); | ||||
| $axicoIdEntity->setParentManufacturerId($manufacturerId); | $axicoIdEntity->setParentManufacturerId($manufacturerId); | ||||
| $axicoIdEntity->setParentCategoryId($categoryId); | |||||
| $axicoIdEntity->setParentComponentId(null); | $axicoIdEntity->setParentComponentId(null); | ||||
| $axicoIdEntity->setParentCategoryId($categoryId); | |||||
| $axicoIdEntity->setNextCount(1); | $axicoIdEntity->setNextCount(1); | ||||
| return $axicoIdEntity; | return $axicoIdEntity; | ||||
| } | } | ||||
| public function createForComponent(int $manufacturerId, int $componentId): AxicoId | |||||
| { | |||||
| public function createForComponent(int $manufacturerId, int $componentId): AxicoId { | |||||
| $axicoIdEntity = $this->create(); | $axicoIdEntity = $this->create(); | ||||
| $axicoIdEntity->setParentManufacturerId($manufacturerId); | $axicoIdEntity->setParentManufacturerId($manufacturerId); | ||||
| return $axicoIdEntity; | return $axicoIdEntity; | ||||
| } | } | ||||
| public function resetAxicoIdEntity(AxicoId $axicoIdEntity): void | |||||
| { | |||||
| public function resetAxicoIdEntity(AxicoId $axicoIdEntity): void { | |||||
| $this->reviveAxicoIdEntity($axicoIdEntity); | $this->reviveAxicoIdEntity($axicoIdEntity); | ||||
| } | } | ||||
| public function reviveAxicoIdEntity(AxicoId $axicoIdEntity): AxicoId | |||||
| { | |||||
| public function reviveAxicoIdEntity(AxicoId $axicoIdEntity): AxicoId { | |||||
| $axicoIdEntity->setNextCount(1); | $axicoIdEntity->setNextCount(1); | ||||
| $axicoIdEntity->setProductId(null); | $axicoIdEntity->setProductId(null); | ||||
| $axicoIdEntity->setRevoked(1); | |||||
| return $this->save($axicoIdEntity); | return $this->save($axicoIdEntity); | ||||
| } | } | ||||
| public function deleteNextAxicoIdEntityIfExists($axicoIdEntity): void | |||||
| { | |||||
| public function deleteNextAxicoIdEntityIfExists($axicoIdEntity): void { | |||||
| $nextComponentAxicoId = null; | $nextComponentAxicoId = null; | ||||
| if ($axicoIdEntity->isComponentBased()) { | if ($axicoIdEntity->isComponentBased()) { | ||||
| $nextComponentAxicoId = $this->findNextAxicoIdByComponent($axicoIdEntity->getParentManufacturerId(), $axicoIdEntity->getParentComponentId()); | |||||
| $nextComponentAxicoId = $this->findOrCreateNextAxicoIdByManufacturerIdAndComponentId($axicoIdEntity->getParentManufacturerId(), $axicoIdEntity->getParentComponentId()); | |||||
| } else { | } else { | ||||
| $nextComponentAxicoId = $this->findNextAxicoIdByCategory($axicoIdEntity->getParentManufacturerId(), $axicoIdEntity->getParentCategoryId()); | |||||
| $nextComponentAxicoId = $this->findOrCreateNextAxicoIdByManufacturerIdAndCategoryId($axicoIdEntity->getParentManufacturerId(), $axicoIdEntity->getParentCategoryId()); | |||||
| } | } | ||||
| if ($nextComponentAxicoId) { | if ($nextComponentAxicoId) { | ||||
| if ($nextComponentAxicoId->getId() != $axicoIdEntity->getId()) { | if ($nextComponentAxicoId->getId() != $axicoIdEntity->getId()) { | ||||
| $this->delete($nextComponentAxicoId); | $this->delete($nextComponentAxicoId); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public function findByProductId(int $id): ?AxicoId | |||||
| { | |||||
| public function findByProductId(int $id): ?AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('product_id', $id) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('product_id', $id) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return $this->load($data); | return $this->load($data); | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function findNextAxicoIdByCategory(int $parentManufacturerId, int $parentCategoryId): ?AxicoId | |||||
| { | |||||
| /** | |||||
| * Find Or Create Next AxicoId By Category based parent category | |||||
| * | |||||
| * - search for the lowest free and next count 1 (possibly revoked or it is the highest next actual) | |||||
| * - create new based on highest taken and current count 1 (regular way) | |||||
| * | |||||
| * | |||||
| * @param int $parentManufacturerId | |||||
| * @param int $parentCategoryId | |||||
| * @return AxicoId|null | |||||
| */ | |||||
| public function findOrCreateNextAxicoIdByManufacturerIdAndCategoryId(int $parentManufacturerId, int $parentCategoryId): ?AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $parentManufacturerId) | |||||
| ->condition('w.parent_category_id', $parentCategoryId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.id', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $parentManufacturerId) | |||||
| ->condition('w.parent_category_id', $parentCategoryId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.id', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if (empty($data)) { | |||||
| $data = $this->getConnection() | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $parentManufacturerId) | |||||
| ->condition('w.parent_category_id', $parentCategoryId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | |||||
| $newEntity = $this->load($data); | |||||
| $newEntity->setId(null); | |||||
| $newEntity->setProductId(null); | |||||
| $newEntity->addToCurrentCount(1); | |||||
| $newEntity->setNextCount(1); | |||||
| return $this->save($newEntity); | |||||
| } | |||||
| return null; | |||||
| } else { | |||||
| if (!empty($data)) { | |||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| $data = $this->getConnection() | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $parentManufacturerId) | |||||
| ->condition('w.parent_category_id', $parentCategoryId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if (!empty($data)) { | |||||
| $newEntity = $this->load($data); | |||||
| $newEntity->setId(null); | |||||
| $newEntity->setProductId(null); | |||||
| $newEntity->addToCurrentCount(1); | |||||
| $newEntity->setNextCount(1); | |||||
| return $this->save($newEntity); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| public function findNextAxicoIdByComponent(int $manufacturerId, int $componentId): ?AxicoId | |||||
| { | |||||
| /** | |||||
| * Find Or Create Next AxicoId By Component based Parent Category | |||||
| * | |||||
| * - search for the lowest free and next count 1 (possibly revoked or it is the highest next actual) | |||||
| * - create new based on highest taken and current count 1 (regular way) | |||||
| * | |||||
| * @param int $manufacturerId | |||||
| * @param int $componentId | |||||
| * @return AxicoId|null | |||||
| */ | |||||
| public function findOrCreateNextAxicoIdByManufacturerIdAndComponentId(int $manufacturerId, int $componentId): ?AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.id', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.id', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if (empty($data)) { | |||||
| $data = $this->getConnection() | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | |||||
| $newEntity = $this->load($data); | |||||
| $newEntity->setId(null); | |||||
| $newEntity->setProductId(null); | |||||
| $newEntity->setNextCount(1); | |||||
| $newEntity->addToCurrentCount(1); | |||||
| return $this->save($newEntity); | |||||
| } | |||||
| return null; | |||||
| } else { | |||||
| if (!empty($data)) { | |||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| $data = $this->getConnection() | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if (!empty($data)) { | |||||
| $newEntity = $this->load($data); | |||||
| $newEntity->setId(null); | |||||
| $newEntity->setProductId(null); | |||||
| $newEntity->setNextCount(1); | |||||
| $newEntity->addToCurrentCount(1); | |||||
| return $this->save($newEntity); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| public function isAxicoIdPresentInGroup(int $manufacturerId, ?int $categoryId, ?int $componentId): bool | |||||
| { | |||||
| public function isAxicoIdPresentInGroup(int $manufacturerId, ?int $categoryId, ?int $componentId): bool { | |||||
| if ($categoryId) { | if ($categoryId) { | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| return !empty($data); | return !empty($data); | ||||
| } | } | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| return !empty($data); | return !empty($data); | ||||
| } | } | ||||
| protected function insert(AbstractEntity $entity): AxicoId | |||||
| { | |||||
| protected function insert(AbstractEntity $entity): AxicoId { | |||||
| $id = $this->getConnection() | $id = $this->getConnection() | ||||
| ->insert($this->getActiveTable()) | |||||
| ->fields([ | |||||
| 'name' => $entity->getName(), | |||||
| 'status' => $entity->getStatus(), | |||||
| 'parent_category_id' => $entity->getParentCategoryId(), | |||||
| 'parent_manufacturer_id' => $entity->getParentManufacturerId(), | |||||
| 'parent_component_id' => $entity->getParentComponentId(), | |||||
| 'product_id' => $entity->getProductId(), | |||||
| 'current_count' => $entity->getCurrentCount(), | |||||
| 'next_count' => $entity->getNextCount(), | |||||
| 'created_at' => date('Y-m-d H:i:s', $this->getTime()->getRequestTime()), | |||||
| 'created_by' => $this->getCurrentUser()->id(), | |||||
| ]) | |||||
| ->execute(); | |||||
| ->insert($this->getActiveTable()) | |||||
| ->fields([ | |||||
| 'name' => $entity->getName(), | |||||
| 'status' => $entity->getStatus(), | |||||
| 'parent_category_id' => $entity->getParentCategoryId(), | |||||
| 'parent_manufacturer_id' => $entity->getParentManufacturerId(), | |||||
| 'parent_component_id' => $entity->getParentComponentId(), | |||||
| 'product_id' => $entity->getProductId(), | |||||
| 'current_count' => $entity->getCurrentCount(), | |||||
| 'next_count' => $entity->getNextCount(), | |||||
| 'revoked' => $entity->getRevoked(), | |||||
| 'created_at' => date('Y-m-d H:i:s', $this->getTime()->getRequestTime()), | |||||
| 'created_by' => $this->getCurrentUser()->id(), | |||||
| ]) | |||||
| ->execute(); | |||||
| $entity->setId($id); | $entity->setId($id); | ||||
| return $entity; | return $entity; | ||||
| } | } | ||||
| protected function update(AbstractEntity $entity): AxicoId | |||||
| { | |||||
| protected function update(AbstractEntity $entity): AxicoId { | |||||
| $this->getConnection() | $this->getConnection() | ||||
| ->update($this->getActiveTable()) | |||||
| ->fields([ | |||||
| 'name' => $entity->getName(), | |||||
| 'status' => $entity->getStatus(), | |||||
| 'parent_category_id' => $entity->getParentCategoryId(), | |||||
| 'parent_manufacturer_id' => $entity->getParentManufacturerId(), | |||||
| 'parent_component_id' => $entity->getParentComponentId(), | |||||
| 'product_id' => $entity->getProductId(), | |||||
| 'current_count' => $entity->getCurrentCount(), | |||||
| 'next_count' => $entity->getNextCount(), | |||||
| 'modified_at' => date('Y-m-d H:i:s', $this->getTime()->getRequestTime()), | |||||
| 'modified_by' => $this->getCurrentUser()->id(), | |||||
| ]) | |||||
| ->condition('id', $entity->getId()) | |||||
| ->execute(); | |||||
| ->update($this->getActiveTable()) | |||||
| ->fields([ | |||||
| 'name' => $entity->getName(), | |||||
| 'status' => $entity->getStatus(), | |||||
| 'parent_category_id' => $entity->getParentCategoryId(), | |||||
| 'parent_manufacturer_id' => $entity->getParentManufacturerId(), | |||||
| 'parent_component_id' => $entity->getParentComponentId(), | |||||
| 'product_id' => $entity->getProductId(), | |||||
| 'current_count' => $entity->getCurrentCount(), | |||||
| 'next_count' => $entity->getNextCount(), | |||||
| 'revoked' => $entity->getRevoked(), | |||||
| 'modified_at' => date('Y-m-d H:i:s', $this->getTime()->getRequestTime()), | |||||
| 'modified_by' => $this->getCurrentUser()->id(), | |||||
| ]) | |||||
| ->condition('id', $entity->getId()) | |||||
| ->execute(); | |||||
| return $entity; | return $entity; | ||||
| } | } | ||||
| protected function load(stdClass $data): AxicoId | |||||
| { | |||||
| protected function load(stdClass $data): AxicoId { | |||||
| $entity = $this->create(); | $entity = $this->create(); | ||||
| $entity->setId($data->id); | $entity->setId($data->id); | ||||
| $entity->setName($data->name); | $entity->setName($data->name); | ||||
| $entity->setProductId($data->product_id); | $entity->setProductId($data->product_id); | ||||
| $entity->setCurrentCount($data->current_count); | $entity->setCurrentCount($data->current_count); | ||||
| $entity->setNextCount($data->next_count); | $entity->setNextCount($data->next_count); | ||||
| $entity->setRevoked($data->revoked); | |||||
| $entity->setCreatedAt($data->created_at); | $entity->setCreatedAt($data->created_at); | ||||
| $entity->setCreatedBy($data->created_by); | $entity->setCreatedBy($data->created_by); | ||||
| $entity->setModifiedAt($data->modified_at); | $entity->setModifiedAt($data->modified_at); | ||||
| return $entity; | return $entity; | ||||
| } | } | ||||
| public function importAll(array $data): array | |||||
| { | |||||
| public function importAll(array $data): array { | |||||
| foreach ($data as $i => $manufacturerData) { | foreach ($data as $i => $manufacturerData) { | ||||
| /* @var $manufacturerData['manufacturer'] Manufacturer */ | /* @var $manufacturerData['manufacturer'] Manufacturer */ | ||||
| if ($manufacturerData['manufacturer']->isComponentBased()) { | if ($manufacturerData['manufacturer']->isComponentBased()) { | ||||
| return $data; | return $data; | ||||
| } | } | ||||
| public function createForEachComponent(array $data): array | |||||
| { | |||||
| public function createForEachComponent(array $data): array { | |||||
| foreach ($data as $key => $componentData) { | foreach ($data as $key => $componentData) { | ||||
| foreach ($componentData['components'] as $manufacturerId => $componentWrapper) { | foreach ($componentData['components'] as $manufacturerId => $componentWrapper) { | ||||
| /* @var $component Component */ | /* @var $component Component */ | ||||
| if (!$component instanceof Component) { | if (!$component instanceof Component) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $existingAxicoId = $this->findNextAxicoIdByComponent($manufacturerId, $component->getId()); | |||||
| $existingAxicoId = $this->findOrCreateNextAxicoIdByManufacturerIdAndComponentId($manufacturerId, $component->getId()); | |||||
| if (empty($existingAxicoId)) { | if (empty($existingAxicoId)) { | ||||
| $entity = $this->createForComponent($manufacturerId, $component->getId()); | $entity = $this->createForComponent($manufacturerId, $component->getId()); | ||||
| $entity->setName($data[$key]['manufacturers'][$manufacturerId]->getAxicoIdName() . $component->getAxicoIdName()); | $entity->setName($data[$key]['manufacturers'][$manufacturerId]->getAxicoIdName() . $component->getAxicoIdName()); | ||||
| return $data; | return $data; | ||||
| } | } | ||||
| public function findHighestCurrentAxicoIdByComponentId(int $componentId): ?AxicoId | |||||
| { | |||||
| public function findHighestCurrentAxicoIdByComponentId(int $componentId): ?AxicoId { | |||||
| $item = $this->getConnection() | $item = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($item) { | if ($item) { | ||||
| return $this->load($item); | return $this->load($item); | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function findHighestCurrentAxicoIdByManufacturerIdAndCategoryIdAndComponentId(int $manufacturerId, ?int $categoryId, ?int $componentId): ?AxicoId | |||||
| { | |||||
| public function findHighestCurrentAxicoIdByManufacturerIdAndCategoryIdAndComponentId(int $manufacturerId, ?int $categoryId, ?int $componentId): ?AxicoId { | |||||
| $data = null; | $data = null; | ||||
| if ($categoryId) { | if ($categoryId) { | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->orderBy('current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->orderBy('current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| } else { | } else { | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->orderBy('current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| } | } | ||||
| if (!empty($data)) { | if (!empty($data)) { | ||||
| return $this->load($data[0]); | return $this->load($data[0]); | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function findFirstFakeAxicoIdByManufacturerIdAndCategoryIdAndComponentId(int $manufacturerId, ?int $categoryId, ?int $componentId): ?AxicoId | |||||
| { | |||||
| public function findFirstFakeAxicoIdByManufacturerIdAndCategoryIdAndComponentId(int $manufacturerId, ?int $categoryId, ?int $componentId): ?AxicoId { | |||||
| $data = null; | $data = null; | ||||
| if ($categoryId) { | if ($categoryId) { | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.product_id') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.current_count', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.product_id') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_category_id', $categoryId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.current_count', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| } else { | } else { | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.product_id') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.current_count', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.product_id') | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.parent_component_id', $componentId) | |||||
| ->condition('w.next_count', 1) | |||||
| ->orderBy('w.current_count', 'ASC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| } | } | ||||
| if (!empty($data)) { | if (!empty($data)) { | ||||
| return $this->load($data[0]); | return $this->load($data[0]); | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function findByFullProductAxicoId(string $productAxicoId): ?AxicoId | |||||
| { | |||||
| public function findByFullProductAxicoId(string $productAxicoId): ?AxicoId { | |||||
| $manufacturer = $this->getManufacturerAxicoId($productAxicoId); | $manufacturer = $this->getManufacturerAxicoId($productAxicoId); | ||||
| $group = $this->getGroupAxicoId($productAxicoId); | $group = $this->getGroupAxicoId($productAxicoId); | ||||
| $count = $this->getGroupCount($productAxicoId); | $count = $this->getGroupCount($productAxicoId); | ||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('name', $manufacturer . $group) | |||||
| ->condition('current_count', $count) | |||||
| ->condition('next_count', 0) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('name', $manufacturer . $group) | |||||
| ->condition('current_count', $count) | |||||
| ->condition('next_count', 0) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function addZeros(int $currentCount): string | |||||
| { | |||||
| public function addZeros(int $currentCount): string { | |||||
| if ($currentCount >= 999) { | if ($currentCount >= 999) { | ||||
| return (string) $currentCount; | return (string) $currentCount; | ||||
| } | } | ||||
| return '00' . (string) $currentCount; | return '00' . (string) $currentCount; | ||||
| } | } | ||||
| public function findHighestCountByComponentAxicoIdName(string $erroneusAxicoId): AxicoId | |||||
| { | |||||
| public function findHighestCountByComponentAxicoIdName(string $erroneusAxicoId): AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.parent_category_id') | |||||
| ->condition('w.name', $erroneusAxicoId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.parent_category_id') | |||||
| ->condition('w.name', $erroneusAxicoId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| } | } | ||||
| public function findHighestCountByCategoryAxicoIdName(string $erroneusAxicoId): AxicoId | |||||
| { | |||||
| public function findHighestCountByCategoryAxicoIdName(string $erroneusAxicoId): AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.parent_component_id') | |||||
| ->condition('w.name', $erroneusAxicoId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->isNull('w.parent_component_id') | |||||
| ->condition('w.name', $erroneusAxicoId) | |||||
| ->orderBy('w.current_count', 'DESC') | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| } | } | ||||
| public function removeErrors(): void | |||||
| { | |||||
| public function removeErrors(): void { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->condition('w.current_count', 1) | |||||
| ->condition('w.next_count', 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->condition('w.current_count', 1) | |||||
| ->condition('w.next_count', 1) | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| $entities = $this->loadAll($data); | $entities = $this->loadAll($data); | ||||
| foreach ($entities as $entity) { | foreach ($entities as $entity) { | ||||
| } | } | ||||
| } | } | ||||
| public function loadAll(array $data): array | |||||
| { | |||||
| public function loadAll(array $data): array { | |||||
| $entities = []; | $entities = []; | ||||
| if (empty($data)) { | if (empty($data)) { | ||||
| return $entities; | return $entities; | ||||
| } | } | ||||
| public function followingExists(AxicoId $entity): bool | |||||
| { | |||||
| public function followingExists(AxicoId $entity): bool { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_category_id', $entity->getParentCategoryId()) | |||||
| ->condition('w.parent_component_id', $entity->getParentComponentId()) | |||||
| ->condition('w.parent_manufacturer_id', $entity->getParentManufacturerId()) | |||||
| ->condition('w.current_count', '>', 0) | |||||
| ->condition('w.next_count', 1) | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.parent_category_id', $entity->getParentCategoryId()) | |||||
| ->condition('w.parent_component_id', $entity->getParentComponentId()) | |||||
| ->condition('w.parent_manufacturer_id', $entity->getParentManufacturerId()) | |||||
| ->condition('w.current_count', '>', 0) | |||||
| ->condition('w.next_count', 1) | |||||
| ->range(0, 1) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function findPreviousAxicoIdEntity(string $groupName, int $manufacturerId, int $previousCount): ?AxicoId | |||||
| { | |||||
| public function findPreviousAxicoIdEntity(string $groupName, int $manufacturerId, int $previousCount): ?AxicoId { | |||||
| $data = $this->getConnection() | $data = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.name', $groupName) | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.current_count', $previousCount) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->fields('w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->condition('w.name', $groupName) | |||||
| ->condition('w.parent_manufacturer_id', $manufacturerId) | |||||
| ->condition('w.current_count', $previousCount) | |||||
| ->execute() | |||||
| ->fetchObject(); | |||||
| if ($data) { | if ($data) { | ||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function findAllDistinct(): array | |||||
| { | |||||
| public function findAllDistinct(): array { | |||||
| $axicoIds = $this->getConnection() | $axicoIds = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->distinct() | |||||
| ->fields('w', array('name')) | |||||
| ->orderBy('name') | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| ->select($this->getActiveTable(), 'w') | |||||
| ->isNull('w.deleted_at') | |||||
| ->distinct() | |||||
| ->fields('w', array('name')) | |||||
| ->orderBy('name') | |||||
| ->execute() | |||||
| ->fetchAll(); | |||||
| return $axicoIds; | return $axicoIds; | ||||
| } | } | ||||
| } | } |
| <div id="custom-table-wrapper"> | <div id="custom-table-wrapper"> | ||||
| <table class="table product-list"> | |||||
| <tbody> | |||||
| <tr> | |||||
| <th>Letöltésre</th> | |||||
| <th>Név</th> | |||||
| <th>Gyártói cikkszám</th> | |||||
| <th>Axico név</th> | |||||
| <th>Axico cikkszám</th> | |||||
| {% if cikkszam|length is same as(0) %} | |||||
| <th>{% if file.componentBased is same as(0) %}Termékcsoport{% else %}Komponens{% endif %}</th> | |||||
| {% endif %} | |||||
| <th>Változások</th> | |||||
| <th>Ár</th> | |||||
| <th> | |||||
| Aktív | |||||
| </th> | |||||
| <th>Munkafolyamat</th> | |||||
| </tr> | |||||
| {% for product in products %} | |||||
| {% set loopIndex = loop.index %} | |||||
| <tr class="correct-files-uploaded-product" | |||||
| data-field-request-status="ready" | |||||
| data-field-uploaded-file-id="{{ product.uploadedFileId }}" | |||||
| data-field-attr-mid="{{ product.parentManufacturerId }}" | |||||
| data-field-product-id="{{ product.id }}"> | |||||
| <td class="downloadable"> | |||||
| {% if product.correctStatus is not same as('VALTOZATLAN') | |||||
| <table class="table product-list"> | |||||
| <tbody> | |||||
| <tr> | |||||
| <th>Letöltésre</th> | |||||
| <th>Név</th> | |||||
| <th>Gyártói cikkszám</th> | |||||
| <th>Axico név</th> | |||||
| <th>Axico cikkszám</th> | |||||
| {% if cikkszam|length is same as(0) %} | |||||
| <th>{% if file.componentBased is same as(0) %}Termékcsoport{% else %}Komponens{% endif %}</th> | |||||
| {% endif %} | |||||
| <th>Változások</th> | |||||
| <th>Ár</th> | |||||
| <th> | |||||
| Aktív | |||||
| </th> | |||||
| <th>Munkafolyamat</th> | |||||
| </tr> | |||||
| {% for product in products %} | |||||
| {% set loopIndex = loop.index %} | |||||
| <tr class="correct-files-uploaded-product" | |||||
| data-field-request-status="ready" | |||||
| data-field-uploaded-file-id="{{ product.uploadedFileId }}" | |||||
| data-field-attr-mid="{{ product.parentManufacturerId }}" | |||||
| data-field-product-id="{{ product.id }}"> | |||||
| <td class="downloadable"> | |||||
| {% if product.correctStatus is not same as('VALTOZATLAN') | |||||
| and (product.parentCategoryId is not same as(null) or product.parentComponentId is not same as(null)) | and (product.parentCategoryId is not same as(null) or product.parentComponentId is not same as(null)) | ||||
| and product.axicoId|length is not same as(0) | and product.axicoId|length is not same as(0) | ||||
| and (product.workFlow is same as('ACTIVATED')) | and (product.workFlow is same as('ACTIVATED')) | ||||
| or (product.workFlow is same as('DELETED')) %} | or (product.workFlow is same as('DELETED')) %} | ||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %}</td> | |||||
| <td> | |||||
| <a href="{{ url('<front>') }}product/edit/{{ product.id }}/{{ page }}/{{ correctStatus }}/{{ keyWords }}/{{ listed }}/null{% if product.source is same as('live') %}/live{% else %}/uploaded{% endif %}/{{ file.parentManufacturerId }}/{{ file.id }}"> | |||||
| {% if product.name|length is not same as(0) %} | |||||
| {{ product.name }} | |||||
| {% else %} | |||||
| {{ product.fabricName}} | |||||
| {% endif %} | |||||
| </a> | |||||
| {% if product.different %} | |||||
| <div class="product-changes"> | |||||
| {% if product.fabricName is not same as(product.prevFabricName) and product.prevFabricName is not empty%} | |||||
| <span>Név</span> | |||||
| <span class="previous-value">{{ product.prevFabricName }}</span> | |||||
| <span class="new-value">{{ product.fabricName }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| <td>{{ product.fabricId }}</td> | |||||
| <td> | |||||
| {% if product.axicoName|length is not same as(0) %} | |||||
| {{ product.axicoName }} | |||||
| {% else %} | |||||
| {{ product.fabricName}} | |||||
| {% endif %} | |||||
| {% if product.different %} | |||||
| <div class="product-changes"> | |||||
| {% if product.axicoName is not same as(product.prevAxicoName) and product.prevAxicoName is not empty%} | |||||
| <span class="previous-value">{{ product.prevAxicoName }}</span> | |||||
| <span class="new-value">{{ product.axicoName }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| <td data-field-product-id-{{ product.id }}="{{ product.id }}" class="axico-id">{{ product.axicoId }}</td> | |||||
| {% if file.componentBased is same as(0) %} | |||||
| <td> | |||||
| <select class="product-list-category-select" name="product-category"> | |||||
| <option data-field-attr-mid="-1" value="-1">Kérem válasszon</option> | |||||
| {% for category in categories %} | |||||
| <option data-field-attr-mid="{{ product.parentManufacturerId }}" | |||||
| value="{{ product.parentManufacturerId }}-{{ category.id }}" | |||||
| {% if product.parentCategoryId is same as(category.id) %} selected {% endif %} | |||||
| {% if product.correctStatus == 'CORRECT_IMPORTED' %} disabled="true" {% endif %}>({{ category.axicoIdName }}) {{ category.name }}</option> | |||||
| {% endfor %} | |||||
| {% if product.axicoId|length is not same as(0) and product.correctStatus is not same as('CORRECT_IMPORTED') %} | |||||
| <option data-field-attr-mid="-1" | |||||
| value="0-0-revokeAxicoId" | |||||
| {% if product.correctStatus == 'CORRECT_IMPORTED' %} disabled="true" {% endif %}>Cikkszám visszavonása</option> | |||||
| {% endif %} | |||||
| </select> | |||||
| </td> | |||||
| {% else %} | |||||
| <td> | |||||
| <select class="product-list-component-select" name="product-component"> | |||||
| <option value="0-x">Kérem válasszon</option> | |||||
| {% for component in components %} | |||||
| <option value="{{ component.parentManufacturerId }}-{{ component.id }}" | |||||
| {% if product.parentComponentId is same as(component.id) %} selected {% endif %} | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} disabled="true" | |||||
| {% endif %}>{{ componentManufacturers[component.id] }} ({{ component.axicoIdName }}) {{ component.name }}</option> | |||||
| {% endfor %} | |||||
| {% if product.axicoId|length is not same as(0) and product.correctStatus is not same as('CORRECT_IMPORTED') %} | |||||
| <option data-field-attr-mid="-1" | |||||
| value="0-0-revokeAxicoId" | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} disabled="true"{% endif %}>Cikkszám visszavonása</option> | |||||
| {% endif %} | |||||
| </select> | |||||
| </td> | |||||
| {% endif %} | |||||
| <td class="changes"> | |||||
| <select class="product-correct-status" name="product_correct_status" disabled="true"> | |||||
| {% for key,value in correctStatuses %} | |||||
| <option value="{{ key }}" {% if product.correctStatus is same as(key) %} selected {% endif %}>{{ value }}</option> | |||||
| {% endfor %} | |||||
| </select> | |||||
| {% if product.different %} | |||||
| <span class="changed-data">{{ icons['change'] }}</span> | |||||
| <div class="product-changes"> | |||||
| {% if product.warranty is not same as(product.prevWarranty) and product.prevWarranty is not empty %} | |||||
| <span>Garancia</span> | |||||
| <span class="previous-value">{{ product.prevWarranty }}</span> | |||||
| <span class="new-value">{{ product.warranty }}</span> | |||||
| {% endif %} | |||||
| {% if product.notes is not same as(product.prevNotes) and product.prevNotes is not empty %} | |||||
| <span>Megjegyzések</span> | |||||
| <span class="previous-value">{{ product.prevNotes }}</span> | |||||
| <span class="new-value">{{ product.notes }}</span> | |||||
| {% endif %} | |||||
| {% if product.description is not same as(product.prevDescription) and product.prevDescription is not empty %} | |||||
| <span>Leírás</span> | |||||
| <span class="previous-value">{{ product.prevDescription }}</span> | |||||
| <span class="new-value">{{ product.description }}</span> | |||||
| {% endif %} | |||||
| {% if product.eol is not same as(product.prevEol) and product.prevEol is not empty %} | |||||
| <span>EOL</span> | |||||
| <span class="previous-value">{{ product.prevEol }}</span> | |||||
| <span class="new-value">{{ product.eol }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| {% if product.currency == 'HUF' %} | |||||
| <td> | |||||
| {{ product.price|number_format( 0, ',', '.' ) }} {{ product.currency }} | |||||
| </td> | |||||
| {% else %} | |||||
| <td> | |||||
| {{ product.price|number_format( 2, ',', '.' ) }} {{ product.currency }} | |||||
| <div> | |||||
| {% if product.prevPrice < product.price and product.different and product.prevPrice > 0 %} | |||||
| <span class="changed-data">{{ icons['plus'] }}{{ (product.price - product.prevPrice)|number_format(2, ',','.') }}</span> | |||||
| <span class="previous-value">{{ product.prevPrice|number_format(2, ',','.') }}</span> | |||||
| {% endif %} | |||||
| {% if product.prevPrice > product.price and product.different and product.prevPrice > 0 %} | |||||
| <span class="changed-data">{{ icons['minus'] }}{{ (product.price - product.prevPrice)|number_format(2, ',','.') }}</span> | |||||
| <span class="previous-value">{{ product.prevPrice|number_format(2, ',','.') }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| </td> | |||||
| {% endif %} | |||||
| <td> | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} | |||||
| {% if product.status is same as (1) %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| {% if product.correctStatus is same as('FRISSITENDO') %} | |||||
| {% if product.workFlow is same as ('ACTIVATED') %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| {% if product.correctStatus is same as('UJ') %} | |||||
| {% if product.workFlow is same as ('ACTIVATED') %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| </td> | |||||
| <td> | |||||
| <select class="product-work-flow" name="product_work_flow" disabled="true"> | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} | |||||
| <option value="ACTIVATED" selected>Aktiválva</option> | |||||
| {% else %} | |||||
| {% for key,value in workFlows %} | |||||
| <option value="{{ key }}" {% if product.workFlow is same as(key) %} selected {% endif %}>{{ value }}</option> | |||||
| {% endfor %} | |||||
| {% endif %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %}</td> | |||||
| <td> | |||||
| <a href="{{ url('<front>') }}product/edit/{{ product.id }}/{{ page }}/{{ correctStatus }}/{{ keyWords }}/{{ listed }}/null{% if product.source is same as('live') %}/live{% else %}/uploaded{% endif %}/{{ file.parentManufacturerId }}/{{ file.id }}"> | |||||
| {% if product.name|length is not same as(0) %} | |||||
| {{ product.name }} | |||||
| {% else %} | |||||
| {{ product.fabricName}} | |||||
| {% endif %} | |||||
| </a> | |||||
| {% if product.different %} | |||||
| <div class="product-changes"> | |||||
| {% if product.fabricName is not same as(product.prevFabricName) and product.prevFabricName is not empty%} | |||||
| <span>Név</span> | |||||
| <span class="previous-value">{{ product.prevFabricName }}</span> | |||||
| <span class="new-value">{{ product.fabricName }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| <td>{{ product.fabricId }}</td> | |||||
| <td> | |||||
| {% if product.axicoName|length is not same as(0) %} | |||||
| {{ product.axicoName }} | |||||
| {% else %} | |||||
| {{ product.fabricName}} | |||||
| {% endif %} | |||||
| {% if product.different %} | |||||
| <div class="product-changes"> | |||||
| {% if product.axicoName is not same as(product.prevAxicoName) and product.prevAxicoName is not empty%} | |||||
| <span class="previous-value">{{ product.prevAxicoName }}</span> | |||||
| <span class="new-value">{{ product.axicoName }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| <td data-field-product-id-{{ product.id }}="{{ product.id }}" class="axico-id">{{ product.axicoId }}</td> | |||||
| {% if file.componentBased is same as(0) %} | |||||
| <td> | |||||
| <select class="product-list-category-select" name="product-category"> | |||||
| <option data-field-attr-mid="-1" value="-1">Kérem válasszon</option> | |||||
| {% for category in categories %} | |||||
| <option data-field-attr-mid="{{ product.parentManufacturerId }}" value="{{ product.parentManufacturerId }}-{{ category.id }}" | |||||
| {% if product.parentCategoryId is same as(category.id) %} selected {% endif %}>({{ category.axicoIdName }}) {{ category.name }}</option> | |||||
| {% endfor %} | |||||
| <option data-field-attr-mid="-1" value="0-0-revokeAxicoId">Cikkszám visszavonása</option> | |||||
| </select> | |||||
| </td> | |||||
| {% else %} | |||||
| <td> | |||||
| <select class="product-list-component-select" name="product-component"> | |||||
| <option value="0-x">Kérem válasszon</option> | |||||
| {% for component in components %} | |||||
| <option value="{{ component.parentManufacturerId }}-{{ component.id }}" | |||||
| {% if product.parentComponentId is same as(component.id) %} selected {% endif %} | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} disabled="true" | |||||
| {% endif %}>{{ componentManufacturers[component.id] }} ({{ component.axicoIdName }}) {{ component.name }}</option> | |||||
| {% endfor %} | |||||
| {% if product.axicoId|length is not same as(0) and product.correctStatus is not same as('CORRECT_IMPORTED') %} | |||||
| <option data-field-attr-mid="-1" | |||||
| value="0-0-revokeAxicoId" | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} disabled="true"{% endif %}>Cikkszám visszavonása</option> | |||||
| {% endif %} | |||||
| </select> | |||||
| </td> | |||||
| {% endif %} | |||||
| <td class="changes"> | |||||
| <select class="product-correct-status" name="product_correct_status" disabled="true"> | |||||
| {% for key,value in correctStatuses %} | |||||
| <option value="{{ key }}" {% if product.correctStatus is same as(key) %} selected {% endif %}>{{ value }}</option> | |||||
| {% endfor %} | |||||
| </select> | |||||
| {% if product.different %} | |||||
| <span class="changed-data">{{ icons['change'] }}</span> | |||||
| <div class="product-changes"> | |||||
| {% if product.warranty is not same as(product.prevWarranty) and product.prevWarranty is not empty %} | |||||
| <span>Garancia</span> | |||||
| <span class="previous-value">{{ product.prevWarranty }}</span> | |||||
| <span class="new-value">{{ product.warranty }}</span> | |||||
| {% endif %} | |||||
| {% if product.notes is not same as(product.prevNotes) and product.prevNotes is not empty %} | |||||
| <span>Megjegyzések</span> | |||||
| <span class="previous-value">{{ product.prevNotes }}</span> | |||||
| <span class="new-value">{{ product.notes }}</span> | |||||
| {% endif %} | |||||
| {% if product.description is not same as(product.prevDescription) and product.prevDescription is not empty %} | |||||
| <span>Leírás</span> | |||||
| <span class="previous-value">{{ product.prevDescription }}</span> | |||||
| <span class="new-value">{{ product.description }}</span> | |||||
| {% endif %} | |||||
| {% if product.eol is not same as(product.prevEol) and product.prevEol is not empty %} | |||||
| <span>EOL</span> | |||||
| <span class="previous-value">{{ product.prevEol }}</span> | |||||
| <span class="new-value">{{ product.eol }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| {% endif %} | |||||
| </td> | |||||
| {% if product.currency == 'HUF' %} | |||||
| <td> | |||||
| {{ product.price|number_format( 0, ',', '.' ) }} {{ product.currency }} | |||||
| </td> | |||||
| {% else %} | |||||
| <td> | |||||
| {{ product.price|number_format( 2, ',', '.' ) }} {{ product.currency }} | |||||
| <div> | |||||
| {% if product.prevPrice < product.price and product.different and product.prevPrice > 0 %} | |||||
| <span class="changed-data">{{ icons['plus'] }}{{ (product.price - product.prevPrice)|number_format(2, ',','.') }}</span> | |||||
| <span class="previous-value">{{ product.prevPrice|number_format(2, ',','.') }}</span> | |||||
| {% endif %} | |||||
| {% if product.prevPrice > product.price and product.different and product.prevPrice > 0 %} | |||||
| <span class="changed-data">{{ icons['minus'] }}{{ (product.price - product.prevPrice)|number_format(2, ',','.') }}</span> | |||||
| <span class="previous-value">{{ product.prevPrice|number_format(2, ',','.') }}</span> | |||||
| {% endif %} | |||||
| </div> | |||||
| </td> | |||||
| {% endif %} | |||||
| <td> | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} | |||||
| {% if product.status is same as (1) %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| {% if product.correctStatus is same as('FRISSITENDO') %} | |||||
| {% if product.workFlow is same as ('ACTIVATED') %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| {% if product.correctStatus is same as('UJ') %} | |||||
| {% if product.workFlow is same as ('ACTIVATED') %} | |||||
| Igen | |||||
| {% else %} | |||||
| Nem | |||||
| {% endif %} | |||||
| {% endif %} | |||||
| </td> | |||||
| <td> | |||||
| <select class="product-work-flow" name="product_work_flow" disabled="true"> | |||||
| {% if product.correctStatus is same as('CORRECT_IMPORTED') %} | |||||
| <option value="ACTIVATED" selected>Aktiválva</option> | |||||
| {% else %} | |||||
| {% for key,value in workFlows %} | |||||
| <option value="{{ key }}" {% if product.workFlow is same as(key) %} selected {% endif %}>{{ value }}</option> | |||||
| {% endfor %} | |||||
| {% endif %} | |||||
| </select> | |||||
| </td> | |||||
| </tr> | |||||
| {% endfor %} | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| </select> | |||||
| </td> | |||||
| </tr> | |||||
| {% endfor %} | |||||
| </tbody> | |||||
| </table> | |||||
| </div> |
| -- Update 2023-04-26 | |||||
| ALTER TABLE `arlista_manager_axico_id` ADD `revoked` INT NOT NULL DEFAULT '0' AFTER `next_count`; | |||||
| -- Update 2023-01-19 | -- Update 2023-01-19 | ||||
| CREATE TABLE IF NOT EXISTS `arlista_manager_axico_id_warranty` ( | CREATE TABLE IF NOT EXISTS `arlista_manager_axico_id_warranty` ( |