4 * namespace OnsitePortal
6 * Copyright (C) 2006-2015 Rod Roark <rod@sunsetsystems.com>
7 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Rod Roark <rod@sunsetsystems.com>
22 * @author Jerry Padgett <sjpadgett@gmail.com>
23 * @link http://www.open-emr.org
28 if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
29 $pid = $_SESSION['pid'];
31 require_once(dirname(__FILE__
) . "/../interface/globals.php");
35 require_once(dirname(__FILE__
) . "/../interface/globals.php");
36 if (! isset($_SESSION['authUserID'])) {
37 $landingpage = "index.php";
38 header('Location: ' . $landingpage);
43 require_once(dirname(__FILE__
) . "/lib/appsql.class.php");
44 require_once("$srcdir/acl.inc");
45 require_once("$srcdir/patient.inc");
46 require_once("$srcdir/billing.inc");
47 require_once("$srcdir/payment.inc.php");
48 require_once("$srcdir/forms.inc");
49 require_once("$srcdir/sl_eob.inc.php");
50 require_once("$srcdir/invoice_summary.inc.php");
51 require_once("../custom/code_types.inc.php");
52 require_once("$srcdir/formatting.inc.php");
53 require_once("$srcdir/options.inc.php");
54 require_once("$srcdir/encounter_events.inc.php");
55 require_once("$srcdir/log.inc");
56 require_once("$srcdir/crypto.php");
58 $appsql = new ApplicationTable();
60 $pid = $_REQUEST['hidden_patient_code'] > 0 ?
$_REQUEST['hidden_patient_code'] : $pid;
62 $edata = $appsql->getPortalAudit($pid, 'review', 'payment');
67 $ccdata = json_decode(aes256Decrypt($edata['checksum']), true);
68 $invdata = json_decode($edata['table_args'], true);
69 echo "<script type='text/javascript'>var jsondata='" . $edata['table_args'] . "';var ccdata='" . $edata['checksum'] . "'</script>";
72 function bucks($amount)
75 $amount = oeFormatMoney($amount);
81 function rawbucks($amount)
84 $amount = sprintf("%.2f", $amount);
91 // Display a row of data for an encounter.
94 function echoLine($iname, $date, $charges, $ptpaid, $inspaid, $duept, $encounter = 0, $copay = 0, $patcopay = 0)
98 $balance = bucks($charges - $ptpaid - $inspaid);
99 $balance = ( round($duept, 2) != 0 ) ?
0 : $balance; // if balance is due from patient, then insurance balance is displayed as zero
100 $encounter = $encounter ?
$encounter : '';
101 echo " <tr id='tr_" . attr($var_index) . "' >\n";
102 echo " <td class='detail'>" . text(oeFormatShortDate($date)) . "</td>\n";
103 echo " <td class='detail' id='" . attr($date) . "' align='left'>" . htmlspecialchars($encounter, ENT_QUOTES
) . "</td>\n";
104 echo " <td class='detail' align='center' id='td_charges_$var_index' >" . htmlspecialchars(bucks($charges), ENT_QUOTES
) . "</td>\n";
105 echo " <td class='detail' align='center' id='td_inspaid_$var_index' >" . htmlspecialchars(bucks($inspaid * - 1), ENT_QUOTES
) . "</td>\n";
106 echo " <td class='detail' align='center' id='td_ptpaid_$var_index' >" . htmlspecialchars(bucks($ptpaid * - 1), ENT_QUOTES
) . "</td>\n";
107 echo " <td class='detail' align='center' id='td_patient_copay_$var_index' >" . htmlspecialchars(bucks($patcopay), ENT_QUOTES
) . "</td>\n";
108 echo " <td class='detail' align='center' id='td_copay_$var_index' >" . htmlspecialchars(bucks($copay), ENT_QUOTES
) . "</td>\n";
109 echo " <td class='detail' align='center' id='balance_$var_index'>" . htmlspecialchars(bucks($balance), ENT_QUOTES
) . "</td>\n";
110 echo " <td class='detail' align='center' id='duept_$var_index'>" . htmlspecialchars(bucks(round($duept, 2) * 1), ENT_QUOTES
) . "</td>\n";
111 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";
115 // We use this to put dashes, colons, etc. back into a timestamp.
117 function decorateString($fmt, $str)
121 $fc = substr($fmt, 0, 1);
122 $fmt = substr($fmt, 1);
124 $res .= substr($str, 0, 1);
125 $str = substr($str, 1);
134 // Compute taxes from a tax rate string and a possibly taxable amount.
136 function calcTaxes($row, $amount)
139 if (empty($row['taxrates'])) {
143 $arates = explode(':', $row['taxrates']);
144 if (empty($arates)) {
148 foreach ($arates as $value) {
153 $trow = sqlQuery("SELECT option_value FROM list_options WHERE " . "list_id = 'taxrate' AND option_id = ? LIMIT 1", array ($value
155 if (empty($trow['option_value'])) {
156 echo "<!-- Missing tax rate '" . text($value) . "'! -->\n";
160 $tax = sprintf("%01.2f", $amount * $trow['option_value']);
161 // echo "<!-- Rate = '$value', amount = '$amount', tax = '$tax' -->\n";
169 $today = date('Y-m-d', $now);
170 $timestamp = date('Y-m-d H:i:s', $now);
173 // $patdata = getPatientData($pid, 'fname,lname,pubpid');
175 $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
178 $alertmsg = ''; // anything here pops up in an alert box
180 // If the Save button was clicked...
181 if ($_POST['form_save']) {
182 // $extra = json_decode($_POST['ajax_mode'], true);
183 $form_pid = $_POST['form_pid'];
184 $form_method = trim($_POST['form_method']);
185 $form_source = trim($_POST['form_source']);
186 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
187 $NameNew = $patdata['fname'] . " " . $patdata['lname'] . " " . $patdata['mname'];
189 if ($_REQUEST['radio_type_of_payment'] == 'pre_payment') {
190 $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 (
191 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$_REQUEST['form_prepayment'],$NameNew,$form_method
194 frontPayment($form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0, $timestamp); // insertion to 'payments' table.
197 if ($_POST['form_upay'] && $_REQUEST['radio_type_of_payment'] != 'pre_payment') {
198 foreach ($_POST['form_upay'] as $enc => $payment) {
199 if ($amount = 0 +
$payment) {
201 if ($_REQUEST['radio_type_of_payment'] == 'invoice_balance') {
205 $enc = calendar_arrived($form_pid);
209 // ----------------------------------------------------------------------------------------------------
210 // Fetching the existing code and modifier
211 $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
213 if ($RowSearch = sqlFetchArray($ResultSearchNew)) {
214 $Codetype = $RowSearch['code_type'];
215 $Code = $RowSearch['code'];
216 $Modifier = $RowSearch['modifier'];
223 // ----------------------------------------------------------------------------------------------------
224 if ($_REQUEST['radio_type_of_payment'] == 'copay') { // copay saving to ar_session and ar_activity tables
225 $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 (
226 $_SESSION['authId'],$form_source,$amount,$form_pid,$form_method
229 $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
232 frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0, $timestamp); // insertion to 'payments' table.
235 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.
236 if ($_REQUEST['radio_type_of_payment'] == 'cash') {
237 sqlStatement("update form_encounter set last_level_closed=? where encounter=? and pid=? ", array (4,$enc,$form_pid
239 sqlStatement("update billing set billed=? where encounter=? and pid=?", array (1,$enc,$form_pid
243 $adjustment_code = 'patient_payment';
244 $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 (
245 0,$form_pid,$_SESSION['authUserID'],0,$form_source,$amount,$NameNew,$adjustment_code,$form_method
248 // --------------------------------------------------------------------------------------------------------------------
250 frontPayment($form_pid, $enc, $form_method, $form_source, 0, $amount, $timestamp); // insertion to 'payments' table.
252 // --------------------------------------------------------------------------------------------------------------------
254 $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
255 )); // new fees screen copay gives account_code='PCP'
256 $rowMoneyGot = sqlFetchArray($resMoneyGot);
257 $Copay = $rowMoneyGot['PatientPay'];
259 // --------------------------------------------------------------------------------------------------------------------
261 // Looping the existing code and modifier
262 $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
264 while ($RowSearch = sqlFetchArray($ResultSearchNew)) {
265 $Codetype = $RowSearch['code_type'];
266 $Code = $RowSearch['code'];
267 $Modifier = $RowSearch['modifier'];
268 $Fee = $RowSearch['fee'];
270 $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
272 // new fees screen copay gives account_code='PCP'
273 $rowMoneyGot = sqlFetchArray($resMoneyGot);
274 $MoneyGot = $rowMoneyGot['MoneyGot'];
276 $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
278 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
279 $MoneyAdjusted = $rowMoneyAdjusted['MoneyAdjusted'];
281 $Remainder = $Fee - $Copay - $MoneyGot - $MoneyAdjusted;
283 if (round($Remainder, 2) != 0 && $amount != 0) {
284 if ($amount - $Remainder >= 0) {
285 $insert_value = $Remainder;
286 $amount = $amount - $Remainder;
288 $insert_value = $amount;
292 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 (
293 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$insert_value,0
297 if ($amount != 0) { // if any excess is there.
298 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 (
299 $form_pid,$enc,$Codetype,$Code,$Modifier,0,3,$payment_id,$amount,0
303 // --------------------------------------------------------------------------------------------------------------------
305 } // if ($amount = 0 + $payment)
307 } // if ($_POST['form_upay'])
308 } // if ($_POST['form_save'])
310 if ($_POST['form_save'] ||
$_REQUEST['receipt']) {
311 if ($_REQUEST['receipt']) {
312 $form_pid = $_GET['patient'];
313 $timestamp = decorateString('....-..-.. ..:..:..', $_GET['time']);
316 // Get details for what we guess is the primary facility.
317 $frow = sqlQuery("SELECT * FROM facility " . "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1");
319 // Get the patient's name and chart number.
320 $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
322 // Re-fetch payment info.
323 $payrow = sqlQuery("SELECT " . "SUM(amount1) AS amount1, " . "SUM(amount2) AS amount2, " . "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " .
324 // "MAX(user) AS user " .
325 "MAX(user) AS user, " . "MAX(encounter) as encounter " . "FROM payments WHERE " . "pid = ? AND dtime = ?", array ($form_pid,$timestamp
328 // Create key for deleting, just in case.
329 $ref_id = ( $_REQUEST['radio_type_of_payment'] == 'copay' ) ?
$session_id : $payment_id;
330 $payment_key = $form_pid . '.' . preg_replace('/[^0-9]/', '', $timestamp) . '.' . $ref_id;
332 // get facility from encounter
336 WHERE encounter = ?", array ($payrow['encounter']
338 $frow = sqlQuery("SELECT * FROM facility " . " WHERE id = ?", array ($tmprow['facility_id']
341 // Now proceed with printing the receipt.
344 <title
><?php
echo xlt('Receipt for Payment'); ?
></title
>
346 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-11-3/index.js"></script
>
347 <script type
="text/javascript">
348 $
( document
).ready();
350 window
.location
.replace("./patient/onsiteactivityviews");
352 function notifyPatient(){
353 var pid
= <?php
echo attr($pid);?
>;
354 var note
= $
('#pop_receipt').text();
355 var formURL
= './messaging/handle_note.php';
359 data
: {'task':'add', 'pid':pid
, 'inputBody':note
, 'title':'Bill/Collect', 'sendto':'-patient-','noteid':'0'},
360 success
: function(data
, textStatus
, jqXHR
) {
361 alert('Receipt sent to patient via Messages.')
363 error
: function(jqXHR
, status
, error
) {
364 console
.log(status +
": " + error
);
371 echo '<htlm><head></head><body style="text-align: center; margin: auto;">';
374 <div id
='pop_receipt' style
='display: block'>
376 <h2
><?php
echo xlt('Receipt for Payment'); ?
></h2
>
377 <p
><?php
echo text($frow['name'])?
>
378 <br
><?php
echo text($frow['street'])?
>
379 <br
><?php
echo text($frow['city'] . ', ' . $frow['state']) . ' ' . text($frow['postal_code'])?
>
380 <br
><?php
echo htmlentities($frow['phone'])?
>
382 <div style
="text-align: center; margin: auto;">
383 <table border
='0' cellspacing
='8'
384 style
="text-align: center; margin: auto;">
386 <td
><?php
echo xlt('Date'); ?
>:</td
>
387 <td
><?php
echo text(oeFormatSDFT(strtotime($payrow['dtime']))) ?
></td
>
390 <td
><?php
echo xlt('Patient'); ?
>:</td
>
391 <td
><?php
echo text($patdata['fname']) . " " . text($patdata['mname']) . " " . text($patdata['lname']) . " (" . text($patdata['pubpid']) . ")"?
></td
>
394 <td
><?php
echo xlt('Paid Via'); ?
>:</td
>
395 <td
><?php
echo generate_display_field(array('data_type'=>'1','list_id'=>'payment_method'), $payrow['method']); ?
></td
>
398 <td
><?php
echo xlt('Authorized Id'); ?
>:</td
>
399 <td
><?php
echo text($payrow['source']) ?
></td
>
402 <td
><?php
echo xlt('Amount for This Visit'); ?
>:</td
>
403 <td
><?php
echo text(oeFormatMoney($payrow['amount1'])) ?
></td
>
406 <td
><?php
echo xlt('Amount for Past Balance'); ?
>:</td
>
407 <td
><?php
echo text(oeFormatMoney($payrow['amount2'])) ?
></td
>
410 <td
><?php
echo xlt('Received By'); ?
>:</td
>
411 <td
><?php
echo text($payrow['user']) ?
></td
>
416 <button
class='btn btn-sm' type
='button' onclick
='goHome()' id
='returnhome'><?php
echo xla('Return Home'); ?
></button
>
417 <button
class='btn btn-sm' type
='button' onclick
="notifyPatient()"><?php
echo xla('Notify Patient'); ?
></button
>
423 // Here we display the form for data entry.
426 <title
><?php
echo xlt('Record Payment'); ?
></title
>
427 <style type
="text/css">
429 /* font-family:sans-serif; font-size:10pt; font-weight:normal */
433 color
: #000000; /*font-family:sans-serif; font-size:10pt;*/
440 color
: #000000; /*font-family:sans-serif; font-size:10pt; */
444 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-creditcardvalidator-1-1-0/jquery.creditCardValidator.js"></script
>
445 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
447 <script type
="text/javascript">
449 function calctotal() {
451 var f
= document
.forms
["payfrm"];
453 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
454 var elem
= f
.elements
[i
];
455 var ename
= elem
.name
;
456 if (ename
.indexOf('form_upay[') == 0 || ename
.indexOf('form_bpay[') == 0) {
457 if (elem
.value
.length
> 0){
458 total +
= Number(elem
.value
);
459 if(total
< 0) flag
=1;
463 f
.form_paytotal
.value
= Number(total
).toFixed(2);
465 $
('#payfrm')[0].reset();
466 alert("<?php echo addslashes(xl('Negative payments not accepted')) ?>")
472 for (var i
= 1; ; ++i
)
474 if(document
.getElementById('paying_'+i
))
476 paying
=document
.getElementById('paying_'+i
).value
*1;
477 patient_balance
=document
.getElementById('duept_'+i
).innerHTML
*1;
478 //balance=document.getElementById('balance_'+i).innerHTML*1;
479 if(patient_balance
>0 && paying
>0)
481 if(paying
>patient_balance
)
483 document
.getElementById('paying_'+i
).style
.background
='#FF0000';
485 else if(paying
<patient_balance
)
487 document
.getElementById('paying_'+i
).style
.background
='#99CC00';
489 else if(paying
==patient_balance
)
491 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
496 document
.getElementById('paying_'+i
).style
.background
='#ffffff';
505 function CheckVisible(MakeBlank
)
506 {//Displays and hides the check number text box.
507 if(document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='check_payment' ||
508 document
.getElementById('form_method').options
[document
.getElementById('form_method').selectedIndex
].value
=='bank_draft' )
510 document
.getElementById('check_number').disabled
=false;
514 document
.getElementById('check_number').disabled
=true;
519 var f
= document
.forms
["payfrm"];
521 //no checks taken here....
523 /*if(((document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='check_payment' ||
524 document.getElementById('form_method').options[document.getElementById('form_method').selectedIndex].value=='bank_draft') &&
525 document.getElementById('check_number').value=='' ))
527 alert("<?php //echo addslashes( xl('Please Fill the Check/Ref Number')) ?>");
528 document.getElementById('check_number').focus();
532 if(document
.getElementById('radio_type_of_payment_self1').checked
==false &&
533 document
.getElementById('radio_type_of_payment1').checked
==false
534 && document
.getElementById('radio_type_of_payment2').checked
==false
535 && document
.getElementById('radio_type_of_payment4').checked
==false)
537 alert("<?php //echo addslashes( xl('Please Select Type Of Payment.')) ?>");
540 if(document
.getElementById('radio_type_of_payment_self1').checked
==true || document
.getElementById('radio_type_of_payment1').checked
==true)
542 for (var i
= 0; i
< f
.elements
.length
; ++i
)
544 var elem
= f
.elements
[i
];
545 var ename
= elem
.name
;
546 if (ename
.indexOf('form_upay[0') == 0) //Today is this text box.
549 {//A warning message, if the amount is posted with out encounter.
550 if(confirm("<?php echo addslashes(xl('Are you sure to post for today?')) ?>"))
565 /* if(document.getElementById('radio_type_of_payment1').checked==true)
568 for (var i = 0; i < f.elements.length; ++i)
570 var elem = f.elements[i];
571 var ename = elem.name;
572 if (ename.indexOf('form_upay[') == 0) //Today is this text box.
574 if(f.form_paytotal.value*1!=elem.value*1)//Total CO-PAY is not posted against today
575 {//A warning message, if the amount is posted against an old encounter.
576 if(confirm("<?php //echo addslashes( xl('You are posting against an old encounter?')) ?>"))
590 else if( document
.getElementsByName('form_paytotal')[0].value
<= 0 )//total 0
592 alert("<?php echo addslashes(xl('Invalid Total!')) ?>")
598 if(confirm("<?php echo addslashes(xl('Payment Validated: Save?')) ?>"))
608 function cursor_pointer()
609 {//Point the cursor to the latest encounter(Today)
610 var f
= document
.forms
["payfrm"];
612 for (var i
= 0; i
< f
.elements
.length
; ++i
)
614 var elem
= f
.elements
[i
];
615 var ename
= elem
.name
;
616 if (ename
.indexOf('form_upay[') == 0)
623 //=====================================================
624 function make_it_hide_enc_pay()
626 document
.getElementById('td_head_insurance_payment').style
.display
="none";
627 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
628 document
.getElementById('td_head_co_pay').style
.display
="none";
629 document
.getElementById('td_head_insurance_balance').style
.display
="none";
630 for (var i
= 1; ; ++i
)
632 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
633 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
634 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
635 var balance_elem
= document
.getElementById('balance_'+i
)
638 td_inspaid_elem
.style
.display
="none";
639 td_patient_copay_elem
.style
.display
="none";
640 td_copay_elem
.style
.display
="none";
641 balance_elem
.style
.display
="none";
648 document
.getElementById('td_total_4').style
.display
="none";
649 document
.getElementById('td_total_7').style
.display
="none";
650 document
.getElementById('td_total_8').style
.display
="none";
651 document
.getElementById('td_total_6').style
.display
="none";
653 document
.getElementById('table_display').width
="420px";
656 //=====================================================
657 function make_visible()
659 document
.getElementById('td_head_rep_doc').style
.display
="";
660 document
.getElementById('td_head_description').style
.display
="";
661 document
.getElementById('td_head_total_charge').style
.display
="none";
662 document
.getElementById('td_head_insurance_payment').style
.display
="none";
663 document
.getElementById('td_head_patient_payment').style
.display
="none";
664 document
.getElementById('td_head_patient_co_pay').style
.display
="none";
665 document
.getElementById('td_head_co_pay').style
.display
="none";
666 document
.getElementById('td_head_insurance_balance').style
.display
="none";
667 document
.getElementById('td_head_patient_balance').style
.display
="none";
668 for (var i
= 1; ; ++i
)
670 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
671 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
672 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
673 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
674 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
675 var balance_elem
= document
.getElementById('balance_'+i
)
676 var duept_elem
= document
.getElementById('duept_'+i
)
679 td_charges_elem
.style
.display
="none";
680 td_inspaid_elem
.style
.display
="none";
681 td_ptpaid_elem
.style
.display
="none";
682 td_patient_copay_elem
.style
.display
="none";
683 td_copay_elem
.style
.display
="none";
684 balance_elem
.style
.display
="none";
685 duept_elem
.style
.display
="none";
692 document
.getElementById('td_total_7').style
.display
="";
693 document
.getElementById('td_total_8').style
.display
="";
694 document
.getElementById('td_total_1').style
.display
="none";
695 document
.getElementById('td_total_2').style
.display
="none";
696 document
.getElementById('td_total_3').style
.display
="none";
697 document
.getElementById('td_total_4').style
.display
="none";
698 document
.getElementById('td_total_5').style
.display
="none";
699 document
.getElementById('td_total_6').style
.display
="none";
701 document
.getElementById('table_display').width
="505px";
703 function make_it_hide()
705 document
.getElementById('td_head_rep_doc').style
.display
="none";
706 document
.getElementById('td_head_description').style
.display
="none";
707 document
.getElementById('td_head_total_charge').style
.display
="";
708 document
.getElementById('td_head_insurance_payment').style
.display
="";
709 document
.getElementById('td_head_patient_payment').style
.display
="";
710 document
.getElementById('td_head_patient_co_pay').style
.display
="";
711 document
.getElementById('td_head_co_pay').style
.display
="";
712 document
.getElementById('td_head_insurance_balance').style
.display
="";
713 document
.getElementById('td_head_patient_balance').style
.display
="";
714 for (var i
= 1; ; ++i
)
716 var td_charges_elem
= document
.getElementById('td_charges_'+i
)
717 var td_inspaid_elem
= document
.getElementById('td_inspaid_'+i
)
718 var td_ptpaid_elem
= document
.getElementById('td_ptpaid_'+i
)
719 var td_patient_copay_elem
= document
.getElementById('td_patient_copay_'+i
)
720 var td_copay_elem
= document
.getElementById('td_copay_'+i
)
721 var balance_elem
= document
.getElementById('balance_'+i
)
722 var duept_elem
= document
.getElementById('duept_'+i
)
725 td_charges_elem
.style
.display
="";
726 td_inspaid_elem
.style
.display
="";
727 td_ptpaid_elem
.style
.display
="";
728 td_patient_copay_elem
.style
.display
="";
729 td_copay_elem
.style
.display
="";
730 balance_elem
.style
.display
="";
731 duept_elem
.style
.display
="";
738 document
.getElementById('td_total_1').style
.display
="";
739 document
.getElementById('td_total_2').style
.display
="";
740 document
.getElementById('td_total_3').style
.display
="";
741 document
.getElementById('td_total_4').style
.display
="";
742 document
.getElementById('td_total_5').style
.display
="";
743 document
.getElementById('td_total_6').style
.display
="";
744 document
.getElementById('td_total_7').style
.display
="";
745 document
.getElementById('td_total_8').style
.display
="";
747 document
.getElementById('table_display').width
="100%";
749 function make_visible_radio()
751 document
.getElementById('tr_radio1').style
.display
="";
752 document
.getElementById('tr_radio2').style
.display
="none";
754 function make_hide_radio()
756 document
.getElementById('tr_radio1').style
.display
="none";
757 document
.getElementById('tr_radio2').style
.display
="";
759 function make_visible_row()
761 document
.getElementById('table_display').style
.display
="";
762 document
.getElementById('table_display_prepayment').style
.display
="none";
764 function make_hide_row()
766 document
.getElementById('table_display').style
.display
="none";
767 document
.getElementById('table_display_prepayment').style
.display
="";
773 make_it_hide_enc_pay();
774 document
.getElementById('radio_type_of_payment_self1').checked
=true;
777 function make_insurance()
782 document
.getElementById('radio_type_of_payment1').checked
=true;
784 //--------------------------------------------------------------------------------------------------//
785 $
('#paySubmit').click( function(e
) {
787 $
("#mode").val( "portal-save" );
788 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
789 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
790 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
793 var liburl
= './lib/paylib.php';
797 data
: $
("#payfrm").serialize()+extra
,
798 beforeSend
: function(xhr
){
799 if( validateCC() !== true) return false;
800 if( $
('#pin').val() == "" || $
('#ccname').val() == "" || $
('#ccyear').val() == "" || $
('#ccmonth').val() == ""){
801 alert("<?php echo addslashes(xl('Invalid Credit Card Values: Please correct')) ?>")
804 if( validate() != true){
806 alert("<?php echo addslashes(xl('Validation error: Fix and resubmit. This popup info is preserved!')) ?>")
809 $
("#openPayModal .close").click()
811 error
: function(qXHR
, textStatus
, errorThrow
){
812 console
.log("There was an error:"+errorThrow
);
814 success
: function(templateHtml
, textStatus
, jqXHR
){
815 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')) ?>")
816 window
.location
.reload(false);
820 $
("#openPayModal .close").click();
822 //---------------------------------------------------------------------------------------//
823 $
("#payfrm").on('submit', function(e
){
826 $
("#mode").val( "review-save" );
827 var inv_values
= JSON
.stringify(getFormObj('payfrm'));
828 var extra_values
=JSON
.stringify(getFormObj('paycredit'));
829 var extra
= "&inv_values="+inv_values+
"&extra_values="+extra_values
;
832 var liburl
='<?php echo $GLOBALS["webroot"] ?>/portal/lib/paylib.php';
836 data
: $
("#payfrm").serialize()+extra
,
837 beforeSend
: function(xhr
){
838 if( validate() != true){
840 alert("<?php echo addslashes(xl('Validation error: Fix and resubmit. Payment values are preserved!')) ?>")
844 error
: function(xhr
, textStatus
, error
){
845 alert("<?php echo addslashes(xl('There is a Post error')) ?>")
846 console
.log("There was an error:"+textStatus
);
849 success
: function(templateHtml
, textStatus
, jqXHR
){
854 function getFormObj(formId
) {
856 var inputs
= $
('#'+formId
).serializeArray();
857 $
.each(inputs
, function (i
, input
) {
858 formObj
[input
.name
] = input
.value
;
862 function formRepopulate(jsondata
){
863 data
= $
.parseJSON(jsondata
);
864 $
.each(data
, function(name
, val
){
865 var $el = $
('[name="'+name+
'"]'),
866 type
= $el.attr('type');
869 $el.prop('checked',true);
872 $el.filter('[value="'+val+
'"]').prop('checked', true);
880 var authnum
= prompt("<?php echo xlt('Please enter card comfirmation authorization') ?>", "");
881 if (authnum
!= null) {
882 $
('#check_number').val(authnum
);
887 <body
class="skin-blue" onunload
='imclosing()' onLoad
="cursor_pointer();"
888 style
="text-align: center; margin: auto;">
890 <form id
="payfrm" method
='post'
891 action
='<?php echo $GLOBALS["webroot"] ?>/portal/portal_payment.php'>
892 <input type
='hidden' name
='form_pid' value
='<?php echo attr($pid) ?>' />
893 <input type
='hidden' name
='form_save'
894 value
='<?php echo xlt('Invoice
');?>' />
898 <td colspan
="3"> 
;</td
>
902 <td colspan
='3' align
='center' class='text'><b
><?php
echo xlt('Accept Payment for'); ?
> 
;: 
; 
;<?php
904 echo htmlspecialchars($patdata['fname'], ENT_QUOTES
) . " " . htmlspecialchars($patdata['lname'], ENT_QUOTES
) . " " . htmlspecialchars($patdata['mname'], ENT_QUOTES
) . " (" . htmlspecialchars($patdata['pid'], ENT_QUOTES
) . ")"?
></b
>
905 <?php
$NameNew=$patdata['fname'] . " " .$patdata['lname']. " " .$patdata['mname'];?
>
909 <td colspan
='3'></td
>
913 <?php
echo xlt('Payment Method'); ?
>:
915 <td colspan
='2'><select name
="form_method" id
="form_method"
916 class="text" onChange
='CheckVisible("yes")'>
918 $query1112 = "SELECT * FROM list_options where list_id=? ORDER BY seq, title ";
919 $bres1112 = sqlStatement($query1112, array ('payment_method'));
920 while ($brow1112 = sqlFetchArray($bres1112)) {
921 if ($brow1112['option_id'] != 'credit_card' ||
$brow1112['option_id'] == 'electronic' ||
$brow1112['option_id'] == 'bank_draft') {
925 echo "<option value='" . htmlspecialchars($brow1112['option_id'], ENT_QUOTES
) . "'>" . htmlspecialchars(xl_list_label($brow1112['title']), ENT_QUOTES
) . "</option>";
932 <td colspan
='3'></td
>
937 <?php
echo xla('Authorized'); ?
>:
941 if (isset($_SESSION['authUserID'])) {
942 echo "<input type='text' id='check_number' name='form_source' style='width:120px;' value='" . htmlspecialchars($payrow['source'], ENT_QUOTES
) . "'>";
948 <td colspan
='3'></td
>
951 <td
class='text' valign
="middle">
952 <?php
echo xlt('Patient Coverage'); ?
>:
954 <td
class='text' colspan
="2">
955 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverage1"
956 value
="self" onClick
="make_visible_radio();make_self();" />
957 <?php
echo xlt('Self'); ?
>
958 <input type
="radio" name
="radio_type_of_coverage" id
="radio_type_of_coverag2" value
="insurance" checked
="checked"
959 onClick
="make_hide_radio();make_insurance();" />
960 <?php
echo xlt('Insurance'); ?
>
964 <td colspan
='3'></td
>
966 <tr id
="tr_radio1" style
="display: none">
967 <!-- For radio Insurance
-->
968 <td
class='text' valign
="top">
969 <?php
echo xlt('Payment against'); ?
>:
971 <td
class='text' colspan
="2">
972 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment_self1"
973 value
="cash" onClick
="make_visible_row();make_it_hide_enc_pay();cursor_pointer();" />
974 <?php
echo xlt('Encounter Payment'); ?
>
978 <!-- For radio self
-->
979 <td
class='text' valign
="top"><?php
echo xlt('Payment against'); ?
>:
981 <td
class='text' colspan
="2"><input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment1" checked
="checked"
982 value
="copay" onClick
="make_visible_row();cursor_pointer();" /><?php
echo xlt('Co Pay'); ?
>
983 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment2"
984 value
="invoice_balance" onClick
="make_visible_row();" /><?php
echo xlt('Invoice Balance'); ?
><br
/>
985 <input type
="radio" name
="radio_type_of_payment" id
="radio_type_of_payment4" value
="pre_payment"
986 onClick
="make_hide_row();" /><?php
echo xlt('Pre Pay'); ?
></td
>
989 <td colspan
='3'></td
>
992 <table width
="35%" border
="0" cellspacing
="0" cellpadding
="0" id
="table_display_prepayment" style
="display: none">
994 <td
class='detail'><?php
echo xlt('Pre Payment'); ?
></td
>
995 <td
><input
class="form-control" type
='text' name
='form_prepayment' style
='width: 100px' /></td
>
998 <table id
="table_display" style
="width: 100%; background: #eee;" class="table table-striped table-responsive">
1002 <!-- <table border
='0' id
="table_display" cellpadding
='0' cellspacing
='0' width
='100%'> -->
1003 <tr bgcolor
="#cccccc" id
="tr_head">
1004 <td
class="dehead" width
="60">
1005 <?php
echo xlt('DOS')?
>
1007 <td
class="dehead" width
="120">
1008 <?php
echo xlt('Visit Reason')?
>
1010 <td
class="dehead" align
="center" width
="70" id
="td_head_total_charge">
1011 <?php
echo xlt('Total Charge')?
>
1013 <td
class="dehead" align
="center" width
="70" id
="td_head_rep_doc" style
='display: none'>
1014 <?php
echo xlt('Report/ Form')?
>
1016 <td
class="dehead" align
="center" width
="200" id
="td_head_description" style
='display: none'>
1017 <?php
echo xlt('Description')?
>
1019 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_payment">
1020 <?php
echo xlt('Insurance Payment')?
>
1022 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_payment">
1023 <?php
echo xlt('Patient Payment')?
>
1025 <td
class="dehead" align
="center" width
="55" id
="td_head_patient_co_pay">
1026 <?php
echo xlt('Co Pay Paid')?
>
1028 <td
class="dehead" align
="center" width
="55" id
="td_head_co_pay">
1029 <?php
echo xlt('Required Co Pay')?
>
1031 <td
class="dehead" align
="center" width
="70" id
="td_head_insurance_balance">
1032 <?php
echo xlt('Insurance Balance')?
>
1034 <td
class="dehead" align
="center" width
="70" id
="td_head_patient_balance">
1035 <?php
echo xlt('Patient Balance')?
>
1037 <td
class="dehead" align
="center" width
="50">
1038 <?php
echo xlt('Paying')?
>
1043 // Get the unbilled service charges and payments by encounter for this patient.
1045 $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
1046 "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";
1047 $bres = sqlStatement($query, array ($pid,$pid));
1049 while ($brow = sqlFetchArray($bres)) {
1050 $key = 0 +
$brow['encounter'];
1051 if (empty($encs[$key])) {
1052 $encs[$key] = array ('encounter' => $brow['encounter'],'date' => $brow['encdate'],'last_level_closed' => $brow['last_level_closed'],'charges' => 0,'payments' => 0,'reason'=>$brow['reason']
1056 if ($brow['code_type'] === 'COPAY') {
1057 // $encs[$key]['payments'] -= $brow['fee'];
1059 $encs[$key]['charges'] +
= $brow['fee'];
1061 $sql_array = array ();
1062 $query = "SELECT taxrates FROM codes WHERE " . "code_type = ? AND " . "code = ? AND ";
1063 array_push($sql_array, $code_types[$brow['code_type']]['id'], $brow['code']);
1064 if ($brow['modifier']) {
1065 $query .= "modifier = ?";
1066 array_push($sql_array, $brow['modifier']);
1068 $query .= "(modifier IS NULL OR modifier = '')";
1071 $query .= " LIMIT 1";
1072 $trow = sqlQuery($query, $sql_array);
1073 $encs[$key]['charges'] +
= calcTaxes($trow, $brow['fee']);
1077 // Do the same for unbilled product sales.
1079 $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
1080 "AND fe.pid = s.pid AND fe.encounter = s.encounter " . "where fe.pid = ? " . "ORDER BY s.encounter";
1082 $dres = sqlStatement($query, array ($pid,$pid));
1084 while ($drow = sqlFetchArray($dres)) {
1085 $key = 0 +
$drow['encounter'];
1086 if (empty($encs[$key])) {
1087 $encs[$key] = array ('encounter' => $drow['encounter'],'date' => $drow['encdate'],'last_level_closed' => $drow['last_level_closed'],'charges' => 0,'payments' => 0
1091 $encs[$key]['charges'] +
= $drow['fee'];
1093 $trow = sqlQuery("SELECT taxrates FROM drug_templates WHERE drug_id = ? " . "ORDER BY selector LIMIT 1", array ($drow['drug_id']
1095 $encs[$key]['charges'] +
= calcTaxes($trow, $drow['fee']);
1098 ksort($encs, SORT_NUMERIC
);
1100 // Bringing on top the Today always
1101 foreach ($encs as $key => $value) {
1102 $dispdate = $value['date'];
1103 if (strcmp($dispdate, $today) == 0 && ! $gottoday) {
1109 // If no billing was entered yet for today, then generate a line for
1110 // entering today's co-pay.
1113 // echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0 /*$duept*/);//No encounter yet defined.
1117 foreach ($encs as $key => $value) {
1118 $enc = $value['encounter'];
1119 $reason = $value['reason'];
1120 $dispdate = $value['date'];
1121 if (strcmp($dispdate, $today) == 0 && ! $gottoday) {
1122 $dispdate = date("Y-m-d");
1126 // ------------------------------------------------------------------------------------
1127 $inscopay = getCopay($pid, $dispdate);
1128 $patcopay = getPatientCopay($pid, $enc);
1129 // Insurance Payment
1130 // -----------------
1131 $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
1133 $dpayment = $drow['payments'];
1134 $dadjustment = $drow['adjustments'];
1137 $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
1139 $dpayment_pat = $drow['payments'];
1141 // ------------------------------------------------------------------------------------
1142 // NumberOfInsurance
1143 $ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data
1144 where pid = ? and provider>0 ", array ($pid
1146 $RowNumberOfInsurance = sqlFetchArray($ResultNumberOfInsurance);
1147 $NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1;
1148 // ------------------------------------------------------------------------------------
1150 if (( ( $NumberOfInsurance == 0 ||
$value['last_level_closed'] == 4 ||
$NumberOfInsurance == $value['last_level_closed'] ) )) { // Patient balance
1151 $brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " . "pid = ? and encounter = ? AND activity = 1", array ($pid,$enc
1153 $srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1155 $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? ", array ($pid,$enc
1157 $duept = $brow['amount'] +
$srow['amount'] - $drow['payments'] - $drow['adjustments'];
1160 echoLine("form_upay[$enc]", $dispdate, $value['charges'], $dpayment_pat, ( $dpayment +
$dadjustment ), $duept, ($enc.':'.$reason), $inscopay, $patcopay);
1163 // Continue with display of the data entry form.
1166 <td
class="dehead" id
='td_total_1'></td
>
1167 <td
class="dehead" id
='td_total_2'></td
>
1168 <td
class="dehead" id
='td_total_3'></td
>
1169 <td
class="dehead" id
='td_total_4'></td
>
1170 <td
class="dehead" id
='td_total_5'></td
>
1171 <td
class="dehead" id
='td_total_6'></td
>
1172 <td
class="dehead" id
='td_total_7'></td
>
1173 <td
class="dehead" id
='td_total_8'></td
>
1174 <td
class="dehead" align
="right"><?php
echo xlt('Total');?
></td
>
1175 <td
class="dehead" align
="right"><input
class="form-control" type
='text' name
='form_paytotal'
1176 value
='' style
='color: #00aa00; width: 65px; padding: 1px 1px;' readonly
/>
1181 if (isset($ccdata["name"])) {
1182 echo '<div class="col-xs-12 col-md-4 col-lg-4">
1183 <div class="panel panel-default height">';
1184 if (! isset($_SESSION['authUserID'])) {
1185 echo '<div class="panel-heading">'.xlt("Payment Information").'<span style="color:#cc0000"><em> '.xlt("Pending Auth since").': </em>'.text($edata["date"]).'</span></div>';
1187 echo '<div class="panel-heading">'.xlt("Payment Information").' <button type="button" class="btn btn-danger btn-sm" onclick="getAuth()">'.xlt("Authorize").'</button></div>';
1190 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>';
1193 <div
class="panel-body">
1194 <strong
><?php
echo xlt('Card Name');?
>: </strong
><span id
="cn"><?php
echo attr($ccdata["cc_type"])?
></span
><br
>
1195 <strong
><?php
echo xlt('Name on Card');?
>: </strong
><span id
="nc"><?php
echo attr($ccdata["name"])?
></span
><br
>
1196 <strong
><?php
echo xlt('Card Number');?
>: </strong
><span id
="ccn"><?php
1197 if (isset($_SESSION['authUserID'])) {
1198 echo $ccdata["cc_number"] . "</span><br>";
1200 echo "********** ".substr($ccdata["cc_number"], -4) . "</span><br>";
1203 <strong
><?php
echo xlt('Exp Date');?
>: </strong
><span id
="ed"><?php
echo attr($ccdata["month"])."/".attr($ccdata["year"])?
></span
><br
>
1204 <strong
><?php
echo xlt('Charge Total');?
>: </strong
><span id
="ct"><?php
echo attr($invdata["form_paytotal"])?
></span
><br
>
1210 if (! isset($_SESSION['authUserID'])) {
1211 echo '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#openPayModal">' . xlt("Pay Invoice") . '</button>';
1213 echo "<button type='submit' class='btn btn-danger' form='payfrm'>" . xlt('Post Payment') . "</button>";
1218 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo attr($pid);?>" />
1219 <input type
='hidden' name
='mode' id
='mode' value
='' />
1222 <script type
="text/javascript">
1223 if (typeof jsondata
!== 'undefined') {
1224 formRepopulate(jsondata
);
1228 <!-- credit payment modal
-->
1229 <div id
="openPayModal" class="modal fade" role
="dialog">
1230 <div
class="modal-dialog">
1231 <div
class="modal-content">
1232 <div
class="modal-header">
1233 <h3
><?php
echo xlt('Submit Payment for Authorization');?
></h3
>
1234 <button type
="button" class="close" data
-dismiss
="modal">×
;</button
>
1236 <div
class="modal-body container">
1237 <form id
='paycredit' class="form-horizontal col-xs-12 col-sm-6 col-md-6">
1239 <div
class="control-group">
1240 <label label
-default="label-default" class="control-label"><?php
echo xlt('Name on Card');?
></label
>
1241 <div
class="controls">
1242 <input name
="name" id
="ccname" type
="text" class="form-control"
1243 pattern
="\w+ \w+.*" title
="<?php echo xla('Fill your first and last name'); ?>"
1244 required value
="" />
1247 <div
class="control-group">
1248 <label
class="control-label"><?php
echo xlt('Card Number');?
></label
>
1249 <div
class="controls">
1251 <div
class="col-sm-12">
1252 <input name
="cc_number" id
="cc_number" type
="text" class="form-control inline col-sm-3"
1253 autocomplete
="off" maxlength
="19" pattern
="\d" onchange
="validateCC()"
1254 title
="<?php echo xla('Card Number'); ?>" required value
="" />
1255 <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
="" />
1260 <div
class="control-group">
1261 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card Expiry Date');?
></label
>
1262 <div
class="controls">
1264 <div
class="col-md-4">
1265 <select name
="month" id
="ccmonth" class="form-control">
1266 <option value
=""><?php
echo xlt('Select Month'); ?
></option
>
1267 <option value
="01"><?php
echo xlt('January'); ?
></option
>
1268 <option value
="02"><?php
echo xlt('February'); ?
></option
>
1269 <option value
="03"><?php
echo xlt('March'); ?
></option
>
1270 <option value
="04"><?php
echo xlt('April'); ?
></option
>
1271 <option value
="05"><?php
echo xlt('May'); ?
></option
>
1272 <option value
="06"><?php
echo xlt('June'); ?
></option
>
1273 <option value
="07"><?php
echo xlt('July'); ?
></option
>
1274 <option value
="08"><?php
echo xlt('August'); ?
></option
>
1275 <option value
="09"><?php
echo xlt('September'); ?
></option
>
1276 <option value
="10"><?php
echo xlt('October'); ?
></option
>
1277 <option value
="11"><?php
echo xlt('November'); ?
></option
>
1278 <option value
="12"><?php
echo xlt('December'); ?
></option
>
1281 <div
class="col-md-3">
1282 <select name
="year" id
="ccyear" class="form-control">
1283 <option value
=""><?php
echo xlt('Select Year'); ?
></option
>
1284 <option value
="2017">2017</option
>
1285 <option value
="2018">2018</option
>
1286 <option value
="2019">2019</option
>
1287 <option value
="2020">2020</option
>
1288 <option value
="2021">2021</option
>
1289 <option value
="2022">2022</option
>
1290 <option value
="2023">2023</option
>
1291 <option value
="2024">2024</option
>
1297 <div
class="control-group">
1298 <label label
-default="label-default" class="control-label"><?php
echo xlt('Card CVV');?
></label
>
1299 <div
class="controls">
1301 <div
class="col-md-3">
1302 <input name
="pin" id
="pin" type
="text" class="form-control"
1303 autocomplete
="off" maxlength
="4" pattern
="\d{3}" onfocus
="validateCC()"
1304 title
="<?php echo xlt('Three or four digits at back of your card'); ?>" required value
="" />
1306 <div
class="col-md-3">
1307 <img src
='./images/img_cvc.png' style
='height: 58px; width: auto'>
1312 <div
class="form-actions">
1313 <button id
="paySubmit" class="btn btn-danger"><?php
echo xlt('Submit');?
></button
>
1314 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Cancel');?
></button
>
1317 <input type
='hidden' name
='cc_type' id
='cc_type' value
='' />
1321 <div
class="modal-footer">
1322 <button type
="button" class="btn btn-default" data
-dismiss
="modal"><?php
echo xlt('Close');?
></button
>
1327 <?php
echo "<script>var ccerr='". xlt('Invalid Credit Card Number') . "';</script>";?
>
1328 <script type
="text/javascript">
1329 $
('#cc_number').validateCreditCard(function(result
){
1330 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1331 var v
= (result
.valid
== true ?
' Valid #' : ' Invalid #')
1332 $
('#cardtype').val(r+v
);
1334 function validateCC() {
1335 var result
= $
('#cc_number').validateCreditCard();
1336 var r
= (result
.card_type
== null ?
'' : result
.card_type
.name
.toUpperCase())
1337 var v
= (result
.valid
== true ?
' Okay' : ' Invalid #')
1338 $
('#cardtype').val(r+v
);
1339 $
('#cc_type').val(r
);