| [ 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_data.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_data.php,v 1.27.2.3 2005/09/12 13:58:27 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") < 2) die("You are not allowed to do this!"); 14 15 include_once("$lib_path/permission.inc.php"); 16 $include_path3 = $path_pre."lib/access.inc.php"; 17 include_once $include_path3; 18 include_once ("err_pro.php"); 19 $acc = assign_acc($acc, 'projekte'); 20 if ($acc_write <> '') $acc_write = 'w'; 21 if ($parent == '') $parent = 0; 22 23 switch (true) { 24 25 case ($delete_file <> '') : 26 delete_attached_file($file_field_name, $ID, 'projects'); 27 break; 28 29 // ************** 30 // delete project 31 case ($delete_b <> ''): 32 manage_delete_records($ID, $module); 33 break; 34 35 case ($delete_c): 36 if(isset($_REQUEST['ID_s'])){ 37 $tmp = explode(',', $_REQUEST['ID_s']); 38 foreach($tmp as $tmp_id){ 39 $tmp_id = (int) $tmp_id; 40 if(check_children($tmp_id, $module)){ 41 message_stack_in(__('project could not be deleted, because it has sub-projects'),"projects","error"); 42 } 43 elseif($tmp_id > 0){ 44 manage_delete_records($tmp_id, $module); 45 } 46 } 47 } 48 elseif(isset($_REQUEST['ID'])){ 49 $tmp_id = (int) $_REQUEST['ID']; 50 if(check_children($tmp_id, $module)){ 51 message_stack_in(__('project could not be deleted, because it has sub-projects'),"projects","error"); 52 } 53 elseif($tmp_id > 0){ 54 manage_delete_records($tmp_id, $module); 55 } 56 } 57 unset($tmp, $tmp_id); 58 break; 59 60 // delete a file attached to a record 61 case ($delete_file): 62 delete_attached_file($file_field_name, $ID, 'projects'); 63 break; 64 65 // ************* 66 // update status 67 case ($modify_status_b and $ID > 0): 68 if ($status <> '') { 69 // check permission if you don't have chef level 70 if(slookup('projekte','chef','ID',$ID) <> $user_ID) $error = 1; 71 // if the status is not between 0 and 100% or not a number -> forget it 72 if (!is_numeric($status) or $status < 0 or $status > 100) { 73 message_stack_in(__('please check the status!'),"projects","error"); 74 $error = 1; 75 } 76 if (!$error) { 77 $result = db_query("update ".DB_PREFIX."projekte 78 set statuseintrag = '".date("Y-m-d")."', 79 status = '".(int) $status."' 80 where ID = '$ID'") or db_die(); 81 } 82 } 83 break; 84 85 // ************* 86 // update record 87 case ($modify_b and $ID > 0): 88 89 // ********** 90 // set status 91 if ($status <> '') { 92 // check permission if you don't have chef level 93 if(slookup('projekte','chef','ID',$ID) <> $user_ID) $error = 1; 94 // if the status is not between 0 and 100% or not a number -> forget it 95 if (!is_numeric($status) or $status < 0 or $status > 100) { 96 message_stack_in(__('please check the status!'),"projects","error"); 97 $error = 1; 98 } 99 if (!$error) { 100 $result = db_query("update ".DB_PREFIX."projekte 101 set statuseintrag = '".date("Y-m-d")."', 102 status = '".(int) $status."' 103 where ID = '$ID'") or db_die(); 104 105 } 106 $error=''; 107 } 108 109 check_anlegen(); 110 // check whether the subproject has changed the parent and resides in a new branch - 111 // in this case the next/previous entry and the dependency will be deleted 112 if ($parent <> slookup('projekte', 'parent', 'ID', $ID)) { 113 unset($depend_mode); unset($depend_proj); unset($next_mode); unset($next_proj); 114 // but also: scan for projects which have this project as next or dependency and delete this relations 115 $result4 = db_query("update ".DB_PREFIX."projekte 116 set depend_proj='', 117 depend_mode='' 118 where depend_proj = '$ID'") or db_die(); 119 $result4 = db_query("update ".DB_PREFIX."projekte 120 set next_proj='', 121 next_mode='' 122 where next_proj = '$ID'") or db_die(); 123 } 124 125 if(!$error){ 126 //keep history 127 if (PHPR_HISTORY_LOG) { 128 sqlstrings_create(); 129 history_keep('projekte','acc,acc_write,'.$sql_fieldstring,$ID); 130 } 131 132 $accessstring = "acc = '$access',"; 133 $sql_string = sqlstrings_modify(); 134 135 // next check: there is a bug if the user has chosen 'next_mode' (means: thre is a project before or after the current one 136 // but hasn't chosen a record for it! workaround: set next_mode inactive in this record 137 if ($next_mode > 0 and !$next_proj) unset($next_mode); 138 $result = db_query(xss("update ".DB_PREFIX."projekte 139 set $sql_string 140 personen='".serialize($personen)."', 141 gruppe='$user_group', 142 parent='$parent', 143 depend_mode = '$depend_mode', 144 depend_proj = '$depend_proj', 145 next_mode = '$next_mode', 146 next_proj = '$next_proj', 147 probability = '$probability', 148 acc='$acc', 149 acc_write = '$acc_write' 150 where ID = '$ID'")) or db_die(); 151 message_stack_in("$project_name: ".__('The project has been modified'),"projects","notice"); 152 } 153 break; 154 155 // leave here on tree open/close mode 156 case (isset($_GET['element_mode'])): 157 break; 158 159 // ************* 160 // insert record 161 default: 162 check_anlegen(); 163 sqlstrings_create(); 164 $result = db_query(xss("insert into ".DB_PREFIX."projekte 165 (ID, von, personen, gruppe, parent, probability, acc, acc_write,".$sql_fieldstring.") 166 values ($dbIDnull,'$user_ID','".serialize($personen)."','$user_group','$parent','$probability','$acc','$acc_write', ".$sql_valuestring.")")) or db_die(); 167 // message: project inserted 168 message_stack_in("$project_name: ".__('The project is now in the list'),"projects","notice"); 169 break; 170 } 171 172 173 function check_anlegen() { 174 global $ende, $anfang, $sid, $ID, $wichtung, $project_name, $action, $error, $cat; 175 global $depend_mode, $depend_proj, $project_name,$project_name, $chef, $note; 176 global $contact, $stundensatz, $budget, $parent, $img_path, $probability; 177 178 // check if end time is bigger than start time 179 if ($ende < $anfang) die(__('The duration of the project is incorrect.')."!<br /><a href='projects.php?mode=forms&ID=$ID&name=$name&anfang=$anfang&ende=$ende&wichtung=$wichtung&chef=$chef&parent=$parent¬e=$note&contact=$contact&stundensatz=$stundensatz&budget=$budget$sid'>".__('back')."</a> "); 180 // if given, check whether budget and hourly rates are integer 181 if ($budget <> '' and !is_numeric($budget)) die(__('Calculated budget').": ".__('Please check your date and time format! ')."!<br /><a href='projects.php?mode=forms&action=$action&ID=$ID&project_name=$project_name&anfang=$anfang&ende=$ende&wichtung=$wichtung&chef=$chef&parent=$parent¬e=$note&contact=$contact&stundensatz=$stundensatz&budget=$budget$sid'>".__('back')."</a> "); 182 if ($stundensatz <> '' and !is_numeric($stundensatz)) die(__('Calculated budget').": ".__('Please check your date and time format! ')."!<br /><a href='projects.php?mode=forms&action=$action&ID=$ID&project_name=$project_name&anfang=$anfang&ende=$ende&wichtung=$wichtung&chef=$chef&parent=$parent¬e=$note&contact=$contact&stundensatz=$stundensatz&budget=$budget$sid'>".__('back')."</a> "); 183 184 if ($parent > 0) { 185 /* 186 // the project is subproject? check whether the start and end time is within the limits of the parent project 187 $result2 = db_query("select anfang, ende 188 from ".DB_PREFIX."projekte 189 where ID = '$parent'") or db_die(); 190 $row2 = db_fetch_row($result2); 191 // timespan exceeds timespan of parent -> die ... 192 if ($anfang < $row2[0] or $ende > $row2[1]) { 193 die("$proj_text31<br /><a href='projects.php?mode=forms&action=$action&ID=$ID&project_name=$project_name&anfang=$anfang&ende=$ende&wichtung=$wichtung&chef=$chef&parent=$parent¬e=$note&contact=$contact&stundensatz=$stundensatz&budget=$budget&ziel=$ziel¬e=$note$sid'>$back</a>\n"); 194 */ 195 oerror($parent); 196 } 197 if ($ID>0) { 198 $resun = db_query("SELECT ID 199 FROM ".DB_PREFIX."projekte 200 WHERE parent = '$ID'"); 201 $uproj[] = $arr_empt; 202 while($rowun = db_fetch_row($resun)){ 203 if (!empty($rowun[0])) $uproj[] = $rowun[0]; 204 } 205 if ($uproj) uerror($uproj); 206 } 207 208 // check dependencies 209 if ($depend_mode > 1) $error = check_dependencies($ID, $depend_mode, $depend_proj, $cat, $project_name, $anfang, $ende); 210 211 // probability check: in case the status is set to 'offered', the author can enter a percentage for the probability of a project 212 // once the status turns into a higher level (e.g. ordered, at work etc.), the probability of course has to change to 'positive' = 100% 213 if ($cat > 1) $probability = 100; 214 } 215 216 217 function check_dependencies($ID, $depend_mode, $depend_proj, $cat, $project_name, $anfang, $ende) { 218 global $dependencies, $categories; 219 220 // fetch start and end date of the target project 221 $result = db_query("select anfang, ende, kategorie, name 222 from ".DB_PREFIX."projekte 223 where ID = '$depend_proj'") or db_die(); 224 $row = db_fetch_row($result); 225 226 switch ($depend_mode) { 227 228 // repeat the categiories here for those who don't want to have a look into the other skript: 229 // 1=offered, 2=ordered, 3=at work, 4=ended, 5=stopped, 6=reopened 7 = waiting, 10=container, 11=ext. project 230 // start means 'at work' or higher, but not 'waiting' 231 // end means 'ended' or 'stopped' 232 233 // 2 = this project cannot start before the end of project B 234 case "2": 235 // check logical 236 if (($cat > "2" and $cat <> 7) and ($row[2] <> "4" and $row[2] <> "5")) { 237 message_stack_in(__('Warning, violation of dependency').": $project_name \"$dependencies[$depend_mode] $row[3]\"<br />($row[3] = ".$categories[$row[2]].")","projects","error"); 238 $error = 1; 239 } 240 // check timeframe 241 if ($anfang < $row[1]) { 242 message_stack_in(__('Warning, violation of dependency').": ".__('Begin')."($project_name) < ".__('End')."($row[3])","projects","error"); 243 } 244 break; 245 246 // 3 = this project cannot start before start of project B 247 case "3": 248 if (($cat > "2" and $cat <> 7) and ($row[2] <= "2" or $row[2] == 7)) { 249 message_stack_in(__('Warning, violation of dependency').": $project_name \"$dependencies[$depend_mode] $row[3]\"<br />($row[3] = ".$categories[$row[2]].")","projects","error"); 250 $error = 1; 251 } 252 // check timeframe 253 if ($anfang < $row[0]) { 254 message_stack_in(__('Warning, violation of dependency').": ".__('Begin')."($project_name) < ".__('Begin')."($row[3])","projects","error"); 255 } 256 break; 257 258 // 4 = this project cannot end before start of project B 259 case "4": 260 if (($cat == "4" or $cat == "5") and ($row[2] <= "2" or $row[2] == 7)) { 261 message_stack_in(__('Warning, violation of dependency').": $project_name \"$dependencies[$depend_mode] $row[3]\"<br />($row[3] = ".$categories[$row[2]].")","projects","error"); 262 $error = 1; 263 } 264 // check timeframe 265 if ($ende < $row[0]) { 266 message_stack_in(__('Warning, violation of dependency').": ".__('End')."($project_name) < ".__('Begin')."($row[3])","projects","error"); 267 } 268 break; 269 270 // 5 = this project cannot end before end of project B 271 case "5": 272 if (($cat == "4" or $cat == "5") and ($row[2] <> "4" and $row[2] <> "5")) { 273 message_stack_in(__('Warning, violation of dependency').": $project_name \"$dependencies[$depend_mode] $row[3]\"<br />($row[3] = ".$categories[$row[2]].")","projects","error"); 274 $error = 1; 275 } 276 // check timeframe 277 if ($ende < $row[1]) { 278 message_stack_in(__('Warning, violation of dependency').": ".__('End')."($project_name) < ".__('End')."($row[3])","projects","error"); 279 } 280 break; 281 } 282 return $error; 283 } 284 285 286 function delete_record($ID) { 287 global $fields, $user_ID; 288 289 // only if an ID is given of course ... 290 if (!$ID) die(__('Please choose a project')."!<br /><a href='projects.php?".SID."'>".__('back')."</a>"); 291 292 // check whether there are subprojects below this record .. 293 $result = db_query("SELECT ID 294 FROM ".DB_PREFIX."projekte 295 WHERE parent = '$ID'") or db_die(); 296 $row = db_fetch_row($result); 297 298 if ($row[0] > 0) { 299 message_stack_in(__('Please delete all subelements first')."!","projects","error"); 300 return; 301 } 302 303 // delete project and show message 304 $tmp = slookup('projekte','name','ID',$ID); 305 306 // delete corresponding entry from db_record 307 $result = db_query("delete from ".DB_PREFIX."db_records 308 where t_record = '$ID' and t_module = 'projects'") or db_die(); 309 $result = db_query("delete from ".DB_PREFIX."projekte 310 where ID = '$ID'") or db_die(); 311 message_stack_in($tmp." - ".__('The project is deleted'),"projects","notice"); 312 unset($tmp); 313 // free events from project link 314 315 if (PHPR_CALENDAR) { 316 $result = db_query("update ".DB_PREFIX."termine 317 set projekt = '' 318 where projekt = '$ID'") or db_die(); 319 message_stack_in(__('All links in events to this project are deleted'),"projects","notice"); 320 } 321 // free files from project link 322 if (PHPR_FILEMANAGER) { 323 $result = db_query("update ".DB_PREFIX."dateien 324 set div2 = '' 325 where div2 = '$ID'") or db_die(); 326 } 327 // free notes from project link 328 if (PHPR_NOTES) { 329 $result = db_query("update ".DB_PREFIX."notes 330 set projekt = '' 331 where projekt = '$ID'") or db_die(); 332 } 333 // free timesheet from assignements from the timecard 334 if (PHPR_PROJECTS > 1) { 335 $result = db_query("delete from ".DB_PREFIX."timeproj 336 where projekt = '$ID'") or db_die(); 337 } 338 // free relations to this project 339 $result = db_query("update ".DB_PREFIX."projekte 340 set next_mode = '', next_proj = '' 341 where next_proj = '$ID'") or db_die(); 342 $result = db_query("update ".DB_PREFIX."projekte 343 set depend_mode = '', depend_proj = '' 344 where depend_proj = '$ID'") or db_die(); 345 echo "<img src='$img_path/s.gif' width='300px' height='1' vspace='2' border='0' />"; 346 347 // finally delete history 348 if (PHPR_HISTORY_LOG) history_delete('projekte',$ID); 349 } 350 351 // ******* 352 // actions 353 // ******* 354 355 if (!$justform) { 356 include_once ("./projects_view.php"); 357 } 358 else { 359 echo '<script type="text/javascript">self.opener.location.reload();self.close()</script>'; 360 } 361 362 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |