From dc98deacad62e0736abb02e5905cdf2eeadec26b Mon Sep 17 00:00:00 2001 From: Semenov Date: Tue, 2 Jul 2024 14:01:08 +0300 Subject: [PATCH] dev --- src/console/controllers/ImageController.php | 21 ++++++++++++++----- .../AdminStorageFilesController.php | 1 - src/controllers/AdminUserController.php | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/console/controllers/ImageController.php b/src/console/controllers/ImageController.php index 1d11ea6d..4cad4d77 100644 --- a/src/console/controllers/ImageController.php +++ b/src/console/controllers/ImageController.php @@ -11,6 +11,8 @@ use skeeks\imagine\Image; use skeeks\cms\models\CmsStorageFile; use yii\base\Exception; +use yii\db\Expression; +use yii\helpers\ArrayHelper; use yii\helpers\Console; /** @@ -45,8 +47,15 @@ public function actionResizeOriginalImages($maxWidth = 1024, $maxHeight = 768) ->orderBy(['size' => SORT_DESC]) ; + + if ($total = $query->count()) { - $this->stdout("Неоптимизированных картинок: {$total} \n"); + $sizeQuery = clone $query; + $sizeQuery->select(['sumsize' => new Expression('sum(size)')]); + $data = $sizeQuery->asArray()->one(); + $formatedSumSize = \Yii::$app->formatter->asShortSize((float)ArrayHelper::getValue($data, 'sumsize')); + + $this->stdout("Неоптимизированных картинок: {$total} шт. ({$formatedSumSize}) \n"); } else { $this->stdout("Неоптимизированных картинок нет\n"); return; @@ -63,16 +72,17 @@ public function actionResizeOriginalImages($maxWidth = 1024, $maxHeight = 768) $fileRoot = $storageFile->getRootSrc(); $this->stdout("\tКартинка: {$storageFile->id}\n"); $this->stdout("\t\t{$fileRoot}\n"); - $this->stdout("\t\t{$storageFile->image_width}x{$storageFile->image_height}\n"); + $this->stdout("\t\tРазрешение: {$storageFile->image_width}x{$storageFile->image_height}\n"); $fileSize = filesize($fileRoot); - $this->stdout("\t\t{$fileSize}\n"); + $fileSizeFormated = \Yii::$app->formatter->asShortSize($fileSize); + $this->stdout("\t\tРазмер: {$fileSizeFormated}\n"); $size = Image::getImagine()->open($fileRoot)->getSize(); $height = ($size->getHeight() * $maxWidth) / $size->getWidth(); $newHeight = (int)round($height); $newWidth = $maxWidth; - $this->stdout("\t\tnew: {$newWidth}x{$newHeight}\n"); + $this->stdout("\t\tНовое разрешение: {$newWidth}x{$newHeight}\n"); Image::thumbnail($fileRoot, $newWidth, $newHeight)->save($fileRoot); @@ -84,7 +94,8 @@ public function actionResizeOriginalImages($maxWidth = 1024, $maxHeight = 768) clearstatcache(); $fileSize = filesize($fileRoot); - $this->stdout("\t\tnew: {$fileSize}\n"); + $fileSizeFormated = \Yii::$app->formatter->asShortSize($fileSize); + $this->stdout("\t\tНовый размер файла: {$fileSizeFormated}\n"); $storageFile->size = $fileSize; diff --git a/src/controllers/AdminStorageFilesController.php b/src/controllers/AdminStorageFilesController.php index 75d1c479..af18a40c 100644 --- a/src/controllers/AdminStorageFilesController.php +++ b/src/controllers/AdminStorageFilesController.php @@ -130,7 +130,6 @@ function(data) ], 'autoFilters' => [ 'id', - '' ], 'filtersModel' => [ 'fields' => [ diff --git a/src/controllers/AdminUserController.php b/src/controllers/AdminUserController.php index 44f6e591..6ecd14e5 100644 --- a/src/controllers/AdminUserController.php +++ b/src/controllers/AdminUserController.php @@ -1296,6 +1296,7 @@ public function addContractor() //Создать компанию $party = new PartyModel($dadata[0]); $contractor = new CmsContractor(); + $contractor->setAttributesFromDadata($party); if (!$contractor->save()) { throw new Exception("Не удалось создать компанию: ".print_r($contractor->errors, true));