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