Пример #1
0
 /**
  * @param string $sql
  * @param integer $item_id
  * @param object $pdf
  * @return object
  */
 public static function get_equipment_item_report($sql, $item_id, $pdf)
 {
     if ($sql and is_object($pdf)) {
         $result_array = Equipment_Wrapper::list_item_equipments($sql, null, null, null, null);
         if (is_array($result_array) and count($result_array) >= 1) {
             $pdf->addPage();
             $pdf->SetFont('dejavusans', 'B', 14, '', true);
             $pdf->Write(0, 'Equipment', '', 0, 'C', true, 0, false, false, 0);
             $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
             $pdf->MultiCell(70, 0, "Equipment Name", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
             $pdf->MultiCell(60, 0, "Category", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
             $pdf->MultiCell(60, 0, "Date/Time", 1, 'L', 1, 1, '', '', true, 0, false, true, 0);
             $pdf->SetFont('dejavusans', '', 14, '', true);
             foreach ($result_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($result_array[$key]['datetime']);
                 $result_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 $pdf->MultiCell(70, 0, $result_array[$key]['name'], 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
                 $pdf->MultiCell(60, 0, $result_array[$key]['category'], 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
                 $pdf->MultiCell(60, 0, $result_array[$key]['datetime'], 1, 'L', 1, 1, '', '', true, 0, false, true, 0);
             }
         }
         return $pdf;
     } else {
         return null;
     }
 }
Пример #2
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws ProjectIDMissingException
  */
 public static function list_project_tasks($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     $project_id = $argument_array[1];
     if (is_numeric($project_id)) {
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Project_Wrapper::list_project_tasks($project_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $start_date = new DatetimeHandler($list_array[$key]['start_date']);
                 $end_date = new DatetimeHandler($list_array[$key]['end_date'] . " " . $list_array[$key]['end_time']);
                 $list_array[$key]['start_date'] = $start_date->get_date();
                 $list_array[$key]['end_date'] = $end_date->get_date();
                 $list_array[$key]['end_time'] = $end_date->get_time();
                 if ($list_array[$key]['whole_day'] == "t") {
                     $list_array[$key]['end_time'] = "whole day";
                 }
                 if ($list_array[$key]['is_status_process'] or $list_array[$key]['is_process']) {
                     $project_task = new ProjectTask($list_array[$key]['id']);
                 }
                 if ($list_array[$key]['is_status_process']) {
                     $list_array[$key]['type'] = "Status Rel. Task";
                     $list_array[$key]['name'] = $project_task->get_name();
                 }
                 if ($list_array[$key]['is_process']) {
                     $list_array[$key]['type'] = "Task";
                 }
                 if ($list_array[$key]['is_milestone']) {
                     $list_array[$key]['type'] = "Milestone";
                 } else {
                     $list_array[$key]['progress'] = "<img src='core/images/status_bar.php?length=100&height=15&linecolor=A0A0A0&color=" . $project_task->get_color() . "&value=" . $project_task->get_progress() . "' />";
                 }
                 $paramquery = array();
                 $paramquery['session_id'] = $_GET['session_id'];
                 $paramquery['username'] = $_GET['username'];
                 $paramquery['nav'] = "project";
                 $paramquery['run'] = "task_detail";
                 $paramquery['id'] = $list_array[$key]['id'];
                 $params = http_build_query($paramquery, '', '&#38;');
                 $tmp_name = $list_array[$key]['name'];
                 unset($list_array[$key]['name']);
                 $list_array[$key]['name']['content'] = $tmp_name;
                 $list_array[$key]['name']['link'] = $params;
             }
         } else {
             $list_request->empty_message("<span class='italic'>No Project tasks found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new ProjectIDMissingException();
     }
 }
Пример #3
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseUserAccessDeniedException
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_system_log($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     if ($user->is_admin()) {
         if ($get_array) {
             $_GET = unserialize($get_array);
         }
         $argument_array = json_decode($json_argument_array);
         if (is_array($argument_array)) {
             $type_id = $argument_array[1];
             $list_request = new ListRequest_IO();
             $list_request->set_column_array($json_column_array);
             if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
                 $entries_per_page = 20;
             }
             $list_array = SystemFE_Wrapper::list_system_log($type_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
             if (is_array($list_array) and count($list_array) >= 1) {
                 foreach ($list_array as $key => $value) {
                     $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                     $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                     $paramquery = $_GET;
                     $paramquery['id'] = $list_array[$key]['id'];
                     $paramquery['action'] = "detail";
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_datetime = $list_array[$key]['datetime'];
                     unset($list_array[$key]['datetime']);
                     $list_array[$key]['datetime']['link'] = $params;
                     $list_array[$key]['datetime']['content'] = $tmp_datetime;
                     $paramquery = $_GET;
                     $paramquery['id'] = $list_array[$key]['ip'];
                     $paramquery['action'] = "ip_info";
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_ip = $list_array[$key]['ip'];
                     unset($list_array[$key]['ip']);
                     $list_array[$key]['ip']['link'] = $params;
                     $list_array[$key]['ip']['content'] = $tmp_ip;
                 }
             } else {
                 $list_request->empty_message("<span class='italic'>No results found!</span>");
             }
             $list_request->set_array($list_array);
             return $list_request->get_page($page);
         } else {
             throw new BaseAjaxArgumentMissingException();
         }
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }
Пример #4
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws DataSecurityAccessDeniedException
  * @throws ValueIDMissingException
  */
 public static function list_versions($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     $argument_array = json_decode($json_argument_array);
     $value_id = $argument_array[1];
     if (is_numeric($value_id)) {
         $value_obj = Value::get_instance($value_id);
         if ($value_obj->is_read_access()) {
             $list_request = new ListRequest_IO();
             $list_request->set_column_array($json_column_array);
             if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
                 $entries_per_page = 20;
             }
             $list_array = Data_Wrapper::list_value_versions($value_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
             if (is_array($list_array) and count($list_array) >= 1) {
                 foreach ($list_array as $key => $value) {
                     $paramquery = $_GET;
                     $paramquery['action'] = "value_detail";
                     $paramquery['version'] = $list_array[$key]['internal_revision'];
                     $params = http_build_query($paramquery, '', '&#38;');
                     $list_array[$key]['symbol']['link'] = $params;
                     $list_array[$key]['symbol']['content'] = "<img src='images/icons/value.png' alt='N' border='0' />";
                     $tmp_name = $list_array[$key]['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['link'] = $params;
                     $list_array[$key]['name']['content'] = $tmp_name;
                     $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                     $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                     $user = new User($list_array[$key]['owner_id']);
                     $list_array[$key]['user'] = $user->get_full_name(false);
                     $value_version_obj = clone $value_obj;
                     $value_version_obj->open_internal_revision($value['internal_revision']);
                     if ($value_version_obj->is_current() == true) {
                         $list_array[$key]['version'] = $value_version_obj->get_version() . " <span class='italic'>current</span>";
                     } else {
                         $list_array[$key]['version'] = $value_version_obj->get_version();
                     }
                 }
             } else {
                 $list_request->empty_message("<span class='italic'>No results found!</span>");
             }
             $list_request->set_array($list_array);
             return $list_request->get_page($page);
         } else {
             throw new DataSecurityAccessDeniedException();
         }
     } else {
         throw new ValueIDMissingException();
     }
 }
Пример #5
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_items($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     if (is_array($argument_array)) {
         $string = $argument_array[0][1];
         $item_type_array = $argument_array[1][1];
         $language_id = $argument_array[2][1];
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Item_Wrapper::list_fulltext_search($string, $item_type_array, $language_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             $item_type_array = Item::list_types();
             foreach ($list_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 $sample_paramquery = array();
                 $sample_paramquery['username'] = $_GET['username'];
                 $sample_paramquery['session_id'] = $_GET['session_id'];
                 $sample_paramquery['nav'] = "sample";
                 $sample_paramquery['run'] = "detail";
                 $sample_paramquery['sample_id'] = $value['sample_id'];
                 $sample_params = http_build_query($sample_paramquery, '', '&#38;');
                 $tmp_sample_name = $list_array[$key]['sample_name'];
                 unset($list_array[$key]['sample_name']);
                 $list_array[$key]['sample_name']['content'] = $tmp_sample_name;
                 $list_array[$key]['sample_name']['link'] = $sample_params;
                 if (is_array($item_type_array) and count($item_type_array) >= 1) {
                     foreach ($item_type_array as $item_key => $item_value) {
                         if ($value[$item_key . "_id"] != null) {
                             $list_array[$key]['type'] = $item_value::get_generic_name($item_key, null);
                             $tmp_item_name = $list_array[$key]['name'];
                             unset($list_array[$key]['name']);
                             $list_array[$key]['name']['content'] = $tmp_item_name;
                             $list_array[$key]['name']['link'] = $item_value::get_generic_link($item_key, $value[$item_key . "_id"]);
                             $list_array[$key]['symbol']['content'] = $item_value::get_generic_symbol($item_key, $value[$item_key . "_id"]);
                             $list_array[$key]['symbol']['link'] = $item_value::get_generic_link($item_key, $value[$item_key . "_id"]);
                         }
                     }
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
 }
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseUserAccessDeniedException
  */
 public static function list_templates($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     if ($user->is_admin()) {
         if ($get_array) {
             $_GET = unserialize($get_array);
         }
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Data_Wrapper::list_parameter_templates($sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $paramquery = $_GET;
                 $paramquery['id'] = $list_array[$key]['id'];
                 $paramquery['action'] = "edit";
                 unset($paramquery['sortvalue']);
                 unset($paramquery['sortmethod']);
                 unset($paramquery['nextpage']);
                 $params = http_build_query($paramquery, '', '&#38;');
                 $name = $list_array[$key]['name'];
                 unset($list_array[$key]['name']);
                 $list_array[$key]['name']['link'] = $params;
                 $list_array[$key]['name']['content'] = $name;
                 $internal_name = $list_array[$key]['internal_name'];
                 unset($list_array[$key]['internal_name']);
                 $list_array[$key]['internal_name']['link'] = $params;
                 $list_array[$key]['internal_name']['content'] = $internal_name;
                 $user = new User($list_array[$key]['created_by']);
                 $list_array[$key]['created_by'] = $user->get_full_name(true);
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 if (ParameterTemplate::is_deletable($list_array[$key]['id']) === true) {
                     $list_array[$key]['delete'] = "<a title='delete' style='cursor: pointer;' id='DataParameterTemplateDeleteButton" . $list_array[$key]['id'] . "' class='DataParameterTemplateDeleteButton'><img src='images/icons/delete.png' alt='D' /></a>";
                 } else {
                     $list_array[$key]['delete'] = "";
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }
Пример #7
0
 /**
  * @see ServiceInterface::is_responding()
  * @return boolean
  */
 public function is_responding()
 {
     if ($this->service and $this->service_id) {
         $last_lifesign = $this->service->get_last_lifesign();
         $last_lifesign_datetime_handler = new DatetimeHandler($last_lifesign);
         $current_datetime_handler = new DatetimeHandler();
         if ($last_lifesign_datetime_handler->distance($current_datetime_handler) >= 600) {
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
Пример #8
0
 public static function list_system_messages()
 {
     define(SYSTEM_MESSAGE_ENTRIES_PER_PAGE, 6);
     $system_message_array = SystemMessage::list_entries();
     if (!$_GET['page']) {
         $page = 1;
     } else {
         $page = $_GET['page'];
     }
     $entry_count = count($system_message_array);
     $number_of_pages = ceil($entry_count / SYSTEM_MESSAGE_ENTRIES_PER_PAGE);
     $template = new HTMLTemplate("base/list_system_messages.html");
     if (is_array($system_message_array) and count($system_message_array) >= 1) {
         $template->set_var("no_entry", false);
         $result = array();
         $counter = 0;
         if (count($system_message_array) < $page * SYSTEM_MESSAGE_ENTRIES_PER_PAGE) {
             $max_for = count($system_message_array) % SYSTEM_MESSAGE_ENTRIES_PER_PAGE - 1;
         } else {
             $max_for = SYSTEM_MESSAGE_ENTRIES_PER_PAGE - 1;
         }
         for ($i = 0; $i <= $max_for; $i++) {
             $entry = $page * SYSTEM_MESSAGE_ENTRIES_PER_PAGE + $i - SYSTEM_MESSAGE_ENTRIES_PER_PAGE;
             // Erzeugt Entry-ID
             $value = $system_message_array[$entry];
             $system_message = new SystemMessage($value);
             $user = new User($system_message->get_user_id());
             $datetime_handler = new DatetimeHandler($system_message->get_datetime());
             $content = str_replace("\n", "<br />", $system_message->get_content());
             $content = str_replace("\\", "", $content);
             $result[$counter]['user'] = $user->get_full_name(false);
             $result[$counter]['datetime'] = $datetime_handler->get_date() . " at " . $datetime_handler->get_time();
             $result[$counter]['content'] = $content;
             $counter++;
         }
         $template->set_var("message_array", $result);
     } else {
         $template->set_var("no_entry", true);
     }
     if ($number_of_pages > 1) {
         $template->set_var("page_bar", Common_IO::page_bar($page, $number_of_pages, $_GET));
     } else {
         $template->set_var("page_bar", "");
     }
     $template->output();
 }
Пример #9
0
 /**
  * @see ProjectTaskPointInterface::get_status_achieved_points()
  * @param integer $status_id
  * @param string $datetime
  * @return integer
  */
 public function get_status_achieved_points($status_id, $datetime)
 {
     if ($this->project_id and $this->project and is_numeric($status_id)) {
         $project_status_array = $this->project_status_array;
         if (is_array($project_status_array) and count($project_status_array) >= 1) {
             $array_key = -1;
             $status = 0;
             foreach ($project_status_array as $key => $value) {
                 if ($value['id'] == $status_id) {
                     $array_key = $key;
                     $status = $value['status'];
                     $status_datetime = $value['datetime'];
                 }
             }
             if ($array_key >= 0) {
                 if ($status == 2) {
                     if (is_object($datetime)) {
                         $status_datetime_handler = new DatetimeHandler($status_datetime);
                         if ($status_datetime_handler->distance($datetime) < 0) {
                             return 0;
                         } else {
                             return $this->get_status_max_points($status_id) + 1;
                         }
                     } else {
                         return $this->get_status_max_points($status_id) + 1;
                     }
                 } elseif ($status == 1) {
                     return $this->get_current_achieved_points($datetime);
                 } else {
                     return 0;
                 }
             } else {
                 return null;
             }
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Пример #10
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_projects($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     if (is_array($argument_array)) {
         $name = $argument_array[0][1];
         $template_array = $argument_array[1][1];
         $organisation_unit_array = $argument_array[2][1];
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Project_Wrapper::list_search_projects_without_subprojects($name, $template_array, $organisation_unit_array, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $list_array[$key]['symbol'] = "<img src='images/icons/project.png' alt='N' border='0' />";
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 $proejct_paramquery = array();
                 $project_paramquery['username'] = $_GET['username'];
                 $project_paramquery['session_id'] = $_GET['session_id'];
                 $project_paramquery['nav'] = "project";
                 $project_paramquery['run'] = "detail";
                 $project_paramquery['project_id'] = $value['id'];
                 $project_params = http_build_query($project_paramquery, '', '&#38;');
                 $tmp_project_name = $list_array[$key]['name'];
                 unset($list_array[$key]['name']);
                 $list_array[$key]['name']['content'] = $tmp_project_name;
                 $list_array[$key]['name']['link'] = $project_params;
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
 }
Пример #11
0
 /**
  * @param string $json_argument_array
  * @return integer
  */
 public static function count_batches($json_argument_array)
 {
     $datetime_handler_end = new DatetimeHandler();
     $datetime_handler_end->sub_day(7);
     $datetime_handler_create = new DatetimeHandler();
     $datetime_handler_create->sub_day(30);
     return Batch_Wrapper::count_batches($datetime_handler_create->get_formatted_string("Y-m-d H:i:s"), $datetime_handler_end->get_formatted_string("Y-m-d H:i:s"));
 }
Пример #12
0
 /**
  * @param string $get_array
  * @throws SampleIDMissingException
  */
 public static function get_sample_information($get_array)
 {
     global $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['sample_id']) {
         $sample_security = new SampleSecurity($_GET['sample_id']);
         if ($sample_security->is_access(1, false)) {
             $sample = new Sample($_GET['sample_id']);
             $owner = new User($sample->get_owner_id());
             $template = new HTMLTemplate("sample/ajax/detail_information.html");
             $template->set_var("id", $sample->get_formatted_id());
             $template->set_var("name", $sample->get_name());
             $template->set_var("owner", $owner->get_full_name(false));
             $template->set_var("template", $sample->get_template_name());
             $template->set_var("permissions", $sample_security->get_access_string());
             $datetime = new DatetimeHandler($sample->get_datetime());
             $template->set_var("datetime", $datetime->get_datetime());
             if ($sample->get_date_of_expiry()) {
                 $date_of_expiry = new DatetimeHandler($sample->get_date_of_expiry());
                 $template->set_var("date_of_expiry", $date_of_expiry->get_date());
             } else {
                 $template->set_var("date_of_expiry", false);
             }
             if ($sample->get_current_location_name()) {
                 $template->set_var("location", $sample->get_current_location_name());
             } else {
                 $template->set_var("location", false);
             }
             if ($sample->get_manufacturer_id()) {
                 $manufacturer = new Manufacturer($sample->get_manufacturer_id());
                 $template->set_var("manufacturer", $manufacturer->get_name());
             } else {
                 $template->set_var("manufacturer", false);
             }
             if ($sample->get_availability() == true) {
                 $template->set_var("status", "available");
             } else {
                 $template->set_var("status", "not available");
             }
             if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) {
                 $template->set_var("is_owner", true);
             } else {
                 $template->set_var("is_owner", false);
             }
             if ($user->is_admin() == true) {
                 $template->set_var("is_admin", true);
             } else {
                 $template->set_var("is_admin", false);
             }
             $owner_paramquery = array();
             $owner_paramquery['username'] = $_GET['username'];
             $owner_paramquery['session_id'] = $_GET['session_id'];
             $owner_paramquery['nav'] = "sample";
             $owner_paramquery['run'] = "common_dialog";
             $owner_paramquery['dialog'] = "user_detail";
             $owner_paramquery['id'] = $sample->get_owner_id();
             $owner_params = http_build_query($owner_paramquery, '', '&#38;');
             $template->set_var("owner_params", $owner_params);
             $location_history_paramquery = $_GET;
             $location_history_paramquery['run'] = "location_history";
             $location_history_params = http_build_query($location_history_paramquery, '', '&#38;');
             $template->set_var("location_history_params", $location_history_params);
             $template->output();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
Пример #13
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws FolderIDMissingException
  */
 public static function list_data_browser($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($json_argument_array) {
         $argument_array = json_decode($json_argument_array);
     }
     $folder_id = $argument_array[0][1];
     $virtual_folder_id = $argument_array[1][1];
     if (!$folder_id and !$virtual_folder_id) {
         $data_path = new DataPath(null, null);
         $folder_id = $data_path->get_folder_id();
     }
     if (is_numeric($folder_id) or is_numeric($virtual_folder_id)) {
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = DataBrowser::get_data_browser_array($folder_id, $virtual_folder_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if ($folder_id) {
             $data_path = new DataPath($folder_id, null);
         } elseif ($virtual_folder_id) {
             $data_path = new DataPath(null, $virtual_folder_id);
         } else {
             $data_path = new DataPath(null, null);
         }
         if ($folder_id != 1 or $virtual_folder_id != null) {
             if ($data_path->get_previous_entry_virtual() == true) {
                 $paramquery = $_GET;
                 $paramquery['vfolder_id'] = $data_path->get_previous_entry_id();
                 unset($paramquery['folder_id']);
                 unset($paramquery['nextpage']);
                 unset($paramquery['page']);
                 $params = http_build_query($paramquery, '', '&#38;');
             } else {
                 $paramquery = $_GET;
                 $paramquery['folder_id'] = $data_path->get_previous_entry_id();
                 unset($paramquery['nextpage']);
                 unset($paramquery['vfolder_id']);
                 unset($paramquery['page']);
                 $params = http_build_query($paramquery, '', '&#38;');
             }
             $first_line_array['symbol']['link'] = $params;
             $first_line_array['symbol']['content'] = "<img src='images/icons/parent_folder.png' alt='' style='border:0;' />";
             $first_line_array['name']['link'] = $params;
             $first_line_array['name']['content'] = Language::get_message("DataGeneralTitleParentFolder", "general");
             $first_line_array['type'] = Language::get_message("DataGeneralDataTypeParentFolder", "general");
             $first_line_array['version'] = "";
             $first_line_array['datetime'] = "";
             $first_line_array['size'] = "";
             $first_line_array['owner'] = "";
             $first_line_array['permission'] = "";
             $list_request->add_first_line($first_line_array, "DataBrowserParentFolderRow");
         }
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 // Common
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 if ($list_array[$key]['owner_id']) {
                     $user = new User($list_array[$key]['owner_id']);
                 } else {
                     $user = new User(1);
                 }
                 $list_array[$key]['owner'] = $user->get_full_name(true);
                 // Special
                 if ($list_array[$key]['file_id']) {
                     $file = File::get_instance($list_array[$key]['file_id']);
                     if ($file->is_read_access() == true) {
                         $paramquery = $_GET;
                         $paramquery['nav'] = $_GET['nav'];
                         $paramquery['file_id'] = $list_array[$key]['file_id'];
                         $paramquery['action'] = "file_detail";
                         $params = http_build_query($paramquery, '', '&#38;');
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='" . $file->get_icon() . "' alt='' style='border:0;' />";
                         $tmp_name = $list_array[$key]['name'];
                         unset($list_array[$key]['name']);
                         $list_array[$key]['name']['content'] = $tmp_name;
                         $list_array[$key]['name']['link'] = $params;
                         $list_array[$key]['name']['class'] = "DataBrowserIsFile";
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=" . $file->get_icon() . "' alt='' border='0' />";
                     }
                     $list_array[$key]['type'] = Language::get_message("DataGeneralDataTypeFile", "general");
                     $list_array[$key]['version'] = $file->get_version();
                     $list_array[$key]['size'] = Convert::convert_byte_1024($list_array[$key]['size']);
                     $list_array[$key]['permission'] = $file->get_permission_string();
                     if ($file->is_delete_access()) {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name=''></input>";
                     } else {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name='' disabled='disabled'></input>";
                     }
                 } elseif ($list_array[$key]['value_id']) {
                     $value = Value::get_instance($list_array[$key]['value_id']);
                     if ($value->is_read_access() == true) {
                         $paramquery = $_GET;
                         $paramquery['nav'] = $_GET['nav'];
                         $paramquery['value_id'] = $list_array[$key]['value_id'];
                         $paramquery['action'] = "value_detail";
                         $params = http_build_query($paramquery, '', '&#38;');
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/fileicons/16/unknown.png' alt='' style='border:0;' />";
                         $tmp_name = $list_array[$key]['name'];
                         unset($list_array[$key]['name']);
                         $list_array[$key]['name']['content'] = $tmp_name;
                         $list_array[$key]['name']['link'] = $params;
                         $list_array[$key]['name']['class'] = "DataBrowserIsValue";
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/fileicons/16/unknown.png' alt='' border='0' />";
                     }
                     $list_array[$key]['type'] = Language::get_message("DataGeneralDataTypeValue", "general");
                     $list_array[$key]['version'] = $value->get_version();
                     $list_array[$key]['permission'] = $value->get_permission_string();
                     if ($value->is_delete_access()) {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name=''></input>";
                     } else {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name='' disabled='disabled'></input>";
                     }
                 } elseif ($list_array[$key]['parameter_id']) {
                     $parameter = ParameterTemplateParameter::get_instance($list_array[$key]['parameter_id']);
                     if ($parameter->is_read_access() == true) {
                         $paramquery = $_GET;
                         $paramquery['nav'] = $_GET['nav'];
                         $paramquery['parameter_id'] = $list_array[$key]['parameter_id'];
                         $paramquery['action'] = "parameter_detail";
                         $params = http_build_query($paramquery, '', '&#38;');
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/fileicons/16/unknown.png' alt='' style='border:0;' />";
                         $tmp_name = $list_array[$key]['name'];
                         unset($list_array[$key]['name']);
                         $list_array[$key]['name']['content'] = $tmp_name;
                         $list_array[$key]['name']['link'] = $params;
                         $list_array[$key]['name']['class'] = "DataBrowserIsParameter";
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/fileicons/16/unknown.png' alt='' border='0' />";
                     }
                     $list_array[$key]['type'] = Language::get_message("DataGeneralDataTypeParameter", "general");
                     $list_array[$key]['version'] = $parameter->get_version();
                     $list_array[$key]['permission'] = $parameter->get_permission_string();
                     if ($parameter->is_delete_access()) {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name=''></input>";
                     } else {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name='' disabled='disabled'></input>";
                     }
                 } elseif ($list_array[$key]['folder_id']) {
                     $sub_folder = Folder::get_instance($list_array[$key]['folder_id']);
                     if ($sub_folder->is_read_access() == true) {
                         $paramquery = $_GET;
                         $paramquery['folder_id'] = $list_array[$key]['folder_id'];
                         unset($paramquery['nextpage']);
                         unset($paramquery['vfolder_id']);
                         unset($paramquery['page']);
                         $params = http_build_query($paramquery, '', '&#38;');
                         $list_array[$key]['symbol']['content'] = "<img src='images/icons/folder.png' alt='' style='border:0;' />";
                         $list_array[$key]['symbol']['link'] = $params;
                         $tmp_name = $list_array[$key]['name'];
                         unset($list_array[$key]['name']);
                         $list_array[$key]['name']['content'] = $tmp_name;
                         $list_array[$key]['name']['link'] = $params;
                         $list_array[$key]['name']['class'] = "DataBrowserIsFolder";
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/icons/folder.png' alt='' border='0' />";
                     }
                     $list_array[$key]['type'] = Language::get_message("DataGeneralDataTypeFolder", "general");
                     $list_array[$key]['permission'] = $sub_folder->get_permission_string();
                     if ($sub_folder->is_delete_access()) {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name=''></input>";
                     } else {
                         $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name='' disabled='disabled'></input>";
                     }
                 } elseif ($list_array[$key]['virtual_folder_id']) {
                     $paramquery = $_GET;
                     $paramquery['vfolder_id'] = $list_array[$key]['virtual_folder_id'];
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $list_array[$key]['symbol']['content'] = "<img src='images/icons/virtual_folder.png' alt='' style='border:0;' />";
                     $list_array[$key]['symbol']['link'] = $params;
                     $tmp_name = $list_array[$key]['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     $list_array[$key]['name']['link'] = $params;
                     $list_array[$key]['name']['class'] = "DataBrowserIsVirtualFolder";
                     $list_array[$key]['type'] = Language::get_message("DataGeneralDataTypeVirtualFolder", "general");
                     $list_array[$key]['permission'] = "automatic";
                     $list_array[$key]['delete_checkbox'] = "<input type='checkbox' class='DataBrowserDeleteCheckbox' value='' name='' disabled='disabled'></input>";
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new FolderIDMissingException();
     }
 }
Пример #14
0
 /**
  * @throws FileIDMissingException
  * @throws DataSecurityAccessDeniedException
  */
 public static function detail()
 {
     global $regional;
     if ($_GET['file_id']) {
         $file = File::get_instance($_GET['file_id']);
         if ($file->is_read_access()) {
             $template = new HTMLTemplate("data/file_detail.html");
             $folder = Folder::get_instance($file->get_parent_folder_id());
             if ($_GET['version'] and is_numeric($_GET['version'])) {
                 $file->open_internal_revision($_GET['version']);
                 $internal_revision = $_GET['version'];
             } else {
                 $internal_revision = $file->get_internal_revision();
             }
             $template = new HTMLTemplate("data/file_detail.html");
             $folder = Folder::get_instance($file->get_parent_folder_id());
             $user = new User($file->get_owner_id());
             $file_version_array = $file->get_file_internal_revisions();
             if (is_array($file_version_array) and count($file_version_array) > 0) {
                 $result = array();
                 $counter = 1;
                 $result[0]['version'] = 0;
                 $result[0]['text'] = "----------------------------------------------";
                 $file_version = File::get_instance($_GET['file_id'], true);
                 foreach ($file_version_array as $key => $value) {
                     $file_version->open_internal_revision($value);
                     $version_datetime_handler = new DatetimeHandler($file_version->get_datetime());
                     $result[$counter]['version'] = $file_version->get_internal_revision();
                     $result[$counter]['text'] = "Version " . $file_version->get_version() . " - " . $version_datetime_handler->get_datetime();
                     $counter++;
                 }
                 $template->set_var("version_option", $result);
             }
             $result = array();
             $counter = 0;
             foreach ($_GET as $key => $value) {
                 if ($key != "version") {
                     $result[$counter]['value'] = $value;
                     $result[$counter]['key'] = $key;
                     $counter++;
                 }
             }
             $template->set_var("get", $result);
             $template->set_var("version", $file->get_version());
             $paramquery = $_GET;
             $paramquery['action'] = "file_history";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("version_list_link", $params);
             $template->set_var("title", $file->get_name());
             $template->set_var("name", $file->get_name());
             $template->set_var("path", $folder->get_object_path());
             $template->set_var("size", Convert::convert_byte_1024($file->get_size()));
             $template->set_var("size_in_byte", $regional->format_number($file->get_size()));
             $create_datetime_handler = new DatetimeHandler($file->get_datetime());
             $version_datetime_handler = new DatetimeHandler($file->get_version_datetime());
             $template->set_var("creation_datetime", $create_datetime_handler->get_datetime());
             $template->set_var("version_datetime", $version_datetime_handler->get_datetime());
             $template->set_var("mime_type", $file->get_mime_type());
             $template->set_var("owner", $user->get_full_name(false));
             $template->set_var("checksum", $file->get_checksum());
             $template->set_var("permission", $file->get_permission_string());
             $template->set_var("comment", "");
             if ($file->is_image() == true) {
                 $template->set_var("thumbnail_image", "<img src='image.php?session_id=" . $_GET['session_id'] . "&file_id=" . $_GET['file_id'] . "&max_width=340&max_height=350' alt='' />");
             } else {
                 $template->set_var("thumbnail_image", "");
             }
             $paramquery = array();
             $paramquery['username'] = $_GET['username'];
             $paramquery['session_id'] = $_GET['session_id'];
             $paramquery['file_id'] = $_GET['file_id'];
             if ($_GET['version']) {
                 $paramquery['version'] = $_GET['version'];
             }
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("download_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_update";
             $paramquery['version'] = $internal_revision;
             $paramquery['retrace'] = Retrace::create_retrace_string();
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("update_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_update_minor";
             $paramquery['version'] = $file->get_internal_revision();
             $paramquery['retrace'] = Retrace::create_retrace_string();
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("update_minor_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("set_permission_params", $params);
             $template->set_var("write_access", $file->is_write_access());
             if ($file->is_control_access() == true or $file->get_owner_id() == $user->get_user_id()) {
                 $template->set_var("change_permission", true);
             } else {
                 $template->set_var("change_permission", false);
             }
             $template->set_var("delete_access", $file->is_delete_access());
             $paramquery = $_GET;
             $paramquery['action'] = "file_delete";
             unset($paramquery['sure']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("delete_file_params", $params);
             $paramquery = $_GET;
             $paramquery['action'] = "file_delete_version";
             $paramquery['version'] = $internal_revision;
             unset($paramquery['sure']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("delete_file_version_params", $params);
             $paramquery = $_GET;
             unset($paramquery['file_id']);
             unset($paramquery['version']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("back_link", $params);
             $template->output();
         } else {
             throw new DataSecurityAccessDeniedException();
         }
     } else {
         throw new FileIDMissingException();
     }
 }
Пример #15
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecuriyAccessDeniedException
  */
 public static function gantt_view()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project_task_array = ProjectTask::list_tasks($_GET['project_id']);
             $left_limit = 0;
             $right_limit = 0;
             if (is_array($project_task_array) and count($project_task_array) >= 1) {
                 foreach ($project_task_array as $key => $value) {
                     $project_task = new ProjectTask($value);
                     if ($project_task->get_start_date()) {
                         $begin_timestamp = $project_task->get_start_date() . " 00:00:00";
                         if ($project_task->get_uf_end_time() != "-1") {
                             $end_timestamp = $project_task->get_end_date() . " " . $project_task->get_end_time();
                         } else {
                             $end_timestamp = $project_task->get_end_date() . " 00:00:00";
                         }
                         $begin_datetime_handler = new DatetimeHandler($begin_timestamp);
                         $end_datetime_handler = new DatetimeHandler($end_timestamp);
                         $begin_mktime = $begin_datetime_handler->get_mktime();
                         $end_mktime = $end_datetime_handler->get_mktime();
                         if ($left_limit == 0 or $left_limit > $begin_mktime) {
                             $left_limit = $begin_mktime;
                         }
                         if ($right_limit == 0 or $right_limit < $end_mktime) {
                             $right_limit = $end_mktime;
                         }
                     }
                 }
                 $left_limit_handler = new DatetimeHandler($left_limit);
                 $right_limit_handler = new DatetimeHandler($right_limit);
                 $day_distance = $left_limit_handler->day_distance($right_limit_handler);
                 $date_range = $right_limit - $left_limit;
                 if ($day_distance < 30) {
                     if ($day_distance < 15) {
                         if ($day_distance < 7) {
                             $date_range_addition = ceil($date_range / ($day_distance * 4));
                             $date_mktime = $left_limit;
                             $number_of_rows = $day_distance * 4 + 4;
                         } else {
                             $date_range_addition = ceil($date_range / ($day_distance * 2));
                             $date_mktime = $left_limit;
                             $number_of_rows = $day_distance * 2 + 2;
                         }
                     } else {
                         $date_range_addition = ceil($date_range / $day_distance);
                         $date_mktime = $left_limit;
                         $number_of_rows = $day_distance + 1;
                     }
                 } else {
                     $date_range_addition = ceil($date_range / 29);
                     $date_mktime = $left_limit;
                     $number_of_rows = 30;
                 }
                 $width_of_row = 705 / $number_of_rows;
                 $gantt_array = array();
                 for ($i = 0; $i <= $number_of_rows - 1; $i++) {
                     $day = date("d", $date_mktime);
                     $month = date("M", $date_mktime);
                     $gantt_array[$i]['title'] = $day . "<br />" . $month;
                     $gantt_array[$i]['mktime'] = $date_mktime;
                     $date_mktime = $date_mktime + $date_range_addition;
                 }
                 $template = new HTMLTemplate("project/tasks/gantt_view.html");
                 $table_view_paramquery = $_GET;
                 $table_view_paramquery['show'] = "table";
                 $table_view_params = http_build_query($table_view_paramquery, '', '&#38;');
                 $template->set_var("table_view_params", $table_view_params);
                 $gantt_view_paramquery = $_GET;
                 $gantt_view_paramquery['show'] = "gantt";
                 $gantt_view_params = http_build_query($gantt_view_paramquery, '', '&#38;');
                 $template->set_var("gantt_view_params", $gantt_view_params);
                 $cal_view_paramquery = $_GET;
                 $cal_view_paramquery['show'] = "cal";
                 $cal_view_params = http_build_query($cal_view_paramquery, '', '&#38;');
                 $template->set_var("cal_view_params", $cal_view_params);
                 $table = "<table class='ProjectTaskGanttTable'>";
                 $table .= "<tr>";
                 foreach ($gantt_array as $key => $value) {
                     $table .= "<th width='" . $width_of_row . "px'>" . $value['title'] . "</th>";
                 }
                 $table .= "</tr>";
                 foreach ($project_task_array as $key => $value) {
                     $project_task = new ProjectTask($value);
                     $begin_timestamp = $project_task->get_start_date() . " 00:00:00";
                     if ($project_task->get_uf_end_time() != "-1") {
                         $end_timestamp = $project_task->get_end_date() . " " . $project_task->get_end_time();
                     } else {
                         $end_timestamp = $project_task->get_end_date() . " 23:59:59";
                     }
                     $begin_datetime_handler = new DatetimeHandler($begin_timestamp);
                     $end_datetime_handler = new DatetimeHandler($end_timestamp);
                     $begin_mktime = $begin_datetime_handler->get_mktime();
                     $end_mktime = $end_datetime_handler->get_mktime();
                     $table .= "<tr>";
                     $paramquery = $_GET;
                     $paramquery['run'] = "task_detail";
                     $paramquery['id'] = $value;
                     $params = http_build_query($paramquery, '', '&#38;');
                     $table .= "<td colspan='30'><span class='smallText'><a href='index.php?" . $params . "'>" . $project_task->get_name() . " (" . $begin_datetime_handler->get_formatted_string("j/n/Y") . " - " . $end_datetime_handler->get_formatted_string("j/n/Y") . ")</a></span></td>";
                     $table .= "</tr><tr class='ProjectTaskGanttBlockEnd'>";
                     $begin_key = -1;
                     $end_key = -1;
                     foreach ($gantt_array as $fe_key => $fe_value) {
                         if ($fe_value['mktime'] >= $begin_mktime) {
                             if ($begin_key == -1) {
                                 $begin_key = $fe_key;
                             }
                         }
                         if ($begin_key != -1 and $fe_value['mktime'] <= $end_mktime) {
                             $end_key = $fe_key;
                         }
                     }
                     $key_range = $end_key - $begin_key + 1;
                     $in_task = false;
                     for ($i = 0; $i <= $number_of_rows - 1; $i++) {
                         if ($i == $begin_key) {
                             $in_task = true;
                             $width = $key_range * ($width_of_row + 1);
                             if ($project_task->get_type() == 3) {
                                 $table .= "<td colspan='" . $key_range . "' style='text-align: center;'><img src='images/icons/milestone.png' alt='' /></td>";
                             } else {
                                 $table .= "<td colspan='" . $key_range . "'><img src='core/images/status_bar.php?length=" . $width . "&height=15&linecolor=A0A0A0&bgcolor=EAEAEA&color=" . $project_task->get_color() . "&value=" . $project_task->get_progress() . "' /></td>";
                             }
                         }
                         if ($in_task == false) {
                             $table .= "<td></td>";
                         }
                         if ($i == $end_key) {
                             $in_task = false;
                         }
                     }
                     $table .= "</tr>";
                 }
                 $table .= "</table>";
                 $template->set_var("table", $table);
                 $template->output();
             } else {
                 $template = new HTMLTemplate("project/tasks/gantt_view.html");
                 $table_view_paramquery = $_GET;
                 $table_view_paramquery['show'] = "table";
                 $table_view_params = http_build_query($table_view_paramquery, '', '&#38;');
                 $template->set_var("table_view_params", $table_view_params);
                 $gantt_view_paramquery = $_GET;
                 $gantt_view_paramquery['show'] = "gantt";
                 $gantt_view_params = http_build_query($gantt_view_paramquery, '', '&#38;');
                 $template->set_var("gantt_view_params", $gantt_view_params);
                 $cal_view_paramquery = $_GET;
                 $cal_view_paramquery['show'] = "cal";
                 $cal_view_params = http_build_query($cal_view_paramquery, '', '&#38;');
                 $template->set_var("cal_view_params", $cal_view_params);
                 $template->set_var("table", "<span class='italic'>No Entries Found</span>");
                 $template->output();
             }
         } else {
             throw new ProjectSecuriyAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Пример #16
0
 /**
  * @param string $sql
  * @param integer $item_id
  * @param object $pdf
  * @return object
  */
 public static function get_sample_item_report($sql, $item_id, $pdf)
 {
     if ($sql and is_object($pdf)) {
         $new_page = false;
         $child_sample_array = Sample_Wrapper::list_item_samples($sql, null, null, null, null);
         if (is_array($child_sample_array) and count($child_sample_array) >= 1) {
             $pdf->addPage();
             $new_page = true;
             $pdf->SetFont('dejavusans', 'B', 14, '', true);
             $pdf->Write(0, 'Samples', '', 0, 'C', true, 0, false, false, 0);
             $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
             $pdf->MultiCell(35, 0, "ID", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
             $pdf->MultiCell(60, 0, "Name", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
             $pdf->MultiCell(50, 0, "Date/Time", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
             $pdf->MultiCell(45, 0, "User", 1, 'L', 1, 1, '', '', true, 0, false, true, 0);
             $pdf->SetFont('dejavusans', '', 14, '', true);
             foreach ($child_sample_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($value['datetime']);
                 $value['datetime'] = $datetime_handler->get_datetime(false);
                 $value['id'] = "S" . str_pad($value['id'], 8, '0', STR_PAD_LEFT);
                 $owner = new User($value['owner']);
                 $pdf->MultiCell(35, 0, $value['id'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                 $pdf->MultiCell(60, 0, $value['name'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                 $pdf->MultiCell(50, 0, $value['datetime'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                 $pdf->MultiCell(45, 0, $owner->get_full_name(true), 1, 'L', 1, 1, '', '', true, 0, true, true, 0);
             }
         }
         if ($item_id) {
             $parent_sample_array = Sample_Wrapper::list_samples_by_item_id($item_id, null, null, null, null);
             if (is_array($parent_sample_array) and count($parent_sample_array) >= 1) {
                 if ($new_page == false) {
                     $pdf->addPage();
                 } else {
                     $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                     $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                 }
                 $pdf->SetFont('dejavusans', 'B', 14, '', true);
                 $pdf->Write(0, 'Parent Samples', '', 0, 'C', true, 0, false, false, 0);
                 $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                 $pdf->MultiCell(35, 0, "ID", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
                 $pdf->MultiCell(60, 0, "Name", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
                 $pdf->MultiCell(50, 0, "Date/Time", 1, 'L', 1, 0, '', '', true, 0, false, true, 0);
                 $pdf->MultiCell(45, 0, "User", 1, 'L', 1, 1, '', '', true, 0, false, true, 0);
                 $pdf->SetFont('dejavusans', '', 14, '', true);
                 foreach ($parent_sample_array as $key => $value) {
                     $datetime_handler = new DatetimeHandler($value['datetime']);
                     $value['datetime'] = $datetime_handler->get_datetime(false);
                     $value['id'] = "S" . str_pad($value['id'], 8, '0', STR_PAD_LEFT);
                     $owner = new User($value['owner']);
                     $pdf->MultiCell(35, 0, $value['id'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                     $pdf->MultiCell(60, 0, $value['name'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                     $pdf->MultiCell(50, 0, $value['datetime'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0);
                     $pdf->MultiCell(45, 0, $owner->get_full_name(true), 1, 'L', 1, 1, '', '', true, 0, true, true, 0);
                 }
             }
         }
         return $pdf;
     } else {
         return null;
     }
 }
Пример #17
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecuriyAccessDeniedException
  */
 public static function detail()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project = new Project($_GET['project_id']);
             $project_owner = new User($project->get_owner_id());
             $template = new HTMLTemplate("project/detail.html");
             $template->set_var("get_array", serialize($_GET));
             $template->set_var("title", $project->get_name());
             $template->set_var("owner", $project_owner->get_full_name(false));
             $create_datetime = new DatetimeHandler($project->get_datetime());
             $template->set_var("created_at", $create_datetime->get_datetime());
             $template->set_var("template", $project->get_template_name());
             $template->set_var("permissions", "");
             $template->set_var("size", Convert::convert_byte_1024($project->get_filesize()));
             $template->set_var("quota", Convert::convert_byte_1024($project->get_quota()));
             $owner_paramquery = array();
             $owner_paramquery['username'] = $_GET['username'];
             $owner_paramquery['session_id'] = $_GET['session_id'];
             $owner_paramquery['nav'] = "project";
             $owner_paramquery['run'] = "common_dialog";
             $owner_paramquery['dialog'] = "user_detail";
             $owner_paramquery['id'] = $project->get_owner_id();
             $owner_params = http_build_query($owner_paramquery, '', '&#38;');
             $template->set_var("owner_params", $owner_params);
             $template->output();
         } else {
             throw new ProjectSecurityAccessDeniedxception();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Пример #18
0
 /**
  * @see ProjectTaskInterface::list_upcoming_tasks()
  * @return array
  * @todo tasks ending today
  * @todo tasks ending this week
  * @todo tasks ending next 30 days
  */
 public static function list_upcoming_tasks()
 {
     global $user;
     $upcoming_task_array = array();
     $over_time_task_array = Project_Wrapper_Access::list_not_finished_over_time_project_tasks_by_user_id($user->get_user_id(), date("Y-m-d H:i:s"));
     if (is_array($over_time_task_array) and count($over_time_task_array) >= 1) {
         foreach ($over_time_task_array as $key => $value) {
             $project_task = new ProjectTask($value);
             $project = new Project($project_task->get_project_id());
             if ($project_task->get_uf_end_time() == -1) {
                 $end_task_datetime = new DatetimeHandler($project_task->get_end_date() . " 23:59:59");
             } else {
                 $end_task_datetime = new DatetimeHandler($project_task->get_end_date() . " " . $project_task->get_uf_end_time());
             }
             if ($project_task->get_over_time() == true) {
                 $temp_array = array();
                 $temp_array['project_id'] = $project_task->get_project_id();
                 $temp_array['project_name'] = $project->get_name();
                 $temp_array['task_name'] = $project_task->get_name();
                 $temp_array['end_date'] = $end_task_datetime->get_formatted_string("d/m/Y");
                 $temp_array['status'] = 1;
                 array_push($upcoming_task_array, $temp_array);
                 unset($temp_array);
             } else {
                 if ($project_task->get_progress() < 100) {
                     $temp_array = array();
                     $temp_array['project_id'] = $project_task->get_project_id();
                     $temp_array['project_name'] = $project->get_name();
                     $temp_array['task_name'] = $project_task->get_name();
                     $temp_array['end_date'] = $end_task_datetime->get_formatted_string("d/m/Y");
                     $temp_array['status'] = 1;
                     array_push($upcoming_task_array, $temp_array);
                     unset($temp_array);
                     $project_task->set_over_time(true);
                 } else {
                     $project_task->set_finished(true);
                 }
             }
         }
     }
     return $upcoming_task_array;
 }
Пример #19
0
 /**
  * @see CronInterface::check()
  * @return bool
  */
 public static function check()
 {
     self::init();
     if (self::$last_run_datetime and is_numeric(self::$last_run_id)) {
         $last_run_datetime_handler = new DatetimeHandler(self::$last_run_datetime);
         $current_datetime_handler = new DatetimeHandler(date("Y-m-d H:i:s"));
         if ($last_run_datetime_handler->distance($current_datetime_handler) >= 3600) {
             return true;
         } else {
             return false;
         }
     }
 }
Пример #20
0
 /**
  * @throws SystemLogIDMissingException
  */
 public static function detail()
 {
     if ($_GET['id']) {
         $system_log = new SystemLog($_GET['id']);
         $user = new User($system_log->get_user_id());
         $datetime_handler = new DatetimeHandler($system_log->get_datetime());
         $template = new HTMLTemplate("base/admin/system_log/detail.html");
         $template->set_var("datetime", $datetime_handler->get_datetime(false));
         if ($system_log->get_user_id()) {
             $template->set_var("username", $user->get_username() . " (" . $user->get_full_name(false) . ")");
         } else {
             $template->set_var("username", "");
         }
         if ($system_log->get_ip()) {
             $template->set_var("ip", $system_log->get_ip());
         } else {
             $template->set_var("ip", "");
         }
         if ($system_log->get_file()) {
             $template->set_var("file", $system_log->get_file());
         } else {
             $template->set_var("file", "");
         }
         if ($system_log->get_line()) {
             $template->set_var("line", $system_log->get_line());
         } else {
             $template->set_var("line", "");
         }
         if ($system_log->get_content_int()) {
             $template->set_var("content_int", $system_log->get_content_int());
         } else {
             $template->set_var("content_int", "");
         }
         if ($system_log->get_content_string()) {
             $template->set_var("content_string", $system_log->get_content_string());
         } else {
             $template->set_var("content_string", "");
         }
         if ($system_log->get_link()) {
             $unserialized_string = unserialize($system_log->get_link());
             if (is_array($unserialized_string)) {
                 if (count($unserialized_string) >= 1) {
                     $string = "";
                     foreach ($unserialized_string as $key => $value) {
                         $string .= $key . " => " . $value . "<br />";
                     }
                     $template->set_var("get", $string);
                 } else {
                     $template->set_var("get", "");
                 }
             } else {
                 $template->set_var("get", $system_log->get_link());
             }
         } else {
             $template->set_var("get", "");
         }
         $template->output();
     } else {
         throw new SystemLogIDMissingException();
     }
 }
Пример #21
0
 private function day_view()
 {
     $today = date("j-m-Y");
     $today_datetime_handler = new DatetimeHandler($today);
     if (!$_GET['page']) {
         $date = date("j-m-Y");
     } else {
         $date = $_GET['page'];
     }
     $datetime_handler = new DatetimeHandler($date);
     $datetime_handler->add_hour(6);
     $next_day_datetime_handler = clone $datetime_handler;
     $next_day_datetime_handler->add_day(1);
     $prev_day_datetime_handler = clone $datetime_handler;
     $prev_day_datetime_handler->sub_day(1);
     $mktime = $datetime_handler->get_mktime();
     $day = date("jS", $mktime);
     $month = date("m", $mktime);
     $month_name = date("F", $mktime);
     $year = date("Y", $mktime);
     $color_count = 1;
     $date_array = $this->mktime_has_date($mktime, $mktime + 86399);
     $rows = count($date_array);
     $column_array = array();
     $column_array_count = 0;
     if ($datetime_handler->get_formatted_string("Y-m-d") == $today_datetime_handler->get_formatted_string("Y-m-d")) {
         $display_date = "<span class='CalendarToday'>" . $datetime_handler->get_formatted_string("l jS F Y") . "</span>";
     } else {
         $display_date = $datetime_handler->get_formatted_string("l jS F Y");
     }
     for ($i = 0; $i <= 17; $i++) {
         $mktime = $datetime_handler->get_mktime();
         $date_array = $this->mktime_has_date($mktime, $mktime + 3599);
         if (is_array($date_array) and count($date_array >= 1)) {
             foreach ($date_array as $key => $value) {
                 if (!in_array($value, $column_array)) {
                     if ($this->calendar_array[$value]['link']) {
                         $content_array[$i][$column_array_count]['name'] = "<a href='index.php?" . $this->calendar_array[$value]['link'] . "'>" . $this->calendar_array[$value]['name'] . "</a>";
                     } else {
                         $content_array[$i][$column_array_count]['name'] = $this->calendar_array[$value]['name'];
                     }
                     $content_array[$i][$column_array_count]['value'] = $this->calendar_array[$value]['color'];
                     $content_array[$i][$column_array_count]['datebegin'] = true;
                     $start_datetime_handler = new DatetimeHandler($this->calendar_array[$value]['start_date'] . " " . $this->calendar_array[$value]['start_time']);
                     $end_datetime_handler = new DatetimeHandler($this->calendar_array[$value]['end_date'] . " " . $this->calendar_array[$value]['end_time']);
                     $content_array[$i][$column_array_count]['range'] = $start_datetime_handler->get_formatted_string("j-n-Y (H:i)") . " - " . $end_datetime_handler->get_formatted_string("j-n-Y (H:i)");
                     $column_array_count++;
                     array_push($column_array, $value);
                 }
             }
             for ($j = 0; $j <= $rows - 1; $j++) {
                 if (!$content_array[$i][$j]['content']) {
                     if (isset($column_array[$j]) and in_array($column_array[$j], $date_array)) {
                         $content_array[$i][$j]['value'] = $this->calendar_array[$column_array[$j]]['color'];
                         if ($content_array[$i][$j]['datebegin'] != true) {
                             $content_array[$i][$j]['datebegin'] = false;
                         }
                     } else {
                         $content_array[$i][$j]['value'] = "";
                         $content_array[$i][$j]['datebegin'] = false;
                     }
                 }
             }
         } else {
             $content_array[$i][0]['datebegin'] = false;
             $content_array[$i][0]['value'] = "";
         }
         $content_array[$i]['time'] = $datetime_handler->get_formatted_string("H:i");
         $datetime_handler->add_hour(1);
         if ($color_count % 2) {
             $tr_class = " class='CalendarTrGrey'";
         } else {
             $tr_class = "";
         }
         $content_array[$i]['tr_class'] = $tr_class;
         $color_count++;
     }
     $template = new HTMLTemplate("organiser/views/day.html");
     $paramquery_prev = $_GET;
     $paramquery_prev['page'] = date("j-m-Y", $prev_day_datetime_handler->get_mktime());
     $params_prev = http_build_query($paramquery_prev, '', '&#38;');
     $paramquery_next = $_GET;
     $paramquery_next['page'] = date("j-m-Y", $next_day_datetime_handler->get_mktime());
     $params_next = http_build_query($paramquery_next, '', '&#38;');
     $template->set_var("previous_params", $params_prev);
     $template->set_var("next_params", $params_next);
     $template->set_var("date", $display_date);
     $template->set_var("content_array", $content_array);
     return $template->get_string();
 }
Пример #22
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  */
 public static function list_equipment_items($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $page, $sortvalue, $sortmethod)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($json_argument_array) {
         $argument_array = json_decode($json_argument_array);
     }
     $handling_class = Item::get_holder_handling_class_by_name($argument_array[0][1]);
     if ($handling_class) {
         $sql = $handling_class::get_item_list_sql($argument_array[1][1]);
     }
     if ($sql) {
         $list_request = new ListRequest_IO();
         if ($argument_array[2][1] == true) {
             $list_array = Equipment_Wrapper::list_item_equipments($sql, $sortvalue, $sortmethod, $page * 20 - 20, $page * 20);
         } else {
             $list_array = Equipment_Wrapper::list_item_equipments($sql, $sortvalue, $sortmethod, 0, null);
         }
         $list_request->set_column_array($json_column_array);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 if ($argument_array[3][1] == true) {
                     $column_array = json_decode($json_column_array);
                     if (is_array($column_array) and count($column_array) >= 1) {
                         foreach ($column_array as $row_key => $row_value) {
                             if ($row_value[1] == "checkbox") {
                                 if ($row_value[4]) {
                                     $checkbox_class = $row_value[4];
                                     break;
                                 }
                             }
                         }
                     }
                     if ($checkbox_class) {
                         $list_array[$key]['checkbox'] = "<input type='checkbox' name='equipment-" . $list_array[$key]['item_id'] . "' value='1' class='" . $checkbox_class . "' checked='checked' />";
                     } else {
                         $list_array[$key]['checkbox'] = "<input type='checkbox' name='equipment-" . $list_array[$key]['item_id'] . "' value='1' checked='checked' />";
                     }
                     $list_array[$key]['symbol'] = "<img src='images/icons/equipment.png' alt='N' border='0' />";
                 } else {
                     $paramquery = $_GET;
                     $paramquery['action'] = "detail";
                     $paramquery['id'] = $list_array[$key]['id'];
                     $params = http_build_query($paramquery, '', '&#38;');
                     $list_array[$key]['symbol']['link'] = $params;
                     $list_array[$key]['symbol']['content'] = "<img src='images/icons/equipment.png' alt='N' border='0' />";
                     $equipment_name = $list_array[$key]['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['link'] = $params;
                     $list_array[$key]['name']['content'] = $equipment_name;
                 }
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
             }
         } else {
             $list_request->empty_message("<span class='italic'>No Equipment found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         // Error
     }
 }
Пример #23
0
 /**
  * @param string $sql
  * @param integer $item_id
  * @param object $pdf
  * @return object
  */
 public static function get_data_item_report($sql, $item_id, $pdf)
 {
     global $regional;
     if ($sql and is_object($pdf)) {
         // Values
         $value_array = Data_Wrapper::list_item_values($sql);
         if (is_array($value_array) and count($value_array) >= 1) {
             foreach ($value_array as $key => $value) {
                 $value_object = Value::get_instance($value['id']);
                 $value_object_value_array = $value_object->get_value_content(false);
                 $pdf->addPage();
                 $pdf->SetFont('dejavusans', 'B', 14, '', true);
                 $pdf->Write(0, 'Value - ' . $value_object->get_name() . '', '', 0, 'C', true, 0, false, false, 0);
                 $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                 $pdf->SetFont('dejavusans', '', 12, '', true);
                 if (is_array($value_object_value_array) and count($value_object_value_array) >= 1) {
                     foreach ($value_object_value_array as $sub_key => $sub_value) {
                         $sub_value['content'][0] = str_replace("\n", "<br />", $sub_value['content'][0]);
                         if ($sub_value['type'] == "textarea") {
                             $pdf->SetFont('dejavusans', 'B', 12, '', true);
                             $pdf->MultiCell(190, 9, $sub_value['title'], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
                             $pdf->SetFont('dejavusans', '', 12, '', true);
                             $string_height = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1);
                             $pdf->MultiCell(190, $string_height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
                         } else {
                             $pdf->SetFont('dejavusans', 'B', 12, '', true);
                             $string_height1 = $pdf->getStringHeight(80, $sub_value['title'], true, true, '', 1);
                             $pdf->SetFont('dejavusans', '', 12, '', true);
                             $string_height2 = $pdf->getStringHeight(110, $sub_value['content'][0], true, true, '', 1);
                             if ($string_height1 > $string_height2) {
                                 $height = $string_height1;
                             } else {
                                 $height = $string_height2;
                             }
                             $pdf->SetFont('dejavusans', 'B', 12, '', true);
                             $pdf->MultiCell(80, $height, $sub_value['title'], 1, 'L', 1, 0, '', '', true, 0, true, true, 0, "T");
                             $pdf->SetFont('dejavusans', '', 12, '', true);
                             $pdf->MultiCell(110, $height, $sub_value['content'][0], 1, 'L', 1, 1, '', '', true, 0, true, true, 0, "T");
                         }
                     }
                 }
                 $value_object_version_array = $value_object->get_value_internal_revisions();
                 if (is_array($value_object_version_array) and count($value_object_version_array) >= 1) {
                     $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                     $header_array = array(array("name" => "name", "title" => "Name", "width" => 60), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 50));
                     $report_table = new ReportTable_IO($pdf, '', '12');
                     $report_table->add_header($header_array);
                     foreach ($value_object_version_array as $sub_key => $sub_value) {
                         $value_version = clone $value_object;
                         $value_version->open_internal_revision($sub_value);
                         $datetime_handler = new DatetimeHandler($value_version->get_datetime());
                         $owner = new User($value_version->get_version_owner_id());
                         $line_array = array(array("name" => "name", "content" => $value_version->get_name()), array("name" => "version", "content" => $value_version->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true)));
                         $report_table->add_line($line_array);
                     }
                 }
                 $pdf = $report_table->get_pdf();
             }
         }
         // Files
         $file_array = Data_Wrapper::list_item_files($sql, null, null, null, null);
         if (is_array($file_array) and count($file_array) >= 1) {
             $pdf->addPage();
             $pdf->SetFont('dejavusans', 'B', 14, '', true);
             $pdf->Write(0, 'Files', '', 0, 'C', true, 0, false, false, 0);
             $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
             $pdf->SetFont('dejavusans', '', 14, '', true);
             $header_array = array(array("name" => "name", "title" => "Name", "width" => 62), array("name" => "version", "title" => "Version", "width" => 25), array("name" => "datetime", "title" => "Date/Time", "width" => 55), array("name" => "user", "title" => "User", "width" => 48));
             $report_table = new ReportTable_IO($pdf, '', '12');
             $report_table->add_header($header_array);
             foreach ($file_array as $key => $value) {
                 $file = File::get_instance($value['id']);
                 $owner = new User($value['owner_id']);
                 $datetime_handler = new DatetimeHandler($value['datetime']);
                 $line_array = array(array("name" => "name", "content" => $value['name']), array("name" => "version", "content" => $file->get_version()), array("name" => "datetime", "content" => $datetime_handler->get_datetime(false)), array("name" => "user", "content" => $owner->get_full_name(true)));
                 $report_table->add_line($line_array);
             }
             $pdf = $report_table->get_pdf();
         }
         // Parameters
         $parameter_array = Data_Wrapper::list_item_parameters($sql);
         if (is_array($parameter_array) and count($parameter_array) >= 1) {
             foreach ($parameter_array as $key => $value) {
                 $parameter_object = Parameter::get_instance($value['id']);
                 $parameter_template = new ParameterTemplate($parameter_object->get_template_id());
                 $parameter_template_field_array = $parameter_template->get_fields();
                 $parameter_template_limit_array = $parameter_template->get_limits();
                 $parameter_value_array = $parameter_object->get_values();
                 $parameter_method_array = $parameter_object->get_methods();
                 $parameter_status_array = $parameter_object->get_status();
                 $parameter_limit_array = $parameter_object->geT_limits();
                 $pdf->addPage();
                 $pdf->SetFont('dejavusans', 'B', 14, '', true);
                 $pdf->Write(0, '' . $parameter_object->get_name() . '', '', 0, 'L', true, 0, false, false, 0);
                 $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
                 $pdf->SetFont('dejavusans', '', 12, '', true);
                 $header_array = array(array("name" => "parameter", "title" => "Parameter", "width" => 44), array("name" => "value", "title" => "Value", "width" => 25), array("name" => "unit", "title" => "Unit", "width" => 25), array("name" => "min", "title" => "Min", "width" => 20), array("name" => "max", "title" => "Max", "width" => 20), array("name" => "method", "title" => "Method", "width" => 30), array("name" => "status", "title" => "Status", "width" => 25));
                 $report_table = new ReportTable_IO($pdf, '', '12');
                 $report_table->add_header($header_array);
                 if (is_array($parameter_template_field_array) and count($parameter_template_field_array) >= 1) {
                     foreach ($parameter_template_field_array as $key => $value) {
                         if (is_numeric($parameter_value_array[$value['pk']])) {
                             $regionalized_value = str_replace(".", $regional->get_decimal_separator(), $parameter_value_array[$value['pk']]);
                         } else {
                             $regionalized_value = "";
                         }
                         if (is_numeric($value['unit'])) {
                             if ($value['unit_exponent'] < 0) {
                                 $unit_exponent = $value['unit_exponent'] * -1;
                                 $unit_prefix = MeasuringUnit::get_prefix($unit_exponent, false);
                             } else {
                                 $unit_prefix = MeasuringUnit::get_prefix($value['unit_exponent'], true);
                             }
                             $measuring_unit = new MeasuringUnit($value['unit']);
                             $unit = $unit_prefix[1] . "" . $measuring_unit->get_unit_symbol();
                         } elseif (is_numeric($value['unit_ratio'])) {
                             $measuring_unit_ratio = new MeasuringUnitRatio($value['unit_ratio']);
                             $unit = $measuring_unit_ratio->get_symbol();
                         } else {
                             $unit = "";
                         }
                         if ($parameter_limit_array[$value['pk']]) {
                             if (is_numeric($parameter_limit_array[$value['pk']]['usl'])) {
                                 $usl = $parameter_limit_array[$value['pk']]['usl'];
                             } else {
                                 $usl = "";
                             }
                             if (is_numeric($parameter_limit_array[$value['pk']]['lsl'])) {
                                 $lsl = $parameter_limit_array[$value['pk']]['lsl'];
                             } else {
                                 $lsl = "";
                             }
                         } else {
                             if (is_numeric($parameter_template_limit_array[0]['usl'][$key])) {
                                 $usl = $parameter_template_limit_array[0]['usl'][$key];
                             } else {
                                 $usl = "";
                             }
                             if (is_numeric($parameter_template_limit_array[0]['lsl'][$key])) {
                                 $lsl = $parameter_template_limit_array[0]['lsl'][$key];
                             } else {
                                 $lsl = "";
                             }
                         }
                         if ($parameter_method_array[$key]) {
                             $method = $parameter_method_array[$key];
                         } else {
                             $method = "none";
                         }
                         if ($parameter_status_array[$value['pk']]) {
                             switch ($parameter_status_array[$value['pk']]) {
                                 case "max":
                                     $status = ">max";
                                     break;
                                 case "min":
                                     $status = "<min";
                                     break;
                                 default:
                                     $status = "OK";
                                     break;
                             }
                         } else {
                             $status = "none";
                         }
                         $line_array = array(array("name" => "parameter", "content" => $value['name']), array("name" => "value", "content" => $regionalized_value), array("name" => "unit", "content" => $unit), array("name" => "min", "content" => $lsl), array("name" => "max", "content" => $usl), array("name" => "method", "content" => $method), array("name" => "status", "content" => $status));
                         $report_table->add_line($line_array);
                         unset($regionalized_value);
                         unset($unit);
                         unset($lsl);
                         unset($usl);
                         unset($method);
                         unset($status);
                     }
                 }
                 $pdf = $report_table->get_pdf();
             }
         }
         return $pdf;
     } else {
         return null;
     }
 }
Пример #24
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_samples($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     if (is_array($argument_array)) {
         $name = $argument_array[0][1];
         $organisation_unit_array = $argument_array[1][1];
         $template_array = $argument_array[2][1];
         $in_id = $argument_array[3][1];
         $in_name = $argument_array[4][1];
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Sample_Wrapper::list_sample_search($name, $organisation_unit_array, $template_array, $in_id, $in_name, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             $today_end = new DatetimeHandler(date("Y-m-d") . " 23:59:59");
             foreach ($list_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 if ($list_array[$key]['av'] == "f") {
                     $list_array[$key]['av'] = "<img src='images/icons/grey_point.png' alt='' />";
                 } else {
                     if ($list_array[$key]['date_of_expiry'] and $list_array[$key]['expiry_warning']) {
                         $date_of_expiry = new DatetimeHandler($list_array[$key]['date_of_expiry'] . " 23:59:59");
                         $warning_day = clone $date_of_expiry;
                         $warning_day->sub_day($list_array[$key]['expiry_warning']);
                         if ($date_of_expiry->distance($today_end) > 0) {
                             $list_array[$key]['av'] = "<img src='images/icons/red_point.png' alt='' />";
                         } else {
                             if ($warning_day->distance($today_end) > 0) {
                                 $list_array[$key]['av'] = "<img src='images/icons/yellow_point.png' alt='' />";
                             } else {
                                 $list_array[$key]['av'] = "<img src='images/icons/green_point.png' alt='' />";
                             }
                         }
                     } else {
                         $list_array[$key]['av'] = "<img src='images/icons/green_point.png' alt='' />";
                     }
                 }
                 $sample_id = $list_array[$key]['id'];
                 $sample_security = new SampleSecurity($sample_id);
                 if ($sample_security->is_access(1, false)) {
                     $paramquery = array();
                     $paramquery['username'] = $_GET['username'];
                     $paramquery['session_id'] = $_GET['session_id'];
                     $paramquery['nav'] = "sample";
                     $paramquery['run'] = "detail";
                     $paramquery['sample_id'] = $sample_id;
                     $params = http_build_query($paramquery, '', '&#38;');
                     $list_array[$key]['symbol']['link'] = $params;
                     $list_array[$key]['symbol']['content'] = "<img src='images/icons/sample.png' alt='' style='border:0;' />";
                     unset($list_array[$key]['id']);
                     $list_array[$key]['id']['link'] = $params;
                     $list_array[$key]['id']['content'] = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT);
                     $sample_name = $list_array[$key]['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['link'] = $params;
                     $list_array[$key]['name']['content'] = $sample_name;
                 } else {
                     $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/icons/sample.png' alt='N' border='0' />";
                     $list_array[$key]['id'] = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT);
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
 }
Пример #25
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseAjaxArgumentMissingException
  */
 public static function list_data($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     $argument_array = json_decode($json_argument_array);
     if (is_array($argument_array)) {
         $folder_id = $argument_array[0][1];
         $name = $argument_array[1][1];
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = Data_Wrapper::list_search_ffv($folder_id, $name, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 $owner = new User($value['owner']);
                 $list_array[$key]['owner'] = $owner->get_full_name(true);
                 if (is_numeric($value['file_id'])) {
                     $file = File::get_instance($value['file_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['action'] = "file_detail";
                     $paramquery['file_id'] = $value['file_id'];
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($file->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='" . File::get_icon_by_name($value['name']) . "' alt='' style='border:0;' />";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=" . File::get_icon_by_name($value['name']) . "' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "File";
                     $list_array[$key]['version'] = $file->get_version();
                     $list_array[$key]['size'] = Convert::convert_byte_1024($file->get_size());
                     $list_array[$key]['permission'] = $file->get_permission_string();
                 }
                 if (is_numeric($value['value_id'])) {
                     $value_obj = Value::get_instance($value['value_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['action'] = "value_detail";
                     $paramquery['value_id'] = $value['value_id'];
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($value_obj->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/fileicons/16/unknown.png' alt='' style='border: 0;'>";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/fileicons/16/unknown.png' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "Value";
                     $list_array[$key]['version'] = $value_obj->get_version();
                     $list_array[$key]['permission'] = $value_obj->get_permission_string();
                 }
                 if (is_numeric($value['folder_id'])) {
                     $folder = Folder::get_instance($value['folder_id']);
                     $paramquery = $_GET;
                     $paramquery['nav'] = "data";
                     $paramquery['folder_id'] = $value['folder_id'];
                     unset($paramquery['run']);
                     unset($paramquery['sortvalue']);
                     unset($paramquery['sortmethod']);
                     unset($paramquery['nextpage']);
                     $params = http_build_query($paramquery, '', '&#38;');
                     $tmp_name = $value['name'];
                     unset($list_array[$key]['name']);
                     $list_array[$key]['name']['content'] = $tmp_name;
                     if ($folder->is_read_access() == true) {
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/icons/folder.png' alt='' style='border: 0;'>";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol']['link'] = "";
                         $list_array[$key]['symbol']['content'] = "<img src='core/images/denied_overlay.php?image=images/icons/folder.png' alt='' border='0' />";
                         $list_array[$key]['name']['link'] = "";
                     }
                     $list_array[$key]['type'] = "Folder";
                     $list_array[$key]['permission'] = $folder->get_permission_string();
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
 }
Пример #26
0
 /**
  * @param object $value
  * @param string $target_params
  * @param boolean $display_header
  * @throws ValueIDMissingException
  * @throws DataSecurityAccessDeniedException
  */
 public static function detail($value = null, $target_params = null, $display_header = true)
 {
     global $user, $regional;
     if (is_object($value) and $target_params) {
         $retrace = "index.php?" . $target_params;
     } elseif (is_numeric($_GET['value_id'])) {
         $value_id = $_GET['value_id'];
         $value = Value::get_instance($value_id);
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['value_id']);
         $params = http_build_query($paramquery);
         $retrace = "index.php?" . $params;
         if ($_GET['version'] and is_numeric($_GET['version'])) {
             $value->open_internal_revision($_GET['version']);
         }
     } else {
         throw new ValueIDMissingException();
     }
     if ($value->is_read_access()) {
         if ($value->get_type_id() == 2) {
             $template = new HTMLTemplate("data/value_description_detail.html");
         } else {
             $template = new HTMLTemplate("data/value_detail.html");
         }
         $template->set_var("display_header", $display_header);
         $template->set_var("decimal_separator", $regional->get_decimal_separator());
         $template->set_var("thousand_separator", $regional->get_thousand_separator());
         $value_version_array = $value->get_value_internal_revisions();
         if (is_array($value_version_array) and count($value_version_array) > 0) {
             $result = array();
             $counter = 1;
             $result[0]['version'] = 0;
             $result[0]['text'] = "----------------------------------------------";
             $value_version = Value::get_instance($_GET['value_id'], true);
             foreach ($value_version_array as $key => $fe_value) {
                 $value_version->open_internal_revision($fe_value);
                 $version_datetime_handler = new DatetimeHandler($value_version->get_version_datetime());
                 $result[$counter]['version'] = $value_version->get_internal_revision();
                 $result[$counter]['text'] = "Version " . $value_version->get_version() . " - " . $version_datetime_handler->get_datetime();
                 $counter++;
             }
             $template->set_var("version_option", $result);
         }
         $result = array();
         $counter = 0;
         foreach ($_GET as $key => $fe_value) {
             if ($key != "version") {
                 $result[$counter]['value'] = $fe_value;
                 $result[$counter]['key'] = $key;
                 $counter++;
             }
         }
         $template->set_var("get", $result);
         $template->set_var("version", $value->get_version());
         $version_datetime_handler = new DatetimeHandler($value->get_version_datetime());
         $template->set_var("version_datetime", $version_datetime_handler->get_datetime());
         $paramquery = $_GET;
         $paramquery['action'] = "permission";
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("change_permission_params", $params);
         if ($value->is_control_access() == true or $value->get_owner_id() == $user->get_user_id()) {
             $template->set_var("change_permission", true);
         } else {
             $template->set_var("change_permission", false);
         }
         if ($value->is_write_access() == true or $value->get_owner_id() == $user->get_user_id()) {
             $template->set_var("write_permission", true);
         } else {
             $template->set_var("write_permission", false);
         }
         $paramquery = $_GET;
         $paramquery['action'] = "value_history";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("version_list_link", $params);
         $template->set_var("title", $value->get_type_name());
         $template->set_var("retrace", $retrace);
         if ($value->get_type_id() == 2) {
             $value_string = unserialize($value->get_value());
             $template->set_var("description", $value_string);
         } else {
             require_once "value_form.io.php";
             $value_form_io = new ValueFormIO($value->get_id());
             $value_form_io->set_field_class("DataValueUpdateValues");
             $template->set_var("value", $value_form_io->get_content());
         }
         $template->set_var("session_id", $_GET['session_id']);
         $template->set_var("internal_revision", $value->get_internal_revision());
         $template->set_var("value_id", $value->get_id());
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['value_id']);
         $params = http_build_query($paramquery);
         $template->set_var("retrace", "index.php?" . $params);
         $template->output();
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Пример #27
0
 * you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
 * version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, see <http://www.gnu.org/licenses/>.
 */
/**
 *
 */
$template = new HTMLTemplate("base/home.html");
$template->set_var("USERNAME", $user->get_full_name(false));
$datetime_handler = new DatetimeHandler();
$template->set_var("DATE", $datetime_handler->get_formatted_string("l, jS F Y"));
$home_summery_left_array = ModuleDialog::list_dialogs_by_type("home_summary_left");
if (is_array($home_summery_left_array) and count($home_summery_left_array) >= 1) {
    $content_array = array();
    $counter = 0;
    foreach ($home_summery_left_array as $key => $value) {
        require_once $value['class_path'];
        $content_array[$counter]['content'] = $value['class']::$value['method']();
        $counter++;
    }
    $template->set_var("HOME_SUMMARY_LEFT_ARRAY", $content_array);
}
$home_summery_right_array = ModuleDialog::list_dialogs_by_type("home_summary_right");
if (is_array($home_summery_right_array) and count($home_summery_right_array) >= 1) {
    $content_array = array();
Пример #28
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws ItemIDMissingException
  */
 public static function list_projects_by_item_id($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     $argument_array = json_decode($json_argument_array);
     $item_id = $argument_array[0][1];
     if (is_numeric($item_id)) {
         $list_request = new ListRequest_IO();
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         if ($argument_array[2][1] == true) {
             $list_array = Project_Wrapper::list_projects_by_item_id($item_id, $user->is_admin(), $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         } else {
             $list_array = Project_Wrapper::list_projects_by_item_id($item_id, $user->is_admin(), $sortvalue, $sortmethod, 0, null);
         }
         $list_request->set_column_array($json_column_array);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $tmp_name = trim($list_array[$key]['name']);
                 unset($list_array[$key]['name']);
                 $list_array[$key]['name']['label'] = $tmp_name;
                 $list_array[$key]['name']['content'] = $tmp_name;
                 $tmp_template = trim($list_array[$key]['template']);
                 unset($list_array[$key]['template']);
                 $list_array[$key]['template']['label'] = $tmp_template;
                 $list_array[$key]['template']['content'] = $tmp_template;
                 $tmp_status = trim($list_array[$key]['status']);
                 unset($list_array[$key]['status']);
                 $list_array[$key]['status']['label'] = $tmp_status;
                 $list_array[$key]['status']['content'] = $tmp_status;
                 if ($list_array[$key]['deleted'] == "t") {
                     $list_array[$key]['name']['content'] = "<span class='crossed'>" . $list_array[$key]['name']['content'] . "</span>";
                     $list_array[$key]['template']['content'] = "<span class='crossed'>" . $list_array[$key]['template']['content'] . "</span>";
                     $list_array[$key]['status']['content'] = "<span class='crossed'>" . $list_array[$key]['status']['content'] . "</span>";
                 }
                 if ($argument_array[1][1] == true) {
                     $column_array = json_decode($json_column_array);
                     if (is_array($column_array) and count($column_array) >= 1) {
                         foreach ($column_array as $row_key => $row_value) {
                             if ($row_value[1] == "checkbox") {
                                 if ($row_value[4]) {
                                     $checkbox_class = $row_value[4];
                                     break;
                                 }
                             }
                         }
                     }
                     if ($checkbox_class) {
                         $list_array[$key]['checkbox'] = "<input type='checkbox' name='parent-project-" . $list_array[$key]['id'] . "' value='1' class='" . $checkbox_class . "' />";
                     } else {
                         $list_array[$key]['checkbox'] = "<input type='checkbox' name='parent-project-" . $list_array[$key]['id'] . "' value='1' />";
                     }
                     $list_array[$key]['symbol'] = "<img src='images/icons/project.png' alt='' style='border:0;' />";
                 } else {
                     $project_id = $list_array[$key]['id'];
                     $project_security = new ProjectSecurity($project_id);
                     if ($project_security->is_access(1, false)) {
                         $paramquery = array();
                         $paramquery['username'] = $_GET['username'];
                         $paramquery['session_id'] = $_GET['session_id'];
                         $paramquery['nav'] = "project";
                         $paramquery['run'] = "detail";
                         $paramquery['project_id'] = $project_id;
                         $params = http_build_query($paramquery, '', '&#38;');
                         $list_array[$key]['symbol']['link'] = $params;
                         $list_array[$key]['symbol']['content'] = "<img src='images/icons/project.png' alt='' style='border:0;' />";
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/icons/project.png' alt='N' border='0' />";
                     }
                 }
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false);
                 if ($list_array[$key]['owner']) {
                     $user = new User($list_array[$key]['owner']);
                 } else {
                     $user = new User(1);
                 }
                 $list_array[$key]['owner'] = $user->get_full_name(true);
             }
         } else {
             $list_request->empty_message("<span class='italic'>No Projects found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new ItemIDMissingException();
     }
 }
Пример #29
0
 public static function detail($parameter = null, $target_params = null, $display_header = true)
 {
     global $regional;
     if (is_object($parameter) and $target_params) {
         $retrace = "index.php?" . $target_params;
         $parameter_id = $parameter->get_id();
     } elseif (is_numeric($_GET['parameter_id'])) {
         $parameter_id = $_GET['parameter_id'];
         $parameter = ParameterTemplateParameter::get_instance($parameter_id);
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['parameter_id']);
         $params = http_build_query($paramquery);
         $retrace = "index.php?" . $params;
         if ($_GET['version'] and is_numeric($_GET['version'])) {
             $parameter->open_internal_revision($_GET['version']);
         }
     } else {
         throw new ParameterIDMissingException();
     }
     if ($parameter->is_read_access()) {
         $parameter_template_id = $parameter->get_template_id();
         $parameter_template = new ParameterTemplate($parameter_template_id);
         $parameter_template_field_array = $parameter_template->get_fields();
         $parameter_template_limit_array = $parameter_template->get_limits();
         $parameter_possible_methods_array = $parameter_template->get_methods();
         $parameter_value_array = $parameter->get_values();
         $parameter_method_array = $parameter->get_methods();
         $parameter_limit_array = $parameter->get_limits();
         $output_template_limit_array = array();
         $output_template_limit_counter = 0;
         if (is_array($parameter_template_limit_array) and count($parameter_template_limit_array) >= 1) {
             $current_limit = $parameter->get_limit_id();
             foreach ($parameter_template_limit_array as $key => $value) {
                 $output_template_limit_array[$output_template_limit_counter]['value'] = $value['pk'];
                 $output_template_limit_array[$output_template_limit_counter]['content'] = $value['name'];
                 if ($value['pk'] == $current_limit) {
                     $output_template_limit_array[$output_template_limit_counter]['selected'] = "selected='selected'";
                 } else {
                     $output_template_limit_array[$output_template_limit_counter]['selected'] = "";
                 }
                 $output_template_limit_counter++;
             }
         }
         $output_template_field_array = array();
         $output_template_field_counter = 0;
         if (is_array($parameter_template_field_array) and count($parameter_template_field_array) >= 1) {
             foreach ($parameter_template_field_array as $key => $value) {
                 $output_template_field_array[$output_template_field_counter]['id'] = $key;
                 $output_template_field_array[$output_template_field_counter]['pk'] = $value['pk'];
                 $output_template_field_array[$output_template_field_counter]['name'] = $value['name'];
                 if (is_numeric($parameter_value_array[$value['pk']])) {
                     $regionalized_value = str_replace(".", $regional->get_decimal_separator(), $parameter_value_array[$value['pk']]);
                     $output_template_field_array[$output_template_field_counter]['value'] = $regionalized_value;
                 } else {
                     $output_template_field_array[$output_template_field_counter]['value'] = "";
                 }
                 if (is_numeric($value['min'])) {
                     $output_template_field_array[$output_template_field_counter]['min'] = $value['min'];
                 } else {
                     $output_template_field_array[$output_template_field_counter]['min'] = "";
                 }
                 if (is_numeric($value['max'])) {
                     $output_template_field_array[$output_template_field_counter]['max'] = $value['max'];
                 } else {
                     $output_template_field_array[$output_template_field_counter]['max'] = "";
                 }
                 if ($parameter_limit_array[$value['pk']]) {
                     if (is_numeric($parameter_limit_array[$value['pk']]['usl'])) {
                         $output_template_field_array[$output_template_field_counter]['usl'] = $parameter_limit_array[$value['pk']]['usl'];
                     } else {
                         $output_template_field_array[$output_template_field_counter]['usl'] = "";
                     }
                     if (is_numeric($parameter_limit_array[$value['pk']]['lsl'])) {
                         $output_template_field_array[$output_template_field_counter]['lsl'] = $parameter_limit_array[$value['pk']]['lsl'];
                     } else {
                         $output_template_field_array[$output_template_field_counter]['lsl'] = "";
                     }
                 } else {
                     if (is_numeric($parameter_template_limit_array[0]['usl'][$key])) {
                         $output_template_field_array[$output_template_field_counter]['usl'] = $parameter_template_limit_array[0]['usl'][$key];
                     } else {
                         $output_template_field_array[$output_template_field_counter]['usl'] = "";
                     }
                     if (is_numeric($parameter_template_limit_array[0]['lsl'][$key])) {
                         $output_template_field_array[$output_template_field_counter]['lsl'] = $parameter_template_limit_array[0]['lsl'][$key];
                     } else {
                         $output_template_field_array[$output_template_field_counter]['lsl'] = "";
                     }
                 }
                 if ($key == 1) {
                     $output_template_field_array[$output_template_field_counter]['class'] = "odd";
                 } else {
                     if ($output_template_field_counter % 2 == 0) {
                         $output_template_field_array[$output_template_field_counter]['class'] = "odd DataParameterTemplateField";
                     } else {
                         $output_template_field_array[$output_template_field_counter]['class'] = "evan DataParameterTemplateField";
                     }
                 }
                 if (is_numeric($value['unit'])) {
                     if ($value['unit_exponent'] < 0) {
                         $unit_exponent = $value['unit_exponent'] * -1;
                         $unit_prefix = MeasuringUnit::get_prefix($unit_exponent, false);
                     } else {
                         $unit_prefix = MeasuringUnit::get_prefix($value['unit_exponent'], true);
                     }
                     $measuring_unit = new MeasuringUnit($value['unit']);
                     $output_template_field_array[$output_template_field_counter]['unit'] = $unit_prefix[1] . "" . $measuring_unit->get_unit_symbol();
                 } elseif (is_numeric($value['unit_ratio'])) {
                     $measuring_unit_ratio = new MeasuringUnitRatio($value['unit_ratio']);
                     $output_template_field_array[$output_template_field_counter]['unit'] = $measuring_unit_ratio->get_symbol();
                 } else {
                     $output_template_field_array[$output_template_field_counter]['unit'] = "";
                 }
                 $method_counter = 1;
                 $output_template_field_array[$output_template_field_counter][0]['value'] = "0";
                 $output_template_field_array[$output_template_field_counter][0]['content'] = "none";
                 if (is_array($parameter_possible_methods_array) and is_array($parameter_possible_methods_array[$value['pk']]) and count($parameter_possible_methods_array[$value['pk']]) >= 1) {
                     foreach ($parameter_possible_methods_array[$value['pk']] as $method_key => $method_value) {
                         $output_template_field_array[$output_template_field_counter][$method_counter]['value'] = $method_key;
                         $output_template_field_array[$output_template_field_counter][$method_counter]['content'] = $method_value;
                         if ($parameter_method_array[$value['pk']] == $method_key) {
                             $output_template_field_array[$output_template_field_counter][$method_counter]['selected'] = " selected='selected'";
                         } else {
                             $output_template_field_array[$output_template_field_counter][$method_counter]['selected'] = "";
                         }
                         $method_counter++;
                     }
                 }
                 $output_template_field_counter++;
             }
         }
         $template = new HTMLTemplate("data/parameter_detail.html");
         $parameter_version_array = $parameter->get_parameter_internal_revisions();
         if (is_array($parameter_version_array) and count($parameter_version_array) > 0) {
             $result = array();
             $counter = 1;
             $result[0]['version'] = 0;
             $result[0]['text'] = "----------------------------------------------";
             $parameter_version = Parameter::get_instance($_GET['parameter_id'], true);
             foreach ($parameter_version_array as $key => $fe_value) {
                 $parameter_version->open_internal_revision($fe_value);
                 $version_datetime_handler = new DatetimeHandler($parameter_version->get_version_datetime());
                 $result[$counter]['version'] = $parameter_version->get_internal_revision();
                 $result[$counter]['text'] = "Version " . $parameter_version->get_version() . " - " . $version_datetime_handler->get_datetime();
                 $counter++;
             }
             $template->set_var("version_option", $result);
         }
         $result = array();
         $counter = 0;
         foreach ($_GET as $key => $fe_value) {
             if ($key != "version") {
                 $result[$counter]['value'] = $fe_value;
                 $result[$counter]['key'] = $key;
                 $counter++;
             }
         }
         $template->set_var("get", $result);
         $template->set_var("version", $parameter->get_version());
         $version_datetime_handler = new DatetimeHandler($parameter->get_version_datetime());
         $template->set_var("version_datetime", $version_datetime_handler->get_datetime());
         $paramquery = $_GET;
         $paramquery['action'] = "permission";
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("change_permission_params", $params);
         if ($parameter->is_control_access() == true or $parameter->get_owner_id() == $user->get_user_id()) {
             $template->set_var("change_permission", true);
         } else {
             $template->set_var("change_permission", false);
         }
         if ($parameter->is_write_access() == true or $parameter->get_owner_id() == $user->get_user_id()) {
             $template->set_var("write_permission", true);
         } else {
             $template->set_var("write_permission", false);
         }
         $paramquery = $_GET;
         $paramquery['action'] = "parameter_history";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("version_list_link", $params);
         $template->set_var("display_header", $display_header);
         $template->set_var("session_id", $_GET['session_id']);
         $template->set_var("parameter_id", $parameter_id);
         $template->set_var("type_id", $parameter_template_id);
         $template->set_var("thousand_separator", $regional->get_thousand_separator());
         $template->set_var("decimal_separator", $regional->get_decimal_separator());
         $template->set_var("name", $parameter_template->get_name());
         $template->set_var("limits", $output_template_limit_array);
         $template->set_var("fields", $output_template_field_array);
         $template->set_var("retrace", $retrace);
         $template->output();
     } else {
         throw new DataSecurityAccessDeniedException();
     }
 }
Пример #30
0
 /**
  * @param string $get_array
  * @param intger $page
  * @return integer
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectIDMissingException
  */
 public static function get_list($get_array, $page)
 {
     global $project_security, $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project_log_array = ProjectLog::list_entries_by_project_id($_GET['project_id']);
             if (!$page) {
                 $page = 1;
             }
             $entry_count = count($project_log_array);
             $number_of_pages = ceil($entry_count / constant("PROJECT_LOG_ENTRIES_PER_PAGE"));
             $template = new HTMLTemplate("project/ajax/log.html");
             $template->set_var("get_array", $get_array);
             $template->set_var("page", $page);
             $template->set_var("number_of_pages", $number_of_pages);
             if (is_array($project_log_array) and count($project_log_array) >= 1) {
                 $template->set_var("no_log", false);
                 $result = array();
                 $counter = 0;
                 if (count($project_log_array) < $page * PROJECT_LOG_ENTRIES_PER_PAGE) {
                     $max_for = count($project_log_array) % PROJECT_LOG_ENTRIES_PER_PAGE - 1;
                 } else {
                     $max_for = PROJECT_LOG_ENTRIES_PER_PAGE - 1;
                 }
                 for ($i = 0; $i <= $max_for; $i++) {
                     $entry = $page * PROJECT_LOG_ENTRIES_PER_PAGE + $i - PROJECT_LOG_ENTRIES_PER_PAGE;
                     // Erzeugt Entry-ID
                     $value = $project_log_array[$entry];
                     $project_log = new ProjectLog($value);
                     $user = new User($project_log->get_owner_id());
                     $result[$counter]['id'] = $value;
                     $result[$counter]['show_more'] = false;
                     $datetime_handler = new DatetimeHandler($project_log->get_datetime());
                     $result[$counter]['date'] = $datetime_handler->get_date();
                     $result[$counter]['time'] = $datetime_handler->get_time();
                     $result[$counter]['user'] = $user->get_full_name(false);
                     if (($content = $project_log->get_content()) != null) {
                         $content = str_replace("\n", "<br />", $content);
                         if (strlen($content) > 500) {
                             $content = substr($content, 0, 500) . "...";
                             $result[$counter]['show_more'] = true;
                         }
                         $result[$counter]['content'] = $content;
                     } else {
                         $result[$counter]['content'] = false;
                     }
                     $status_id = $project_log->get_status_id();
                     if ($status_id != null) {
                         $project_status = new ProjectStatus($status_id);
                         $result[$counter]['status'] = $project_status->get_name();
                     } else {
                         $result[$counter]['status'] = false;
                     }
                     if ($project_log->get_important() == true) {
                         $result[$counter]['important'] = true;
                     } else {
                         $result[$counter]['important'] = false;
                     }
                     $item_array = $project_log->list_items();
                     $number_of_items = count($item_array);
                     if ($number_of_items == 0) {
                         $result[$counter]['items'] = false;
                     } else {
                         if ($number_of_items == 1) {
                             $result[$counter]['items'] = $number_of_items . " Item was added";
                         } else {
                             $result[$counter]['items'] = $number_of_items . " Items were added";
                         }
                     }
                     $detail_paramquery = $_GET;
                     $detail_paramquery['run'] = "log_detail";
                     $detail_paramquery['id'] = $value;
                     $detail_params = http_build_query($detail_paramquery, '', '&#38;');
                     $result[$counter]['detail_params'] = $detail_params;
                     if ($user->is_admin()) {
                         $result[$counter]['delete'] = true;
                     } else {
                         $result[$counter]['delete'] = false;
                     }
                     $counter++;
                 }
                 $template->set_var("log_array", $result);
             } else {
                 $template->set_var("no_log", true);
             }
             if ($number_of_pages > 1) {
                 $pagebar = "<div id='ProjectLogActionSelect'></div><div class='ResultNextPageBar' id='ProjectLogPageBar'></div>";
                 $template->set_var("page_bar", $pagebar);
             } else {
                 $template->set_var("page_bar", "");
             }
             $template->output();
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }