]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
add bonus/vozvrat-stats during moving from pure php to yii
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 21 Dec 2023 10:14:22 +0000 (13:14 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 21 Dec 2023 10:14:22 +0000 (13:14 +0300)
erp24/actions/bonus/AjaxShowCheckAction.php [new file with mode: 0644]
erp24/actions/bonus/VozvratStatsAction.php [new file with mode: 0644]
erp24/controllers/BonusController.php
erp24/views/bonus/ajax-show-check.php [new file with mode: 0644]
erp24/views/bonus/vozvrat-stats.php [new file with mode: 0644]

diff --git a/erp24/actions/bonus/AjaxShowCheckAction.php b/erp24/actions/bonus/AjaxShowCheckAction.php
new file mode 100644 (file)
index 0000000..f33f5c8
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+namespace yii_app\actions\bonus;
+
+use yii\base\Action;
+
+class AjaxShowCheckAction extends Action
+{
+    public function run() {
+        return $this->controller->renderPartial('ajax-show-check');
+    }
+}
\ No newline at end of file
diff --git a/erp24/actions/bonus/VozvratStatsAction.php b/erp24/actions/bonus/VozvratStatsAction.php
new file mode 100644 (file)
index 0000000..f227430
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+namespace yii_app\actions\bonus;
+
+use yii\base\Action;
+
+class VozvratStatsAction extends Action
+{
+    public function run() {
+        return $this->controller->render('vozvrat-stats');
+    }
+}
\ No newline at end of file
index 226735a445db14c2dca7348a2e8b02bb8f588adb..1e58eb1c5dc02824236263f311fb8521e9ee98d3 100644 (file)
@@ -4,12 +4,12 @@ namespace app\controllers;
 
 class BonusController extends \yii\web\Controller
 {
-
     public function actions()
     {
         return [
             'stat' => \yii_app\actions\bonus\StatAction::class,
+            'vozvrat-stats' => \yii_app\actions\bonus\VozvratStatsAction::class,
+            'ajax-show-check' => \yii_app\actions\bonus\AjaxShowCheckAction::class,
         ];
     }
-
-}
+}
\ No newline at end of file
diff --git a/erp24/views/bonus/ajax-show-check.php b/erp24/views/bonus/ajax-show-check.php
new file mode 100644 (file)
index 0000000..964c20f
--- /dev/null
@@ -0,0 +1,91 @@
+<?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");
+
+error_reporting(E_ALL ^ E_NOTICE);
+
+if(!empty($_REQUEST["id"])) {
+    $id=htmlentities($_REQUEST["id"]);
+
+
+
+
+    $data = $db::getRow("SELECT  * FROM sales WHERE id=?",[$id]);
+
+
+    $data_v = $db::getRow("SELECT * FROM sales WHERE id=?",[$data["sales_check"]]);
+
+    echo '<h3> '.$data["operation"].'  Сумма'.$data["summ"].' Номер чека '.$data["number"].'</h3>
+
+<p>';
+
+    if(!empty($data["phone"]))
+        echo'Клиент <a href="/bonus/bonus_users/?search[phone]='.$data["phone"].'" target=new class="btn btn-success">
+Искать в бонусной '.$data["phone"].'</a>';
+
+
+    echo'Дата <b>'.$data["date"].'</b><br> ';
+// id: '.$id.'
+    $paym=json_decode($data["payments"],true);
+    $nal=0;
+    $paym_txt='';
+    foreach($paym as $kl =>$arrr) {
+        if($arrr["type"]=="Наличные") $nal=1;
+        $paym_txt .='1) Тип: '.$arrr["type"].'  '.$arrr["terminal"].'  Сумма:'.$arrr["summ"].'<br> ';
+    }
+
+
+    echo' <div class="alert '; if($nal==1) echo' alert-danger'; echo'">'.$paym_txt.'</div> ';
+
+
+
+
+    if(!empty($data_v)) {
+        $paym=json_decode($data_v["payments"],true);
+        $nal=0;
+        $paym_txt='';
+        foreach($paym as $kl =>$arrr) {
+            if($arrr["type"]=="Наличные") $nal=1;
+            $paym_txt .='1) Тип: '.$arrr["type"].'  '.$arrr["terminal"].'  Сумма:'.$arrr["summ"].'<br> ';
+        }
+
+        echo'<div class="alert alert-danger">По этому чеку был возврат<br>
+Дата: <b>'.$data_v["date"].' <br>'.$paym_txt.'</div>';
+
+    }
+
+
+    $data_v = $db::getRow("SELECT * FROM sales WHERE sales_check=?",[$id]);
+    if(!empty($data_v)) {
+        $paym=json_decode($data_v["payments"],true);
+        $nal=0;
+        $paym_txt='';
+        foreach($paym as $kl =>$arrr) {
+            if($arrr["type"]=="Наличные") $nal=1;
+            $paym_txt .='1) Тип: '.$arrr["type"].'  '.$arrr["terminal"].'  Сумма:'.$arrr["summ"].'<br> ';
+        }
+
+        echo'<div class="alert alert-danger">По этому чеку был возврат<br> Дата: <b>'.$data_v["date"].'<br> '.$paym_txt.'</div>';
+
+    }
+
+
+
+    $data = $db::getRows("SELECT  p.name, i.kol, i.summa, i.id_1c FROM sales_items as i RIGHT JOIN products_1c as p ON p.id=i.id_1c  WHERE i.check_id=?",[$id]);
+    echo'<div class="table-responsive"><table class="table table-hover table-sm">
+<thead><th>Наименование</th><th>кол-во</th><th>сумма</th></thead>
+<tbody>';
+    foreach($data as $row) {
+        $itogo=$itogo+$row["summa"];
+        echo '<tr><td>'.$row["name"].'</td><td>'.$row["kol"].'</td><td>'.$row["summa"].'</td></tr> ';
+    }
+    echo'</tbody></table></div>';
+
+    echo 'Итого: '.$itogo;
+
+
+}
+
+
diff --git a/erp24/views/bonus/vozvrat-stats.php b/erp24/views/bonus/vozvrat-stats.php
new file mode 100644 (file)
index 0000000..28e6c6d
--- /dev/null
@@ -0,0 +1,130 @@
+<?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);
+
+//$data = $db::getRows("SELECT id, name FROM admin ");
+//foreach ($data as $row)  $user_arr[$row["id"]]=$row["name"];
+$store_arr=array();
+$data = $db::getRows("SELECT id, name FROM city_store ");
+foreach ($data as $row)  $store_arr[$row["id"]]=$row["name"];
+
+
+$date1=date("Y-m-d",time()-86400*13);
+$date2=date("Y-m-d",time());
+
+if(!empty($_REQUEST["created_at1"])) $date1=htmlentities($_REQUEST["created_at1"]);
+if(!empty($_REQUEST["created_at2"])) $date2=htmlentities($_REQUEST["created_at2"]);
+
+$where=" AND date>='$date1 00:00:00' AND date<='$date2 23:59:59'";
+
+if(!empty($_REQUEST["store_id"]) and $_REQUEST["store_id"]!="-1") {
+    $store_id=intval($_REQUEST["store_id"]); $where .=" AND store_id='$store_id'";}
+
+
+
+echo"$where<form method=post role=\"form\" class=\"form-horizontal\" action=\"\">
+<input type=\"hidden\" name=\"_csrf\" value=\"" . Yii::$app->request->getCsrfToken() . "\" />
+<table><tbody>
+<tr>
+<input type=date style=\"width:150px;\" class=\"form-control datetime\" value=\"$date1\" name=created_at1>
+</td><td>
+<input type=date  style=\"width:150px;\" class=\"form-control datetime\" value=\"$date2\" name=created_at2>
+</td><td>
+<select name=store_id  style=\"width:120px;\" class=\"form-control\">
+<option value=\"-1\""; if($store_id=="-1") echo" selected"; echo">-все-</option>
+<option value=\"0\""; if($store_id=="0") echo" selected"; echo">-без -</option>";
+
+foreach($store_arr as $id => $name) { echo"<option value=$id"; if($id==$store_id) echo" selected"; echo">$name</option>";}
+echo"</select>
+</td>
+
+<td><button type=submit class=\"btn btn-success\" name=show>поиск</button></td>
+
+</tr></tbody></table></form>";
+
+
+
+
+
+$data = $db::getRows("SELECT *, DATE_FORMAT(date,'%d.%m.%Y в %H:%i:%s') as date_t  FROM 
+sales WHERE   operation='Возврат' $where order by date desc");
+
+echo'<div class="table-responsive"><table class="table table-hover table-sm">
+<theah></thead><tbody>';
+foreach ($data as $row)  {
+    $paym=json_decode($row["payments"],true);
+    $nal=0;
+    $paym_txt='';
+    foreach($paym as $kl =>$arrr) {
+        if($arrr["type"]=="Наличные") $nal=1;
+        $paym_txt .='1) Тип: '.$arrr["type"].' '.$arrr["terminal"].'  Сумма:'.$arrr["summ"].'<br> ';
+    }
+
+    echo'<tr'; if($nal==1) echo' class="bg-danger"'; echo'><td>'.$row["date_t"].'</td>
+<td><b>'.$row["summ"].'</b></td><td>'.$row["status"].' 
+<a href="#" onclick="ajax_show_check(\''.$row["sales_check"].'\')" class="btn btn-info btn-sm">просмотр '.$row["number"].'</a>
+
+</td><td>'.$store_arr[$row["store_id"]].' </td><td>';
+
+
+
+
+    echo''.$paym_txt.''.$row["phone"].'</td></tr>';
+
+}
+echo'</tbody><table></div>';
+
+
+
+
+$_CONFIG["jscss"]="<script>
+
+const param7x = $('meta[name=csrf-param]').attr('content');
+const token7x = $('meta[name=csrf-token]').attr('content');
+
+function ajax_show_check(id) {
+ jQuery('#modal-7').modal('show', {backdrop: 'static'}); $('#modal-7 .modal-title').text('');  
+$.ajax({
+       url: '/bonus/ajax-show-check/',
+       method: 'post',       
+       dataType: 'html',        
+       data: { id: ''+id+'', [param7x]: token7x},  
+       success: function(data){  
+       $('#modal-7 .modal-body').html(data);
+       }}); 
+}
+
+
+</script>";
+
+
+echo'<!-- MODAL -->
+               <div class="modal fade" id="modal-7">
+                       <div class="modal-dialog modal-dialog-centered text-center" role="document">
+                               <div class="modal-content modal-content-demo">
+                                       <div class="modal-header">
+                                               <h6 class="modal-title"></h6><button aria-label="Close" class="btn-close" data-bs-dismiss="modal" type="button"><span aria-hidden="true">&times;</span></button>
+                                       </div>
+                                       <div class="modal-body">
+                               
+                                       </div>
+                                       <div class="modal-footer">
+                                               
+                                        <button class="btn btn-secondary" data-bs-dismiss="modal" type="button">закрыть</button>
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+
+';
+
+
+
+
+include_once dirname(__DIR__, 2) . '/templates/bottom_light.php';