#vagrant folder
/.vagrant
/cron_last_run.txt
+
+/uploads/*
+/data/*
+/runtime/*
\ No newline at end of file
$date1_=date("Y-m-d",$date1);
$date2_=date("Y-m-d",$date2);
-$_REQUEST["date1"]=$date1_;
-$_REQUEST["date2"]=$date2_;
if(!empty($_REQUEST["date1"])) {
$date1=htmlentities($_REQUEST["date1"]);
$status_amo=intval($_REQUEST["status_id"] ?? 0);
+} else {
+ $_REQUEST["date1"]=$date1_;
+ $_REQUEST["date2"]=$date2_;
}
-$unix_delivery_date0=time()-1*3600;
-$unix_delivery_date1=time();
+if(!empty($_REQUEST["date1"])) {
+ $unix_delivery_date0 = strtotime($_REQUEST["date1"]);
+} else {
+ $unix_delivery_date0=time()-1*3600;
+}
+if(!empty($_REQUEST["date2"])) {
+ $unix_delivery_date1=strtotime($_REQUEST["date2"]);
+} else {
+ $unix_delivery_date1=time();
+}
+
/*
echo'<form method=post action=""><div class="row"><div class="col-12">
<input type=date name=date1 value="'.$date1_.'" class="form-control" width=120>
}
$unset_valiues[]="florist_foto";
+ $unset_valiues[]="florist_peredano";
+ $unset_valiues[]="florist_zabor";
+ $unset_valiues[]="florist_sobrano";
+
//updated_at
$dt="created_at";
if(isset($_REQUEST["page_amo"])) $page_amo=(int)$_REQUEST["page_amo"];
- $delivery__date='&filter['.$dt.'][from]='.$unix_delivery_date0.'&filter['.$dt.'][to]='.$unix_delivery_date1.'';
-//$delivery__date .='&filter[custom_fields_values][647935][from]='.$unix_delivery_date0.'&filter[custom_fields_values][647935][to]='.$unix_delivery_date1.'&page='.$page_amo.''; //
+// $delivery__date='&filter['.$dt.'][from]='.$unix_delivery_date0.'&filter['.$dt.'][to]='.$unix_delivery_date1.'';
+$delivery__date .='&filter[custom_fields_values][647935][from]='.$unix_delivery_date0.'&filter[custom_fields_values][647935][to]='.$unix_delivery_date1.'&page='.$page_amo.''; //
echo date("d.m.Y H:i:s" , $unix0);
$sql_query="";
foreach($sql_fields as $pole) {
- if (array_key_exists($pole, $result)) {
+ if (!array_key_exists($pole, $result)) {
unset($result[$pole]);
}
}
+
$param=array();
$param_insert=array();
$i=0; $upper="";
}
- $i=0; $insert="";
+ $i=0; $insert=""; $insert_fields = []; $insert_values = [];
foreach($result as $row =>$value) {
- if(!empty($sql_fields[$row])) { // удаляем поля которых нет в таблице
- if($i!=0) { $insert.=","; }
- $insert.=" $row=:$row";
- $param_insert[$row]=$value;
- $i++;
+ if (!empty($row) and !in_array($row,$unset_valiues)) {
+ if(in_array($row, $sql_fields)) { // удаляем поля которых нет в таблице
+ if($i!=0) {
+ $insert.=",";
+ }
+
+ $insert.=" $row=:$row";
+ $insert_fields[] = $row;
+ $insert_values[] = $value;
+ $param_insert[$row]=$value;
+ $i++;
+ }
}
}
- $z="INSERT INTO orders_amo SET ".$insert ." , id='".$result["nomer"]."'";
- $db::sql($z,$param_insert);
+ $z="INSERT INTO orders_amo (" . implode(", ", $insert_fields) . ", id, update_at) VALUES ('".implode("', '", $insert_values) ."' , '".$result["nomer"]."', NOW())";
+
+ $db::sql($z);
//$db::sql($z,$param_insert);
mess("Заказ внесен в таблицу $z ");
}
catch (Exception $e) {
- file_put_contents('modul/content/error.txt', PHP_EOL . $e->getMessage(), FILE_APPEND);
+ var_dump($e->getFile(). ' ' . $e->getLine() . ' '. $e->getMessage());
+ die;
+ file_put_contents('modul/content/error.txt', PHP_EOL . $e->getLine(). ' '. $e->getMessage(), FILE_APPEND);
}
} else {
}
echo"<h3>Состав</h3>";
$sum=0;
- $data=$db::getRows("SELECT item_id, guid, price, name, kol FROM site_order_items_sostav WHERE tip='1' AND lid_id=? ",[(int)$result["nomer"]]);
+// $data=$db::getRows("SELECT item_id, guid, price, name, kol FROM site_order_items_sostav WHERE tip='1' AND lid_id=? ",[(int)$result["nomer"]]);
+ $date = [];
foreach($data as $row) {
$sum=$sum+$row["kol"]*$row["price"];
echo"<br> ". $row["name"] ." ". $row["kol"] ." ". $row["price"] ." ". $row["guid"] ." ";
exit('Incorrect secret phrase');
}
-chmod(__DIR__ . "/../../../inc/amo/" . SECRET_FILE, 0740);
+//chmod(__DIR__ . "/../../../inc/amo/" . SECRET_FILE, 0740);
if (!empty($_GET['grant_type']) && $_GET['grant_type'] == 'refresh_token') {
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
- '@uploads' => dirname(__DIR__) . "/uploads",
+ '@uploads' => dirname(__DIR__, 1) . "/uploads",
'@data-path' => dirname(__DIR__, 1) . "/data",
'@uploads-images-path' => "@uploads/images",
],
ini_set("memory_limit", "256M");
-include_once('../inc/base_new.php');
-include_once('../inc/amo_inc.php');
-error_reporting(E_ALL ^ E_NOTICE);
-ini_set("memory_limit", "256M");
-
use Exception;
use Yii;
use yii\web\Controller;
public static function ResizeImage($file_input, $w_o, $h_o, $quality = 100)
{
$file_output = str_replace('uploads/images/', 'uploads/images/resize/' . $w_o . '_' . $h_o . '_' . $quality . '/', $file_input);
- @mkdir('uploads/images/resize/' . $w_o . '_' . $h_o . '_' . $quality . '/');
- @mkdir('uploads/images/resize/' . $w_o . '_' . $h_o . '_' . $quality . '/' . substr(basename($file_input), 0, 2));
+ $dirOrigin = 'uploads/images/resize/' . $w_o . '_' . $h_o . '_' . $quality . '/';
+ @mkdir($dirOrigin);
+ $dirResize = $dirOrigin . substr(basename($file_input), 0, 2);
+ @mkdir($dirResize);
ImageResize::resize($file_input, $file_output, $w_o, $h_o, $quality);
usleep(10000);
}
$files = (!empty(self::$fileIndex) ? self::$fileIndex : self::getFileIndex());
self::$absolutePathArray = \Yii::$app->cache->getOrSet([__FUNCTION__, 'absolute_path_array'], function () use ($files) {
$result = [];
- $uploadDir = \Yii::getAlias('uploads/images');
+ $uploadDir = \Yii::getAlias('@uploads/images');
if (!empty($files)) {
foreach ($files as $id => $filename) {
$substr = substr($filename, 0, 2);
}
}
return $result;
- }, 86400, $fileDependency);
+ }, 0, $fileDependency);
}
return self::$absolutePathArray;
}
}
}
return $result;
- }, 86400, $fileDependency);
+ }, 0, $fileDependency);
}
return self::$webPathArray;
}
$files = (!empty(self::$webpIndex) ? self::$webpIndex : self::getWebpIndex());
self::$webpAbsolutePathArray = \Yii::$app->cache->getOrSet([__FUNCTION__, 'webp_absolute_path_array'], function () use ($files) {
$result = [];
- $uploadDir = \Yii::getAlias('uploads/images');
+ $uploadDir = \Yii::getAlias('@uploads/images');
if (!empty($files)) {
foreach ($files as $id => $filename) {
$substr = substr($filename, 0, 2);
}
}
return $result;
- }, 86400, $fileDependency);
+ }, 0, $fileDependency);
}
return self::$webpAbsolutePathArray;
}
private static function getAbsolutePath($data)
{
$frontend = \Yii::getAlias('@frontend');
- $upload = \Yii::getAlias('uploads/images');
+ $upload = \Yii::getAlias('@uploads/images');
if (is_numeric($data)) {
$files = (!empty(self::$absolutePathArray) ? self::$absolutePathArray : self::getAbsolutePathArray());
*/
private static function getWebpAbsolutePath($data)
{
- $upload = \Yii::getAlias('uploads/images');
+ $upload = \Yii::getAlias('@uploads/images');
if (is_numeric($data)) {
$files = (!empty(self::$webpAbsolutePathArray) ? self::$webpAbsolutePathArray : self::getWebpAbsolutePathArray());
*/
private static function getResizedAbsolutePath($path, $width, $height, $quality)
{
- $upload = \Yii::getAlias('uploads/images');
+ $upload = \Yii::getAlias('@uploads/images');
$resize = preg_replace('/\/+/', '/', "{$upload}/resize/");
@mkdir($resize);
$path = preg_replace('/(.+\/web\/)(.+)/', '/$2', $path);
$frontend = \Yii::getAlias('@frontend');
- $upload = \Yii::getAlias('uploads/images');
+ $upload = \Yii::getAlias('@uploads/images');
$originalFilename = basename($path);
$webpFilename = explode('.', $originalFilename)[0] . '.webp';
define('SECRET_FILE', __DIR__ . '/token_amo__1234u5u6uvhvhfdjhrrtghhr2022.json');
define('SUBDOMAIN', 'bazacvetov24');
$arr_token = json_decode(file_get_contents(SECRET_FILE), true);
+global $ACCESS_TOKEN;
$ACCESS_TOKEN = $arr_token['access_token'];
function amo_rest($access_token, $end_point, $method = 'GET', $params) {
include_once(dirname(__DIR__, 2) . "/inc/base_new.php");
include_once(dirname(__DIR__, 2) . "/inc/design_new.php");
error_reporting(E_ALL);
+global $ACCESS_TOKEN;
try {
//include"templates/top.php";
$deal0 = amo_rest($ACCESS_TOKEN, '/api/v4/leads?order[updated_at]=desc&limit=250&filter[statuses][0][pipeline_id]=4021495&filter[statuses][0][status_id]='.$status.''.$delivery__date.'', 'GET', []);
//echo print_r($deal0);
-foreach($deal0["_embedded"]["leads"] as $lid_id3 => $arr0) {
+foreach($deal0["_embedded"]["leads"] ?? [] as $lid_id3 => $arr0) {
foreach($arr0["custom_fields_values"] as $fid => $arr20) {
if($arr20["field_id"]==655357) $lid_id5=$arr20["values"][0]["value"];
if($arr20["field_id"]==647929) $store=$arr20["values"][0]["value"]; // store
$ext = '.' . end($ar_file_name);
$file_name = md5($file_obj->name . rand(100000, 999999)) . $ext;
$dir_name = substr($file_name, 0, 2);
- if (!is_dir('uploads/images')) {
- mkdir('uploads/images', 0777, true);
+
+ $uploadDirPath = \Yii::getAlias('@uploads/images');
+
+ if (!is_dir($uploadDirPath)) {
+ mkdir($uploadDirPath, 0777, true);
}
- if (!is_dir('uploads/images/' . $dir_name)) {
- mkdir('uploads/images/' . $dir_name);
+ $imageDirPath = $uploadDirPath . '/' . $dir_name;
+ if (!is_dir($imageDirPath)) {
+ mkdir($imageDirPath);
}
- if ($file_obj->saveAs(Yii::getAlias('uploads/images/' . $dir_name . '/' . $file_name))) {
+
+ if ($file_obj->saveAs($imageDirPath . '/' . $file_name)) {
$this->original_name = $file_obj->baseName;
$this->filename = $file_name;
$this->size = $file_obj->size;