]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
миграция add alias
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Wed, 10 Apr 2024 06:37:16 +0000 (09:37 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Wed, 10 Apr 2024 06:37:16 +0000 (09:37 +0300)
docker/migrationToPgsql/mysql/command.sql
erp24/actions/files/DownloadAction.php
erp24/actions/infoTable/ChartsFotAction.php
erp24/config/web.php
erp24/controllers/MatrixErpPropertyController.php
erp24/helpers/File.php
erp24/records/MatrixErpMedia.php
erp24/records/MatrixErpProperty.php
erp24/services/FileService.php
erp24/views/check-type/my-index.php

index b36df4d6783485662f8c66d0d867ef28b9b6b882..2ef29dea5f7e3cb64e910339db271b9552270691 100644 (file)
@@ -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`;
+
index 9a390ff29e3d8c493c01cd9877af2c00cf46d63c..8084e936713961cac0e4235f00d2ad0c38c5bf33 100755 (executable)
@@ -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
index def983686e7a3c3286a730acd4b60897dd99ab11..4b48c8f946d9f3a3bd9197db7841900bc4742087 100644 (file)
@@ -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;
                 }
             }
 
index 77d6a17021b2db8e634931fc387ff7138796f023..23e78297671ed97dc1c4e851c9597c4284b4da3c 100644 (file)
@@ -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",
     ],
index 3e37dbfd7e198d3362d3f51ac81c7c65f16fa243..7d0b53236360f6bc31bb1c3aa5819a6f34fe9812 100644 (file)
@@ -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;
index 3fa0cde67c43e5858bac16c3c4e16a0b76af5ad0..90fbee36813e17f120969f49d3e1532f9fe7f1dd 100644 (file)
@@ -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)) {
index 15a7af84ff3e7991e510f05496bc3c8d533011ad..1df22c93b5358cd41ee9191644280ce49b5603e8 100644 (file)
@@ -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],
         ];
     }
index 87379f417f93f2404c8a28d89f2fcde479699f02..01572022ee185c73b947450b54f63d1d53a42a76 100644 (file)
@@ -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'],
             [
                 [
index 47009b16186bee4a15b0b6d2b7f87e2b08fd8242..57dacb51db0c40b5f5332ababc013353ac7a9c5d 100755 (executable)
@@ -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[] = [];
                         }
index 809ccbb3e50538c1a1e133f0dec2782ef9e3dc55..1bc0e9cbc501b32ff13ac8ec658a1f4dd6072dc6 100644 (file)
@@ -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;
                 }
             ],
             [