'stat' => \yii_app\actions\bonus\StatAction::class,
'vozvrat-stats' => \yii_app\actions\bonus\VozvratStatsAction::class,
'ajax-show-check' => \yii_app\actions\bonus\AjaxShowCheckAction::class,
- 'users' => \yii_app\actions\bonus\UsersAction::class,
- 'ajax-bonus-history' => \yii_app\actions\bonus\AjaxBonusHistoryAction::class,
- 'ajax-user-add-stop-list' => \yii_app\actions\bonus\AjaxUserAddStopListAction::class,
- 'ajax-user-remove-stop-list' => \yii_app\actions\bonus\AjaxUserRemoveStopListAction::class,
+// 'users' => \yii_app\actions\bonus\UsersAction::class,
+// 'ajax-bonus-history' => \yii_app\actions\bonus\AjaxBonusHistoryAction::class,
+// 'ajax-user-add-stop-list' => \yii_app\actions\bonus\AjaxUserAddStopListAction::class,
+// 'ajax-user-remove-stop-list' => \yii_app\actions\bonus\AjaxUserRemoveStopListAction::class,
'ajax-bonus-remove' => \yii_app\actions\bonus\AjaxBonusRemoveAction::class,
'sex' => \yii_app\actions\bonus\SexAction::class,
];
}
+ public function actionBonusUsers() { return $this->render('bonus-users'); }
+ public function actionAjaxBonusHistory() { return $this->renderPartial('ajax-bonus-history'); }
+ public function actionAjaxUserAddStopList() { return $this->renderPartial('ajax-user-add-stop-list'); }
+ public function actionAjaxUserRemoveStopList() { return $this->renderPartial('ajax-user-remove-stop-list'); }
}
\ No newline at end of file
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/base_new.php");
-include_once("inc/uni.php");
-include_once("inc/bonus.php");
+<?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/uni.php");
+include_once(dirname(__DIR__, 2) . "/inc/bonus.php");
if(!empty($_REQUEST["id"])) {
-if($_REQUEST["dell_hostory"]==0) $dell_hostory=0; else $dell_hostory=1;
+if(($_REQUEST["dell_hostory"]??-1)==0) $dell_hostory=0; else $dell_hostory=1;
$store_arr=get_sql_array("city_store", "id", "name", "" );
$user_arr=get_sql_array("admin", "id", "name", "" );
if(empty($phone_user)) echo"<div class=\"text-center\"><a href=\"/users/add/\" target=new class=\"btn btn-lg btn-success mt-5 mb-5\">Добавить клиента в бонусную</a></div>";
-$data = $db::getRows("SELECT id,tip, tip_sale, store_id,bonus,date, name,admin_id, check_id, DATE_FORMAT(date,'%d.%m.%Y в %H:%i') as date_h,
-DATE_FORMAT(date_end,'%d.%m.%Y') as date_end, price,price_skidka
+$data = $db::getRows("SELECT id,tip, tip_sale, store_id,bonus,date, name,admin_id, check_id, TO_CHAR(date,'DD.MM.YYYY в HH:MM') as date_h,
+TO_CHAR(date_end,'DD.MM.YYYY') as date_end, price,price_skidka
FROM users_bonus WHERE phone=? order by date DESC",[$phone]);
echo"<table class=\"table table-bordered table-hover table-sm m-0\">
<thead><th width=120>бонусы</th><th width=150>дата</th><th width=25%>магазин, сотрудник</th><th>наименование</th><th>дата сгорания</th></thead><tbody>";
+$minus = 0;
foreach ($data as $row) {
-if($row["tip"]=="plus") {$tip="+"; $store_arr_bonus[$row["store_id"]]["plus"]=$store_arr_bonus[$row["store_id"]]["plus"]+$row["bonus"];}
-else { $tip="-"; $minus=$minus+$row["bonus"]; $store_arr_bonus[$row["store_id"]]["minus"]=$store_arr_bonus[$row["store_id"]]["minus"]+$row["bonus"]; }
+if($row["tip"]=="plus") {$tip="+"; $store_arr_bonus[$row["store_id"]]["plus"]=($store_arr_bonus[$row["store_id"]]["plus"]??0)+$row["bonus"];}
+else { $tip="-"; $minus=$minus+$row["bonus"]; $store_arr_bonus[$row["store_id"]]["minus"]=($store_arr_bonus[$row["store_id"]]["minus"]??0)+$row["bonus"]; }
echo'<tr class="bg-'; if($row["tip"]=="plus") echo'success';
if($row["tip"]=="minus") echo'danger';
$db::sql("INSERT INTO users_bonus (name, phone,date,store_id,check_id,tip,tip_sale,price,bonus)
VALUES ('Возврат по чеку', ?,?,?,?,'minus','vozvrat',?,?)",
[$phone, $data_v["date"], $row["store_id"], $check_id,$data_v["summ"] ,$row["bonus"] ]);
+
+
+
+
+
+
+
+
get_bonus_balans($phone, "update");
}
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/base_new.php");
-if(!empty($_REQUEST["phone"])) {
+<?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");
+
+if(!empty($_REQUEST["phone"])) {
$phone=(int)$_REQUEST["phone"];
-$db::sql("INSERT IGNORE INTO users_stop_list (phone,date, admin_id) VALUES (?,NOW(),?)",[$phone,$_SESSION["admin_id"]]);
+$sql = "INSERT INTO users_stop_list (phone, name, date, admin_id) VALUES (?,'bonus/bonus-users',NOW(),?) ON CONFLICT (phone) DO UPDATE SET date=NOW(), admin_id=?";
+$db::sql($sql, [$phone,$_SESSION["admin_id"],$_SESSION["admin_id"]]);
$db::sql("UPDATE users SET black_list='1' WHERE phone=?",[$phone]);
echo"Добавлен!";
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/base_new.php");
-if(!empty($_REQUEST["phone"])) {
+<?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");
+
+if(!empty($_REQUEST["phone"])) {
$phone=(int)$_REQUEST["phone"];
$db::sql("DELETE FROM users_stop_list WHERE phone=?",[$phone]);
$db::sql("UPDATE users SET black_list='0' WHERE phone=?",[$phone]);
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/base_new.php");
-include_once("inc/design_new.php");
-include_once("inc/uni2.php");
-include_once("inc/bonus.php");
+<?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");
+include_once(dirname(__DIR__, 2) . "/inc/uni2.php");
+include_once(dirname(__DIR__, 2) . "/inc/bonus.php");
global $modul,$act;
$modul="bonus";
-$act="bonus_users";
+$act="bonus-users";
-include"templates/top.php";
/*
$arr["bonus"]=rand(10,999);
$arr["phone"]="7".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."".rand(0,9)."";
$get="";
$where=" AND id>? ";
$binding[]=0;
-
+$search = [];
if(!empty($_REQUEST["search"])) {
foreach($_REQUEST["search"] as $pole =>$val) {
$search[$pole]=$val;
-$where .="order by $sort_by $asc_desc";
// получаем кол-во записей
-$resultNum = $db::getRow("SELECT COUNT(*) as postNum FROM users WHERE 1 $where ",$binding); //'%'.$name.'%'
-$rowCount = $resultNum['postNum'];
+$sql = "SELECT COUNT(*) as postnum FROM users WHERE 1 = 1 $where ";
+$resultNum = $db::getRow($sql,$binding); //'%'.$name.'%'
+$rowCount = $resultNum['postnum'];
$limit = 100;
$offset = !empty($_GET['p'])?(($_GET['p']-1)*$limit):0;
$offset=(int)$offset;
+$where .="order by $sort_by $asc_desc";
echo $where;
-$data = $db::getRows("SELECT *,DATE_FORMAT(bdate,'%d.%m.%Y') as bdate2,DATE_FORMAT(date,'%d.%m.%Y %H:%i') as date2 FROM users WHERE 1 $where LIMIT $offset,$limit",$binding);
-
+$sql = "SELECT *,TO_CHAR(bdate,'DD.MM.YYYY') as bdate2, TO_CHAR(date,'DD.MM.YYYY HH:MM') as date2 FROM users WHERE 1=1 $where LIMIT $limit OFFSET $offset";
+$data = $db::getRows($sql, $binding);
echo"<h1>Клиенты в программе лояльности</h1> ";
// $where ".print_r($binding)."
//пагинация
}
-echo"<div class=\"table-rosponsive\"><form method=post action=\"/$modul/$act/\"><table class=\"table table-bordered table-sm\">
-<thead><th>дата добавления</th><th>Клиент <br> <input type=text name=search[name] value=\"".$search["name"]."\">
+echo"<div class=\"table-rosponsive\"><form method=post action=\"/$modul/$act/\">" . '<input type="hidden" name="_csrf" value="' . Yii::$app->request->getCsrfToken() . '" />' . "<table class=\"table table-bordered table-sm\">
+<thead><th>дата добавления</th><th>Клиент <br> <input type=text name=search[name] value=\"".($search["name"] ?? '')."\">
<button type=submit class=\"btn btn-success btn-sm\">поиск</button>
-</th><th>Телефон <br> <input type=text name=search[phone] value=\"".$search["phone"]."\">
+</th><th>Телефон <br> <input type=text name=search[phone] value=\"".($search["phone"] ?? '')."\">
<button type=submit class=\"btn btn-success btn-sm\">поиск</button>
</th><th>продаж</th>
<th>Даты клиента</th>
if($row["bdate"]!='0000-00-00') {
$barr=explode("-",$row["bdate"]);
-echo '<small>'.$barr[2].'.'.$barr[1].'.'.$barr[0].'</small>';
-$vozrast=date("Y")-$barr[0];
-echo'('.$vozrast.')';
+ if (!empty($barr)) {
+ echo '<small>' . ($barr[2] ?? '') . '.' . ($barr[1] ?? '') . '.' . ($barr[0] ?? '') . '</small>';
+ if (!empty($barr[0])) {
+ $vozrast = date("Y") - (int)($barr[0] ?? 0);
+ echo '(' . $vozrast . ')';
+ }
+ }
}
<td>'.$row["balans"].' <font color=red>'.$balans.'</font></td><td>'.$row["bonus_minus"].'</td>
-<td> '.$row["referal_id"].'
+<td> '.($row["referal_id"] ?? '').'
Сума продажи '.$row["sale_price"].'
';
<script>
function ajax_bonus_history(id,phone) {
-
+const param3 = $('meta[name=csrf-param]').attr('content');
+const token3 = $('meta[name=csrf-token]').attr('content');
$.ajax({
- url: '/bonus/ajax_bonus_history/',
+ url: '/bonus/ajax-bonus-history/',
method: 'post',
dataType: 'html',
- data: {id: ''+id+'',phone: ''+phone+''},
+ data: {id: ''+id+'',phone: ''+phone+'', [param3]:token3},
success: function(data){
$('#tr_'+id).after('<tr id=\"trr_'+id+'\" class=\"bg-gray-400\"><td colspan=10>'+data+'</td></tr>');
}});
}
function ajax_user_add_stop_list(phone) {
+const param3 = $('meta[name=csrf-param]').attr('content');
+const token3 = $('meta[name=csrf-token]').attr('content');
$.ajax({
- url: '/bonus/ajax_user_add_stop_list/',
+ url: '/bonus/ajax-user-add-stop-list/',
method: 'post',
dataType: 'html',
- data: {phone: ''+phone+''},
+ data: {phone: ''+phone+'', [param3]:token3},
success: function(data){
$('#tdstop_'+phone).html(data);
}});
function ajax_user_remove_stop_list(phone) {
+const param3 = $('meta[name=csrf-param]').attr('content');
+const token3 = $('meta[name=csrf-token]').attr('content');
$.ajax({
- url: '/bonus/ajax_user_remove_stop_list/',
+ url: '/bonus/ajax-user-remove-stop-list/',
method: 'post',
dataType: 'html',
- data: {phone: ''+phone+''},
+ data: {phone: ''+phone+'', [param3]:token3},
success: function(data){
$('#tdstop_'+phone).html(data);
}});
function ajax_bonus_remove(id) {
+const param3 = $('meta[name=csrf-param]').attr('content');
+const token3 = $('meta[name=csrf-token]').attr('content');
$.ajax({
- url: '/bonus/ajax_bonus_remove/',
+ url: '/bonus/ajax-bonus-remove/',
method: 'post',
dataType: 'html',
- data: { id: ''+id+''},
+ data: { id: ''+id+'',[param3]:token3},
success: function(data){
$('#his'+id).html(data);
}});
function ajax_show_check(id) {
jQuery('#modal-7').modal('show', {backdrop: 'static'}); $('#modal-7 .modal-title').text('');
-
+
+const param3 = $('meta[name=csrf-param]').attr('content');
+const token3 = $('meta[name=csrf-token]').attr('content');
+
$.ajax({
- url: '/bonus/ajax_show_check/',
+ url: '/bonus/ajax-show-check/',
method: 'post',
dataType: 'html',
- data: { id: ''+id+''},
+ data: { id: ''+id+'', [param3]:token3},
success: function(data){
$('#modal-7 .modal-body').html(data);
}});
</div>
</div>
-';
-
+';
+
-include"templates/bottom.php";
+include_once dirname(__DIR__, 2) . '/templates/bottom_light.php';
<?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/uni.php");
-include_once(dirname(__DIR__, 2) . "/inc/bonus.php");
-
-error_reporting(E_ALL ^ E_NOTICE);
-
-
-if(!empty($_REQUEST["id"])) {
- $user_id=(int)$_REQUEST["id"];
- $phone=phoneClear($_REQUEST["phone"]);
-
-
-
- if($_REQUEST["dell_hostory"]==0) $dell_hostory=0; else $dell_hostory=1;
-
- $store_arr=get_sql_array("city_store", "id", "name", "" );
- $user_arr=get_sql_array("admin", "id", "name", "" );
-
-
-
-
- $phone_user = $db::getValue("SELECT phone FROM users WHERE phone=? LIMIT 1",[$phone]);
- if(empty($phone_user)) echo"<div class=\"text-center\"><a href=\"/users/add/\" target=new class=\"btn btn-lg btn-success mt-5 mb-5\">Добавить клиента в бонусную</a></div>";
-
-
- $data = $db::getRows("SELECT id,tip, tip_sale, store_id,bonus,date, name,admin_id, check_id, DATE_FORMAT(date,'%d.%m.%Y в %H:%i') as date_h,
-DATE_FORMAT(date_end,'%d.%m.%Y') as date_end, price,price_skidka
-FROM users_bonus WHERE phone=? order by date DESC",[$phone]);
- echo"<table class=\"table table-bordered table-hover table-sm m-0\">
-<thead><th width=120>бонусы</th><th width=150>дата</th><th width=25%>магазин, сотрудник</th><th>наименование</th><th>дата сгорания</th></thead><tbody>";
- foreach ($data as $row) {
- if($row["tip"]=="plus") {$tip="+"; $store_arr_bonus[$row["store_id"]]["plus"]=$store_arr_bonus[$row["store_id"]]["plus"]+$row["bonus"];}
- else { $tip="-"; $minus=$minus+$row["bonus"]; $store_arr_bonus[$row["store_id"]]["minus"]=$store_arr_bonus[$row["store_id"]]["minus"]+$row["bonus"]; }
-
- echo'<tr class="bg-'; if($row["tip"]=="plus") echo'success';
- if($row["tip"]=="minus") echo'danger';
-
-
- echo'"><td>';
-
- if($dell_hostory==1)
- echo'<span id=his'.$row["id"].' onclick="ajax_bonus_remove('.$row["id"].')" class="btn btn-sm btn-danger">X</span>';
-
-
- echo $tip.' '.$row["bonus"].'<br> от '.(int)$row["price"].'</td>
-<td>'.$row["date_h"].'';
- if($row["check_id"]) {
-
-
- echo'<br><span id=ch'.$row["id"].' onclick="ajax_show_check(\''.$row["check_id"].'\')" class="btn btn-sm btn-info">просмотр чека</span> ';
-
-
- $operation= $db::getValue("SELECT operation FROM sales WHERE id=? LIMIT 1",[$row["check_id"]]);
-
-
- if($operation=="Удален") echo'<sapn class="btn btn-lg btn-danger ">'.$operation.'</span> ';
-
-
-
-
-
- }
-
-
- $zov='';
-
- if($row["tip"]=="plus" and $row["tip_sale"]=="sale") {
- $data_v = $db::getRow("SELECT id, date, payments,summ,sales_check, operation FROM sales WHERE sales_check=? AND sales_check!='' LIMIT 1",[$row["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> ';
- }
-
-
-
- $zov='<div class="alert alert-danger">По этому чеку был возврат <b>'.$data_v["operation"].'</b><br> Дата: <b>'.$data_v["date"].'<br> '.$paym_txt.'</div>';
-
- if(!empty($row["check_id"]) and !empty($phone)) {
- $id_ol = $db::getValue("SELECT check_id FROM users_bonus WHERE phone=? AND check_id=? AND tip='minus'
-AND tip_sale='vozvrat' LIMIT 1",[$phone,$data_v["id"]]);
- if(empty($id_ol)) {
- $db::sql("INSERT INTO users_bonus (name, phone,date,store_id,check_id,tip,tip_sale,price,bonus)
-VALUES ('Возврат по чеку', ?,?,?,?,'minus','vozvrat',?,?)",
- [$phone, $data_v["date"], $row["store_id"], $data_v["id"],$data_v["summ"] ,$row["bonus"] ]);
- get_bonus_balans($phone, "update");
- }
-
- }
- }
- }
-
-
- /*function insert_bonus_vozvrat($phone,$check_id) {
- global $db;
- $id_ol = $db::getValue("SELECT check_id FROM users_bonus WHERE phone=? AND check_id=? AND tip='minus' AND tip_sale='vozvrat' LIMIT 1",[$phone,$check_id]);
- if(empty($id_ol)) {
-
- $data_v = $db::getRow("SELECT id, date, payments,summ FROM sales WHERE sales_check=?",[$row["check_id"]]);
-
-
-
- $db::sql("INSERT INTO users_bonus (name, phone,date,store_id,check_id,tip,tip_sale,price,bonus)
- VALUES ('Возврат по чеку', ?,?,?,?,'minus','vozvrat',?,?)",
- [$phone, $data_v["date"], $row["store_id"], $check_id,$data_v["summ"] ,$row["bonus"] ]);
- get_bonus_balans($phone, "update");
- }
-
- }*/
-
-
- echo'</td>
-<td>'.$store_arr[$row["store_id"]].', '.$user_arr[$row["admin_id"]].'</td>
-<td>'.$row["name"].' Сумма покупки: '.$row["price"].'';
- $row["price_skidka"]=(int)$row["price_skidka"];
- if(!empty($row["price_skidka"])) echo'Скидка:'.$row["price_skidka"];
-
- echo $zov;
-
- echo'</td><td>'.$row["date_end"].'</td></tr>';
- }
-
- echo'<tr><td colspan=2>Итого Списано бонусов: '.$minus.'</td></tr>';
-
- echo'</tbody></table>';
-
-}
-
+chdir(__DIR__ . '/../../');
+include 'modul/bonus/ajax_bonus_history.php';
\ No newline at end of file
--- /dev/null
+<?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/uni.php");
+include_once(dirname(__DIR__, 2) . "/inc/bonus.php");
+
+error_reporting(E_ALL ^ E_NOTICE);
+
+
+if(!empty($_REQUEST["id"])) {
+ $user_id=(int)$_REQUEST["id"];
+ $phone=phoneClear($_REQUEST["phone"]);
+
+
+
+ if($_REQUEST["dell_hostory"]==0) $dell_hostory=0; else $dell_hostory=1;
+
+ $store_arr=get_sql_array("city_store", "id", "name", "" );
+ $user_arr=get_sql_array("admin", "id", "name", "" );
+
+
+
+
+ $phone_user = $db::getValue("SELECT phone FROM users WHERE phone=? LIMIT 1",[$phone]);
+ if(empty($phone_user)) echo"<div class=\"text-center\"><a href=\"/users/add/\" target=new class=\"btn btn-lg btn-success mt-5 mb-5\">Добавить клиента в бонусную</a></div>";
+
+
+ $data = $db::getRows("SELECT id,tip, tip_sale, store_id,bonus,date, name,admin_id, check_id, DATE_FORMAT(date,'%d.%m.%Y в %H:%i') as date_h,
+DATE_FORMAT(date_end,'%d.%m.%Y') as date_end, price,price_skidka
+FROM users_bonus WHERE phone=? order by date DESC",[$phone]);
+ echo"<table class=\"table table-bordered table-hover table-sm m-0\">
+<thead><th width=120>бонусы</th><th width=150>дата</th><th width=25%>магазин, сотрудник</th><th>наименование</th><th>дата сгорания</th></thead><tbody>";
+ foreach ($data as $row) {
+ if($row["tip"]=="plus") {$tip="+"; $store_arr_bonus[$row["store_id"]]["plus"]=$store_arr_bonus[$row["store_id"]]["plus"]+$row["bonus"];}
+ else { $tip="-"; $minus=$minus+$row["bonus"]; $store_arr_bonus[$row["store_id"]]["minus"]=$store_arr_bonus[$row["store_id"]]["minus"]+$row["bonus"]; }
+
+ echo'<tr class="bg-'; if($row["tip"]=="plus") echo'success';
+ if($row["tip"]=="minus") echo'danger';
+
+
+ echo'"><td>';
+
+ if($dell_hostory==1)
+ echo'<span id=his'.$row["id"].' onclick="ajax_bonus_remove('.$row["id"].')" class="btn btn-sm btn-danger">X</span>';
+
+
+ echo $tip.' '.$row["bonus"].'<br> от '.(int)$row["price"].'</td>
+<td>'.$row["date_h"].'';
+ if($row["check_id"]) {
+
+
+ echo'<br><span id=ch'.$row["id"].' onclick="ajax_show_check(\''.$row["check_id"].'\')" class="btn btn-sm btn-info">просмотр чека</span> ';
+
+
+ $operation= $db::getValue("SELECT operation FROM sales WHERE id=? LIMIT 1",[$row["check_id"]]);
+
+
+ if($operation=="Удален") echo'<sapn class="btn btn-lg btn-danger ">'.$operation.'</span> ';
+
+
+
+
+
+ }
+
+
+ $zov='';
+
+ if($row["tip"]=="plus" and $row["tip_sale"]=="sale") {
+ $data_v = $db::getRow("SELECT id, date, payments,summ,sales_check, operation FROM sales WHERE sales_check=? AND sales_check!='' LIMIT 1",[$row["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> ';
+ }
+
+
+
+ $zov='<div class="alert alert-danger">По этому чеку был возврат <b>'.$data_v["operation"].'</b><br> Дата: <b>'.$data_v["date"].'<br> '.$paym_txt.'</div>';
+
+ if(!empty($row["check_id"]) and !empty($phone)) {
+ $id_ol = $db::getValue("SELECT check_id FROM users_bonus WHERE phone=? AND check_id=? AND tip='minus'
+AND tip_sale='vozvrat' LIMIT 1",[$phone,$data_v["id"]]);
+ if(empty($id_ol)) {
+ $db::sql("INSERT INTO users_bonus (name, phone,date,store_id,check_id,tip,tip_sale,price,bonus)
+VALUES ('Возврат по чеку', ?,?,?,?,'minus','vozvrat',?,?)",
+ [$phone, $data_v["date"], $row["store_id"], $data_v["id"],$data_v["summ"] ,$row["bonus"] ]);
+ get_bonus_balans($phone, "update");
+ }
+
+ }
+ }
+ }
+
+
+ /*function insert_bonus_vozvrat($phone,$check_id) {
+ global $db;
+ $id_ol = $db::getValue("SELECT check_id FROM users_bonus WHERE phone=? AND check_id=? AND tip='minus' AND tip_sale='vozvrat' LIMIT 1",[$phone,$check_id]);
+ if(empty($id_ol)) {
+
+ $data_v = $db::getRow("SELECT id, date, payments,summ FROM sales WHERE sales_check=?",[$row["check_id"]]);
+
+
+
+ $db::sql("INSERT INTO users_bonus (name, phone,date,store_id,check_id,tip,tip_sale,price,bonus)
+ VALUES ('Возврат по чеку', ?,?,?,?,'minus','vozvrat',?,?)",
+ [$phone, $data_v["date"], $row["store_id"], $check_id,$data_v["summ"] ,$row["bonus"] ]);
+ get_bonus_balans($phone, "update");
+ }
+
+ }*/
+
+
+ echo'</td>
+<td>'.$store_arr[$row["store_id"]].', '.$user_arr[$row["admin_id"]].'</td>
+<td>'.$row["name"].' Сумма покупки: '.$row["price"].'';
+ $row["price_skidka"]=(int)$row["price_skidka"];
+ if(!empty($row["price_skidka"])) echo'Скидка:'.$row["price_skidka"];
+
+ echo $zov;
+
+ echo'</td><td>'.$row["date_end"].'</td></tr>';
+ }
+
+ echo'<tr><td colspan=2>Итого Списано бонусов: '.$minus.'</td></tr>';
+
+ echo'</tbody></table>';
+
+}
+
+
if(!empty($_REQUEST["id"])) {
$id=(int)$_REQUEST["id"];
- if($_SESSON["group_id"]<3) {
- $db::sql("DELETE FROM users_bonus WHERE id=? LIMIT 1",[$id]);
+ if($_SESSION["group_id"]<3) {
+ $sql = "DELETE FROM users_bonus WHERE id=?";
+ $db::sql($sql,[$id]);
echo"Удален $id !";
}
<?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["phone"])) {
- $phone=(int)$_REQUEST["phone"];
- $db::sql("INSERT IGNORE INTO users_stop_list (phone,date, admin_id) VALUES (?,NOW(),?)",[$phone,$_SESSION["admin_id"]]);
- $db::sql("UPDATE users SET black_list='1' WHERE phone=?",[$phone]);
- echo"Добавлен!";
-
-}
-
+chdir(__DIR__ . '/../../');
+include 'modul/bonus/ajax_user_add_stop_list.php';
\ No newline at end of file
--- /dev/null
+<?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["phone"])) {
+ $phone=(int)$_REQUEST["phone"];
+ $db::sql("INSERT IGNORE INTO users_stop_list (phone,date, admin_id) VALUES (?,NOW(),?)",[$phone,$_SESSION["admin_id"]]);
+ $db::sql("UPDATE users SET black_list='1' WHERE phone=?",[$phone]);
+ echo"Добавлен!";
+
+}
+
+
<?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["phone"])) {
- $phone=(int)$_REQUEST["phone"];
- $db::sql("DELETE FROM users_stop_list WHERE phone=?",[$phone]);
- $db::sql("UPDATE users SET black_list='0' WHERE phone=?",[$phone]);
- echo"Удален из стоп листа!";
-
-}
-
+chdir(__DIR__ . '/../../');
+include 'modul/bonus/ajax_user_remove_stop_list.php';
\ No newline at end of file
--- /dev/null
+<?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["phone"])) {
+ $phone=(int)$_REQUEST["phone"];
+ $db::sql("DELETE FROM users_stop_list WHERE phone=?",[$phone]);
+ $db::sql("UPDATE users SET black_list='0' WHERE phone=?",[$phone]);
+ echo"Удален из стоп листа!";
+
+}
+
+
--- /dev/null
+<?php
+
+chdir(__DIR__ . '/../../');
+
+include 'modul/bonus/bonus_users.php';
\ No newline at end of file