Просмотр исходного кода

munkalap nev osszehasonlitas

master
Dukai Károly 3 лет назад
Родитель
Сommit
57741e09d3
5 измененных файлов: 38 добавлений и 30 удалений
  1. +8
    -0
      modules/custom/arlista/src/Controller/UploadedFileController.php
  2. +16
    -2
      modules/custom/arlista/src/Factory/SpreadSheetFactory.php
  3. +12
    -12
      modules/custom/arlista/src/Form/ArlistaAbstractForm.php
  4. +2
    -6
      modules/custom/arlista/src/Form/Manufacturer/ManufacturerEdit.php
  5. +0
    -10
      modules/custom/arlista/src/Form/SheetSetting/SheetSettingReorder.php

+ 8
- 0
modules/custom/arlista/src/Controller/UploadedFileController.php Просмотреть файл

// Data extraction from file // Data extraction from file
$result = $this->getSpreadSheetFactory()->extractDataFromSpreadSheet($spreadSheet, $sheetSettings); $result = $this->getSpreadSheetFactory()->extractDataFromSpreadSheet($spreadSheet, $sheetSettings);


foreach($sheetSettings as $sheetSetting){
if (isset($result['extracted'][$sheetSetting->getIndex()]['validation'])) {
$this->getResponseBody()->setMessage($result['extracted'][$sheetSetting->getIndex()]['validation']);
$this->getResponse()->setData($this->getResponseBody()->toArray());
return $this->getResponse();
}
}
if (empty($result['totalProducts'])) { if (empty($result['totalProducts'])) {
$this->getResponseBody()->setMessage('A fájl egyik munkalapja sem tartalmaz terméket - ellenőrizze a konfigurációkat'); $this->getResponseBody()->setMessage('A fájl egyik munkalapja sem tartalmaz terméket - ellenőrizze a konfigurációkat');
$this->getResponse()->setData($this->getResponseBody()->toArray()); $this->getResponse()->setData($this->getResponseBody()->toArray());

+ 16
- 2
modules/custom/arlista/src/Factory/SpreadSheetFactory.php Просмотреть файл

} }




$result['spreadSheet'] = $spreadSheet;
for ($i = 0; $i < $worksheetCount; $i++) { for ($i = 0; $i < $worksheetCount; $i++) {
$sheetSetting = $this->getSheetSettingByIndex($sheetSettings, $i); $sheetSetting = $this->getSheetSettingByIndex($sheetSettings, $i);
if (empty($sheetSetting)) { if (empty($sheetSetting)) {
} }
$result = $this->loadProductsOfWorkSheet($result, $result = $this->loadProductsOfWorkSheet($result,
$this->loadWorkSheetBySheetIndex($spreadSheet, $i), $sheetSetting); $this->loadWorkSheetBySheetIndex($spreadSheet, $i), $sheetSetting);
if(isset($result['extracted'][$sheetSetting->getIndex()]['validation'])){
return $result;
}
} }


return $result; return $result;
public function loadWorkSheetBySheetIndex(Spreadsheet $spreadSheet, int $index): Worksheet { public function loadWorkSheetBySheetIndex(Spreadsheet $spreadSheet, int $index): Worksheet {
return $spreadSheet->getSheet($index); return $spreadSheet->getSheet($index);
} }
public function loadProductsOfWorkSheet(array $result, Worksheet $workSheet, SheetSetting $sheetSetting): array { public function loadProductsOfWorkSheet(array $result, Worksheet $workSheet, SheetSetting $sheetSetting): array {
$result['extracted'][$sheetSetting->getIndex()]['workSheetName'] = empty($workSheet->getTitle()) ? $sheetSetting->getIndex() : $workSheet->getTitle(); $result['extracted'][$sheetSetting->getIndex()]['workSheetName'] = empty($workSheet->getTitle()) ? $sheetSetting->getIndex() : $workSheet->getTitle();
$result['extracted'][$sheetSetting->getIndex()]['products'] = []; $result['extracted'][$sheetSetting->getIndex()]['products'] = [];

$cleanWorkSheetTitle = strtolower(preg_replace("/[^A-Za-z0-9 ]/", '', $workSheet->getTitle()));
$cleanSheetSettingName = strtolower(preg_replace("/[^A-Za-z0-9 ]/", '', $sheetSetting->getName()));
if(strcmp($cleanWorkSheetTitle,$cleanSheetSettingName) != 0){
$result['extracted'][$sheetSetting->getIndex()]['validation'] = ['A munkalap neve nem megfelő. Ellenőrizze a konfigurációkat! Munkalap száma: ' . $sheetSetting->getIndex() ];
return $result;
}
$highestRow = $workSheet->getHighestRow(); $highestRow = $workSheet->getHighestRow();
if (empty($highestRow)) { if (empty($highestRow)) {
$result['extracted'][$sheetSetting->getIndex()]['empty'] = true; $result['extracted'][$sheetSetting->getIndex()]['empty'] = true;

+ 12
- 12
modules/custom/arlista/src/Form/ArlistaAbstractForm.php Просмотреть файл

*/ */
abstract class ArlistaAbstractForm extends FormBase { abstract class ArlistaAbstractForm extends FormBase {


private $categoryFactory;
private $componentFactory;
private $fileFactory;
private $manufacturerFactory;
private $sheetSettingFactory;
private $cacheService;
private $axicoIdFactory;
private $productFactory;
private $spreadSheetFactory;
private $calculationFactory;
private $enabledGroupFactory;
private $axicoIdWarrantyFactory;
private CategoryFactory $categoryFactory;
private ComponentFactory $componentFactory;
private FileFactory $fileFactory;
private ManufacturerFactory $manufacturerFactory;
private SheetSettingFactory $sheetSettingFactory;
private CacheService $cacheService;
private AxicoIdFactory $axicoIdFactory;
private ProductFactory $productFactory;
private SpreadSheetFactory $spreadSheetFactory;
private CalculationFactory $calculationFactory;
private EnabledGroupFactory $enabledGroupFactory;
private AxicoIdWarrantyFactory $axicoIdWarrantyFactory;
private $config; private $config;


public function __construct(ComponentFactory $componentFactory, CategoryFactory $categoryFactory, public function __construct(ComponentFactory $componentFactory, CategoryFactory $categoryFactory,

+ 2
- 6
modules/custom/arlista/src/Form/Manufacturer/ManufacturerEdit.php Просмотреть файл

if (!$manufacturer->isNew()) { if (!$manufacturer->isNew()) {
$definedSheetSettings = $this->getSheetSettingFactory()->findSheetSettingsByManufacturerId($manufacturer->getId()); $definedSheetSettings = $this->getSheetSettingFactory()->findSheetSettingsByManufacturerId($manufacturer->getId());
if (count($definedSheetSettings) > 0) { if (count($definedSheetSettings) > 0) {
$munkalapSorrendNodeIds = \Drupal::entityQuery('node')
->condition('type', 'munkalap_sorrend')
->condition('field_manufacturer_id', $manufacturer->getId())
->execute();
$form['items_wrapper'][]['sheet_settings']['link'] = \Drupal\Core\Link::fromTextAndUrl( $form['items_wrapper'][]['sheet_settings']['link'] = \Drupal\Core\Link::fromTextAndUrl(
'Munkalapok sorrendje', 'Munkalapok sorrendje',
Url::fromRoute('arlista.manufacturer.sheet-setting.reorder', [ Url::fromRoute('arlista.manufacturer.sheet-setting.reorder', [
'mid' => $mid,
'sheetIndex' => 0]
'mid' => $mid
]
) )
)->toRenderable(); )->toRenderable();
} }

+ 0
- 10
modules/custom/arlista/src/Form/SheetSetting/SheetSettingReorder.php Просмотреть файл



use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\arlista\Form\ArlistaAbstractForm; use Drupal\arlista\Form\ArlistaAbstractForm;
use Drupal\arlista\Entity\Currency;
use Drupal\arlista\Entity\Manufacturer; use Drupal\arlista\Entity\Manufacturer;
use Drupal\arlista\Entity\SheetSetting;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\Core\Link; use Drupal\Core\Link;
use \Drupal\node\Entity\Node; use \Drupal\node\Entity\Node;
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {


$values = $form_state->getValues();
/* @var $manufacturer Manufacturer */
$manufacturer = $this->getManufacturerFactory()->find($values['mid']);

/* @var $sheetSetting SheetSetting */

\Drupal::messenger()->addStatus('Sikeres mentés!');
} }


} }

Загрузка…
Отмена
Сохранить