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 );
42 require_once ( dirname( __FILE__
) . "/lib/appsql.class.php" );
43 require_once ( "$srcdir/acl.inc" );
44 require_once ( "$srcdir/patient.inc" );
45 require_once ( "$srcdir/billing.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/formatting.inc.php" );
52 require_once ( "$srcdir/options.inc.php" );
53 require_once ( "$srcdir/encounter_events.inc.php" );
55 $appsql = new ApplicationTable();
57 $pid = $_REQUEST['hidden_patient_code'] > 0 ?
$_REQUEST['hidden_patient_code'] : $pid;
59 $edata = $appsql->getPortalAudit( $pid, 'review', 'payment' );
64 $ccdata = json_decode(aes256Decrypt($edata['checksum']),true);
65 $invdata = json_decode($edata['table_args'],true);
66 echo "<script type='text/javascript'>var jsondata='" . $edata['table_args'] . "';var ccdata='" . $edata['checksum'] . "'</script>";
68 function bucks( $amount ){
70 $amount = oeFormatMoney( $amount );
75 function rawbucks( $amount ){
77 $amount = sprintf( "%.2f", $amount );
83 // Display a row of data for an encounter.
86 function echoLine( $iname, $date, $charges, $ptpaid, $inspaid, $duept, $encounter = 0, $copay = 0, $patcopay = 0 ){
89 $balance = bucks( $charges - $ptpaid - $inspaid );
90 $balance = ( round( $duept, 2 ) != 0 ) ?
0 : $balance; // if balance is due from patient, then insurance balance is displayed as zero
91 $encounter = $encounter ?
$encounter : '';
92 echo " <tr id='tr_" . attr( $var_index ) . "' >\n";
93 echo " <td class='detail'>" . text( oeFormatShortDate( $date ) ) . "</td>\n";
94 echo " <td class='detail' id='" . attr( $date ) . "' align='left'>" . htmlspecialchars( $encounter, ENT_QUOTES
) . "</td>\n";
95 echo " <td class='detail' align='center' id='td_charges_$var_index' >" . htmlspecialchars( bucks( $charges ), ENT_QUOTES
) . "</td>\n";
96 echo " <td class='detail' align='center' id='td_inspaid_$var_index' >" . htmlspecialchars( bucks( $inspaid * - 1 ), ENT_QUOTES
) . "</td>\n";
97 echo " <td class='detail' align='center' id='td_ptpaid_$var_index' >" . htmlspecialchars( bucks( $ptpaid * - 1 ), ENT_QUOTES
) . "</td>\n";
98 echo " <td class='detail' align='center' id='td_patient_copay_$var_index' >" . htmlspecialchars( bucks( $patcopay ), ENT_QUOTES
) . "</td>\n";
99 echo " <td class='detail' align='center' id='td_copay_$var_index' >" . htmlspecialchars( bucks( $copay ), ENT_QUOTES
) . "</td>\n";
100 echo " <td class='detail' align='center' id='balance_$var_index'>" . htmlspecialchars( bucks( $balance ), ENT_QUOTES
) . "</td>\n";
101 echo " <td class='detail' align='center' id='duept_$var_index'>" . htmlspecialchars( bucks( round( $duept, 2 ) * 1 ), ENT_QUOTES
) . "</td>\n";
102 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";
106 // We use this to put dashes, colons, etc. back into a timestamp.
108 function decorateString( $fmt, $str ){
111 $fc = substr( $fmt, 0, 1 );
112 $fmt = substr( $fmt, 1 );
114 $res .= substr( $str, 0, 1 );
115 $str = substr( $str, 1 );
123 // Compute taxes from a tax rate string and a possibly taxable amount.
125 function calcTaxes( $row, $amount ){
127 if( empty( $row['taxrates'] ) ) return $total;
128 $arates = explode( ':', $row['taxrates'] );
129 if( empty( $arates ) ) return $total;
130 foreach( $arates as $value ){
131 if( empty( $value ) ) continue;
132 $trow = sqlQuery( "SELECT option_value FROM list_options WHERE " . "list_id = 'taxrate' AND option_id = ? LIMIT 1", array ($value
134 if( empty( $trow['option_value'] ) ){
135 echo "<!-- Missing tax rate '" . text( $value ) . "'! -->\n";
138 $tax = sprintf( "%01.2f", $amount * $trow['option_value'] );
139 // echo "<!-- Rate = '$value', amount = '$amount', tax = '$tax' -->\n";
146 $today = date( 'Y-m-d', $now );
147 $timestamp = date( 'Y-m-d H:i:s', $now );
150 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
152 $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
155 $alertmsg = ''; // anything here pops up in an alert box
157 // If the Save button was clicked...
158 if( $_POST['form_save'] ){
159 // $extra = json_decode($_POST['ajax_mode'], true);
160 $form_pid = $_POST['form_pid'];
161 $form_method = trim( $_POST['form_method'] );
162 $form_source = trim( $_POST['form_source'] );
163 $patdata = getPatientData( $form_pid, 'fname,mname,lname,pubpid' );
164 $NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname'];
166 if( $_REQUEST['radio_type_of_payment'] == 'pre_payment' ){
167 $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 (
168 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$_REQUEST['form_prepayment'],$NameNew,$form_method
171 frontPayment( $form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0, $timestamp ); // insertion to 'payments' table.
174 if( $_POST['form_upay'] && $_REQUEST['radio_type_of_payment'] != 'pre_payment' ){
175 foreach( $_POST['form_upay'] as $enc => $payment ){
176 if( $amount = 0 +
$payment ){
178 if( $_REQUEST['radio_type_of_payment'] == 'invoice_balance' ){
182 $enc = calendar_arrived( $form_pid );
185 // ----------------------------------------------------------------------------------------------------
186 // Fetching the existing code and modifier
187 $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
189 if( $RowSearch = sqlFetchArray( $ResultSearchNew ) ){
190 $Codetype = $RowSearch['code_type'];
191 $Code = $RowSearch['code'];
192 $Modifier = $RowSearch['modifier'];
198 // ----------------------------------------------------------------------------------------------------
199 if( $_REQUEST['radio_type_of_payment'] == 'copay' ) // copay saving to ar_session and ar_activity tables
201 $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 (
202 $_SESSION['authId'],$form_source,$amount,$form_pid,$form_method
205 $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
208 frontPayment( $form_pid, $enc, $form_method, $form_source, $amount, 0, $timestamp ); // insertion to 'payments' table.
210 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.
211 if( $_REQUEST['radio_type_of_payment'] == 'cash' ){
212 sqlStatement( "update form_encounter set last_level_closed=? where encounter=? and pid=? ", array (4,$enc,$form_pid
214 sqlStatement( "update billing set billed=? where encounter=? and pid=?", array (1,$enc,$form_pid
217 $adjustment_code = 'patient_payment';
218 $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 (
219 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$amount,$NameNew,$adjustment_code,$form_method
222 // --------------------------------------------------------------------------------------------------------------------
224 frontPayment( $form_pid, $enc, $form_method, $form_source, 0, $amount, $timestamp ); // insertion to 'payments' table.
226 // --------------------------------------------------------------------------------------------------------------------
228 $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
229 ) ); // new fees screen copay gives account_code='PCP'
230 $rowMoneyGot = sqlFetchArray( $resMoneyGot );
231 $Copay = $rowMoneyGot['PatientPay'];
233 // --------------------------------------------------------------------------------------------------------------------
235 // Looping the existing code and modifier
236 $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
238 while( $RowSearch = sqlFetchArray( $ResultSearchNew ) ){
239 $Codetype = $RowSearch['code_type'];
240 $Code = $RowSearch['code'];
241 $Modifier = $RowSearch['modifier'];
242 $Fee = $RowSearch['fee'];
244 $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
246 // new fees screen copay gives account_code='PCP'
247 $rowMoneyGot = sqlFetchArray( $resMoneyGot );
248 $MoneyGot = $rowMoneyGot['MoneyGot'];
250 $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
252 $rowMoneyAdjusted = sqlFetchArray( $resMoneyAdjusted );
253 $MoneyAdjusted = $rowMoneyAdjusted['MoneyAdjusted'];
255 $Remainder = $Fee - $Copay - $MoneyGot - $MoneyAdjusted;
257 if( round( $Remainder, 2 ) != 0 && $amount != 0 ){
258 if( $amount - $Remainder >= 0 ){
259 $insert_value = $Remainder;
260 $amount = $amount - $Remainder;
262 $insert_value = $amount;
265 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 (
266 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$insert_value,0
270 if( $amount != 0 ){ // if any excess is there.
271 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 (
272 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$amount,0
275 // --------------------------------------------------------------------------------------------------------------------
277 } // if ($amount = 0 + $payment)
279 } // if ($_POST['form_upay'])
280 } // if ($_POST['form_save'])
282 if( $_POST['form_save'] ||
$_REQUEST['receipt']){
284 if( $_REQUEST['receipt'] ){
285 $form_pid = $_GET['patient'];
286 $timestamp = decorateString( '....-..-.. ..:..:..', $_GET['time'] );
289 // Get details for what we guess is the primary facility.
290 $frow = sqlQuery( "SELECT * FROM facility " . "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1" );
292 // Get the patient's name and chart number.
293 $patdata = getPatientData( $form_pid, 'fname,mname,lname,pubpid' );
295 // Re-fetch payment info.
296 $payrow = sqlQuery( "SELECT " . "SUM(amount1) AS amount1, " . "SUM(amount2) AS amount2, " . "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " .
297 // "MAX(user) AS user " .
298 "MAX(user) AS user, " . "MAX(encounter) as encounter " . "FROM payments WHERE " . "pid = ? AND dtime = ?", array ($form_pid,$timestamp
301 // Create key for deleting, just in case.
302 $ref_id = ( $_REQUEST['radio_type_of_payment'] == 'copay' ) ?
$session_id : $payment_id;
303 $payment_key = $form_pid . '.' . preg_replace( '/[^0-9]/', '', $timestamp ) . '.' . $ref_id;
305 // get facility from encounter
306 $tmprow = sqlQuery( "
309 WHERE encounter = ?", array ($payrow['encounter']
311 $frow = sqlQuery( "SELECT * FROM facility " . " WHERE id = ?", array ($tmprow['facility_id']
314 // Now proceed with printing the receipt.
317 <title
><?php
echo xlt('Receipt for Payment'); ?
></title
>
319 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-11-3/index.js"></script
>
320 <script type
="text/javascript">
321 $
( document
).ready();
323 window
.location
.replace("./patient/onsiteactivityviews");
325 function notifyPatient(){
326 var pid
= <?php
echo attr($pid);?
>;
327 var note
= $
('#pop_receipt').text();
328 var formURL
= './messaging/handle_note.php';
332 data
: {'task':'add', 'pid':pid
, 'inputBody':note
, 'title':'Bill/Collect', 'sendto':'-patient-','noteid':'0'},
333 success
: function(data
, textStatus
, jqXHR
) {
334 alert('Receipt sent to patient via Messages.')
336 error
: function(jqXHR
, status
, error
) {
337 console
.log(status +
": " + error
);
344 echo '<htlm><head></head><body style="text-align: center; margin: auto;">';
347 <div id
='pop_receipt' style
='display: block'>
349 <h2
><?php
echo xlt('Receipt for Payment'); ?
></h2
>
350 <p
><?php
echo text($frow['name'])?
>
351 <br
><?php
echo text($frow['street'])?
>
352 <br
><?php
echo text( $frow['city'] . ', ' . $frow['state'] ) . ' ' . text( $frow['postal_code'] )?
>
353 <br
><?php
echo htmlentities($frow['phone'])?
>
355 <div style
="text-align: center; margin: auto;">
356 <table border
='0' cellspacing
='8'
357 style
="text-align: center; margin: auto;">
359 <td
><?php
echo xlt('Date'); ?
>:</td
>
360 <td
><?php
echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?
></td
>
363 <td
><?php
echo xlt('Patient'); ?
>:</td
>
364 <td
><?php
echo text( $patdata['fname'] ) . " " . text( $patdata['mname'] ) . " " . text( $patdata['lname'] ) . " (" . text( $patdata['pubpid'] ) . ")"?
></td
>
367 <td
><?php
echo xlt('Paid Via'); ?
>:</td
>
368 <td
><?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'payment_method'),$payrow['method']); ?
></td
>
371 <td
><?php
echo xlt('Authorized Id'); ?
>:</td
>
372 <td
><?php
echo text($payrow['source']) ?
></td
>
375 <td
><?php
echo xlt('Amount for This Visit'); ?
>:</td
>
376 <td
><?php
echo text(oeFormatMoney($payrow['amount1'])) ?
></td
>
379 <td
><?php
echo xlt('Amount for Past Balance'); ?
>:</td
>
380 <td
><?php
echo text(oeFormatMoney($payrow['amount2'])) ?
></td
>
383 <td
><?php
echo xlt('Received By'); ?
>:</td
>
384 <td
><?php
echo text($payrow['user']) ?
></td
>
389 <button
class='btn btn-sm' type
='button' onclick
='goHome()' id
='returnhome'><?php
echo xla('Return Home'); ?
></button
>
390 <button
class='btn btn-sm' type
='button' onclick
="notifyPatient()"><?php
echo xla('Notify Patient'); ?
></button
>
396 // Here we display the form for data entry.
399 <title
><?php
echo xlt('Record Payment'); ?
></title
>
400 <style type
="text/css">
402 /* font-family:sans-serif; font-size:10pt; font-weight:normal */
406 color
: #000000; /*font-family:sans-serif; font-size:10pt;*/
413 color
: #000000; /*font-family:sans-serif; font-size:10pt; */
417 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-creditcardvalidator-1-1-0/jquery.creditCardValidator.js"></script
>
418 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
420 <script type
="text/javascript">
422 function calctotal() {
424 var f
= document
.forms
["payfrm"];
426 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
427 var elem
= f
.elements
[i
];
428 var ename
= elem
.name
;
429 if (ename
.indexOf('form_upay[') == 0 || ename
.indexOf('form_bpay[') == 0) {
430 if (elem
.value
.length
> 0){
431 total +
= Number(elem
.value
);
432 if(total
< 0) flag
=1;
436 f
.form_paytotal
.value
= Number(total
).toFixed(2);
438 $
('#payfrm')[0].reset();
439 alert("<?php echo addslashes( xl('Negative payments not accepted')) ?>")
445 for (var i
= 1; ; ++i
)
447 if(document
.getElementById('paying_'+i
))
449 paying
=document
.getElementById('paying_'+i
).value
*1;
450 patient_balance
=document
.getElementById('duept_'+i
).innerHTML
*1;
451 //balance=document.getElementById('balance_'+i).innerHTML*1;
452 if(patient_balance
>0 && paying
>0)
454 if(paying
>patient_balance
)
456 document
.getElementById('paying_'+i
).style
.background
='#FF0000';
458 else if(paying
<patient_balance
)
460 document
.getElementById('paying_'+i
).style
.background
='#99CC00';
462 else if(paying
==patient_balance
)
464 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
469 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
478 function CheckVisible(MakeBlank
)
479 {//Displays and hides the check number text box.
480 if(document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='check_payment' ||
481 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='bank_draft' )
483 document
.getElementById('check_number').disabled
=false;
487 document
.getElementById('check_number').disabled
=true;
492 var f
= document
.forms
["payfrm"];
494 //no checks taken here....
496 /*if(((document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='check_payment' ||
497 document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='bank_draft') &&
498 document.getElementById('check_number').value=='' ))
500 alert("<?php //echo addslashes( xl('Please Fill the Check/Ref Number')) ?>");
501 document.getElementById('check_number').focus();
505 if(document
.getElementById('radio_type_of_payment_self1').checked
==false &&
506 document
.getElementById('radio_type_of_payment1').checked
==false
507 && document
.getElementById('radio_type_of_payment2').checked
==false
508 && document
.getElementById('radio_type_of_payment4').checked
==false)
510 alert("<?php //echo addslashes( xl('Please Select Type Of Payment.')) ?>");
513 if(document
.getElementById('radio_type_of_payment_self1').checked
==true || document
.getElementById('radio_type_of_payment1').checked
==true)
515 for (var i
= 0; i
< f
.elements
.length
; ++i
)
517 var elem
= f
.elements
[i
];
518 var ename
= elem
.name
;
519 if (ename
.indexOf('form_upay[0') == 0) //Today is this text box.
522 {//A warning message, if the amount is posted with out encounter.
523 if(confirm("<?php echo addslashes( xl('Are you sure to post for today?')) ?>"))
538 /* if(document.getElementById('radio_type_of_payment1').checked==true)
541 for (var i = 0; i < f.elements.length; ++i)
543 var elem = f.elements[i];
544 var ename = elem.name;
545 if (ename.indexOf('form_upay[') == 0) //Today is this text box.
547 if(f.form_paytotal.value*1!=elem.value*1)//Total CO-PAY is not posted against today
548 {//A warning message, if the amount is posted against an old encounter.
549 if(confirm("<?php //echo addslashes( xl('You are posting against an old encounter?')) ?>"))
563 else if( document
.getElementsByName('form_paytotal')[0].value
<= 0 )//total 0
565 alert("<?php echo addslashes( xl('Invalid Total!')) ?>")
571 if(confirm("<?php echo addslashes( xl('Payment Validated: Save?')) ?>"))
581 function cursor_pointer()
582 {//Point the cursor to the latest encounter(Today)
583 var f
= document
.forms
["payfrm"];
585 for (var i
= 0; i
< f
.elements
.length
; ++i
)
587 var elem
= f
.elements
[i
];
588 var ename
= elem
.name
;
589 if (ename
.indexOf('form_upay[') == 0)
596 //=====================================================
597 function make_it_hide_enc_pay()
599 document
.getElementById('td_head_insurance_payment').style
.display
="none";
600 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
601 document
.getElementById('td_head_co_pay').style
.display
="none";
602 document
.getElementById('td_head_insurance_balance').style
.display
="none";
603 for (var i
= 1; ; ++i
)
605 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
606 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
607 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
608 var balance_elem
= document
.getElementById('balance_'+i
)
611 td_inspaid_elem
.style
.display
="none";
612 td_patient_copay_elem
.style
.display
="none";
613 td_copay_elem
.style
.display
="none";
614 balance_elem
.style
.display
="none";
621 document
.getElementById('td_total_4').style
.display
="none";
622 document
.getElementById('td_total_7').style
.display
="none";
623 document
.getElementById('td_total_8').style
.display
="none";
624 document
.getElementById('td_total_6').style
.display
="none";
626 document
.getElementById('table_display').width
="420px";
629 //=====================================================
630 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
)
643 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
644 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
645 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
646 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
647 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
648 var balance_elem
= document
.getElementById('balance_'+i
)
649 var duept_elem
= document
.getElementById('duept_'+i
)
652 td_charges_elem
.style
.display
="none";
653 td_inspaid_elem
.style
.display
="none";
654 td_ptpaid_elem
.style
.display
="none";
655 td_patient_copay_elem
.style
.display
="none";
656 td_copay_elem
.style
.display
="none";
657 balance_elem
.style
.display
="none";
658 duept_elem
.style
.display
="none";
665 document
.getElementById('td_total_7').style
.display
="";
666 document
.getElementById('td_total_8').style
.display
="";
667 document
.getElementById('td_total_1').style
.display
="none";
668 document
.getElementById('td_total_2').style
.display
="none";
669 document
.getElementById('td_total_3').style
.display
="none";
670 document
.getElementById('td_total_4').style
.display
="none";
671 document
.getElementById('td_total_5').style
.display
="none";
672 document
.getElementById('td_total_6').style
.display
="none";
674 document
.getElementById('table_display').width
="505px";
676 function make_it_hide()
678 document
.getElementById('td_head_rep_doc').style
.display
="none";
679 document
.getElementById('td_head_description').style
.display
="none";
680 document
.getElementById('td_head_total_charge').style
.display
="";
681 document
.getElementById('td_head_insurance_payment').style
.display
="";
682 document
.getElementById('td_head_patient_payment').style
.display
="";
683 document
.getElementById('td_head_patient_co_pay').style
.display
="";
684 document
.getElementById('td_head_co_pay').style
.display
="";
685 document
.getElementById('td_head_insurance_balance').style
.display
="";
686 document
.getElementById('td_head_patient_balance').style
.display
="";
687 for (var i
= 1; ; ++i
)
689 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
690 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
691 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
692 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
693 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
694 var balance_elem
= document
.getElementById('balance_'+i
)
695 var duept_elem
= document
.getElementById('duept_'+i
)
698 td_charges_elem
.style
.display
="";
699 td_inspaid_elem
.style
.display
="";
700 td_ptpaid_elem
.style
.display
="";
701 td_patient_copay_elem
.style
.display
="";
702 td_copay_elem
.style
.display
="";
703 balance_elem
.style
.display
="";
704 duept_elem
.style
.display
="";
711 document
.getElementById('td_total_1').style
.display
="";
712 document
.getElementById('td_total_2').style
.display
="";
713 document
.getElementById('td_total_3').style
.display
="";
714 document
.getElementById('td_total_4').style
.display
="";
715 document
.getElementById('td_total_5').style
.display
="";
716 document
.getElementById('td_total_6').style
.display
="";
717 document
.getElementById('td_total_7').style
.display
="";
718 document
.getElementById('td_total_8').style
.display
="";
720 document
.getElementById('table_display').width
="100%";
722 function make_visible_radio()
724 document
.getElementById('tr_radio1').style
.display
="";
725 document
.getElementById('tr_radio2').style
.display
="none";
727 function make_hide_radio()
729 document
.getElementById('tr_radio1').style
.display
="none";
730 document
.getElementById('tr_radio2').style
.display
="";
732 function make_visible_row()
734 document
.getElementById('table_display').style
.display
="";
735 document
.getElementById('table_display_prepayment').style
.display
="none";
737 function make_hide_row()
739 document
.getElementById('table_display').style
.display
="none";
740 document
.getElementById('table_display_prepayment').style
.display
="";
746 make_it_hide_enc_pay();
747 document
.getElementById('radio_type_of_payment_self1').checked
=true;
750 function make_insurance()
755 document
.getElementById('radio_type_of_payment1').checked
=true;
757 //--------------------------------------------------------------------------------------------------//
758 $
('#paySubmit').click( function(e
) {
760 $
("#mode").val( "portal-save" );
761 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
762 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
763 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
766 var liburl
= './lib/paylib.php';
770 data
: $
("#payfrm").serialize()+extra
,
771 beforeSend
: function(xhr
){
772 if( validateCC() !== true) return false;
773 if( $
('#pin').val() == "" || $
('#ccname').val() == "" || $
('#ccyear').val() == "" || $
('#ccmonth').val() == ""){
774 alert("<?php echo addslashes( xl('Invalid Credit Card Values: Please correct')) ?>")
777 if( validate() != true){
779 alert("<?php echo addslashes( xl('Validation error: Fix and resubmit. This popup info is preserved!')) ?>")
782 $
("#openPayModal .close").click()
784 error
: function(qXHR
, textStatus
, errorThrow
){
785 console
.log("There was an error:"+errorThrow
);
787 success
: function(templateHtml
, textStatus
, jqXHR
){
788 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')) ?>")
789 window
.location
.reload(false);
793 $
("#openPayModal .close").click();
795 //---------------------------------------------------------------------------------------//
796 $
("#payfrm").on('submit', function(e
){
799 $
("#mode").val( "review-save" );
800 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
801 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
802 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
805 var liburl
='<?php echo $GLOBALS["webroot"] ?>/portal/lib/paylib.php';
809 data
: $
("#payfrm").serialize()+extra
,
810 beforeSend
: function(xhr
){
811 if( validate() != true){
813 alert("<?php echo addslashes( xl('Validation error: Fix and resubmit. Payment values are preserved!')) ?>")
817 error
: function(xhr
, textStatus
, error
){
818 alert("<?php echo addslashes( xl('There is a Post error')) ?>")
819 console
.log("There was an error:"+textStatus
);
822 success
: function(templateHtml
, textStatus
, jqXHR
){
827 function getFormObj(formId
) {
829 var inputs
= $
('#'+formId
).serializeArray();
830 $
.each(inputs
, function (i
, input
) {
831 formObj
[input
.name
] = input
.value
;
835 function formRepopulate(jsondata
){
836 data
= $
.parseJSON(jsondata
);
837 $
.each(data
, function(name
, val
){
838 var $el = $
('[name="'+name+
'"]'),
839 type
= $el.attr('type');
842 $el.prop('checked',true);
845 $el.filter('[value="'+val+
'"]').prop('checked', true);
853 var authnum
= prompt("<?php echo xlt('Please enter card comfirmation authorization') ?>", "");
854 if (authnum
!= null) {
855 $
('#check_number').val(authnum
);
860 <body
class="body_top" onunload
='imclosing()' onLoad
="cursor_pointer();"
861 style
="text-align: center; margin: auto;">
863 <form id
="payfrm" method
='post'
864 action
='<?php echo $GLOBALS["webroot"] ?>/portal/portal_payment.php'>
865 <input type
='hidden' name
='form_pid' value
='<?php echo attr($pid) ?>' />
866 <input type
='hidden' name
='form_save'
867 value
='<?php echo xlt('Invoice
');?>' />
871 <td colspan
="3"> 
;</td
>
875 <td colspan
='3' align
='center' class='text'><b
><?php
echo xlt('Accept Payment for'); ?
> 
;: 
; 
;<?php
877 echo htmlspecialchars( $patdata['fname'], ENT_QUOTES
) . " " . htmlspecialchars( $patdata['lname'], ENT_QUOTES
) . " " . htmlspecialchars( $patdata['mname'], ENT_QUOTES
) . " (" . htmlspecialchars( $patdata['pid'], ENT_QUOTES
) . ")"?
></b
>
878 <?php
$NameNew=$patdata['fname'] . " " .$patdata['lname']. " " .$patdata['mname'];?
>
882 <td colspan
='3'></td
>
886 <?php
echo xlt('Payment Method'); ?
>:
888 <td colspan
='2'><select name
="form_method" id
="form_method"
889 class="text" onChange
='CheckVisible("yes")'>
891 $query1112 = "SELECT * FROM list_options where list_id=? ORDER BY seq, title ";
892 $bres1112 = sqlStatement( $query1112, array ('payment_method') );
893 while( $brow1112 = sqlFetchArray( $bres1112 ) ){
894 if( $brow1112['option_id'] != 'credit_card' ||
$brow1112['option_id'] == 'electronic' ||
$brow1112['option_id'] == 'bank_draft' ) continue;
895 echo "<option value='" . htmlspecialchars( $brow1112['option_id'], ENT_QUOTES
) . "'>" . htmlspecialchars( xl_list_label( $brow1112['title'] ), ENT_QUOTES
) . "</option>";
902 <td colspan
='3'></td
>
907 <?php
echo xla('Authorized'); ?
>:
911 if( isset( $_SESSION['authUserID'] ) )
912 echo "<input type='text' id='check_number' name='form_source' style='width:120px;' value='" . htmlspecialchars( $payrow['source'], ENT_QUOTES
) . "'>";
917 <td colspan
='3'></td
>
920 <td
class='text' valign
="middle">
921 <?php
echo xlt('Patient Coverage'); ?
>:
923 <td
class='text' colspan
="2">
924 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverage1"
925 value
="self" onClick
="make_visible_radio();make_self();" />
926 <?php
echo xlt('Self'); ?
>
927 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverag2" value
="insurance" checked
="checked"
928 onClick
="make_hide_radio();make_insurance();" />
929 <?php
echo xlt('Insurance'); ?
>
933 <td colspan
='3'></td
>
935 <tr id
="tr_radio1" style
="display: none">
936 <!-- For radio Insurance
-->
937 <td
class='text' valign
="top">
938 <?php
echo xlt('Payment against'); ?
>:
940 <td
class='text' colspan
="2">
941 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment_self1"
942 value
="cash" onClick
="make_visible_row();make_it_hide_enc_pay();cursor_pointer();" />
943 <?php
echo xlt('Encounter Payment'); ?
>
947 <!-- For radio self
-->
948 <td
class='text' valign
="top"><?php
echo xlt('Payment against'); ?
>:
950 <td
class='text' colspan
="2"><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment1" checked
="checked"
951 value
="copay" onClick
="make_visible_row();cursor_pointer();" /><?php
echo xlt('Co Pay'); ?
>
952 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment2"
953 value
="invoice_balance" onClick
="make_visible_row();" /><?php
echo xlt('Invoice Balance'); ?
><br
/>
954 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment4" value
="pre_payment"
955 onClick
="make_hide_row();" /><?php
echo xlt('Pre Pay'); ?
></td
>
958 <td colspan
='3'></td
>
961 <table width
="35%" border
="0" cellspacing
="0" cellpadding
="0" id
="table_display_prepayment" style
="display: none">
963 <td
class='detail'><?php
echo xlt('Pre Payment'); ?
></td
>
964 <td
><input
class="form-control" type
='text' name
='form_prepayment' style
='width: 100px' /></td
>
967 <table id
="table_display" style
="width: 100%; background: #eee;" class="table table-striped table-responsive">
971 <!-- <table border
='0' id
="table_display" cellpadding
='0' cellspacing
='0' width
='100%'> -->
972 <tr bgcolor
="#cccccc" id
="tr_head">
973 <td
class="dehead" width
="60">
974 <?php
echo xlt('DOS')?
>
976 <td
class="dehead" width
="120">
977 <?php
echo xlt('Visit Reason')?
>
979 <td
class="dehead" align
="center" width
="70" id
="td_head_total_charge">
980 <?php
echo xlt('Total Charge')?
>
982 <td
class="dehead" align
="center" width
="70" id
="td_head_rep_doc" style
='display: none'>
983 <?php
echo xlt('Report/ Form')?
>
985 <td
class="dehead" align
="center" width
="200" id
="td_head_description" style
='display: none'>
986 <?php
echo xlt('Description')?
>
988 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_payment">
989 <?php
echo xlt('Insurance Payment')?
>
991 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_payment">
992 <?php
echo xlt('Patient Payment')?
>
994 <td
class="dehead" align
="center" width
="55" id
="td_head_patient_co_pay">
995 <?php
echo xlt('Co Pay Paid')?
>
997 <td
class="dehead" align
="center" width
="55" id
="td_head_co_pay">
998 <?php
echo xlt('Required Co Pay')?
>
1000 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_balance">
1001 <?php
echo xlt('Insurance Balance')?
>
1003 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_balance">
1004 <?php
echo xlt('Patient Balance')?
>
1006 <td
class="dehead" align
="center" width
="50">
1007 <?php
echo xlt('Paying')?
>
1012 // Get the unbilled service charges and payments by encounter for this patient.
1014 $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
1015 "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";
1016 $bres = sqlStatement( $query, array ($pid,$pid) );
1018 while( $brow = sqlFetchArray( $bres ) ){
1019 $key = 0 +
$brow['encounter'];
1020 if( empty( $encs[$key] ) ){
1021 $encs[$key] = array ('encounter' => $brow['encounter'],'date' => $brow['encdate'],'last_level_closed' => $brow['last_level_closed'],'charges' => 0,'payments' => 0,'reason'=>$brow['reason']
1024 if( $brow['code_type'] === 'COPAY' ){
1025 // $encs[$key]['payments'] -= $brow['fee'];
1027 $encs[$key]['charges'] +
= $brow['fee'];
1029 $sql_array = array ();
1030 $query = "SELECT taxrates FROM codes WHERE " . "code_type = ? AND " . "code = ? AND ";
1031 array_push( $sql_array, $code_types[$brow['code_type']]['id'], $brow['code'] );
1032 if( $brow['modifier'] ){
1033 $query .= "modifier = ?";
1034 array_push( $sql_array, $brow['modifier'] );
1036 $query .= "(modifier IS NULL OR modifier = '')";
1038 $query .= " LIMIT 1";
1039 $trow = sqlQuery( $query, $sql_array );
1040 $encs[$key]['charges'] +
= calcTaxes( $trow, $brow['fee'] );
1043 // Do the same for unbilled product sales.
1045 $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
1046 "AND fe.pid = s.pid AND fe.encounter = s.encounter " . "where fe.pid = ? " . "ORDER BY s.encounter";
1048 $dres = sqlStatement( $query, array ($pid,$pid) );
1050 while( $drow = sqlFetchArray( $dres ) ){
1051 $key = 0 +
$drow['encounter'];
1052 if( empty( $encs[$key] ) ){
1053 $encs[$key] = array ('encounter' => $drow['encounter'],'date' => $drow['encdate'],'last_level_closed' => $drow['last_level_closed'],'charges' => 0,'payments' => 0
1056 $encs[$key]['charges'] +
= $drow['fee'];
1058 $trow = sqlQuery( "SELECT taxrates FROM drug_templates WHERE drug_id = ? " . "ORDER BY selector LIMIT 1", array ($drow['drug_id']
1060 $encs[$key]['charges'] +
= calcTaxes( $trow, $drow['fee'] );
1063 ksort( $encs, SORT_NUMERIC
);
1065 // Bringing on top the Today always
1066 foreach( $encs as $key => $value ){
1067 $dispdate = $value['date'];
1068 if( strcmp( $dispdate, $today ) == 0 && ! $gottoday ){
1074 // If no billing was entered yet for today, then generate a line for
1075 // entering today's co-pay.
1078 // echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0 /*$duept*/);//No encounter yet defined.
1081 foreach( $encs as $key => $value ){
1082 $enc = $value['encounter'];
1083 $reason = $value['reason'];
1084 $dispdate = $value['date'];
1085 if( strcmp( $dispdate, $today ) == 0 && ! $gottoday ){
1086 $dispdate = date( "Y-m-d" );
1089 // ------------------------------------------------------------------------------------
1090 $inscopay = getCopay( $pid, $dispdate );
1091 $patcopay = getPatientCopay( $pid, $enc );
1092 // Insurance Payment
1093 // -----------------
1094 $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
1096 $dpayment = $drow['payments'];
1097 $dadjustment = $drow['adjustments'];
1100 $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
1102 $dpayment_pat = $drow['payments'];
1104 // ------------------------------------------------------------------------------------
1105 // NumberOfInsurance
1106 $ResultNumberOfInsurance = sqlStatement( "SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
1107 where pid = ? and provider>0 ", array ($pid
1109 $RowNumberOfInsurance = sqlFetchArray( $ResultNumberOfInsurance );
1110 $NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1;
1111 // ------------------------------------------------------------------------------------
1113 if( ( ( $NumberOfInsurance == 0 ||
$value['last_level_closed'] == 4 ||
$NumberOfInsurance == $value['last_level_closed'] ) ) ){ // Patient balance
1114 $brow = sqlQuery( "SELECT SUM(fee) AS amount FROM billing WHERE " . "pid = ? and encounter = ? AND activity = 1", array ($pid,$enc
1116 $srow = sqlQuery( "SELECT SUM(fee) AS amount FROM drug_sales WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1118 $drow = sqlQuery( "SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1120 $duept = $brow['amount'] +
$srow['amount'] - $drow['payments'] - $drow['adjustments'];
1122 echoLine( "form_upay[$enc]", $dispdate, $value['charges'], $dpayment_pat, ( $dpayment +
$dadjustment ), $duept, ($enc.':'.$reason), $inscopay, $patcopay );
1125 // Continue with display of the data entry form.
1128 <td
class="dehead" id
='td_total_1'></td
>
1129 <td
class="dehead" id
='td_total_2'></td
>
1130 <td
class="dehead" id
='td_total_3'></td
>
1131 <td
class="dehead" id
='td_total_4'></td
>
1132 <td
class="dehead" id
='td_total_5'></td
>
1133 <td
class="dehead" id
='td_total_6'></td
>
1134 <td
class="dehead" id
='td_total_7'></td
>
1135 <td
class="dehead" id
='td_total_8'></td
>
1136 <td
class="dehead" align
="right"><?php
echo xlt('Total');?
></td
>
1137 <td
class="dehead" align
="right"><input
class="form-control" type
='text' name
='form_paytotal'
1138 value
='' style
='color: #00aa00; width: 65px; padding: 1px 1px;' readonly
/>
1143 if( isset( $ccdata["name"] ) ){
1144 echo '<div class="col-xs-12 col-md-4 col-lg-4">
1145 <div class="panel panel-default height">';
1146 if( ! isset( $_SESSION['authUserID'] ) )
1147 echo '<div class="panel-heading">'.xlt("Payment Information").'<span style="color:#cc0000"><em> '.xlt("Pending Auth since").': </em>'.text($edata["date"]).'</span></div>';
1149 echo '<div class="panel-heading">'.xlt("Payment Information").' <button type="button" class="btn btn-danger btn-sm" onclick="getAuth()">'.xlt("Authorize").'</button></div>';
1152 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>';
1155 <div
class="panel-body">
1156 <strong
><?php
echo xlt('Card Name');?
>: </strong
><span id
="cn"><?php
echo attr($ccdata["cc_type"])?
></span
><br
>
1157 <strong
><?php
echo xlt('Name On Card');?
>: </strong
><span id
="nc"><?php
echo attr($ccdata["name"])?
></span
><br
>
1158 <strong
><?php
echo xlt('Card Number');?
>: </strong
><span id
="ccn"><?php
1159 if( isset( $_SESSION['authUserID'] ) )
1160 echo $ccdata["cc_number"] . "</span><br>";
1162 echo "********** ".substr($ccdata["cc_number"],-4) . "</span><br>";
1164 <strong
><?php
echo xlt('Exp Date');?
>: </strong
><span id
="ed"><?php
echo attr($ccdata["month"])."/".attr($ccdata["year"])?
></span
><br
>
1165 <strong
><?php
echo xlt('Charge Total');?
>: </strong
><span id
="ct"><?php
echo attr($invdata["form_paytotal"])?
></span
><br
>
1171 if( ! isset( $_SESSION['authUserID'] ) )
1172 echo '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#openPayModal">' . xlt("Pay Invoice") . '</button>';
1174 echo "<button type='submit' class='btn btn-danger' form='payfrm'>" . xlt('Post Payment') . "</button>";
1178 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo attr($pid);?>" />
1179 <input type
='hidden' name
='mode' id
='mode' value
='' />
1182 <script type
="text/javascript">
1183 if (typeof jsondata
!== 'undefined') {
1184 formRepopulate(jsondata
);
1188 <!-- credit payment modal
-->
1189 <div id
="openPayModal" class="modal fade" role
="dialog">
1190 <div
class="modal-dialog">
1191 <div
class="modal-content">
1192 <div
class="modal-header">
1193 <h3
><?php
echo xlt('Submit Payment for Authorization');?
></h3
>
1194 <button type
="button" class="close" data
-dismiss
="modal">×
;</button
>
1196 <div
class="modal-body container">
1197 <form id
='paycredit' class="form-horizontal col-xs-12 col-sm-6 col-md-6">
1199 <div
class="control-group">
1200 <label label
-default="label-default" class="control-label"><?php
echo xlt('Name on Card');?
></label
>
1201 <div
class="controls">
1202 <input name
="name" id
="ccname" type
="text" class="form-control"
1203 pattern
="\w+ \w+.*" title
="<?php echo xla('Fill your first and last name'); ?>"
1204 required value
="" />
1207 <div
class="control-group">
1208 <label
class="control-label"><?php
echo xlt('Card Number');?
></label
>
1209 <div
class="controls">
1211 <div
class="col-sm-12">
1212 <input name
="cc_number" id
="cc_number" type
="text" class="form-control inline col-sm-3"
1213 autocomplete
="off" maxlength
="19" pattern
="\d" onchange
="validateCC()"
1214 title
="<?php echo xla('Card Number'); ?>" required value
="" />
1215 <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
="" />
1220 <div
class="control-group">
1221 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card Expiry Date');?
></label
>
1222 <div
class="controls">
1224 <div
class="col-md-4">
1225 <select name
="month" id
="ccmonth" class="form-control">
1226 <option value
=""><?php
echo xlt('Select Month'); ?
></option
>
1227 <option value
="01"><?php
echo xlt('January'); ?
></option
>
1228 <option value
="02"><?php
echo xlt('February'); ?
></option
>
1229 <option value
="03"><?php
echo xlt('March'); ?
></option
>
1230 <option value
="04"><?php
echo xlt('April'); ?
></option
>
1231 <option value
="05"><?php
echo xlt('May'); ?
></option
>
1232 <option value
="06"><?php
echo xlt('June'); ?
></option
>
1233 <option value
="07"><?php
echo xlt('July'); ?
></option
>
1234 <option value
="08"><?php
echo xlt('August'); ?
></option
>
1235 <option value
="09"><?php
echo xlt('September'); ?
></option
>
1236 <option value
="10"><?php
echo xlt('October'); ?
></option
>
1237 <option value
="11"><?php
echo xlt('November'); ?
></option
>
1238 <option value
="12"><?php
echo xlt('December'); ?
></option
>
1241 <div
class="col-md-3">
1242 <select name
="year" id
="ccyear" class="form-control">
1243 <option value
=""><?php
echo xlt('Select Year'); ?
></option
>
1244 <option value
="2017">2017</option
>
1245 <option value
="2018">2018</option
>
1246 <option value
="2019">2019</option
>
1247 <option value
="2020">2020</option
>
1248 <option value
="2021">2021</option
>
1249 <option value
="2022">2022</option
>
1250 <option value
="2023">2023</option
>
1251 <option value
="2024">2024</option
>
1257 <div
class="control-group">
1258 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card CVV');?
></label
>
1259 <div
class="controls">
1261 <div
class="col-md-3">
1262 <input name
="pin" id
="pin" type
="text" class="form-control"
1263 autocomplete
="off" maxlength
="4" pattern
="\d{3}" onfocus
="validateCC()"
1264 title
="<?php echo xlt('Three or four digits at back of your card'); ?>" required value
="" />
1266 <div
class="col-md-3">
1267 <img src
='./images/img_cvc.png' style
='height: 58px; width: auto'>
1272 <div
class="form-actions">
1273 <button id
="paySubmit" class="btn btn-danger"><?php
echo xlt('Submit');?
></button
>
1274 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Cancel');?
></button
>
1277 <input type
='hidden' name
='cc_type' id
='cc_type' value
='' />
1281 <div
class="modal-footer">
1282 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Close');?
></button
>
1287 <?php
echo "<script>var ccerr='". xlt('Invalid Credit Card Number') . "';</script>";?
>
1288 <script type
="text/javascript">
1289 $
('#cc_number').validateCreditCard(function(result
){
1290 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1291 var v
= (result
.valid
== true ?
' Valid #' : ' Invalid #')
1292 $
('#cardtype').val(r+v
);
1294 function validateCC() {
1295 var result
= $
('#cc_number').validateCreditCard();
1296 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1297 var v
= (result
.valid
== true ?
' Okay' : ' Invalid #')
1298 $
('#cardtype').val(r+v
);
1299 $
('#cc_type').val(r
);