Пример #1
0
 /**
  * @Then name of id :arg1 should be :arg2
  */
 public function nameOfIdShouldBe($arg1, $arg2)
 {
     $data = new Sample();
     $rows = $data->get_name($arg1);
     //      print_r( $rows);
     if (sizeof($rows) != 1) {
         throw new Exception("Name is not present.\n");
     } else {
         if ($rows[0]['name'] != $arg2) {
             throw new Exception("Name did not match.\n");
         }
     }
 }
Пример #2
0
 /**
  * @throws SampleIDMissingException
  * @throws SampleSecurityAccessDeniedException
  */
 public static function rename()
 {
     global $user;
     if ($_GET['sample_id']) {
         $sample_id = $_GET['sample_id'];
         $sample = new Sample($sample_id);
         if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) {
             if ($_GET['nextpage'] == 1) {
                 if ($_POST['name']) {
                     $page_1_passed = true;
                 } else {
                     $page_1_passed = false;
                     $error = "You must enter a name";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("sample/int_admin/rename.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 if ($_POST['name']) {
                     $template->set_var("name", $_POST['name']);
                 } else {
                     $template->set_var("name", trim($sample->get_name()));
                 }
                 $template->output();
             } else {
                 $paramquery = $_GET;
                 unset($paramquery['nextpage']);
                 $paramquery['run'] = "detail";
                 $params = http_build_query($paramquery);
                 if ($sample->set_name($_POST['name'])) {
                     Common_IO::step_proceed($params, "Rename Sample", "Operation Successful", null);
                 } else {
                     Common_IO::step_proceed($params, "Rename Sample", "Operation Failed", null);
                 }
             }
         } else {
             throw new SampleSecurityAccessDeniedException();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
Пример #3
0
 /**
  * Creates a new Sample Folder including Folder
  * @param integer $sample_id
  * @return integer
  */
 public function create($sample_id)
 {
     if (is_numeric($sample_id)) {
         $sample = new Sample($sample_id);
         // Folder
         $sample_folder_id = constant("SAMPLE_FOLDER_ID");
         $folder = new Folder($sample_folder_id);
         $path = new Path($folder->get_path());
         $path->add_element($sample_id);
         $name = $sample->get_name() . " (" . $sample->get_formatted_id() . ")";
         if (($folder_id = parent::create($name, $sample_folder_id, $path->get_path_string(), $sample->get_owner_id(), null)) != null) {
             $sample_has_folder_access = new SampleHasFolder_Access(null);
             if ($sample_has_folder_access->create($sample_id, $folder_id) == null) {
                 return null;
             }
             // Virtual Folders (Event)
             $sample_folder_create_event = new SampleFolderCreateEvent($folder_id);
             $event_handler = new EventHandler($sample_folder_create_event);
             if ($event_handler->get_success() == false) {
                 $this->delete();
                 return false;
             } else {
                 return $folder_id;
             }
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Пример #4
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, '', '&');
             $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();
     }
 }
Пример #5
0
 /**
  * @throws SampleIDMissingException
  * @throws SampleSecurityAccessDeniedException
  */
 public static function location_history()
 {
     global $sample_security;
     if ($_GET['sample_id']) {
         if ($sample_security->is_access(1, false)) {
             $argument_array = array();
             $argument_array[0] = "sample_id";
             $argument_array[1] = $_GET['sample_id'];
             $list = new List_IO("SampleLocationHistory", "ajax.php?nav=sample", "list_location_history", "count_location_history", $argument_array, "SampleLocationHistory");
             $list->add_column("", "symbol", false, "16px");
             $list->add_column(Language::get_message("SampleGeneralListColumnName", "general"), "name", true, null);
             $list->add_column(Language::get_message("SampleGeneralListColumnDateTime", "general"), "datetime", true, null);
             $list->add_column(Language::get_message("SampleGeneralListColumnUser", "general"), "user", true, null);
             $template = new HTMLTemplate("sample/location_history.html");
             $sample = new Sample($_GET['sample_id']);
             $template->set_var("sample_id", $sample->get_formatted_id());
             $template->set_var("sample_name", "(" . $sample->get_name() . ")");
             $template->set_var("list", $list->get_list());
             $template->output();
         } else {
             throw new SampleSecurityAccessDeniedException();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
Пример #6
0
<?php

error_reporting(-1);
ini_set('display_errors', 1);
echo '
    <html>
    <head><title>Sample Page</title></head>
    <body>';
echo '<h1>Sample Page Headline</h1>';
//  phpinfo();
include_once 'Sample.php';
$sample = new Sample();
$sample->init();
$sample->set('Tom', 10);
$sample->set('Joe', 20);
$sample->set('Che', 30);
$names = $sample->get_name(10);
echo "<p>ID: {$names[0]['id']} Name: {$names[0]['name']}</p>";
$names = $sample->get_name(30);
echo "<p>ID: {$names[0]['id']} Name: {$names[0]['name']}</p>";
$ids = $sample->get_id('Joe');
echo "<p>ID: {$ids[0]['id']} Name: {$ids[0]['name']}</p>";
echo '</body></html>';
Пример #7
0
 public static function search()
 {
     global $user, $session;
     if ($_GET['nextpage']) {
         if ($_GET['sortvalue'] and $_GET['sortmethod']) {
             if ($_GET['nextpage'] == "2" and $_POST['string']) {
                 $string = $_POST['string'];
                 $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE");
                 $sample_id_array = $session->read_value("SEARCH_DATA_SAMPLE_ID");
             } else {
                 $string = $session->read_value("SEARCH_DATA_STRING");
                 $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE");
                 $sample_id_array = $session->read_value("SEARCH_DATA_SAMPLE_ID");
             }
         } else {
             if ($_GET['page']) {
                 $string = $session->read_value("SEARCH_DATA_STRING");
                 $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE");
                 $sample_id_array = $session->read_value("SEARCH_DATA_SAMPLE_ID");
             } else {
                 if ($_GET['nextpage'] == "1") {
                     $string = $_POST['string'];
                     $session->delete_value("SEARCH_DATA_STRING");
                     $session->delete_value("SEARCH_DATA_ITEM_TYPE");
                     $session->delete_value("SEARCH_DATA_SAMPLE_ID");
                 } else {
                     $string = $_POST['string'];
                     $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE");
                     $sample_id_array = $session->read_value("SEARCH_DATA_SAMPLE_ID");
                 }
             }
         }
         $no_error = true;
     } else {
         $no_error = false;
     }
     if ($no_error == false) {
         $template = new HTMLTemplate("sample/search/data_search.html");
         $template->set_var("error", "");
         $paramquery = $_GET;
         unset($paramquery['page']);
         $paramquery['nextpage'] = "1";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("params", $params);
         $result = array();
         $counter = 0;
         $sample_array = Sample::list_user_related_samples($user->get_user_id(), false);
         if (is_array($sample_array)) {
             foreach ($sample_array as $key => $value) {
                 $sample = new Sample($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $sample->get_name();
                 $result[$counter]['selected'] = "";
                 $counter++;
             }
         }
         $template->set_var("sample_array", $result);
         $result = array();
         $counter = 0;
         $item_type_array = Item::list_types();
         if (is_array($item_type_array)) {
             foreach ($item_type_array as $key => $value) {
                 if (class_exists($value)) {
                     if ($value::get_sql_select_array($key) != null) {
                         $result[$counter]['title'] = $value::get_generic_name($key, null);
                         $result[$counter]['name'] = "item-" . $key;
                         $result[$counter]['value'] = $key;
                         $result[$counter]['checked'] = "checked='checked'";
                         $counter++;
                     }
                 }
             }
         }
         $template->set_var("item_type_array", $result);
         $template->output();
     } else {
         if (!$sample_id_array) {
             if ($_POST['sample_id'] == 0) {
                 $sample_id_array = array();
                 $tmp_id_array = Sample::list_user_related_samples($user->get_user_id(), false);
                 if (is_array($tmp_id_array) and count($tmp_id_array) >= 1) {
                     foreach ($tmp_id_array as $key => $value) {
                         array_push($sample_id_array, $value);
                     }
                 }
             } else {
                 $sample_id_array = array();
                 $sample_id_array[0] = $_POST['sample_id'];
                 $sample = new Sample($_POST['sample_id']);
                 $search_name = $sample->get_name();
             }
         } else {
             if (count($sample_id_array) == 1) {
                 $sample = new Sample($sample_id_array[0]);
                 $search_name = $sample->get_name();
             } else {
                 $search_name = "All";
             }
         }
         if (!$item_type_array) {
             $item_type_array = array();
             foreach ($_POST as $key => $value) {
                 if (strpos($key, "item-") === 0) {
                     array_push($item_type_array, $value);
                 }
             }
             if (!$item_type_array) {
                 $tmp_item_type_array = Item::list_types();
                 foreach ($tmp_item_type_array as $key => $value) {
                     if (class_exists($value)) {
                         if ($value::get_sql_select_array($key) != null) {
                             array_push($item_type_array, $key);
                         }
                     }
                 }
             }
         }
         $session->write_value("SEARCH_DATA_STRING", $string, true);
         $session->write_value("SEARCH_DATA_ITEM_TYPE", $item_type_array, true);
         $session->write_value("SEARCH_DATA_SAMPLE_ID", $sample_id_array, true);
         $argument_array = array();
         $argument_array[0][0] = "string";
         $argument_array[0][1] = $string;
         $argument_array[1][0] = "sample_id_array";
         $argument_array[1][1] = $sample_id_array;
         $argument_array[2][0] = "item_type_array";
         $argument_array[2][1] = $item_type_array;
         $list = new List_IO("SampleDataSearch", "ajax.php?nav=sample", "search_sample_data_list_samples", "search_sample_data_count_samples", $argument_array, "SampleDataSearch");
         $list->add_column("", "symbol", false, "16px");
         $list->add_column(Language::get_message("SampleGeneralListColumnName", "general"), "name", true, null);
         $list->add_column(Language::get_message("SampleGeneralListColumnType", "general"), "type", false, null);
         $list->add_column(Language::get_message("SampleGeneralListColumnDateTime", "general"), "datetime", true, null);
         $list->add_column(Language::get_message("SampleGeneralListColumnSample", "general"), "sample_name", true, null);
         $template = new HTMLTemplate("sample/search/data_search_result.html");
         $paramquery = $_GET;
         $paramquery['nextpage'] = "2";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("params", $params);
         $template->set_var("string", $string);
         $template->set_var("list", $list->get_list());
         $template->output();
     }
 }
Пример #8
0
 /**
  * @param integer $page
  * @return string
  * @throws BaseAssistantRequestPageNotExistsException
  */
 public static function get_content($page)
 {
     global $session, $user;
     switch ($page) {
         case "1":
             $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT");
             $template = new HTMLTemplate("sample/new_sample_page_1.html");
             $result = array();
             $counter = 0;
             $organisation_unit_array = OrganisationUnit::list_entries();
             foreach ($organisation_unit_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 if ($organisation_unit->is_permission($user->get_user_id()) and $organisation_unit->get_stores_data() == true) {
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $organisation_unit->get_name();
                     if ($sample_organ_unit == $value) {
                         $result[$counter]['selected'] = "selected";
                     } else {
                         $result[$counter]['selected'] = "";
                     }
                     $result[$counter]['disabled'] = "";
                     $counter++;
                 }
             }
             if (!$result) {
                 $result[$counter]['value'] = "0";
                 $result[$counter]['content'] = "NO ORGANISATION UNIT FOUND!";
                 $result[$counter]['selected'] = "";
                 $result[$counter]['disabled'] = "disabled='disabled'";
             }
             $template->set_var("option", $result);
             return $template->get_string();
             break;
         case "2":
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $type_array = $session->read_value("SAMPLE_ITEM_TYPE_ARRAY");
             $template = new HTMLTemplate("sample/new_sample_page_2.html");
             if (!is_array($type_array) or count($type_array) == 0) {
                 $type_array = null;
             }
             $result = array();
             $counter = 0;
             $sample_template_array = SampleTemplate::list_entries();
             if (is_array($sample_template_array)) {
                 foreach ($sample_template_array as $key => $value) {
                     if ($type_array == null or in_array($value, $type_array)) {
                         $sample_sub_template = new SampleTemplate($value);
                         $result[$counter]['value'] = $value;
                         $result[$counter]['content'] = $sample_sub_template->get_name();
                         if ($sample_template == $value) {
                             $result[$counter]['selected'] = "selected";
                         } else {
                             $result[$counter]['selected'] = "";
                         }
                         $result[$counter]['disabled'] = "";
                         $counter++;
                     }
                 }
             } else {
                 $result[$counter]['value'] = "0";
                 $result[$counter]['content'] = "NO TEMPLATES FOUND!";
                 $result[$counter]['selected'] = "";
                 $result[$counter]['disabled'] = "disabled='disabled'";
             }
             $template->set_var("option", $result);
             if ($session->is_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']) == true) {
                 $template->set_var("keywords", $session->read_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']));
             } else {
                 $template->set_var("keywords", "");
             }
             if ($session->is_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']) == true) {
                 $template->set_var("description", $session->read_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']));
             } else {
                 $template->set_var("description", "");
             }
             return $template->get_string();
             break;
         case "3":
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_name = $session->read_value("SAMPLE_NAME");
             $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID");
             $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME");
             $sample_location = $session->read_value("SAMPLE_LOCATION");
             $sample_expiry = $session->read_value("SAMPLE_EXPIRY");
             $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING");
             $sample_description = $session->read_value("SAMPLE_DESCRIPTION");
             $sample_template_obj = new SampleTemplate($sample_template);
             $information_fields = $sample_template_obj->get_information_fields();
             $template = new HTMLTemplate("sample/new_sample_page_3.html");
             if ($information_fields['manufacturer']['name'] and $information_fields['manufacturer']['requirement'] != "optional") {
                 $template->set_var("check_manufacturer", true);
             } else {
                 $template->set_var("check_manufacturer", false);
             }
             if ($information_fields['expiry']['name'] and $information_fields['expiry']['requirement'] != "optional") {
                 $template->set_var("check_expiry", true);
             } else {
                 $template->set_var("check_expiry", false);
             }
             if ($information_fields['location']['name'] and $information_fields['location']['requirement'] != "optional") {
                 $template->set_var("check_location", true);
             } else {
                 $template->set_var("check_location", false);
             }
             if ($sample_name) {
                 $template->set_var("name", $sample_name);
             } else {
                 $template->set_var("name", "");
             }
             if ($information_fields['manufacturer']['name']) {
                 require_once "core/modules/manufacturer/io/manufacturer.io.php";
                 $template->set_var("show_manufacturer", true);
                 $template->set_var("manufacturer_html", ManufacturerIO::dialog());
             } else {
                 $template->set_var("show_manufacturer", false);
                 $template->set_var("manufacturer_html", "");
             }
             if ($information_fields['expiry']['name']) {
                 $template->set_var("show_expiry", true);
             } else {
                 $template->set_var("show_expiry", false);
             }
             if ($information_fields['location']['name']) {
                 $template->set_var("show_location", true);
                 $result = array();
                 $counter = 0;
                 $sample_location_array = Location::list_entries();
                 if (is_array($sample_location_array) and count($sample_location_array) >= 1) {
                     foreach ($sample_location_array as $key => $value) {
                         $sample_location_obj = new Location($value);
                         $result[$counter]['value'] = $value;
                         $result[$counter]['content'] = $sample_location_obj->get_name(true);
                         if ($sample_location == $value) {
                             $result[$counter]['selected'] = "selected";
                         } else {
                             $result[$counter]['selected'] = "";
                         }
                         $counter++;
                     }
                 } else {
                     $result[$counter]['value'] = "0";
                     $result[$counter]['content'] = "NO LOCATIONS FOUND!";
                 }
                 $template->set_var("location", $result);
             } else {
                 $template->set_var("show_location", false);
             }
             if ($sample_manufacturer) {
                 $template->set_var("manufacturer", $sample_manufacturer);
             } else {
                 $template->set_var("manufacturer", "");
             }
             if ($sample_manufacturer_name) {
                 $template->set_var("manufacturer_name", $sample_manufacturer_name);
             } else {
                 $template->set_var("manufacturer_name", "");
             }
             if ($sample_expiry) {
                 $template->set_var("expiry", $sample_expiry);
             } else {
                 $template->set_var("expiry", "");
             }
             if ($sample_expiry_warning) {
                 $template->set_var("expiry_warning", $sample_expiry_warning);
             } else {
                 $template->set_var("expiry_warning", (int) Registry::get_value("sample_default_expiry_warning"));
             }
             if ($sample_description) {
                 $template->set_var("desc", $sample_description);
             } else {
                 $template->set_var("desc", "");
             }
             return $template->get_string();
             break;
         case "4":
             $sample_add_role = $session->read_value("SAMPLE_ADD_ROLE");
             $sample_add_item_holder_class = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_CLASS");
             $sample_add_item_holder_id = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_ID");
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_template_data_type = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE");
             $sample_template_data_type_id = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE_ID");
             $sample_template_data_array = $session->read_value("SAMPLE_TEMPLATE_DATA_ARRAY");
             $sample_template_obj = new SampleTemplate($sample_template);
             $required_array = $sample_template_obj->get_required_requirements();
             if (is_array($required_array) and count($required_array) >= 1) {
                 $value_type_id = 0;
                 $sample_count = 0;
                 $is_value = false;
                 $is_sample = false;
                 foreach ($required_array as $key => $value) {
                     if ($value['xml_element'] == "item") {
                         if ($value['type'] == "value") {
                             $is_value = true;
                         } elseif ($value['type'] == "parentsample") {
                             $is_sample = true;
                             $sample_count++;
                         }
                     }
                     if ($value['xml_element'] == "type" and !$value['close'] and $is_value == true) {
                         $value_type_id = $value['id'];
                     }
                 }
                 if ($is_value == true xor $is_sample == true) {
                     if ($is_value == true) {
                         $template = new HTMLTemplate("sample/new_sample_page_4_value.html");
                         require_once "core/modules/data/io/value_form.io.php";
                         $value_form_io = new ValueFormIO(null, $value_type_id, null, $sample_template_data_array);
                         $value_form_io->set_field_class("SampleCreateAssistantField");
                         $template->set_var("content", $value_form_io->get_content());
                         $template->set_var("template_data_type_id", $value_type_id);
                         return $template->get_string();
                     } else {
                         $template = new HTMLTemplate("sample/new_sample_page_4_sample.html");
                         if ($sample_count > 0) {
                             $result = array();
                             if ($sample_add_role == "item" and is_numeric($sample_add_item_holder_id) and class_exists($sample_add_item_holder_class)) {
                                 $item_holder_list_sql = $sample_add_item_holder_class::get_item_list_sql($sample_add_item_holder_id);
                                 if ($item_holder_list_sql) {
                                     $sample_array = Sample::list_samples_by_item_sql_list($item_holder_list_sql);
                                 } else {
                                     $sample_array = Sample::list_user_related_samples($user->get_user_id());
                                 }
                             } else {
                                 $sample_array = Sample::list_user_related_samples($user->get_user_id());
                             }
                             for ($i = 0; $i <= $sample_count - 1; $i++) {
                                 $result[$i]['id'] = $i + 1;
                                 if ($sample_template_data_type == "sample") {
                                     if ($sample_template_data_array['sample-' . $result[$i]['id'] . '']) {
                                         $selected_id = $sample_template_data_array['sample-' . $result[$i]['id'] . ''];
                                     }
                                 }
                                 if (is_array($sample_array) and count($sample_array) >= 1) {
                                     $counter = 0;
                                     foreach ($sample_array as $key => $value) {
                                         $sample = new Sample($value);
                                         $result[$i][$counter]['value'] = $value;
                                         $result[$i][$counter]['content'] = $sample->get_name();
                                         if ($selected_id == $value) {
                                             $result[$i][$counter]['selected'] = "selected";
                                         } else {
                                             $result[$i][$counter]['selected'] = "";
                                         }
                                         $counter++;
                                     }
                                 } else {
                                     $result[$i][0]['value'] = 0;
                                     $result[$i][0]['content'] = "You have no samples";
                                     $result[$i][0]['selected'] = "";
                                 }
                                 unset($selected_id);
                             }
                             $template->set_var("sample", $result);
                         }
                         return $template->get_string();
                     }
                 } else {
                     $template = new HTMLTemplate("sample/new_sample_page_4_error.html");
                     return $template->get_string();
                 }
             } else {
                 $template = new HTMLTemplate("sample/new_sample_page_4_error.html");
                 return $template->get_string();
             }
             break;
         case "5":
             $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT");
             $sample_template = $session->read_value("SAMPLE_TEMPLATE");
             $sample_name = $session->read_value("SAMPLE_NAME");
             $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID");
             $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME");
             $sample_location = $session->read_value("SAMPLE_LOCATION");
             $sample_expiry = $session->read_value("SAMPLE_EXPIRY");
             $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING");
             $sample_description = $session->read_value("SAMPLE_DESCRIPTION");
             $template = new HTMLTemplate("sample/new_sample_page_5.html");
             $organisation_unit = new OrganisationUnit($sample_organ_unit);
             $template->set_var("sample_organisation_unit", $organisation_unit->get_name());
             $sample_template_obj = new SampleTemplate($sample_template);
             $template->set_var("sample_template", $sample_template_obj->get_name());
             $template->set_var("sample_name", $sample_name);
             if ($sample_manufacturer) {
                 $template->set_var("sample_manufacturer", $sample_manufacturer_name);
             } else {
                 $template->set_var("sample_manufacturer", false);
             }
             if ($sample_location) {
                 $sample_location_obj = new Location($sample_location);
                 $template->set_var("sample_location", $sample_location_obj->get_name(true));
             } else {
                 $template->set_var("sample_location", false);
             }
             if ($sample_expiry) {
                 $template->set_var("sample_date_of_expiry", $sample_expiry);
             } else {
                 $template->set_var("sample_date_of_expiry", false);
             }
             if ($sample_desc) {
                 $sample_desc_display = str_replace("\n", "<br />", $sample_desc);
                 $template->set_var("sample_description", $sample_desc_display);
             } else {
                 $template->set_var("sample_description", "<span class='italic'>None</span>");
             }
             return $template->get_string();
             break;
         default:
             throw new BaseAssistantRequestedPageNotExistsException();
             break;
     }
 }
Пример #9
0
 /**
  * @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("&nbsp;", " ", $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();
     }
 }