Merge pull request #2107 from stephenwaite/forum-fix
[openemr.git] / sites / default / statement.inc.php
blob6b193a96890abd42bbd56d10220ef7bfe439bd76
1 <?php
2 /* This is a template for printing patient statements and collection
3 * letters. You must customize it to suit your practice. If your
4 * needs are simple then you do not need programming experience to do
5 * this - just read the comments and make appropriate substitutions.
6 * All you really need to do is replace the [strings in brackets].
8 * @package OpenEMR
9 * @author Rod Roark <rod@sunsetsystems.com>
10 * @author Bill Cernansky <bill@mi-squared.com>
11 * @author Tony McCormick <tony@mi-squared.com>
12 * @author Raymond Magauran <magauran@medfetch.com>
13 * @author Jerry Padgett <sjpadgett@gmail.com>
14 * @author Stephen Waite <stephen.waite@cmsvt.com>
15 * @author Daniel Pflieger <daniel@growlingflea.com>
16 * @copyright Copyright (c) 2006 Rod Roark <rod@sunsetsystems.com>
17 * @copyright Copyright (c) 2009 Bill Cernansky <bill@mi-squared.com>
18 * @copyright Copyright (c) 2009 Tony McCormick <tony@mi-squared.com>
19 * @copyright Copyright (c) 2016 Raymond Magauran <magauran@medfetch.com>
20 * @copyright Copyright (c) 2017 Jerry Padgett <sjpadgett@gmail.com>
21 * @copyright Copyright (c) 2017 Stephen Waite <stephen.waite@cmsvt.com>
22 * @copyright Copyright (c) 2018 Daniel Pflieger <daniel@growlingflea.com>
23 * @link https://github.com/openemr/openemr/tree/master
24 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
27 // The location/name of a temporary file to hold printable statements.
28 // May want to alter these names to allow multi-site installs out-of-the-box
30 $STMT_TEMP_FILE = $GLOBALS['temporary_files_dir'] . "/openemr_statements.txt";
31 $STMT_TEMP_FILE_PDF = $GLOBALS['temporary_files_dir'] . "/openemr_statements.pdf";
32 $STMT_PRINT_CMD = $GLOBALS['print_command'];
34 /** There are two options to print a batch of PDF statements:
35 * 1. The original statement, a text based statement, using CezPDF
36 * Altering this statement is labor intensive, but capable of being altered any way desired...
38 * 2. Branded Statement, whose core is build from 1., the original statement, using HTML2PDF.
40 * To customize 2., add your practice location/images/practice_logo.gif
41 * In the base/default install this is located at '/openemr/sites/default/images/practice_logo.gif',
42 * Adjust directory paths per your installation.
43 * Further customize 2. manually in functions report_2() and create_HTML_statement(), below.
46 function make_statement($stmt)
48 if ($GLOBALS['statement_appearance'] == "1") {
49 if ($_POST['form_portalnotify'] && is_auth_portal($stmt['pid'])) {
50 return osp_create_HTML_statement($stmt);
51 } else {
52 return create_HTML_statement($stmt);
54 } else {
55 return create_statement($stmt);
58 /**
59 * This prints a header for documents. Keeps the brand uniform...
60 * @param string $pid patient_id
61 * @param string $direction, options "web" or anything else. Web provides apache-friendly url links.
62 * @return outputs to be displayed however requested
64 function report_header_2($stmt, $providerID = '1')
66 $titleres = getPatientData($stmt['pid'], "fname,lname,DOB");
67 //Author Daniel Pflieger - daniel@growlingflea.com
68 //We get the service facility from the encounter. In cases with multiple service facilities
69 //OpenEMR sends the correct facility
71 $service_query = sqlStatement("SELECT * FROM `form_encounter` fe join facility f on fe.facility_id = f.id where fe.id = ?", array($stmt['fid']));
72 $facility = sqlFetchArray($service_query);
74 $DOB = oeFormatShortDate($titleres['DOB']);
75 /******************************************************************/
76 ob_start();
77 // Use logo if it exists as 'practice_logo.gif' in the site dir
78 // old code used the global custom dir which is no longer a valid
80 <table style="width:100%;">
81 <tr>
82 <?php
83 $haveLogo = false;
84 if (empty(!$GLOBALS['statement_logo'])) {
85 $practice_logo = $GLOBALS['OE_SITE_DIR'] . "/images/" . convert_safe_file_dir_name($GLOBALS['statement_logo']);
86 } else { // 'ya never know.
87 $practice_logo = $GLOBALS['OE_SITE_DIR'] . "/images/practice_logo.gif"; // can see is safe...
90 //Author Daniel Pflieger - daniel@growlingflea.com
91 //We only put space for a logo if it exists.
92 //if it does we put the patient name and the service facility on a separate line.
93 //Patients with long names cause formatting issues and it makes the statement look
94 //unprofessional. Additionally, the end user should be able to choose the
95 //statement logo from Administration -> statement.
97 if (is_file($practice_logo)) { // note: file_exist() will return true if path exist but not file. a truly function name misnomer.
98 echo "<td style='width:15%; height: auto; text-align:center;'>\n";
99 // restrain logo proportionally
100 echo "<img src='" . attr($practice_logo) . "' align='left' style='width:100%; height: auto; margin:0px;'><br />\n";
101 echo "</td>\n";
102 $haveLogo = true;
105 <td align='center' style='<?php echo ($haveLogo ? text("width:40%;max-width:50%;") : text("width:50%;") ) ?>'> <!--adds some growing room-->
106 <em style="font-weight:bold;font-size:1.4em;"><?php echo text($facility['name']); ?></em><br />
107 <?php echo text($facility['street']); ?><br />
108 <?php echo text($facility['city']); ?>, <?php echo text($facility['state']); ?> <?php echo text($facility['postal_code']); ?><br />
109 <?php echo xlt('Phone').': ' .text($facility['phone']); ?><br />
110 <?php echo xlt('Fax').': ' .text($facility['fax']); ?><br />
111 <br clear='all' />
112 </td>
113 <td align='center'>
114 <em style="font-weight:bold;font-size:1.4em;"><?php echo text($titleres['fname']) . " " . text($titleres['lname']); ?></em><br />
115 <b style="font-weight:bold;"><?php echo xlt('Chart Number'); ?>:</b> <?php echo text($stmt['pid']); ?><br />
116 <b style="font-weight:bold;"><?php echo xlt('Generated on'); ?>:</b> <?php echo text(oeFormatShortDate()); ?><br />
117 <b><?php echo xlt('Provider') . ':</b> '; ?><?php echo text(getProviderName($providerID)); ?> <br />
118 </td>
119 </tr>
120 </table>
121 <?php
122 $output = ob_get_contents();
123 ob_end_clean();
124 return $output;
127 function create_HTML_statement($stmt)
129 if (! $stmt['pid']) {
130 return ""; // get out if no data
133 #minimum_amount_due_to _print
134 if ($stmt['amount'] <= ($GLOBALS['minimum_amount_to_print']) && $GLOBALS['use_statement_print_exclusion']) {
135 return "";
138 // Facility (service location) modified by Daniel Pflieger at Growlingflea Software
139 $service_query = sqlStatement("SELECT * FROM `form_encounter` fe join facility f on fe.facility_id = f.id where fe.id = ? ", array($stmt['fid']));
140 $row = sqlFetchArray($service_query);
141 $clinic_name = "{$row['name']}";
142 $clinic_addr = "{$row['street']}";
143 $clinic_csz = "{$row['city']}, {$row['state']}, {$row['postal_code']}";
146 // Billing location modified by Daniel Pflieger at Growlingflea Software
147 $service_query = sqlStatement("SELECT * FROM `form_encounter` fe join facility f on fe.billing_facility = f.id where fe.id = ?", array($stmt['fid']));
148 $row = sqlFetchArray($service_query);
149 $remit_name = "{$row['name']}";
150 $remit_addr = "{$row['street']}";
151 $remit_csz = "{$row['city']}, {$row['state']}, {$row['postal_code']}";
153 ob_start();
154 ?><div style="padding-left:25px;">
155 <?php
156 $find_provider = sqlQuery("SELECT * FROM form_encounter " .
157 "WHERE pid = ? AND encounter = ? " .
158 "ORDER BY id DESC LIMIT 1", array($stmt['pid'],$stmt['encounter']));
159 $providerID = $find_provider['provider_id'];
160 echo report_header_2($stmt, $providerID);
162 // dunning message setup
164 // insurance has paid something
165 // $stmt['age'] how old is the invoice
166 // $stmt['dun_count'] number of statements run
167 // $stmt['level_closed'] <= 3 insurance 4 = patient
169 if ($GLOBALS['use_dunning_message']) {
170 if ($stmt['ins_paid'] != 0 || $stmt['level_closed'] == 4) {
171 // do collection messages
172 switch ($stmt{'age'}) {
173 case $stmt{'age'} <= $GLOBALS['first_dun_msg_set']:
174 $dun_message = $GLOBALS['first_dun_msg_text'];
175 break;
176 case $stmt{'age'} <= $GLOBALS['second_dun_msg_set']:
177 $dun_message = $GLOBALS['second_dun_msg_text'];
178 break;
179 case $stmt{'age'} <= $GLOBALS['third_dun_msg_set']:
180 $dun_message = $GLOBALS['third_dun_msg_text'];
181 break;
182 case $stmt{'age'} <= $GLOBALS['fourth_dun_msg_set']:
183 $dun_message = $GLOBALS['fourth_dun_msg_text'];
184 break;
185 case $stmt{'age'} >= $GLOBALS['fifth_dun_msg_set']:
186 $dun_message = $GLOBALS['fifth_dun_msg_text'];
187 break;
192 // Text only labels
194 $label_addressee = xl('ADDRESSED TO');
195 $label_remitto = xl('REMIT TO');
196 $label_chartnum = xl('Chart Number');
197 $label_insinfo = xl('Insurance information on file');
198 $label_totaldue = xl('Total amount due');
199 $label_payby = xl('If paying by');
200 $label_cards = xl('VISA/MC/Discovery/HSA');
201 $label_cardnum = xl('Card');
202 $label_expiry = xl('Exp');
203 $label_cvv = xl('CVV');
204 $label_sign = xl('Signature');
205 $label_retpay = xl('Please return this bottom part with your payment');
206 $label_pgbrk = xl('STATEMENT SUMMARY');
207 $label_visit = xl('Visit Date');
208 $label_desc = xl('Description');
209 $label_amt = xl('Amount');
211 // This is the text for the top part of the page, up to but not
212 // including the detail lines. Some examples of variable fields are:
213 // %s = string with no minimum width
214 // %9s = right-justified string of 9 characters padded with spaces
215 // %-25s = left-justified string of 25 characters padded with spaces
216 // Note that "\n" is a line feed (new line) character.
217 // reformatted to handle i8n by tony
219 $out = "<div style='margin-left:60px;margin-top:20px;'><pre>";
220 $out .= "\n";
221 $out .= sprintf("_______________________ %s _______________________\n", $label_pgbrk);
222 $out .= "\n";
223 $out .= sprintf("%-11s %-46s %s\n", $label_visit, $label_desc, $label_amt);
224 $out .= "\n";
226 // This must be set to the number of lines generated above.
228 $count = 6;
229 $num_ages = 4;
230 $aging = array();
231 for ($age_index = 0; $age_index < $num_ages; ++$age_index) {
232 $aging[$age_index] = 0.00;
235 $todays_time = strtotime(date('Y-m-d'));
237 // This generates the detail lines. Again, note that the values must be specified in the order used.
238 foreach ($stmt['lines'] as $line) {
239 if ($GLOBALS['use_custom_statement']) {
240 $description = substr($line['desc'], 0, 30);
241 } else {
242 $description = $line['desc'];
245 $tmp = substr($description, 0, 14);
246 if ($tmp == 'Procedure 9920' || $tmp == 'Procedure 9921' || $tmp == 'Procedure 9200' || $tmp == 'Procedure 9201') {
247 $description = str_replace("Procedure", xl('Office Visit').":", $description);
250 //92002-14 are Eye Office Visit Codes
252 $dos = $line['dos'];
253 ksort($line['detail']);
254 # Compute the aging bucket index and accumulate into that bucket.
255 $age_in_days = (int) (($todays_time - strtotime($dos)) / (60 * 60 * 24));
256 $age_index = (int) (($age_in_days - 1) / 30);
257 $age_index = max(0, min($num_ages - 1, $age_index));
258 $aging[$age_index] += $line['amount'] - $line['paid'];
260 foreach ($line['detail'] as $dkey => $ddata) {
261 $ddate = substr($dkey, 0, 10);
262 if (preg_match('/^(\d\d\d\d)(\d\d)(\d\d)\s*$/', $ddate, $matches)) {
263 $ddate = $matches[1] . '-' . $matches[2] . '-' . $matches[3];
266 $amount = '';
268 if ($ddata['pmt']) {
269 $amount = sprintf("%.2f", 0 - $ddata['pmt']);
270 $desc = xl('Paid') .' '. oeFormatShortDate($ddate) .': '. $ddata['src'].' '. $ddata['pmt_method'].' '. $ddata['insurance_company'];
271 } else if ($ddata['rsn']) {
272 if ($ddata['chg']) {
273 $amount = sprintf("%.2f", $ddata['chg']);
274 $desc = xl('Adj') .' '. oeFormatShortDate($ddate) .': ' . $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
275 } else {
276 $desc = xl('Note') .' '. oeFormatShortDate($ddate) .': '. $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
278 } else if ($ddata['chg'] < 0) {
279 $amount = sprintf("%.2f", $ddata['chg']);
280 $desc = xl('Patient Payment');
281 } else {
282 $amount = sprintf("%.2f", $ddata['chg']);
283 $desc = $description;
286 $out .= sprintf("%-10s %-45s%8s\n", oeFormatShortDate($dos), $desc, $amount);
287 $dos = '';
288 ++$count;
292 // This generates blank lines until we are at line 20.
293 // At line 20 we start middle third.
295 while ($count++ < 16) {
296 $out .= "\n";
299 # Generate the string of aging text. This will look like:
300 # Current xxx.xx / 31-60 x.xx / 61-90 x.xx / Over-90 xxx.xx
301 # ....+....1....+....2....+....3....+....4....+....5....+....6....+
303 $ageline = xl('Current') .': ' . sprintf("%.2f", $aging[0]);
304 for ($age_index = 1; $age_index < ($num_ages - 1); ++$age_index) {
305 $ageline .= ' | ' . ($age_index * 30 + 1) . '-' . ($age_index * 30 + 30) . ':' .
306 sprintf(" %.2f", $GLOBALS['gbl_currency_symbol'].''.$aging[$age_index]);
309 // Fixed text labels
310 $label_ptname = xl('Name');
311 $label_today = xl('Date');
312 $label_due = xl('Due');
313 $label_thanks = xl('Thank you for choosing');
314 $label_call = xl('Please call if any of the above information is incorrect.');
315 $label_prompt = xl('We appreciate prompt payment of balances due.');
316 $label_dept = xl('Billing Department');
317 $label_bill_phone = (!empty($GLOBALS['billing_phone_number']) ? $GLOBALS['billing_phone_number'] : $row['phone'] );
318 $label_appointments = xl('Future Appointments').':';
320 // This is the top portion of the page.
321 $out .= "\n\n\n";
322 if (strlen($stmt['bill_note']) !=0 && $GLOBALS['statement_bill_note_print']) {
323 $out .= sprintf("%-46s\n", $stmt['bill_note']);
324 $count++;
327 if ($GLOBALS['use_dunning_message']) {
328 $out .= sprintf("%-46s\n", $dun_message);
329 $count++;
332 $out .= "\n";
333 $out .= sprintf(
334 "%-s: %-25s %-s: %-14s %-s: %8s\n",
335 $label_ptname,
336 $stmt['patient'],
337 $label_today,
338 oeFormatShortDate($stmt['today']),
339 $label_due,
340 $stmt['amount']
342 $out .= sprintf("__________________________________________________________________\n");
343 $out .= "\n";
344 $out .= sprintf("%-s\n", $label_call);
345 $out .= sprintf("%-s\n", $label_prompt);
346 $out .= "\n";
347 // $out .= sprintf("%-s\n", $billing_contact);
348 $out .= sprintf(" %-s %-25s\n", $label_dept, $label_bill_phone);
349 if ($GLOBALS['statement_message_to_patient']) {
350 $out .= "\n";
351 $statement_message = $GLOBALS['statement_msg_text'];
352 $out .= sprintf("%-40s\n", $statement_message);
353 $count++;
356 if ($GLOBALS['show_aging_on_custom_statement']) {
357 # code for ageing
358 $ageline .= ' | ' . xl('Over') . ' ' . ($age_index * 30) .':'.
359 sprintf(" %.2f", $aging[$age_index]);
360 $out .= "\n" . $ageline . "\n\n";
361 $count++;
364 if ($GLOBALS['number_appointments_on_statement']!=0) {
365 $out .= "\n";
366 $num_appts = $GLOBALS['number_appointments_on_statement'];
367 $next_day = mktime(0, 0, 0, date('m'), date('d')+1, date('Y'));
368 # add one day to date so it will not get todays appointment
369 $current_date2 = date('Y-m-d', $next_day);
370 $events = fetchNextXAppts($current_date2, $stmt['pid'], $num_appts);
371 $j=0;
372 $out .= sprintf("%-s\n", $label_appointments);
373 #loop to add the appointments
374 for ($x = 1; $x <= $num_appts; $x++) {
375 $next_appoint_date = oeFormatShortDate($events[$j]['pc_eventDate']);
376 $next_appoint_time = substr($events[$j]['pc_startTime'], 0, 5);
377 if (strlen(umname) != 0) {
378 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['umname'] . ' ' . $events[$j]['ulname'];
379 } else {
380 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['ulname'];
383 if (strlen($next_appoint_time) != 0) {
384 $label_plsnote[$j] = xlt('Date') . ': ' . text($next_appoint_date) . ' ' . xlt('Time') . ' ' . text($next_appoint_time) . ' ' . xlt('Provider') . ' ' . text($next_appoint_provider);
385 $out .= sprintf("%-s\n", $label_plsnote[$j]);
388 $j++;
389 $count++;
393 while ($count++ < 29) {
394 $out .= "\n";
397 $out .= sprintf("%-10s %s\n", null, $label_retpay);
398 $out .= '</pre></div>';
399 $out .= '<div style="width:7.0in;border-top:1pt dotted black;font-size:12px;margin:0px;"><br /><br />
400 <table style="width:7in;margin-left:20px;"><tr><td style="width:4.5in;"><br />
402 $out .= $label_payby.' '.$label_cards;
403 $out .= "<br /><br />";
404 $out .= $label_cardnum .': __________________________________ '.$label_expiry.': ___ / ____ '.$label_cvv.':____<br /><br />';
405 $out .= $label_sign .' ______________________________________________<br />';
406 $out .=" </td><td style=width:2.0in;vertical-align:middle;'>";
407 $practice_cards = $GLOBALS['OE_SITE_DIR']. "/images/visa_mc_disc_credit_card_logos_176x35.gif";
408 if (file_exists($GLOBALS['OE_SITE_DIR']."/images/visa_mc_disc_credit_card_logos_176x35.gif")) {
409 $out .= "<img src='$practice_cards' style='width:100%; margin:4px auto;'><br /><p>\n<b>" .
410 $label_totaldue . "</b>: " . $stmt['amount']. "<br/>". xlt('Payment Tracking Id') . ": " .
411 text($stmt['pid']);
412 $out .= "<br />" . xlt('Amount Paid') . ": _______ " . xlt('Check') . " #:</p>";
413 } else {
414 $out .= "<br /><p><b>" . $label_totaldue . "</b>: " . $stmt['amount'] . "<br/>".
415 xlt('Payment Tracking Id') . ": " . text($stmt['pid']) . "</p>";
416 $out .= "<br /><p>" . xlt('Amount Paid') . ": _______ " . xlt('Check') . " #:</p>";
419 $out .="</td></tr></table>";
421 $out .= '</div><br />
422 <pre>';
423 if ($stmt['to'][3]!='') { //to avoid double blank lines the if condition is put.
424 $out .= sprintf(" %-32s\n", $stmt['to'][3]);
427 $out .= ' </pre>
428 <div style="width:7.0in;border-top:1pt solid black;"><br />';
429 $out .= " <table style='width:7.0in;margin:auto;'><tr>";
430 $out .= '<td style="margin:auto;"></td><td style="width:3.0in;"><b>'
431 .$label_addressee.'</b><br />'
432 .$stmt['to'][0].'<br />'
433 .$stmt['to'][1].'<br />'
434 .$stmt['to'][2].'
435 </td><td style="width:0.5in;"></td>
436 <td style="margin:auto;"><b>'.$label_remitto.'</b><br />'
437 .$remit_name.'<br />'
438 .$remit_addr.'<br />'
439 .$remit_csz.'
440 </td>
441 </tr></table>';
443 $out .= " </div></div>";
444 $out .= "\014
445 <br /><br />"; // this is a form feed
446 echo $out;
447 $output = ob_get_clean();
448 return $output;
451 // This function builds a printable statement or collection letter from
452 // an associative array having the following keys:
454 // today = statement date yyyy-mm-dd
455 // pid = patient ID
456 // patient = patient name
457 // amount = total amount due
458 // to = array of addressee name/address lines
459 // lines = array of lines, each with the following keys:
460 // dos = date of service yyyy-mm-dd
461 // desc = description
462 // amount = charge less adjustments
463 // paid = amount paid
464 // notice = 1 for first notice, 2 for second, etc.
465 // detail = associative array of details
467 // Each detail array is keyed on a string beginning with a date in
468 // yyyy-mm-dd format, or blanks in the case of the original charge
469 // items. Its values are associative arrays like this:
471 // pmt - payment amount as a positive number, only for payments
472 // src - check number or other source, only for payments
473 // chg - invoice line item amount amount, only for charges or
474 // adjustments (adjustments may be zero)
475 // rsn - adjustment reason, only for adjustments
477 // The returned value is a string that can be sent to a printer.
478 // This example is plain text, but if you are a hotshot programmer
479 // then you could make a PDF or PostScript or whatever peels your
480 // banana. These strings are sent in succession, so append a form
481 // feed if that is appropriate.
484 // A sample of the text based format follows:
486 //[Your Clinic Name] Patient Name 2009-12-29
487 //[Your Clinic Address] Chart Number: 1848
488 //[City, State Zip] Insurance information on file
491 //ADDRESSEE REMIT TO
492 //Patient Name [Your Clinic Name]
493 //patient address [Your Clinic Address]
494 //city, state zipcode [City, State Zip]
495 // If paying by VISA/MC/AMEX/Dis
497 //Card_____________________ Exp______ Signature___________________
498 // Return above part with your payment
499 //-----------------------------------------------------------------
501 //_______________________ STATEMENT SUMMARY _______________________
503 //Visit Date Description Amount
505 //2009-08-20 Procedure 99345 198.90
506 // Paid 2009-12-15: -51.50
507 //... more details ...
508 //...
509 //...
510 // skipping blanks in example
513 //Name: Patient Name Date: 2009-12-29 Due: 147.40
514 //_________________________________________________________________
516 //Please call if any of the above information is incorrect
517 //We appreciate prompt payment of balances due
519 //[Your billing contact name]
520 // Billing Department
521 // [Your billing dept phone]
523 function create_statement($stmt)
525 if (! $stmt['pid']) {
526 return ""; // get out if no data
529 #minimum_amount_to _print
530 if ($stmt[amount] <= ($GLOBALS['minimum_amount_to_print']) && $GLOBALS['use_statement_print_exclusion']) {
531 return "";
534 // These are your clinics return address, contact etc. Edit them.
535 // TBD: read this from the facility table
537 // Facility (service location) modified by Daniel Pflieger at Growlingflea Software
538 $service_query = sqlStatement("SELECT * FROM `form_encounter` fe join facility f on fe.facility_id = f.id where fe.id = ?", array($stmt['fid']));
539 $row = sqlFetchArray($service_query);
540 $clinic_name = "{$row['name']}";
541 $clinic_addr = "{$row['street']}";
542 $clinic_csz = "{$row['city']}, {$row['state']}, {$row['postal_code']}";
545 // Billing location modified by Daniel Pflieger at Growlingflea Software
546 $service_query = sqlStatement("SELECT * FROM `form_encounter` fe join facility f on fe.billing_facility = f.id where fe.id = ?", array($stmt['fid']));
547 $row = sqlFetchArray($service_query);
548 $remit_name = "{$row['name']}";
549 $remit_addr = "{$row['street']}";
550 $remit_csz = "{$row['city']}, {$row['state']}, {$row['postal_code']}";
553 // Contacts
554 $atres = sqlStatement("select f.attn,f.phone from facility f " .
555 " left join users u on f.id=u.facility_id " .
556 " left join billing b on b.provider_id=u.id and b.pid = '".$stmt['pid']."' " .
557 " where billing_location=1");
558 $row = sqlFetchArray($atres);
559 $billing_contact = "{$row['attn']}";
560 $billing_phone = "{$row['phone']}";
562 // dunning message setup
564 // insurance has paid something
565 // $stmt['age'] how old is the invoice
566 // $stmt['dun_count'] number of statements run
567 // $stmt['level_closed'] <= 3 insurance 4 = patient
569 if ($GLOBALS['use_dunning_message']) {
570 if ($stmt['ins_paid'] != 0 || $stmt['level_closed'] == 4) {
571 // do collection messages
572 switch ($stmt{'age'}) {
573 case $stmt{'age'} <= $GLOBALS['first_dun_msg_set']:
574 $dun_message = $GLOBALS['first_dun_msg_text'];
575 break;
576 case $stmt{'age'} <= $GLOBALS['second_dun_msg_set']:
577 $dun_message = $GLOBALS['second_dun_msg_text'];
578 break;
579 case $stmt{'age'} <= $GLOBALS['third_dun_msg_set']:
580 $dun_message = $GLOBALS['third_dun_msg_text'];
581 break;
582 case $stmt{'age'} <= $GLOBALS['fourth_dun_msg_set']:
583 $dun_message = $GLOBALS['fourth_dun_msg_text'];
584 break;
585 case $stmt{'age'} >= $GLOBALS['fifth_dun_msg_set']:
586 $dun_message = $GLOBALS['fifth_dun_msg_text'];
587 break;
592 // Text only labels
594 $label_addressee = xl('ADDRESSED TO');
595 $label_remitto = xl('REMIT TO');
596 $label_chartnum = xl('Chart Number');
597 $label_insinfo = xl('Insurance information on file');
598 $label_totaldue = xl('Total amount due');
599 $label_payby = xl('If paying by');
600 $label_cards = xl('VISA/MC/Discovery/HSA');
601 $label_cardnum = xl('Card');
602 $label_expiry = xl('Exp');
603 $label_cvv = xl('CVV');
604 $label_sign = xl('Signature');
605 $label_retpay = xl('Return above part with your payment');
606 $label_pgbrk = xl('STATEMENT SUMMARY');
607 $label_visit = xl('Visit Date');
608 $label_desc = xl('Description');
609 $label_amt = xl('Amount');
611 // This is the text for the top part of the page, up to but not
612 // including the detail lines. Some examples of variable fields are:
613 // %s = string with no minimum width
614 // %9s = right-justified string of 9 characters padded with spaces
615 // %-25s = left-justified string of 25 characters padded with spaces
616 // Note that "\n" is a line feed (new line) character.
617 // reformatted to handle i8n by tony
618 $out = "\n\n";
619 $providerNAME = getProviderName($stmt['provider_id']);
620 $out .= sprintf("%-30s %s %-s\n", $clinic_name, $stmt['patient'], $stmt['today']);
621 $out .= sprintf("%-30s %s: %-s\n", $providerNAME, $label_chartnum, $stmt['pid']);
622 $out .= sprintf("%-30s %s\n", $clinic_addr, $label_insinfo);
623 $out .= sprintf("%-30s %-s: %-s\n", $clinic_csz, $label_totaldue, $stmt['amount']);
624 $out .= "\n";
625 $out .= sprintf(" %-30s %-s\n", $label_addressee, $label_remitto);
626 $out .= sprintf(" %-30s %s\n", $stmt['to'][0], $remit_name);
627 $out .= sprintf(" %-30s %s\n", $stmt['to'][1], $remit_addr);
628 $out .= sprintf(" %-30s %s\n", $stmt['to'][2], $remit_csz);
630 if ($stmt['to'][3]!='') { //to avoid double blank lines the if condition is put.
631 $out .= sprintf(" %-32s\n", $stmt['to'][3]);
634 $out .= sprintf("_________________________________________________________________\n");
635 $out .= "\n";
636 $out .= sprintf("%-32s\n", $label_payby.' '.$label_cards);
637 $out .= "\n";
638 $out .= sprintf(
639 "%s_____________________ %s______ %s______ %s___________________\n\n",
640 $label_cardnum,
641 $label_expiry,
642 $label_cvv,
643 $label_sign
645 $out .= sprintf("-----------------------------------------------------------------\n");
646 $out .= sprintf("%-20s %s\n", null, $label_retpay);
647 $out .= "\n";
648 $out .= sprintf("_______________________ %s _______________________\n", $label_pgbrk);
649 $out .= "\n";
650 $out .= sprintf("%-11s %-46s %s\n", $label_visit, $label_desc, $label_amt);
651 $out .= "\n";
653 // This must be set to the number of lines generated above.
655 $count = 25;
656 $num_ages = 4;
657 $aging = array();
658 for ($age_index = 0; $age_index < $num_ages; ++$age_index) {
659 $aging[$age_index] = 0.00;
662 $todays_time = strtotime(date('Y-m-d'));
664 // This generates the detail lines. Again, note that the values must
665 // be specified in the order used.
669 foreach ($stmt['lines'] as $line) {
670 if ($GLOBALS['use_custom_statement']) {
671 $description = substr($line['desc'], 0, 30);
672 } else {
673 $description = $line['desc'];
676 $tmp = substr($description, 0, 14);
677 if ($tmp == 'Procedure 9920' || $tmp == 'Procedure 9921' || $tmp == 'Procedure 9200' || $tmp == 'Procedure 9201') {
678 $description = str_replace("Procedure", xl('Office Visit').":", $description);
681 //92002-14 are Eye Office Visit Codes
683 $dos = $line['dos'];
684 ksort($line['detail']);
685 # Compute the aging bucket index and accumulate into that bucket.
687 $age_in_days = (int) (($todays_time - strtotime($dos)) / (60 * 60 * 24));
688 $age_index = (int) (($age_in_days - 1) / 30);
689 $age_index = max(0, min($num_ages - 1, $age_index));
690 $aging[$age_index] += $line['amount'] - $line['paid'];
692 foreach ($line['detail'] as $dkey => $ddata) {
693 $ddate = substr($dkey, 0, 10);
694 if (preg_match('/^(\d\d\d\d)(\d\d)(\d\d)\s*$/', $ddate, $matches)) {
695 $ddate = $matches[1] . '-' . $matches[2] . '-' . $matches[3];
698 $amount = '';
700 if ($ddata['pmt']) {
701 $amount = sprintf("%.2f", 0 - $ddata['pmt']);
702 $desc = xl('Paid') .' '. oeFormatShortDate($ddate) .': '. $ddata['src'].' '. $ddata['pmt_method'].' '. $ddata['insurance_company'];
703 } else if ($ddata['rsn']) {
704 if ($ddata['chg']) {
705 $amount = sprintf("%.2f", $ddata['chg']);
706 $desc = xl('Adj') .' '. oeFormatShortDate($ddate) .': ' . $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
707 } else {
708 $desc = xl('Note') .' '. oeFormatShortDate($ddate) .': '. $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
710 } else if ($ddata['chg'] < 0) {
711 $amount = sprintf("%.2f", $ddata['chg']);
712 $desc = xl('Patient Payment');
713 } else {
714 $amount = sprintf("%.2f", $ddata['chg']);
715 $desc = $description;
718 $out .= sprintf("%-10s %-45s%8s\n", oeFormatShortDate($dos), $desc, $amount);
719 $dos = '';
720 ++$count;
724 // This generates blank lines until we are at line 42.
726 while ($count++ < 42) {
727 $out .= "\n";
730 # Generate the string of aging text. This will look like:
731 # Current xxx.xx / 31-60 x.xx / 61-90 x.xx / Over-90 xxx.xx
732 # ....+....1....+....2....+....3....+....4....+....5....+....6....+
734 $ageline = xl('Current') .' ' . sprintf("%.2f", $aging[0]);
735 for ($age_index = 1; $age_index < ($num_ages - 1); ++$age_index) {
736 $ageline .= ' / ' . ($age_index * 30 + 1) . '-' . ($age_index * 30 + 30) .
737 sprintf(" %.2f", $aging[$age_index]);
740 // Fixed text labels
741 $label_ptname = xl('Name');
742 $label_today = xl('Date');
743 $label_due = xl('Amount Due');
744 $label_thanks = xl('Thank you for choosing');
745 $label_call = xl('Please call if any of the above information is incorrect.');
746 $label_prompt = xl('We appreciate prompt payment of balances due.');
747 $label_dept = xl('Billing Department');
748 $label_bill_phone = (!empty($GLOBALS['billing_phone_number']) ? $GLOBALS['billing_phone_number'] : $billing_phone );
749 $label_appointments = xl('Future Appointments').':';
751 // This is the bottom portion of the page.
752 $out .= "\n";
753 if (strlen($stmt['bill_note']) !=0 && $GLOBALS['statement_bill_note_print']) {
754 $out .= sprintf("%-46s\n", $stmt['bill_note']);
757 if ($GLOBALS['use_dunning_message']) {
758 $out .= sprintf("%-46s\n", $dun_message);
761 $out .= "\n";
762 $out .= sprintf(
763 "%-s: %-25s %-s: %-14s %-s: %8s\n",
764 $label_ptname,
765 $stmt['patient'],
766 $label_today,
767 oeFormatShortDate($stmt['today']),
768 $label_due,
769 $stmt['amount']
771 $out .= sprintf("__________________________________________________________________\n");
772 $out .= "\n";
773 $out .= sprintf("%-s\n", $label_call);
774 $out .= sprintf("%-s\n", $label_prompt);
775 $out .= "\n";
776 $out .= sprintf("%-s\n", $billing_contact);
777 $out .= sprintf(" %-s %-25s\n", $label_dept, $label_bill_phone);
778 if ($GLOBALS['statement_message_to_patient']) {
779 $out .= "\n";
780 $statement_message = $GLOBALS['statement_msg_text'];
781 $out .= sprintf("%-40s\n", $statement_message);
784 if ($GLOBALS['show_aging_on_custom_statement']) {
785 # code for ageing
786 $ageline .= ' / ' . xl('Over') . '-' . ($age_index * 30) .
787 sprintf(" %.2f", $aging[$age_index]);
788 $out .= "\n" . $ageline . "\n\n";
791 if ($GLOBALS['number_appointments_on_statement']!=0) {
792 $out .= "\n";
793 $num_appts = $GLOBALS['number_appointments_on_statement'];
794 $next_day = mktime(0, 0, 0, date('m'), date('d')+1, date('Y'));
795 # add one day to date so it will not get todays appointment
796 $current_date2 = date('Y-m-d', $next_day);
797 $events = fetchNextXAppts($current_date2, $stmt['pid'], $num_appts);
798 $j=0;
799 $out .= sprintf("%-s\n", $label_appointments);
800 #loop to add the appointments
801 for ($x = 1; $x <= $num_appts; $x++) {
802 $next_appoint_date = oeFormatShortDate($events[$j]['pc_eventDate']);
803 $next_appoint_time = substr($events[$j]['pc_startTime'], 0, 5);
804 if (strlen(umname) != 0) {
805 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['umname'] .
806 ' ' . $events[$j]['ulname'];
807 } else {
808 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['ulname'];
811 if (strlen($next_appoint_time) != 0) {
812 $label_plsnote[$j] = xlt('Date') . ': ' . text($next_appoint_date) . ' ' . xlt('Time') .
813 ' ' . text($next_appoint_time) . ' ' . xlt('Provider') . ' ' . text($next_appoint_provider);
814 $out .= sprintf("%-s\n", $label_plsnote[$j]);
817 $j++;
821 $out .= "\014"; // this is a form feed
823 return $out;
826 function osp_create_HTML_statement($stmt)
828 if (! $stmt['pid']) {
829 return ""; // get out if no data
832 #minimum_amount_due_to _print
833 if ($stmt['amount'] <= ($GLOBALS['minimum_amount_to_print']) && $GLOBALS['use_statement_print_exclusion']) {
834 return "";
837 // Facility (service location)
838 $atres = sqlStatement("select f.name,f.street,f.city,f.state,f.postal_code,f.attn,f.phone from facility f " .
839 " left join users u on f.id=u.facility_id " .
840 " left join billing b on b.provider_id=u.id and b.pid = ? ".
841 " where service_location=1", array($stmt['pid']));
842 $row = sqlFetchArray($atres);
843 $clinic_name = "{$row['name']}";
844 $clinic_addr = "{$row['street']}";
845 $clinic_csz = "{$row['city']}, {$row['state']}, {$row['postal_code']}";
846 // Contacts
847 $billing_contact = "{$row['attn']}";
848 $billing_phone = "{$row['phone']}";
849 // Billing location
850 $remit_name = $clinic_name;
851 $remit_addr = $clinic_addr;
852 $remit_csz = $clinic_csz;
854 ob_start();
855 ?><div style="padding-left:25px;">
856 <?php
857 $find_provider = sqlQuery("SELECT * FROM form_encounter " .
858 "WHERE pid = ? AND encounter = ? " .
859 "ORDER BY id DESC LIMIT 1", array($stmt['pid'],$stmt['encounter']));
860 $providerID = $find_provider['provider_id'];
861 echo report_header_2($stmt, $providerID);
863 // dunning message setup
865 // insurance has paid something
866 // $stmt['age'] how old is the invoice
867 // $stmt['dun_count'] number of statements run
868 // $stmt['level_closed'] <= 3 insurance 4 = patient
870 if ($GLOBALS['use_dunning_message']) {
871 if ($stmt['ins_paid'] != 0 || $stmt['level_closed'] == 4) {
872 // do collection messages
873 switch ($stmt{'age'}) {
874 case $stmt{'age'} <= $GLOBALS['first_dun_msg_set']:
875 $dun_message = $GLOBALS['first_dun_msg_text'];
876 break;
877 case $stmt{'age'} <= $GLOBALS['second_dun_msg_set']:
878 $dun_message = $GLOBALS['second_dun_msg_text'];
879 break;
880 case $stmt{'age'} <= $GLOBALS['third_dun_msg_set']:
881 $dun_message = $GLOBALS['third_dun_msg_text'];
882 break;
883 case $stmt{'age'} <= $GLOBALS['fourth_dun_msg_set']:
884 $dun_message = $GLOBALS['fourth_dun_msg_text'];
885 break;
886 case $stmt{'age'} >= $GLOBALS['fifth_dun_msg_set']:
887 $dun_message = $GLOBALS['fifth_dun_msg_text'];
888 break;
893 // Text only labels
895 $label_addressee = xl('ADDRESSED TO');
896 $label_remitto = xl('REMIT TO');
897 $label_chartnum = xl('Chart Number');
898 $label_insinfo = xl('Insurance information on file');
899 $label_totaldue = xl('Total amount due');
900 $label_payby = xl('If paying by');
901 $label_cards = xl('VISA/MC/Discovery/HSA');
902 $label_cardnum = xl('Card');
903 $label_expiry = xl('Exp');
904 $label_sign = xl('Signature');
905 $label_retpay = xl('Please fill in credit information and send for review.');
906 $label_pgbrk = xl('STATEMENT SUMMARY');
907 $label_visit = xl('Visit Date');
908 $label_desc = xl('Description');
909 $label_amt = xl('Amount');
911 // This is the text for the top part of the page, up to but not
912 // including the detail lines. Some examples of variable fields are:
913 // %s = string with no minimum width
914 // %9s = right-justified string of 9 characters padded with spaces
915 // %-25s = left-justified string of 25 characters padded with spaces
916 // Note that "\n" is a line feed (new line) character.
917 // reformatted to handle i8n by tony
919 $out = "<div style='margin-left:60px;margin-top:0px;'>";
920 $out .= "\n";
921 $out .= sprintf("_______________________ %s _______________________\n", $label_pgbrk);
922 $out .= "\n";
923 $out .= sprintf("%-11s %-46s %s\n", $label_visit, $label_desc, $label_amt);
924 $out .= "\n";
926 // This must be set to the number of lines generated above.
928 $count = 6;
929 $num_ages = 4;
930 $aging = array();
931 for ($age_index = 0; $age_index < $num_ages; ++$age_index) {
932 $aging[$age_index] = 0.00;
935 $todays_time = strtotime(date('Y-m-d'));
937 // This generates the detail lines. Again, note that the values must be specified in the order used.
938 foreach ($stmt['lines'] as $line) {
939 if ($GLOBALS['use_custom_statement']) {
940 $description = substr($line['desc'], 0, 30);
941 } else {
942 $description = $line['desc'];
945 $tmp = substr($description, 0, 14);
946 if ($tmp == 'Procedure 9920' || $tmp == 'Procedure 9921' || $tmp == 'Procedure 9200' || $tmp == 'Procedure 9201') {
947 $description = str_replace("Procedure", xl('Office Visit').":", $description);
950 //92002-14 are Eye Office Visit Codes
952 $dos = $line['dos'];
953 ksort($line['detail']);
954 # Compute the aging bucket index and accumulate into that bucket.
955 $age_in_days = (int) (($todays_time - strtotime($dos)) / (60 * 60 * 24));
956 $age_index = (int) (($age_in_days - 1) / 30);
957 $age_index = max(0, min($num_ages - 1, $age_index));
958 $aging[$age_index] += $line['amount'] - $line['paid'];
960 foreach ($line['detail'] as $dkey => $ddata) {
961 $ddate = substr($dkey, 0, 10);
962 if (preg_match('/^(\d\d\d\d)(\d\d)(\d\d)\s*$/', $ddate, $matches)) {
963 $ddate = $matches[1] . '-' . $matches[2] . '-' . $matches[3];
966 $amount = '';
968 if ($ddata['pmt']) {
969 $amount = sprintf("%.2f", 0 - $ddata['pmt']);
970 $desc = xl('Paid') .' '. oeFormatShortDate($ddate) .': '. $ddata['src'].' '. $ddata['pmt_method'].' '. $ddata['insurance_company'];
971 } else if ($ddata['rsn']) {
972 if ($ddata['chg']) {
973 $amount = sprintf("%.2f", $ddata['chg']);
974 $desc = xl('Adj') .' '. oeFormatShortDate($ddate) .': ' . $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
975 } else {
976 $desc = xl('Note') .' '. oeFormatShortDate($ddate) .': '. $ddata['rsn'].' '.$ddata['pmt_method'].' '. $ddata['insurance_company'];
978 } else if ($ddata['chg'] < 0) {
979 $amount = sprintf("%.2f", $ddata['chg']);
980 $desc = xl('Patient Payment');
981 } else {
982 $amount = sprintf("%.2f", $ddata['chg']);
983 $desc = $description;
986 $out .= sprintf("%-10s %-45s%8s\n", oeFormatShortDate($dos), $desc, $amount);
987 $dos = '';
988 ++$count;
992 // This generates blank lines until we are at line 20.
993 // At line 20 we start middle third.
995 //while ($count++ < 16) $out .= "\n";
996 # Generate the string of aging text. This will look like:
997 # Current xxx.xx / 31-60 x.xx / 61-90 x.xx / Over-90 xxx.xx
998 # ....+....1....+....2....+....3....+....4....+....5....+....6....+
1000 $ageline = xl('Current') .': ' . sprintf("%.2f", $aging[0]);
1001 for ($age_index = 1; $age_index < ($num_ages - 1); ++$age_index) {
1002 $ageline .= ' | ' . ($age_index * 30 + 1) . '-' . ($age_index * 30 + 30) . ':' .
1003 sprintf(" %.2f", $GLOBALS['gbl_currency_symbol'].''.$aging[$age_index]);
1006 // Fixed text labels
1007 $label_ptname = xl('Name');
1008 $label_today = xl('Date');
1009 $label_due = xl('Due');
1010 $label_thanks = xl('Thank you for choosing');
1011 $label_call = xl('Please call or message if any of the above information is incorrect.');
1012 $label_prompt = xl('We appreciate prompt payment of balances due.');
1013 $label_dept = xl('Billing Department');
1014 $label_bill_phone = (!empty($GLOBALS['billing_phone_number']) ? $GLOBALS['billing_phone_number'] : $billing_phone );
1015 $label_appointments = xl('Future Appointments').':';
1017 // This is the top portion of the page.
1018 $out .= "\n";
1019 if (strlen($stmt['bill_note']) !=0 && $GLOBALS['statement_bill_note_print']) {
1020 $out .= sprintf("%-46s\n", $stmt['bill_note']);
1021 $count++;
1024 if ($GLOBALS['use_dunning_message']) {
1025 $out .= sprintf("%-46s\n", $dun_message);
1026 $count++;
1029 $out .= "\n";
1030 $out .= sprintf(
1031 "%-s: %-25s %-s: %-14s %-s: %8s\n",
1032 $label_ptname,
1033 $stmt['patient'],
1034 $label_today,
1035 oeFormatShortDate($stmt['today']),
1036 $label_due,
1037 $stmt['amount']
1039 $out .= sprintf("__________________________________________________________________\n");
1040 $out .= "\n";
1041 $out .= sprintf("%-s\n", $label_call);
1042 $out .= sprintf("%-s\n", $label_prompt);
1043 $out .= "\n";
1044 $out .= sprintf("%-s\n", $billing_contact);
1045 $out .= sprintf(" %-s %-25s\n", $label_dept, $label_bill_phone);
1046 if ($GLOBALS['statement_message_to_patient']) {
1047 $out .= "\n";
1048 $statement_message = $GLOBALS['statement_msg_text'];
1049 $out .= sprintf("%-40s\n", $statement_message);
1050 $count++;
1053 if ($GLOBALS['show_aging_on_custom_statement']) {
1054 # code for ageing
1055 $ageline .= ' | ' . xl('Over') . ' ' . ($age_index * 30) .':'.
1056 sprintf(" %.2f", $aging[$age_index]);
1057 $out .= "\n" . $ageline . "\n\n";
1058 $count++;
1061 if ($GLOBALS['number_appointments_on_statement']!=0) {
1062 $out .= "\n";
1063 $num_appts = $GLOBALS['number_appointments_on_statement'];
1064 $next_day = mktime(0, 0, 0, date('m'), date('d')+1, date('Y'));
1065 # add one day to date so it will not get todays appointment
1066 $current_date2 = date('Y-m-d', $next_day);
1067 $events = fetchNextXAppts($current_date2, $stmt['pid'], $num_appts);
1068 $j=0;
1069 $out .= sprintf("%-s\n", $label_appointments);
1070 #loop to add the appointments
1071 for ($x = 1; $x <= $num_appts; $x++) {
1072 $next_appoint_date = oeFormatShortDate($events[$j]['pc_eventDate']);
1073 $next_appoint_time = substr($events[$j]['pc_startTime'], 0, 5);
1074 if (strlen(umname) != 0) {
1075 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['umname'] . ' ' . $events[$j]['ulname'];
1076 } else {
1077 $next_appoint_provider = $events[$j]['ufname'] . ' ' . $events[$j]['ulname'];
1080 if (strlen($next_appoint_time) != 0) {
1081 $label_plsnote[$j] = xlt('Date') . ': ' . text($next_appoint_date) . ' ' . xlt('Time') . ' ' . text($next_appoint_time) . ' ' . xlt('Provider') . ' ' . text($next_appoint_provider);
1082 $out .= sprintf("%-s\n", $label_plsnote[$j]);
1085 $j++;
1086 $count++;
1090 // while ($count++ < 29) $out .= "\n";
1091 $out .= sprintf("%-10s %s\n", null, $label_retpay);
1092 $out .= '</pre></div>';
1093 $out .= '<div style="width:7.0in;border-top:1pt dotted black;font-size:12px;margin:0px;"><br /><br />
1094 <table style="width:8in;margin-left:20px;"><tr><td style="width:4.5in;"><br />
1096 $out .= $label_payby.' '.$label_cards;
1097 $out .= "<br /><br />";
1098 $out .= $label_cardnum .': {TextInput} '.$label_expiry.': {smTextInput} / {smTextInput} <br /><br />';
1099 $out .= $label_sign .' {PatientSignature}<br />';
1100 $out .=" </td><td style=width:2.0in;vertical-align:middle;'>";
1101 $practice_cards = $GLOBALS['OE_SITE_DIR']. "/images/visa_mc_disc_credit_card_logos_176x35.gif";
1102 if (file_exists($GLOBALS['OE_SITE_DIR']."/images/visa_mc_disc_credit_card_logos_176x35.gif")) {
1103 //$out .= "<img onclick='getPayment()' src='$practice_cards' style='width:100%;margin:4px auto;'><br /><p>\n".$label_totaldue.": ".$stmt['amount']."</p>";
1104 $out .= "<br /><p>".$label_totaldue.": ".$stmt['amount']."</p>";
1107 $out .="</td></tr></table>";
1109 $out .= '</div><br />';
1110 if ($stmt['to'][3]!='') { //to avoid double blank lines the if condition is put.
1111 $out .= sprintf(" %-32s\n", $stmt['to'][3]);
1114 $out .= ' </pre>
1115 <div style="width:8in;border-top:1pt solid black;"><br />';
1116 $out .= " <table style='width:6.0in;margin-left:40px;'><tr>";
1117 $out .= '<td style="width:3.0in;"><b>'
1118 .$label_addressee.'</b><br />'
1119 .$stmt['to'][0].'<br />'
1120 .$stmt['to'][1].'<br />'
1121 .$stmt['to'][2].'
1122 </td>
1123 <td style="width:3.0in;"><b>'.$label_remitto.'</b><br />'
1124 .$remit_name.'<br />'
1125 .$remit_addr.'<br />'
1126 .$remit_csz.'
1127 </td>
1128 </tr></table>';
1130 $out .= " </div></div>";
1131 $out .= "\014
1132 <br /><br />"; // this is a form feed
1133 echo $out;
1134 $output = ob_get_clean();
1135 return $output;