]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
add /bonus/write_off during moving pure php to yii
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 10 Jan 2024 16:43:26 +0000 (19:43 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 10 Jan 2024 16:43:26 +0000 (19:43 +0300)
erp24/actions/shipment/WriteOffAction.php [new file with mode: 0644]
erp24/controllers/ShipmentController.php
erp24/views/shipment/write_off.php [new file with mode: 0644]

diff --git a/erp24/actions/shipment/WriteOffAction.php b/erp24/actions/shipment/WriteOffAction.php
new file mode 100644 (file)
index 0000000..61e91cd
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+namespace yii_app\actions\shipment;
+
+use yii\base\Action;
+
+class WriteOffAction extends Action
+{
+    public function run() {
+        return $this->controller->render('write_off');
+    }
+}
\ No newline at end of file
index d42c40eddc499d9725c059afb69dd597ef700f12..9ba0173809eea9652815bfb09a1ec93887aef262 100755 (executable)
@@ -29,6 +29,7 @@ class ShipmentController extends \yii\web\Controller
             'store-products-fact-edit' => \yii_app\actions\shipment\StoreProductsFactEditAction::class,
             'polnogramm' => \yii_app\actions\shipment\PolnogrammAction::class,
             'store-planogram-logi' => \yii_app\actions\shipment\StorePlanogramLogiAction::class,
+            'write_off' => \yii_app\actions\shipment\WriteOffAction::class,
         ];
     }
 
diff --git a/erp24/views/shipment/write_off.php b/erp24/views/shipment/write_off.php
new file mode 100644 (file)
index 0000000..111c7b9
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+include_once(dirname(__DIR__, 2) . "/startup.php");
+include_once(dirname(__DIR__, 2) . "/inc/db.php");
+include_once(dirname(__DIR__, 2) . "/inc/base_new.php");
+include_once(dirname(__DIR__, 2) . "/inc/design_new.php");
+
+error_reporting(E_ALL ^ E_NOTICE);
+
+$date_14day=date("Y-m-d",time()-86400*7);
+$date2=date("Y-m-d",time());
+
+$where=""; $get="";
+if(!empty($_REQUEST["date1"])) {$date_14day=htmlentities($_REQUEST["date1"]); $where .=" AND date>='$date_14day'";  $get .="&date1=$date_14day";  }
+if(!empty($_REQUEST["date2"])) {$date2=htmlentities($_REQUEST["date2"]);  $where .=" AND date<='$date2'"; $get .="&date2=$date2";}
+
+
+echo'<form method=post>
+<input type="hidden" name="_csrf" value="' . Yii::$app->request->getCsrfToken() . '" />
+<table><td><input type=date name=date1 value="'.$date_14day.'" class="form-control"></td>
+<td><input type=date name=date2 value="'.$date2.'" class="form-control"> </td>
+<td><button class="btn btn-success" value="1" name=show>сохранить</button></td></table></form>';
+
+
+$stores=$db::mapping("SELECT id, name FROM products_1c WHERE tip='city_store'");
+
+
+$data=$db::getRows("SELECT p.product_id, products.name, sum(p.quantity) as cnt, w.store_id, prices.price
+FROM write_offs as w, write_offs_products as p , products_1c as products, prices
+WHERE p.write_offs_id=w.id AND products.id=p.product_id AND products.id=prices.product_id   AND w.type='Брак'  AND  w.date>=?  AND  w.date<=? group BY w.store_id, p.product_id order by p.product_id, cnt DESC",[$date_14day,$date2]);
+
+foreach($data as $row) {
+    $write[$row["product_id"]][$row["store_id"]] =$row["cnt"];
+    $write_all[$row["store_id"]] +=$row["cnt"];
+    $all +=$row["cnt"];
+
+
+    $write_price_all[$row["store_id"]] +=$row["cnt"]*$row["price"];
+    $all_price +=$row["cnt"]*$row["price"];
+}
+
+
+echo" Данные из 1c c $date_14day по  $date2
+ <h3>% списания от общего списания по магазинам</h3> 
+ Списнаия на сумму $all_price=
+  <table class=\"table table-border\"><tbody>";
+foreach($stores as $storeId =>$store) {
+
+    $percent_all=round(100*($write_all[$storeId]/($all + 0.0001)));
+    $percantArr[$storeId]=$percent_all;
+    $percentp_all=round(100*($write_price_all[$storeId]/($all_price + 0.0001)));
+    $percantArrPrice[$storeId]=$percentp_all;
+
+}
+
+arsort($percantArr);
+foreach($percantArr as $storeId =>$percent_all)  {
+    if($percent_all>0) echo"<tr><td> ".$stores[$storeId]." </td><td>$percent_all%</td><td>".$write_price_all[$storeId]."</td><td>".$percantArrPrice[$storeId]."%</td></tr>";
+
+}
+
+echo"</tbody></table>";
+
+$data=$db::getRows("SELECT p.product_id, products.name, sum(p.quantity) as cnt
+FROM write_offs as w, write_offs_products as p , products_1c as products
+WHERE p.write_offs_id=w.id AND products.id=p.product_id  AND w.type='Брак' AND  w.date>=?  AND  w.date<=? group BY p.product_id order by  cnt DESC",[$date_14day,$date2]);
+echo" <h3>Списания по магазинам</h3><table class=\"table table-border\">";
+foreach($data as $row) {
+
+    echo"<tr><td><span class=\"btn btn-info btn-sm me-2\" onclick=\"$('.p".$row["product_id"]."').toggle()\">+</span>".$row["name"]."</td><td>".$row["cnt"]."</td></tr> ";
+
+    foreach($write[$row["product_id"]] ?? [] as $storeId => $cnt) {
+
+
+        $percent=round( ($cnt/$row["cnt"])*100 );
+
+        echo"<tr style=\"display:none;\" class=\"p".$row["product_id"]."\"><td>$cnt  <b>$percent%</b></td><td>".$stores[$storeId]."</td></tr>";
+
+
+    }
+
+}
+echo"</table>";
+
+
+
+
+
+include_once dirname(__DIR__, 2) . '/templates/bottom_light.php';
\ No newline at end of file