rasp - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of rasp.php

  1. <?php
  2.  
  3. $hour = "15:00";
  4. $progressarray = array();
  5.  
  6. $clientset = array(
  7.         "sergey" => array(
  8.                     "on" => 0, // 1 вкл, 0 выкл
  9.                     "starttime" => "09:00", // время работы start
  10.                     "endtime" => "09:01", // время работы end
  11.                     "file" => "sergey.txt", // файл
  12.                     "dayorder" => "10"), // заказ лидов на день
  13.         "partner200" => array(
  14.                     "on" => 1, 
  15.                     "starttime" => "09:30", 
  16.                     "endtime" => "19:31", 
  17.                     "file" => "partner2.txt", 
  18.                     "dayorder" => "15"), 
  19.         "partner100" => array(
  20.                     "on" => 0, 
  21.                     "starttime" => "09:30", 
  22.                     "endtime" => "19:31", 
  23.                     "file" => "partner1.txt", 
  24.                     "dayorder" => "0"), 
  25.         "dmitriy" => array(
  26.                     "on" => 1, 
  27.                     "starttime" => "10:00", 
  28.                     "endtime" => "19:01", 
  29.                     "file" => "dmit.txt", 
  30.                     "dayorder" => "40"), 
  31.         "msk1" => array(
  32.                     "on" => 1, 
  33.                     "starttime" => "09:00", 
  34.                     "endtime" => "19:01", 
  35.                     "file" => "msk1.txt", 
  36.                     "dayorder" => "40"), 
  37.         "migros" => array(
  38.                     "on" => 1, 
  39.                     "starttime" => "09:00", 
  40.                     "endtime" => "09:01", 
  41.                     "file" => "migros.txt", 
  42.                     "dayorder" => "0"), 
  43.         "nair" => array(
  44.                     "on" => 1, 
  45.                     "starttime" => "09:00", 
  46.                     "endtime" => "19:01", 
  47.                     "file" => "nair.txt", 
  48.                     "dayorder" => "50"), 
  49.         "klim" => array(
  50.                     "on" => 0, 
  51.                     "starttime" => "09:00", 
  52.                     "endtime" => "19:01", 
  53.                     "file" => "klim.txt", 
  54.                     "dayorder" => "100"), 
  55.                 );
  56.  
  57. foreach($clientset as $client => $set){ 
  58.  if ($set["on"] == 1 && $hour >= $set["starttime"] && strlen("file") < $set["dayorder"]) 
  59.  { 
  60.      $doneleads = "10";
  61.      $clientopt[$client]["minutessincelastlead"] = "16";
  62.      $clientopt[$client]["progress"] = $doneleads / $clientset[$client]["dayorder"]; 
  63.  }
  64. }
  65.  
  66. if (count(array_keys($clientopt)) == 0) { echo "klim"; } 
  67. if (count(array_keys($clientopt)) == 1) { $clientset[array_keys($clientopt)[0]]["sendlead"] = 1; }
  68.  
  69. // Если включенных клиентов больше одного НАЧИНАЕМ БОЛЬШОЙ IF 
  70. if (count(array_keys($clientopt)) > 1 ) {
  71. $clientopt["nair"]["minutessincelastlead"] = "5";
  72.     // если есть клиенты кому не приходили более 10 мин, отправляем туда
  73.     foreach($clientopt as $client => $set){ 
  74.         if ($clientopt[$client]["minutessincelastlead"] > 10) { $clientset[$client]["sendlead"] = 1; break; }
  75.     } 
  76.     
  77.     // if there are no sendlead, продолжаем (или отдельный флаг еще повесить)
  78.     
  79.     foreach($clientopt as $client => $set){ 
  80.         if ($clientopt[$client]["minutessincelastlead"] > 2) { array_push($progressarray, [$client => $clientopt[$client]["progress"]]); }
  81.     } 
  82.     
  83.     if (count($progressarray) == 0) {/* что тут ищем всех не обращая внимания на 2 мин ?*/}
  84.     if (count($progressarray) == 1) {$clientset[array_keys($progressarray)[0]]["sendlead"] = 1;}
  85.     if (count($progressarray) > 1) {$clientset[array_key_first($progressarray[array_search(min(array_values($progressarray)), $progressarray)])]["sendlead"] = 1;    }
  86.     
  87. }
  88. // $progressarray = array_column($clientopt, 'progress');
  89. // $clientsarray = array_keys($clientopt);
  90. // echo min(array_column($clientopt, 'progress'));
  91.  
  92. echo "\n\n\nprogressarray";
  93. print_r($progressarray);
  94. //print_r($clientsarray);
  95. print_r($clientopt);
  96. echo "\n\n\n========================--";
  97. print_r($clientset);
  98.  
File Description
  • rasp
  • PHP Code
  • 12 Sep-2022
  • 3.99 Kb
You can Share it: