]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-283] запрет на редактирование
authorAlexander Smirnov <fredeom@mail.ru>
Mon, 10 Feb 2025 11:13:31 +0000 (14:13 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Mon, 10 Feb 2025 11:13:31 +0000 (14:13 +0300)
erp24/controllers/SalesWriteOffsPlanController.php
erp24/views/sales-write-offs-plan/index.php

index 28528e5d429bf9ddee735b503c221596903b3f99..e52cca2e4cdcb3e20aa5f5dff87ab5cc601a217f 100644 (file)
@@ -31,6 +31,12 @@ class SalesWriteOffsPlanController extends Controller
 
         $model->load(Yii::$app->request->get());
 
+        $isEditable = date($model->year . '-' . $model->month . '-d') > date('Y-m-d') && (
+                (date('d') < 25) ||
+                (date('Y-m-d', strtotime('-1 month', date($model->year . '-' . $model->month . '-d'))) > date('Y-m-d')
+            ));
+//var_dump($isEditable); die;
+
         $prevPrevMonthStart = date("Y-m-01", strtotime("-2 month", strtotime($model->year . "-" . $model->month . "-01")));
         $prevPrevMonthEnd = date("Y-m-t", strtotime("-2 month", strtotime($model->year . "-" . $model->month . "-01")));
 
@@ -109,7 +115,7 @@ class SalesWriteOffsPlanController extends Controller
         $stores = $query->all();
 
         return $this->render('index', compact('model', 'years', 'stores',
-            'salesWriteOffsPlan', 'sales'));
+            'salesWriteOffsPlan', 'sales', 'isEditable'));
     }
 
     public function actionSaveFields() {
index 364d0cd3c0347c736c4918652dce3f4fc58d4bb1..f315dc5f30bd6e287e219e641763b958a26b7406 100644 (file)
@@ -20,6 +20,7 @@ use yii_app\records\SalesWriteOffsPlan;
 /* @var $stores array */
 /* @var $salesWriteOffsPlan SalesWriteOffsPlan[] */
 /* @var $sales array */
+/* @var $isEditable boolean */
 
 $this->registerJsFile('/js/sales-write-offs-plan/index.js', ['position' => \yii\web\View::POS_END]);
 
@@ -27,6 +28,9 @@ $this->registerCss('
 input[type=number], [name=total_sales_plan] {
   max-width: 100px;
 }
+input[readonly] {
+  background: lightgray;
+}
 ');
 
 function colorScheme1($p) {
@@ -167,32 +171,32 @@ function colorScheme2($p) {
                 ?>
                 <tr>
                     <td><?= $store->name ?><?= Html::hiddenInput('store_id', $store->id) ?></td>
-                    <td><?= Html::textInput('total_sales_plan', $total_sales_plan, ['readonly' => true, 'style' => 'background: lightgray;']) ?></td>
+                    <td><?= Html::textInput('total_sales_plan', $total_sales_plan, ['readonly' => true]) ?></td>
                     <td>
                         <?= Html::hiddenInput('total_sales_fact', $total_sales_fact) ?>
                         <span class="p1" style="color:<?= colorScheme1($p1) ?>">
                             <?= number_format(round($p1 * 100), 0, '.', ' ') ?>
                         </span>%
                     </td>
-                    <td><?= Html::textInput('write_offs_plan', $write_offs_plan, ['type' => 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?></td>
+                    <td><?= Html::textInput('write_offs_plan', $write_offs_plan, ['type' => 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?></td>
                     <td>
                         <span class="p2" style="color:<?= colorScheme2($p2) ?>">
                             <?= number_format(round($p2 * 100), 1, '.', ' ') ?>
                         </span>%
                     </td>
-                    <td><?= Html::textInput('offline_sales_plan', $offline_sales_plan, ['type' => 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?></td>
+                    <td><?= Html::textInput('offline_sales_plan', $offline_sales_plan, ['type' => 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?></td>
                     <td>
                         <span class="p3" style="color:<?= colorScheme1($p3) ?>">
                             <?= number_format(round($p3 * 100), 0, '.', ' ') ?>
                         </span>%
                     </td>
-                    <td><?= Html::textInput('online_sales_shop_plan', $online_sales_shop_plan, ['type' => 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?></td>
+                    <td><?= Html::textInput('online_sales_shop_plan', $online_sales_shop_plan, ['type' => 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?></td>
                     <td>
                         <span class="p4" style="color:<?= colorScheme1($p4) ?>">
                             <?= number_format(round($p4 * 100), 0, '.', ' ') ?>
                         </span>%
                     </td>
-                    <td><?= Html::textInput('online_sales_marketplace_plan', $online_sales_marketplace_plan, ['type' => 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?></td>
+                    <td><?= Html::textInput('online_sales_marketplace_plan', $online_sales_marketplace_plan, ['type' => 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?></td>
                     <td>
                         <span class="p5" style="color:<?= colorScheme1($p5) ?>">
                             <?= number_format(round($p5 * 100), 0, '.', ' ') ?>