| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:53:39 2008 ] | [ PHProjekt 5.0.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 // projects_forms.php - PHProjekt Version 5.0 4 // copyright © 2000-2005 Albrecht Guenther ag@phprojekt.com 5 // www.phprojekt.com 6 // Author: Albrecht Guenther, $Author: fgraf $ 7 // $Id: projects_forms.php,v 1.45.2.3 2005/09/12 12:17:36 fgraf Exp $ 8 9 // check whether the lib has been included - authentication! 10 if (!defined("lib_included")) die("Please use index.php!"); 11 12 // check role 13 if (check_role("projects") < 1) die("You are not allowed to do this!"); 14 $path_pre = '../'; 15 $include_path = $path_pre.'lib/access_form.inc.php'; 16 include_once $include_path; 17 18 if ($justform == 2) { 19 $onload[] = 'window.opener.location.reload();'; 20 $onload[] = 'window.close();'; 21 } 22 else if ($justform > 0) { 23 $justform++; 24 } 25 26 // update project? -> fetch values form record 27 if ($action <> "new" and $ID > 0) { 28 $result = db_query("SELECT ID, name, anfang, ende, chef, contact, stundensatz, budget, wichtung, 29 ziel, note, depend_mode, depend_proj, next_mode, next_proj, probability, 30 ende_real, kategorie, status, statuseintrag, parent, personen, acc, 31 acc_write, von 32 FROM ".DB_PREFIX."projekte 33 WHERE (acc LIKE 'system' 34 OR ((von = '$user_ID' OR acc LIKE 'group' OR acc LIKE '%\"$user_kurz\"%') 35 AND $sql_user_group)) 36 AND ID = '$ID'") or db_die(); 37 $row = db_fetch_row($result); 38 // check access 39 // genreal acces - either the user has direct access to it or the user has chief status 40 if (!$row[0] and !eregi('c', $user_access)) die("You are not privileged to do this!"); 41 42 if (($row[24] <> $user_ID and $row[23] <> 'w') or check_role("projects") < 2) $read_o = 1; 43 44 // get values 45 $project_name = html_out($row[1]); 46 $anfang = $row[2]; 47 $ende = $row[3]; 48 $chef = $row[4]; 49 $contact = $row[5]; 50 $stundensatz = $row[6]; 51 $budget = $row[7]; 52 $wichtung = $row[8]; 53 $ziel = $row[9]; 54 $note = $row[10]; 55 $depend_mode = $row[11]; 56 $depend_proj = $row[12]; 57 $next_mode = $row[13]; 58 $next_proj = $row[14]; 59 $probability = $row[15]; 60 $ende_real = $row[16]; 61 $category = $row[17]; 62 $status = $row[18]; 63 $statuseintrag = $row[19]; 64 $parent = $row[20]; 65 $personen = $row[21]; 66 $acc = $row[22]; 67 $acc_write = $row[23]; 68 } 69 // set variables for a new project: 70 else { 71 // new subproject ... 72 if ($parent) { 73 $row[11] = set_new_subproject($parent); 74 } 75 // ... or a new project at all 76 else { 77 set_new_project(); 78 } 79 } 80 81 if ($ID) $head = slookup('projekte', 'name', 'ID', $ID); 82 else $head = __('New project'); 83 84 // tabs 85 $tabs = array(); 86 $buttons = array(); 87 $hidden = array(); 88 if (SID) $hidden[session_name()] = session_id(); 89 90 // form start 91 $buttons[] = array('type' => 'form_start', 'hidden' => $hidden, 'name' => 'frm', 'onsubmit' => "return chkForm('frm','name','".__('Please insert a name')."') && chkISODate('frm','anfang','".__('Begin').": ".__('ISO-Format: yyyy-mm-dd')."') && chkISODate('frm','ende','".__('End').": ".__('ISO-Format: yyyy-mm-dd')."') && chkNumbers('frm','budget','".__('Calculated budget has a wrong format')."') && chkNumbers('frm','stundensatz','".__('Hourly rate has a wrong format')."');"); 92 $output = get_buttons($buttons); 93 $output .= get_tabs_area($tabs); 94 95 // button bar 96 $buttons = array(); 97 if (!$read_o and check_role("projects") > 1) { 98 if (!$ID) { 99 // create new project 100 $buttons[] = array('type' => 'submit', 'name' => 'create_b', 'value' => __('Accept'), 'active' => false); 101 // hidden 102 $buttons[] = array('type' => 'hidden', 'name' => 'anlegen', 'value' => 'neu_anlegen'); 103 } // modify and delete 104 else { 105 // modify project 106 $buttons[] = array('type' => 'submit', 'name' => 'modify_b', 'value' => __('Accept'), 'active' => false); 107 // hidden 108 $buttons[] = array('type' => 'hidden', 'name' => 'aendern', 'value' => 'aendern'); 109 // check whether there is no subproject beyond this one. 110 // if no and if userid = owner of the project-> allow to delete 111 $result2 = db_query("SELECT ID 112 FROM ".DB_PREFIX."projekte 113 WHERE parent = '$ID'") or db_die(); 114 $row2 = db_fetch_row($result2); 115 if ($row2[0] == '' and $row[24] == $user_ID) { 116 $buttons[] = array('type' => 'submit', 'name' => 'delete_b', 'value' => __('Delete'), 'active' => false, 'onclick' => 'return confirm(\''.__('Are you sure?').'\');'); 117 } 118 } 119 } 120 else if (check_role("projects") > 1 and $user_ID == $chef) { 121 // modify status 122 $buttons[] = array('type' => 'submit', 'name' => 'modify_status_b', 'value' => __('Modify status'), 'active' => false); 123 // hidden 124 $buttons[] = array('type' => 'hidden', 'name' => 'modify_status', 'value' => 'modify_status'); 125 } 126 127 128 129 // new subproject 130 if (!$read_o and check_role("projects") > 1 and $ID > 0) { 131 $buttons[] = array('type' => 'link', 'href' => 'projects.php?parent='.$ID.'&action=new&mode=forms', 'text' => __('New Sub-Project'), 'active' => false); 132 //$output.= "<input type='button' onclick='self.location.href=\"projects.php?parent=$ID&action=new&mode=forms\"' value='".__('New Sub-Project')."' class='button' />"; 133 } 134 // print 135 if ($ID > 0) { 136 $buttons[] = array('type' => 'link', 'href' => $_SERVER['PHP_SELF'].'?mode=view&set_read_flag=1&ID_s='.$ID.$sid, 'text' => __('Mark as read'), 'active' => false); 137 138 // disable print buttons in 5.0 139 //$output.= "<input type='button' onclick='window.open(\"../misc/print.php?ID=$row[0]&module=proj\",\"_blank\")' value='".__('print')."' class='button' />\n"; 140 } 141 // cancel 142 $buttons[] = array('type' => 'link', 'href' => 'projects.php?type='.$type.'&sort='.$sort.'&mode=view&up='.$up.'&filter='.$filter.'&keyword='.$keyword.'&perpage='.$perpage.'&page='.$page, 'text' => __('Cancel'), 'active' => false); 143 $output .= get_buttons_area($buttons); 144 145 $output .= ' 146 <div class="hline"></div> 147 <div class="inner_content"> 148 <a name="content"></a> 149 <br /> 150 '; 151 152 /************************************* 153 Header Box 1 (Basis data) 154 *************************************/ 155 $box_right_data = array(); 156 $box_right_data['type'] = 'anker'; 157 $box_right_data['anker_target'] = 'unten'; 158 $box_right_data['link_text'] = __('Links'); 159 $output .= get_box_header(__('Basis data'), 'oben', $box_right_data); 160 161 $basis_data = " 162 <div class='formbody'> 163 <fieldset style='margin:0;'> 164 <legend></legend> 165 "; 166 // calculate hidden fields 167 $hidden = array_merge(array('ID'=>$ID, 'type'=>$type, 'mode'=>'data', 'gruppe'=>'user_group', 'justform'=>$justform, 'project_name'=>$project_name), $view_param); 168 // add hidden fields 169 $basis_data .= hidden_fields($hidden); 170 // fields html 171 $basis_data .= build_form($fields); 172 // project to a subproject 173 $basis_data .= ' 174 </div></fieldset> 175 </div> 176 '; 177 178 $output .= ' 179 <div class="boxContent">'.$basis_data.'</div> 180 <br style="clear:both" /> 181 '; 182 183 184 /************************************* 185 Header Box 2 (Categorization) 186 *************************************/ 187 $box_right_data = array(); 188 $box_right_data['type'] = 'anker'; 189 $box_right_data['anker_target'] = 'oben'; 190 $box_right_data['link_text'] = __('Basis data'); 191 $output .= '<br style="clear:both" />'; 192 $output .= get_box_header(__('Categorization'), 'unten', $box_right_data); 193 194 $categorization = ' 195 <div class="formbody"> 196 <fieldset> 197 <legend></legend> 198 <br /> 199 <label for="parent" class="center2">'.__('Sub-Project of').':</label> 200 <select class="projectCat" id="parent" name="parent"'.read_o($read_o).'> 201 <option value="0"></option> 202 '; 203 204 // prepare query for function 205 $query = "WHERE $sql_user_group"; 206 // call function to show all required elements in a tree structure in the select box 207 $categorization .= show_elements_of_tree('projekte', 'name', 208 "WHERE (acc LIKE 'system' OR ((von = ".$user_ID." OR acc LIKE 'group' OR acc LIKE '%\"$user_kurz\"%') AND $sql_user_group))", 209 'acc', " ORDER BY name", $parent, 'parent', $ID); 210 $categorization .= "</select><br />\n"; 211 212 $read_o_status = $user_ID == $chef ? 0 : 1; 213 $categorization .= "<label for='parent' class='center2'>".__('Status')." [%]:</label>\n"; 214 $categorization .= "<input name='status' value='$status' type='text' class='form smallinput' ".read_o($read_o_status, 'readonly')."/>\n"; 215 $categorization .= '<br style="clear:both" /><br />'."\n"; 216 217 218 // next record in list 219 if ($ID > 0) { 220 // check where there are any other projects on this level 221 $result2 = db_query("SELECT COUNT(ID) 222 FROM ".DB_PREFIX."projekte 223 WHERE parent = '$parent' 224 AND ID <> '$ID'") or db_die(); 225 $row2 = db_fetch_row($result2); 226 // first display the possible modes 227 if ($row2[0] > 0) { 228 $categorization .= "<label for='next_mode' class='center2'>".__('List').":</label>\n"; 229 $categorization .= "<select class='projectCat' name=next_mode".read_o($read_o).">\n<option value='0'></option>\n"; 230 foreach ($next_mode_arr as $next1 => $next2) { 231 $categorization .= "<option value='$next1'"; 232 if ($next1 == $next_mode) $categorization .= ' selected="selected"'; 233 $categorization .= ">$next2:</option>\n"; 234 } 235 $categorization .= "</select>\n"; 236 // fetch all of these neighbours and display them 237 $categorization .= "<label for='next_mode' class='center2'>".__('Next Project').":</label>\n"; 238 $categorization .= "<select class='projectCat' name='next_proj'".read_o($read_o)."><option value='0'></option>\n"; 239 $result2 = db_query("SELECT ID, name 240 FROM ".DB_PREFIX."projekte 241 WHERE parent = '$parent' 242 AND $sql_user_group 243 AND ID <> '$ID' 244 ORDER BY name") or db_die(); 245 while ($row2 = db_fetch_row($result2)) { 246 $categorization .= "<option value='$row2[0]'"; 247 if ($row2[0] == $next_proj) $categorization .= ' selected="selected"'; 248 $categorization .= ">$row2[1]</option>\n"; 249 } 250 $categorization .= "</select><br />\n"; 251 // dependency 252 $categorization .= "<label for='depend_mode' class='center2'>".__('Dependency').":</label>\n"; 253 $categorization .= "<select class='projectCat' name='depend_mode'".read_o($read_o)."><option value='0'>\n"; 254 foreach ($dependencies as $dep1 => $dep2) { 255 $categorization .= "<option value='$dep1'"; 256 if ($dep1 == $depend_mode) $categorization .= ' selected="selected"'; 257 $categorization .= ">$dep2:</option>\n"; 258 } 259 $categorization .= "</select>\n"; 260 // fetch all of these neighbours and display them 261 $categorization .= "<label for='depend_mode' class='center2'>".__('Dependend projects').":</label>\n"; 262 $categorization .= "<select class='projectCat' name='depend_proj'".read_o($read_o)."><option value='0'>\n"; 263 $result2 = db_query("SELECT ID, name 264 FROM ".DB_PREFIX."projekte 265 WHERE parent = '$parent' 266 AND $sql_user_group 267 AND ID <> '$ID' 268 ORDER BY name") or db_die(); 269 while ($row2 = db_fetch_row($result2)) { 270 $categorization .= "<option value='$row2[0]'"; 271 if ($row2[0] == $depend_proj) $categorization .= ' selected="selected"'; 272 $categorization .= ">$row2[1]</option>\n"; 273 } 274 $categorization .= "</select>\n"; 275 $categorization .= "</td></tr>\n"; 276 } 277 // otherwise set the dependency to 0 to avoid that this project has an 'old' dependency 278 else { 279 $output.= "<input type='hidden' name='dependency' value='0' />\n"; 280 } 281 } 282 $categorization .= "</fieldset>\n</div>\n"; 283 284 285 $output .= ' 286 <div class="boxContent">'.$categorization.'</div> 287 <br style="clear:both"/> 288 '; 289 290 291 /* 292 // show already booked work time 293 if (PHPR_PROJECTS > 1) { 294 $result2 = db_query("select h,m 295 from ".DB_PREFIX."timeproj 296 where projekt = '$ID'") or db_die(); 297 while ($row2 = db_fetch_row($result2)) { 298 $sum1 = $sum1 + $row2[0]*60+$row2[1]; 299 } 300 $h = floor($sum1/60); 301 $m = $sum1 - $h*60; 302 $amount = number_format($row[16] * $sum1/60); 303 if ($amount > 0) { 304 $output.= "<tr><td>$proj_text16: </td><td>".PHPR_CUR_SYMBOL.":$amount - h:$h/m:$m </td></tr>\n"; 305 } 306 } 307 */ 308 309 /************************************************** 310 Header Box 3 (Assignment of Participants) 311 **************************************************/ 312 $box_right_data = array(); 313 $box_right_data['type'] = 'anker'; 314 $box_right_data['anker_target'] = 'oben'; 315 $box_right_data['link_text'] = __('Basis data'); 316 $output .= '<br style="clear:both"/>'; 317 $acc_read = slookup('projekte', 'personen', 'ID', $ID); 318 $assignment = ' 319 <div class="formbody" style="margin-top:2px;"> 320 <fieldset style="border:1px solid black;width:400px;padding:10px;"> 321 <legend>'.__('Participants').'</legend> 322 <select size="7" name="personen[]" multiple="multiple"'.read_o($read_o).'>'.show_group_users($user_group, false, $acc_read, true).'</select> 323 </fieldset> 324 </div> 325 '; 326 327 // access 328 // select participants 329 $access_form = '<div class="formbody" style="margin-top:2px;">'; 330 // acc_read, exclude the user itself, acc_write, no parent possible, write access=yes 331 $access_form .= access_form2($row[22], 1, $row[23], 0, 1).'</div>'; 332 333 $output .= ' 334 <div class="boxHeaderSmallLeft">'.__('Assignment').'</div> 335 <div class="boxHeaderSmallRight">'.__('Participants').'</div> 336 <div class="boxContentSmallLeft" style="height:170px">'.$access_form.'</div> 337 <div class="boxContentSmallRight" style="height:170px">'.$assignment.'</div> 338 <br style="clear:both" /><br /> 339 340 341 '; 342 343 /************************************************** 344 Buttons 345 **************************************************/ 346 347 348 /* 349 $output .= ' 350 <div class="buttons" style="margin-top:5px;"> 351 <span class="co1">'.$head.'</span> 352 <span class="col3"> 353 <form style="display:inline;" action="forum.php" name="forumneu" method="post"> 354 '; 355 356 if (!$read_o and check_role("projects") > 1){ 357 if (!$ID) { 358 $output .= "<input type='submit' name='create_b' value='".__('Create')."' class='button' />\n"; 359 $output .= "<input type='hidden' name='anlegen' value='neu_anlegen' />\n"; 360 } // modify and delete 361 else { 362 $output .= "<td><input type='submit' name='modify_b' value='".__('Modify')."' class='button' /></td>\n"; 363 // change values 364 $output .= "<input type='hidden' value='aendern' class='button' />\n"; 365 // check whether there is no subproject beyond this one. if no -> allow to delete 366 $result2 = db_query("SELECT ID 367 FROM ".DB_PREFIX."projekte 368 WHERE parent = '$ID'") or db_die(); 369 $row2 = db_fetch_row($result2); 370 if ($row2[0] == '') $output .= "<input type='submit' name='delete_b' value='".__('Delete')."' onclick=\"return confirm('".__('Are you sure?')."');\" class='button' />\n"; 371 } 372 } // end buttons chief only 373 // new subproject 374 if (!$read_o and check_role("projects") > 1 and $ID > 0) { 375 $output .= "<input type='button' onclick='self.location.href=\"projects.php?parent=$ID&action=new&mode=forms\";' value='".__('New Sub-Project')."' class='button' />"; 376 } 377 // print 378 if ($ID > 0) { 379 // disable print buttons in 5.0 380 //$output .= "<input type='button' 'window.open(\"../misc/print.php?ID=$row[0]&module=proj\",\"_blank\")' value='".__('print')."' class='button' />\n"; 381 } 382 // cancel 383 $ure = "projects.php?type=$type&sort=$sort&mode=view&up=$up&filter=$filter&keyword=$keyword&perpage=$perpage&page=$page"; 384 $output .= "<input type='button' onclick='self.location.href=\" $ure\";' value='".__('back')."' class='button' /></a>\n"; 385 $output .= '</span></div></form>'; 386 */ 387 388 // button bar 389 $buttons = array(); 390 if (!$read_o and check_role("projects") > 1) { 391 if (!$ID) { 392 // create new project 393 $buttons[] = array('type' => 'submit', 'name' => 'create_b', 'value' => __('Accept'), 'active' => false); 394 } // modify and delete 395 else { 396 // modify project 397 $buttons[] = array('type' => 'submit', 'name' => 'modify_b', 'value' => __('Accept'), 'active' => false); 398 // check whether there is no subproject beyond this one. if no -> allow to delete 399 $result2 = db_query("SELECT ID 400 FROM ".DB_PREFIX."projekte 401 WHERE parent='$ID'") or db_die(); 402 $row2 = db_fetch_row($result2); 403 if ($row2[0] == '') { 404 $buttons[] = array('type' => 'submit', 'name' => 'delete_b', 'value' => __('Delete'), 'active' => false, 'onclick' => 'return confirm(\''.__('Are you sure?').'\');'); 405 } 406 } 407 } 408 else if (check_role("projects") > 1 and $user_ID == $chef) { 409 // modify status 410 $buttons[] = array('type' => 'submit', 'name' => 'modify_status_b', 'value' => __('Modify status'), 'active' => false); 411 } 412 413 414 415 // new subproject 416 if (!$read_o and check_role("projects") > 1 and $ID > 0) { 417 $buttons[] = array('type' => 'link', 'href' => 'projects.php?parent='.$ID.'&action=new&mode=forms', 'text' => __('New Sub-Project'), 'active' => false); 418 //$output.= "<input type='button' onclick='self.location.href=\"projects.php?parent=$ID&action=new&mode=forms\"' value='".__('New Sub-Project')."' class='button' />"; 419 } 420 // print 421 if ($ID > 0) { 422 $buttons[] = array('type' => 'link', 'href' => $_SERVER['PHP_SELF'].'?mode=view&set_read_flag=1&ID_s='.$ID.$sid, 'text' => __('Mark as read'), 'active' => false); 423 424 /* disable print buttons in 5.0 425 $output.= "<input type='button' onclick='window.open(\"../misc/print.php?ID=$row[0]&module=proj\",\"_blank\")' value='".__('print')."' class='button' />\n"; 426 */ 427 } 428 // cancel 429 $buttons[] = array('type' => 'link', 'href' => 'projects.php?type='.$type.'&sort='.$sort.'&mode=view&up='.$up.'&filter='.$filter.'&keyword='.$keyword.'&perpage='.$perpage.'&page='.$page, 'text' => __('Cancel'), 'active' => false); 430 $output .= get_buttons_area($buttons); 431 $output .= '</div> 432 </form> 433 <div class="hline"></div> 434 '; 435 436 437 /* 438 // preselect selector data 439 $participants = unserialize($personen); 440 $accessors = unserialize($acc); 441 settype($participants, "array"); 442 settype($accessors, "array"); 443 $output .= ' 444 <script type="text/javascript"> 445 <!-- 446 participants = new Array("'.implode('","', $participants).'"); 447 preselect_options(participants, "perfound1[]", "personen[]"); 448 accessors = new Array("'.implode('","', $accessors).'"); 449 preselect_options(accessors, "perfound[]", "persons[]"); 450 //--> 451 </script> 452 '; 453 */ 454 455 456 /************************************************** 457 related objects 458 **************************************************/ 459 if ($ID > 0) { 460 $output .= "<br />\n"; 461 $projekt_ID = $ID; 462 // include the lib 463 include_once($lib_path."/show_related.inc.php"); 464 $referer = "projects.php?mode=forms&ID=$ID"; 465 // show related todos 466 if (PHPR_TODO and check_role("todo") > 0) { 467 $query = "project='$ID'"; 468 $output .= show_related_todo($query, $referer); 469 $output .= "<br />\n"; 470 } 471 472 // related notes, show only for existing projects 473 if (PHPR_NOTES and check_role("notes") > 0) { 474 $module = "projects"; 475 $query = "projekt='$ID'"; 476 $output .= show_related_notes($query, $referer); 477 $output .= "<br />\n"; 478 } 479 480 // show related files 481 if (PHPR_FILEMANAGER and check_role("filemanager") > 0) { 482 $module = "projects"; 483 $query = "div2='$ID'"; 484 $output .= show_related_files($query, $referer); 485 $output .= "<br />\n"; 486 } 487 488 // show related events 489 if (PHPR_CALENDAR and check_role("calendar") > 0) { 490 $module = "projects"; 491 $query = "projekt='$ID'"; 492 $output .= show_related_events($query, $referer); 493 $output .= "<br />\n"; 494 } 495 // show history 496 if (PHPR_HISTORY_LOG) $output .= history_show('projekte', $ID); 497 } 498 // end show related objects 499 // ************************ 500 501 // close big div 502 //$output .= '</div>'; 503 echo $output; 504 505 // end of big form :-) 506 507 508 // set variables for a new subproject 509 function set_new_subproject($parent) { 510 global $ID, $row, $anfang, $ende; 511 512 $result = db_query("SELECT ID, name, anfang, ende 513 FROM ".DB_PREFIX."projekte 514 WHERE ID='$parent'") or db_die(); 515 $row = db_fetch_row($result); 516 // delete ID, because it's a new project 517 $row[0] = $ID = 0; 518 $row[1] = ''; 519 $anfang = $row[2]; 520 $ende = $row[3]; 521 return $parent; 522 } 523 524 // set variables for a new root project 525 function set_new_project() { 526 global $ID, $anfang, $ende, $row; 527 528 $ID = $row[0] = 0; 529 $anfang = date("Y")."-".date("m")."-".date("d"); 530 $ende = date("Y")."-12-31"; 531 $row[16] = 0; // stundensatz / hourly rate 532 $row[17] = 0; // budget 533 } 534 535 ?>