コード例 #1
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $diff_str = '';
     $estimated_str = '';
     $str = '';
     $percent = '';
     /*if($obj->getStatus()){
     			$sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
     		}
     		else{*/
     $sum_task = Effort::getSumEfforts(array('project' => $obj->project, 'task' => $obj->task));
     #}
     if ($sum_task) {
         $sum = $sum_task;
     }
     if ($task = Task::getVisibleById($obj->task)) {
         $estimated = $task->estimated;
         $estimated_max = $task->estimated_max;
         if ($estimated_max) {
             $estimated_str = round($estimated_max / 60 / 60, 1) . "h";
             $diff = $estimated_max - $sum;
         } else {
             $estimated_str = round($estimated / 60 / 60, 1) . "h";
             $diff = $estimated - $sum;
         }
         if ($diff) {
             $diff_str = "(" . round($diff / 60 / 60, 1) . "h)";
         }
         $str = $estimated_str . " / " . round($sum / 60 / 60, 1) . "h {$diff_str}";
         $percent = __('Completion:') . " " . $task->completion . "%";
     }
     print "<td class=nowrap title='" . __("Relation between estimated time and booked efforts") . "'>{$str}<br><span class='sub who'>{$percent}</span></td>";
 }
コード例 #2
0
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Project) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $sum_sal = 0.0;
     $sum_all = 0.0;
     $sum_cal = 0.0;
     $diff_value = false;
     if ($effort_people = Effort::getEffortPeople(array('project' => $obj->id))) {
         foreach ($effort_people as $ep) {
             if ($person = Person::getVisibleById($ep->person)) {
                 /*if($obj->getStatus()){
                 			$sum_sal = Effort::getSumEfforts(array('project'=>$obj->id, 'person'=>$person->id, 'status'=>$obj->status));
                 		}
                 		else{*/
                 $sum_sal = Effort::getSumEfforts(array('project' => $obj->id, 'person' => $person->id));
                 #}
                 if ($sum_sal) {
                     $sum = round($sum_sal / 60 / 60, 1) * 1.0;
                     if ($pp = $obj->getProjectPeople(array('person_id' => $person->id))) {
                         if ($pp[0]->salary_per_hour) {
                             $sum_all = $sum * $pp[0]->salary_per_hour;
                         } else {
                             $sum_all = $sum * $person->salary_per_hour;
                         }
                     } else {
                         $sum_all = $sum * $person->salary_per_hour;
                     }
                     //$sum_all += ($sum * $person->salary_per_hour);
                 }
             }
         }
     }
     if ($effort_tasks = Effort::getEffortTasks(array('project' => $obj->id))) {
         foreach ($effort_tasks as $et) {
             if ($task = Task::getById($et->task)) {
                 if ($task->calculation) {
                     $sum_cal += $task->calculation;
                 }
             }
         }
     }
     if ($sum_all && $sum_cal) {
         $max_length_value = 3;
         $get_percentage = $sum_all / $sum_cal * 100;
         if ($get_percentage > 100) {
             $diff = $get_percentage - 100;
             $get_percentage = 100;
             $diff_value = true;
         }
         $show_rate = $get_percentage * $max_length_value;
         echo "<td>";
         echo "<nobr>";
         echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
         if ($diff_value) {
             $show_rate = $diff * $max_length_value;
             echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#ff9900;'>";
             echo " " . round($get_percentage, 1) . "% / " . round($diff, 1) . " %";
         } else {
             echo " " . round($get_percentage, 1) . "%";
         }
         echo "</nobr>";
         echo "</td>";
     } else {
         echo "<td>-</td>";
     }
 }
コード例 #3
0
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     if ($obj->as_duration) {
         echo "<td>-</td>";
     } else {
         /*if($obj->getStatus()){
         			$sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
         			$sum_proj = Effort::getSumEfforts(array('project'=>$obj->project, 'status'=>$obj->status));
         		}
         		else{*/
         $sum_task = Effort::getSumEfforts(array('project' => $obj->project, 'task' => $obj->task));
         $sum_proj = Effort::getSumEfforts(array('project' => $obj->project));
         #}
         if ($sum_task && $sum_proj) {
             $max_length_value = 3;
             $get_percentage = $sum_task / $sum_proj * 100;
             $show_rate = $get_percentage * $max_length_value;
             echo "<td>";
             echo "<nobr>";
             echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
             echo " " . round($get_percentage, 1) . "%";
             echo "</nobr>";
             echo "</td>";
         } else {
             echo "<td>-</td>";
         }
     }
 }