| span.hide-roller, | span.hide-roller, | ||||
| tr.correct-files-uploaded-file.row-for-hiding { | tr.correct-files-uploaded-file.row-for-hiding { | ||||
| display: none; | display: none; | ||||
| } | |||||
| div.form-type-number > label { | |||||
| min-width: 33%; | |||||
| } | } |
| revokeAxicoId: revokeAxicoId | revokeAxicoId: revokeAxicoId | ||||
| }; | }; | ||||
| let url = drupalSettings.arlista.host + "/update/category"; | let url = drupalSettings.arlista.host + "/update/category"; | ||||
| updateWorkFlowOnNumberingEvent(revokeAxicoId > 0, selected); | |||||
| postPackageToUrl(package, url, false, selected); | postPackageToUrl(package, url, false, selected); | ||||
| }); | }); | ||||
| success: function (data, status, xhr) { | success: function (data, status, xhr) { | ||||
| $('html,body').css('cursor', 'initial'); | $('html,body').css('cursor', 'initial'); | ||||
| selected.prop('disabled', false); | selected.prop('disabled', false); | ||||
| console.log(data); | |||||
| //console.log(data); | |||||
| $('#edit-axico-id-warranty-length').val(data.data) | $('#edit-axico-id-warranty-length').val(data.data) | ||||
| return; | return; | ||||
| }; | }; | ||||
| let url = drupalSettings.arlista.host + "/update/component"; | let url = drupalSettings.arlista.host + "/update/component"; | ||||
| updateWorkFlowOnNumberingEvent(revokeAxicoId > 0, selected); | |||||
| postPackageToUrl(package, url, false, selected); | postPackageToUrl(package, url, false, selected); | ||||
| }); | }); | ||||
| function updateWorkFlowOnNumberingEvent(revoking, selected){ | |||||
| let workFlow = 'NUMBERED'; | |||||
| if(revoking){ | |||||
| workFlow = 'COMPARED'; | |||||
| } | |||||
| selected.closest('tr').children().last().find('.product-work-flow').val(workFlow); | |||||
| } | |||||
| /* | /* | ||||
| * # Update selected products component on select change | * # Update selected products component on select change | ||||
| */ | */ | ||||
| $("#default_status_select").change(function (e) { | $("#default_status_select").change(function (e) { | ||||
| e.preventDefault(); | e.preventDefault(); | ||||
| let selected = $(this); | let selected = $(this); | ||||
| console.log(selected.val()); | |||||
| //console.log(selected.val()); | |||||
| if (selected.val() === 2 || selected.val() === "2") { | if (selected.val() === 2 || selected.val() === "2") { | ||||
| $("#enable-group-calculation-list").show(); | $("#enable-group-calculation-list").show(); | ||||
| } | } | ||||
| method: "POST", | method: "POST", | ||||
| data: package, | data: package, | ||||
| success: function (data, status, xhr) { | success: function (data, status, xhr) { | ||||
| console.log(data); | |||||
| //console.log(data); | |||||
| $('html,body').css('cursor', 'initial'); | $('html,body').css('cursor', 'initial'); | ||||
| if(!data.success && redirect){ | if(!data.success && redirect){ | ||||
| alert(data.message); | alert(data.message); | ||||
| window.location.replace(document.URL); | window.location.replace(document.URL); | ||||
| } | } | ||||
| if (selected) { | if (selected) { | ||||
| console.log('here'); | |||||
| let id = package.pid; | let id = package.pid; | ||||
| selected.closest('td').prev().text(data.data.axicoId[id]); | selected.closest('td').prev().text(data.data.axicoId[id]); | ||||
| if (!data.data.axicoId[id]) { | if (!data.data.axicoId[id]) { |
| $product->setParentCategoryId(null); | $product->setParentCategoryId(null); | ||||
| $product->setParentComponentId(null); | $product->setParentComponentId(null); | ||||
| $product->setWarranty(0); | $product->setWarranty(0); | ||||
| $product->setAxicoId(null); | |||||
| $product->setWorkFlow(WorkFlow::COMPARED); | |||||
| $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; |
| '#weight' => 30, | '#weight' => 30, | ||||
| ]; | ]; | ||||
| $sheetSetting = $this->getSheetSettingFactory()->findSettingBySheetIndex($manufacturer->getId(), $this->sheetIndex); | $sheetSetting = $this->getSheetSettingFactory()->findSettingBySheetIndex($manufacturer->getId(), $this->sheetIndex); | ||||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSetting->getId(), $manufacturer->isComponentBased()); | $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSetting->getId(), $manufacturer->isComponentBased()); | ||||
| $options = []; | $options = []; | ||||
| $options[0] = 'Kérem válasszon'; | $options[0] = 'Kérem válasszon'; | ||||
| $form_state->setErrorByName('warranty', 'A garancia csak számjegyeket tartalmazhat (* egész hónapok száma)'); | $form_state->setErrorByName('warranty', 'A garancia csak számjegyeket tartalmazhat (* egész hónapok száma)'); | ||||
| } | } | ||||
| } | } | ||||
| $manufacturer = $this->getManufacturerFactory()->find($this->mid); | |||||
| if((!$manufacturer->isComponentBased() && (int) $form_state->getValue('category') == 0) | |||||
| || ($manufacturer->isComponentBased() && (int) $form_state->getValue('component') == 0)){ | |||||
| $errorName = 'category'; | |||||
| if($manufacturer->isComponentBased()){ | |||||
| $errorName = 'component'; | |||||
| } | |||||
| $form_state->setErrorByName($errorName, 'Nincs termékcsoport vagy komponenscsoport!'); | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| ]; | ]; | ||||
| $result = $this->getProductFactory()->compareProducts($result); | $result = $this->getProductFactory()->compareProducts($result); | ||||
| $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | $result = $this->getProductFactory()->createOrFindAxicoIdForEachProduct($result); | ||||
| $product = $result['products'][0]; | |||||
| if ($product->isComponentBased()) { | |||||
| $component = $this->getComponentFactory()->find($product->getParentComponentId()); | |||||
| $calculation = $this->getCalculationFactory()->findByComponent($component); | |||||
| $calculation->setExchangeRate($this->getCalculationFactory()->getExchangeRate($product->getCurrency())); | |||||
| } else { | |||||
| $category = $this->getCategoryFactory()->find($product->getParentCategoryId()); | |||||
| $manufacturer = $this->getManufacturerFactory()->find($product->getParentManufacturerId()); | |||||
| $calculation = $this->getCalculationFactory()->findByManufacturerAndCategory($manufacturer, $category); | |||||
| $calculation->setExchangeRate($this->getCalculationFactory()->getExchangeRate($product->getCurrency())); | |||||
| } | |||||
| $product->setCalculation($calculation); | |||||
| $product->setCorrectStatus(Status::UJ); | |||||
| $product->calculatePrices(); | |||||
| \Drupal::messenger()->addStatus('Sikeres mentés!'); | \Drupal::messenger()->addStatus('Sikeres mentés!'); | ||||
| } | } | ||||
| $this->manufacturersList = $this->getComponentManufacturersList($enabledComponents); | $this->manufacturersList = $this->getComponentManufacturersList($enabledComponents); | ||||
| $this->enabledComponents = $enabledComponents; | $this->enabledComponents = $enabledComponents; | ||||
| $this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| $sheetSetting->getId(), 'enabled_components'], $enabledComponents); | |||||
| $this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| $sheetSetting->getId(), 'enabled_components_manufacturers_list'], $this->manufacturersList); | |||||
| //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| // $sheetSetting->getId(), 'enabled_components'], $enabledComponents); | |||||
| //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| // $sheetSetting->getId(), 'enabled_components_manufacturers_list'], $this->manufacturersList); | |||||
| } else { | } else { | ||||
| $categories = $this->getCategoryFactory()->findAll('axico_id_name', 'ASC'); | $categories = $this->getCategoryFactory()->findAll('axico_id_name', 'ASC'); | ||||
| /* @var $category Category */ | /* @var $category Category */ | ||||
| } | } | ||||
| } | } | ||||
| $this->enabledCategories = $enabledCategories; | $this->enabledCategories = $enabledCategories; | ||||
| $this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| $sheetSetting->getId(), 'enabled_categories'], $enabledCategories); | |||||
| //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||||
| // $sheetSetting->getId(), 'enabled_categories'], $enabledCategories); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private function getStoringTime() : int { | private function getStoringTime() : int { | ||||
| return 24 * 60 * 60; | |||||
| return 1 * 1 * 1; | |||||
| } | } | ||||
| public function getCachedDataByName(array $nameElements) { | public function getCachedDataByName(array $nameElements) { |