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_effortsPerson 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 = 'effortsperson';
00026 $this->bg_style = 'bg_time';
00027 $this->no_items_html = __('no efforts booked yet');
00028 $this->title = __("Efforts on team member");
00029 $this->show_icons = true;
00030
00031 $this->add_col(new ListBlockColMethod(array(
00032 'key'=>'person',
00033 'name'=>__('person'),
00034 'func'=>'getPersonLink'
00035 )));
00036 $this->add_col( new ListBlockCol_EffortPersonRole);
00037 $this->add_col( new ListBlockCol_EffortPersonAmount);
00038 $this->add_col( new ListBlockCol_EffortGraph);
00039
00040 }
00041
00042 public function print_automatic()
00043 {
00044 global $PH;
00045
00046 $effort_status = false;
00047 if($this->query_options['effort_status_min'] == $this->query_options['effort_status_max']){
00048 $effort_status = true;
00049 }
00050
00051 $efforts = Effort::getEffortPersons($this->query_options);
00052
00053 foreach($efforts as $e){
00054 $e->setStatus($effort_status);
00055 }
00056
00057 $this->render_list(&$efforts);
00058 }
00059
00063 public function render_list(&$efforts=NULL)
00064 {
00065 switch($this->page->format){
00066 case FORMAT_CSV:
00067 $this->renderListCSV($efforts);
00068 break;
00069 default:
00070 $this->renderListHtml($efforts);
00071 break;
00072 }
00073
00074 }
00075
00076 function renderListHtml(&$efforts=NULL)
00077 {
00078 $this->render_header();
00079 if(!$efforts && $this->no_items_html) {
00080 $this->render_tfoot_empty();
00081 }
00082 else {
00083
00084 $this->render_thead();
00085
00086 $sum=0.0;
00087
00088 foreach($efforts as $e) {
00089 $this->render_trow(&$e);
00090 }
00091
00092 if($efforts[0]->getStatus()){
00093 $sum_proj = Effort::getSumEfforts(array('project'=>$efforts[0]->project, 'status'=>$efforts[0]->status));
00094 }
00095 else{
00096 $sum_proj = Effort::getSumEfforts(array('project'=>$efforts[0]->project));
00097 }
00098
00099 if($sum_proj)
00100 {
00101 $sum += $sum_proj/60/60 * 1.0;
00102 }
00103
00104 $sum=round($sum,1);
00105 $this->summary= sprintf(__("Total effort sum: %s hours"), $sum);
00106 $this->render_tfoot();
00107 }
00108 }
00109 }
00110
00111 class ListBlockCol_EffortPersonRole extends ListBlockCol
00112 {
00113 public function __construct($args=NULL) {
00114 parent::__construct($args);
00115 $this->name= __('Role','columnheader');
00116 }
00117
00118 function render_tr(&$obj, $style="") {
00119
00120 global $g_user_profile_names;
00121
00122 if(!isset($obj) || !$obj instanceof Effort) {
00123 trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00124 return;
00125 }
00126
00127 if($project = Project::getVisibleById($obj->project)){
00128 if($pp = $project->getProjectPersons(array('person_id'=>$obj->person))){
00129 $role = $g_user_profile_names[intval($pp[0]->role)];
00130 }
00131 else{
00132 $role = '';
00133 }
00134
00135 }
00136 else{
00137 $role = '';
00138 }
00139
00140 print "<td><nobr>$role</nobr></td>";
00141 }
00142 }
00143
00144 class ListBlockCol_EffortPersonAmount extends ListBlockCol
00145 {
00146 public function __construct($args=NULL) {
00147 parent::__construct($args);
00148 $this->name= __('Sum','columnheader');
00149 }
00150
00151 function render_tr(&$obj, $style="") {
00152
00153 if(!isset($obj) || !$obj instanceof Effort) {
00154 trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00155 return;
00156 }
00157
00158 $sum = 0.0;
00159
00160 if($obj->getStatus()){
00161 $sum_eff = Effort::getSumEfforts(array('project'=>$obj->project, 'person'=>$obj->person, 'status'=>$obj->status));
00162 }
00163 else{
00164 $sum_eff = Effort::getSumEfforts(array('project'=>$obj->project, 'person'=>$obj->person));
00165 }
00166
00167 if($sum_eff)
00168 {
00169 $sum = (round($sum_eff/60/60, 1) * 1.0) . " h";
00170 }
00171
00172 print "<td><nobr>$sum</nobr></td>";
00173 }
00174 }
00175
00176 class ListBlockCol_EffortGraph extends ListBlockCol
00177 {
00178
00179 public function __construct($args=NULL) {
00180 parent::__construct($args);
00181 $this->name= __('Effortgraph','columnheader');
00182 $this->width= '40%';
00183 }
00184
00185 function render_tr(&$obj, $style="") {
00186
00187 if(!isset($obj) || !$obj instanceof Effort) {
00188 trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00189 return;
00190 }
00191 if($obj->as_duration) {
00192 echo "<td>-</td>";
00193 }
00194 else {
00195
00196 if($obj->getStatus()){
00197 $sum_eff = Effort::getSumEfforts(array('project'=>$obj->project, 'person'=>$obj->person, 'status'=>$obj->status));
00198 $sum_proj = Effort::getSumEfforts(array('project'=>$obj->project, 'status'=>$obj->status));
00199 }
00200 else{
00201 $sum_eff = Effort::getSumEfforts(array('project'=>$obj->project, 'person'=>$obj->person));
00202 $sum_proj = Effort::getSumEfforts(array('project'=>$obj->project));
00203 }
00204
00205 if($sum_eff && $sum_proj){
00206 $max_length_value = 3;
00207 $get_percentage = ($sum_eff / $sum_proj) * 100;
00208 $show_rate = $get_percentage * $max_length_value;
00209
00210 echo "<td>";
00211 echo "<nobr>";
00212 echo "<img src='".getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
00213 echo " " . round($get_percentage,1) . "%";
00214 echo "</nobr>";
00215 echo "</td>";
00216 }
00217 else{
00218 echo "<td>-</td>";
00219 }
00220 }
00221 }
00222 }
00223 ?>