From: Aleksey Filippov Date: Wed, 10 Apr 2024 06:37:16 +0000 (+0300) Subject: миграция add alias X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5157dcc7403a33465169829e95f0fb0369508775;p=yii-erp24%2F.git миграция add alias --- diff --git a/docker/migrationToPgsql/mysql/command.sql b/docker/migrationToPgsql/mysql/command.sql index b36df4d..2ef29de 100644 --- a/docker/migrationToPgsql/mysql/command.sql +++ b/docker/migrationToPgsql/mysql/command.sql @@ -38,8 +38,8 @@ UPDATE `store_order_status` SET `date` = '1970-01-01 00:00:01' WHERE `date` < '1 UPDATE `users_events` SET `date_edit` = '1970-01-01 00:00:01' WHERE `date_edit` < '1970-01-01 00:00:00' AND `date_edit` IS NOT NULL; UPDATE `users_events` SET `date_add` = '1970-01-01 00:00:01' WHERE `date_add` < '1970-01-01 00:00:00'; UPDATE `users_events` SET `date_edit` = '1970-01-01 00:00:01' WHERE `date_edit` < '1970-01-01 00:00:00' AND `date_edit` IS NOT NULL; -ALTER TABLE `users_events` MODIFY COLUMN `cannel` ENUM('bp', 'seller', 'site', 'salebot', 'none'); -UPDATE `users_events` SET `cannel` = 'none' WHERE `cannel` = ''; +-- ALTER TABLE `users_events` MODIFY COLUMN `cannel` ENUM('bp', 'seller', 'site', 'salebot', 'none'); +-- UPDATE `users_events` SET `cannel` = 'none' WHERE `cannel` = ''; UPDATE `orders_payments` SET `date_end` = '1970-01-01 00:00:01' WHERE date_end < '1970-01-01 00:00:01'; @@ -169,21 +169,5 @@ UPDATE `users_events` SET `date` = '1970-01-01' WHERE `date` < '1970-01-01' AND UPDATE `universal_pipeline_triggers` SET `time` = '1970-01-01' WHERE `time` < '1970-01-01' AND `time` IS NOT NULL; UPDATE `shipment_waybills` SET `created_at` = '1970-01-01' WHERE `created_at` < '1970-01-01' AND `created_at` IS NOT NULL; UPDATE `store_orders` SET `date_add` = '1970-01-01' WHERE `date_add` < '1970-01-01' AND `date_add` IS NOT NULL; -ALTER TABLE `sales` DROP INDEX `date`; - -ALTER TABLE page_statistics ADD PRIMARY KEY (id); -ALTER TABLE IF EXISTS erp24.page_statistics - ADD COLUMN id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 30000 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ); -SELECT setval('page_statistics_id_seq', max(id)) FROM page_statistics; - -ALTER TABLE admin ADD PRIMARY KEY (id); -ALTER TABLE admin_group ADD PRIMARY KEY (id); -ALTER TABLE timetable ADD PRIMARY KEY (id); -ALTER TABLE sales ADD PRIMARY KEY (id); -ALTER TABLE sales_products ADD PRIMARY KEY (id); -ALTER TABLE write_offs_erp ADD PRIMARY KEY (id); -ALTER TABLE store_plan ADD PRIMARY KEY (store_id,month,year); -ALTER TABLE dashboard_fields_links ADD PRIMARY KEY (dashboard_id,field_id); -ALTER TABLE products_1c ADD PRIMARY KEY (id); -ALTER TABLE write_offs_products_erp ADD PRIMARY KEY (id); -ALTER TABLE dashboard_fields_property ADD PRIMARY KEY (id); \ No newline at end of file +-- ALTER TABLE `sales` DROP INDEX `date`; + diff --git a/erp24/actions/files/DownloadAction.php b/erp24/actions/files/DownloadAction.php index 9a390ff..8084e93 100755 --- a/erp24/actions/files/DownloadAction.php +++ b/erp24/actions/files/DownloadAction.php @@ -9,7 +9,8 @@ class DownloadAction extends Action { public function run($url) { - $filepath = \Yii::getalias('@webroot') . DIRECTORY_SEPARATOR . $url; + $filepath = \Yii::getalias('@yii_app') . $url; +// $filepath = \Yii::getalias('@webroot') . DIRECTORY_SEPARATOR . $url; return \Yii::$app->response->sendFile($filepath); } } \ No newline at end of file diff --git a/erp24/actions/infoTable/ChartsFotAction.php b/erp24/actions/infoTable/ChartsFotAction.php index def9836..4b48c8f 100644 --- a/erp24/actions/infoTable/ChartsFotAction.php +++ b/erp24/actions/infoTable/ChartsFotAction.php @@ -51,7 +51,7 @@ class ChartsFotAction extends \yii\base\Action ->andWhere(['date' => $dates]) ->andFilterWhere(['city_store.id' => $charts->store_id]) ->groupBy([ - 'id', + 'admin_payroll_days.store_id', 'date', 'smena_type', 'name', @@ -65,7 +65,10 @@ class ChartsFotAction extends \yii\base\Action $store_params = []; foreach ($payrollStore as $item) { - + $itemPlanRow = 0; + if (!empty($item['plan'])) { + $itemPlanRow = $item['plan']; + } $data[$clusterStoresDict[$item['id']]][$item['id']][$item['smena_type']][$item['date']] = [ 'sales_sum' => floatval($item['sales_sum']), 'day_payroll' => floatval($item['day_payroll']), @@ -79,7 +82,10 @@ class ChartsFotAction extends \yii\base\Action if (isset($data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']])) { if ($item['timetable_person_count'] !== 0) { - $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['plan'] += $item['plan']; + if (!array_key_exists('plan', $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']])) { + $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['plan'] = 0; + } + $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['plan'] += $itemPlanRow; } $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['sales_sum'] += floatval($item['sales_sum']); $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['day_payroll'] += floatval($item['day_payroll']); @@ -94,7 +100,7 @@ class ChartsFotAction extends \yii\base\Action 'payroll_constant' => floatval($item['payroll_constant']), ]; if ($item['timetable_person_count'] !== 0) { - $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['plan'] = $item['plan']; + $data[$clusterStoresDict[$item['id']]][$item['id']][3][$item['date']]['plan'] = $itemPlanRow; } } diff --git a/erp24/config/web.php b/erp24/config/web.php index 77d6a17..23e7829 100644 --- a/erp24/config/web.php +++ b/erp24/config/web.php @@ -10,7 +10,7 @@ $config = [ 'aliases' => [ '@bower' => '@vendor/bower-asset', '@npm' => '@vendor/npm-asset', - '@uploads' => dirname(__DIR__, 2) . "/uploads", + '@uploads' => dirname(__DIR__) . "/uploads", '@data-path' => dirname(__DIR__, 2) . "/data", '@uploads-images-path' => "@uploads/images", ], diff --git a/erp24/controllers/MatrixErpPropertyController.php b/erp24/controllers/MatrixErpPropertyController.php index 3e37dbf..7d0b532 100644 --- a/erp24/controllers/MatrixErpPropertyController.php +++ b/erp24/controllers/MatrixErpPropertyController.php @@ -229,7 +229,7 @@ class MatrixErpPropertyController extends Controller $file->entity_id = $modelEdit->id; $file->entity = "matrix_media"; $file->file_type = $info['fileType']; - $file->url = $info['target_file']; + $file->url = $info['target_base_dir']; $file->save(false); $modelMatrixErpMediaRow->file_id = $file->id; diff --git a/erp24/helpers/File.php b/erp24/helpers/File.php index 3fa0cde..90fbee3 100644 --- a/erp24/helpers/File.php +++ b/erp24/helpers/File.php @@ -114,9 +114,10 @@ class File extends FileHelper } $substr = substr($filename, 0, 2); $imagePath = self::filepath($filename, 'images'); - $resizePath = "/var/www/erp24/uploads/images/resize/{$substr}/{$w}_{$h}_{$quality}"; + $uploadDir = \Yii::getAlias('@uploads'); + $resizePath = $uploadDir . "/images/resize/{$substr}/{$w}_{$h}_{$quality}"; $resizedUrl = "{$resizePath}/{$filename}"; - $resizedPath = "/var/www/erp24/uploads/images/resize/{$substr}/{$w}_{$h}_{$quality}"; + $resizedPath = $uploadDir . "/images/resize/{$substr}/{$w}_{$h}_{$quality}"; $resizedFile = "{$resizedPath}/{$filename}"; if (!file_exists($imagePath)) { diff --git a/erp24/records/MatrixErpMedia.php b/erp24/records/MatrixErpMedia.php index 15a7af8..1df22c9 100644 --- a/erp24/records/MatrixErpMedia.php +++ b/erp24/records/MatrixErpMedia.php @@ -40,7 +40,7 @@ class MatrixErpMedia extends \yii\db\ActiveRecord [['guid', 'name', 'date'], 'required'], [['description'], 'string'], [['mediaFiles'], 'safe'], - [['id', 'file_id', 'created_admin_id', 'updated_admin_id'], 'integer'], + [['file_id', 'created_admin_id', 'updated_admin_id'], 'integer'], [['guid', 'name', 'date', 'created_at', 'updated_at'], 'string', 'max' => 100], ]; } diff --git a/erp24/records/MatrixErpProperty.php b/erp24/records/MatrixErpProperty.php index 87379f4..0157202 100644 --- a/erp24/records/MatrixErpProperty.php +++ b/erp24/records/MatrixErpProperty.php @@ -38,7 +38,6 @@ class MatrixErpProperty extends \yii\db\ActiveRecord return [ [['guid', 'date'], 'required'], [['description'], 'string'], - [['id'], 'integer'], [['image_id', 'created_admin_id', 'updated_admin_id'], 'integer'], [ [ diff --git a/erp24/services/FileService.php b/erp24/services/FileService.php index 47009b1..57dacb5 100755 --- a/erp24/services/FileService.php +++ b/erp24/services/FileService.php @@ -186,7 +186,9 @@ class FileService public static function uploadFileMultilevel($label, $admin_id, array $multilevelKey) { if (isset($_FILES[$label]["name"])) { $isMultiple = is_array($_FILES[$label]["name"]); - $target_dir = "uploads/$admin_id/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; + $uploadDir = \Yii::getAlias('@uploads'); + $target_dir = $uploadDir."/$admin_id/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; + $target_base_dir = "/uploads/$admin_id/" . date("Y") . "/" . date("m") . "/" . date("d") . "/"; if ($isMultiple) { $filesKeyName = $label.'.name'; @@ -222,7 +224,7 @@ class FileService $filesTempNameRow = $filesTempName . '.' . $filesKeyNameRow; $filesTempRow = ArrayHelper::getValue($_FILES,$filesTempNameRow); if (move_uploaded_file($filesTempRow, $target_file)) { - $result[] = compact('fileType', 'target_file'); + $result[] = compact('fileType', 'target_file', 'target_base_dir'); } else { $result[] = []; } diff --git a/erp24/views/check-type/my-index.php b/erp24/views/check-type/my-index.php index 809ccbb..1bc0e9c 100644 --- a/erp24/views/check-type/my-index.php +++ b/erp24/views/check-type/my-index.php @@ -46,7 +46,11 @@ use \yii_app\records\CheckType; [ 'label' => 'Создатель', 'value' => function ($model) { - return $model->checkGroup->createdBy ? $model->checkGroup->createdBy->name : '---'; + $createdByName = '---'; + if (isset($model->checkGroup)) { + $createdByName = $model->checkGroup->createdBy ? $model->checkGroup->createdBy->name : '---'; + } + return $createdByName; } ], [