From eeae84012e122c097f99efb78d94f693b6cfacf1 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 30 Jul 2024 15:09:15 +0300 Subject: [PATCH] =?utf8?q?=D0=A3=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D0=BC=20?= =?utf8?q?=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/motivation/UploadXlsxAction.php | 55 ------------------ erp24/controllers/MotivationController.php | 1 - erp24/views/motivation/upload-xlsx.php | 57 ------------------- 3 files changed, 113 deletions(-) delete mode 100644 erp24/actions/motivation/UploadXlsxAction.php delete mode 100644 erp24/views/motivation/upload-xlsx.php diff --git a/erp24/actions/motivation/UploadXlsxAction.php b/erp24/actions/motivation/UploadXlsxAction.php deleted file mode 100644 index 1ac5a11e..00000000 --- a/erp24/actions/motivation/UploadXlsxAction.php +++ /dev/null @@ -1,55 +0,0 @@ - false, 'extensions' => 'xlsx'], - ]); - - $sheets = []; - if (Yii::$app->request->isPost) { - $model->myfile = UploadedFile::getInstance($model, 'myfile'); - if ($model->myfile && $model->validate()) { - $path = Yii::getAlias('@uploads') . '/' . date("YmdHis") . rand(1000, 9999) . "." . $model->myfile->extension; - $model->myfile->saveAs($path); - // read xlsx - $reader = ReaderEntityFactory::createXLSXReader(); - $reader->open($path); - foreach ($reader->getSheetIterator() as $sheetData) { - $dataNum = 1; - $sheet = ['rows' => [], 'vars' => []]; - foreach ($sheetData->getRowIterator() as $row) { - $sheetRow = []; - foreach ($row->getCells() as $cell) { - if ($cell->getValue() == '###') { - $dataNum = 2; - break; - } - $sheetRow []= $cell->getValue(); - } - switch ($dataNum) { - case 1: { $sheet['rows'][] = $sheetRow; break;} - case 2: { $sheet['vars'][] = $sheetRow; break;} - } - } - $sheets []= $sheet; - } - $reader->close(); - } - } - - return $this->controller->render('upload-xlsx', - compact('model', 'sheets')); - } -} \ No newline at end of file diff --git a/erp24/controllers/MotivationController.php b/erp24/controllers/MotivationController.php index 1fb1ca18..f81c287b 100644 --- a/erp24/controllers/MotivationController.php +++ b/erp24/controllers/MotivationController.php @@ -12,7 +12,6 @@ class MotivationController extends Controller public function actions() { return [ 'index' => \yii_app\actions\motivation\IndexAction::class, - //'upload-xlsx' => \yii_app\actions\motivation\UploadXlsxAction::class, 'values' => \yii_app\actions\motivation\ValuesAction::class, 'create-value' => \yii_app\actions\motivation\CreateValueAction::class, 'update-value' => \yii_app\actions\motivation\UpdateValueAction::class, diff --git a/erp24/views/motivation/upload-xlsx.php b/erp24/views/motivation/upload-xlsx.php deleted file mode 100644 index f78b8a54..00000000 --- a/erp24/views/motivation/upload-xlsx.php +++ /dev/null @@ -1,57 +0,0 @@ - - -
- - ['enctype' => 'multipart/form-data']]) ?> - -
-
-
-
Excel file:
-
field($model, 'myfile')->fileInput()->label(false) ?>
-
-
-
'btn btn-success btn-sm'])?>
-
-
-
- - - - - - - - - - - - - - - $rows): ?> - - - ###'; continue; } ?> - - - - - - - - - -
NumNamVal
- - -
-- 2.39.5