'; if ($new != "2" && $new != "3") $taskarr = GrabTasktypes("subs"); echo "
"; echo "

Среднее время выполнения задач компании $companyname:

"; EchoTaskTypes($taskarr); echo "
"; function EchoTaskTypes($arr, $chooseSubtasks = false) { global $link, $companyID; foreach ($arr as $res1) { $tasktype_id = $res1->id; $taskname = $res1->name; $description = $res1->description; $main = $res1->main_task; $completeTime = intval($res1->time_to_complete_minutes); // $tasktype_id = $res1['id']; // $taskname = $res1['name']; // $description = $res1['description']; // $main = $res1['main_task']; // $completeTime = intval($res1['time_to_complete_minutes']); $global = ''; $styletab = ' style="margin-left: 40px"'; $nam = 'Задача '.$tasktype_id.$global.': '.$taskname.''; echo "
"; echo $nam; if ($description != '') echo " [$description]"; if ($main != '1') echo " Норматив выполнения: ".$completeTime." минут"; if ($chooseSubtasks) echo ' '; else{ ShowSubTasks($tasktype_id); } echo '


'; $query1 = mysqli_query($link, "select * from accounts where company=$companyID"); while ($res1 = mysqli_fetch_array($query1)) { $staff_id = $res1['id']; $staff_name = $res1['name']; echo ''.$staff_name.':'; // $eff = EfficiencyReport($staff_id); $tasks = GrabReadyTasksForAccount($staff_id, $tasktype_id); // $data = $eff[$tasktype_id]; if (sizeof($tasks) == 0) echo ' не выполнял'; else { $data = round(GetAverageTime($tasks)/60.0, 0, PHP_ROUND_HALF_UP); $minutes = 'минут'; switch (intval($data)) { case 0: $data = 'меньше минуты'; $minutes = ''; break; case 1: $minutes = 'минуту'; break; case 2: case 3: case 4: $minutes = 'минуты'; break; } echo " в среднем затрачивает $data $minutes "; echo ""; } echo "

"; } echo "

"; } } function ShowSubTasks($id) { global $link, $Subtaskarr; $str = "select subtasks from tasktypes where id=$id"; $query1 = mysqli_query($link, $str); if ($res1 = mysqli_fetch_row($query1)) { $arr = explode(",", $res1[0]); if (sizeof($arr) > 0 && $arr[0] != '') { echo ' '; } } } ?>