]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
store plan page
authorpavlikov_maxim <truobleblyat@yandex.ru>
Mon, 6 May 2024 08:58:23 +0000 (11:58 +0300)
committerpavlikov_maxim <truobleblyat@yandex.ru>
Mon, 6 May 2024 08:58:23 +0000 (11:58 +0300)
erp24/controllers/ShipmentController.php
erp24/modul/shipment/store_plan.php
erp24/views/shipment/store-plan.php [new file with mode: 0644]

index 4635daa6cb8750f41c732524a67781768d7da917..321aaf5e3c9e40d4f0cb18cf5ec63f74cf801452 100755 (executable)
@@ -16,6 +16,7 @@ class ShipmentController extends Controller
     {
         return $this->render('info');
     }
+    public function actionStorePlan() { return $this->render('store-plan'); }
     public function actionPolnogrammEdit() { return $this->render('polnogramm-edit'); }
     public function actionIndex() { return $this->render('index'); }
     //public function actionAdd() { return $this->render('add'); }
index e11a0112b2a0fdcf4dfd66e8078a6e2449405d9f..dacae64d1f81afab40da69e07b6fce349941a1c5 100644 (file)
@@ -1,86 +1,86 @@
-<?
+<?php
 include_once("startup.php");
 include_once("inc/db.php");
 include_once("inc/base_new.php");
 include_once("inc/design_new.php");
 
-include"templates/top.php";
-
-$year=date("Y");
-$month=(int)date("m");
-
-if(!empty($_REQUEST["store_id"])) $store_id=htmlentities($_REQUEST["store_id"]);
-if(!empty($_REQUEST["year"])) $year=intval($_REQUEST["year"]);
-if(!empty($_REQUEST["month"])) $month=intval($_REQUEST["month"]);
+$year = date("Y");
+$month = date("m");
+$values_data = $values_data ?? [];
+if (!empty($_REQUEST["store_id"])) $store_id = htmlentities($_REQUEST["store_id"]);
+if (!empty($_REQUEST["year"])) $year = intval($_REQUEST["year"]);
+if (!empty($_REQUEST["month"])) $month = intval($_REQUEST["month"]);
 
 //$users_group=$db::mapping("SELECT id,name FROM admin_group order by name ASC");
-$stores=$db::mapping("SELECT name,id FROM products_1c WHERE tip='city_store' AND view='1' order by name ASC");
+$stores = $db::mapping("SELECT name,id FROM products_1c WHERE tip='city_store' AND view='1' order by name ASC");
 
+foreach ($_POST["summ_week"] ?? [] as $storeid => $summ) {
 
-foreach($_POST["summ_week"] as $storeid => $summ) {
-    
 //$_POST["summ_week"] as $storeid => $summ  
-$summ2=$_POST["summ"][$storeid];
-$summ_fact=$_POST["summ_fact"][$storeid];
+    $summ2 = $_POST["summ"][$storeid];
+    $summ_fact = $_POST["summ_fact"][$storeid];
 
-$sql="INSERT IGNORE INTO store_plan SET  store_id='$storeid', month='$month', year='$year' , summ_week='$summ', summ='$summ2', summ_fact='$summ_fact' 
-ON DUPLICATE KEY UPDATE store_id='$storeid', month='$month', year='$year', summ_week='$summ', summ='$summ2', summ_fact='$summ_fact' ";
-$db::sql($sql);    
+    $sql = "INSERT INTO store_plan (store_id, month, year, summ_week, summ, summ_fact, plan_day, plan_day_saturday, plan_checks_counter, plan_avg, plan_checks_counter_saturday, plan_chacks_counter_week, plan_people_day, plan_people_day_saturday, plan_people_week, admin_id, date_edit) 
+VALUES ('$storeid','$month','$year','$summ','$summ2','$summ_fact',0,0,0,0,0,0,0,0,0,0,now())
+ON CONFLICT (store_id, month, year) DO UPDATE SET store_id='$storeid', month='$month', year='$year', summ_week='$summ', summ='$summ2', summ_fact='$summ_fact', date_edit=now()";
+    $db::sql($sql);
 
 //echo $sql;
 }
 
 
-$data=$db::getRows("SELECT * FROM store_plan WHERE year=? AND month=?",[$year,$month]);
-foreach($data as $row){
-$values_data[$row["store_id"]]["summ"]=$row["summ"];
-$values_data[$row["store_id"]]["summ_week"]=$row["summ_week"];    
-$values_data[$row["store_id"]]["summ_fact"]=$row["summ_fact"];    
+$data = $db::getRows("SELECT * FROM store_plan WHERE year=? AND month=?", [$year, $month]);
+foreach ($data as $row) {
+    $values_data[$row["store_id"]]["summ"] = $row["summ"];
+    $values_data[$row["store_id"]]["summ_week"] = $row["summ_week"];
+    $values_data[$row["store_id"]]["summ_fact"] = $row["summ_fact"];
 }
 
-echo'<h1>План продаж и закупки по магазинам</h1>';
-$array=[2019,2020,2021,2022];
-
+echo '<h1>План продаж и закупки по магазинам</h1>';
+$array = [2019, 2020, 2021, 2022];
 
 
-foreach($array as $y) {
- echo"<a href=\"/shipment/store_plan/?year=$y\" class=\"btn btn-";
-if($year==$y) { echo"success"; 
+foreach ($array as $y) {
+    echo "<a href=\"/shipment/store-plan/?year=$y\" class=\"btn btn-";
+    if ($year == $y) {
+        echo "success";
 
-} else echo"warning";  echo" btn-sm m-1\">$y ";
-echo"</a> ";  
+    } else echo "warning";
+    echo " btn-sm m-1\">$y ";
+    echo "</a> ";
 }
 
 
 $array = array(
-       1 => 'Январь',
-       2 => 'Февраль',
-       3 => 'Март',
-       4 => 'Апрель',
-       5 => 'Май',
-       6 => 'Июнь',
-       7 => 'Июль',
-       8 => 'Август',
-       9 => 'Сентябрь',
-       10 => 'Октябрь',
-       11 => 'Ноябрь',
-       12 => 'Декабрь'
+    1 => 'Январь',
+    2 => 'Февраль',
+    3 => 'Март',
+    4 => 'Апрель',
+    5 => 'Май',
+    6 => 'Июнь',
+    7 => 'Июль',
+    8 => 'Август',
+    9 => 'Сентябрь',
+    10 => 'Октябрь',
+    11 => 'Ноябрь',
+    12 => 'Декабрь'
 );
- echo"<br>";
-foreach($array as $monf => $m) {
- echo"<a href=\"/shipment/store_plan/?year=$year&month=$monf\" class=\"btn btn-";
-if($month==$monf) { echo"success"; 
-} else echo"info";  echo" btn-sm m-1\">$m ";
-echo"</a> ";  
-}
-
 
 
+echo "<br>";
+foreach ($array as $monf => $m) {
+    echo "<a href=\"/shipment/store-plan/?year=$year&month=$monf\" class=\"btn btn-";
+    if ($month == $monf) {
+        echo "success";
+    } else echo "info";
+    echo " btn-sm m-1\">$m ";
+    echo "</a> ";
+}
 
 
-echo'<form method=post action="/shipment/store_plan/?year='.$year.'&month='.$month.'"><table class="table table-hover">
+echo '<form method=post action="/shipment/store-plan/?year=' . $year . '&month=' . $month . '">
+<input type="hidden" name="_csrf" value=" ' . Yii::$app->request->getCsrfToken() . ' "/>
+<table class="table table-hover">
 <thead><th>магазин</th>
 <th>план продаж</th>
 
@@ -89,24 +89,20 @@ echo'<form method=post action="/shipment/store_plan/?year='.$year.'&month='.$mon
 </thead>
 
 <tbody>';
-foreach($stores as $strid=>$namestore){
-echo"<tr><td class=\"text-right\">$namestore</td><td><input  value=\"".$values_data[$strid]["summ"]."\"  type=text class=\"form-control\" name=summ[$strid]></td>
-<td><input type=text class=\"form-control\" value=\"".$values_data[$strid]["summ_week"]."\" name=summ_week[$strid]></td>
-<td><input type=text class=\"form-control\"  value=\"".$values_data[$strid]["summ_fact"]."\"  name=summ_fact[$strid]></td>
-
-</tr>";   
+foreach ($stores as $strid => $namestore) {
+    if ($values_data[$strid] ?? false) {
+        echo "<tr><td class=\"text-right\">$namestore</td><td><input  value=\"" . $values_data[$strid]["summ"] . "\"  type=text class=\"form-control\" name=summ[$strid]></td>
+<td><input type=text class=\"form-control\" value=\"" . $values_data[$strid]["summ_week"] . "\" name=summ_week[$strid]></td>
+<td><input type=text class=\"form-control\"  value=\"" . $values_data[$strid]["summ_fact"] . "\"  name=summ_fact[$strid]></td>
+</tr>";
+    }
 }
-echo'</tbody></table>
+echo '</tbody></table>
 
 <button type=submit name=save value=1 class="btn btn-success btn-lg m-2">сохранить</button>
 
 </form>';
 
-
-
-
-       
-include"templates/bottom.php"; 
        
 
 
diff --git a/erp24/views/shipment/store-plan.php b/erp24/views/shipment/store-plan.php
new file mode 100644 (file)
index 0000000..481f87f
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+chdir(__DIR__ . '/../../');
+
+include 'modul/shipment/store_plan.php';
\ No newline at end of file