preparing for 5.0.1 release in several weeks (#1509)
[openemr.git] / interface / patient_file / barcode_label.php
blob74aaa8e9c2ecbe62a959cd04835d827b161bfc4a
1 <?php
2 /**
3 * interface/patient_file/barcode_label.php Displaying a PDF file of Labels for printing.
5 * Program for displaying Barcode Label
6 * via the popups on the left nav screen
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lillysystems.com>
23 * @link http://www.open-emr.org
25 * this is from the barcode-coder and FPDF website I used the examples and code snippets listed on the sites
26 * to create this program
31 require_once("../globals.php");
33 //Get the data to place on labels
35 $patdata = sqlQuery("SELECT " .
36 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
37 "p.street, p.city, p.state, p.postal_code, p.pid " .
38 "FROM patient_data AS p " .
39 "WHERE p.pid = ? LIMIT 1", array($pid));
43 $today = date('m/d/Y');
44 $dob = substr($patdata['DOB'], 5, 2) ."/". Substr($patdata['DOB'], 8, 2) ."/". Substr($patdata['DOB'], 0, 4);
48 // -------------------------------------------------- //
49 // BARCODE DATA AND TYPE
50 // -------------------------------------------------- //
52 $code = $patdata['pubpid']; // what is wanted as the barcode
53 $bartype = $GLOBALS['barcode_label_type'] ; // Get barcode type
55 switch ($bartype) {
56 case '1':
57 $type = 'std25';
58 break;
59 case '2':
60 $type = 'int25';
61 break;
62 case '3':
63 $type = 'ean8';
64 break;
65 case '4':
66 $type = 'ean13';
67 break;
68 case '5':
69 $type = 'upc';
70 break;
71 case '6':
72 $type = 'code11';
73 break;
74 case '7':
75 $type = 'code39';
76 break;
77 case '8':
78 $type = 'code93';
79 break;
80 case '9':
81 $type = 'code128';
82 break;
83 case '10':
84 $type = 'codabar';
85 break;
86 case '11':
87 $type = 'msi';
88 break;
89 case '12':
90 $type = 'datamatrix';
91 break;
94 // -------------------------------------------------- //
95 // PROPERTIES
96 // -------------------------------------------------- //
97 $fontSize = 28;
98 $angle = 90; // rotation in degrees
99 $black = '000000'; // color in hexa
101 if ($GLOBALS['barcode_label_type'] == '12') { // datamatrix
102 $marge = 0; // between barcode and hri in pixel
103 $x = 35; // barcode center
104 $y = 120; // barcode center
105 $height = 40; // barcode height in 1D ; module size in 2D
106 $width = 4; // barcode height in 1D ; not use in 2D
107 } else {
108 $marge = 5; // between barcode and hri in pixel
109 $x = 30; // barcode center
110 $y = 120; // barcode center
111 $height = 40; // barcode height in 1D ; module size in 2D
112 $width = 1; // barcode height in 1D ; not use in 2D
115 // -------------------------------------------------- //
116 // ALLOCATE FPDF RESSOURCE
117 // -------------------------------------------------- //
119 $pdf = new eFPDF('P', 'mm', array(102,252)); // set the orentation, unit of measure and size of the page
120 $pdf->AddPage();
122 // -------------------------------------------------- //
123 // BARCODE
124 // -------------------------------------------------- //
126 $data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
127 $pdf->SetFont('Arial', 'B', $fontSize);
128 $pdf->SetTextColor(0, 0, 0);
129 $len = $pdf->GetStringWidth($data['hri']);
130 Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
132 // -------------------------------------------------- //
133 // OUTPUT
134 // -------------------------------------------------- //
136 $pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
137 $pdf->Output();