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
00006
00007
00008 class ListGroupingCompany extends ListGrouping {
00009
00010 public function __construct($args=NULL) {
00011 $this->id = 'company';
00012 parent::__construct($args);
00013 }
00014
00018 public function render(&$item)
00019 {
00020 require_once "db/class_company.inc.php";
00021 if(isset($item->company)) {
00022 if($c= Company::getVisibleById($item->company)) {
00023 return $c->getLink();
00024 }
00025 else {
00026 return __("Company");
00027 }
00028
00029 }
00030 else {
00031 trigger_error("can't group for company",E_USER_NOTICE);
00032 return "---";
00033 }
00034 }
00035 }
00036
00037
00038
00049 class ListBlock_projects extends ListBlock
00050 {
00051
00052 public function __construct($args=NULL)
00053 {
00054 parent::__construct($args);
00055
00056 $this->id = 'projects';
00057 $this->bg_style = 'bg_projects';
00058 $this->title = "related Projects";
00059
00060 $this->add_col( new ListBlockColSelect());
00061 $this->add_col( new ListBlockColPrio(array(
00062 'key'=>'prio',
00063 'name'=>"P",
00064 'tooltip'=>__("Project priority (the icons have tooltips, too)"),
00065 'sort'=>1,
00066 )));
00067 $this->add_col( new ListBlockColStatus(array(
00068 'key'=>'status',
00069 'name'=>"S",
00070 'tooltip'=>__("Task-Status"),
00071 'sort'=>0
00072 )));
00073 $this->add_col( new ListBlockColMethod(array(
00074 'id' =>'company',
00075 'key'=>'c.name',
00076 'name'=>__("Company"),
00077 'tooltip'=>__("Company"),
00078 'func'=>'getCompanyLink',
00079 )));
00080
00081
00082
00083
00084
00085
00086
00087
00088 $this->add_col( new ListBlockCol_ProjectName);
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 $this->add_col( new ListBlockColFormat(array(
00101 'key'=>'status_summary',
00102 'name'=>__("Status Summary"),
00103 'tooltip'=>__("Short discription of the current status"),
00104 'format'=>'{?status_summary}'
00105 )));
00106
00107 $this->add_col( new ListBlockCol_ProjectPersons);
00108
00109 $this->add_col( new ListBlockCol_ProjectEffortSum);
00110
00111 $this->add_col( new ListBlockColMethod(array(
00112 'name'=>__("Tasks"),
00113 'tooltip'=>__("Number of open Tasks"),
00114 'sort'=>0,
00115 'func'=>'getNumTasks',
00116 'style' =>'right',
00117 'id' =>'tasks',
00118 )));
00119 $this->add_col( new ListBlockColDate(array(
00120 'key'=>'date_start',
00121 'name'=>__("Opened"),
00122 'tooltip'=>__("Day the Project opened"),
00123 'sort'=>0,
00124 )));
00125 $this->add_col( new ListBlockColDate(array(
00126 'key'=>'date_closed',
00127 'name'=>__("Closed"),
00128 'tooltip'=>__("Day the Project state changed to closed"),
00129 'sort'=>0,
00130 )));
00131
00132 #---- functions ------------------------
00133 global $PH;
00134
00135 $this->add_function(new ListFunction(array(
00136 'target'=>$PH->getPage('projEdit')->id,
00137 'name' =>__('Edit project'),
00138 'id' =>'projEdit',
00139 'icon' =>'edit',
00140 'context_menu'=>'submit',
00141 )));
00142 $this->add_function(new ListFunction(array(
00143 'target'=>$PH->getPage('projDelete')->id,
00144 'name' =>__('Delete project'),
00145 'id' =>'projDelete',
00146 'icon' =>'delete'
00147 )));
00148
00149 $this->add_function(new ListFunction(array(
00150 'target'=>$PH->getPage('effortNew')->id,
00151 'name' =>__('Log hours for a project'),
00152 'id' =>'effortNew',
00153 'context_menu'=>'submit',
00154 'icon' =>'loghours',
00155 )));
00156
00157 $this->add_function(new ListFunction(array(
00158 'target'=>$PH->getPage('projChangeStatus')->id,
00159 'name' =>__('Open / Close'),
00160 'id' =>'projOpenClose',
00161 'context_menu'=>'submit',
00162 )));
00163
00164 $this->add_function(new ListFunction(array(
00165 'target'=>$PH->getPage('projNew')->id,
00166 'name' =>__('Create new project'),
00167 'id' =>'projNew',
00168 'icon' =>'new',
00169 'context_menu'=>'submit',
00170 )));
00171
00172 $this->add_function(new ListFunction(array(
00173 'target'=>$PH->getPage('projCreateTemplate')->id,
00174 'name' =>__('Create Template'),
00175 'id' =>'projCreateTemplate',
00176 'dropdown_menu'=>true,
00177 'context_menu'=>'submit',
00178
00179 )));
00180 $this->add_function(new ListFunction(array(
00181 'target'=>$PH->getPage('projNewFromTemplate')->id,
00182 'name' =>__('Project from Template'),
00183 'id' =>'projNewFromTemplate',
00184 'dropdown_menu'=>true,
00185
00186 )));
00187 $this->add_function(new ListFunction(array(
00188 'target'=>$PH->getPage('itemsAsBookmark')->id,
00189 'name' =>__('Mark as bookmark'),
00190 'id' =>'itemsAsBookmark',
00191 'context_menu'=>'submit',
00192 )));
00193
00194 ### block style functions ###
00195 $this->add_blockFunction(new BlockFunction(array(
00196 'target'=>'changeBlockStyle',
00197 'key'=>'list',
00198 'name'=>'List',
00199 'params'=>array(
00200 'style'=>'list',
00201 'block_id'=>$this->id,
00202 'page_id'=>$PH->cur_page->id,
00203 # 'use_collapsed'=>true, @@@ this parameter seems useless
00204 ),
00205 'default'=>true,
00206 )));
00207 $this->groupings= new BlockFunction_grouping(array(
00208 'target'=>'changeBlockStyle',
00209 'key'=>'grouped',
00210 'name'=>'Grouped',
00211 'params'=>array(
00212 'style'=>'grouped',
00213 'block_id'=>$this->id,
00214 'page_id'=>$PH->cur_page->id,
00215 ),
00216 ));
00217
00218 $this->add_blockFunction($this->groupings);
00219
00220
00221 ### list groupings ###
00222
00223 $this->groupings->groupings= array(
00224 new ListGroupingStatus(),
00225 new ListGroupingPrio(),
00226 new ListGroupingCompany(),
00227 );
00228 }
00229
00230
00240 public function print_automatic()
00241 {
00242 global $PH;
00243
00244 if(!$this->active_block_function=$this->getBlockStyleFromCookie()) {
00245 $this->active_block_function = 'list';
00246 }
00247
00248 $this->group_by= get("blockstyle_{$PH->cur_page->id}_{$this->id}_grouping");
00249
00250 $this->initOrderQueryOption();
00251
00252 ### add filter options ###
00253 #foreach($this->filters as $f) {
00254 # foreach($f->getQuerryAttributes() as $k=>$v) {
00255 # $this->query_options[$k]= $v;
00256 # }
00257 #}
00258
00259 ### grouped view ###
00260 if($this->active_block_function == 'grouped') {
00261
00267 if(isset($this->columns[ $this->group_by ])) {
00268 unset($this->columns[$this->group_by]);
00269 }
00270
00271 ### prepend key to sorting ###
00272 if(isset($this->query_options['order_by'])) {
00273 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie() . ",".$this->query_options['order_by'];
00274
00275 }
00276 else {
00277 $this->query_options['order_by'] = $this->groupings->getActiveFromCookie();
00278 }
00279
00280
00281 }
00282 ### list view ###
00283 else {
00284 $pass= true;
00285
00286 }
00287
00288 $projects= Project::getAll($this->query_options);
00289
00290
00291 $this->render_list(&$projects);
00292 }
00293 }
00294
00295
00300 class ListBlockCol_ProjectPersons extends ListBlockCol
00301 {
00302 public $name;
00303 public $tooltip;
00304 public $id='persons';
00305 public $width="70%";
00306
00307 public function __construct($args=NULL) {
00308 parent::__construct($args);
00309 $this->name =__('People');
00310 $this->tooltip =__("... working in project");
00311 }
00312
00313
00314 function render_tr(&$project, $style="")
00315 {
00316 global $PH;
00317
00318 print "<td>";
00319 if($pps= $project->getProjectPersons()) {
00320
00321 $str_delimiter="";
00322 foreach($pps as $pp){
00323 ### ###
00324 if( $person= Person::getVisibleById($pp->person)) {
00325 $link= $PH->getLink('personView',$person->getShort(),array('person'=>$person->id));
00326 print $str_delimiter . $link;
00327
00328 $str_delimiter=", ";
00329 }
00330
00331 }
00332 }
00333 print "</td>";
00334
00335 }
00336 }
00337
00338
00339
00340
00341 class ListBlockCol_ProjectName extends ListBlockCol
00342 {
00343 public $id='name';
00344
00345 function __construct($args= NULL)
00346 {
00347 parent::__construct($args);
00348 if(!$this->name) {
00349 $this->name= __('Project', 'column header');
00350 }
00351 }
00352
00353 function render_tr(&$project, $style="")
00354 {
00355 global $PH;
00356 print "<td><b><nobr>". $PH->getLink('projView',asHtml($project->name), array('prj' => $project->id)) ."</b></nobr></td>";
00357 }
00358 }
00359
00360
00361
00362 class ListBlockCol_ProjectEffortSum extends ListBlockCol{
00363 public $name='Efforts';
00364 public $tooltip="Not cleared project efforts in hours";
00365 public $id='efforts';
00366
00367 public function __construct($args=NULL) {
00368 parent::__construct($args);
00369 }
00370 function render_tr(&$project, $style="") {
00371
00372 if(!isset($project) || !$project instanceof Project) {
00373 trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
00374 return;
00375 }
00376
00377 $value= round($project->getEffortsSum()/60/60,1);
00378 if($value) {
00379 print "<td>{$value}h</td>";
00380 }
00381 else {
00382 print "<td></td>";
00383 }
00384 }
00385 }
00386
00387
00388
00389 ?>