Exemple #1
0
 /**
  * @param string $get_array
  * @return string
  * @throws ProjectIDMissingException
  */
 public static function get_project_status_bar($get_array)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         $project = new Project($_GET['project_id']);
         $template = new HTMLTemplate("project/ajax/detail_status.html");
         // Status Bar
         $all_status_array = $project->get_all_status_array();
         $result = array();
         $counter = 0;
         if (is_array($all_status_array) and count($all_status_array) >= 1) {
             foreach ($all_status_array as $key => $value) {
                 $project_status = new ProjectStatus($value['id']);
                 if ($value['optional'] == true) {
                     $result[$counter]['name'] = $project_status->get_name() . " (optional)";
                 } else {
                     $result[$counter]['name'] = $project_status->get_name();
                 }
                 if ($value['status'] == 3) {
                     $result[$counter]['icon'] = "<img src='images/icons/status_cancel.png' alt='R' />";
                 } elseif ($value['status'] == 2) {
                     $result[$counter]['icon'] = "<img src='images/icons/status_ok.png' alt='R' />";
                 } elseif ($value['status'] == 1) {
                     $result[$counter]['icon'] = "<img src='images/icons/status_run.png' alt='R' />";
                 } else {
                     $result[$counter]['icon'] = "";
                 }
                 if (!($counter % 2)) {
                     $result[$counter]['tr_class'] = " class='trLightGrey'";
                 } else {
                     $result[$counter]['tr_class'] = "";
                 }
                 $counter++;
             }
             $project_status = new ProjectStatus(2);
             $result[$counter]['name'] = $project_status->get_name();
             if ($project->get_current_status_id() == 2) {
                 $result[$counter]['icon'] = "<img src='images/icons/status_ok.png' alt='R' />";
             } else {
                 $result[$counter]['icon'] = "";
             }
             if (!($counter % 2)) {
                 $result[$counter]['tr_class'] = " class='trLightGrey'";
             } else {
                 $result[$counter]['tr_class'] = "";
             }
             $counter++;
         }
         $template->set_var("status", $result);
         $template->output();
     } else {
         throw new ProjectIDMissingException();
     }
 }
Exemple #2
0
 /**
  * @see ProjectInterface::get_next_status_name()
  * @return string
  */
 public function get_next_status_name()
 {
     if ($this->is_next_status_available()) {
         $next_status_id = $this->get_next_status_id();
         $project_status = new ProjectStatus($next_status_id);
         return $project_status->get_name();
     } else {
         return null;
     }
 }
 /**
  * @throws ProjectStatusIDMissingException
  */
 public static function edit()
 {
     if ($_GET['id']) {
         $project_status = new ProjectStatus($_GET['id']);
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
             if (!$_POST['name']) {
                 $page_1_passed = false;
                 $error = "You must enter a name";
             }
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("project/admin/project_status/edit.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             if ($error) {
                 $template->set_var("error", $error);
             } else {
                 $template->set_var("error", "");
             }
             if ($_POST['name']) {
                 $template->set_var("name", $_POST['name']);
             } else {
                 $template->set_var("name", $project_status->get_name());
             }
             $template->output();
         } else {
             $paramquery = $_GET;
             unset($paramquery['nextpage']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery);
             if ($project_status->set_name($_POST['name'])) {
                 Common_IO::step_proceed($params, "Edit Project Status", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Edit Project Status", "Operation Failed", null);
             }
         }
     } else {
         throw new ProjectStatusIDMissingException();
     }
 }
Exemple #4
0
 /**
  * @param integer $id
  * @return string
  * @throws ProjectLogIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function get_less($id)
 {
     global $project_security;
     if ($project_security->is_access(3, false) == true) {
         if (is_numeric($id)) {
             $return_json_array = array();
             $project_log = new ProjectLog($id);
             if (($content = $project_log->get_content()) != null) {
                 $content = str_replace("\n", "<br />", $content);
                 if (strlen($content) > 500) {
                     $content = substr($content, 0, 500) . "...";
                 }
                 $return_json_array[0] = $content;
             } else {
                 $return_json_array[0] = false;
             }
             $status_id = $project_log->get_status_id();
             if ($status_id != null) {
                 $project_status = new ProjectStatus($status_id);
                 $return_json_array[1] = $project_status->get_name();
             } else {
                 $return_json_array[1] = false;
             }
             $item_array = $project_log->list_items();
             $number_of_items = count($item_array);
             if ($number_of_items == 0) {
                 $return_json_array[2] = false;
             } else {
                 if ($number_of_items == 1) {
                     $return_json_array[2] = $number_of_items . " Item was added";
                 } else {
                     $return_json_array[2] = $number_of_items . " Items were added";
                 }
             }
             $return_json_array[3] = "Show more";
             return json_encode($return_json_array);
         } else {
             throw new ProjectLogIDMissingException();
         }
     } else {
         throw new ProjectSecurityAccessDeniedException();
     }
 }
 /**
  * @see ProjectTaskInterface::get_name()
  * @return string
  */
 public function get_name()
 {
     if ($this->task_type and $this->task and $this->task_id) {
         if ($this->task->get_type_id() == 1) {
             $project_status = new ProjectStatus($this->task_type->get_end_status_id());
             if ($this->task_type->get_finalise() == true) {
                 return "Finalise " . $project_status->get_name();
             } else {
                 return "Achieve " . $project_status->get_name();
             }
         } else {
             return $this->task_type->get_name();
         }
     } else {
         return null;
     }
 }
Exemple #6
0
 /**
  * @throws ProjectTaskIDMissingException
  * @throws ProjectSecuriyAccessDeniedException
  */
 public static function detail()
 {
     global $user, $project_security;
     if ($_GET['id']) {
         if ($project_security->is_access(1, false) == true) {
             $project_task = new ProjectTask($_GET['id']);
             $project_task_owner = new User($project_task->get_owner_id());
             if ($project_task->get_start_time()) {
                 $project_task_start = new DatetimeHandler($project_task->get_start_date() . " " . $project_task->get_start_time());
             } else {
                 $project_task_start = new DatetimeHandler($project_task->get_start_date() . " 00:00:00");
             }
             if ($project_task->get_uf_end_time() != -1) {
                 $project_task_end = new DatetimeHandler($project_task->get_end_date() . " " . $project_task->get_end_time());
             } else {
                 $project_task_end = new DatetimeHandler($project_task->get_end_date() . " 23:59:59");
             }
             $project_task_created_at = new DatetimeHandler($project_task->get_created_at());
             $template = new HTMLTemplate("project/tasks/detail.html");
             switch ($project_task->get_type()) {
                 case 1:
                     $template->set_var("type", "Status Related Task");
                     $template->set_var("task_type", "1");
                     $template->set_var("progress", $project_task->get_progress() . "%");
                     $project_status = new ProjectStatus($project_task->get_begin_status_id());
                     $template->set_var("begin_status", $project_status->get_name());
                     break;
                 case 2:
                     $template->set_var("type", "Task");
                     $template->set_var("task_type", "2");
                     $template->set_var("progress", $project_task->get_progress() . "%");
                     break;
                 case 3:
                     $template->set_var("type", "Milestone");
                     $template->set_var("task_type", "3");
                     break;
                 default:
                     $template->set_var("type", "Undefined");
                     $template->set_var("task_type", "0");
                     break;
             }
             $template->set_var("owner", $project_task_owner->get_full_name(false));
             $template->set_var("start", $project_task_start->get_formatted_string("l, jS F Y H:i"));
             $template->set_var("end", $project_task_end->get_formatted_string("l, jS F Y H:i"));
             if ($project_task->get_auto_connect() == true) {
                 $template->set_var("auto_connect", "Yes");
             } else {
                 $template->set_var("auto_connect", "No");
             }
             $template->set_var("created_at", $project_task_created_at->get_formatted_string("l, jS F Y H:i"));
             $template->set_var("name", $project_task->get_name());
             if ($user->get_user_id() == $project_task->get_owner_id() or $user->is_admin()) {
                 $template->set_var("task_admin", true);
                 $paramquery = $_GET;
                 $paramquery['run'] = "task_edit_start";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("task_edit_start_params", $params);
                 $paramquery = $_GET;
                 $paramquery['run'] = "task_edit_end";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("task_edit_end_params", $params);
                 $paramquery = $_GET;
                 $paramquery['run'] = "task_delete";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("delete_params", $params);
             } else {
                 $template->set_var("task_admin", false);
             }
             $template->output();
         } else {
             throw new ProjectSecuriyAccessDeniedException();
         }
     } else {
         throw new ProjectTaskIDMissingException();
     }
 }
 /**
  * Creates a new Project Folder including Folder
  * @param integer $project_id
  * @return integer
  */
 public function create($project_id, $project_status_id)
 {
     if (is_numeric($project_id) and is_numeric($project_status_id)) {
         $project_status = new ProjectStatus($project_status_id);
         $project = new Project($project_id);
         $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id);
         $folder = new Folder($project_folder_id);
         $path = new Path($folder->get_path());
         $path->add_element("status-" . $project_status_id);
         if (($folder_id = parent::create($project_status->get_name(), $project_folder_id, $path->get_path_string(), $project->get_owner_id(), null)) != null) {
             $project_status_has_folder_access = new ProjectStatusHasFolder_Access(null);
             if ($project_status_has_folder_access->create($project_id, $project_status_id, $folder_id) == null) {
                 return null;
             }
             return $folder_id;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }