]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Перенос JS в файлы
authorvladfo <fvv2011@gmail.com>
Tue, 24 Sep 2024 08:10:58 +0000 (11:10 +0300)
committervladfo <fvv2011@gmail.com>
Tue, 24 Sep 2024 08:10:58 +0000 (11:10 +0300)
erp24/views/cluster_link_edit/index.php
erp24/views/cluster_link_edit/view-all.php
erp24/views/cluster_link_store_edit/view.php
erp24/web/css/select2-container-and-other-styles-fix.css
erp24/web/js/cluster-link-edit/view-all.js [new file with mode: 0644]
erp24/web/js/cluster-link-edit/view.js [new file with mode: 0644]

index 5a0b16b25f3f93b5d7230746c7938114b4c23cfe..8918126a567074d6f757415a2b55f818fc1d16cc 100644 (file)
@@ -89,7 +89,7 @@ $this->params['breadcrumbs'][] = $this->title;
                     'view-all' => function ($url, $model, $key) use ($clusterToManager, $currentDate) {
                         $currentDateStr = date('Y-m-d');
                         if ($currentDate !== $currentDateStr) {
-                        return Html::a('<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1.125em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M573 241C518 136 411 64 288 64S58 136 3 241a32 32 0 000 30c55 105 162 177 285 177s230-72 285-177a32 32 0 000-30zM288 400a144 144 0 11144-144 144 144 0 01-144 144zm0-240a95 95 0 00-25 4 48 48 0 01-67 67 96 96 0 1092-71z"></path></svg>', [
+                        return Html::a('<svg aria-hidden="true" style="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M573 241C518 136 411 64 288 64S58 136 3 241a32 32 0 000 30c55 105 162 177 285 177s230-72 285-177a32 32 0 000-30zM288 400a144 144 0 11144-144 144 144 0 01-144 144zm0-240a95 95 0 00-25 4 48 48 0 01-67 67 96 96 0 1092-71z"></path></svg>', [
                             'view-all',
                             'id' => $model->id,
                             'manager' => $clusterToManager[$model->id] ?? 'Не назначен',
@@ -111,7 +111,7 @@ $this->params['breadcrumbs'][] = $this->title;
                         // Проверка, является ли текущая дата датой запроса
                         if ($currentDate === $currentDateStr) {
                             // Ссылка для редактирования с иконкой "Карандаш" (bi-pencil)
-                            return Html::a('<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M498 142l-46 46c-5 5-13 5-17 0L324 77c-5-5-5-12 0-17l46-46c19-19 49-19 68 0l60 60c19 19 19 49 0 68zm-214-42L22 362 0 484c-3 16 12 30 28 28l122-22 262-262c5-5 5-13 0-17L301 100c-4-5-12-5-17 0zM124 340c-5-6-5-14 0-20l154-154c6-5 14-5 20 0s5 14 0 20L144 340c-6 5-14 5-20 0zm-36 84h48v36l-64 12-32-31 12-65h36v48z"></path></svg>', [
+                            return Html::a('<svg aria-hidden="true" style="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M498 142l-46 46c-5 5-13 5-17 0L324 77c-5-5-5-12 0-17l46-46c19-19 49-19 68 0l60 60c19 19 19 49 0 68zm-214-42L22 362 0 484c-3 16 12 30 28 28l122-22 262-262c5-5 5-13 0-17L301 100c-4-5-12-5-17 0zM124 340c-5-6-5-14 0-20l154-154c6-5 14-5 20 0s5 14 0 20L144 340c-6 5-14 5-20 0zm-36 84h48v36l-64 12-32-31 12-65h36v48z"></path></svg>', [
                                 'view-all',
                                 'id' => $model->id,
                                 'manager' => $clusterToManager[$model->id] ?? 'Не назначен',
index 069095c2cb4111ab595f5f757c0b1b01918e916e..f0671f3f20277f545d8d7a21bf5e39cac788b107 100644 (file)
@@ -18,7 +18,7 @@ use yii\bootstrap5\Icon;
 $this->title = $model->name;
 $this->params['breadcrumbs'][] = ['label' => 'Clusters', 'url' => ['index']];
 $this->params['breadcrumbs'][] = $this->title;
-
+$this->registerJsFile('/js/cluster-link-edit/view-all.js', ['position' => \yii\web\View::POS_END]);
 // Получение списка магазинов, которые еще не находятся в текущем кусте
 $storesInCluster = ArrayHelper::getColumn($dataProvider->getModels(), 'value_int');
 $availableStores = array_filter($storeNames, function ($storeId) use ($storesInCluster) {
@@ -99,7 +99,7 @@ $availableStores = array_filter($storeNames, function ($storeId) use ($storesInC
                             }
                             return Html::a(
                             // Используем встроенный SVG-код для иконки удаления
-                                '<svg aria-hidden="true" style="display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em;width:.875em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M32 464a48 48 0 0048 48h288a48 48 0 0048-48V128H32zm272-256a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zM432 32H312l-9-19a24 24 0 00-22-13H167a24 24 0 00-22 13l-9 19H16A16 16 0 000 48v32a16 16 0 0016 16h416a16 16 0 0016-16V48a16 16 0 00-16-16z"></path></svg>',
+                                '<svg aria-hidden="true" style="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M32 464a48 48 0 0048 48h288a48 48 0 0048-48V128H32zm272-256a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zm-96 0a16 16 0 0132 0v224a16 16 0 01-32 0zM432 32H312l-9-19a24 24 0 00-22-13H167a24 24 0 00-22 13l-9 19H16A16 16 0 000 48v32a16 16 0 0016 16h416a16 16 0 0016-16V48a16 16 0 00-16-16z"></path></svg>',
                                 ['delete-store', 'id' => $store['id'], 'cluster_id' => $model->id],
                                 [
                                     'class' => 'btn btn-danger',
@@ -116,48 +116,3 @@ $availableStores = array_filter($storeNames, function ($storeId) use ($storesInC
         ]); ?>
     </div>
 
-<?php
-$js = <<<JS
-$('select[name="cluster_id"]').change(function() {
-    let storeId = $(this).data('store-id');
-    let newClusterId = $(this).val();
-    
-    // Получаем имя магазина из первого столбца той же строки
-    let storeName = $(this).closest('tr').find('td:first').text().trim();
-
-    // Добавляем подтверждение с именем магазина
-    if (confirm('Вы действительно хотите перевести магазин ' + storeName + ' в куст с номером ' + newClusterId + '?')) {
-        // Отправляем данные на сервер после подтверждения
-        $.post({
-            url: 'move-store',
-            data: { store_id: storeId, new_cluster_id: newClusterId },
-            success: function() {
-                // Если магазин был успешно перемещен, удаляем его строку из таблицы
-                $('select[name="cluster_id"][data-store-id="' + storeId + '"]').closest('tr').remove();
-                alert('Магазин успешно переведен в новый куст');
-            },
-            error: function() {
-                alert('Ошибка при переводе магазина');
-            }
-        });
-    } else {
-        // Если пользователь отменил действие
-        console.log('Перемещение отменено пользователем.');
-    }
-});
-// Отслеживаем изменение выбора магазина в селекте
-$('#store-id-select').change(function() {
-    let storeId = $(this).val();
-    if (storeId) {
-        $('#add-store-button').prop('disabled', false); // Включаем кнопку, если выбран магазин
-    } else {
-        $('#add-store-button').prop('disabled', true); // Отключаем кнопку, если магазин не выбран
-    }
-});
-
-// Изначально кнопка добавления должна быть отключена
-$('#add-store-button').prop('disabled', true);
-JS;
-
-$this->registerJs($js);
-?>
\ No newline at end of file
index bce145e9af929ff8ffb782fd365fcca2a45635c6..112c511ccd9369067c1af35581db27b8a3246065 100644 (file)
@@ -19,7 +19,7 @@ $this->title = 'Просмотр кустов';
 // Определяем текущий квартал
 $currentMonth = date('n'); // Текущий месяц (1-12)
 $currentQuarter = ceil($currentMonth / 3); // Определяем квартал (1-4)
-
+$this->registerJsFile('/js/cluster-link-edit/view.js', ['position' => \yii\web\View::POS_END]);
 ?>
 <style>
     tr>th:first-child, tr>td:first-child {
@@ -183,28 +183,4 @@ $currentQuarter = ceil($currentMonth / 3); // Определяем кварта
     </table>
 </div>
 
-<!-- Скрипт для управления отображением месяцев по кварталам -->
-<script>
-    document.addEventListener('DOMContentLoaded', function () {
-        const quarterSelect = document.getElementById('quarter-select');
-        const monthColumns = document.querySelectorAll('.month-column');
-
-        function updateMonthColumns() {
-            const selectedQuarter = quarterSelect.value;
-
-            monthColumns.forEach(function (column) {
-                if (column.dataset.quarter === selectedQuarter) {
-                    column.style.display = '';
-                } else {
-                    column.style.display = 'none';
-                }
-            });
-        }
-
-        // Событие при изменении квартала
-        quarterSelect.addEventListener('change', updateMonthColumns);
-
-        // Инициализация: отображаем текущий квартал при загрузке
-        updateMonthColumns();
-    });
-</script>
+
index f32e0837495376f30056c403c6ccd89067fc130e..ddc1f57651a4917442a9f923658d9ac435d8921d 100755 (executable)
     overflow: hidden;
     white-space: nowrap;
     text-overflow: ellipsis;
+}
+
+.cluster-index svg {
+
+    display:inline-block;
+    font-size:inherit;
+    height:1em;
+    overflow:visible;
+    vertical-align:-.125em;
+    width:1.125em
+}
+
+.cluster-view svg{
+    display:inline-block;
+    font-size:inherit;
+    height:1em;
+    overflow:visible;
+    vertical-align:-.125em;
+    width:.875em
 }
\ No newline at end of file
diff --git a/erp24/web/js/cluster-link-edit/view-all.js b/erp24/web/js/cluster-link-edit/view-all.js
new file mode 100644 (file)
index 0000000..3fba472
--- /dev/null
@@ -0,0 +1,39 @@
+$('select[name="cluster_id"]').change(function() {
+    let storeId = $(this).data('store-id');
+    let newClusterId = $(this).val();
+
+    // Получаем имя магазина из первого столбца той же строки
+    let storeName = $(this).closest('tr').find('td:first').text().trim();
+
+    // Добавляем подтверждение с именем магазина
+    if (confirm('Вы действительно хотите перевести магазин ' + storeName + ' в куст с номером ' + newClusterId + '?')) {
+        // Отправляем данные на сервер после подтверждения
+        $.post({
+            url: 'move-store',
+            data: { store_id: storeId, new_cluster_id: newClusterId },
+            success: function() {
+                // Если магазин был успешно перемещен, удаляем его строку из таблицы
+                $('select[name="cluster_id"][data-store-id="' + storeId + '"]').closest('tr').remove();
+                alert('Магазин успешно переведен в новый куст');
+            },
+            error: function() {
+                alert('Ошибка при переводе магазина');
+            }
+        });
+    } else {
+        // Если пользователь отменил действие
+        console.log('Перемещение отменено пользователем.');
+    }
+});
+// Отслеживаем изменение выбора магазина в селекте
+$('#store-id-select').change(function() {
+    let storeId = $(this).val();
+    if (storeId) {
+        $('#add-store-button').prop('disabled', false); // Включаем кнопку, если выбран магазин
+    } else {
+        $('#add-store-button').prop('disabled', true); // Отключаем кнопку, если магазин не выбран
+    }
+});
+
+// Изначально кнопка добавления должна быть отключена
+$('#add-store-button').prop('disabled', true);
\ No newline at end of file
diff --git a/erp24/web/js/cluster-link-edit/view.js b/erp24/web/js/cluster-link-edit/view.js
new file mode 100644 (file)
index 0000000..d49e5a6
--- /dev/null
@@ -0,0 +1,22 @@
+document.addEventListener('DOMContentLoaded', function () {
+    const quarterSelect = document.getElementById('quarter-select');
+    const monthColumns = document.querySelectorAll('.month-column');
+
+    function updateMonthColumns() {
+        const selectedQuarter = quarterSelect.value;
+
+        monthColumns.forEach(function (column) {
+            if (column.dataset.quarter === selectedQuarter) {
+                column.style.display = '';
+            } else {
+                column.style.display = 'none';
+            }
+        });
+    }
+
+    // Событие при изменении квартала
+    quarterSelect.addEventListener('change', updateMonthColumns);
+
+    // Инициализация: отображаем текущий квартал при загрузке
+    updateMonthColumns();
+});
\ No newline at end of file