Procházet zdrojové kódy

munkalap nev osszehasonlitas

master
Dukai Károly před 3 roky
rodič
revize
57741e09d3
5 změnil soubory, kde provedl 38 přidání a 30 odebrání
  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 Zobrazit soubor

@@ -37,6 +37,14 @@ class UploadedFileController extends ArlistaAbstractController {
// Data extraction from file
$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'])) {
$this->getResponseBody()->setMessage('A fájl egyik munkalapja sem tartalmaz terméket - ellenőrizze a konfigurációkat');
$this->getResponse()->setData($this->getResponseBody()->toArray());

+ 16
- 2
modules/custom/arlista/src/Factory/SpreadSheetFactory.php Zobrazit soubor

@@ -81,6 +81,8 @@ class SpreadSheetFactory extends AbstractSpreadSheetFactory {
}


$result['spreadSheet'] = $spreadSheet;
for ($i = 0; $i < $worksheetCount; $i++) {
$sheetSetting = $this->getSheetSettingByIndex($sheetSettings, $i);
if (empty($sheetSetting)) {
@@ -88,6 +90,9 @@ class SpreadSheetFactory extends AbstractSpreadSheetFactory {
}
$result = $this->loadProductsOfWorkSheet($result,
$this->loadWorkSheetBySheetIndex($spreadSheet, $i), $sheetSetting);
if(isset($result['extracted'][$sheetSetting->getIndex()]['validation'])){
return $result;
}
}

return $result;
@@ -105,11 +110,20 @@ class SpreadSheetFactory extends AbstractSpreadSheetFactory {
public function loadWorkSheetBySheetIndex(Spreadsheet $spreadSheet, int $index): Worksheet {
return $spreadSheet->getSheet($index);
}
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()]['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();
if (empty($highestRow)) {
$result['extracted'][$sheetSetting->getIndex()]['empty'] = true;

+ 12
- 12
modules/custom/arlista/src/Form/ArlistaAbstractForm.php Zobrazit soubor

@@ -32,18 +32,18 @@ use Drupal\arlista\Entity\Manufacturer;
*/
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;

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

+ 2
- 6
modules/custom/arlista/src/Form/Manufacturer/ManufacturerEdit.php Zobrazit soubor

@@ -106,15 +106,11 @@ class ManufacturerEdit extends ArlistaAbstractForm
if (!$manufacturer->isNew()) {
$definedSheetSettings = $this->getSheetSettingFactory()->findSheetSettingsByManufacturerId($manufacturer->getId());
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(
'Munkalapok sorrendje',
Url::fromRoute('arlista.manufacturer.sheet-setting.reorder', [
'mid' => $mid,
'sheetIndex' => 0]
'mid' => $mid
]
)
)->toRenderable();
}

+ 0
- 10
modules/custom/arlista/src/Form/SheetSetting/SheetSettingReorder.php Zobrazit soubor

@@ -4,9 +4,7 @@ namespace Drupal\arlista\Form\SheetSetting;

use Drupal\Core\Form\FormStateInterface;
use Drupal\arlista\Form\ArlistaAbstractForm;
use Drupal\arlista\Entity\Currency;
use Drupal\arlista\Entity\Manufacturer;
use Drupal\arlista\Entity\SheetSetting;
use Drupal\Core\Url;
use Drupal\Core\Link;
use \Drupal\node\Entity\Node;
@@ -122,14 +120,6 @@ class SheetSettingReorder extends ArlistaAbstractForm {
*/
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!');
}

}

Načítá se…
Zrušit
Uložit