Exemplo n.º 1
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
  * @throws BaseAjaxDependentArgumentMissingException
  */
 public static function list_sample_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);
     $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]);
     } else {
         throw new BaseAjaxArgumentMissingException();
     }
     if ($sql) {
         $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 = Sample_Wrapper::list_item_samples($sql, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         } else {
             $list_array = Sample_Wrapper::list_item_samples($sql, $sortvalue, $sortmethod, 0, null);
         }
         $list_request->set_column_array($json_column_array);
         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) {
                 $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;
                 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='sample-" . $list_array[$key]['item_id'] . "' value='1' class='" . $checkbox_class . "' checked='checked' />";
                     } else {
                         $list_array[$key]['checkbox'] = "<input type='checkbox' name='sample-" . $list_array[$key]['item_id'] . "' value='1' checked='checked' />";
                     }
                     $list_array[$key]['symbol'] = "<img src='images/icons/sample.png' alt='' style='border:0;' />";
                     $list_array[$key]['sid'] = "S" . str_pad($list_array[$key]['id'], 8, '0', STR_PAD_LEFT);
                 } else {
                     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]['sid']['link'] = $params;
                         $list_array[$key]['sid']['content'] = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT);
                         $list_array[$key]['name']['link'] = $params;
                     } else {
                         $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/icons/sample.png' alt='N' border='0' />";
                         $list_array[$key]['sid'] = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT);
                     }
                 }
                 $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']);
                 $list_array[$key]['datetime'] = $datetime_handler->get_date();
                 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 Samples found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseAjaxDependentArgumentMissingException();
     }
 }
Exemplo n.º 2
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;
     }
 }