/** * @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, '', '&'); $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(); } }
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(); }
/** * @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, '', '&'); $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, '', '&'); $template->set_var("location_history_params", $location_history_params); $template->output(); } } else { throw new SampleIDMissingException(); } }
/** * @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, '', '&'); $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(); } }
/** * @return object * @throws SampleIDMissingException * @throws BaseReportTCPDFClassMissingException */ public static function get_full_report() { if (class_exists("TCPDF")) { if ($_GET['sample_id']) { $sample_id = $_GET['sample_id']; $sample = new Sample($sample_id); $owner = new User($sample->get_owner_id()); $owner_name = str_replace(" ", " ", $owner->get_full_name(false)); $paper_size_info_array = PaperSize::get_standard_size(); $format = array($paper_size_info_array['width'], $paper_size_info_array['height']); if ($paper_size_info_array['width'] >= $paper_size_info_array['height']) { $orientation = "L"; } else { $orientation = "P"; } $pdf = new SamplePDF($sample_id, $sample->get_name(), $orientation, "mm", $format, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Open-LIMS'); $pdf->SetTitle('Sample Report'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins($paper_size_info_array['margin_left'], $paper_size_info_array['margin_top'] * 3, $paper_size_info_array['margin_right']); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, $paper_size_info_array['margin_bottom']); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->setFontSubsetting(true); $pdf->SetFont('dejavusans', '', 14, '', true); $pdf->AddPage(); $print_sample_id = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT); $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0); $pdf->SetFillColor(255, 255, 255); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(90, 0, "ID", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $pdf->MultiCell(100, 0, $print_sample_id, 1, '', 1, 1, '', '', true, 0, false, true, 0); $pdf->MultiCell(90, 0, "Name", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $pdf->MultiCell(100, 0, $sample->get_name(), 1, '', 1, 1, '', '', true, 0, false, true, 0); $pdf->MultiCell(90, 0, "Type/Template", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $pdf->MultiCell(100, 0, $sample->get_template_name(), 1, '', 1, 1, '', '', true, 0, false, true, 0); $pdf->MultiCell(90, 0, "Owner", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $pdf->MultiCell(100, 0, $owner_name, 1, '', 1, 1, '', '', true, 0, false, true, 0); $pdf->MultiCell(90, 0, "Status", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); if ($sample->get_availability() == true) { $pdf->MultiCell(100, 0, "available", 1, '', 1, 1, '', '', true, 0, false, true, 0); } else { $pdf->MultiCell(100, 0, "not available", 1, '', 1, 1, '', '', true, 0, false, true, 0); } $pdf->MultiCell(90, 0, "Date/Time", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $datetime = new DatetimeHandler($sample->get_datetime()); $pdf->MultiCell(100, 0, $datetime->get_datetime(false), 1, '', 1, 1, '', '', true, 0, false, true, 0); if ($sample->get_manufacturer_id()) { $manufacturer = new Manufacturer($sample->get_manufacturer_id()); $pdf->MultiCell(90, 0, "Manufacturer", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $pdf->MultiCell(100, 0, $manufacturer->get_name(), 1, '', 1, 1, '', '', true, 0, false, true, 0); } if ($sample->get_date_of_expiry()) { $pdf->MultiCell(90, 0, "Date of Expiry", 1, 'L', 1, 0, '', '', true, 0, false, true, 0); $date_of_expiry = new DatetimeHandler($sample->get_date_of_expiry()); $pdf->MultiCell(100, 0, $date_of_expiry->get_date(), 1, '', 1, 1, '', '', true, 0, false, true, 0); } $module_dialog_array = ModuleDialog::list_dialogs_by_type("item_report"); if (is_array($module_dialog_array) and count($module_dialog_array) >= 1) { foreach ($module_dialog_array as $key => $value) { if (file_exists($value['class_path'])) { require_once $value['class_path']; if (class_exists($value['class'])) { if (method_exists($value['class'], $value['method'])) { $sql = " SELECT item_id FROM " . constant("SAMPLE_HAS_ITEM_TABLE") . " WHERE sample_id = " . $_GET['sample_id'] . ""; $pdf = $value['class']::$value['method']($sql, $sample->get_item_id(), $pdf); } } } } } return $pdf; } else { throw new SampleIDMissingException(); } } else { throw new BaseReportTCPDFClassMissingException(); } }