Various changes and fixes (#7424)
[openemr.git] / interface / patient_file / addr_label.php
blobaa1002f0e67f573f98fda4e2b2c0d1da8f03cd23
1 <?php
3 /**
4 * interface/patient_file/addr_label.php Displaying a PDF file of Labels for printing.
6 * Program for displaying Address Labels
8 * @package OpenEMR
9 * @link http://www.open-emr.org
10 * @author Terry Hill <terry@lillysystems.com>
11 * @author Daniel Pflieger <growlingflea@gmail.com>
12 * @copyright Copyright (c) 2014 Terry Hill <terry@lillysystems.com>
13 * @copyright Copyright (c) 2017 Daniel Pflieger <growlingflea@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../globals.php");
19 //Get the data to place on labels
22 $patdata = sqlQuery("SELECT " .
23 "p.fname, p.mname, p.lname, p.pubpid, p.DOB, " .
24 "p.street, p.city, p.state, p.postal_code, p.pid " .
25 "FROM patient_data AS p " .
26 "WHERE p.pid = ? LIMIT 1", array($pid));
28 // re-order the dates
30 $today = oeFormatShortDate($date = 'today');
31 $dob = oeFormatShortDate($patdata['DOB']);
33 //Keep in mind the envelope is shifted by 90 degrees.
34 // Changes made by Daniel Pflieger, daniel@mi-squared.com growlingflea@gmail.com
36 $x_width = $GLOBALS['env_x_width'];
37 $y_height = $GLOBALS['env_y_height'];
39 //printed text details
40 $font_size = $GLOBALS['env_font_size'];
41 $x = $GLOBALS['env_x_dist']; // Distance from the 'top' of the envelope in portrait position
42 $y = $GLOBALS['env_y_dist']; // Distance from the right most edge of the envelope in portrait position
43 $angle = 90; // rotation in degrees
44 $black = '000000'; // color in hexa
46 //Format of the address
47 //This number increases the spacing between the line printed on the envelope
48 $xt = .2 * $font_size;
50 //ymargin of printed text. The smaller the number, the further from the left edge edge the address is printed
51 $yt = 0;
53 $text1 = sprintf("%s %s\n", $patdata['fname'], $patdata['lname']);
54 $text2 = sprintf("%s \n", $patdata['street']);
55 $text3 = sprintf("%s , %s %s", $patdata['city'], $patdata['state'], $patdata['postal_code']);
57 $pdf = new eFPDF('P', 'mm', array($x_width, $y_height)); // set the orentation, unit of measure and size of the page
58 $pdf->AddPage();
59 $pdf->SetFont('Arial', '', $font_size);
60 $pdf->TextWithRotation($x, $y + $yt, $text1, $angle);
61 $xt += $xt;
62 $pdf->TextWithRotation($x + $xt, $y + $yt, $text2, $angle);
63 $xt += $xt;
64 $pdf->TextWithRotation($x + $xt, $y + $yt, $text3, $angle);
65 $xt += $xt;
67 $pdf->Output();