home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / tasks / do_task_aed.php < prev    next >
Encoding:
PHP Script  |  2003-12-08  |  1.9 KB  |  69 lines

  1. <?php /* TASKS $Id: do_task_aed.php,v 1.10 2003/12/08 07:04:22 jcgonz Exp $ */
  2.  
  3. $del = isset($_POST['del']) ? $_POST['del'] : 0;
  4. $hassign = @$_POST['hassign'];
  5. $hdependencies = @$_POST['hdependencies'];
  6. $notify = isset($_POST['task_notify']) ? $_POST['task_notify'] : 0;
  7.  
  8. $obj = new CTask();
  9.  
  10. if (!$obj->bind( $_POST )) {
  11.     $AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
  12.     $AppUI->redirect();
  13. }
  14.  
  15. // let's check if there are some assigned departments to task
  16. $obj->task_departments = implode(",", dPgetParam($_POST, "dept_ids", array()));
  17.  
  18. //Assign custom fields to task_custom for them to be saved
  19. $custom_fields = dPgetSysVal("TaskCustomFields");
  20. $custom_field_data = array();
  21. if ( count($custom_fields) > 0 ){
  22.     foreach ( $custom_fields as $key => $array ) {
  23.         $custom_field_data[$key] = $_POST["custom_$key"];
  24.     }
  25.     $obj->task_custom = serialize($custom_field_data);
  26. }
  27.  
  28. // convert dates to SQL format first
  29. if ($obj->task_start_date) {
  30.     $date = new CDate( $obj->task_start_date );
  31.     $obj->task_start_date = $date->format( FMT_DATETIME_MYSQL );
  32. }
  33. if ($obj->task_end_date) {
  34.     $date = new CDate( $obj->task_end_date );
  35.     $obj->task_end_date = $date->format( FMT_DATETIME_MYSQL );
  36. }
  37.  
  38. //echo '<pre>';print_r( $hassign );echo '</pre>';die;
  39. // prepare (and translate) the module name ready for the suffix
  40. if ($del) {
  41.     if (($msg = $obj->delete())) {
  42.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  43.         $AppUI->redirect();
  44.     } else {
  45.         $AppUI->setMsg( 'Task deleted' );
  46.         $AppUI->redirect( '', -1 );
  47.     }
  48. } else {
  49.     if (($msg = $obj->store())) {
  50.         $AppUI->setMsg( $msg, UI_MSG_ERROR );
  51.     } else {
  52.         $AppUI->setMsg( @$_POST['task_id'] ? 'Task updated' : 'Task added', UI_MSG_OK);
  53.     }
  54.  
  55.     if (isset($hassign)) {
  56.         $obj->updateAssigned( $hassign );
  57.     }
  58.     if (isset($hdependencies)) {
  59.         $obj->updateDependencies( $hdependencies );
  60.     }
  61.     if ($notify) {
  62.         if ($msg = $obj->notify()) {
  63.             $AppUI->setMsg( $msg, UI_MSG_ERROR );
  64.         }
  65.     }
  66.     $AppUI->redirect();
  67. }
  68. ?>
  69.