bug fix for note save return after fancybox replace. (#1320)
[openemr.git] / interface / patient_file / barcode_label.php
blob3ae16d97bde526297508ca8609cbaa43384f1ced
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
34 require_once("../globals.php");
36 //Get the data to place on labels
38 $patdata = sqlQuery("SELECT " .
39 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
40 "p.street, p.city, p.state, p.postal_code, p.pid " .
41 "FROM patient_data AS p " .
42 "WHERE p.pid = ? LIMIT 1", array($pid));
46 $today = date('m/d/Y');
47 $dob = substr($patdata['DOB'], 5, 2) ."/". Substr($patdata['DOB'], 8, 2) ."/". Substr($patdata['DOB'], 0, 4);
51 // -------------------------------------------------- //
52 // BARCODE DATA AND TYPE
53 // -------------------------------------------------- //
55 $code = $patdata['pubpid']; // what is wanted as the barcode
56 $bartype = $GLOBALS['barcode_label_type'] ; // Get barcode type
58 switch ($bartype) {
59 case '1':
60 $type = 'std25';
61 break;
62 case '2':
63 $type = 'int25';
64 break;
65 case '3':
66 $type = 'ean8';
67 break;
68 case '4':
69 $type = 'ean13';
70 break;
71 case '5':
72 $type = 'upc';
73 break;
74 case '6':
75 $type = 'code11';
76 break;
77 case '7':
78 $type = 'code39';
79 break;
80 case '8':
81 $type = 'code93';
82 break;
83 case '9':
84 $type = 'code128';
85 break;
86 case '10':
87 $type = 'codabar';
88 break;
89 case '11':
90 $type = 'msi';
91 break;
92 case '12':
93 $type = 'datamatrix';
94 break;
97 // -------------------------------------------------- //
98 // PROPERTIES
99 // -------------------------------------------------- //
100 $fontSize = 28;
101 $angle = 90; // rotation in degrees
102 $black = '000000'; // color in hexa
104 if ($GLOBALS['barcode_label_type'] == '12') { // datamatrix
105 $marge = 0; // between barcode and hri in pixel
106 $x = 35; // barcode center
107 $y = 120; // barcode center
108 $height = 40; // barcode height in 1D ; module size in 2D
109 $width = 4; // barcode height in 1D ; not use in 2D
110 } else {
111 $marge = 5; // between barcode and hri in pixel
112 $x = 30; // barcode center
113 $y = 120; // barcode center
114 $height = 40; // barcode height in 1D ; module size in 2D
115 $width = 1; // barcode height in 1D ; not use in 2D
118 // -------------------------------------------------- //
119 // ALLOCATE FPDF RESSOURCE
120 // -------------------------------------------------- //
122 $pdf = new eFPDF('P', 'mm', array(102,252)); // set the orentation, unit of measure and size of the page
123 $pdf->AddPage();
125 // -------------------------------------------------- //
126 // BARCODE
127 // -------------------------------------------------- //
129 $data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
130 $pdf->SetFont('Arial', 'B', $fontSize);
131 $pdf->SetTextColor(0, 0, 0);
132 $len = $pdf->GetStringWidth($data['hri']);
133 Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
135 // -------------------------------------------------- //
136 // OUTPUT
137 // -------------------------------------------------- //
139 $pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
140 $pdf->Output();