| @@ -5,13 +5,6 @@ arlista.manufacturer.list: | |||
| route_name: arlista.manufacturer.list | |||
| weight: 10 | |||
| menu_name: main | |||
| arlista.category.list: | |||
| title: "Termékcsoportok" | |||
| description: "Termékcsoportok szerkesztése" | |||
| parent: main | |||
| route_name: arlista.category.list | |||
| weight: 30 | |||
| menu_name: main | |||
| arlista.component.list: | |||
| title: "Komponensek" | |||
| description: "Komponensek szerkesztése" | |||
| @@ -20,12 +13,19 @@ arlista.component.list: | |||
| weight: 20 | |||
| menu_name: main | |||
| route_parameters: { mid: '0' } | |||
| arlista.category.list: | |||
| title: "Termékcsoportok" | |||
| description: "Termékcsoportok szerkesztése" | |||
| parent: main | |||
| route_name: arlista.category.list | |||
| weight: 30 | |||
| menu_name: main | |||
| arlista.warranty.list: | |||
| title: "Garanciák" | |||
| description: "Garanciák listája" | |||
| parent: main | |||
| route_name: arlista.warranty.list | |||
| weight: 25 | |||
| weight: 35 | |||
| menu_name: main | |||
| route_parameters: { filterx: 'mind' } | |||
| arlista.file.list: | |||
| @@ -52,6 +52,7 @@ function arlista_theme($existing, $type, $theme, $path) { | |||
| 'manufacturers' => null, | |||
| 'sheetSettings' => null, | |||
| 'listed' => null, | |||
| 'icons' => null, | |||
| ], | |||
| 'template' => 'arlista-file-list', | |||
| 'render element' => 'form', | |||
| @@ -307,6 +307,14 @@ arlista.product.list.file.update.component: | |||
| defaults: | |||
| _controller: '\Drupal\arlista\Controller\ComponentController::updateProductComponent' | |||
| _title: "Komponens update" | |||
| requirements: | |||
| _permission: "arlista manage_pricelists" | |||
| _disable_route_normalizer: "TRUE" | |||
| arlista.warranty.category.manufacturer.fetch: | |||
| path: "warranty/category/manufacturer/fetch" | |||
| defaults: | |||
| _controller: '\Drupal\arlista\Controller\CategoryController::getAxicoIdwarranty' | |||
| _title: "Fetch warranty for category and manufacturer" | |||
| requirements: | |||
| _permission: "arlista manage_pricelists" | |||
| _disable_route_normalizer: "TRUE" | |||
| @@ -40,7 +40,6 @@ | |||
| .arlista-green { | |||
| color: green; | |||
| padding: 0.2rem 0rem; | |||
| } | |||
| .price-changed { | |||
| @@ -92,7 +91,7 @@ footer.footer { | |||
| margin-top: 5rem; | |||
| } | |||
| form.arlista-manufacturer-edit-form > a { | |||
| form.arlista-manufacturer-edit-form > a, form > a.edit-link { | |||
| display: block; | |||
| margin-bottom: 1rem; | |||
| } | |||
| @@ -101,3 +100,11 @@ div.custom-items-wrapper.link-container > ul > li > a { | |||
| display: block; | |||
| margin-top: 0.5rem; | |||
| } | |||
| tr.correct-files-uploaded-file.row-for-hiding { | |||
| display: none; | |||
| } | |||
| span.hide-roller { | |||
| display: none; | |||
| } | |||
| @@ -182,6 +182,25 @@ | |||
| } | |||
| }); | |||
| /* | |||
| * # Show/Hide uploaded files | |||
| */ | |||
| $(".show-roller").on("click",function () { | |||
| $('.hide-roller').css('display', 'block'); | |||
| $('.show-roller').css('display', 'none'); | |||
| $('tr.correct-files-uploaded-file.row-for-hiding').show(); | |||
| }); | |||
| /* | |||
| * # Show/Hide uploaded files | |||
| */ | |||
| $(".hide-roller").on("click",function () { | |||
| $('.show-roller').css('display', 'block'); | |||
| $('.hide-roller').css('display', 'none'); | |||
| $('tr.correct-files-uploaded-file.row-for-hiding').hide(); | |||
| }); | |||
| /* | |||
| * # delete uploaded file | |||
| */ | |||
| @@ -210,7 +229,7 @@ | |||
| /* | |||
| * # Update listed products category on select change | |||
| */ | |||
| $(".product-list-category-select").change(function (e) { | |||
| $(".product-list-category-select").on("change", function (e) { | |||
| e.preventDefault(); | |||
| let selected = $(this); | |||
| let cid = selected.val(); | |||
| @@ -289,6 +308,51 @@ | |||
| }); | |||
| }); | |||
| /* | |||
| * # Update selected categories warranty on manufacturer select change | |||
| */ | |||
| $("#parent_manufacturer_id_select_warranty").on("change", function (e) { | |||
| e.preventDefault(); | |||
| let url = document.URL; | |||
| let cid = $('form').find('*').filter(':input[name=cid]').attr('value'); | |||
| let selected = $(this); | |||
| if (selected.prop('disabled')) { | |||
| return; | |||
| } | |||
| let mid = selected.val(); | |||
| if(mid < 1){ | |||
| return; | |||
| } | |||
| selected.prop('disabled', true); | |||
| let package = { | |||
| cid: cid, | |||
| mid: mid, | |||
| }; | |||
| let fullPath = drupalSettings.arlista.host; | |||
| let arr = fullPath.split("/"); | |||
| url = arr[0] + "warranty/category/manufacturer/fetch"; | |||
| $('html,body').css('cursor', 'wait'); | |||
| $.ajax({ | |||
| url: url, | |||
| method: "POST", | |||
| data: package, | |||
| success: function (data, status, xhr) { | |||
| $('html,body').css('cursor', 'initial'); | |||
| selected.prop('disabled', false); | |||
| console.log(data); | |||
| $('#edit-axico-id-warranty-length').val(data.data) | |||
| return; | |||
| }, | |||
| error: function (request, ajaxOptions, thrownError) { | |||
| $('html,body').css('cursor', 'initial'); | |||
| alert(request.status); | |||
| alert(thrownError); | |||
| } | |||
| }); | |||
| }); | |||
| /* | |||
| * # Update listed products component on select change | |||
| */ | |||
| @@ -459,7 +523,7 @@ | |||
| success: function (data, status, xhr) { | |||
| console.log(data); | |||
| $('html,body').css('cursor', 'initial'); | |||
| if(!data.success){ | |||
| if(!data.success && redirect){ | |||
| alert(data.message); | |||
| const myTimeout = setTimeout(window.location.replace(document.URL), 5000); | |||
| clearTimeout(myTimeout); | |||
| @@ -4,6 +4,7 @@ namespace Drupal\arlista\Controller; | |||
| use Drupal\Core\Controller\ControllerBase; | |||
| use Drupal\arlista\Service\CacheService; | |||
| use Drupal\arlista\Factory\AxicoIdWarrantyFactory; | |||
| use Drupal\arlista\Factory\CategoryFactory; | |||
| use Symfony\Component\DependencyInjection\ContainerInterface; | |||
| use Drupal\arlista\Factory\FileFactory; | |||
| @@ -20,6 +21,7 @@ use Drupal\arlista\Entity\WorkFlow; | |||
| abstract class ArlistaAbstractController extends ControllerBase { | |||
| private $axicoIdWarrantyFactory; | |||
| private $categoryFactory; | |||
| private $fileFactory; | |||
| private $manufacturerFactory; | |||
| @@ -36,7 +38,7 @@ abstract class ArlistaAbstractController extends ControllerBase { | |||
| FileFactory $fileFactory, ManufacturerFactory $manufacturerFactory, | |||
| SheetSettingFactory $SheetSettingFactory, CacheService $cacheService, | |||
| SpreadSheetFactory $spreadSheetFactory, ProductFactory $productFactory, | |||
| CalculationFactory $calculationFactory) { | |||
| CalculationFactory $calculationFactory, AxicoIdWarrantyFactory $axicoIdWarrantyFactory) { | |||
| $this->categoryFactory = $categoryFactory; | |||
| $this->fileFactory = $fileFactory; | |||
| $this->manufacturerFactory = $manufacturerFactory; | |||
| @@ -45,6 +47,7 @@ abstract class ArlistaAbstractController extends ControllerBase { | |||
| $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(); | |||
| @@ -66,9 +69,14 @@ abstract class ArlistaAbstractController extends ControllerBase { | |||
| $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; | |||
| } | |||
| @@ -81,6 +81,7 @@ class CategoryController extends ArlistaAbstractController { | |||
| 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(); | |||
| @@ -91,6 +92,7 @@ class CategoryController extends ArlistaAbstractController { | |||
| } | |||
| 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()); | |||
| @@ -98,4 +100,24 @@ class CategoryController extends ArlistaAbstractController { | |||
| 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(); | |||
| } | |||
| } | |||
| @@ -138,6 +138,41 @@ class AxicoIdWarrantyFactory extends AbstractFactory | |||
| return $result; | |||
| } | |||
| public function findHighestSimilarCategoryWarranty($axicoIdName){ | |||
| $result = $this->findAllLike($axicoIdName); | |||
| $highest = 0; | |||
| foreach($result as $axicoIdWarranty){ | |||
| $string = substr($axicoIdWarranty->getAxicoIdName(),3,3); | |||
| if($string == $axicoIdName){ | |||
| $highest = $axicoIdWarranty->getDefaultWarranty() > $highest ? $axicoIdWarranty->getDefaultWarranty() : $highest; | |||
| } | |||
| } | |||
| return $highest; | |||
| } | |||
| public function updateForManufacturer($manufacturerAxicoIdName, $categoryAxicoIdName, $warranty){ | |||
| $axicoIdName = $manufacturerAxicoIdName . $categoryAxicoIdName; | |||
| $axicoIdWarranty = $this->findByAxicoIdName($axicoIdName); | |||
| $axicoIdWarranty->setDefaultWarranty($warranty); | |||
| $this->save($axicoIdWarranty); | |||
| } | |||
| public function updateForAllManufacturers($categoryAxicoIdName, $warranty){ | |||
| $result = $this->findAllLike($categoryAxicoIdName); | |||
| $highest = 0; | |||
| foreach($result as $axicoIdWarranty){ | |||
| $string = substr($axicoIdWarranty->getAxicoIdName(),3,3); | |||
| if($string == $categoryAxicoIdName){ | |||
| $axicoIdWarranty->setDefaultWarranty($warranty); | |||
| $this->update($axicoIdWarranty); | |||
| $highest++; | |||
| } | |||
| } | |||
| return $highest; | |||
| } | |||
| } | |||
| @@ -40,7 +40,7 @@ class AxicoIdWarrantyList extends ArlistaAbstractForm { | |||
| \Drupal::messenger()->addStatus('Nincsenek adatok. Konfigurálja az alapértelmezett garancia értéket a beállítások menüpontban! Ha ezt megtette, importálhatja/frissítheti a cikkszámtörzsadatokat.'); | |||
| } | |||
| if ($data = $this->getCacheService()->getCachedDataByName([$this->getFormId(), $filterx])) { | |||
| if ($filterx == 'mind' && $data = $this->getCacheService()->getCachedDataByName([$this->getFormId(), 'mind'])) { | |||
| return $data; | |||
| } | |||
| @@ -100,13 +100,11 @@ class AxicoIdWarrantyList extends ArlistaAbstractForm { | |||
| return; | |||
| } | |||
| $data = $this->getAxicoIdFactory()->findAllDistinct(); | |||
| $result = $this->getAxicoIdWarrantyFactory()->updateDatabase($data); | |||
| \Drupal::messenger()->addStatus('Egyedi cikkszámtörzsek száma ' . count($data) . '. Új Axico Cikkszámtörzs Garancia entitások száma ('. count($result['axicoIdWarrantyList']['inserted']) .')'); | |||
| $this->getCacheService()->resetCache([$this->getFormId(), 1]); | |||
| $this->getCacheService()->resetCache([$this->getFormId(), 'mind']); | |||
| } | |||
| } | |||
| @@ -21,12 +21,8 @@ class CategoryEdit extends ArlistaAbstractForm { | |||
| public function buildForm(array $form, FormStateInterface $form_state) { | |||
| $cid = $this->getQueryValue('cid'); | |||
| $category = empty($cid) ? $this->getCategoryFactory()->create() : $this->getCategoryFactory()->find($cid); | |||
| if (!$category->isNew()) { | |||
| if ($data = $this->getCacheService()->getCachedDataByName([$this->getFormId(), $category->getId()])) { | |||
| return $data; | |||
| } | |||
| } | |||
| $form['#prefix'] ='<div class="col-lg-6">'; | |||
| $form['#prefix'] ='<div class="col-lg-4">'; | |||
| $form['items_wrapper']['cid'] = [ | |||
| '#type' => 'hidden', | |||
| '#value' => $cid | |||
| @@ -37,15 +33,50 @@ class CategoryEdit extends ArlistaAbstractForm { | |||
| $form['items_wrapper']['axico_id_name'] = [ | |||
| '#title' => 'Termékcsoport Axico cikkszáma', | |||
| '#type' => 'textfield', | |||
| '#weight' => -900, | |||
| '#weight' => 20, | |||
| '#default_value' => $category->getAxicoIdName(), | |||
| ]; | |||
| $options = []; | |||
| $options[100000] = 'Nincs garancia felülírás (Kérem válasszon gyártót)'; | |||
| $options[0] = 'Minden gyártó ezen termékcsoportjának cikkszámgaranciájának felülírása'; | |||
| $manufacturers = $this->getManufacturerFactory()->findAll(); | |||
| foreach ($manufacturers as $selectable) { | |||
| if ($selectable->getStatus() === 1) { | |||
| $options[$selectable->getId()] = $selectable->getName(); | |||
| } | |||
| } | |||
| $axicoId = $category->isNew() ? 'XXX' : $category->getAxicoIdName(); | |||
| $selectSettings = [ | |||
| 'name' => 'parent_manufacturer_id', | |||
| 'title' => 'Gyártók hasonló cikkszámtörzseinek garanciájának felülirása [---][' . $axicoId . ']' | |||
| ]; | |||
| $form['items_wrapper'][$selectSettings['name']] = [ | |||
| '#title' => $selectSettings['title'], | |||
| '#name' => $selectSettings['name'], | |||
| '#type' => 'select', | |||
| '#options' => $options, | |||
| '#id' => $selectSettings['name'] . '_select_warranty', | |||
| '#default_value' => [$options[100000]], | |||
| '#weight' => 40, | |||
| ]; | |||
| $form['items_wrapper']['axico_id_warranty_length'] = [ | |||
| '#title' => 'Termékcsoport Axico cikkszámtörzs garancia ([---][XXX])', | |||
| '#type' => 'textfield', | |||
| '#default_value' => $this->getConfig()->get('default_warranty'), | |||
| '#weight' => 30, | |||
| ]; | |||
| $form = $this->getSifField($form, $category, -800); | |||
| $form['items_wrapper']['buttons'] = array( | |||
| '#type' => 'container', | |||
| '#weight' => -700, | |||
| '#weight' => 50, | |||
| '##attributes' => ['class' => ['col-lg-6']], | |||
| ); | |||
| $form['items_wrapper']['buttons']['arlista_category_edit_form_submit'] = [ | |||
| @@ -58,9 +89,6 @@ class CategoryEdit extends ArlistaAbstractForm { | |||
| $form['items_wrapper']['buttons']['deleteCategory'] = $this->getDeleteButton($category); | |||
| $form['items_wrapper']['buttons']['deleteCategory']['#disabled'] = true; | |||
| $form['#suffix'] ='</div>'; | |||
| $this->getCacheService()->setCachedDataByName([$this->getFormId(), $cid], $form); | |||
| return $form; | |||
| } | |||
| @@ -84,10 +112,19 @@ class CategoryEdit extends ArlistaAbstractForm { | |||
| $manufacturers = $this->getManufacturerFactory()->findAll(); | |||
| $updated = 0; | |||
| foreach ($manufacturers as $manufacturer) { | |||
| /* | |||
| * Create axico id for each existing manugacturer upon saving a new category | |||
| */ | |||
| if($this->getAxicoIdWarrantyFactory()->findByAxicoIdName($manufacturer->getAxicoIdName() . $category->getAxicoIdName())){ | |||
| if($values['parent_manufacturer_id'] == $manufacturer->getId()){ | |||
| $this->getAxicoIdWarrantyFactory()->updateForManufacturer($manufacturer->getAxicoIdName(), $category->getAxicoIdName(), $values['axico_id_warranty_length']); | |||
| $updated++; | |||
| } | |||
| continue; | |||
| } | |||
| // Create axico id for each existing manugacturer upon saving a new category | |||
| if (!$this->getAxicoIdFactory()->isAxicoIdPresentInGroup($manufacturer->getId(), $category->getId(), null)) { | |||
| /* @var $axicoId AxicoId */ | |||
| $axicoId = $this->getAxicoIdFactory()->createForCategory($manufacturer->getId(), $category->getId()); | |||
| @@ -96,17 +133,24 @@ class CategoryEdit extends ArlistaAbstractForm { | |||
| $axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->create(); | |||
| $axicoIdWarranty->setAxicoIdName($axicoId->getName()); | |||
| $axicoIdWarranty->setDefaultWarranty($values['axico_id_warranty']); | |||
| $this->getAxicoIdWarrantyFactory()->save($axicoIdWarranty); | |||
| } | |||
| /* | |||
| * Create calculation for each newly created category | |||
| */ | |||
| // Create calculation for each newly created category | |||
| if (empty($this->getCalculationFactory()->findByManufacturerAndCategory($manufacturer, $category))) { | |||
| $this->getCalculationFactory()->createFor(null, $category, $manufacturer); | |||
| } | |||
| } | |||
| \Drupal::messenger()->addStatus($this->t('Sikeres mentés!')); | |||
| \Drupal::messenger()->addStatus($values['parent_manufacturer_id']); | |||
| if($values['parent_manufacturer_id'] == 0){ | |||
| $updated = $this->getAxicoIdWarrantyFactory()->updateForAllManufacturers($category->getAxicoIdName(),$values['axico_id_warranty_length']); | |||
| } | |||
| \Drupal::messenger()->addStatus($this->t('Sikeres mentés! ' . $updated . ' (Cikkszámgarancia frissítve)')); | |||
| $form_state->setRedirect('arlista.category.edit', ['cid' => $category->getId()]); | |||
| } | |||
| @@ -2,156 +2,189 @@ | |||
| namespace Drupal\arlista\Form\Component; | |||
| use Drupal\Core\Form\FormStateInterface; | |||
| use Drupal\arlista\Form\ArlistaAbstractForm; | |||
| use Drupal\arlista\Entity\Component; | |||
| use Drupal\arlista\Entity\Manufacturer; | |||
| use Drupal\arlista\Entity\AxicoId; | |||
| use Drupal\arlista\Form\ArlistaAbstractForm; | |||
| use Drupal\Core\Form\FormStateInterface; | |||
| use Drupal\Core\Link; | |||
| use Drupal\Core\Url; | |||
| class ComponentEdit extends ArlistaAbstractForm { | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function getFormId() { | |||
| return 'arlista_component_edit_form'; | |||
| } | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function buildForm(array $form, FormStateInterface $form_state) { | |||
| $cmpId = $this->getQueryValue('cmpId'); | |||
| /** @var $component Component */ | |||
| $component = empty($cmpId) ? $this->getComponentFactory()->create() : $this->getComponentFactory()->find($cmpId); | |||
| $form['#prefix'] = '<div class="col-lg-6">'; | |||
| $form['cmpId'] = [ | |||
| '#type' => 'hidden', | |||
| '#value' => $cmpId, | |||
| ]; | |||
| if (!$component->isNew()) { | |||
| $form['link'] = Link::fromTextAndUrl( | |||
| 'Kalkulációs paraméterek', | |||
| Url::fromRoute('arlista.manufacturer.calculation.edit', [ | |||
| 'mid' => $component->getParentManufacturerId(), | |||
| 'catId' => 0, | |||
| 'cmpId' => $component->getId() | |||
| ]) | |||
| )->toRenderable(); | |||
| $form['link']['#weight'] = -1100; | |||
| $axicoId = $this->getAxicoIdFactory()->findHighestCurrentAxicoIdByComponentId($component->getId()); | |||
| if ($axicoId) { | |||
| $form['axico_id_count'] = [ | |||
| '#title' => 'Utolsó kiosztott cikkszám azonosító sorszám [AAA-BBB-xxx]', | |||
| class ComponentEdit extends ArlistaAbstractForm | |||
| { | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function getFormId() | |||
| { | |||
| return 'arlista_component_edit_form'; | |||
| } | |||
| private $axicoIdWarranty = null; | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function buildForm(array $form, FormStateInterface $form_state) | |||
| { | |||
| $cmpId = $this->getQueryValue('cmpId'); | |||
| /** @var $component Component */ | |||
| $component = empty($cmpId) ? $this->getComponentFactory()->create() : $this->getComponentFactory()->find($cmpId); | |||
| $form['#prefix'] = '<div class="col-lg-4">'; | |||
| $form['cmpId'] = [ | |||
| '#type' => 'hidden', | |||
| '#value' => $cmpId, | |||
| ]; | |||
| if (!$component->isNew()) { | |||
| $form['link'] = Link::fromTextAndUrl( | |||
| 'Kalkulációs paraméterek', | |||
| Url::fromRoute('arlista.manufacturer.calculation.edit', [ | |||
| 'mid' => $component->getParentManufacturerId(), | |||
| 'catId' => 0, | |||
| 'cmpId' => $component->getId(), | |||
| ]) | |||
| )->toRenderable(); | |||
| $form['link']['#weight'] = -1100; | |||
| $axicoId = $this->getAxicoIdFactory()->findHighestCurrentAxicoIdByComponentId($component->getId()); | |||
| if ($axicoId) { | |||
| $form['axico_id_count'] = [ | |||
| '#title' => 'Utolsó kiosztott cikkszám azonosító sorszám [AAA-BBB-xxx]', | |||
| '#type' => 'textfield', | |||
| '#default_value' => $axicoId->getCurrentCount(), | |||
| '#disabled' => true, | |||
| '#weight' => -975, | |||
| ]; | |||
| } | |||
| } | |||
| $form = $this->getNameField($form, $component, -1000); | |||
| $form['axico_id_name'] = [ | |||
| '#title' => 'Komponens Axico cikkszáma', | |||
| '#type' => 'textfield', | |||
| '#default_value' => $component->getAxicoIdName(), | |||
| '#weight' => -900, | |||
| ]; | |||
| if ($component->getParentManufacturerId()) { | |||
| $manufacturer = $this->getManufacturerFactory()->find($component->getParentManufacturerId()); | |||
| $axicoIdName = $manufacturer->getAxicoIdName() . $component->getAxicoIdName(); | |||
| $axicoIdWarranty = $component->isNew() ? $this->getAxicoIdWarrantyFactory()->create() : $this->getAxicoIdWarrantyFactory()->findByAxicoIdName($axicoIdName); | |||
| if ($axicoIdWarranty->isNew()) { | |||
| $axicoIdWarranty->setAxicoIdName($axicoIdName); | |||
| } | |||
| $this->axicoIdWarranty = $axicoIdWarranty; | |||
| } else { | |||
| $this->axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->create(); | |||
| } | |||
| $form['axico_id_warranty_length'] = [ | |||
| '#title' => 'Komponens Axico cikkszámtörzs ' . $this->axicoIdWarranty->getAxicoIdName() . ' garancia', | |||
| '#type' => 'textfield', | |||
| '#default_value' => $axicoId->getCurrentCount(), | |||
| '#disabled' => true, | |||
| '#weight' => -975, | |||
| '#default_value' => $this->axicoIdWarranty->getDefaultWarranty(), | |||
| '#weight' => -900, | |||
| ]; | |||
| $form = $this->getSifField($form, $component, -850); | |||
| $manufacturers = $this->getManufacturerFactory()->findAll(); | |||
| $selectSettings = [ | |||
| 'name' => 'parent_manufacturer_id', 'title' => 'Gyártó']; | |||
| $form['parent_manufacturer_id'] = $this->getSelectOptions($selectSettings, | |||
| $manufacturers, $component); | |||
| $form['parent_manufacturer_id']['#disabled'] = $component->isNew() ? false : true; | |||
| $form['parent_manufacturer_id']['#weight'] = -700; | |||
| $form['buttons'] = array( | |||
| '#type' => 'container', | |||
| '#weight' => -500, | |||
| ); | |||
| $form['buttons']['arlista_component_edit_form_submit'] = [ | |||
| '#type' => 'submit', | |||
| '#value' => empty($component->getName()) ? 'Új komponens mentése' : $component->getName() . ' - mentés', | |||
| '#attributes' => ['class' => ['btn-success']], | |||
| ]; | |||
| } | |||
| $form['buttons']['deleteComponent'] = $this->getDeleteButton($component); | |||
| $form['buttons']['deleteComponent']['#disabled'] = true; | |||
| $form['#suffix'] = '</div>'; | |||
| return $form; | |||
| } | |||
| $form = $this->getNameField($form, $component, -1000); | |||
| $form['axico_id_name'] = [ | |||
| '#title' => 'Komponens Axico cikkszáma', | |||
| '#type' => 'textfield', | |||
| '#default_value' => $component->getAxicoIdName(), | |||
| '#weight' => -900, | |||
| ]; | |||
| $form = $this->getSifField($form, $component, -850); | |||
| $manufacturers = $this->getManufacturerFactory()->findAll(); | |||
| $selectSettings = [ | |||
| 'name' => 'parent_manufacturer_id', 'title' => 'Gyártó']; | |||
| $form['parent_manufacturer_id'] = $this->getSelectOptions($selectSettings, | |||
| $manufacturers, $component); | |||
| $form['parent_manufacturer_id']['#disabled'] = $component->isNew() ? false : true; | |||
| $form['parent_manufacturer_id']['#weight'] = -700; | |||
| $form['buttons'] = array( | |||
| '#type' => 'container', | |||
| '#weight' => -500, | |||
| ); | |||
| $form['buttons']['arlista_component_edit_form_submit'] = [ | |||
| '#type' => 'submit', | |||
| '#value' => empty($component->getName()) ? 'Új komponens mentése' : $component->getName() . ' - mentés', | |||
| '#attributes' => ['class' => ['btn-success']] | |||
| ]; | |||
| $form['buttons']['deleteComponent'] = $this->getDeleteButton($component); | |||
| $form['buttons']['deleteComponent']['#disabled'] = true; | |||
| $form['#suffix'] = '</div>'; | |||
| return $form; | |||
| } | |||
| public function validateForm(array &$form, FormStateInterface $form_state) { | |||
| parent::validateForm($form, $form_state); | |||
| } | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function submitForm(array &$form, FormStateInterface $form_state) { | |||
| $values = $form_state->getValues(); | |||
| /* @var $component Component */ | |||
| $component = empty($values['cmpId']) ? $this->getComponentFactory()->create() : $this->getComponentFactory()->find($values['cmpId']); | |||
| $component->setName($values['name']); | |||
| $component->setAxicoIdName($values['axico_id_name']); | |||
| $component->setSif($values['sif']); | |||
| /* @var $manufacturer Manufacturer */ | |||
| $manufacturer = $this->getManufacturerFactory()->find($values['parent_manufacturer_id'][0]); | |||
| if ($component->isNew()) { | |||
| $component->setParentManufacturerId($manufacturer->getId()); | |||
| $component = $this->getComponentFactory()->save($component); | |||
| if (!$this->getAxicoIdFactory()->isAxicoIdPresentInGroup($manufacturer->getId(), null, $component->getId())) { | |||
| /* @var $axicoId AxicoId */ | |||
| $axicoId = $this->getAxicoIdFactory()->createForComponent($manufacturer->getId(), $component->getId()); | |||
| $axicoId->setName($manufacturer->getAxicoIdName() . $component->getAxicoIdName()); | |||
| $axicoId = $this->getAxicoIdFactory()->save($axicoId); | |||
| $axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->create(); | |||
| $axicoIdWarranty->setAxicoIdName($axicoId->getName()); | |||
| $this->getAxicoIdWarrantyFactory()->save($axicoIdWarranty); | |||
| } | |||
| /* @var $calculation Calculation */ | |||
| $calculation = $this->getCalculationFactory()->findByComponent($component); | |||
| if (empty($calculation)) { | |||
| $this->getCalculationFactory()->createFor($component, null, $manufacturer); | |||
| } | |||
| \Drupal::messenger()->addStatus('Új komponens sikeresen mentve!'); | |||
| } else { | |||
| $component = $this->getComponentFactory()->save($component); | |||
| \Drupal::messenger()->addStatus('Sikeres mentés!'); | |||
| public function validateForm(array &$form, FormStateInterface $form_state) | |||
| { | |||
| parent::validateForm($form, $form_state); | |||
| } | |||
| $this->clearCaches($manufacturer); | |||
| /** | |||
| * {@inheritdoc} | |||
| */ | |||
| public function submitForm(array &$form, FormStateInterface $form_state) | |||
| { | |||
| $values = $form_state->getValues(); | |||
| /* @var $component Component */ | |||
| $component = empty($values['cmpId']) ? $this->getComponentFactory()->create() : $this->getComponentFactory()->find($values['cmpId']); | |||
| $component->setName($values['name']); | |||
| $component->setAxicoIdName($values['axico_id_name']); | |||
| $component->setSif($values['sif']); | |||
| /* @var $manufacturer Manufacturer */ | |||
| $manufacturer = $this->getManufacturerFactory()->find($values['parent_manufacturer_id'][0]); | |||
| if ($component->isNew()) { | |||
| $component->setParentManufacturerId($manufacturer->getId()); | |||
| $component = $this->getComponentFactory()->save($component); | |||
| if (!$this->getAxicoIdFactory()->isAxicoIdPresentInGroup($manufacturer->getId(), null, $component->getId())) { | |||
| /* @var $axicoId AxicoId */ | |||
| $axicoId = $this->getAxicoIdFactory()->createForComponent($manufacturer->getId(), $component->getId()); | |||
| $axicoId->setName($manufacturer->getAxicoIdName() . $component->getAxicoIdName()); | |||
| $axicoId = $this->getAxicoIdFactory()->save($axicoId); | |||
| $axicoIdWarranty = $this->getAxicoIdWarrantyFactory()->create(); | |||
| $axicoIdWarranty->setAxicoIdName($axicoId->getName()); | |||
| $this->axicoIdWarranty = $axicoIdWarranty; | |||
| } | |||
| /* @var $calculation Calculation */ | |||
| $calculation = $this->getCalculationFactory()->findByComponent($component); | |||
| if (empty($calculation)) { | |||
| $this->getCalculationFactory()->createFor($component, null, $manufacturer); | |||
| } | |||
| \Drupal::messenger()->addStatus('Új komponens sikeresen mentve!'); | |||
| } else { | |||
| $component = $this->getComponentFactory()->save($component); | |||
| \Drupal::messenger()->addStatus('Sikeres mentés!'); | |||
| } | |||
| $axicoIdWarranty = $this->axicoIdWarranty; | |||
| $axicoIdWarranty->setDefaultWarranty($values['axico_id_warranty_length']); | |||
| $form_state->setRedirect('arlista.component.edit', ['cmpId' => $component->getId()]); | |||
| } | |||
| $this->getAxicoIdWarrantyFactory()->save($axicoIdWarranty); | |||
| $this->clearCaches($manufacturer); | |||
| public function deleteEntity(array &$form, FormStateInterface $form_state) { | |||
| $form_state->setRedirect('arlista.component.delete', ['id' => $this->getQueryValue('cmpId')]); | |||
| } | |||
| $form_state->setRedirect('arlista.component.edit', ['cmpId' => $component->getId()]); | |||
| } | |||
| public function deleteEntity(array &$form, FormStateInterface $form_state) | |||
| { | |||
| $form_state->setRedirect('arlista.component.delete', ['id' => $this->getQueryValue('cmpId')]); | |||
| } | |||
| public function clearCaches(Manufacturer $manufacturer) { | |||
| $sheetSettings = $this->getSheetSettingFactory()->findSheetSettingsByManufacturerId($manufacturer->getId()); | |||
| foreach ($sheetSettings as $sheetSetting) { | |||
| $this->getCacheService()->resetCache(['arlista_product_uploaded_list_form', $manufacturer->getId(), | |||
| $sheetSetting->getId(), 'enabled_components_manufacturers_list']); | |||
| public function clearCaches(Manufacturer $manufacturer) | |||
| { | |||
| $sheetSettings = $this->getSheetSettingFactory()->findSheetSettingsByManufacturerId($manufacturer->getId()); | |||
| foreach ($sheetSettings as $sheetSetting) { | |||
| $this->getCacheService()->resetCache(['arlista_product_uploaded_list_form', $manufacturer->getId(), | |||
| $sheetSetting->getId(), 'enabled_components_manufacturers_list']); | |||
| } | |||
| $this->getCacheService()->resetCache(['arlista_component_list_form', $manufacturer->getId()]); | |||
| $this->getCacheService()->resetCache(['arlista_axico_id_warranty_list_form', 'mind']); | |||
| } | |||
| $this->getCacheService()->resetCache(['arlista_component_list_form', $manufacturer->getId()]); | |||
| } | |||
| } | |||
| @@ -70,6 +70,7 @@ class FileUpload extends ArlistaAbstractForm { | |||
| '#manufacturers' => $enabled, | |||
| '#sheetSettings' => $sheetSettings, | |||
| '#listed' => $this->getConfig()->get('default_listed') ?? 10, | |||
| '#icons' => $this->getProductFactory()->getFontAwesomeIcons(), | |||
| '#form' => $form, | |||
| ]; | |||
| $rendered_list = \Drupal::service('renderer')->render($renderable_items); | |||
| @@ -28,7 +28,7 @@ class ManufacturerEdit extends ArlistaAbstractForm { | |||
| $manufacturer = empty($mid) ? $this->getManufacturerFactory()->create() : $this->getManufacturerFactory()->find($mid); | |||
| $this->mid = $mid; | |||
| $form['#prefix'] ='<div class="col-lg-6">'; | |||
| $form['#prefix'] ='<div class="col-lg-4">'; | |||
| $form[]['link'] = Link::fromTextAndUrl( | |||
| 'Vissza a gyártókhoz', | |||
| Url::fromRoute('arlista.manufacturer.list') | |||
| @@ -7,8 +7,15 @@ | |||
| <th>Módosítva</th> | |||
| <th>Munkafolyamat</th> | |||
| <th>Műveletek</th> | |||
| {% for file in files %} | |||
| <tr class="correct-files-uploaded-file" data-field-uploaded-file-id="{{ file.id }}" data-field-request-status="ready" data-field-file-work-flow="{{ file.workFlow }}"> | |||
| </tr> | |||
| {% if files|length > 3 %} | |||
| <tr class="correct-files-uploaded-file"> | |||
| <td colspan="6"><span class="show-roller">{{icons['plus']}}</span><span class="hide-roller">{{icons['minus']}}</span></td> | |||
| </tr> | |||
| {% endif %} | |||
| {% for key,file in files %} | |||
| <tr {% if files|length > 3 and key < files|length - 2 %} class="correct-files-uploaded-file row-for-hiding" {% else %} class="correct-files-uploaded-file row-for-displaying" {% endif %} data-field-uploaded-file-id="{{ file.id }}" data-field-request-status="ready" data-field-file-work-flow="{{ file.workFlow }}"> | |||
| <td>{{ manufacturers[file.parentManufacturerId].name }}</td> | |||
| <td> | |||
| {% if file.workFlow is not same as('UPLOADED') %} | |||
| @@ -48,7 +55,6 @@ | |||
| </td> | |||
| </tr> | |||
| {% endfor %} | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| <div>* A kiosztott új cikkszámok visszavonása</div> | |||