public function actionCollation() { return $this->render('collation'); }
+ public function actionInfoDb2() { return $this->renderPartial('info-db2'); }
+
+ public function actionAjaxOrdersPays() { return $this->renderPartial('ajax-orders-pays'); }
+
+ public function actionAjaxOrderConnectPay() { return $this->renderPartial('ajax-order-connect-pay'); }
+
+ public function actionAjaxCollation() { return $this->renderPartial('ajax-collation'); }
+ public function actionAjaxCheckDell() { return $this->renderPartial('ajax-check-dell'); }
+
public function actionDelivery2()
{
if (!empty($_REQUEST["umoup"])) {
function create_order_from_amo($amo_id="") {
global $db, $db2,$ACCESS_TOKEN;
if(!empty($amo_id)) {
-include_once("inc/db.php");
-
-if(empty($ACCESS_TOKEN)) include_once"/var/www/www-root/data/www/amo.bazacvetov24.ru/amo/amo_inc.php";
+include_once(__DIR__ . "/db.php");
+
+if(empty($ACCESS_TOKEN)) include_once(dirname(__DIR__, 1) . "/inc/amo/amo_inc.php");
$deal = amo_rest($ACCESS_TOKEN, '/api/v4/leads/'.$amo_id.'?with=contacts','GET', []);
$id_contact = $deal['_embedded']['contacts'][0]['id'];
$custom_fields = $deal['custom_fields_values'];
$i=1;
+$tags = '';
+$tags_arr = '';
foreach($deal['_embedded']["tags"] as $ud => $tag) {
if($i<count($deal['_embedded']["tags"])) $z=","; else $z="";
$tags.="".$tag["name"]."$z";
}
//if($row["delivery_time"]==$row["delivery_time_old"]) $row["delivery_time_old"]="";
-if($row["delivery_time_extend"]==$row["delivery_time"]) $row["delivery_time_extend"]="";
-if($row["delivery_time_extend"]==$row["delivery_time_old"]) $row["delivery_time_extend"]="";
+if(($row["delivery_time_extend"] ?? "") == ($row["delivery_time"] ?? '')) $row["delivery_time_extend"]="";
+if(($row["delivery_time_extend"] ?? "") == ($row["delivery_time_old"] ?? '')) $row["delivery_time_extend"]="";
//foreach($row as $k => $v) echo"<br>$k => $v";
//print'<pre>';print_r($deal);echo'</pre>';
$contact = amo_rest($ACCESS_TOKEN, '/api/v4/contacts/' . $id_contact, $method = 'GET', []);
//$arr = ['lead' => $deal, 'contact' => $contact];
-$phone=$contact["custom_fields_values"]["0"]["values"]["0"]["value"];
-$email=$contact["custom_fields_values"]["1"]["values"]["0"]["value"];
-$name=$contact["name"];
+$phone=$contact["custom_fields_values"]["0"]["values"]["0"]["value"] ?? '';
+$email=$contact["custom_fields_values"]["1"]["values"]["0"]["value"] ?? '';
+$name=$contact["name"] ?? '';
$row["client"]=$name;
$row["phone"]=$phone;
$row["email"]=$email;
*/
$param=array();
$upper=array("id","price","pay","delivery","store_id","payment_type_id","status_id","florist_id","dostavka_povtor_tip");
-foreach($upper as $pole) $param[$pole]=$row[$pole];
+foreach($upper as $pole) {
+ $param[$pole] = $row[$pole] ?? "";
+}
$param["price"]=$summ;
//$param["istochnik_id"]=1;
//$uopdet="UPDATE orders_amo SET $sql0 WHERE id=:id ";
}
} catch (Exception $e0) {
- // echo 'Выброшено исключение: ', $e0->getMessage(), "\n";
- file_put_contents('modul/orders/error_create_order.txt', PHP_EOL . $e0->getMessage(), FILE_APPEND);
+ echo 'Выброшено исключение: ', $e0->getMessage(), $e0->getFile(), $e0->getLine(), $e0->getTraceAsString(), "\n";
+// file_put_contents('modul/orders/error_create_order.txt', PHP_EOL . $e0->getMessage(), FILE_APPEND);
return false;
}
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/base_new.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");
if(!empty($_REQUEST["order_id"])) $order_id=(int)$_REQUEST["order_id"];
if(!empty($_REQUEST["pay_id"])) $pay_id=htmlentities($_REQUEST["pay_id"]);
-mess("UPDATE orders_pays SET order_id=$order_id WHERE guid='$pay_id' AND guid!='' ");
-$db::sql("UPDATE orders_pays SET order_id=? WHERE guid=? AND guid!='' LIMIT 1 ",[$order_id,$pay_id]);
+mess("UPDATE orders_pays SET order_id=$order_id WHERE guid='$pay_id' AND guid!=''");
+$db::sql("UPDATE orders_pays SET order_id=? WHERE guid=? AND guid!=''",[$order_id,$pay_id]);
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/db2.php");
-include_once("inc/base_new.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");
if(!empty($_REQUEST["id"])) $id=(int)$_REQUEST["id"];
if(!empty($_REQUEST["amo_id"])) $amo_id=(int)$_REQUEST["amo_id"];
if(!empty($_REQUEST["phone"])) $phone=(int)$_REQUEST["phone"];
-$order=$db2::getRow("SELECT *,DATE_FORMAT(created_at, '%d.%m.%Y в %H:%i') as date FROM orders_amo WHERE id=?",[$id]);
+$order=$db::getRow("SELECT *,TO_CHAR(created_at, 'DD.MM.YYYY в HH:MM') as date FROM orders_amo WHERE id=?",[$id]);
echo"$id $price $delivery_date
price=".$order["price"]."
}
-if($found) mess("Платеж найден!");
+if($found ?? false) mess("Платеж найден!");
if(empty($found)) {
-<?
-include_once("startup.php");
-include_once("inc/base_new.php");
-include_once("inc/db2.php");
-include_once("inc/db.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");
if(!empty($_REQUEST["amo_id"]) and !empty($_REQUEST["status"])) {
-$amo_id=(int)$_REQUEST["amo_id"];
-$status=(int)$_REQUEST["status"];
-$name=htmlentities($_REQUEST["name"]);
-$row=$db2::getRow("SELECT * FROM orders_amo WHERE amo_id=? LIMIT 1",[$amo_id]);
-
-if($row) {
-
-
-$db::sql("insert ignore into orders_cheking (date, admin_id,amo_id,delivery_date, name, status) VALUES (NOW(),?, ?,?,?,? )",
-[$_SESSION["admin_id"], $amo_id, $row["delivery_date"], $name, $status]);
-mess("Поверка по заказу внесена статус $status");
-
- // if(!empty($err)) file_put_contents('modul/orders/collation_error.txt', PHP_EOL . "
-// Чек не создался lid_id= $lid_id ".$err, FILE_APPEND);
-
-
-}
+ $amo_id=(int)$_REQUEST["amo_id"];
+ $status=(int)$_REQUEST["status"];
+ $name=htmlentities($_REQUEST["name"]);
+ $row=$db::getRow("SELECT * FROM orders_amo WHERE amo_id=? LIMIT 1",[$amo_id]);
+ if($row) {
+ $db::sql("INSERT INTO orders_cheking (date, admin_id,amo_id,delivery_date, name, status) VALUES (NOW(),?, ?,?,?,? ) ON CONFLICT (amo_id) DO UPDATE SET date=NOW(), admin_id=?, delivery_date=?, name=?, status=?",
+ [$_SESSION["admin_id"], $amo_id, $row["delivery_date"], $name, $status, $_SESSION["admin_id"], $row["delivery_date"], $name, $status]);
+ mess("Поверка по заказу внесена статус $status");
+ // if(!empty($err)) file_put_contents('modul/orders/collation_error.txt', PHP_EOL . "
+ // Чек не создался lid_id= $lid_id ".$err, FILE_APPEND);
+ }
} else error_mess("Отсуствует ID заказа или статус проверки");
\ No newline at end of file
error_reporting(E_ALL ^ E_NOTICE);
+$in_orders = [];
+
try {
$delivery_arr=["Доставка","Такси", "Самовывоз", "Доставка из магазина"];
-echo"<form action=\"\" method=post>
-<table><td><input type=text name=lid_id value=\"" . ($lid_id ?? '') . "\" placeholder=\"ID заказа\" class=\"form-control\" style=\"width:100px;\">
+echo"<form action=\"\" method=post>";
+echo '<input type="hidden" name="_csrf" value="' . Yii::$app->request->getCsrfToken() . '" />';
+echo "<table><td><input type=text name=lid_id value=\"" . ($lid_id ?? '') . "\" placeholder=\"ID заказа\" class=\"form-control\" style=\"width:100px;\">
</td><td><input type=text name=amo_id value=\"\" placeholder=\"amo ID\" class=\"form-control\" style=\"width:100px;\">
</td><td>дата доставки:</td><td>
<input type=date name=delivery_date value=\"$delivery_date\" class=\"form-control\"></td>
-$data= $db::getRows("SELECT * FROM orders_cheking WHERE date>=NOW()::date- INTERVAL '17 day'");
+$data= $db::getRows("SELECT amo_id, name, date, delivery_date, admin_id, status FROM orders_cheking WHERE date>=NOW()::date- INTERVAL '17 day'");
foreach($data as $row) {
$orders_cheking_array[$row["amo_id"]]=" ".$row["name"]." ".$row["date"]." ".$row["delivery_date"]." ".$users_arr[$row["admin_id"]]." ".$row["status"]." ";
$orders_cheking_status_array[$row["amo_id"]]=$row["status"];
-$checkarr= $db::getRows("SELECT * FROM sales WHERE date>=NOW()::date - INTERVAL '120 day' order by date DESC");
+$sql = "SELECT id, operation, summ, number, date, store_id_1c, order_id FROM sales WHERE date>='" . $delivery_date
+ . "'::date - INTERVAL '25 day' AND date<='" . $delivery_date . "' AND operation IN ('Возврат', 'Продажа') order by date DESC";
+
+$checkarr= $db::getRows($sql);
//$cheks_txt=";
foreach($checkarr as $checkr) {
$cheks_txt ="<div class=\"cur col text-center p-1 m-1 ";
}
$cheks_txt .="</div>";
-if($checkr["operation"]=="Возврат") $check_vozvrat_cnt[$checkr["order_id"]]=$check_vozvrat_cnt[$checkr["order_id"]]+1;
-if($checkr["operation"]=="Продажа") $check_sale_cnt[$checkr["order_id"]]=$check_sale_cnt[$checkr["order_id"]]+1;
+if($checkr["operation"]=="Возврат") $check_vozvrat_cnt[$checkr["order_id"]]=($check_vozvrat_cnt[$checkr["order_id"]] ?? 0) + 1;
+if($checkr["operation"]=="Продажа") $check_sale_cnt[$checkr["order_id"]] = ($check_sale_cnt[$checkr["order_id"]] ?? 0) + 1;
$sale[$checkr["order_id"]] = ($sale[$checkr["order_id"]] ?? '') . $cheks_txt;
$data4= $db::getRow("SELECT * FROM create_checks WHERE date>=NOW()::date- INTERVAL '1 day' AND type='Продажа'");
-foreach($data4 as $row4) $create_check_arr[$row4["order_id"]]=$row4;
+foreach($data4 ? $data4 : [] as $row4) $create_check_arr[$row4["order_id"]]=$row4;
$j=0;
$data = $db::getRows("SELECT *,TO_CHAR(delivery_date, 'DD.MM.YYYY') as dated FROM orders_amo WHERE 1 = 1 $where AND delivery_date <= NOW() order by delivery_date DESC LIMIT 750");
echo"<table class=\"table table-hover\"><thead>
</tr>";
-if(!in_array($row["id"],$counter_no_check_array) and $check_vozvrat_cnt[$row["id"]]>=$check_sale_cnt[$row["id"]]) $conter_false_check++;
+if(!in_array($row["id"],$counter_no_check_array ?? []) and $check_vozvrat_cnt[$row["id"]]>=$check_sale_cnt[$row["id"]]) $conter_false_check++;
}
const token3 = $(\"meta[name=csrf-token]\").attr(\"content\");
$.ajax({
- url: '/orders/info_db2/',
+ url: '/orders/info-db2/',
method: 'post',
dataType: 'html',
data: { id: ''+id+'',amo_id: ''+amo_id+'' ,price: ''+price+'' , delivery_date: ''+delivery_date+'' , phone: ''+phone+'', [param3]: token3},
const token3 = $(\"meta[name=csrf-token]\").attr(\"content\");
$.ajax({
- url: '/orders/ajax_collation/',
+ url: '/orders/ajax-collation/',
method: 'post',
dataType: 'html',
data: { amo_id: ''+amo_id+'', name: ''+$('#name__'+amo_id+'').val()+'', status: ''+$('#status__'+amo_id+'').val()+'', [param3]: token3 },
const token3 = $(\"meta[name=csrf-token]\").attr(\"content\");
$.ajax({
- url: '/orders/ajax_check_dell/',
+ url: '/orders/ajax-check-dell/',
method: 'post',
dataType: 'html',
data: { check_id: ''+check_id+'', [param3]: token3 },
const token3 = $(\"meta[name=csrf-token]\").attr(\"content\");
$.ajax({
- url: '/orders/ajax_return_check/',
+ url: '/orders/ajax-return-check/',
method: 'post',
dataType: 'html',
data: { sales_check: ''+sales_check+'', [param3]: token3 },
const token3 = $(\"meta[name=csrf-token]\").attr(\"content\");
$.ajax({
- url: '/orders/ajax_create_check/',
+ url: '/orders/ajax-create-check/',
method: 'post',
dataType: 'html',
data: { order_id: ''+order_id+'', create_check: '2', [param3]: token3 },
-<?
-include_once("startup.php");
-include_once("inc/db.php");
-include_once("inc/db2.php");
-include_once("inc/base_new.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");
+
+global $sql_n2, $colors;
$pipeline=4021495;
foreach ($data as $row) $users_arr[$row["id"]]=$row["name"];
-$order=$db2::getRow("SELECT *,DATE_FORMAT(created_at, '%d.%m.%Y в %H:%i') as date FROM orders_amo WHERE id=?",[$id]);
+$order=$db::getRow("SELECT *,TO_CHAR(created_at, 'DD.MM.YYYY в HH:MM') as date FROM orders_amo WHERE id=?",[$id]);
echo'<b>'.$order["name"].'</b> Сумма'.$order["price"].' Дата доставки: '.$order["delivery_date"].' '.$order["delivery_time"].'
Тэги '.$order["tags"].'<br>
Дата заказа '.$order["date"].'<br>
-Текст заказа '.$order["text_order"].'<br>
+Текст заказа '.($order["text_order"] ?? '').'<br>
Телефон'.$order["phone"].'<br> Клиент'.$order["client"].'<br> Адрес '.$order["delivery_adress"].' ';
echo"
-<a href=\"https://bazacvetov24.amocrm.ru/leads/detail/".$order["amo_id"]."\" target=new".$row["amo_id"]." class=\"m-1 btn btn-sm btn-info\">заказ в амо</a>
+<a href=\"https://bazacvetov24.amocrm.ru/leads/detail/".$order["amo_id"]."\" target=new".($row["amo_id"] ?? '')." class=\"m-1 btn btn-sm btn-info\">заказ в амо</a>
<a href=\"https://bazacvetov24.ru/manager24/".$order["id"]."/?k=".$order["key_code"]."&p=J4CK22UEF4rFGBr6&amo_id=".$order["amo_id"]."\" target=new class=\"m-1 btn btn-sm btn-info\">состав</a>";
-$lid_id7 = $db2::getValue("SELECT lid_id FROM site_order_items_sostav WHERE lid_id=? AND tip=1",[$id]);
-if(empty($lid_id7)) { foreach($sql_n2 as $k => $sql) $db::sql($sql);}
+$lid_id7 = $db::getValue("SELECT lid_id FROM site_order_items_sostav WHERE lid_id=? AND tip=1",[$id]);
+if(empty($lid_id7)) { foreach($sql_n2 ?? [] as $k => $sql) $db::sql($sql);}
echo"<table class=\"table table-tovars table-hover table-sm\" id=\"sostav__table\">
<tbody>";
-$datas = $db::getRows("SELECT item_id FROM info_items_table_shop_0 WHERE cat_items_id='2'");
-foreach($datas as $ro) $usligi[$ro["item_id"]]=$ro["item_id"];
-
-$datas = $db::getRows("SELECT item_id,id_1c FROM info_items_table_shop_0 WHERE id_1c!=''");
-foreach($datas as $ro) $guid_arr[$ro["item_id"]]=$ro["id_1c"];
+//$datas = $db::getRows("SELECT item_id FROM info_items_table_shop_0 WHERE cat_items_id='2'");
+//foreach($datas as $ro) $usligi[$ro["item_id"]]=$ro["item_id"];
+//
+//$datas = $db::getRows("SELECT item_id,id_1c FROM info_items_table_shop_0 WHERE id_1c!=''");
+//foreach($datas as $ro) $guid_arr[$ro["item_id"]]=$ro["id_1c"];
$begin_step=1;
-$datas = $db2::getRows("SELECT *, kol*price as sumn FROM site_order_items_sostav WHERE lid_id='$id' AND tip=1 order by kol DESC, price DESC ");
+$datas = $db::getRows("SELECT *, kol*price as sumn FROM site_order_items_sostav WHERE lid_id='$id' AND tip=1 order by kol DESC, price DESC ");
+$itogo = 0;
foreach($datas as $row3) {
$row3["price"]=str_replace(".00","",$row3["price"]);
$row3["sumn"]=ceil($row3["sumn"]);
$classi="";
$cl="";
-if(!empty($row3["color_id"])) $cl=" цвет:".$colors[$row3["color_id"]];
+if(!empty($row3["color_id"])) $cl=" цвет:".($colors[$row3["color_id"]] ?? '');
if(!empty($usligi[$row3["item_id"]])) $classi=" class=\"bg-warning\" ";
if(empty($begin_step)) error_mess("В чеке есть товары которым не присвоен товар из 1с - нужно поставить товар с сайта в соотвкетствие товару из 1с");
-
-
-
-
-
-
--- /dev/null
+<?php
+
+chdir(__DIR__ . '/../../');
+
+include 'modul/orders/ajax_collation.php';
\ No newline at end of file
--- /dev/null
+<?php
+
+chdir(__DIR__ . '/../../');
+
+include 'modul/orders/ajaxOrderConnectPay.php';
\ No newline at end of file
--- /dev/null
+<?php
+
+chdir(__DIR__ . '/../../');
+
+include 'modul/orders/ajaxOrdersPays.php';
\ No newline at end of file
--- /dev/null
+<?php
+
+chdir(__DIR__ . '/../../');
+
+include 'modul/orders/info_db2.php';
\ No newline at end of file