lists/list_effortstask.inc.php

00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit;}
00002 # streber - a php based project management system
00003 # Copyright (c) 2005 Thomas Mann - thomas@pixtur.de
00004 # Distributed under the terms and conditions of the GPL as stated in docs/license.txt
00005 
00016 class ListBlock_effortsTask extends ListBlock
00017 {
00018     public $bg_style = "bg_time";
00019     
00020     public function __construct($args=NULL)
00021     {
00022         parent::__construct($args);
00023 
00024         global $PH;
00025         $this->id = 'effortstask';
00026         $this->bg_style = 'bg_time';
00027         $this->no_items_html = __('no efforts booked yet');
00028         $this->title =  __("Efforts on task");
00029         $this->show_icons = true;
00030         $this->add_col( new ListBlockCol_EffortTaskName);
00031         $this->add_col( new ListBlockCol_EffortTaskAmount);
00032         $this->add_col( new ListBlockCol_EffortTaskGraph);
00033 
00034     }
00035     
00036     public function print_automatic()
00037     {
00038         global $PH;
00039         
00040         $effort_status = false;
00041         if($this->query_options['effort_status_min'] == $this->query_options['effort_status_max']){
00042             $effort_status = true;
00043         }
00044         
00045         $efforts = Effort::getEffortTasks($this->query_options);
00046         
00047         foreach($efforts as $e){
00048             $e->setStatus($effort_status);
00049         }
00050         
00051         $this->render_list(&$efforts);
00052     }
00053     
00057     public function render_list(&$efforts=NULL)
00058     {
00059         switch($this->page->format){
00060             case FORMAT_CSV:
00061                 $this->renderListCSV($efforts);
00062                 break;
00063             default:
00064                 $this->renderListHtml($efforts);
00065                 break;
00066         }
00067 
00068     }
00069 
00070     function renderListHtml(&$efforts=NULL)
00071     {
00072         $this->render_header();
00073         if(!$efforts && $this->no_items_html) {
00074             $this->render_tfoot_empty();
00075         }
00076         else {
00077 
00078             $this->render_thead();
00079             
00080             $sum=0.0;
00081             
00082             foreach($efforts as $e) {
00083                 $this->render_trow(&$e);
00084             }
00085             
00086             if($efforts[0]->getStatus()){
00087                 $sum_proj = Effort::getSumEfforts(array('project'=>$efforts[0]->project, 'status'=>$efforts[0]->status));
00088             }
00089             else{
00090                 $sum_proj = Effort::getSumEfforts(array('project'=>$efforts[0]->project));
00091             }
00092             
00093             if($sum_proj){
00094                 $sum += $sum_proj/60/60 * 1.0;
00095             }
00096             
00097             $sum=round($sum,1);
00098             $this->summary= sprintf(__("Total effort sum: %s hours"), $sum);
00099             $this->render_tfoot();
00100         }
00101     }
00102 }
00103 
00104 
00105 class ListBlockCol_EffortTaskName extends ListBlockCol
00106 {
00107     public function __construct($args=NULL) {
00108         parent::__construct($args);
00109         $this->name= __('Task','columnheader');
00110     }
00111     
00112     function render_tr(&$obj, $style=""){
00113         global $PH;
00114         $str="";
00115 
00116         if(isset($obj->task)) {
00117             if($task= Task::getById($obj->task)) {
00118                 $str= $PH->getLink('taskView',$task->name,array('tsk'=>$task->id));
00119             }
00120         }
00121         print "<td><nobr>$str</nobr></td>";
00122     }
00123 }
00124 
00125 class ListBlockCol_EffortTaskAmount extends ListBlockCol
00126 {
00127     public function __construct($args=NULL) {
00128         parent::__construct($args);
00129         $this->name= __('Sum','columnheader');
00130     }
00131     
00132     function render_tr(&$obj, $style="") {
00133             
00134         if(!isset($obj) || !$obj instanceof Effort) {
00135             trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00136             return;
00137         }
00138         
00139         $sum = 0.0;
00140         
00141         if($obj->getStatus()){
00142             $sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
00143         }
00144         else{
00145             $sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task));
00146         }
00147         
00148         if($sum_task)
00149         {
00150             $sum = (round($sum_task/60/60, 1) * 1.0) . " h";
00151         }
00152         
00153         print "<td><nobr>$sum</nobr></td>";
00154     }
00155 }
00156 
00157 class ListBlockCol_EffortTaskGraph extends ListBlockCol
00158 {
00159 
00160     public function __construct($args=NULL) {
00161         parent::__construct($args);
00162         $this->name= __('Effortgraph','columnheader');
00163         $this->width= '40%';
00164     }
00165     
00166     function render_tr(&$obj, $style="") {
00167     
00168         if(!isset($obj) || !$obj instanceof Effort) {
00169             trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00170             return;
00171         }
00172         if($obj->as_duration) {
00173             echo "<td>-</td>";
00174         }
00175         else {
00176             if($obj->getStatus()){
00177                 $sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
00178                 $sum_proj = Effort::getSumEfforts(array('project'=>$obj->project, 'status'=>$obj->status));
00179             }
00180             else{
00181                 $sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task));
00182                 $sum_proj = Effort::getSumEfforts(array('project'=>$obj->project));
00183             }
00184             
00185             if($sum_task && $sum_proj){
00186                 $max_length_value = 3;
00187                 $get_percentage = ($sum_task / $sum_proj) * 100;
00188                 $show_rate = $get_percentage * $max_length_value;
00189                 
00190                 echo "<td>";
00191                 echo "<nobr>";
00192                 echo "<img src='".getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
00193                 echo " " . round($get_percentage,1) . "%";
00194                 echo "</nobr>";
00195                 echo "</td>";
00196             }
00197             else{
00198                  echo "<td>-</td>";
00199             }
00200         }
00201     }
00202 }
00203 ?>

Generated on Sun Mar 4 17:19:30 2007 for streber by  doxygen 1.5.1-p1