4 * namespace OnsitePortal
6 * Copyright (C) 2006-2015 Rod Roark <rod@sunsetsystems.com>
7 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Rod Roark <rod@sunsetsystems.com>
22 * @author Jerry Padgett <sjpadgett@gmail.com>
23 * @link http://www.open-emr.org
28 if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
29 $pid = $_SESSION['pid'];
31 require_once(dirname(__FILE__
) . "/../interface/globals.php");
35 require_once(dirname(__FILE__
) . "/../interface/globals.php");
36 if (!isset($_SESSION['authUserID'])) {
37 $landingpage = "index.php";
38 header('Location: ' . $landingpage);
43 require_once(dirname(__FILE__
) . "/lib/appsql.class.php");
44 require_once("$srcdir/acl.inc");
45 require_once("$srcdir/patient.inc");
46 require_once("$srcdir/payment.inc.php");
47 require_once("$srcdir/forms.inc");
48 require_once("$srcdir/sl_eob.inc.php");
49 require_once("$srcdir/invoice_summary.inc.php");
50 require_once("../custom/code_types.inc.php");
51 require_once("$srcdir/options.inc.php");
52 require_once("$srcdir/encounter_events.inc.php");
53 require_once("$srcdir/log.inc");
54 require_once("$srcdir/crypto.php");
56 use OpenEMR\Billing\BillingUtilities
;
58 $appsql = new ApplicationTable();
59 $pid = isset($_REQUEST['pid']) ?
$_REQUEST['pid'] : $pid;
60 $pid = $_REQUEST['hidden_patient_code'] > 0 ?
$_REQUEST['hidden_patient_code'] : $pid;
64 $query = "SELECT pao.portal_username as recip_id, Concat_Ws(' ', patient_data.fname, patient_data.lname) as username FROM patient_data " .
65 "LEFT JOIN patient_access_onsite pao ON pao.pid = patient_data.pid " .
66 "WHERE patient_data.pid = ? AND pao.portal_pwd_status = 1";
67 $portalPatient = sqlQueryNoLog($query, $pid);
68 if ($_SESSION['authUserID']) {
69 $query = "SELECT users.username as recip_id, users.authorized as dash, CONCAT(users.fname,' ',users.lname) as username " .
70 "FROM users WHERE id = ?";
71 $adminUser = sqlQueryNoLog($query, $_SESSION['authUserID']);
73 $edata = $appsql->getPortalAudit($pid, 'review', 'payment');
78 $ccdata = json_decode(aes256DecryptTwo($edata['checksum']), true);
79 $invdata = json_decode($edata['table_args'], true);
80 echo "<script type='text/javascript'>var jsondata='" . $edata['table_args'] . "';var ccdata='" . $edata['checksum'] . "'</script>";
83 function bucks($amount)
86 $amount = oeFormatMoney($amount);
93 function rawbucks($amount)
96 $amount = sprintf("%.2f", $amount);
103 // Display a row of data for an encounter.
106 function echoLine($iname, $date, $charges, $ptpaid, $inspaid, $duept, $encounter = 0, $copay = 0, $patcopay = 0)
110 $balance = bucks($charges - $ptpaid - $inspaid);
111 $balance = (round($duept, 2) != 0) ?
0 : $balance; // if balance is due from patient, then insurance balance is displayed as zero
112 $encounter = $encounter ?
$encounter : '';
113 echo " <tr id='tr_" . attr($var_index) . "' >\n";
114 echo " <td class='detail'>" . text(oeFormatShortDate($date)) . "</td>\n";
115 echo " <td class='detail' id='" . attr($date) . "' align='left'>" . htmlspecialchars($encounter, ENT_QUOTES
) . "</td>\n";
116 echo " <td class='detail' align='center' id='td_charges_$var_index' >" . htmlspecialchars(bucks($charges), ENT_QUOTES
) . "</td>\n";
117 echo " <td class='detail' align='center' id='td_inspaid_$var_index' >" . htmlspecialchars(bucks($inspaid * -1), ENT_QUOTES
) . "</td>\n";
118 echo " <td class='detail' align='center' id='td_ptpaid_$var_index' >" . htmlspecialchars(bucks($ptpaid * -1), ENT_QUOTES
) . "</td>\n";
119 echo " <td class='detail' align='center' id='td_patient_copay_$var_index' >" . htmlspecialchars(bucks($patcopay), ENT_QUOTES
) . "</td>\n";
120 echo " <td class='detail' align='center' id='td_copay_$var_index' >" . htmlspecialchars(bucks($copay), ENT_QUOTES
) . "</td>\n";
121 echo " <td class='detail' align='center' id='balance_$var_index'>" . htmlspecialchars(bucks($balance), ENT_QUOTES
) . "</td>\n";
122 echo " <td class='detail' align='center' id='duept_$var_index'>" . htmlspecialchars(bucks(round($duept, 2) * 1), ENT_QUOTES
) . "</td>\n";
123 echo " <td class='detail' align='right'><input class='form-control' style='width:60px;padding:2px 2px;' type='text' name='" . attr($iname) . "' id='paying_" . attr($var_index) . "' " . " value='" . '' . "' onchange='coloring();calctotal()' autocomplete='off' " . "onkeyup='calctotal()'/></td>\n";
127 // We use this to put dashes, colons, etc. back into a timestamp.
129 function decorateString($fmt, $str)
133 $fc = substr($fmt, 0, 1);
134 $fmt = substr($fmt, 1);
136 $res .= substr($str, 0, 1);
137 $str = substr($str, 1);
146 // Compute taxes from a tax rate string and a possibly taxable amount.
148 function calcTaxes($row, $amount)
151 if (empty($row['taxrates'])) {
155 $arates = explode(':', $row['taxrates']);
156 if (empty($arates)) {
160 foreach ($arates as $value) {
165 $trow = sqlQuery("SELECT option_value FROM list_options WHERE " . "list_id = 'taxrate' AND option_id = ? LIMIT 1", array($value
167 if (empty($trow['option_value'])) {
168 echo "<!-- Missing tax rate '" . text($value) . "'! -->\n";
172 $tax = sprintf("%01.2f", $amount * $trow['option_value']);
173 // echo "<!-- Rate = '$value', amount = '$amount', tax = '$tax' -->\n";
181 $today = date('Y-m-d', $now);
182 $timestamp = date('Y-m-d H:i:s', $now);
185 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
187 $patdata = sqlQuery("SELECT " . "p.fname, p.mname, p.lname, p.pubpid,p.pid, i.copay " . "FROM patient_data AS p " . "LEFT OUTER JOIN insurance_data AS i ON " . "i.pid = p.pid AND i.type = 'primary' " . "WHERE p.pid = ? ORDER BY i.date DESC LIMIT 1", array($pid
190 $alertmsg = ''; // anything here pops up in an alert box
192 // If the Save button was clicked...
193 if ($_POST['form_save']) {
194 // $extra = json_decode($_POST['ajax_mode'], true);
195 $form_pid = $_POST['form_pid'];
196 $form_method = trim($_POST['form_method']);
197 $form_source = trim($_POST['form_source']);
198 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
199 $NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname'];
201 if ($_REQUEST['radio_type_of_payment'] == 'pre_payment') {
202 $payment_id = idSqlStatement("insert into ar_session set " . "payer_id = ?" . ", patient_id = ?" . ", user_id = ?" . ", closed = ?" . ", reference = ?" . ", check_date = now() , deposit_date = now() " . ", pay_total = ?" . ", payment_type = 'patient'" . ", description = ?" . ", adjustment_code = 'pre_payment'" . ", post_to_date = now() " . ", payment_method = ?", array(
203 0, $form_pid, $_SESSION['authUserID'], 0, $form_source, $_REQUEST['form_prepayment'], $NameNew, $form_method
206 frontPayment($form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0, $timestamp); // insertion to 'payments' table.
209 if ($_POST['form_upay'] && $_REQUEST['radio_type_of_payment'] != 'pre_payment') {
210 foreach ($_POST['form_upay'] as $enc => $payment) {
211 if ($amount = 0 +
$payment) {
213 if ($_REQUEST['radio_type_of_payment'] == 'invoice_balance') {
217 $enc = calendar_arrived($form_pid);
221 // ----------------------------------------------------------------------------------------------------
222 // Fetching the existing code and modifier
223 $ResultSearchNew = sqlStatement("SELECT * FROM billing LEFT JOIN code_types ON billing.code_type=code_types.ct_key " . "WHERE code_types.ct_fee=1 AND billing.activity!=0 AND billing.pid =? AND encounter=? ORDER BY billing.code,billing.modifier", array($form_pid, $enc
225 if ($RowSearch = sqlFetchArray($ResultSearchNew)) {
226 $Codetype = $RowSearch['code_type'];
227 $Code = $RowSearch['code'];
228 $Modifier = $RowSearch['modifier'];
235 // ----------------------------------------------------------------------------------------------------
236 if ($_REQUEST['radio_type_of_payment'] == 'copay') { // copay saving to ar_session and ar_activity tables
237 $session_id = idSqlStatement("INSERT INTO ar_session (payer_id,user_id,reference,check_date,deposit_date,pay_total," . " global_amount,payment_type,description,patient_id,payment_method,adjustment_code,post_to_date) " . " VALUES ('0',?,?,now(),now(),?,'','patient','COPAY',?,?,'patient_payment',now())", array(
238 $_SESSION['authId'], $form_source, $amount, $form_pid, $form_method
241 $insrt_id = idSqlStatement("INSERT INTO ar_activity (pid,encounter,code_type,code,modifier,payer_type,post_time,post_user,session_id,pay_amount,account_code)" . " VALUES (?,?,?,?,?,0,now(),?,?,?,'PCP')", array($form_pid, $enc, $Codetype, $Code, $Modifier, '3', $session_id, $amount
244 frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0, $timestamp); // insertion to 'payments' table.
247 if ($_REQUEST['radio_type_of_payment'] == 'invoice_balance' ||
$_REQUEST['radio_type_of_payment'] == 'cash') { // Payment by patient after insurance paid, cash patients similar to do not bill insurance in feesheet.
248 if ($_REQUEST['radio_type_of_payment'] == 'cash') {
249 sqlStatement("update form_encounter set last_level_closed=? where encounter=? and pid=? ", array(4, $enc, $form_pid
251 sqlStatement("update billing set billed=? where encounter=? and pid=?", array(1, $enc, $form_pid
255 $adjustment_code = 'patient_payment';
256 $payment_id = idSqlStatement("insert into ar_session set " . "payer_id = ?" . ", patient_id = ?" . ", user_id = ?" . ", closed = ?" . ", reference = ?" . ", check_date = now() , deposit_date = now() " . ", pay_total = ?" . ", payment_type = 'patient'" . ", description = ?" . ", adjustment_code = ?" . ", post_to_date = now() " . ", payment_method = ?", array(
257 0, $form_pid, $_SESSION['authUserID'], 0, $form_source, $amount, $NameNew, $adjustment_code, $form_method
260 // --------------------------------------------------------------------------------------------------------------------
262 frontPayment($form_pid, $enc, $form_method, $form_source, 0, $amount, $timestamp); // insertion to 'payments' table.
264 // --------------------------------------------------------------------------------------------------------------------
266 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where pid =? and " . "encounter =? and payer_type=0 and account_code='PCP'", array($form_pid, $enc
267 )); // new fees screen copay gives account_code='PCP'
268 $rowMoneyGot = sqlFetchArray($resMoneyGot);
269 $Copay = $rowMoneyGot['PatientPay'];
271 // --------------------------------------------------------------------------------------------------------------------
273 // Looping the existing code and modifier
274 $ResultSearchNew = sqlStatement("SELECT * FROM billing LEFT JOIN code_types ON billing.code_type=code_types.ct_key WHERE code_types.ct_fee=1 " . "AND billing.activity!=0 AND billing.pid =? AND encounter=? ORDER BY billing.code,billing.modifier", array($form_pid, $enc
276 while ($RowSearch = sqlFetchArray($ResultSearchNew)) {
277 $Codetype = $RowSearch['code_type'];
278 $Code = $RowSearch['code'];
279 $Modifier = $RowSearch['modifier'];
280 $Fee = $RowSearch['fee'];
282 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where pid =? " . "and code_type=? and code=? and modifier=? and encounter =? and !(payer_type=0 and account_code='PCP')", array($form_pid, $Codetype, $Code, $Modifier, $enc
284 // new fees screen copay gives account_code='PCP'
285 $rowMoneyGot = sqlFetchArray($resMoneyGot);
286 $MoneyGot = $rowMoneyGot['MoneyGot'];
288 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where " . "pid =? and code_type=? and code=? and modifier=? and encounter =?", array($form_pid, $Codetype, $Code, $Modifier, $enc
290 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
291 $MoneyAdjusted = $rowMoneyAdjusted['MoneyAdjusted'];
293 $Remainder = $Fee - $Copay - $MoneyGot - $MoneyAdjusted;
295 if (round($Remainder, 2) != 0 && $amount != 0) {
296 if ($amount - $Remainder >= 0) {
297 $insert_value = $Remainder;
298 $amount = $amount - $Remainder;
300 $insert_value = $amount;
304 sqlStatement("insert into ar_activity set " . "pid = ?" . ", encounter = ?" . ", code_type = ?" . ", code = ?" . ", modifier = ?" . ", payer_type = ?" . ", post_time = now() " . ", post_user = ?" . ", session_id = ?" . ", pay_amount = ?" . ", adj_amount = ?" . ", account_code = 'PP'", array(
305 $form_pid, $enc, $Codetype, $Code, $Modifier, 0, 3, $payment_id, $insert_value, 0
309 if ($amount != 0) { // if any excess is there.
310 sqlStatement("insert into ar_activity set " . "pid = ?" . ", encounter = ?" . ", code_type = ?" . ", code = ?" . ", modifier = ?" . ", payer_type = ?" . ", post_time = now() " . ", post_user = ?" . ", session_id = ?" . ", pay_amount = ?" . ", adj_amount = ?" . ", account_code = 'PP'", array(
311 $form_pid, $enc, $Codetype, $Code, $Modifier, 0, 3, $payment_id, $amount, 0
315 // --------------------------------------------------------------------------------------------------------------------
317 } // if ($amount = 0 + $payment)
319 } // if ($_POST['form_upay'])
320 } // if ($_POST['form_save'])
322 if ($_POST['form_save'] ||
$_REQUEST['receipt']) {
323 if ($_REQUEST['receipt']) {
324 $form_pid = $_GET['patient'];
325 $timestamp = decorateString('....-..-.. ..:..:..', $_GET['time']);
328 // Get details for what we guess is the primary facility.
329 $frow = sqlQuery("SELECT * FROM facility " . "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1");
331 // Get the patient's name and chart number.
332 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
334 // Re-fetch payment info.
335 $payrow = sqlQuery("SELECT " . "SUM(amount1) AS amount1, " . "SUM(amount2) AS amount2, " . "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " .
336 // "MAX(user) AS user " .
337 "MAX(user) AS user, " . "MAX(encounter) as encounter " . "FROM payments WHERE " . "pid = ? AND dtime = ?", array($form_pid, $timestamp
340 // Create key for deleting, just in case.
341 $ref_id = ($_REQUEST['radio_type_of_payment'] == 'copay') ?
$session_id : $payment_id;
342 $payment_key = $form_pid . '.' . preg_replace('/[^0-9]/', '', $timestamp) . '.' . $ref_id;
344 // get facility from encounter
348 WHERE encounter = ?", array($payrow['encounter']
350 $frow = sqlQuery("SELECT * FROM facility " . " WHERE id = ?", array($tmprow['facility_id']
353 // Now proceed with printing the receipt.
356 <title
><?php
echo xlt('Receipt for Payment'); ?
></title
>
358 <script type
="text/javascript"
359 src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-1-11-3/dist/jquery.js"></script
>
360 <script type
="text/javascript">
364 window
.location
.replace("./patient/onsiteactivityviews");
367 function notifyPatient() {
368 let pid
= <?php
echo attr($pid);?
>;
369 let note
= $
('#pop_receipt').html();
370 let formURL
= './messaging/handle_note.php';
371 let owner
= '<?php echo attr($adminUser['recip_id
']); ?>';
372 let sn
= '<?php echo attr($adminUser['username
']); ?>';
373 let rid
= '<?php echo attr($portalPatient['recip_id
']); ?>';
374 let rn
= '<?php echo attr($portalPatient['username
']); ?>';
383 'title': 'Bill/Collect',
384 'recipient_name': rn
,
389 success
: function (data
, textStatus
, jqXHR
) {
390 alert('Receipt sent to patient via Messages.')
392 error
: function (jqXHR
, status
, error
) {
393 console
.log(status +
": " + error
);
400 echo '<htlm><head></head><body style="text-align: center; margin: auto;">';
403 <div id
='pop_receipt' style
='display: block'>
405 <h2
><?php
echo xlt('Receipt for Payment'); ?
></h2
>
406 <p
><?php
echo text($frow['name']) ?
>
407 <br
><?php
echo text($frow['street']) ?
>
408 <br
><?php
echo text($frow['city'] . ', ' . $frow['state']) . ' ' . text($frow['postal_code']) ?
>
409 <br
><?php
echo htmlentities($frow['phone']) ?
>
411 <div style
="text-align: center; margin: auto;">
412 <table border
='0' cellspacing
='8'
413 style
="text-align: center; margin: auto;">
415 <td
><?php
echo xlt('Date'); ?
>:</td
>
416 <td
><?php
echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?
></td
>
419 <td
><?php
echo xlt('Patient'); ?
>:</td
>
420 <td
><?php
echo text($patdata['fname']) . " " . text($patdata['mname']) . " " . text($patdata['lname']) . " (" . text($patdata['pubpid']) . ")" ?
></td
>
423 <td
><?php
echo xlt('Paid Via'); ?
>:</td
>
424 <td
><?php
echo generate_display_field(array('data_type' => '1', 'list_id' => 'payment_method'), $payrow['method']); ?
></td
>
427 <td
><?php
echo xlt('Authorized Id'); ?
>:</td
>
428 <td
><?php
echo text($payrow['source']) ?
></td
>
431 <td
><?php
echo xlt('Amount for This Visit'); ?
>:</td
>
432 <td
><?php
echo text(oeFormatMoney($payrow['amount1'])) ?
></td
>
435 <td
><?php
echo xlt('Amount for Past Balance'); ?
>:</td
>
436 <td
><?php
echo text(oeFormatMoney($payrow['amount2'])) ?
></td
>
439 <td
><?php
echo xlt('Received By'); ?
>:</td
>
440 <td
><?php
echo text($payrow['user']) ?
></td
>
445 <button
class='btn btn-sm' type
='button' onclick
='goHome()'
446 id
='returnhome'><?php
echo xla('Return Home'); ?
></button
>
447 <button
class='btn btn-sm' type
='button' onclick
="notifyPatient()"><?php
echo xla('Notify Patient'); ?
></button
>
453 // Here we display the form for data entry.
456 <title
><?php
echo xlt('Record Payment'); ?
></title
>
457 <style type
="text/css">
459 /* font-family:sans-serif; font-size:10pt; font-weight:normal */
463 color
: #000000; /*font-family:sans-serif; font-size:10pt;*/
470 color
: #000000; /*font-family:sans-serif; font-size:10pt; */
474 <script type
="text/javascript"
475 src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-creditcardvalidator/jquery.creditCardValidator.js"></script
>
476 <script type
="text/javascript"
477 src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
479 <script type
="text/javascript">
482 function calctotal() {
484 var f
= document
.forms
["payfrm"];
486 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
487 var elem
= f
.elements
[i
];
488 var ename
= elem
.name
;
489 if (ename
.indexOf('form_upay[') == 0 || ename
.indexOf('form_bpay[') == 0) {
490 if (elem
.value
.length
> 0) {
491 total +
= Number(elem
.value
);
492 if (total
< 0) flag
= 1;
496 f
.form_paytotal
.value
= Number(total
).toFixed(2);
498 $
('#payfrm')[0].reset();
499 alert("<?php echo addslashes(xl('Negative payments not accepted')) ?>")
504 function coloring() {
505 for (var i
= 1; ; ++i
) {
506 if (document
.getElementById('paying_' + i
)) {
507 paying
= document
.getElementById('paying_' + i
).value
* 1;
508 patient_balance
= document
.getElementById('duept_' + i
).innerHTML
* 1;
509 //balance=document.getElementById('balance_'+i).innerHTML*1;
510 if (patient_balance
> 0 && paying
> 0) {
511 if (paying
> patient_balance
) {
512 document
.getElementById('paying_' + i
).style
.background
= '#FF0000';
514 else if (paying
< patient_balance
) {
515 document
.getElementById('paying_' + i
).style
.background
= '#99CC00';
517 else if (paying
== patient_balance
) {
518 document
.getElementById('paying_' + i
).style
.background
= '#ffffff';
522 document
.getElementById('paying_' + i
).style
.background
= '#ffffff';
531 function CheckVisible(MakeBlank
) {//Displays and hides the check number text box.
532 if (document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
== 'check_payment' ||
533 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
== 'bank_draft') {
534 document
.getElementById('check_number').disabled
= false;
537 document
.getElementById('check_number').disabled
= true;
541 function validate() {
542 var f
= document
.forms
["payfrm"];
544 //no checks taken here....
546 if (document
.getElementById('radio_type_of_payment_self1').checked
== false &&
547 document
.getElementById('radio_type_of_payment1').checked
== false
548 && document
.getElementById('radio_type_of_payment2').checked
== false
549 && document
.getElementById('radio_type_of_payment4').checked
== false) {
550 alert("<?php //echo addslashes( xl('Please Select Type Of Payment.')) ?>");
553 if (document
.getElementById('radio_type_of_payment_self1').checked
== true || document
.getElementById('radio_type_of_payment1').checked
== true) {
554 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
555 var elem
= f
.elements
[i
];
556 var ename
= elem
.name
;
557 if (ename
.indexOf('form_upay[0') == 0) //Today is this text box.
559 if (elem
.value
* 1 > 0) {//A warning message, if the amount is posted with out encounter.
560 if (confirm("<?php echo addslashes(xl('Are you sure to post for today?')) ?>")) {
572 else if (document
.getElementsByName('form_paytotal')[0].value
<= 0)//total 0
574 alert("<?php echo addslashes(xl('Invalid Total!')) ?>")
579 if (confirm("<?php echo addslashes(xl('Payment Validated: Save?')) ?>")) {
588 function cursor_pointer() {//Point the cursor to the latest encounter(Today)
589 var f
= document
.forms
["payfrm"];
591 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
592 var elem
= f
.elements
[i
];
593 var ename
= elem
.name
;
594 if (ename
.indexOf('form_upay[') == 0) {
601 //=====================================================
602 function make_it_hide_enc_pay() {
603 document
.getElementById('td_head_insurance_payment').style
.display
= "none";
604 document
.getElementById('td_head_patient_co_pay').style
.display
= "none";
605 document
.getElementById('td_head_co_pay').style
.display
= "none";
606 document
.getElementById('td_head_insurance_balance').style
.display
= "none";
607 for (var i
= 1; ; ++i
) {
608 var td_inspaid_elem
= document
.getElementById('td_inspaid_' + i
)
609 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_' + i
)
610 var td_copay_elem
= document
.getElementById('td_copay_' + i
)
611 var balance_elem
= document
.getElementById('balance_' + i
)
612 if (td_inspaid_elem
) {
613 td_inspaid_elem
.style
.display
= "none";
614 td_patient_copay_elem
.style
.display
= "none";
615 td_copay_elem
.style
.display
= "none";
616 balance_elem
.style
.display
= "none";
622 document
.getElementById('td_total_4').style
.display
= "none";
623 document
.getElementById('td_total_7').style
.display
= "none";
624 document
.getElementById('td_total_8').style
.display
= "none";
625 document
.getElementById('td_total_6').style
.display
= "none";
627 document
.getElementById('table_display').width
= "420px";
630 //=====================================================
631 function make_visible() {
632 document
.getElementById('td_head_rep_doc').style
.display
= "";
633 document
.getElementById('td_head_description').style
.display
= "";
634 document
.getElementById('td_head_total_charge').style
.display
= "none";
635 document
.getElementById('td_head_insurance_payment').style
.display
= "none";
636 document
.getElementById('td_head_patient_payment').style
.display
= "none";
637 document
.getElementById('td_head_patient_co_pay').style
.display
= "none";
638 document
.getElementById('td_head_co_pay').style
.display
= "none";
639 document
.getElementById('td_head_insurance_balance').style
.display
= "none";
640 document
.getElementById('td_head_patient_balance').style
.display
= "none";
641 for (var i
= 1; ; ++i
) {
642 var td_charges_elem
= document
.getElementById('td_charges_' + i
)
643 var td_inspaid_elem
= document
.getElementById('td_inspaid_' + i
)
644 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_' + i
)
645 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_' + i
)
646 var td_copay_elem
= document
.getElementById('td_copay_' + i
)
647 var balance_elem
= document
.getElementById('balance_' + i
)
648 var duept_elem
= document
.getElementById('duept_' + i
)
649 if (td_charges_elem
) {
650 td_charges_elem
.style
.display
= "none";
651 td_inspaid_elem
.style
.display
= "none";
652 td_ptpaid_elem
.style
.display
= "none";
653 td_patient_copay_elem
.style
.display
= "none";
654 td_copay_elem
.style
.display
= "none";
655 balance_elem
.style
.display
= "none";
656 duept_elem
.style
.display
= "none";
662 document
.getElementById('td_total_7').style
.display
= "";
663 document
.getElementById('td_total_8').style
.display
= "";
664 document
.getElementById('td_total_1').style
.display
= "none";
665 document
.getElementById('td_total_2').style
.display
= "none";
666 document
.getElementById('td_total_3').style
.display
= "none";
667 document
.getElementById('td_total_4').style
.display
= "none";
668 document
.getElementById('td_total_5').style
.display
= "none";
669 document
.getElementById('td_total_6').style
.display
= "none";
671 document
.getElementById('table_display').width
= "505px";
674 function make_it_hide() {
675 document
.getElementById('td_head_rep_doc').style
.display
= "none";
676 document
.getElementById('td_head_description').style
.display
= "none";
677 document
.getElementById('td_head_total_charge').style
.display
= "";
678 document
.getElementById('td_head_insurance_payment').style
.display
= "";
679 document
.getElementById('td_head_patient_payment').style
.display
= "";
680 document
.getElementById('td_head_patient_co_pay').style
.display
= "";
681 document
.getElementById('td_head_co_pay').style
.display
= "";
682 document
.getElementById('td_head_insurance_balance').style
.display
= "";
683 document
.getElementById('td_head_patient_balance').style
.display
= "";
684 for (var i
= 1; ; ++i
) {
685 var td_charges_elem
= document
.getElementById('td_charges_' + i
)
686 var td_inspaid_elem
= document
.getElementById('td_inspaid_' + i
)
687 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_' + i
)
688 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_' + i
)
689 var td_copay_elem
= document
.getElementById('td_copay_' + i
)
690 var balance_elem
= document
.getElementById('balance_' + i
)
691 var duept_elem
= document
.getElementById('duept_' + i
)
692 if (td_charges_elem
) {
693 td_charges_elem
.style
.display
= "";
694 td_inspaid_elem
.style
.display
= "";
695 td_ptpaid_elem
.style
.display
= "";
696 td_patient_copay_elem
.style
.display
= "";
697 td_copay_elem
.style
.display
= "";
698 balance_elem
.style
.display
= "";
699 duept_elem
.style
.display
= "";
705 document
.getElementById('td_total_1').style
.display
= "";
706 document
.getElementById('td_total_2').style
.display
= "";
707 document
.getElementById('td_total_3').style
.display
= "";
708 document
.getElementById('td_total_4').style
.display
= "";
709 document
.getElementById('td_total_5').style
.display
= "";
710 document
.getElementById('td_total_6').style
.display
= "";
711 document
.getElementById('td_total_7').style
.display
= "";
712 document
.getElementById('td_total_8').style
.display
= "";
714 document
.getElementById('table_display').width
= "100%";
717 function make_visible_radio() {
718 document
.getElementById('tr_radio1').style
.display
= "";
719 document
.getElementById('tr_radio2').style
.display
= "none";
722 function make_hide_radio() {
723 document
.getElementById('tr_radio1').style
.display
= "none";
724 document
.getElementById('tr_radio2').style
.display
= "";
727 function make_visible_row() {
728 document
.getElementById('table_display').style
.display
= "";
729 document
.getElementById('table_display_prepayment').style
.display
= "none";
732 function make_hide_row() {
733 document
.getElementById('table_display').style
.display
= "none";
734 document
.getElementById('table_display_prepayment').style
.display
= "";
737 function make_self() {
740 make_it_hide_enc_pay();
741 document
.getElementById('radio_type_of_payment_self1').checked
= true;
745 function make_insurance() {
749 document
.getElementById('radio_type_of_payment1').checked
= true;
752 //--------------------------------------------------------------------------------------------------//
753 $
('#paySubmit').click(function (e
) {
755 $
("#mode").val("portal-save");
756 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
757 var extra_values
= JSON
.stringify(getFormObj('paycredit'));
758 var extra
= "&inv_values=" + inv_values +
"&extra_values=" + extra_values
;
761 var liburl
= './lib/paylib.php';
765 data
: $
("#payfrm").serialize() + extra
,
766 beforeSend
: function (xhr
) {
767 if (validateCC() !== true) return false;
768 if ($
('#pin').val() == "" || $
('#ccname').val() == "" || $
('#ccyear').val() == "" || $
('#ccmonth').val() == "") {
769 alert("<?php echo addslashes(xl('Invalid Credit Card Values: Please correct')) ?>")
772 if (validate() != true) {
774 alert("<?php echo addslashes(xl('Validation error: Fix and resubmit. This popup info is preserved!')) ?>")
777 $
("#openPayModal .close").click()
779 error
: function (qXHR
, textStatus
, errorThrow
) {
780 console
.log("There was an error:" + errorThrow
);
782 success
: function (templateHtml
, textStatus
, jqXHR
) {
783 alert("<?php echo addslashes(xl('Payment successfully sent for authorization. You will be notified when payment is posted. Until payment is accepted and you are notified, you may resubmit this payment at anytime with new amounts or different credit card. Thank you')) ?>")
784 window
.location
.reload(false);
788 $
("#openPayModal .close").click();
790 //---------------------------------------------------------------------------------------//
791 $
("#payfrm").on('submit', function (e
) {
794 $
("#mode").val("review-save");
795 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
796 var extra_values
= JSON
.stringify(getFormObj('paycredit'));
797 var extra
= "&inv_values=" + inv_values +
"&extra_values=" + extra_values
;
800 var liburl
= '<?php echo $GLOBALS["webroot"] ?>/portal/lib/paylib.php';
804 data
: $
("#payfrm").serialize() + extra
,
805 beforeSend
: function (xhr
) {
806 if (validate() != true) {
808 alert("<?php echo addslashes(xl('Validation error: Fix and resubmit. Payment values are preserved!')) ?>")
812 error
: function (xhr
, textStatus
, error
) {
813 alert("<?php echo addslashes(xl('There is a Post error')) ?>")
814 console
.log("There was an error:" + textStatus
);
817 success
: function (templateHtml
, textStatus
, jqXHR
) {
823 function getFormObj(formId
) {
825 var inputs
= $
('#' + formId
).serializeArray();
826 $
.each(inputs
, function (i
, input
) {
827 formObj
[input
.name
] = input
.value
;
832 function formRepopulate(jsondata
) {
833 data
= $
.parseJSON(jsondata
);
834 $
.each(data
, function (name
, val
) {
835 var $el = $
('[name="' + name +
'"]'),
836 type
= $el.attr('type');
839 $el.prop('checked', true);
842 $el.filter('[value="' + val +
'"]').prop('checked', true);
851 var authnum
= prompt("<?php echo xlt('Please enter card comfirmation authorization') ?>", "");
852 if (authnum
!= null) {
853 $
('#check_number').val(authnum
);
858 <body
class="skin-blue" onunload
='imclosing()' onLoad
="cursor_pointer();"
859 style
="text-align: center; margin: auto;">
861 <form id
="payfrm" method
='post'
862 action
='<?php echo $GLOBALS["webroot"] ?>/portal/portal_payment.php'>
863 <input type
='hidden' name
='form_pid' value
='<?php echo attr($pid) ?>'/>
864 <input type
='hidden' name
='form_save'
865 value
='<?php echo xlt('Invoice
'); ?>'/>
869 <td colspan
="3"> 
;</td
>
873 <td colspan
='3' align
='center' class='text'><b
><?php
echo xlt('Accept Payment for'); ?
> 
;: 
; 
;<?php
875 echo htmlspecialchars($patdata['fname'], ENT_QUOTES
) . " " . htmlspecialchars($patdata['lname'], ENT_QUOTES
) . " " . htmlspecialchars($patdata['mname'], ENT_QUOTES
) . " (" . htmlspecialchars($patdata['pid'], ENT_QUOTES
) . ")" ?
></b
>
876 <?php
$NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname']; ?
>
880 <td colspan
='3'></td
>
884 <?php
echo xlt('Payment Method'); ?
>:
886 <td colspan
='2'><select name
="form_method" id
="form_method"
887 class="text" onChange
='CheckVisible("yes")'>
889 $query1112 = "SELECT * FROM list_options where list_id=? ORDER BY seq, title ";
890 $bres1112 = sqlStatement($query1112, array('payment_method'));
891 while ($brow1112 = sqlFetchArray($bres1112)) {
892 if ($brow1112['option_id'] != 'credit_card' ||
$brow1112['option_id'] == 'electronic' ||
$brow1112['option_id'] == 'bank_draft') {
896 echo "<option value='" . htmlspecialchars($brow1112['option_id'], ENT_QUOTES
) . "'>" . htmlspecialchars(xl_list_label($brow1112['title']), ENT_QUOTES
) . "</option>";
903 <td colspan
='3'></td
>
908 <?php
echo xla('Authorized'); ?
>:
912 if (isset($_SESSION['authUserID'])) {
913 echo "<input type='text' id='check_number' name='form_source' style='width:120px;' value='" . htmlspecialchars($payrow['source'], ENT_QUOTES
) . "'>";
919 <td colspan
='3'></td
>
922 <td
class='text' valign
="middle">
923 <?php
echo xlt('Patient Coverage'); ?
>:
925 <td
class='text' colspan
="2">
926 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverage1"
927 value
="self" onClick
="make_visible_radio();make_self();"/>
928 <?php
echo xlt('Self'); ?
>
929 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverag2" value
="insurance"
931 onClick
="make_hide_radio();make_insurance();"/>
932 <?php
echo xlt('Insurance'); ?
>
936 <td colspan
='3'></td
>
938 <tr id
="tr_radio1" style
="display: none">
939 <!-- For radio Insurance
-->
940 <td
class='text' valign
="top">
941 <?php
echo xlt('Payment against'); ?
>:
943 <td
class='text' colspan
="2">
944 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment_self1"
945 value
="cash" onClick
="make_visible_row();make_it_hide_enc_pay();cursor_pointer();"/>
946 <?php
echo xlt('Encounter Payment'); ?
>
950 <!-- For radio self
-->
951 <td
class='text' valign
="top"><?php
echo xlt('Payment against'); ?
>:
953 <td
class='text' colspan
="2"><input type
="radio" name
="radio_type_of_payment"
954 id
="radio_type_of_payment1" checked
="checked"
956 onClick
="make_visible_row();cursor_pointer();"/><?php
echo xlt('Co Pay'); ?
>
957 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment2"
958 value
="invoice_balance" onClick
="make_visible_row();"/><?php
echo xlt('Invoice Balance'); ?
>
960 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment4" value
="pre_payment"
961 onClick
="make_hide_row();"/><?php
echo xlt('Pre Pay'); ?
></td
>
964 <td colspan
='3'></td
>
967 <table width
="35%" border
="0" cellspacing
="0" cellpadding
="0" id
="table_display_prepayment"
968 style
="display: none">
970 <td
class='detail'><?php
echo xlt('Pre Payment'); ?
></td
>
971 <td
><input
class="form-control" type
='text' name
='form_prepayment' style
='width: 100px'/></td
>
974 <table id
="table_display" style
="width: 100%; background: #eee;" class="table table-striped table-responsive">
978 <!-- <table border
='0' id
="table_display" cellpadding
='0' cellspacing
='0' width
='100%'> -->
979 <tr bgcolor
="#cccccc" id
="tr_head">
980 <td
class="dehead" width
="60">
981 <?php
echo xlt('DOS') ?
>
983 <td
class="dehead" width
="120">
984 <?php
echo xlt('Visit Reason') ?
>
986 <td
class="dehead" align
="center" width
="70" id
="td_head_total_charge">
987 <?php
echo xlt('Total Charge') ?
>
989 <td
class="dehead" align
="center" width
="70" id
="td_head_rep_doc" style
='display: none'>
990 <?php
echo xlt('Report/ Form') ?
>
992 <td
class="dehead" align
="center" width
="200" id
="td_head_description" style
='display: none'>
993 <?php
echo xlt('Description') ?
>
995 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_payment">
996 <?php
echo xlt('Insurance Payment') ?
>
998 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_payment">
999 <?php
echo xlt('Patient Payment') ?
>
1001 <td
class="dehead" align
="center" width
="55" id
="td_head_patient_co_pay">
1002 <?php
echo xlt('Co Pay Paid') ?
>
1004 <td
class="dehead" align
="center" width
="55" id
="td_head_co_pay">
1005 <?php
echo xlt('Required Co Pay') ?
>
1007 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_balance">
1008 <?php
echo xlt('Insurance Balance') ?
>
1010 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_balance">
1011 <?php
echo xlt('Patient Balance') ?
>
1013 <td
class="dehead" align
="center" width
="50">
1014 <?php
echo xlt('Paying') ?
>
1019 // Get the unbilled service charges and payments by encounter for this patient.
1021 $query = "SELECT fe.encounter, fe.reason, b.code_type, b.code, b.modifier, b.fee, " . "LEFT(fe.date, 10) AS encdate ,fe.last_level_closed " . "FROM form_encounter AS fe left join billing AS b on " . "b.pid = ? AND b.activity = 1 AND " . // AND b.billed = 0
1022 "b.code_type != 'TAX' AND b.fee != 0 " . "AND fe.pid = b.pid AND fe.encounter = b.encounter " . "where fe.pid = ? " . "ORDER BY b.encounter";
1023 $bres = sqlStatement($query, array($pid, $pid));
1025 while ($brow = sqlFetchArray($bres)) {
1026 $key = 0 +
$brow['encounter'];
1027 if (empty($encs[$key])) {
1028 $encs[$key] = array('encounter' => $brow['encounter'], 'date' => $brow['encdate'], 'last_level_closed' => $brow['last_level_closed'], 'charges' => 0, 'payments' => 0, 'reason' => $brow['reason']
1032 if ($brow['code_type'] === 'COPAY') {
1033 // $encs[$key]['payments'] -= $brow['fee'];
1035 $encs[$key]['charges'] +
= $brow['fee'];
1037 $sql_array = array();
1038 $query = "SELECT taxrates FROM codes WHERE " . "code_type = ? AND " . "code = ? AND ";
1039 array_push($sql_array, $code_types[$brow['code_type']]['id'], $brow['code']);
1040 if ($brow['modifier']) {
1041 $query .= "modifier = ?";
1042 array_push($sql_array, $brow['modifier']);
1044 $query .= "(modifier IS NULL OR modifier = '')";
1047 $query .= " LIMIT 1";
1048 $trow = sqlQuery($query, $sql_array);
1049 $encs[$key]['charges'] +
= calcTaxes($trow, $brow['fee']);
1053 // Do the same for unbilled product sales.
1055 $query = "SELECT fe.encounter, fe.reason, s.drug_id, s.fee, " .
1056 "LEFT(fe.date, 10) AS encdate,fe.last_level_closed " .
1057 "FROM form_encounter AS fe left join drug_sales AS s " .
1058 "on s.pid = ? AND s.fee != 0 " .
1059 "AND fe.pid = s.pid AND fe.encounter = s.encounter " .
1060 "where fe.pid = ? " . "ORDER BY s.encounter";
1062 $dres = sqlStatement($query, array($pid, $pid));
1064 while ($drow = sqlFetchArray($dres)) {
1065 $key = 0 +
$drow['encounter'];
1066 if (empty($encs[$key])) {
1067 $encs[$key] = array('encounter' => $drow['encounter'], 'date' => $drow['encdate'], 'last_level_closed' => $drow['last_level_closed'], 'charges' => 0, 'payments' => 0
1071 $encs[$key]['charges'] +
= $drow['fee'];
1073 $trow = sqlQuery("SELECT taxrates FROM drug_templates WHERE drug_id = ? " . "ORDER BY selector LIMIT 1", array($drow['drug_id']
1075 $encs[$key]['charges'] +
= calcTaxes($trow, $drow['fee']);
1078 ksort($encs, SORT_NUMERIC
);
1080 // Bringing on top the Today always
1081 foreach ($encs as $key => $value) {
1082 $dispdate = $value['date'];
1083 if (strcmp($dispdate, $today) == 0 && !$gottoday) {
1089 // If no billing was entered yet for today, then generate a line for
1090 // entering today's co-pay.
1093 // echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0 /*$duept*/);//No encounter yet defined.
1097 foreach ($encs as $key => $value) {
1098 $enc = $value['encounter'];
1099 $reason = $value['reason'];
1100 $dispdate = $value['date'];
1101 if (strcmp($dispdate, $today) == 0 && !$gottoday) {
1102 $dispdate = date("Y-m-d");
1106 // ------------------------------------------------------------------------------------
1107 $inscopay = BillingUtilities
::getCopay($pid, $dispdate);
1108 $patcopay = BillingUtilities
::getPatientCopay($pid, $enc);
1109 // Insurance Payment
1110 // -----------------
1111 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? and " . "payer_type != 0 and account_code!='PCP' ", array($pid, $enc
1113 $dpayment = $drow['payments'];
1114 $dadjustment = $drow['adjustments'];
1117 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? and " . "payer_type = 0 and account_code!='PCP' ", array($pid, $enc
1119 $dpayment_pat = $drow['payments'];
1121 // ------------------------------------------------------------------------------------
1122 // NumberOfInsurance
1123 $ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
1124 where pid = ? and provider>0 ", array($pid
1126 $RowNumberOfInsurance = sqlFetchArray($ResultNumberOfInsurance);
1127 $NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1;
1128 // ------------------------------------------------------------------------------------
1130 if ((($NumberOfInsurance == 0 ||
$value['last_level_closed'] == 4 ||
$NumberOfInsurance == $value['last_level_closed']))) { // Patient balance
1131 $brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " . "pid = ? and encounter = ? AND activity = 1", array($pid, $enc
1133 $srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " . "pid = ? and encounter = ? ", array($pid, $enc
1135 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? ", array($pid, $enc
1137 $duept = $brow['amount'] +
$srow['amount'] - $drow['payments'] - $drow['adjustments'];
1140 echoLine("form_upay[$enc]", $dispdate, $value['charges'], $dpayment_pat, ($dpayment +
$dadjustment), $duept, ($enc . ':' . $reason), $inscopay, $patcopay);
1143 // Continue with display of the data entry form.
1146 <td
class="dehead" id
='td_total_1'></td
>
1147 <td
class="dehead" id
='td_total_2'></td
>
1148 <td
class="dehead" id
='td_total_3'></td
>
1149 <td
class="dehead" id
='td_total_4'></td
>
1150 <td
class="dehead" id
='td_total_5'></td
>
1151 <td
class="dehead" id
='td_total_6'></td
>
1152 <td
class="dehead" id
='td_total_7'></td
>
1153 <td
class="dehead" id
='td_total_8'></td
>
1154 <td
class="dehead" align
="right"><?php
echo xlt('Total'); ?
></td
>
1155 <td
class="dehead" align
="right"><input
class="form-control" type
='text' name
='form_paytotal'
1156 value
='' style
='color: #00aa00; width: 65px; padding: 1px 1px;'
1162 if (isset($ccdata["name"])) {
1163 echo '<div class="col-xs-12 col-md-4 col-lg-4">
1164 <div class="panel panel-default height">';
1165 if (!isset($_SESSION['authUserID'])) {
1166 echo '<div class="panel-heading">' . xlt("Payment Information") . '<span style="color:#cc0000"><em> ' . xlt("Pending Auth since") . ': </em>' . text($edata["date"]) . '</span></div>';
1168 echo '<div class="panel-heading">' . xlt("Payment Information") . ' <button type="button" class="btn btn-danger btn-sm" onclick="getAuth()">' . xlt("Authorize") . '</button></div>';
1171 echo '<div style="display:none" class="col-xs-12 col-md-6 col-lg-6"><div class="panel panel-default height"><div class="panel-heading">' . xlt("Payment Information") . ' </div>';
1174 <div
class="panel-body">
1175 <strong
><?php
echo xlt('Card Name'); ?
>: </strong
><span
1176 id
="cn"><?php
echo attr($ccdata["cc_type"]) ?
></span
><br
>
1177 <strong
><?php
echo xlt('Name on Card'); ?
>: </strong
><span
1178 id
="nc"><?php
echo attr($ccdata["name"]) ?
></span
><br
>
1179 <strong
><?php
echo xlt('Card Number'); ?
>: </strong
><span id
="ccn">
1181 if (isset($_SESSION['authUserID'])) {
1182 echo $ccdata["cc_number"] . "</span><br>";
1184 echo "********** " . substr($ccdata["cc_number"], -4) . "</span><br>";
1187 <strong
><?php
echo xlt('Exp Date'); ?
>: </strong
><span
1188 id
="ed"><?php
echo attr($ccdata["month"]) . "/" . attr($ccdata["year"]) ?
></span
>
1189 <strong
><?php
echo xlt('CVV'); ?
>: </strong
><span id
="pin"><?php
echo attr($ccdata["pin"]) ?
></span
><br
>
1190 <strong
><?php
echo xlt('Charge Total'); ?
>: </strong
><span id
="ct"><?php
echo attr($invdata["form_paytotal"]) ?
></span
><br
>
1196 if (!isset($_SESSION['authUserID'])) {
1197 echo '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#openPayModal">' . xlt("Pay Invoice") . '</button>';
1199 echo "<button type='submit' class='btn btn-danger' form='payfrm'>" . xlt('Post Payment') . "</button>";
1204 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo attr($pid); ?>"/>
1205 <input type
='hidden' name
='mode' id
='mode' value
=''/>
1208 <script type
="text/javascript">
1209 if (typeof jsondata
!== 'undefined') {
1210 formRepopulate(jsondata
);
1214 <!-- credit payment modal
-->
1215 <div id
="openPayModal" class="modal fade" role
="dialog">
1216 <div
class="modal-dialog">
1217 <div
class="modal-content">
1218 <div
class="modal-header">
1219 <h3
><?php
echo xlt('Submit Payment for Authorization'); ?
></h3
>
1220 <button type
="button" class="close" data
-dismiss
="modal">×
;</button
>
1222 <div
class="modal-body container">
1223 <form id
='paycredit' class="form-horizontal col-xs-12 col-sm-6 col-md-6">
1225 <div
class="control-group">
1226 <label label
-default="label-default"
1227 class="control-label"><?php
echo xlt('Name on Card'); ?
></label
>
1228 <div
class="controls">
1229 <input name
="name" id
="ccname" type
="text" class="form-control"
1231 title
="<?php echo xla('Fill your first and last name'); ?>"
1235 <div
class="control-group">
1236 <label
class="control-label"><?php
echo xlt('Card Number'); ?
></label
>
1237 <div
class="controls">
1239 <div
class="col-sm-12">
1240 <input name
="cc_number" id
="cc_number" type
="text"
1241 class="form-control inline col-sm-3"
1242 autocomplete
="off" maxlength
="19" pattern
="\d"
1243 onchange
="validateCC()"
1244 title
="<?php echo xla('Card Number'); ?>" required value
=""/>
1245 <input disabled name
="cardtype" id
="cardtype" type
="text"
1246 class="form-control inline" title
="<?php echo xla('Card Type'); ?>"
1247 style
="max-width:160px;font-weight:bold;color:red;" value
=""/>
1252 <div
class="control-group">
1253 <label label
-default="label-default"
1254 class="control-label"><?php
echo xlt('Card Expiry Date'); ?
></label
>
1255 <div
class="controls">
1257 <div
class="col-md-4">
1258 <select name
="month" id
="ccmonth" class="form-control">
1259 <option value
=""><?php
echo xlt('Select Month'); ?
></option
>
1260 <option value
="01"><?php
echo xlt('January'); ?
></option
>
1261 <option value
="02"><?php
echo xlt('February'); ?
></option
>
1262 <option value
="03"><?php
echo xlt('March'); ?
></option
>
1263 <option value
="04"><?php
echo xlt('April'); ?
></option
>
1264 <option value
="05"><?php
echo xlt('May'); ?
></option
>
1265 <option value
="06"><?php
echo xlt('June'); ?
></option
>
1266 <option value
="07"><?php
echo xlt('July'); ?
></option
>
1267 <option value
="08"><?php
echo xlt('August'); ?
></option
>
1268 <option value
="09"><?php
echo xlt('September'); ?
></option
>
1269 <option value
="10"><?php
echo xlt('October'); ?
></option
>
1270 <option value
="11"><?php
echo xlt('November'); ?
></option
>
1271 <option value
="12"><?php
echo xlt('December'); ?
></option
>
1274 <div
class="col-md-3">
1275 <select name
="year" id
="ccyear" class="form-control">
1276 <option value
=""><?php
echo xlt('Select Year'); ?
></option
>
1277 <option value
="2018">2018</option
>
1278 <option value
="2019">2019</option
>
1279 <option value
="2020">2020</option
>
1280 <option value
="2021">2021</option
>
1281 <option value
="2022">2022</option
>
1282 <option value
="2023">2023</option
>
1283 <option value
="2024">2024</option
>
1284 <option value
="2025">2017</option
>
1290 <div
class="control-group">
1291 <label label
-default="label-default"
1292 class="control-label"><?php
echo xlt('Card CVV'); ?
></label
>
1293 <div
class="controls">
1295 <div
class="col-md-3">
1296 <input name
="pin" id
="pin" type
="text" class="form-control"
1297 autocomplete
="off" maxlength
="4" pattern
="\d{3}"
1298 onfocus
="validateCC()"
1299 title
="<?php echo xlt('Three or four digits at back of your card'); ?>"
1302 <div
class="col-md-3">
1303 <img src
='./images/img_cvc.png' style
='height: 58px; width: auto'>
1308 <div
class="form-actions">
1309 <button id
="paySubmit" class="btn btn-danger"><?php
echo xlt('Submit'); ?
></button
>
1310 <button type
="button" class="btn btn-default"
1311 data
-dismiss
="modal"><?php
echo xlt('Cancel'); ?
></button
>
1314 <input type
='hidden' name
='cc_type' id
='cc_type' value
=''/>
1318 <div
class="modal-footer">
1319 <button type
="button" class="btn btn-default"
1320 data
-dismiss
="modal"><?php
echo xlt('Close'); ?
></button
>
1325 <?php
echo "<script>var ccerr='" . xlt('Invalid Credit Card Number') . "';</script>"; ?
>
1326 <script type
="text/javascript">
1327 $
('#cc_number').validateCreditCard(function (result
) {
1328 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1329 var v
= (result
.valid
== true ?
' Valid #' : ' Invalid #')
1330 $
('#cardtype').val(r + v
);
1333 function validateCC() {
1334 var result
= $
('#cc_number').validateCreditCard();
1335 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1336 var v
= (result
.valid
== true ?
' Okay' : ' Invalid #')
1337 $
('#cardtype').val(r + v
);
1338 $
('#cc_type').val(r
);
1339 if (!result
.valid
) {