Add back popup dialogs for tabs U.I. (#1434)
[openemr.git] / interface / reports / collections_report.php
blobad084e275f823d41ab1018ac7011813c5ce62711
1 <?php
2 /**
3 * Collections report
5 * (TLH) Added payor,provider,fixed cvs download to included selected fields
6 * (TLH) Added ability to download selected invoices only or all for patient
8 * @package OpenEMR
9 * @link http://www.open-emr.org
10 * @author Rod Roark <rod@sunsetsystems.com>
11 * @author Terry Hill <terry@lillysystems.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2006-2016 Rod Roark <rod@sunsetsystems.com>
14 * @copyright Copyright (c) 2015 Terry Hill <terry@lillysystems.com>
15 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 require_once("../globals.php");
21 require_once("../../library/patient.inc");
22 require_once("../../library/invoice_summary.inc.php");
23 require_once("../../library/sl_eob.inc.php");
24 require_once "$srcdir/options.inc.php";
26 use OpenEMR\Core\Header;
28 $alertmsg = '';
29 $bgcolor = "#aaaaaa";
30 $export_patient_count = 0;
31 $export_dollars = 0;
33 $form_date = (isset($_POST['form_date'])) ? DateToYYYYMMDD($_POST['form_date']) : "";
34 $form_to_date = (isset($_POST['form_to_date'])) ? DateToYYYYMMDD($_POST['form_to_date']) : "";
35 $is_ins_summary = $_POST['form_category'] == 'Ins Summary';
36 $is_due_ins = ($_POST['form_category'] == 'Due Ins') || $is_ins_summary;
37 $is_due_pt = $_POST['form_category'] == 'Due Pt';
38 $is_all = $_POST['form_category'] == 'All';
39 $is_ageby_lad = strpos($_POST['form_ageby'], 'Last') !== false;
40 $form_facility = $_POST['form_facility'];
41 $form_provider = $_POST['form_provider'];
42 $form_payer_id = $_POST['form_payer_id'];
44 if ($_POST['form_refresh'] || $_POST['form_export'] || $_POST['form_csvexport']) {
45 if ($is_ins_summary) {
46 $form_cb_ssn = false;
47 $form_cb_dob = false;
48 $form_cb_pubpid = false;
49 $form_cb_adate = false;
50 $form_cb_policy = false;
51 $form_cb_phone = false;
52 $form_cb_city = false;
53 $form_cb_ins1 = false;
54 $form_cb_referrer = false;
55 $form_cb_idays = false;
56 $form_cb_err = false;
57 } else {
58 $form_cb_ssn = $_POST['form_cb_ssn'] ? true : false;
59 $form_cb_dob = $_POST['form_cb_dob'] ? true : false;
60 $form_cb_pubpid = $_POST['form_cb_pubpid'] ? true : false;
61 $form_cb_adate = $_POST['form_cb_adate'] ? true : false;
62 $form_cb_policy = $_POST['form_cb_policy'] ? true : false;
63 $form_cb_phone = $_POST['form_cb_phone'] ? true : false;
64 $form_cb_city = $_POST['form_cb_city'] ? true : false;
65 $form_cb_ins1 = $_POST['form_cb_ins1'] ? true : false;
66 $form_cb_referrer = $_POST['form_cb_referrer'] ? true : false;
67 $form_cb_idays = $_POST['form_cb_idays'] ? true : false;
68 $form_cb_err = $_POST['form_cb_err'] ? true : false;
70 } else {
71 $form_cb_ssn = true;
72 $form_cb_dob = false;
73 $form_cb_pubpid = false;
74 $form_cb_adate = false;
75 $form_cb_policy = false;
76 $form_cb_phone = true;
77 $form_cb_city = false;
78 $form_cb_ins1 = false;
79 $form_cb_referrer = false;
80 $form_cb_idays = false;
81 $form_cb_err = false;
84 $form_age_cols = (int) $_POST['form_age_cols'];
85 $form_age_inc = (int) $_POST['form_age_inc'];
86 if ($form_age_cols > 0 && $form_age_cols < 50) {
87 if ($form_age_inc <= 0) {
88 $form_age_inc = 30;
90 } else {
91 $form_age_cols = 0;
92 $form_age_inc = 0;
95 $initial_colspan = 1;
96 if ($is_due_ins) {
97 ++$initial_colspan;
100 if ($form_cb_ssn) {
101 ++$initial_colspan;
104 if ($form_cb_dob) {
105 ++$initial_colspan;
108 if ($form_cb_pubpid) {
109 ++$initial_colspan;
112 if ($form_cb_policy) {
113 ++$initial_colspan;
116 if ($form_cb_phone) {
117 ++$initial_colspan;
120 if ($form_cb_city) {
121 ++$initial_colspan;
124 if ($form_cb_ins1) {
125 ++$initial_colspan;
128 if ($form_cb_referrer) {
129 ++$initial_colspan;
132 if ($form_provider) {
133 ++$initial_colspan;
136 if ($form_payer_id) {
137 ++$initial_colspan;
140 $final_colspan = $form_cb_adate ? 6 : 5;
141 $form_cb_with_debt = $_POST['form_cb_with_debt'] ? true : false;
142 $grand_total_charges = 0;
143 $grand_total_adjustments = 0;
144 $grand_total_paid = 0;
145 $grand_total_agedbal = array();
146 for ($c = 0; $c < $form_age_cols;
147 ++$c) {
148 $grand_total_agedbal[$c] = 0;
152 function bucks($amount)
154 if ($amount) {
155 return oeFormatMoney($amount); // was printf("%.2f", $amount);
159 function endPatient($ptrow)
161 global $export_patient_count, $export_dollars, $bgcolor;
162 global $grand_total_charges, $grand_total_adjustments, $grand_total_paid;
163 global $grand_total_agedbal, $is_due_ins, $form_age_cols;
164 global $initial_colspan, $final_colspan, $form_cb_idays, $form_cb_err;
166 if (!$ptrow['pid']) {
167 return;
170 $pt_balance = $ptrow['amount'] - $ptrow['paid'];
172 if ($_POST['form_export']) {
173 // This is a fixed-length format used by Transworld Systems. Your
174 // needs will surely be different, so consider this just an example.
176 echo "1896H"; // client number goes here
177 echo "000"; // filler
178 echo sprintf("%-30s", substr($ptrow['ptname'], 0, 30));
179 echo sprintf("%-30s", " ");
180 echo sprintf("%-30s", substr($ptrow['address1'], 0, 30));
181 echo sprintf("%-15s", substr($ptrow['city'], 0, 15));
182 echo sprintf("%-2s", substr($ptrow['state'], 0, 2));
183 echo sprintf("%-5s", $ptrow['zipcode'] ? substr($ptrow['zipcode'], 0, 5) : '00000');
184 echo "1"; // service code
185 echo sprintf("%010.0f", $ptrow['pid']); // transmittal number = patient id
186 echo " "; // filler
187 echo sprintf("%-15s", substr($ptrow['ss'], 0, 15));
188 echo substr($ptrow['dos'], 5, 2) . substr($ptrow['dos'], 8, 2) . substr($ptrow['dos'], 2, 2);
189 echo sprintf("%08.0f", $pt_balance * 100);
190 echo sprintf("%-9s\n", " ");
192 if (!$_POST['form_without']) {
193 sqlStatement("UPDATE patient_data SET " .
194 "billing_note = CONCAT('IN COLLECTIONS " . date("Y-m-d") . "', billing_note) " .
195 "WHERE pid = ? ", array($ptrow['pid']));
198 $export_patient_count += 1;
199 $export_dollars += $pt_balance;
200 } else if ($_POST['form_csvexport']) {
201 $export_patient_count += 1;
202 $export_dollars += $pt_balance;
203 } else {
204 if ($ptrow['count'] > 1) {
205 echo " <tr bgcolor='$bgcolor'>\n";
206 /***************************************************************
207 echo " <td class='detail' colspan='$initial_colspan'>";
208 echo "&nbsp;</td>\n";
209 echo " <td class='detotal' colspan='$final_colspan'>&nbsp;Total Patient Balance:</td>\n";
210 ***************************************************************/
211 echo " <td class='detotal' colspan='" . ($initial_colspan + $final_colspan) .
212 "'>&nbsp;" . xlt('Total Patient Balance') . ":</td>\n";
213 /**************************************************************/
214 if ($form_age_cols) {
215 for ($c = 0; $c < $form_age_cols; ++$c) {
216 echo " <td class='detotal' align='right'>&nbsp;" .
217 text(oeFormatMoney($ptrow['agedbal'][$c])) . "&nbsp;</td>\n";
219 } else {
220 echo " <td class='detotal' align='right'>&nbsp;" .
221 text(oeFormatMoney($pt_balance)) . "&nbsp;</td>\n";
224 if ($form_cb_idays) {
225 echo " <td class='detail'>&nbsp;</td>\n";
228 echo " <td class='detail' colspan='2'>&nbsp;</td>\n";
229 if ($form_cb_err) {
230 echo " <td class='detail'>&nbsp;</td>\n";
233 echo " </tr>\n";
237 $grand_total_charges += $ptrow['charges'];
238 $grand_total_adjustments += $ptrow['adjustments'];
239 $grand_total_paid += $ptrow['paid'];
240 for ($c = 0; $c < $form_age_cols; ++$c) {
241 $grand_total_agedbal[$c] += $ptrow['agedbal'][$c];
245 function endInsurance($insrow)
247 global $export_patient_count, $export_dollars, $bgcolor;
248 global $grand_total_charges, $grand_total_adjustments, $grand_total_paid;
249 global $grand_total_agedbal, $is_due_ins, $form_age_cols;
250 global $initial_colspan, $form_cb_idays, $form_cb_err;
251 if (!$insrow['pid']) {
252 return;
255 $ins_balance = $insrow['amount'] - $insrow['paid'];
256 if ($_POST['form_export'] || $_POST['form_csvexport']) {
257 // No exporting of insurance summaries.
258 $export_patient_count += 1;
259 $export_dollars += $ins_balance;
260 } else {
261 echo " <tr bgcolor='$bgcolor'>\n";
262 echo " <td class='detail'>" . text($insrow['insname']) . "</td>\n";
263 echo " <td class='detotal' align='right'>&nbsp;" .
264 text(oeFormatMoney($insrow['charges'])) . "&nbsp;</td>\n";
265 echo " <td class='detotal' align='right'>&nbsp;" .
266 text(oeFormatMoney($insrow['adjustments'])) . "&nbsp;</td>\n";
267 echo " <td class='detotal' align='right'>&nbsp;" .
268 text(oeFormatMoney($insrow['paid'])) . "&nbsp;</td>\n";
269 if ($form_age_cols) {
270 for ($c = 0; $c < $form_age_cols; ++$c) {
271 echo " <td class='detotal' align='right'>&nbsp;" .
272 text(oeFormatMoney($insrow['agedbal'][$c])) . "&nbsp;</td>\n";
274 } else {
275 echo " <td class='detotal' align='right'>&nbsp;" .
276 text(oeFormatMoney($ins_balance)) . "&nbsp;</td>\n";
279 echo " </tr>\n";
282 $grand_total_charges += $insrow['charges'];
283 $grand_total_adjustments += $insrow['adjustments'];
284 $grand_total_paid += $insrow['paid'];
285 for ($c = 0; $c < $form_age_cols; ++$c) {
286 $grand_total_agedbal[$c] += $insrow['agedbal'][$c];
290 function getInsName($payerid)
292 $tmp = sqlQuery("SELECT name FROM insurance_companies WHERE id = ? ", array($payerid));
293 return $tmp['name'];
296 // In the case of CSV export only, a download will be forced.
297 if ($_POST['form_csvexport']) {
298 header("Pragma: public");
299 header("Expires: 0");
300 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
301 header("Content-Type: application/force-download");
302 header("Content-Disposition: attachment; filename=collections_report.csv");
303 header("Content-Description: File Transfer");
304 } else {
306 <html>
307 <head>
309 <title><?php echo xlt('Collections Report')?></title>
311 <?php Header::setupHeader(['datetime-picker', 'report-helper']); ?>
313 <style type="text/css">
314 @media print {
315 #report_parameters {
316 visibility: hidden;
317 display: none;
319 #report_parameters_daterange {
320 visibility: visible;
321 display: inline;
323 #report_results {
324 margin-top: 30px;
328 /* specifically exclude some from the screen */
329 @media screen {
330 #report_parameters_daterange {
331 visibility: hidden;
332 display: none;
335 </style>
337 <script language="JavaScript">
338 $(document).ready(function() {
339 oeFixedHeaderSetup(document.getElementById('mymaintable'));
340 var win = top.printLogSetup ? top : opener.top;
341 win.printLogSetup(document.getElementById('printbutton'));
343 $('.datepicker').datetimepicker({
344 <?php $datetimepicker_timepicker = false; ?>
345 <?php $datetimepicker_showseconds = false; ?>
346 <?php $datetimepicker_formatInput = true; ?>
347 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
348 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
352 function checkAll(checked) {
353 var f = document.forms[0];
354 for (var i = 0; i < f.elements.length; ++i) {
355 var ename = f.elements[i].name;
356 if (ename.indexOf('form_cb[') == 0)
357 f.elements[i].checked = checked;
360 </script>
362 </head>
364 <body class="body_top">
366 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Collections'); ?></span>
368 <form method='post' action='collections_report.php' enctype='multipart/form-data' id='theform' onsubmit='return top.restoreSession()'>
370 <div id="report_parameters">
372 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
373 <input type='hidden' name='form_export' id='form_export' value=''/>
374 <input type='hidden' name='form_csvexport' id='form_csvexport' value=''/>
376 <table>
377 <tr>
378 <td width='610px'>
379 <div style='float:left'>
381 <table class='text'>
382 <tr>
383 <td class='control-label'>
384 <table>
385 <tr>
386 <td><?php echo xlt('Displayed Columns') ?>:</td>
387 </tr>
388 <tr>
389 <td>
390 <label><input type='checkbox' name='form_cb_ssn'<?php echo ($form_cb_ssn) ? ' checked' : ''; ?>>
391 <?php echo xlt('SSN') ?>&nbsp;</label>
392 </td>
393 <td>
394 <label><input type='checkbox' name='form_cb_dob'<?php echo ($form_cb_dob) ? ' checked' : ''; ?>>
395 <?php echo xlt('DOB') ?>&nbsp;</label>
396 </td>
397 <td>
398 <label><input type='checkbox' name='form_cb_pubpid'<?php echo ($form_cb_pubpid) ? ' checked' : ''; ?>>
399 <?php echo xlt('ID') ?>&nbsp;</label>
400 </td>
401 <td>
402 <label><input type='checkbox' name='form_cb_policy'<?php echo ($form_cb_policy) ? ' checked' : ''; ?>>
403 <?php echo xlt('Policy') ?>&nbsp;</label>
404 </td>
405 <td>
406 <label><input type='checkbox' name='form_cb_phone'<?php echo ($form_cb_phone) ? ' checked' : ''; ?>>
407 <?php echo xlt('Phone') ?>&nbsp;</label>
408 </td>
409 <td>
410 <label><input type='checkbox' name='form_cb_city'<?php echo ($form_cb_city) ? ' checked' : ''; ?>>
411 <?php echo xlt('City') ?>&nbsp;</label>
412 </td>
413 </tr>
414 <tr>
415 <td>
416 <label><input type='checkbox' name='form_cb_ins1'<?php echo ($form_cb_ins1) ? ' checked' : ''; ?>>
417 <?php echo xlt('Primary Ins') ?>&nbsp;</label>
418 </td>
419 <td>
420 <label><input type='checkbox' name='form_cb_referrer'<?php echo ($form_cb_referrer) ? ' checked' : ''; ?>>
421 <?php echo xlt('Referrer') ?>&nbsp;</label>
422 </td>
423 <td>
424 <label><input type='checkbox' name='form_cb_adate'<?php echo ($form_cb_adate) ? ' checked' : ''; ?>>
425 <?php echo xlt('Act Date') ?>&nbsp;</label>
426 </td>
427 <td>
428 <label><input type='checkbox' name='form_cb_idays'<?php echo ($form_cb_idays) ? ' checked' : ''; ?>>
429 <?php echo xlt('Inactive Days') ?>&nbsp;</label>
430 </td>
431 <td>
432 <label><input type='checkbox' name='form_cb_err'<?php echo ($form_cb_err) ? ' checked' : ''; ?>>
433 <?php echo xlt('Errors') ?></label>
434 </td>
435 </tr>
436 </table>
437 </td>
438 </tr>
439 </tr>
440 <td>
441 <table>
443 <tr>
444 <td class='control-label'>
445 <?php echo xlt('Service Date'); ?>:
446 </td>
447 <td>
448 <input type='text' class='datepicker form-control' name='form_date' id="form_date" size='10' value='<?php echo attr(oeFormatShortDate($form_date)); ?>'>
449 </td>
450 <td class='control-label'>
451 <?php echo xlt('To'); ?>:
452 </td>
453 <td>
454 <input type='text' class='datepicker form-control' name='form_to_date' id="form_to_date" size='10' value='<?php echo attr(oeFormatShortDate($form_to_date)); ?>'>
455 </td>
456 <td>
457 <select name='form_category' class='form-control'>
458 <?php
459 foreach (array('Open' => xl('Open'),'Due Pt' => xl('Due Pt'),'Due Ins' => xl('Due Ins'),'Ins Summary' => xl('Ins Summary'),'Credits' => xl('Credits'),'All' => xl('All')) as $key => $value) {
460 echo " <option value='" . attr($key) . "'";
461 if ($_POST['form_category'] == $key) {
462 echo " selected";
465 echo ">" . text($value) . "</option>\n";
468 </select>
469 </td>
471 </tr>
474 <tr>
475 <td class='control-label'>
476 <?php echo xlt('Facility'); ?>:
477 </td>
478 <td>
479 <?php dropdown_facility($form_facility, 'form_facility', false); ?>
480 </td>
482 <td class='control-label'>
483 <?php echo xlt('Payor'); ?>:
484 </td>
485 <td>
486 <?php # added dropdown for payors (TLH)
487 $insurancei = getInsuranceProviders();
488 echo " <select name='form_payer_id' class='form-control'>\n";
489 echo " <option value='0'>-- " . xlt('All') . " --</option>\n";
490 foreach ($insurancei as $iid => $iname) {
491 echo "<option value='" . attr($iid) . "'";
492 if ($iid == $_POST['form_payer_id']) {
493 echo " selected";
496 echo ">" . text($iname) . "</option>\n";
497 if ($iid == $_POST['form_payer_id']) {
498 $ins_co_name = $iname;
502 echo " </select>\n";
504 </td>
505 </tr>
507 <tr>
508 <td class='control-label'>
509 <?php echo xlt('Age By') ?>:
510 </td>
511 <td>
512 <select name='form_ageby' class='form-control'>
513 <?php
514 foreach (array( 'Service Date'=>xl('Service Date'), 'Last Activity Date'=>xl('Last Activity Date')) as $key => $value) {
515 echo " <option value='" . attr($key) . "'";
516 if ($_POST['form_ageby'] == $value) {
517 echo " selected";
520 echo ">" . text($value) . "</option>\n";
523 </select>
524 </td>
526 <td class='control-label'>
527 <?php echo xlt('Provider') ?>:
528 </td>
529 <td>
530 <?php # Build a drop-down list of providers.
531 # Added (TLH)
533 $query = "SELECT id, lname, fname FROM users WHERE ".
534 "authorized = 1 ORDER BY lname, fname"; #(CHEMED) facility filter
536 $ures = sqlStatement($query);
538 echo " <select name='form_provider' class='form-control'>\n";
539 echo " <option value=''>-- " . xlt('All') . " --\n";
541 while ($urow = sqlFetchArray($ures)) {
542 $provid = $urow['id'];
543 echo " <option value='" . attr($provid) . "'";
544 if ($provid == $_POST['form_provider']) {
545 echo " selected";
548 echo ">" . text($urow['lname']) . ", " . text($urow['fname']) . "\n";
549 if ($provid == $_POST['form_provider']) {
550 $provider_name = $urow['lname'] . ", " . $urow['fname'];
554 echo " </select>\n";
556 </td>
557 </tr>
558 </tr>
559 <td class='control-label'>
560 <?php echo xlt('Aging Columns') ?>:
561 </td>
562 <td>
563 <input type='text' name='form_age_cols' class='form-control' size='2' value='<?php echo attr($form_age_cols); ?>' />
564 </td>
565 <td class='control-label'>
566 <?php echo xlt('Days/Col') ?>:
567 </td>
568 <td>
569 <input type='text' name='form_age_inc' class='form-control' size='3' value='<?php echo attr($form_age_inc); ?>' />
570 </td>
571 <td>
572 <div class="checkbox">
573 <label><input type='checkbox' name='form_cb_with_debt'<?php echo ($form_cb_with_debt) ? ' checked' : ''; ?>>
574 <?php echo xlt('Patients with debt') ?></label>
575 </div>
576 </td>
577 </tr>
580 </table>
581 </td>
582 </tr>
583 </table>
585 </div>
587 </td>
588 <td align='left' valign='middle' height="100%">
589 <table style='border-left:1px solid; width:100%; height:100%' >
590 <tr>
591 <td>
592 <div class="text-center">
593 <div class="btn-group" role="group">
594 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); $("#form_csvexport").val(""); $("#theform").submit();'>
595 <?php echo xlt('Submit'); ?>
596 </a>
597 <?php if ($_POST['form_refresh']) { ?>
598 <a href='#' class='btn btn-default btn-print' onclick='window.print()'>
599 <?php echo xlt('Print'); ?>
600 </a>
601 <?php } ?>
602 </div>
603 </div>
604 </td>
605 </tr>
606 </table>
607 </td>
608 </tr>
609 </table>
610 </div>
613 <?php
614 } // end not form_csvexport
616 if ($_POST['form_refresh'] || $_POST['form_export'] || $_POST['form_csvexport']) {
617 $rows = array();
618 $where = "";
619 $sqlArray = array();
620 if ($_POST['form_export'] || $_POST['form_csvexport']) {
621 $where = "( 1 = 2";
622 foreach ($_POST['form_cb'] as $key => $value) {
623 list($key_newval['pid'], $key_newval['encounter']) = explode(".", $key);
624 $newkey = $key_newval['pid'];
625 $newencounter = $key_newval['encounter'];
626 # added this condition to handle the downloading of individual invoices (TLH)
627 if ($_POST['form_individual'] ==1) {
628 $where .= " OR f.encounter = ? ";
629 array_push($sqlArray, $newencounter);
630 } else {
631 $where .= " OR f.pid = ? ";
632 array_push($sqlArray, $newkey);
636 $where .= ' )';
639 if ($form_date) {
640 if ($where) {
641 $where .= " AND ";
644 if ($form_to_date) {
645 $where .= "f.date >= ? AND f.date <= ? ";
646 array_push($sqlArray, $form_date.' 00:00:00', $form_to_date.' 23:59:59');
647 } else {
648 $where .= "f.date >= ? AND f.date <= ? ";
649 array_push($sqlArray, $form_date.' 00:00:00', $form_date.' 23:59:59');
653 if ($form_facility) {
654 if ($where) {
655 $where .= " AND ";
658 $where .= "f.facility_id = ? ";
659 array_push($sqlArray, $form_facility);
662 # added for filtering by provider (TLH)
663 if ($form_provider) {
664 if ($where) {
665 $where .= " AND ";
668 $where .= "f.provider_id = ? ";
669 array_push($sqlArray, $form_provider);
672 if (! $where) {
673 $where = "1 = 1";
676 # added provider from encounter to the query (TLH)
677 $query = "SELECT f.id, f.date, f.pid, CONCAT(w.lname, ', ', w.fname) AS provider_id, f.encounter, f.last_level_billed, " .
678 "f.last_level_closed, f.last_stmt_date, f.stmt_count, f.invoice_refno, " .
679 "p.fname, p.mname, p.lname, p.street, p.city, p.state, " .
680 "p.postal_code, p.phone_home, p.ss, p.billing_note, " .
681 "p.pubpid, p.DOB, CONCAT(u.lname, ', ', u.fname) AS referrer, " .
682 "( SELECT SUM(b.fee) FROM billing AS b WHERE " .
683 "b.pid = f.pid AND b.encounter = f.encounter AND " .
684 "b.activity = 1 AND b.code_type != 'COPAY' ) AS charges, " .
685 "( SELECT SUM(b.fee) FROM billing AS b WHERE " .
686 "b.pid = f.pid AND b.encounter = f.encounter AND " .
687 "b.activity = 1 AND b.code_type = 'COPAY' ) AS copays, " .
688 "( SELECT SUM(s.fee) FROM drug_sales AS s WHERE " .
689 "s.pid = f.pid AND s.encounter = f.encounter ) AS sales, " .
690 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
691 "a.pid = f.pid AND a.encounter = f.encounter ) AS payments, " .
692 "( SELECT SUM(a.adj_amount) FROM ar_activity AS a WHERE " .
693 "a.pid = f.pid AND a.encounter = f.encounter ) AS adjustments " .
694 "FROM form_encounter AS f " .
695 "JOIN patient_data AS p ON p.pid = f.pid " .
696 "LEFT OUTER JOIN users AS u ON u.id = p.ref_providerID " .
697 "LEFT OUTER JOIN users AS w ON w.id = f.provider_id " .
698 "WHERE $where " .
699 "ORDER BY f.pid, f.encounter";
701 $eres = sqlStatement($query, $sqlArray);
703 while ($erow = sqlFetchArray($eres)) {
704 $patient_id = $erow['pid'];
705 $encounter_id = $erow['encounter'];
706 $pt_balance = $erow['charges'] + $erow['sales'] + $erow['copays'] - $erow['payments'] - $erow['adjustments'];
707 $pt_balance = 0 + sprintf("%.2f", $pt_balance); // yes this seems to be necessary
708 $svcdate = substr($erow['date'], 0, 10);
710 if ($form_cb_with_debt && $pt_balance<=0) {
711 unset($erow);
712 continue;
715 if ($_POST['form_refresh'] && ! $is_all) {
716 if ($pt_balance == 0) {
717 continue;
721 if ($_POST['form_category'] == 'Credits') {
722 if ($pt_balance > 0) {
723 continue;
727 // If we have not yet billed the patient, then compute $duncount as a
728 // negative count of the number of insurance plans for which we have not
729 // yet closed out insurance. Here we also compute $insname as the name of
730 // the insurance plan from which we are awaiting payment, and its sequence
731 // number $insposition (1-3).
732 $last_level_closed = $erow['last_level_closed'];
733 $duncount = $erow['stmt_count'];
734 $payerids = array();
735 $insposition = 0;
736 $insname = '';
737 if (! $duncount) {
738 for ($i = 1; $i <= 3; ++$i) {
739 $tmp = arGetPayerID($patient_id, $svcdate, $i);
740 if (empty($tmp)) {
741 break;
744 $payerids[] = $tmp;
747 $duncount = $last_level_closed - count($payerids);
748 if ($duncount < 0) {
749 if (!empty($payerids[$last_level_closed])) {
750 $insname = getInsName($payerids[$last_level_closed]);
751 $insposition = $last_level_closed + 1;
756 // Skip invoices not in the desired "Due..." category.
758 if ($is_due_ins && $duncount >= 0) {
759 continue;
762 if ($is_due_pt && $duncount < 0) {
763 continue;
766 // echo "<!-- " . $erow['encounter'] . ': ' . $erow['charges'] . ' + ' . $erow['sales'] . ' + ' . $erow['copays'] . ' - ' . $erow['payments'] . ' - ' . $erow['adjustments'] . " -->\n"; // debugging
768 // An invoice is due from the patient if money is owed and we are
769 // not waiting for insurance to pay.
770 $isduept = ($duncount >= 0) ? " checked" : "";
772 $row = array();
774 $row['id'] = $erow['id'];
775 $row['invnumber'] = "$patient_id.$encounter_id";
776 $row['custid'] = $patient_id;
777 $row['name'] = $erow['fname'] . ' ' . $erow['lname'];
778 $row['address1'] = $erow['street'];
779 $row['city'] = $erow['city'];
780 $row['state'] = $erow['state'];
781 $row['zipcode'] = $erow['postal_code'];
782 $row['phone'] = $erow['phone_home'];
783 $row['duncount'] = $duncount;
784 $row['dos'] = $svcdate;
785 $row['ss'] = $erow['ss'];
786 $row['DOB'] = $erow['DOB'];
787 $row['pubpid'] = $erow['pubpid'];
788 $row['billnote'] = $erow['billing_note'];
789 $row['referrer'] = $erow['referrer'];
790 $row['provider'] = $erow['provider_id'];
791 $row['irnumber'] = $erow['invoice_refno'];
793 // Also get the primary insurance company name whenever there is one.
794 $row['ins1'] = '';
795 if ($insposition == 1) {
796 $row['ins1'] = $insname;
797 } else {
798 if (empty($payerids)) {
799 $tmp = arGetPayerID($patient_id, $svcdate, 1);
800 if (!empty($tmp)) {
801 $payerids[] = $tmp;
805 if (!empty($payerids)) {
806 $row['ins1'] = getInsName($payerids[0]);
810 // This computes the invoice's total original charges and adjustments,
811 // date of last activity, and determines if insurance has responded to
812 // all billing items.
813 $invlines = ar_get_invoice_summary($patient_id, $encounter_id, true);
815 // if ($encounter_id == 185) { // debugging
816 // echo "\n<!--\n";
817 // print_r($invlines);
818 // echo "\n-->\n";
819 // }
821 $row['charges'] = 0;
822 $row['adjustments'] = 0;
823 $row['paid'] = 0;
824 $ins_seems_done = true;
825 $ladate = $svcdate;
826 foreach ($invlines as $key => $value) {
827 $row['charges'] += $value['chg'] + $value['adj'];
828 $row['adjustments'] += 0 - $value['adj'];
829 $row['paid'] += $value['chg'] - $value['bal'];
830 foreach ($value['dtl'] as $dkey => $dvalue) {
831 $dtldate = trim(substr($dkey, 0, 10));
832 if ($dtldate && $dtldate > $ladate) {
833 $ladate = $dtldate;
837 $lckey = strtolower($key);
838 if ($lckey == 'co-pay' || $lckey == 'claim') {
839 continue;
842 if (count($value['dtl']) <= 1) {
843 $ins_seems_done = false;
847 // Simulating ar.amount in SQL-Ledger which is charges with adjustments:
848 $row['amount'] = $row['charges'] + $row['adjustments'];
850 $row['billing_errmsg'] = '';
851 if ($is_due_ins && $last_level_closed < 1 && $ins_seems_done) {
852 $row['billing_errmsg'] = 'Ins1 seems done';
853 } else if ($last_level_closed >= 1 && !$ins_seems_done) {
854 $row['billing_errmsg'] = 'Ins1 seems not done';
857 $row['ladate'] = $ladate;
859 // Compute number of days since last activity.
860 $latime = mktime(
864 substr($ladate, 5, 2),
865 substr($ladate, 8, 2),
866 substr($ladate, 0, 4)
868 $row['inactive_days'] = floor((time() - $latime) / (60 * 60 * 24));
870 // Look up insurance policy number if we need it.
871 if ($form_cb_policy) {
872 $instype = ($insposition == 2) ? 'secondary' : (($insposition == 3) ? 'tertiary' : 'primary');
873 $insrow = sqlQuery("SELECT policy_number FROM insurance_data WHERE " .
874 "pid = ? AND type = ? AND date <= ? " .
875 "ORDER BY date DESC LIMIT 1", array($patient_id, $instype, $svcdate));
876 $row['policy'] = $insrow['policy_number'];
879 $ptname = $erow['lname'] . ", " . $erow['fname'];
880 if ($erow['mname']) {
881 $ptname .= " " . substr($erow['mname'], 0, 1);
884 if (!$is_due_ins) {
885 $insname = '';
888 $rows[$insname . '|' . $ptname . '|' . $encounter_id] = $row;
889 } // end while
892 ksort($rows);
894 if ($_POST['form_export']) {
895 echo "<textarea rows='35' cols='100' readonly>";
896 } else if ($_POST['form_csvexport']) {
897 # CSV headers added conditions if they are checked to display then export them (TLH)
898 if (true) {
899 echo '"' . xl('Insurance') . '",';
900 echo '"' . xl('Name') . '",';
901 if ($form_cb_ssn) {
902 echo '"' . xl('SSN') . '",';
905 if ($form_cb_dob) {
906 echo '"' . xl('DOB') . '",';
909 if ($form_cb_pubid) {
910 echo '"' . xl('Pubid') . '",';
913 if ($form_cb_policy) {
914 echo '"' . xl('Policy') . '",';
917 if ($form_cb_phone) {
918 echo '"' . xl('Phone') . '",';
921 if ($form_cb_city) {
922 echo '"' . xl('City') . '",';
925 echo '"' . xl('Invoice') . '",';
926 echo '"' . xl('DOS') . '",';
927 echo '"' . xl('Referrer') . '",';
928 echo '"' . xl('Provider') . '",';
929 echo '"' . xl('Charge') . '",';
930 echo '"' . xl('Adjust') . '",';
931 echo '"' . xl('Paid') . '",';
932 echo '"' . xl('Balance') . '",';
933 echo '"' . xl('IDays') . '",';
934 if ($form_cb_err) {
935 echo '"' . xl('LADate') . '",';
936 echo '"' . xl('Error') . '"' . "\n";
937 } else {
938 echo '"' . xl('LADate') . '"' . "\n";
941 } else {
944 <div id="report_results">
945 <table id='mymaintable'>
947 <thead>
948 <?php if ($is_due_ins) { ?>
949 <th>&nbsp;<?php echo xlt('Insurance')?></th>
950 <?php } ?>
951 <?php if (!$is_ins_summary) { ?>
952 <th>&nbsp;<?php echo xlt('Name')?></th>
953 <?php } ?>
954 <?php if ($form_cb_ssn) { ?>
955 <th>&nbsp;<?php echo xlt('SSN')?></th>
956 <?php } ?>
957 <?php if ($form_cb_dob) { ?>
958 <th>&nbsp;<?php echo xlt('DOB')?></th>
959 <?php } ?>
960 <?php if ($form_cb_pubpid) { ?>
961 <th>&nbsp;<?php echo xlt('ID')?></th>
962 <?php } ?>
963 <?php if ($form_cb_policy) { ?>
964 <th>&nbsp;<?php echo xlt('Policy')?></th>
965 <?php } ?>
966 <?php if ($form_cb_phone) { ?>
967 <th>&nbsp;<?php echo xlt('Phone')?></th>
968 <?php } ?>
969 <?php if ($form_cb_city) { ?>
970 <th>&nbsp;<?php echo xlt('City')?></th>
971 <?php } ?>
972 <?php if ($form_cb_ins1 || $form_payer_id) { ?>
973 <th>&nbsp;<?php echo xlt('Primary Ins')?></th>
974 <?php } ?>
975 <?php if ($form_provider) { ?>
976 <th>&nbsp;<?php echo xlt('Provider')?></th>
977 <?php } ?>
978 <?php if ($form_cb_referrer) { ?>
979 <th>&nbsp;<?php echo xlt('Referrer')?></th>
980 <?php } ?>
981 <?php if (!$is_ins_summary) { ?>
982 <th>&nbsp;<?php echo xlt('Invoice') ?></th>
983 <th>&nbsp;<?php echo xlt('Svc Date') ?></th>
984 <?php if ($form_cb_adate) { ?>
985 <th>&nbsp;<?php echo xlt('Act Date')?></th>
986 <?php } ?>
987 <?php } ?>
988 <th align="right"><?php echo xlt('Charge') ?>&nbsp;</th>
989 <th align="right"><?php echo xlt('Adjust') ?>&nbsp;</th>
990 <th align="right"><?php echo xlt('Paid') ?>&nbsp;</th>
991 <?php
992 // Generate aging headers if appropriate, else balance header.
993 if ($form_age_cols) {
994 for ($c = 0; $c < $form_age_cols;) {
995 echo " <th class='dehead' align='right'>";
996 echo $form_age_inc * $c;
997 if (++$c < $form_age_cols) {
998 echo "-" . ($form_age_inc * $c - 1);
999 } else {
1000 echo "+";
1003 echo "</th>\n";
1005 } else {
1007 <th align="right"><?php echo xlt('Balance') ?>&nbsp;</th>
1008 <?php
1011 <?php if ($form_cb_idays) { ?>
1012 <th align="right"><?php echo xlt('IDays')?>&nbsp;</th>
1013 <?php } ?>
1014 <?php if (!$is_ins_summary) { ?>
1015 <th align="center"><?php echo xlt('Prv') ?></th>
1016 <th align="center"><?php echo xlt('Sel') ?></th>
1017 <?php } ?>
1018 <?php if ($form_cb_err) { ?>
1019 <th>&nbsp;<?php echo xlt('Error')?></th>
1020 <?php } ?>
1021 </thead>
1023 <?php
1024 } // end not export
1026 $ptrow = array('insname' => '', 'pid' => 0);
1027 $orow = -1;
1029 foreach ($rows as $key => $row) {
1030 list($insname, $ptname, $trash) = explode('|', $key);
1031 list($pid, $encounter) = explode(".", $row['invnumber']);
1032 if ($form_payer_id) {
1033 if ($ins_co_name <> $row['ins1']) {
1034 continue;
1038 if ($is_ins_summary && $insname != $ptrow['insname']) {
1039 endInsurance($ptrow);
1040 $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff");
1041 $ptrow = array('insname' => $insname, 'ptname' => $ptname, 'pid' => $pid, 'count' => 1);
1042 foreach ($row as $key => $value) {
1043 $ptrow[$key] = $value;
1046 $ptrow['agedbal'] = array();
1047 } else if (!$is_ins_summary && ($insname != $ptrow['insname'] || $pid != $ptrow['pid'])) {
1048 // For the report, this will write the patient totals. For the
1049 // collections export this writes everything for the patient:
1050 endPatient($ptrow);
1051 $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff");
1052 $ptrow = array('insname' => $insname, 'ptname' => $ptname, 'pid' => $pid, 'count' => 1);
1053 foreach ($row as $key => $value) {
1054 $ptrow[$key] = $value;
1057 $ptrow['agedbal'] = array();
1058 } else {
1059 $ptrow['amount'] += $row['amount'];
1060 $ptrow['paid'] += $row['paid'];
1061 $ptrow['charges'] += $row['charges'];
1062 $ptrow['adjustments'] += $row['adjustments'];
1063 ++$ptrow['count'];
1066 // Compute invoice balance and aging column number, and accumulate aging.
1067 $balance = $row['charges'] + $row['adjustments'] - $row['paid'];
1068 if ($form_age_cols) {
1069 $agedate = $is_ageby_lad ? $row['ladate'] : $row['dos'];
1070 $agetime = mktime(
1074 substr($agedate, 5, 2),
1075 substr($agedate, 8, 2),
1076 substr($agedate, 0, 4)
1078 $days = floor((time() - $agetime) / (60 * 60 * 24));
1079 $agecolno = min($form_age_cols - 1, max(0, floor($days / $form_age_inc)));
1080 $ptrow['agedbal'][$agecolno] += $balance;
1083 if (!$is_ins_summary && !$_POST['form_export'] && !$_POST['form_csvexport']) {
1084 $in_collections = stristr($row['billnote'], 'IN COLLECTIONS') !== false;
1086 <tr bgcolor='<?php echo attr($bgcolor) ?>'>
1087 <?php
1088 if ($ptrow['count'] == 1) {
1089 if ($is_due_ins) {
1090 echo " <td class='detail'>&nbsp;" . text($insname) ."</td>\n";
1093 echo " <td class='detail'>&nbsp;" . text($ptname) ."</td>\n";
1094 if ($form_cb_ssn) {
1095 echo " <td class='detail'>&nbsp;" . text($row['ss']) . "</td>\n";
1098 if ($form_cb_dob) {
1099 echo " <td class='detail'>&nbsp;" . text(oeFormatShortDate($row['DOB'])) . "</td>\n";
1102 if ($form_cb_pubpid) {
1103 echo " <td class='detail'>&nbsp;" . text($row['pubpid']) . "</td>\n";
1106 if ($form_cb_policy) {
1107 echo " <td class='detail'>&nbsp;" . text($row['policy']) . "</td>\n";
1110 if ($form_cb_phone) {
1111 echo " <td class='detail'>&nbsp;" . text($row['phone']) . "</td>\n";
1114 if ($form_cb_city) {
1115 echo " <td class='detail'>&nbsp;" . text($row['city']) . "</td>\n";
1118 if ($form_cb_ins1 || $form_payer_id) {
1119 echo " <td class='detail'>&nbsp;" . text($row['ins1']) . "</td>\n";
1122 if ($form_provider) {
1123 echo " <td class='detail'>&nbsp;" . text($provider_name) . "</td>\n";
1126 if ($form_cb_referrer) {
1127 echo " <td class='detail'>&nbsp;" . text($row['referrer']) . "</td>\n";
1129 } else {
1130 echo " <td class='detail' colspan='" . attr($initial_colspan) . "'>";
1131 echo "&nbsp;</td>\n";
1134 <td class="detail">
1135 &nbsp;<a href="../billing/sl_eob_invoice.php?id=<?php echo attr($row['id']) ?>"
1136 target="_blank"><?php echo empty($row['irnumber']) ? text($row['invnumber']) : text($row['irnumber']); ?></a>
1137 </td>
1138 <td class="detail">
1139 &nbsp;<?php echo text(oeFormatShortDate($row['dos'])); ?>
1140 </td>
1141 <?php if ($form_cb_adate) { ?>
1142 <td class='detail'>
1143 &nbsp;<?php echo text(oeFormatShortDate($row['ladate'])); ?>
1144 </td>
1145 <?php } ?>
1146 <td class="detail" align="right">
1147 <?php echo text(bucks($row['charges'])) ?>&nbsp;
1148 </td>
1149 <td class="detail" align="right">
1150 <?php echo text(bucks($row['adjustments'])) ?>&nbsp;
1151 </td>
1152 <td class="detail" align="right">
1153 <?php echo text(bucks($row['paid'])) ?>&nbsp;
1154 </td>
1155 <?php
1156 if ($form_age_cols) {
1157 for ($c = 0; $c < $form_age_cols; ++$c) {
1158 echo " <td class='detail' align='right'>";
1159 if ($c == $agecolno) {
1160 echo text(bucks($balance));
1163 echo "&nbsp;</td>\n";
1165 } else {
1167 <td class="detail" align="right"><?php echo text(bucks($balance)); ?>&nbsp;</td>
1168 <?php
1169 } // end else
1171 <?php
1172 if ($form_cb_idays) {
1173 echo " <td class='detail' align='right'>";
1174 echo text($row['inactive_days']) . "&nbsp;</td>\n";
1177 <td class="detail" align="center">
1178 <?php echo $row['duncount'] ? text($row['duncount']) : "&nbsp;" ?>
1179 </td>
1180 <td class="detail" align="center">
1181 <?php
1182 if ($in_collections) {
1183 echo " <b><font color='red'>IC</font></b>\n";
1184 } else {
1185 echo " <input type='checkbox' name='form_cb[" . attr($row['invnumber']) . "]' />\n";
1188 </td>
1189 <?php
1190 if ($form_cb_err) {
1191 echo " <td class='detail'>&nbsp;";
1192 echo text($row['billing_errmsg']) . "</td>\n";
1195 </tr>
1196 <?php
1197 } // end not export and not insurance summary
1199 else if ($_POST['form_csvexport']) {
1200 # The CSV detail line is written here added conditions for checked items (TLH).
1201 $balance = $row['charges'] + $row['adjustments'] - $row['paid'];
1202 if ($balance >0) {
1203 // echo '"' . $insname . '",';
1204 echo '"' . $row['ins1'] . '",';
1205 echo '"' . $ptname . '",';
1206 if ($form_cb_ssn) {
1207 echo '"' . $row['ss'] . '",';
1210 if ($form_cb_dob) {
1211 echo '"' . oeFormatShortDate($row['DOB']) . '",';
1214 if ($form_cb_pubid) {
1215 echo '"' . $row['pubpid'] . '",';
1218 if ($form_cb_policy) {
1219 echo '"' . $row['policy'] . '",';
1222 if ($form_cb_phone) {
1223 echo '"' . $row['phone'] . '",';
1226 if ($form_cb_city) {
1227 echo '"' . $row['city'] . '",';
1230 echo '"' . (empty($row['irnumber']) ? $row['invnumber'] : $row['irnumber']) . '",';
1231 echo '"' . oeFormatShortDate($row['dos']) . '",';
1232 echo '"' . $row['referrer'] . '",';
1233 echo '"' . $row['provider'] . '",';
1234 echo '"' . oeFormatMoney($row['charges']) . '",';
1235 echo '"' . oeFormatMoney($row['adjustments']) . '",';
1236 echo '"' . oeFormatMoney($row['paid']) . '",';
1237 echo '"' . oeFormatMoney($balance) . '",';
1238 echo '"' . $row['inactive_days'] . '",';
1239 if ($form_cb_err) {
1240 echo '"' . oeFormatShortDate($row['ladate']) . '",';
1241 echo '"' . $row['billing_errmsg'] . '"' . "\n";
1242 } else {
1243 echo '"' . oeFormatShortDate($row['ladate']) . '"' . "\n";
1246 } // end $form_csvexport
1247 } // end loop
1249 if ($is_ins_summary) {
1250 endInsurance($ptrow);
1251 } else {
1252 endPatient($ptrow);
1255 if ($_POST['form_export']) {
1256 echo "</textarea>\n";
1257 $alertmsg .= "$export_patient_count patients with total of " .
1258 oeFormatMoney($export_dollars) . " have been exported ";
1259 if ($_POST['form_without']) {
1260 $alertmsg .= "but NOT flagged as in collections.";
1261 } else {
1262 $alertmsg .= "AND flagged as in collections.";
1264 } else if ($_POST['form_csvexport']) {
1265 // echo "</textarea>\n";
1266 // $alertmsg .= "$export_patient_count patients representing $" .
1267 // sprintf("%.2f", $export_dollars) . " have been exported.";
1268 } else {
1269 echo " <tr bgcolor='#ffffff'>\n";
1270 if ($is_ins_summary) {
1271 echo " <td class='dehead'>&nbsp;" . xlt('Report Totals') . ":</td>\n";
1272 } else {
1273 echo " <td class='detail' colspan='" . attr($initial_colspan) . "'>\n";
1274 echo " &nbsp;</td>\n";
1275 echo " <td class='dehead' colspan='" . attr($final_colspan - 3) .
1276 "'>&nbsp;" . xlt('Report Totals') . ":</td>\n";
1279 echo " <td class='dehead' align='right'>&nbsp;" .
1280 text(oeFormatMoney($grand_total_charges)) . "&nbsp;</td>\n";
1281 echo " <td class='dehead' align='right'>&nbsp;" .
1282 text(oeFormatMoney($grand_total_adjustments)) . "&nbsp;</td>\n";
1283 echo " <td class='dehead' align='right'>&nbsp;" .
1284 text(oeFormatMoney($grand_total_paid)) . "&nbsp;</td>\n";
1285 if ($form_age_cols) {
1286 for ($c = 0; $c < $form_age_cols; ++$c) {
1287 echo " <td class='dehead' align='right'>" .
1288 text(oeFormatMoney($grand_total_agedbal[$c])) . "&nbsp;</td>\n";
1290 } else {
1291 echo " <td class='dehead' align='right'>" .
1292 text(oeFormatMoney($grand_total_charges +
1293 $grand_total_adjustments - $grand_total_paid)) . "&nbsp;</td>\n";
1296 if ($form_cb_idays) {
1297 echo " <td class='detail'>&nbsp;</td>\n";
1300 if (!$is_ins_summary) {
1301 echo " <td class='detail' colspan='2'>&nbsp;</td>\n";
1304 if ($form_cb_err) {
1305 echo " <td class='detail'>&nbsp;</td>\n";
1308 echo " </tr>\n";
1309 echo "</table>\n";
1310 echo "</div>\n";
1312 } // end if form_refresh
1315 if (!$_POST['form_csvexport']) {
1316 if (!$_POST['form_export']) {
1319 <div style='float;margin-top:5px'>
1320 <div class="btn-group pull-left" role="group">
1321 <a href='javascript:;' class='btn btn-default btn-save' onclick='checkAll(true)'><?php echo xlt('Select All'); ?></a>
1322 <a href='javascript:;' class='btn btn-default btn-cancel' onclick='checkAll(false)'><?php echo xlt('Clear All'); ?></a>
1323 <a href='javascript:;' class='btn btn-default btn-transmit' onclick='$("#form_csvexport").attr("value","true"); $("#theform").submit();'>
1324 <?php echo xlt('Export Selected as CSV'); ?>
1325 </a>
1326 <a href='javascript:;' class='btn btn-default btn-transmit' onclick='$("#form_export").attr("value","true"); $("#form_csvexport").val(""); $("#theform").submit();'>
1327 <?php echo xlt('Export Selected to Collections'); ?>
1328 </a>
1329 </div>
1331 <div style='float:left'>
1332 <label><input type='checkbox' name='form_individual' value='1' /> <?php echo xlt('Export Individual Invoices') ?>&nbsp;&nbsp;</label>
1333 </div>
1335 <div style='float:left'>
1336 <label><input type='checkbox' name='form_without' value='1' /> <?php echo xlt('Without Update') ?></label>
1337 </div>
1338 </div>
1340 <?php
1341 } // end not export
1343 </form>
1344 </center>
1345 <script language="JavaScript">
1346 <?php
1347 if ($alertmsg) {
1348 echo "alert('" . addslashes($alertmsg) . "');\n";
1351 </script>
1352 </body>
1353 </html>
1354 <?php
1355 } // end not form_csvexport