| /* | /* | ||||
| !README.txt | !README.txt | ||||
| !.gitignore | !.gitignore | ||||
| !/modules | |||||
| !/modules | |||||
| !update.sql |
| - axico id starts from 1 instead of 0 | |||||
| - axico id can be higher than 999, as 1000 and 1001 etc, starting numbers will still have 3 characters, like ABCCBA001 | |||||
| - new product now can be added trough a file to the uplodaded products, as if it was inside the excel file | |||||
| - newly added product can be confirmed as ACTIVATED | |||||
| - saving a newly added product redirects on its self for further editing that allows inspecting its generated details as well | |||||
| - user is informed if no product can be found in the excel file | |||||
| - files now can have up to 25 sheets instead of 20 | |||||
| - default warranty can be set and saved in config form | |||||
| - axico id warranty entities can be listed and edited | |||||
| - axico id warranty entities can be refreshed from axic id table | |||||
| - new axico id warranties are stored with default warranty from drupal config | |||||
| - after saving a new product category or component, a new axico id warranty is stored with default warranty from config | |||||
| - products garancia field is filled trough | |||||
| -- Változás napló 2023-01-19 | |||||
| - az axico id 0 helyett 1-től kezdődik | |||||
| - az axico id nagyobb lehet 999-nél, például 1000 és 1001 stb., | |||||
| a kezdő számok továbbra is 3 karakterből állnak, mint például az ABCCBA001, | |||||
| - új termék mostantól egy fájlon keresztül hiba nélkül hozzáadható a | |||||
| feltöltött termékek listájához, mintha az az aktiv excel fájlban lett volna eredetileg is, | |||||
| - az ilyen módon, újonnan hozzáadott termék AKTIVÁLHATÓ, mint az élő adatbázisban szereplő termék, | |||||
| - az ilyen módon, újonnan hozzáadott termék mentése önmagára irányít át további szerkesztésre, | |||||
| amely lehetővé teszi a generált adatok részleteinek ellenőrzését is, | |||||
| - a felhasználó értesítést kap, ha az excel fájlban nem található termék, | |||||
| - FIGYELEM: az excel fájl formázása fennakadásokat okozhat, ezért célszerű eltávolitani | |||||
| minden formázást az összes oszlopról, különösen az árat illetőleg, | |||||
| csak számok szerepeljenek benne, pl 123.12 . Ezt, a cella oszlopot kijelölve a | |||||
| format: Text/Number, General segítségével tudjuk elérni. | |||||
| Semmiféleképpen sem legyen financial vagy currency jellegű az oszlop celláinak formázása, | |||||
| - a fájlok 20 helyett legfeljebb 25 munkalapból állhatnak, | |||||
| - az alapértelmezett garanciaérték (hónapokban) beállítható és elmenthető konfigurációs formában, | |||||
| - az axico id garanciális entitások listázhatók és szerkeszthetők, | |||||
| - az axico id garanciális entitások frissíthetők az axico id táblázatból | |||||
| (ezt csak 1x kell elvégezni a frissítés után, újra importálás során feltöltődik minden komponens és termékcsoport mentése után), | |||||
| - az új axico id garancia entitások a drupal config alapértelmezett jótállási értékével vannak tárolva, | |||||
| - új termékkategória vagy komponens mentésekor új axico id garancia kerül tárolásra | |||||
| a konfigurációból származó alapértelmezett garancia értékkel, | |||||
| - a termékek garancia mezője az alábbi munkafolyamatokban töltődik be: | |||||
| a.) excel import, garancia és korábbi jótállás be van állítva: | |||||
| - alapértelmezett jótállási érték a konfigurációból (ha nincs megadva az excel fájlban), | |||||
| - a korábbi garancia 0-ra van állítva, | |||||
| b.) ismert termék - a termékek összehasonlítása munkafolyamatban, | |||||
| az ismert termékek axico id garancia entitása alapján | |||||
| c.) új termék - kategóriafrissítésről vagy komponens frissítésről | |||||
| d.) termék hozzáadása vagy szerkesztése | |||||
| - a termékek "Frissitendo" jelzéssel lesznek ellátva, ha a korábbi garancia eltér a korábbi jótállástól | |||||
| - a garanciális változásokat a rendszer felismeri és megjeleníti a feltöltött termékek listájában, | |||||
| kék (korábbi) vagy zöld (módosított) egész értékkel jelölve (hónapokban az egérmutatót a zöld bal/jobb nyilakon jelzik), | |||||
| ha az aktuális garancia (lásd fentebb a módszereket) eltér a korábbi garancia értéktől, | |||||
| - a garanciális változtatásokat is szinkronizálni kell a Correcttel, |
| arguments: ['@database', '@current_user', '@datetime.time'] | arguments: ['@database', '@current_user', '@datetime.time'] | ||||
| arlista.product.factory: | arlista.product.factory: | ||||
| class: Drupal\arlista\Factory\ProductFactory | class: Drupal\arlista\Factory\ProductFactory | ||||
| arguments: ['@database', '@current_user', '@datetime.time', '@arlista.axico-id.factory', '@arlista.category.factory', '@arlista.component.factory', '@arlista.manufacturer.factory', '@arlista.calculation.factory','@arlista.cache-service'] | |||||
| arguments: ['@database', '@current_user', '@datetime.time', '@arlista.axico-id.factory', '@arlista.category.factory', '@arlista.component.factory', '@arlista.manufacturer.factory', '@arlista.calculation.factory','@arlista.cache-service', | |||||
| '@arlista.warranty.factory'] | |||||
| arlista.product.service: | arlista.product.service: | ||||
| class: Drupal\arlista\Service\ProductService | class: Drupal\arlista\Service\ProductService | ||||
| arguments: ['@arlista.product.factory','@arlista.file.factory'] | arguments: ['@arlista.product.factory','@arlista.file.factory'] | ||||
| arguments: ['@database', '@current_user', '@datetime.time'] | arguments: ['@database', '@current_user', '@datetime.time'] | ||||
| arlista.spread-sheet.factory: | arlista.spread-sheet.factory: | ||||
| class: Drupal\arlista\Factory\SpreadSheetFactory | class: Drupal\arlista\Factory\SpreadSheetFactory | ||||
| arguments: ['@arlista.component.factory','@arlista.manufacturer.factory','@arlista.category.factory'] | |||||
| arguments: ['@arlista.component.factory','@arlista.manufacturer.factory', | |||||
| '@arlista.category.factory', '@config.factory'] |
| } | } | ||||
| public function isProductWarrantyChanged(Product $product): bool { | public function isProductWarrantyChanged(Product $product): bool { | ||||
| return false; | |||||
| /** | |||||
| * TODO delete or change this | |||||
| */ | |||||
| /* if ($product->getPrevWarranty()) { | |||||
| return $this->warranty != $product->getPrevWarranty(); | |||||
| } | |||||
| return false; */ | |||||
| return $this->warranty != $product->getPrevWarranty(); | |||||
| } | } | ||||
| } | } |
| ->fetchAll(); | ->fetchAll(); | ||||
| return $axicoIds; | return $axicoIds; | ||||
| /*$distinct = []; | |||||
| foreach ($axicoIds as $axicoId){ | |||||
| if(!isset($distinct[$axicoId->getName()])){ | |||||
| $distinct[$axicoId->getName()] = $axicoId->getName(); | |||||
| } | |||||
| } | |||||
| return $distinct;*/ | |||||
| } | } | ||||
| } | } |
| { | { | ||||
| $entity = new AxicoIdWarranty(); | $entity = new AxicoIdWarranty(); | ||||
| $entity->setDefaultWarranty($this->config->get('default_warranty')); | $entity->setDefaultWarranty($this->config->get('default_warranty')); | ||||
| return $entity; | |||||
| } | } | ||||
| protected function insert(AbstractEntity $entity): AxicoIdWarranty | protected function insert(AbstractEntity $entity): AxicoIdWarranty | ||||
| return $this->load($data); | return $this->load($data); | ||||
| } | } | ||||
| public function findByProductAxicoIdName(string $productAxicoId): AxicoIdWarranty { | |||||
| $productAxicoId = preg_replace('/[0-9]+/', '', $productAxicoId); | |||||
| return $this->findByAxicoIdName($productAxicoId); | |||||
| } | |||||
| } | } |
| use Drupal\arlista\Factory\ComponentFactory; | use Drupal\arlista\Factory\ComponentFactory; | ||||
| use Drupal\arlista\Factory\ManufacturerFactory; | use Drupal\arlista\Factory\ManufacturerFactory; | ||||
| use Drupal\arlista\Factory\CalculationFactory; | use Drupal\arlista\Factory\CalculationFactory; | ||||
| use Drupal\arlista\Factory\AxicoIdWarrantyFactory; | |||||
| use Drupal\arlista\Service\CacheService; | use Drupal\arlista\Service\CacheService; | ||||
| use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | ||||
| use Drupal\arlista\Entity\PackingMaterial; | use Drupal\arlista\Entity\PackingMaterial; | ||||
| private ManufacturerFactory $manufacturerFactory; | private ManufacturerFactory $manufacturerFactory; | ||||
| private CacheService $cacheService; | private CacheService $cacheService; | ||||
| private CalculationFactory $calculationFactory; | private CalculationFactory $calculationFactory; | ||||
| private AxicoIdWarrantyFactory $axicoIdWarrantyFactory; | |||||
| private array $fontAwesomeIcons = []; | private array $fontAwesomeIcons = []; | ||||
| public function __construct(Connection $connection, AccountInterface $currentUser, | public function __construct(Connection $connection, AccountInterface $currentUser, | ||||
| TimeInterface $time, AxicoIdFactory $axicoIdFactory, CategoryFactory $categoryFactory, | TimeInterface $time, AxicoIdFactory $axicoIdFactory, CategoryFactory $categoryFactory, | ||||
| ComponentFactory $componentFactory, ManufacturerFactory $manufacturerFactory, | ComponentFactory $componentFactory, ManufacturerFactory $manufacturerFactory, | ||||
| CalculationFactory $calculationFactory, CacheService $cacheService) { | |||||
| CalculationFactory $calculationFactory, CacheService $cacheService, | |||||
| AxicoIdWarrantyFactory $axicoIdWarrantyFactory) { | |||||
| parent::__construct($connection, $currentUser, $time, 'uploaded_product'); | parent::__construct($connection, $currentUser, $time, 'uploaded_product'); | ||||
| $this->axicoIdFactory = $axicoIdFactory; | $this->axicoIdFactory = $axicoIdFactory; | ||||
| $this->categoryFactory = $categoryFactory; | $this->categoryFactory = $categoryFactory; | ||||
| $this->manufacturerFactory = $manufacturerFactory; | $this->manufacturerFactory = $manufacturerFactory; | ||||
| $this->calculationFactory = $calculationFactory; | $this->calculationFactory = $calculationFactory; | ||||
| $this->cacheService = $cacheService; | $this->cacheService = $cacheService; | ||||
| $this->axicoIdWarrantyFactory = $axicoIdWarrantyFactory; | |||||
| $this->setFontAwesomeIcons(); | $this->setFontAwesomeIcons(); | ||||
| } | } | ||||
| $product->setCalculation($calculation); | $product->setCalculation($calculation); | ||||
| $product->calculatePrices(); | $product->calculatePrices(); | ||||
| } | } | ||||
| // Axico Id is set from existing product data | |||||
| $axicoIdWarranty = $this->axicoIdWarrantyFactory->findByProductAxicoIdName($product->getAxicoId()); | |||||
| $product->setWarranty($axicoIdWarranty->getDefaultWarranty()); | |||||
| /* | /* | ||||
| * Detect product data changes in | * Detect product data changes in | ||||
| * 1 price | * 1 price | ||||
| if ($result['revokeAxicoId']) { | if ($result['revokeAxicoId']) { | ||||
| $product->setParentCategoryId(null); | $product->setParentCategoryId(null); | ||||
| $product->setParentComponentId(null); | $product->setParentComponentId(null); | ||||
| $product->setWarranty(0); | |||||
| $product = $this->save($product); | $product = $this->save($product); | ||||
| $result['optionValues'][$product->getId()] = $revokeAxicoIdselectOptionValue; | $result['optionValues'][$product->getId()] = $revokeAxicoIdselectOptionValue; | ||||
| $result['revokedProducts'][$product->getId()] = $product; | $result['revokedProducts'][$product->getId()] = $product; | ||||
| */ | */ | ||||
| if (!empty($existingProduct->getAxicoId())) { | if (!empty($existingProduct->getAxicoId())) { | ||||
| $product->copyBaseProperties($existingProduct); | $product->copyBaseProperties($existingProduct); | ||||
| $axicoIdWarranty = $this->axicoIdWarrantyFactory->findByProductAxicoIdName($existingProduct->getAxicoId()); | |||||
| $product->setWarranty($axicoIdWarranty->getDefaultWarranty()); | |||||
| $product->setWorkFlow(WorkFlow::NUMBERED); | $product->setWorkFlow(WorkFlow::NUMBERED); | ||||
| $product = $this->save($product); | $product = $this->save($product); | ||||
| $result['axicoId'][$product->getId()] = $product->getAxicoId(); | $result['axicoId'][$product->getId()] = $product->getAxicoId(); | ||||
| $product->setAxicoId($existingAxicoIdEntity->getNextAxicoIdName() . $this->getAxicoIdFactory()->addZeros($existingAxicoIdEntity->getCurrentCount())); | $product->setAxicoId($existingAxicoIdEntity->getNextAxicoIdName() . $this->getAxicoIdFactory()->addZeros($existingAxicoIdEntity->getCurrentCount())); | ||||
| $product->setWorkFlow(WorkFlow::NUMBERED); | $product->setWorkFlow(WorkFlow::NUMBERED); | ||||
| $axicoIdWarranty = $this->axicoIdWarrantyFactory->findByProductAxicoIdName($product->getAxicoId()); | |||||
| $product->setWarranty($axicoIdWarranty->getDefaultWarranty()); | |||||
| $product = $this->save($product); | $product = $this->save($product); | ||||
| $result['axicoId'][$product->getId()] = $product->getAxicoId(); | $result['axicoId'][$product->getId()] = $product->getAxicoId(); | ||||
| $product->setAxicoId($newAxicoIdEntity->getNextAxicoIdName() . $this->getAxicoIdFactory()->addZeros($newAxicoIdEntity->getCurrentCount())); | $product->setAxicoId($newAxicoIdEntity->getNextAxicoIdName() . $this->getAxicoIdFactory()->addZeros($newAxicoIdEntity->getCurrentCount())); | ||||
| $product->setWorkFlow(WorkFlow::NUMBERED); | $product->setWorkFlow(WorkFlow::NUMBERED); | ||||
| $axicoIdWarranty = $this->axicoIdWarrantyFactory->findByProductAxicoIdName($product->getAxicoId()); | |||||
| $product->setWarranty($axicoIdWarranty->getDefaultWarranty()); | |||||
| $product = $this->save($product); | $product = $this->save($product); | ||||
| $result['axicoId'][$product->getId()] = $product->getAxicoId(); | $result['axicoId'][$product->getId()] = $product->getAxicoId(); | ||||
| use Drupal\arlista\Entity\PackingMaterial; | use Drupal\arlista\Entity\PackingMaterial; | ||||
| use Drupal\arlista\Entity\MeasureUnit; | use Drupal\arlista\Entity\MeasureUnit; | ||||
| use Drupal\arlista\Factory\CategoryFactory; | use Drupal\arlista\Factory\CategoryFactory; | ||||
| use Drupal\Core\Config\ConfigFactoryInterface; | |||||
| use PhpOffice\PhpSpreadsheet\Cell\DataType; | use PhpOffice\PhpSpreadsheet\Cell\DataType; | ||||
| class SpreadSheetFactory extends AbstractSpreadSheetFactory { | class SpreadSheetFactory extends AbstractSpreadSheetFactory { | ||||
| * Class constructor. | * Class constructor. | ||||
| */ | */ | ||||
| public function __construct(ComponentFactory $componentFactory, | public function __construct(ComponentFactory $componentFactory, | ||||
| ManufacturerFactory $manufacturerFactory, CategoryFactory $categoryFactory) { | |||||
| ManufacturerFactory $manufacturerFactory, CategoryFactory $categoryFactory, | |||||
| ConfigFactoryInterface $configFactory) { | |||||
| $this->componentFactory = $componentFactory; | $this->componentFactory = $componentFactory; | ||||
| $this->manufacturerFactory = $manufacturerFactory; | $this->manufacturerFactory = $manufacturerFactory; | ||||
| $this->categoryFactory = $categoryFactory; | $this->categoryFactory = $categoryFactory; | ||||
| $this->config = $configFactory->get('arlista.settings'); | |||||
| } | } | ||||
| public function getComponentFactory(): ComponentFactory { | public function getComponentFactory(): ComponentFactory { | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| // Add default warranty value from config | |||||
| private function findWarrantyData(Product $product): Product { | private function findWarrantyData(Product $product): Product { | ||||
| if (empty($product->getWarranty())) { | if (empty($product->getWarranty())) { | ||||
| $product->setWarranty(60); | |||||
| $product->setPrevWarranty(60); | |||||
| $product->setWarranty($this->config->get('default_warranty')); | |||||
| $product->setPrevWarranty($this->config->get('default_warranty')); | |||||
| return $product; | return $product; | ||||
| } | } | ||||
| $product->setPrevWarranty($product->getWarranty()); | $product->setPrevWarranty($product->getWarranty()); |
| '#weight' => 130, | '#weight' => 130, | ||||
| ]; | ]; | ||||
| $form = $this->getSifField($form, $product, 75); | $form = $this->getSifField($form, $product, 75); | ||||
| $form['items_wrapper']['sif']['#required'] = false; | |||||
| $form['sif']['#required'] = false; | |||||
| $form['items_wrapper']['listable'] = [ | $form['items_wrapper']['listable'] = [ | ||||
| '#title' => 'Listázható', | '#title' => 'Listázható', | ||||
| '#type' => 'checkbox', | '#type' => 'checkbox', |
| <span class="changed-data">{{ icons['change'] }}</span> | <span class="changed-data">{{ icons['change'] }}</span> | ||||
| <div class="product-changes"> | <div class="product-changes"> | ||||
| {% if product.warranty is not same as(product.prevWarranty) and product.prevWarranty is not empty %} | {% if product.warranty is not same as(product.prevWarranty) and product.prevWarranty is not empty %} | ||||
| <!-- <span>Garancia</span> | |||||
| <span>Garancia</span> | |||||
| <span class="previous-value">{{ product.prevWarranty }}</span> | <span class="previous-value">{{ product.prevWarranty }}</span> | ||||
| <span class="new-value">{{ product.warranty }}</span> --> | |||||
| <span class="new-value">{{ product.warranty }}</span> | |||||
| {% endif %} | {% endif %} | ||||
| {% if product.notes is not same as(product.prevNotes) and product.prevNotes is not empty %} | {% if product.notes is not same as(product.prevNotes) and product.prevNotes is not empty %} | ||||
| <span>Megjegyzések</span> | <span>Megjegyzések</span> |
| -- Update 2023-01-19 | |||||
| CREATE TABLE IF NOT EXISTS `arlista_manager_axico_id_warranty` ( | |||||
| `axico_id_name` varchar(128) DEFAULT NULL, | |||||
| `default_warranty` int NOT NULL, | |||||
| `created_at` datetime NOT NULL, | |||||
| `created_by` int NOT NULL, | |||||
| `modified_by` int DEFAULT NULL, | |||||
| `modified_at` datetime DEFAULT NULL, | |||||
| `deleted_at` datetime DEFAULT NULL, | |||||
| `id` int NOT NULL AUTO_INCREMENT, | |||||
| `status` tinyint NOT NULL DEFAULT '1', | |||||
| `sif` varchar(32) DEFAULT NULL, | |||||
| primary key (id) | |||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; |