public static function samples() { global $user; $template = new HTMLTemplate("sample/home/summary/my_samples.html"); $template->set_var("samples", Sample_Wrapper::count_user_samples($user->get_user_id())); return $template->get_string(); }
public static function count_categories($json_argument_array) { global $user; if ($user->is_admin()) { return Sample_Wrapper::count_list_sample_template_categories(); } else { throw new BaseUserAccessDeniedException(); } }
/** * @see SampleItemFactoryInterface::create() * @param integer $sample_id * @param integer $item_id * @param integer $gid * @param string $keywords * @param string $description * @param bool $parent * @return bool */ public static function create($sample_id, $item_id, $gid, $keywords = null, $description = null, $parent_item_id = null, $parent_sample = false, $parent_is_parent_sample = false) { global $transaction; if ($transaction->is_in_transction() == true) { $sample = new Sample($sample_id); $sample_item = new SampleItem($sample_id); $sample_item->set_gid($gid); $sample_item->set_parent($parent_sample); // For parent sample only $sample_item->set_parent_item_id($parent_item_id); if ($sample_item->set_item_id($item_id) == false) { return false; } if ($sample_item->link_item() == false) { return false; } if (($class_name = $sample_item->is_classified()) == true) { if ($sample_item->set_class($class_name) == false) { return false; } } $description_required = $sample_item->is_description(); $keywords_required = $sample_item->is_keywords(); if ($description_required == true xor $keywords_required == true) { if ($description_required == false and $keywords_required == true) { $sample_item->set_information(null, $keywords); } else { $sample_item->set_information($description, null); } } else { if ($description_required == true and $keywords_required == true) { $sample_item->set_information($description, $keywords); } } $item_holder_type_array = Item::list_holders(); $item_holder_id_array = array(); if (is_array($item_holder_type_array) and count($item_holder_type_array) >= 1) { foreach ($item_holder_type_array as $key => $value) { $item_holder_id_array[$key] = $value::list_item_holders_by_item_id($sample->get_item_id()); if ($key == "sample" and $parent_is_parent_sample == true) { $item_holder_id_array[$key] = array_merge($item_holder_id_array[$key], Sample_Wrapper::get_sample_id_and_gid_by_parent_sample_id($sample_id)); } } } $item_holder_add_event = new ItemHolderAddEvent($item_holder_id_array, $sample->get_item_id(), $item_id, $gid); $event_handler = new EventHandler($item_holder_add_event); if ($event_handler->get_success() == false) { return false; } return true; } else { return false; } }
/** * @param string $json_argument_array * @return integer * @throws SampleIDMissingException */ public static function count_organisation_unit_permissions($json_argument_array) { $argument_array = json_decode($json_argument_array); $sample_id = $argument_array[1]; if (is_numeric($sample_id)) { return Sample_Wrapper::count_sample_organisation_units($sample_id); } else { throw new SampleIDMissingException(); } }
/** * @param string $json_argument_array * @return integer * @throws BaseAjaxArgumentMissingException */ public static function count_samples($json_argument_array) { $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]; return Sample_Wrapper::count_sample_search($name, $organisation_unit_array, $template_array, $in_id, $in_name); } else { throw new BaseAjaxArgumentMissingException(); } }
/** * @see SampleItemInterface::unlink_item_full() * @return bool */ public function unlink_item_full() { global $transaction; if ($this->item_id) { $transaction_id = $transaction->begin(); if (Sample_Wrapper::delete_data_entity_sub_item_links($this->item_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } if (SampleHasItem_Access::delete_sub_items($this->item_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } $sample_has_item_pk_array = SampleHasItem_Access::list_entries_by_item_id_pk($this->item_id); if (is_array($sample_has_item_pk_array)) { if (count($sample_has_item_pk_array) >= 1) { foreach ($sample_has_item_pk_array as $key => $value) { $sample_has_item = new SampleHasItem_Access($value); if ($sample_has_item->delete() == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } return false; } } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { return true; } } else { return false; } } else { return false; } }
/** * @param string $json_argument_array * @return integer * @throws BaseAjaxArgumentMissingException */ public static function count_samples($json_argument_array) { $argument_array = json_decode($json_argument_array); if (is_array($argument_array)) { $string = $argument_array[0][1]; $sample_id_array = $argument_array[1][1]; $item_type_array = $argument_array[2][1]; return Sample_Wrapper::count_data_search($string, $sample_id_array, $item_type_array); } else { throw new BaseAjaxArgumentMissingException(); } }
/** * @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; } }