From: Alexander Smirnov Date: Mon, 10 Feb 2025 11:13:31 +0000 (+0300) Subject: [ERP-283] запрет на редактирование X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=84d9b61bac6a0f020937ffc3f350647d74eb4d23;p=erp24_rep%2Fyii-erp24%2F.git [ERP-283] запрет на редактирование --- diff --git a/erp24/controllers/SalesWriteOffsPlanController.php b/erp24/controllers/SalesWriteOffsPlanController.php index 28528e5d..e52cca2e 100644 --- a/erp24/controllers/SalesWriteOffsPlanController.php +++ b/erp24/controllers/SalesWriteOffsPlanController.php @@ -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() { diff --git a/erp24/views/sales-write-offs-plan/index.php b/erp24/views/sales-write-offs-plan/index.php index 364d0cd3..f315dc5f 100644 --- a/erp24/views/sales-write-offs-plan/index.php +++ b/erp24/views/sales-write-offs-plan/index.php @@ -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) { ?> name ?>id) ?> - true, 'style' => 'background: lightgray;']) ?> + true]) ?> % - 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?> + 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> % - 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?> + 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> % - 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?> + 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?> % - 'number', 'min' => 0, 'onchange' => 'editField(this);']) ?> + 'number', 'min' => 0, 'readonly' => !$isEditable, 'onchange' => 'editField(this);']) ?>