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 $fake_register_globals=false;
32 $sanitize_all_escapes=true;
33 require_once ( dirname( __FILE__
) . "/../interface/globals.php" );
37 $sanitize_all_escapes = true;
38 $fake_register_globals = false;
39 require_once ( dirname( __FILE__
) . "/../interface/globals.php" );
40 if( ! isset( $_SESSION['authUserID'] ) ){
41 $landingpage = "index.php";
42 header( 'Location: ' . $landingpage );
46 require_once ( dirname( __FILE__
) . "/lib/appsql.class.php" );
47 require_once ( "$srcdir/acl.inc" );
48 require_once ( "$srcdir/patient.inc" );
49 require_once ( "$srcdir/billing.inc" );
50 require_once ( "$srcdir/payment.inc.php" );
51 require_once ( "$srcdir/forms.inc" );
52 require_once ( "$srcdir/sl_eob.inc.php" );
53 require_once ( "$srcdir/invoice_summary.inc.php" );
54 require_once ( "../custom/code_types.inc.php" );
55 require_once ( "$srcdir/formatting.inc.php" );
56 require_once ( "$srcdir/options.inc.php" );
57 require_once ( "$srcdir/encounter_events.inc.php" );
59 $appsql = new ApplicationTable();
61 $pid = $_REQUEST['hidden_patient_code'] > 0 ?
$_REQUEST['hidden_patient_code'] : $pid;
63 $edata = $appsql->getPortalAudit( $pid, 'review', 'payment' );
68 $ccdata = json_decode(aes256Decrypt($edata['checksum']),true);
69 $invdata = json_decode($edata['table_args'],true);
70 echo "<script type='text/javascript'>var jsondata='" . $edata['table_args'] . "';var ccdata='" . $edata['checksum'] . "'</script>";
72 function bucks( $amount ){
74 $amount = oeFormatMoney( $amount );
79 function rawbucks( $amount ){
81 $amount = sprintf( "%.2f", $amount );
87 // Display a row of data for an encounter.
90 function echoLine( $iname, $date, $charges, $ptpaid, $inspaid, $duept, $encounter = 0, $copay = 0, $patcopay = 0 ){
93 $balance = bucks( $charges - $ptpaid - $inspaid );
94 $balance = ( round( $duept, 2 ) != 0 ) ?
0 : $balance; // if balance is due from patient, then insurance balance is displayed as zero
95 $encounter = $encounter ?
$encounter : '';
96 echo " <tr id='tr_" . attr( $var_index ) . "' >\n";
97 echo " <td class='detail'>" . text( oeFormatShortDate( $date ) ) . "</td>\n";
98 echo " <td class='detail' id='" . attr( $date ) . "' align='left'>" . htmlspecialchars( $encounter, ENT_QUOTES
) . "</td>\n";
99 echo " <td class='detail' align='center' id='td_charges_$var_index' >" . htmlspecialchars( bucks( $charges ), ENT_QUOTES
) . "</td>\n";
100 echo " <td class='detail' align='center' id='td_inspaid_$var_index' >" . htmlspecialchars( bucks( $inspaid * - 1 ), ENT_QUOTES
) . "</td>\n";
101 echo " <td class='detail' align='center' id='td_ptpaid_$var_index' >" . htmlspecialchars( bucks( $ptpaid * - 1 ), ENT_QUOTES
) . "</td>\n";
102 echo " <td class='detail' align='center' id='td_patient_copay_$var_index' >" . htmlspecialchars( bucks( $patcopay ), ENT_QUOTES
) . "</td>\n";
103 echo " <td class='detail' align='center' id='td_copay_$var_index' >" . htmlspecialchars( bucks( $copay ), ENT_QUOTES
) . "</td>\n";
104 echo " <td class='detail' align='center' id='balance_$var_index'>" . htmlspecialchars( bucks( $balance ), ENT_QUOTES
) . "</td>\n";
105 echo " <td class='detail' align='center' id='duept_$var_index'>" . htmlspecialchars( bucks( round( $duept, 2 ) * 1 ), ENT_QUOTES
) . "</td>\n";
106 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";
110 // We use this to put dashes, colons, etc. back into a timestamp.
112 function decorateString( $fmt, $str ){
115 $fc = substr( $fmt, 0, 1 );
116 $fmt = substr( $fmt, 1 );
118 $res .= substr( $str, 0, 1 );
119 $str = substr( $str, 1 );
127 // Compute taxes from a tax rate string and a possibly taxable amount.
129 function calcTaxes( $row, $amount ){
131 if( empty( $row['taxrates'] ) ) return $total;
132 $arates = explode( ':', $row['taxrates'] );
133 if( empty( $arates ) ) return $total;
134 foreach( $arates as $value ){
135 if( empty( $value ) ) continue;
136 $trow = sqlQuery( "SELECT option_value FROM list_options WHERE " . "list_id = 'taxrate' AND option_id = ? LIMIT 1", array ($value
138 if( empty( $trow['option_value'] ) ){
139 echo "<!-- Missing tax rate '" . text( $value ) . "'! -->\n";
142 $tax = sprintf( "%01.2f", $amount * $trow['option_value'] );
143 // echo "<!-- Rate = '$value', amount = '$amount', tax = '$tax' -->\n";
150 $today = date( 'Y-m-d', $now );
151 $timestamp = date( 'Y-m-d H:i:s', $now );
154 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
156 $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
159 $alertmsg = ''; // anything here pops up in an alert box
161 // If the Save button was clicked...
162 if( $_POST['form_save'] ){
163 // $extra = json_decode($_POST['ajax_mode'], true);
164 $form_pid = $_POST['form_pid'];
165 $form_method = trim( $_POST['form_method'] );
166 $form_source = trim( $_POST['form_source'] );
167 $patdata = getPatientData( $form_pid, 'fname,mname,lname,pubpid' );
168 $NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname'];
170 if( $_REQUEST['radio_type_of_payment'] == 'pre_payment' ){
171 $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 (
172 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$_REQUEST['form_prepayment'],$NameNew,$form_method
175 frontPayment( $form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0, $timestamp ); // insertion to 'payments' table.
178 if( $_POST['form_upay'] && $_REQUEST['radio_type_of_payment'] != 'pre_payment' ){
179 foreach( $_POST['form_upay'] as $enc => $payment ){
180 if( $amount = 0 +
$payment ){
182 if( $_REQUEST['radio_type_of_payment'] == 'invoice_balance' ){
186 $enc = calendar_arrived( $form_pid );
189 // ----------------------------------------------------------------------------------------------------
190 // Fetching the existing code and modifier
191 $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
193 if( $RowSearch = sqlFetchArray( $ResultSearchNew ) ){
194 $Codetype = $RowSearch['code_type'];
195 $Code = $RowSearch['code'];
196 $Modifier = $RowSearch['modifier'];
202 // ----------------------------------------------------------------------------------------------------
203 if( $_REQUEST['radio_type_of_payment'] == 'copay' ) // copay saving to ar_session and ar_activity tables
205 $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 (
206 $_SESSION['authId'],$form_source,$amount,$form_pid,$form_method
209 $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
212 frontPayment( $form_pid, $enc, $form_method, $form_source, $amount, 0, $timestamp ); // insertion to 'payments' table.
214 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.
215 if( $_REQUEST['radio_type_of_payment'] == 'cash' ){
216 sqlStatement( "update form_encounter set last_level_closed=? where encounter=? and pid=? ", array (4,$enc,$form_pid
218 sqlStatement( "update billing set billed=? where encounter=? and pid=?", array (1,$enc,$form_pid
221 $adjustment_code = 'patient_payment';
222 $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 (
223 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$amount,$NameNew,$adjustment_code,$form_method
226 // --------------------------------------------------------------------------------------------------------------------
228 frontPayment( $form_pid, $enc, $form_method, $form_source, 0, $amount, $timestamp ); // insertion to 'payments' table.
230 // --------------------------------------------------------------------------------------------------------------------
232 $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
233 ) ); // new fees screen copay gives account_code='PCP'
234 $rowMoneyGot = sqlFetchArray( $resMoneyGot );
235 $Copay = $rowMoneyGot['PatientPay'];
237 // --------------------------------------------------------------------------------------------------------------------
239 // Looping the existing code and modifier
240 $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
242 while( $RowSearch = sqlFetchArray( $ResultSearchNew ) ){
243 $Codetype = $RowSearch['code_type'];
244 $Code = $RowSearch['code'];
245 $Modifier = $RowSearch['modifier'];
246 $Fee = $RowSearch['fee'];
248 $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
250 // new fees screen copay gives account_code='PCP'
251 $rowMoneyGot = sqlFetchArray( $resMoneyGot );
252 $MoneyGot = $rowMoneyGot['MoneyGot'];
254 $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
256 $rowMoneyAdjusted = sqlFetchArray( $resMoneyAdjusted );
257 $MoneyAdjusted = $rowMoneyAdjusted['MoneyAdjusted'];
259 $Remainder = $Fee - $Copay - $MoneyGot - $MoneyAdjusted;
261 if( round( $Remainder, 2 ) != 0 && $amount != 0 ){
262 if( $amount - $Remainder >= 0 ){
263 $insert_value = $Remainder;
264 $amount = $amount - $Remainder;
266 $insert_value = $amount;
269 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 (
270 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$insert_value,0
274 if( $amount != 0 ){ // if any excess is there.
275 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 (
276 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$amount,0
279 // --------------------------------------------------------------------------------------------------------------------
281 } // if ($amount = 0 + $payment)
283 } // if ($_POST['form_upay'])
284 } // if ($_POST['form_save'])
286 if( $_POST['form_save'] ||
$_REQUEST['receipt']){
288 if( $_REQUEST['receipt'] ){
289 $form_pid = $_GET['patient'];
290 $timestamp = decorateString( '....-..-.. ..:..:..', $_GET['time'] );
293 // Get details for what we guess is the primary facility.
294 $frow = sqlQuery( "SELECT * FROM facility " . "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1" );
296 // Get the patient's name and chart number.
297 $patdata = getPatientData( $form_pid, 'fname,mname,lname,pubpid' );
299 // Re-fetch payment info.
300 $payrow = sqlQuery( "SELECT " . "SUM(amount1) AS amount1, " . "SUM(amount2) AS amount2, " . "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " .
301 // "MAX(user) AS user " .
302 "MAX(user) AS user, " . "MAX(encounter) as encounter " . "FROM payments WHERE " . "pid = ? AND dtime = ?", array ($form_pid,$timestamp
305 // Create key for deleting, just in case.
306 $ref_id = ( $_REQUEST['radio_type_of_payment'] == 'copay' ) ?
$session_id : $payment_id;
307 $payment_key = $form_pid . '.' . preg_replace( '/[^0-9]/', '', $timestamp ) . '.' . $ref_id;
309 // get facility from encounter
310 $tmprow = sqlQuery( "
313 WHERE encounter = ?", array ($payrow['encounter']
315 $frow = sqlQuery( "SELECT * FROM facility " . " WHERE id = ?", array ($tmprow['facility_id']
318 // Now proceed with printing the receipt.
321 <title
><?php
echo xlt('Receipt for Payment'); ?
></title
>
323 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-11-3/index.js"></script
>
324 <script type
="text/javascript">
325 $
( document
).ready();
327 window
.location
.replace("./patient/onsiteactivityviews");
329 function notifyPatient(){
330 var pid
= <?php
echo attr($pid);?
>;
331 var note
= $
('#pop_receipt').text();
332 var formURL
= './messaging/handle_note.php';
336 data
: {'task':'add', 'pid':pid
, 'inputBody':note
, 'title':'Bill/Collect', 'sendto':'-patient-','noteid':'0'},
337 success
: function(data
, textStatus
, jqXHR
) {
338 alert('Receipt sent to patient via Messages.')
340 error
: function(jqXHR
, status
, error
) {
341 console
.log(status +
": " + error
);
348 echo '<htlm><head></head><body style="text-align: center; margin: auto;">';
351 <div id
='pop_receipt' style
='display: block'>
353 <h2
><?php
echo xlt('Receipt for Payment'); ?
></h2
>
354 <p
><?php
echo text($frow['name'])?
>
355 <br
><?php
echo text($frow['street'])?
>
356 <br
><?php
echo text( $frow['city'] . ', ' . $frow['state'] ) . ' ' . text( $frow['postal_code'] )?
>
357 <br
><?php
echo htmlentities($frow['phone'])?
>
359 <div style
="text-align: center; margin: auto;">
360 <table border
='0' cellspacing
='8'
361 style
="text-align: center; margin: auto;">
363 <td
><?php
echo xlt('Date'); ?
>:</td
>
364 <td
><?php
echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?
></td
>
367 <td
><?php
echo xlt('Patient'); ?
>:</td
>
368 <td
><?php
echo text( $patdata['fname'] ) . " " . text( $patdata['mname'] ) . " " . text( $patdata['lname'] ) . " (" . text( $patdata['pubpid'] ) . ")"?
></td
>
371 <td
><?php
echo xlt('Paid Via'); ?
>:</td
>
372 <td
><?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'payment_method'),$payrow['method']); ?
></td
>
375 <td
><?php
echo xlt('Authorized Id'); ?
>:</td
>
376 <td
><?php
echo text($payrow['source']) ?
></td
>
379 <td
><?php
echo xlt('Amount for This Visit'); ?
>:</td
>
380 <td
><?php
echo text(oeFormatMoney($payrow['amount1'])) ?
></td
>
383 <td
><?php
echo xlt('Amount for Past Balance'); ?
>:</td
>
384 <td
><?php
echo text(oeFormatMoney($payrow['amount2'])) ?
></td
>
387 <td
><?php
echo xlt('Received By'); ?
>:</td
>
388 <td
><?php
echo text($payrow['user']) ?
></td
>
393 <button
class='btn btn-sm' type
='button' onclick
='goHome()' id
='returnhome'><?php
echo xla('Return Home'); ?
></button
>
394 <button
class='btn btn-sm' type
='button' onclick
="notifyPatient()"><?php
echo xla('Notify Patient'); ?
></button
>
400 // Here we display the form for data entry.
403 <title
><?php
echo xlt('Record Payment'); ?
></title
>
404 <style type
="text/css">
406 /* font-family:sans-serif; font-size:10pt; font-weight:normal */
410 color
: #000000; /*font-family:sans-serif; font-size:10pt;*/
417 color
: #000000; /*font-family:sans-serif; font-size:10pt; */
421 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-creditcardvalidator-1-1-0/jquery.creditCardValidator.js"></script
>
422 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
424 <script type
="text/javascript">
426 function calctotal() {
428 var f
= document
.forms
["payfrm"];
430 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
431 var elem
= f
.elements
[i
];
432 var ename
= elem
.name
;
433 if (ename
.indexOf('form_upay[') == 0 || ename
.indexOf('form_bpay[') == 0) {
434 if (elem
.value
.length
> 0){
435 total +
= Number(elem
.value
);
436 if(total
< 0) flag
=1;
440 f
.form_paytotal
.value
= Number(total
).toFixed(2);
442 $
('#payfrm')[0].reset();
443 alert("<?php echo addslashes( xl('Negative payments not accepted')) ?>")
449 for (var i
= 1; ; ++i
)
451 if(document
.getElementById('paying_'+i
))
453 paying
=document
.getElementById('paying_'+i
).value
*1;
454 patient_balance
=document
.getElementById('duept_'+i
).innerHTML
*1;
455 //balance=document.getElementById('balance_'+i).innerHTML*1;
456 if(patient_balance
>0 && paying
>0)
458 if(paying
>patient_balance
)
460 document
.getElementById('paying_'+i
).style
.background
='#FF0000';
462 else if(paying
<patient_balance
)
464 document
.getElementById('paying_'+i
).style
.background
='#99CC00';
466 else if(paying
==patient_balance
)
468 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
473 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
482 function CheckVisible(MakeBlank
)
483 {//Displays and hides the check number text box.
484 if(document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='check_payment' ||
485 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='bank_draft' )
487 document
.getElementById('check_number').disabled
=false;
491 document
.getElementById('check_number').disabled
=true;
496 var f
= document
.forms
["payfrm"];
498 //no checks taken here....
500 /*if(((document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='check_payment' ||
501 document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='bank_draft') &&
502 document.getElementById('check_number').value=='' ))
504 alert("<?php //echo addslashes( xl('Please Fill the Check/Ref Number')) ?>");
505 document.getElementById('check_number').focus();
509 if(document
.getElementById('radio_type_of_payment_self1').checked
==false &&
510 document
.getElementById('radio_type_of_payment1').checked
==false
511 && document
.getElementById('radio_type_of_payment2').checked
==false
512 && document
.getElementById('radio_type_of_payment4').checked
==false)
514 alert("<?php //echo addslashes( xl('Please Select Type Of Payment.')) ?>");
517 if(document
.getElementById('radio_type_of_payment_self1').checked
==true || document
.getElementById('radio_type_of_payment1').checked
==true)
519 for (var i
= 0; i
< f
.elements
.length
; ++i
)
521 var elem
= f
.elements
[i
];
522 var ename
= elem
.name
;
523 if (ename
.indexOf('form_upay[0') == 0) //Today is this text box.
526 {//A warning message, if the amount is posted with out encounter.
527 if(confirm("<?php echo addslashes( xl('Are you sure to post for today?')) ?>"))
542 /* if(document.getElementById('radio_type_of_payment1').checked==true)
545 for (var i = 0; i < f.elements.length; ++i)
547 var elem = f.elements[i];
548 var ename = elem.name;
549 if (ename.indexOf('form_upay[') == 0) //Today is this text box.
551 if(f.form_paytotal.value*1!=elem.value*1)//Total CO-PAY is not posted against today
552 {//A warning message, if the amount is posted against an old encounter.
553 if(confirm("<?php //echo addslashes( xl('You are posting against an old encounter?')) ?>"))
567 else if( document
.getElementsByName('form_paytotal')[0].value
<= 0 )//total 0
569 alert("<?php echo addslashes( xl('Invalid Total!')) ?>")
575 if(confirm("<?php echo addslashes( xl('Payment Validated: Save?')) ?>"))
585 function cursor_pointer()
586 {//Point the cursor to the latest encounter(Today)
587 var f
= document
.forms
["payfrm"];
589 for (var i
= 0; i
< f
.elements
.length
; ++i
)
591 var elem
= f
.elements
[i
];
592 var ename
= elem
.name
;
593 if (ename
.indexOf('form_upay[') == 0)
600 //=====================================================
601 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
)
609 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
610 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
611 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
612 var balance_elem
= document
.getElementById('balance_'+i
)
615 td_inspaid_elem
.style
.display
="none";
616 td_patient_copay_elem
.style
.display
="none";
617 td_copay_elem
.style
.display
="none";
618 balance_elem
.style
.display
="none";
625 document
.getElementById('td_total_4').style
.display
="none";
626 document
.getElementById('td_total_7').style
.display
="none";
627 document
.getElementById('td_total_8').style
.display
="none";
628 document
.getElementById('td_total_6').style
.display
="none";
630 document
.getElementById('table_display').width
="420px";
633 //=====================================================
634 function make_visible()
636 document
.getElementById('td_head_rep_doc').style
.display
="";
637 document
.getElementById('td_head_description').style
.display
="";
638 document
.getElementById('td_head_total_charge').style
.display
="none";
639 document
.getElementById('td_head_insurance_payment').style
.display
="none";
640 document
.getElementById('td_head_patient_payment').style
.display
="none";
641 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
642 document
.getElementById('td_head_co_pay').style
.display
="none";
643 document
.getElementById('td_head_insurance_balance').style
.display
="none";
644 document
.getElementById('td_head_patient_balance').style
.display
="none";
645 for (var i
= 1; ; ++i
)
647 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
648 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
649 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
650 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
651 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
652 var balance_elem
= document
.getElementById('balance_'+i
)
653 var duept_elem
= document
.getElementById('duept_'+i
)
656 td_charges_elem
.style
.display
="none";
657 td_inspaid_elem
.style
.display
="none";
658 td_ptpaid_elem
.style
.display
="none";
659 td_patient_copay_elem
.style
.display
="none";
660 td_copay_elem
.style
.display
="none";
661 balance_elem
.style
.display
="none";
662 duept_elem
.style
.display
="none";
669 document
.getElementById('td_total_7').style
.display
="";
670 document
.getElementById('td_total_8').style
.display
="";
671 document
.getElementById('td_total_1').style
.display
="none";
672 document
.getElementById('td_total_2').style
.display
="none";
673 document
.getElementById('td_total_3').style
.display
="none";
674 document
.getElementById('td_total_4').style
.display
="none";
675 document
.getElementById('td_total_5').style
.display
="none";
676 document
.getElementById('td_total_6').style
.display
="none";
678 document
.getElementById('table_display').width
="505px";
680 function make_it_hide()
682 document
.getElementById('td_head_rep_doc').style
.display
="none";
683 document
.getElementById('td_head_description').style
.display
="none";
684 document
.getElementById('td_head_total_charge').style
.display
="";
685 document
.getElementById('td_head_insurance_payment').style
.display
="";
686 document
.getElementById('td_head_patient_payment').style
.display
="";
687 document
.getElementById('td_head_patient_co_pay').style
.display
="";
688 document
.getElementById('td_head_co_pay').style
.display
="";
689 document
.getElementById('td_head_insurance_balance').style
.display
="";
690 document
.getElementById('td_head_patient_balance').style
.display
="";
691 for (var i
= 1; ; ++i
)
693 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
694 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
695 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
696 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
697 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
698 var balance_elem
= document
.getElementById('balance_'+i
)
699 var duept_elem
= document
.getElementById('duept_'+i
)
702 td_charges_elem
.style
.display
="";
703 td_inspaid_elem
.style
.display
="";
704 td_ptpaid_elem
.style
.display
="";
705 td_patient_copay_elem
.style
.display
="";
706 td_copay_elem
.style
.display
="";
707 balance_elem
.style
.display
="";
708 duept_elem
.style
.display
="";
715 document
.getElementById('td_total_1').style
.display
="";
716 document
.getElementById('td_total_2').style
.display
="";
717 document
.getElementById('td_total_3').style
.display
="";
718 document
.getElementById('td_total_4').style
.display
="";
719 document
.getElementById('td_total_5').style
.display
="";
720 document
.getElementById('td_total_6').style
.display
="";
721 document
.getElementById('td_total_7').style
.display
="";
722 document
.getElementById('td_total_8').style
.display
="";
724 document
.getElementById('table_display').width
="100%";
726 function make_visible_radio()
728 document
.getElementById('tr_radio1').style
.display
="";
729 document
.getElementById('tr_radio2').style
.display
="none";
731 function make_hide_radio()
733 document
.getElementById('tr_radio1').style
.display
="none";
734 document
.getElementById('tr_radio2').style
.display
="";
736 function make_visible_row()
738 document
.getElementById('table_display').style
.display
="";
739 document
.getElementById('table_display_prepayment').style
.display
="none";
741 function make_hide_row()
743 document
.getElementById('table_display').style
.display
="none";
744 document
.getElementById('table_display_prepayment').style
.display
="";
750 make_it_hide_enc_pay();
751 document
.getElementById('radio_type_of_payment_self1').checked
=true;
754 function make_insurance()
759 document
.getElementById('radio_type_of_payment1').checked
=true;
761 //--------------------------------------------------------------------------------------------------//
762 $
('#paySubmit').click( function(e
) {
764 $
("#mode").val( "portal-save" );
765 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
766 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
767 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
770 var liburl
= './lib/paylib.php';
774 data
: $
("#payfrm").serialize()+extra
,
775 beforeSend
: function(xhr
){
776 if( validateCC() !== true) return false;
777 if( $
('#pin').val() == "" || $
('#ccname').val() == "" || $
('#ccyear').val() == "" || $
('#ccmonth').val() == ""){
778 alert("<?php echo addslashes( xl('Invalid Credit Card Values: Please correct')) ?>")
781 if( validate() != true){
783 alert("<?php echo addslashes( xl('Validation error: Fix and resubmit. This popup info is preserved!')) ?>")
786 $
("#openPayModal .close").click()
788 error
: function(qXHR
, textStatus
, errorThrow
){
789 console
.log("There was an error:"+errorThrow
);
791 success
: function(templateHtml
, textStatus
, jqXHR
){
792 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')) ?>")
793 window
.location
.reload(false);
797 $
("#openPayModal .close").click();
799 //---------------------------------------------------------------------------------------//
800 $
("#payfrm").on('submit', function(e
){
803 $
("#mode").val( "review-save" );
804 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
805 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
806 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
809 var liburl
='<?php echo $GLOBALS["webroot"] ?>/portal/lib/paylib.php';
813 data
: $
("#payfrm").serialize()+extra
,
814 beforeSend
: function(xhr
){
815 if( validate() != true){
817 alert("<?php echo addslashes( xl('Validation error: Fix and resubmit. Payment values are preserved!')) ?>")
821 error
: function(xhr
, textStatus
, error
){
822 alert("<?php echo addslashes( xl('There is a Post error')) ?>")
823 console
.log("There was an error:"+textStatus
);
826 success
: function(templateHtml
, textStatus
, jqXHR
){
831 function getFormObj(formId
) {
833 var inputs
= $
('#'+formId
).serializeArray();
834 $
.each(inputs
, function (i
, input
) {
835 formObj
[input
.name
] = input
.value
;
839 function formRepopulate(jsondata
){
840 data
= $
.parseJSON(jsondata
);
841 $
.each(data
, function(name
, val
){
842 var $el = $
('[name="'+name+
'"]'),
843 type
= $el.attr('type');
846 $el.prop('checked',true);
849 $el.filter('[value="'+val+
'"]').prop('checked', true);
857 var authnum
= prompt("<?php echo xlt('Please enter card comfirmation authorization') ?>", "");
858 if (authnum
!= null) {
859 $
('#check_number').val(authnum
);
864 <body
class="body_top" onunload
='imclosing()' onLoad
="cursor_pointer();"
865 style
="text-align: center; margin: auto;">
867 <form id
="payfrm" method
='post'
868 action
='<?php echo $GLOBALS["webroot"] ?>/portal/portal_payment.php'>
869 <input type
='hidden' name
='form_pid' value
='<?php echo attr($pid) ?>' />
870 <input type
='hidden' name
='form_save'
871 value
='<?php echo xlt('Invoice
');?>' />
875 <td colspan
="3"> 
;</td
>
879 <td colspan
='3' align
='center' class='text'><b
><?php
echo xlt('Accept Payment for'); ?
> 
;: 
; 
;<?php
881 echo htmlspecialchars( $patdata['fname'], ENT_QUOTES
) . " " . htmlspecialchars( $patdata['lname'], ENT_QUOTES
) . " " . htmlspecialchars( $patdata['mname'], ENT_QUOTES
) . " (" . htmlspecialchars( $patdata['pid'], ENT_QUOTES
) . ")"?
></b
>
882 <?php
$NameNew=$patdata['fname'] . " " .$patdata['lname']. " " .$patdata['mname'];?
>
886 <td colspan
='3'></td
>
890 <?php
echo xlt('Payment Method'); ?
>:
892 <td colspan
='2'><select name
="form_method" id
="form_method"
893 class="text" onChange
='CheckVisible("yes")'>
895 $query1112 = "SELECT * FROM list_options where list_id=? ORDER BY seq, title ";
896 $bres1112 = sqlStatement( $query1112, array ('payment_method') );
897 while( $brow1112 = sqlFetchArray( $bres1112 ) ){
898 if( $brow1112['option_id'] != 'credit_card' ||
$brow1112['option_id'] == 'electronic' ||
$brow1112['option_id'] == 'bank_draft' ) continue;
899 echo "<option value='" . htmlspecialchars( $brow1112['option_id'], ENT_QUOTES
) . "'>" . htmlspecialchars( xl_list_label( $brow1112['title'] ), ENT_QUOTES
) . "</option>";
906 <td colspan
='3'></td
>
911 <?php
echo xla('Authorized'); ?
>:
915 if( isset( $_SESSION['authUserID'] ) )
916 echo "<input type='text' id='check_number' name='form_source' style='width:120px;' value='" . htmlspecialchars( $payrow['source'], ENT_QUOTES
) . "'>";
921 <td colspan
='3'></td
>
924 <td
class='text' valign
="middle">
925 <?php
echo xlt('Patient Coverage'); ?
>:
927 <td
class='text' colspan
="2">
928 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverage1"
929 value
="self" onClick
="make_visible_radio();make_self();" />
930 <?php
echo xlt('Self'); ?
>
931 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverag2" value
="insurance" checked
="checked"
932 onClick
="make_hide_radio();make_insurance();" />
933 <?php
echo xlt('Insurance'); ?
>
937 <td colspan
='3'></td
>
939 <tr id
="tr_radio1" style
="display: none">
940 <!-- For radio Insurance
-->
941 <td
class='text' valign
="top">
942 <?php
echo xlt('Payment against'); ?
>:
944 <td
class='text' colspan
="2">
945 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment_self1"
946 value
="cash" onClick
="make_visible_row();make_it_hide_enc_pay();cursor_pointer();" />
947 <?php
echo xlt('Encounter Payment'); ?
>
951 <!-- For radio self
-->
952 <td
class='text' valign
="top"><?php
echo xlt('Payment against'); ?
>:
954 <td
class='text' colspan
="2"><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment1" checked
="checked"
955 value
="copay" onClick
="make_visible_row();cursor_pointer();" /><?php
echo xlt('Co Pay'); ?
>
956 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment2"
957 value
="invoice_balance" onClick
="make_visible_row();" /><?php
echo xlt('Invoice Balance'); ?
><br
/>
958 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment4" value
="pre_payment"
959 onClick
="make_hide_row();" /><?php
echo xlt('Pre Pay'); ?
></td
>
962 <td colspan
='3'></td
>
965 <table width
="35%" border
="0" cellspacing
="0" cellpadding
="0" id
="table_display_prepayment" style
="display: none">
967 <td
class='detail'><?php
echo xlt('Pre Payment'); ?
></td
>
968 <td
><input
class="form-control" type
='text' name
='form_prepayment' style
='width: 100px' /></td
>
971 <table id
="table_display" style
="width: 100%; background: #eee;" class="table table-striped table-responsive">
975 <!-- <table border
='0' id
="table_display" cellpadding
='0' cellspacing
='0' width
='100%'> -->
976 <tr bgcolor
="#cccccc" id
="tr_head">
977 <td
class="dehead" width
="60">
978 <?php
echo xlt('DOS')?
>
980 <td
class="dehead" width
="120">
981 <?php
echo xlt('Visit Reason')?
>
983 <td
class="dehead" align
="center" width
="70" id
="td_head_total_charge">
984 <?php
echo xlt('Total Charge')?
>
986 <td
class="dehead" align
="center" width
="70" id
="td_head_rep_doc" style
='display: none'>
987 <?php
echo xlt('Report/ Form')?
>
989 <td
class="dehead" align
="center" width
="200" id
="td_head_description" style
='display: none'>
990 <?php
echo xlt('Description')?
>
992 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_payment">
993 <?php
echo xlt('Insurance Payment')?
>
995 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_payment">
996 <?php
echo xlt('Patient Payment')?
>
998 <td
class="dehead" align
="center" width
="55" id
="td_head_patient_co_pay">
999 <?php
echo xlt('Co Pay Paid')?
>
1001 <td
class="dehead" align
="center" width
="55" id
="td_head_co_pay">
1002 <?php
echo xlt('Required Co Pay')?
>
1004 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_balance">
1005 <?php
echo xlt('Insurance Balance')?
>
1007 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_balance">
1008 <?php
echo xlt('Patient Balance')?
>
1010 <td
class="dehead" align
="center" width
="50">
1011 <?php
echo xlt('Paying')?
>
1016 // Get the unbilled service charges and payments by encounter for this patient.
1018 $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
1019 "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";
1020 $bres = sqlStatement( $query, array ($pid,$pid) );
1022 while( $brow = sqlFetchArray( $bres ) ){
1023 $key = 0 +
$brow['encounter'];
1024 if( empty( $encs[$key] ) ){
1025 $encs[$key] = array ('encounter' => $brow['encounter'],'date' => $brow['encdate'],'last_level_closed' => $brow['last_level_closed'],'charges' => 0,'payments' => 0,'reason'=>$brow['reason']
1028 if( $brow['code_type'] === 'COPAY' ){
1029 // $encs[$key]['payments'] -= $brow['fee'];
1031 $encs[$key]['charges'] +
= $brow['fee'];
1033 $sql_array = array ();
1034 $query = "SELECT taxrates FROM codes WHERE " . "code_type = ? AND " . "code = ? AND ";
1035 array_push( $sql_array, $code_types[$brow['code_type']]['id'], $brow['code'] );
1036 if( $brow['modifier'] ){
1037 $query .= "modifier = ?";
1038 array_push( $sql_array, $brow['modifier'] );
1040 $query .= "(modifier IS NULL OR modifier = '')";
1042 $query .= " LIMIT 1";
1043 $trow = sqlQuery( $query, $sql_array );
1044 $encs[$key]['charges'] +
= calcTaxes( $trow, $brow['fee'] );
1047 // Do the same for unbilled product sales.
1049 $query = "SELECT fe.encounter, fe.reason, s.drug_id, s.fee, " . "LEFT(fe.date, 10) AS encdate,fe.last_level_closed " . "FROM form_encounter AS fe left join drug_sales AS s " . "on s.pid = ? AND s.fee != 0 " . // AND s.billed = 0
1050 "AND fe.pid = s.pid AND fe.encounter = s.encounter " . "where fe.pid = ? " . "ORDER BY s.encounter";
1052 $dres = sqlStatement( $query, array ($pid,$pid) );
1054 while( $drow = sqlFetchArray( $dres ) ){
1055 $key = 0 +
$drow['encounter'];
1056 if( empty( $encs[$key] ) ){
1057 $encs[$key] = array ('encounter' => $drow['encounter'],'date' => $drow['encdate'],'last_level_closed' => $drow['last_level_closed'],'charges' => 0,'payments' => 0
1060 $encs[$key]['charges'] +
= $drow['fee'];
1062 $trow = sqlQuery( "SELECT taxrates FROM drug_templates WHERE drug_id = ? " . "ORDER BY selector LIMIT 1", array ($drow['drug_id']
1064 $encs[$key]['charges'] +
= calcTaxes( $trow, $drow['fee'] );
1067 ksort( $encs, SORT_NUMERIC
);
1069 // Bringing on top the Today always
1070 foreach( $encs as $key => $value ){
1071 $dispdate = $value['date'];
1072 if( strcmp( $dispdate, $today ) == 0 && ! $gottoday ){
1078 // If no billing was entered yet for today, then generate a line for
1079 // entering today's co-pay.
1082 // echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0 /*$duept*/);//No encounter yet defined.
1085 foreach( $encs as $key => $value ){
1086 $enc = $value['encounter'];
1087 $reason = $value['reason'];
1088 $dispdate = $value['date'];
1089 if( strcmp( $dispdate, $today ) == 0 && ! $gottoday ){
1090 $dispdate = date( "Y-m-d" );
1093 // ------------------------------------------------------------------------------------
1094 $inscopay = getCopay( $pid, $dispdate );
1095 $patcopay = getPatientCopay( $pid, $enc );
1096 // Insurance Payment
1097 // -----------------
1098 $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
1100 $dpayment = $drow['payments'];
1101 $dadjustment = $drow['adjustments'];
1104 $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
1106 $dpayment_pat = $drow['payments'];
1108 // ------------------------------------------------------------------------------------
1109 // NumberOfInsurance
1110 $ResultNumberOfInsurance = sqlStatement( "SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
1111 where pid = ? and provider>0 ", array ($pid
1113 $RowNumberOfInsurance = sqlFetchArray( $ResultNumberOfInsurance );
1114 $NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1;
1115 // ------------------------------------------------------------------------------------
1117 if( ( ( $NumberOfInsurance == 0 ||
$value['last_level_closed'] == 4 ||
$NumberOfInsurance == $value['last_level_closed'] ) ) ){ // Patient balance
1118 $brow = sqlQuery( "SELECT SUM(fee) AS amount FROM billing WHERE " . "pid = ? and encounter = ? AND activity = 1", array ($pid,$enc
1120 $srow = sqlQuery( "SELECT SUM(fee) AS amount FROM drug_sales WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1122 $drow = sqlQuery( "SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1124 $duept = $brow['amount'] +
$srow['amount'] - $drow['payments'] - $drow['adjustments'];
1126 echoLine( "form_upay[$enc]", $dispdate, $value['charges'], $dpayment_pat, ( $dpayment +
$dadjustment ), $duept, ($enc.':'.$reason), $inscopay, $patcopay );
1129 // Continue with display of the data entry form.
1132 <td
class="dehead" id
='td_total_1'></td
>
1133 <td
class="dehead" id
='td_total_2'></td
>
1134 <td
class="dehead" id
='td_total_3'></td
>
1135 <td
class="dehead" id
='td_total_4'></td
>
1136 <td
class="dehead" id
='td_total_5'></td
>
1137 <td
class="dehead" id
='td_total_6'></td
>
1138 <td
class="dehead" id
='td_total_7'></td
>
1139 <td
class="dehead" id
='td_total_8'></td
>
1140 <td
class="dehead" align
="right"><?php
echo xlt('Total');?
></td
>
1141 <td
class="dehead" align
="right"><input
class="form-control" type
='text' name
='form_paytotal'
1142 value
='' style
='color: #00aa00; width: 65px; padding: 1px 1px;' readonly
/>
1147 if( isset( $ccdata["name"] ) ){
1148 echo '<div class="col-xs-12 col-md-4 col-lg-4">
1149 <div class="panel panel-default height">';
1150 if( ! isset( $_SESSION['authUserID'] ) )
1151 echo '<div class="panel-heading">'.xlt("Payment Information").'<span style="color:#cc0000"><em> '.xlt("Pending Auth since").': </em>'.text($edata["date"]).'</span></div>';
1153 echo '<div class="panel-heading">'.xlt("Payment Information").' <button type="button" class="btn btn-danger btn-sm" onclick="getAuth()">'.xlt("Authorize").'</button></div>';
1156 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>';
1159 <div
class="panel-body">
1160 <strong
><?php
echo xlt('Card Name');?
>: </strong
><span id
="cn"><?php
echo attr($ccdata["cc_type"])?
></span
><br
>
1161 <strong
><?php
echo xlt('Name On Card');?
>: </strong
><span id
="nc"><?php
echo attr($ccdata["name"])?
></span
><br
>
1162 <strong
><?php
echo xlt('Card Number');?
>: </strong
><span id
="ccn"><?php
1163 if( isset( $_SESSION['authUserID'] ) )
1164 echo $ccdata["cc_number"] . "</span><br>";
1166 echo "********** ".substr($ccdata["cc_number"],-4) . "</span><br>";
1168 <strong
><?php
echo xlt('Exp Date');?
>: </strong
><span id
="ed"><?php
echo attr($ccdata["month"])."/".attr($ccdata["year"])?
></span
><br
>
1169 <strong
><?php
echo xlt('Charge Total');?
>: </strong
><span id
="ct"><?php
echo attr($invdata["form_paytotal"])?
></span
><br
>
1175 if( ! isset( $_SESSION['authUserID'] ) )
1176 echo '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#openPayModal">' . xlt("Pay Invoice") . '</button>';
1178 echo "<button type='submit' class='btn btn-danger' form='payfrm'>" . xlt('Post Payment') . "</button>";
1182 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo attr($pid);?>" />
1183 <input type
='hidden' name
='mode' id
='mode' value
='' />
1186 <script type
="text/javascript">
1187 if (typeof jsondata
!== 'undefined') {
1188 formRepopulate(jsondata
);
1192 <!-- credit payment modal
-->
1193 <div id
="openPayModal" class="modal fade" role
="dialog">
1194 <div
class="modal-dialog">
1195 <div
class="modal-content">
1196 <div
class="modal-header">
1197 <h3
><?php
echo xlt('Submit Payment for Authorization');?
></h3
>
1198 <button type
="button" class="close" data
-dismiss
="modal">×
;</button
>
1200 <div
class="modal-body container">
1201 <form id
='paycredit' class="form-horizontal col-xs-12 col-sm-6 col-md-6">
1203 <div
class="control-group">
1204 <label label
-default="label-default" class="control-label"><?php
echo xlt('Name on Card');?
></label
>
1205 <div
class="controls">
1206 <input name
="name" id
="ccname" type
="text" class="form-control"
1207 pattern
="\w+ \w+.*" title
="<?php echo xla('Fill your first and last name'); ?>"
1208 required value
="" />
1211 <div
class="control-group">
1212 <label
class="control-label"><?php
echo xlt('Card Number');?
></label
>
1213 <div
class="controls">
1215 <div
class="col-sm-12">
1216 <input name
="cc_number" id
="cc_number" type
="text" class="form-control inline col-sm-3"
1217 autocomplete
="off" maxlength
="19" pattern
="\d" onchange
="validateCC()"
1218 title
="<?php echo xla('Card Number'); ?>" required value
="" />
1219 <input disabled name
="cardtype" id
="cardtype" type
="text" class="form-control inline" title
="<?php echo xla('Card Type'); ?>" style
="max-width:160px;font-weight:bold;color:red;" value
="" />
1224 <div
class="control-group">
1225 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card Expiry Date');?
></label
>
1226 <div
class="controls">
1228 <div
class="col-md-4">
1229 <select name
="month" id
="ccmonth" class="form-control">
1230 <option value
=""><?php
echo xlt('Select Month'); ?
></option
>
1231 <option value
="01"><?php
echo xlt('January'); ?
></option
>
1232 <option value
="02"><?php
echo xlt('February'); ?
></option
>
1233 <option value
="03"><?php
echo xlt('March'); ?
></option
>
1234 <option value
="04"><?php
echo xlt('April'); ?
></option
>
1235 <option value
="05"><?php
echo xlt('May'); ?
></option
>
1236 <option value
="06"><?php
echo xlt('June'); ?
></option
>
1237 <option value
="07"><?php
echo xlt('July'); ?
></option
>
1238 <option value
="08"><?php
echo xlt('August'); ?
></option
>
1239 <option value
="09"><?php
echo xlt('September'); ?
></option
>
1240 <option value
="10"><?php
echo xlt('October'); ?
></option
>
1241 <option value
="11"><?php
echo xlt('November'); ?
></option
>
1242 <option value
="12"><?php
echo xlt('December'); ?
></option
>
1245 <div
class="col-md-3">
1246 <select name
="year" id
="ccyear" class="form-control">
1247 <option value
=""><?php
echo xlt('Select Year'); ?
></option
>
1248 <option value
="2017">2017</option
>
1249 <option value
="2018">2018</option
>
1250 <option value
="2019">2019</option
>
1251 <option value
="2020">2020</option
>
1252 <option value
="2021">2021</option
>
1253 <option value
="2022">2022</option
>
1254 <option value
="2023">2023</option
>
1255 <option value
="2024">2024</option
>
1261 <div
class="control-group">
1262 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card CVV');?
></label
>
1263 <div
class="controls">
1265 <div
class="col-md-3">
1266 <input name
="pin" id
="pin" type
="text" class="form-control"
1267 autocomplete
="off" maxlength
="4" pattern
="\d{3}" onfocus
="validateCC()"
1268 title
="<?php echo xlt('Three or four digits at back of your card'); ?>" required value
="" />
1270 <div
class="col-md-3">
1271 <img src
='./images/img_cvc.png' style
='height: 58px; width: auto'>
1276 <div
class="form-actions">
1277 <button id
="paySubmit" class="btn btn-danger"><?php
echo xlt('Submit');?
></button
>
1278 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Cancel');?
></button
>
1281 <input type
='hidden' name
='cc_type' id
='cc_type' value
='' />
1285 <div
class="modal-footer">
1286 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Close');?
></button
>
1291 <?php
echo "<script>var ccerr='". xlt('Invalid Credit Card Number') . "';</script>";?
>
1292 <script type
="text/javascript">
1293 $
('#cc_number').validateCreditCard(function(result
){
1294 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1295 var v
= (result
.valid
== true ?
' Valid #' : ' Invalid #')
1296 $
('#cardtype').val(r+v
);
1298 function validateCC() {
1299 var result
= $
('#cc_number').validateCreditCard();
1300 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1301 var v
= (result
.valid
== true ?
' Okay' : ' Invalid #')
1302 $
('#cardtype').val(r+v
);
1303 $
('#cc_type').val(r
);