]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
feat(ERP-256): добавлена кнопка «за прошлый месяц» на странице ошибки смен origin/feature_filippov_ERP-256_cabinet_last_month_button
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 13 Mar 2026 13:16:13 +0000 (16:16 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 13 Mar 2026 13:16:13 +0000 (16:16 +0300)
Добавлен $buttonParams2 с диапазоном дат прошлого месяца.
Кнопка отображается рядом с «за неделю» при ошибке cs1.

erp24/services/CabinetService.php
erp24/views/cabinet/error.php

index 18067d6f4ed7c040391be221c825143d33fb7711..9070b45eb970d03f9122874075d982fb89d3fe36 100755 (executable)
@@ -760,7 +760,15 @@ class CabinetService
                 'name' => 'за неделю',
             ];
 
-            $outputCheckError = $this->outputCheckError($errorText, $buttonParams, $controller);
+            $dateFromLastMonth = date("Y-m-01", strtotime("-1 month"));
+            $dateToLastMonth = date("Y-m-t", strtotime("-1 month"));
+
+            $buttonParams2 = [
+                'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromLastMonth . "&DaysSearchForm[dateTo]=" . $dateToLastMonth,
+                'name' => 'за прошлый месяц',
+            ];
+
+            $outputCheckError = $this->outputCheckError($errorText, $buttonParams, $controller, $buttonParams2);
             if (!empty($outputCheckError)) {
                 if (array_key_exists('errorText', $outputCheckError)) {
                     return [
@@ -2282,7 +2290,15 @@ class CabinetService
                 'name' => 'за неделю',
             ];
 
-            $outputCheckError = $this->outputCheckError($errorText, $buttonParams, $controller);
+            $dateFromLastMonth = date("Y-m-01", strtotime("-1 month"));
+            $dateToLastMonth = date("Y-m-t", strtotime("-1 month"));
+
+            $buttonParams2 = [
+                'url' => "/cabinet/person?DaysSearchForm[employeeId]=" . $employeeId . "&DaysSearchForm[dateFrom]=" . $dateFromLastMonth . "&DaysSearchForm[dateTo]=" . $dateToLastMonth,
+                'name' => 'за прошлый месяц',
+            ];
+
+            $outputCheckError = $this->outputCheckError($errorText, $buttonParams, $controller, $buttonParams2);
             if (!empty($outputCheckError)) {
                 if (array_key_exists('errorText', $outputCheckError)) {
                     return [
@@ -6536,7 +6552,7 @@ Group BY admin_id
     }
 
 
-    public function outputCheckError(string $errorText, $buttonParams, $controller)
+    public function outputCheckError(string $errorText, $buttonParams, $controller, $buttonParams2 = [])
     {
         if (empty($controller)) {
             return [
@@ -6546,6 +6562,7 @@ Group BY admin_id
             echo $controller->render('/cabinet/error', [
                 'errorText' => $errorText,
                 'buttonParams' => $buttonParams,
+                'buttonParams2' => $buttonParams2,
             ]);
             die();
         }
index 347c0dc7d4d1465d826cf85d5486807cb2099845..4d0cb1a6a3f0b0aa3406c4ee13086618c7a0579a 100755 (executable)
@@ -22,6 +22,9 @@ if (empty($hideButton)) {
 if (empty($buttonParams)) {
     $buttonParams = [];
 }
+if (empty($buttonParams2)) {
+    $buttonParams2 = [];
+}
 ?>
 
 
@@ -49,6 +52,13 @@ if (empty($buttonParams)) {
 
                 echo Html::a($buttonName, $buttonUrl, ['class' => 'btn btn-success']);
             }
+
+            if (!empty($buttonParams2)) {
+                $buttonUrl2 = ArrayHelper::getValue($buttonParams2, 'url');
+                $buttonName2 = ArrayHelper::getValue($buttonParams2, 'name');
+                echo ' ';
+                echo Html::a($buttonName2, $buttonUrl2, ['class' => 'btn btn-info']);
+            }
             ?>
         </div>
     </div>