Example #1
0
 /**
  * @param string $id
  * @return string
  * @throws BaseUserAccessDeniedException
  * @throws BaseEnvironmentPaperSizeIDMissingException
  */
 public static function delete_paper_size($id)
 {
     global $user;
     if ($user->is_admin()) {
         if (is_numeric($id)) {
             $paper_size = new PaperSize($id);
             if ($paper_size->delete() == true) {
                 return "1";
             } else {
                 return "0";
             }
         } else {
             throw new BaseEnvironmentPaperSizeIDMissingException();
         }
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }
Example #2
0
 /**
  * @throws SampleIDMissingException
  * @throws SampleSecurityAccessDeniedException
  */
 public static function detail()
 {
     global $sample_security, $user;
     if ($_GET['sample_id']) {
         if ($sample_security->is_access(1, false)) {
             $sample = new Sample($_GET['sample_id']);
             $template = new HTMLTemplate("sample/detail.html");
             $paper_size_array = PaperSize::list_entries();
             $template->set_var("title", $sample->get_formatted_id() . " : " . $sample->get_name());
             $template->set_var("paper_size_array", $paper_size_array);
             $template->set_var("get_array", serialize($_GET));
             $template->set_var("id", $sample->get_formatted_id());
             $template->output();
         } else {
             throw new SampleSecurityAccessDeniedException();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
Example #3
0
 /**
  * @return object
  * @throws SampleIDMissingException
  * @throws BaseReportTCPDFClassMissingException
  */
 public static function get_barcode_report()
 {
     if (class_exists("TCPDF")) {
         if ($_GET['sample_id']) {
             $sample_id = $_GET['sample_id'];
             if ($_GET['paper_size']) {
                 $paper_size_info_array = PaperSize::get_size_by_id($_GET['paper_size']);
             } else {
                 $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 TCPDF($orientation, "mm", $format, true, 'UTF-8', false);
             $pdf->SetCreator(PDF_CREATOR);
             $pdf->SetAuthor('Open-LIMS');
             $pdf->SetTitle('Sample Report');
             $pdf->setPrintHeader(false);
             $pdf->setPrintFooter(false);
             $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
             $pdf->SetMargins($paper_size_info_array['margin_left'], $paper_size_info_array['margin_top'], $paper_size_info_array['margin_right']);
             $pdf->SetAutoPageBreak(TRUE, $paper_size_info_array['margin_bottom']);
             $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
             $pdf->setLanguageArray($l);
             $pdf->AddPage();
             $page_width = $paper_size_info_array['width'] - $paper_size_info_array['margin_left'] - $paper_size_info_array['margin_right'];
             $page_height = $paper_size_info_array['height'] - $paper_size_info_array['margin_top'];
             $font_size = $page_height * 0.1;
             if ($page_width * 0.6 > $page_height) {
                 $barcode_height = $page_height - $font_size;
                 $barcode_width = null;
             } else {
                 $barcode_height = $page_width * 0.6;
                 $barcode_width = $page_width;
             }
             $print_sample_id = "S" . str_pad($sample_id, 8, '0', STR_PAD_LEFT);
             $style = array('position' => '', 'align' => 'C', 'stretch' => true, 'fitwidth' => false, 'cellfitalign' => '', 'border' => false, 'hpadding' => 'auto', 'vpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'text' => true, 'font' => 'helvetica', 'fontsize' => $font_size, 'stretchtext' => 4);
             $pdf->write1DBarcode($print_sample_id, 'C128B', '', '', $barcode_width, $barcode_height, 0.2, $style, 'M');
             return $pdf;
         } else {
             throw new SampleIDMissingException();
         }
     } else {
         throw new BaseReportTCPDFClassMissingException();
     }
 }