analytics.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. echo ' <input type="submit" class="subtaskCheck" onclick="getXml()" name="subtask" value="Скачать XML">';
  5. if ($new != "2" && $new != "3")
  6. $taskarr = GrabTasktypes("subs");
  7. echo "<form id='form1' name='form1' method='post'>";
  8. echo "<h3>Среднее время выполнения задач компании $companyname:</h3>";
  9. EchoTaskTypes($taskarr);
  10. echo "</form>
  11. ";
  12. function EchoTaskTypes($arr, $chooseSubtasks = false)
  13. {
  14. global $link, $companyID;
  15. foreach ($arr as $res1) {
  16. $tasktype_id = $res1->id;
  17. $taskname = $res1->name;
  18. $description = $res1->description;
  19. $main = $res1->main_task;
  20. $completeTime = intval($res1->time_to_complete_minutes);
  21. // $tasktype_id = $res1['id'];
  22. // $taskname = $res1['name'];
  23. // $description = $res1['description'];
  24. // $main = $res1['main_task'];
  25. // $completeTime = intval($res1['time_to_complete_minutes']);
  26. $global = '';
  27. $styletab = ' style="margin-left: 40px"';
  28. $nam = '<b><span'.$styletab.'>Задача '.$tasktype_id.$global.': '.$taskname.'</span></b>';
  29. echo "<div style='border: solid; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; padding: 15px'>";
  30. echo $nam;
  31. if ($description != '')
  32. echo " [$description]";
  33. if ($main != '1')
  34. echo " <span style='color:#1f6377'>Норматив выполнения: <b>".$completeTime." минут</b></span>";
  35. if ($chooseSubtasks)
  36. echo ' <input type="checkbox" class="subtaskCheck" onclick="SubtaskTaskOn()" name="subtask'.$tasktype_id.'"/>';
  37. else{
  38. ShowSubTasks($tasktype_id);
  39. }
  40. echo '<p><br>';
  41. $query1 = mysqli_query($link, "select * from accounts where company=$companyID");
  42. while ($res1 = mysqli_fetch_array($query1))
  43. {
  44. $staff_id = $res1['id'];
  45. $staff_name = $res1['name'];
  46. echo '<b>'.$staff_name.':</b>';
  47. // $eff = EfficiencyReport($staff_id);
  48. $tasks = GrabReadyTasksForAccount($staff_id, $tasktype_id);
  49. // $data = $eff[$tasktype_id];
  50. if (sizeof($tasks) == 0)
  51. echo ' не выполнял';
  52. else {
  53. $data = round(GetAverageTime($tasks)/60.0, 0, PHP_ROUND_HALF_UP);
  54. $minutes = 'минут';
  55. switch (intval($data)) {
  56. case 0:
  57. $data = 'меньше минуты';
  58. $minutes = '';
  59. break;
  60. case 1:
  61. $minutes = 'минуту';
  62. break;
  63. case 2:
  64. case 3:
  65. case 4:
  66. $minutes = 'минуты';
  67. break;
  68. }
  69. echo "<span style='color:green'> в среднем затрачивает $data $minutes </span>";
  70. echo "<input type='button' onclick='ShowAnalytics($staff_id, $tasktype_id)' value='Подробно' style='margin: 2'>";
  71. }
  72. echo "<br><div id='$staff_id"."_"."$tasktype_id' style='display: none; margin-left:20px'>";
  73. foreach ($tasks as $task)
  74. {
  75. $start = $task['accepted_time'];
  76. $finish = $task['finished_time'];
  77. $startdate = date('d.m.Y', strtotime($start));
  78. $starttime = date('H:i', strtotime($start));
  79. $endtime = date('H:i', strtotime($finish));
  80. $time = TimeSpentForTaskFromArray($task);
  81. $minutes = intval(date('i', $time));
  82. $seconds = date('s', $time);
  83. echo "<b>$startdate</b> начал в $starttime, закончил в $endtime, время выполнения: $minutes минут $seconds секунд<br>";
  84. }
  85. echo "<br></div>";
  86. }
  87. echo "</p></div>";
  88. }
  89. }
  90. function ShowSubTasks($id)
  91. {
  92. global $link, $Subtaskarr;
  93. $str = "select subtasks from tasktypes where id=$id";
  94. $query1 = mysqli_query($link, $str);
  95. if ($res1 = mysqli_fetch_row($query1)) {
  96. $arr = explode(",", $res1[0]);
  97. if (sizeof($arr) > 0 && $arr[0] != '') {
  98. echo ' <select name="subtasks">';
  99. $i = 1;
  100. foreach ($arr as $sub) {
  101. if ($sub != '') {
  102. echo '<option value="' . $Subtaskarr[$sub] . '">' . $i . '. [' . $sub . '] ' . $Subtaskarr[$sub]['name'] . '</option>';
  103. $i++;
  104. }
  105. }
  106. echo '</select>';
  107. }
  108. }
  109. }
  110. ?>