function print_report_pdf_A4($sample_id_array, $doctor) { $acr_check_code = array('-1' => '', '-2' => '', '-3' => '', '0' => '', '1' => 'low absurd', '2' => 'high absurd', '3' => 'low critical', '4' => 'high critical', '5' => 'low abnormal', '6' => 'high abnormal'); //A5=210,148 $attachment_exist = 'no'; $pdf = new MYPDF_NABL('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->sample_id_array = $sample_id_array; $pdf->doctor = $doctor; $pdf->login = $_SESSION['login']; //$pdf->SetHeaderMargin(30); //$pdf->SetFooterMargin(30); // set default monospaced font //$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins //$pdf->SetMargins(10, 100); //set auto page breaks //$pdf->SetAutoPageBreak(TRUE, 30); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //$pdf->SetFont('times', '', 10); $pdf->SetFont('courier', '', 8); //$pdf->completed=''; foreach ($sample_id_array as $value) { $pdf->sample_id = $value; $pdf->startPageGroup(); $pdf->AddPage(); $linkk = start_nchsls(); $sql_examination_data = 'select * from examination where sample_id=\'' . $pdf->sample_id . '\' order by name_of_examination'; $result_examination_data = mysql_query($sql_examination_data, $linkk); $counter = $pdf->header_y + 5; $pdf->SetFont('courier', '', 10); $border = 0; while ($examination_array = mysql_fetch_assoc($result_examination_data)) { $counter = $counter + 5; if ($examination_array['id'] < 1000) { $pdf->SetFont('courier', '', 10); $pdf->SetXY(10, $counter); $pdf->Cell($w = 10, $h = 0, $examination_array['NABL_Accredited'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetXY(20, $counter); $pdf->Cell($w = 40, $h = 0, $examination_array['name_of_examination'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); /* $pdf->SetXY(60,$counter); $pdf->Cell($w=40, $h=0, $examination_array['result'],$border, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); */ $pdf->SetXY(60, $counter); // $pdf->Cell($w=40, $h=0, $examination_array['result'],$border, $ln=0, $align='', $fill=false, $link='', // $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); //public function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0, $valign='T', $fitcell=false) { $pdf->MultiCell($w = 100, $h = 0, $examination_array['result'], $border, $align = '', $fill = false, $ln = 1, $x = $pdf->GetX(), $pdf->GetY(), $reseth = true, $stretch = 0, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = false); /* $pdf->SetXY(100,$counter); $pdf->Cell($w=40, $h=0, $examination_array['referance_range'].' '.$examination_array['unit'],$border, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); $pdf->SetXY(140,$counter); $acr=$acr_check_code[check_critical_abnormal_reportable($pdf->sample_type,$examination_array['code'],$examination_array['result'])]; $pdf->Cell($w=20, $h=0,$acr,$border, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); $pdf->SetXY(160,$counter); $pdf->Cell($w=40, $h=0,$examination_array['method_of_analysis'],$border, $ln=0, $align='', $fill=false, $link='', $stretch=1, $ignore_min_height=false, $calign='T', $valign='M'); */ if ($counter >= 260) { $counter = $pdf->header_y + 5; $pdf->AddPage(); } //148=120+28 297=270+27 } else { if ($examination_array['id'] == 1008) { $attachment_exist = 'yes'; } $counter = $counter + 2; $pdf->SetFont('courier', 'B', 12); $pdf->SetXY(10, $counter); $pdf->Cell($w = 50, $h = 0, trim($examination_array['name_of_examination'], 'Z_'), $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); $pdf->SetFont('courier', '', 10); $pdf->SetXY(60, $counter); $pdf->Cell($w = 140, $h = 0, $examination_array['result'], $border, $ln = 0, $align = '', $fill = false, $link = '', $stretch = 1, $ignore_min_height = false, $calign = 'T', $valign = 'M'); if ($counter >= 260) { $counter = $pdf->header_y + 5; $pdf->AddPage(); } } } if ($attachment_exist == 'yes') { //echo '<h2 style="page-break-before: always;"></h2>'; $y = print_attachment_A4($pdf, $pdf->sample_id, $counter); $counter = $y; } } $pdf->Output('report.pdf', 'I'); }
function print_letter($id) { $sql = 'select * from letter where id=\'' . $id . '\''; $link = start_nchsls(); if (!($result = mysql_query($sql, $link))) { echo mysql_error(); } $letter = mysql_fetch_assoc($result); $pdf = new MYPDF_NABL('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->letter = $letter; $pdf->SetMargins(10, 50); $pdf->SetAutoPageBreak(TRUE, 10); $pdf->SetFont('helvetica', '', 8); $pdf->AddPage(); $border = 0; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 50); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Subject:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 50); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['subject'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 55); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Sub-subject:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 2, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 55); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['sub_subject'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $border = 0; $max_height = 0; if (strlen($pdf->letter['reference']) > 0) { $c_str = count_chars($pdf->letter['reference'], 0); $max_height = $c_str[13] * 5 + 5; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, 60); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Reference:', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(30, 60); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['reference'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } $my_y = 55 + 5 + $max_height; $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $my_y); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['greeting'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY(10, $my_y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['body'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 10); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['thanks'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['closing'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', '', 10); $pdf->SetXY($x, $y + 5); $pdf->MultiCell($w = 190, $h = 0, $txt = $pdf->letter['signature'] . ',', $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 0, $valign = 'T', $fitcell = true); if (strlen($pdf->letter['attachment_list']) > 0) { $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $y + 10); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Attachments:', $border, $align = 'L', $fill = false, $ln = 0, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['attachment_list'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } if (strlen($pdf->letter['copy_to']) > 0) { $x = $pdf->getX(); $y = $pdf->getY(); $pdf->SetFont('helvetica', 'B', 10); $pdf->SetXY(10, $y + 10); $pdf->MultiCell($w = 20, $h = 0, $txt = 'Copy to:', $border, $align = 'L', $fill = false, $ln = 0, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = 5, $valign = 'T', $fitcell = true); $pdf->SetFont('helvetica', '', 10); $pdf->MultiCell($w = 210 - 10 - 30, $h = 0, $txt = $pdf->letter['copy_to'], $border, $align = 'L', $fill = false, $ln = 1, $x = '', $y = '', $reseth = true, $stretch = 1, $ishtml = false, $autopadding = true, $maxh = $max_height, $valign = 'T', $fitcell = true); } $filename = $pdf->letter['id'] . '-' . $pdf->letter['type'] . '-' . $pdf->letter['date'] . '.pdf'; $pdf->Output($filename, 'I'); }