]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавлены даты границ опроса камер
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 11 Jul 2024 11:44:42 +0000 (14:44 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 11 Jul 2024 11:44:42 +0000 (14:44 +0300)
erp24/api1/views/cron/domru-cams.php

index 1498ad797adaef392ae1324a1918fb7e210db232..52298890fab49bb51f1eb8ba9ace3b870976648f 100644 (file)
@@ -23,11 +23,10 @@ foreach($revers as $cam_id => $name) {
 }
 
 
-//$tip=rand(0,4);
-
-$daysCnt = 2;
-//if (isset($_GET["tip"])) $tip = (int)$_GET["tip"];
-if (!empty($_GET["daysCnt"])) $daysCnt = (int)$_GET["daysCnt"];
+$date1 = date('Y-m-d', strtotime('-1 day', time()));
+$date2 = date('Y-m-d');
+if (!empty($_GET["date1"])) $date1 = $_GET['date1'];
+if (!empty($_GET["date2"])) $date2 = $_GET['date2'];
 
 
 foreach (range(0,4) as $tip){
@@ -91,14 +90,16 @@ foreach (range(0,4) as $tip){
 
 
 
-    echo "За дней $daysCnt";
+    //echo "За дней $daysCnt";
+    echo "С $date1 по $date2";
 
-    for ($Offset = 0; $Offset <= $daysCnt; $Offset++) {
+    $currDate = $date1;
+    while ($currDate <= $date2) {
         $array = array(
             'SessionID' => $sid,
             'Analytics' => 'CrossingLine',
-            'From' => date("Y-m-d 00:00:00", time() - 86400 * ($Offset)),
-            'To' => date("Y-m-d 23:59:59", time() - 86400 * ($Offset - 1)),
+            'From' => date("Y-m-d 00:00:00", strtotime($currDate)),
+            'To' => date("Y-m-d 23:59:59", strtotime($currDate)),
             'Direction' => 'Out',
             'GroupBy' => 'hour',
             'Limit' => 1000
@@ -117,7 +118,7 @@ foreach (range(0,4) as $tip){
 
 //echo $html;
 
-        $file_put = __DIR__ . "/../../log/xml/ExportReport" . $acc . "_" . $Offset . ".xml";
+        $file_put = __DIR__ . "/../../log/xml/ExportReport" . $acc . "_" . $currDate . ".xml";
 
         file_put_contents($file_put, $html);
 //echo"<textarea class=\"form-control\">$html</textarea>";
@@ -206,11 +207,13 @@ foreach (range(0,4) as $tip){
 
 
         $filename = 'file_cnt.txt';
-        file_put_contents(__DIR__ . '/../../log/text/' . $filename, $Offset . "" . date("Y-m-d H:i:s") . "");
+        file_put_contents(__DIR__ . '/../../log/text/' . $filename, $currDate . "" . date("Y-m-d H:i:s") . "");
         if ($all) {
             arsort($all);
             foreach ($all as $cid => $val) echo "<br> $cid = > $val  "; ///".$allcnt[$cid]."
         }
+
+        $currDate = date("Y-m-d", strtotime("+1 day", strtotime($currDate)));
     }
     sleep(2);
 }