From: bradymiller Date: Sun, 12 May 2013 22:20:23 +0000 (-0700) Subject: Modularize frontPayment() function in front_payment.php script to allow use with... X-Git-Tag: whats-been-changed~322 X-Git-Url: https://repo.or.cz/w/openemr.git/commitdiff_plain/ca276afe0b0781121a816ed69711dda43ac8f579 Modularize frontPayment() function in front_payment.php script to allow use with api. --- diff --git a/interface/patient_file/front_payment.php b/interface/patient_file/front_payment.php index 9e43b8091..95b4cffc3 100644 --- a/interface/patient_file/front_payment.php +++ b/interface/patient_file/front_payment.php @@ -13,6 +13,7 @@ require_once("../globals.php"); require_once("$srcdir/acl.inc"); require_once("$srcdir/patient.inc"); require_once("$srcdir/billing.inc"); +require_once("$srcdir/payment.inc.php"); require_once("$srcdir/forms.inc"); require_once("$srcdir/sl_eob.inc.php"); require_once("$srcdir/invoice_summary.inc.php"); @@ -72,38 +73,6 @@ function echoLine($iname, $date, $charges, $ptpaid, $inspaid, $duept,$encounter= echo " \n"; } -// Post a payment to the payments table. -// -function frontPayment($patient_id, $encounter, $method, $source, $amount1, $amount2) { - global $timestamp; - $tmprow = sqlQuery("SELECT date FROM form_encounter WHERE " . - "encounter=? and pid=?", - array($encounter,$patient_id)); - //the manipulation is done to insert the amount paid into payments table in correct order to show in front receipts report, - //if the payment is for today's encounter it will be shown in the report under today field and otherwise shown as previous - $tmprowArray=explode(' ',$tmprow['date']); - if(date('Y-m-d')==$tmprowArray[0]) - { - if($amount1==0) - { - $amount1=$amount2; - $amount2=0; - } - } - else - { - if($amount2==0) - { - $amount2=$amount1; - $amount1=0; - } - } - $payid = sqlInsert("INSERT INTO payments ( " . - "pid, encounter, dtime, user, method, source, amount1, amount2 " . - ") VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)", array($patient_id,$encounter,$timestamp,$_SESSION['authUser'],$method,$source,$amount1,$amount2) ); - return $payid; -} - // We use this to put dashes, colons, etc. back into a timestamp. // function decorateString($fmt, $str) { @@ -185,7 +154,7 @@ if ($_POST['form_save']) { ", payment_method = ?", array(0,$form_pid,$_SESSION['authUserID'],0,$form_source,$_REQUEST['form_prepayment'],$NameNew,$form_method)); - frontPayment($form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0);//insertion to 'payments' table. + frontPayment($form_pid, 0, $form_method, $form_source, $_REQUEST['form_prepayment'], 0, $timestamp);//insertion to 'payments' table. } if ($_POST['form_upay'] && $_REQUEST['radio_type_of_payment']!='pre_payment') { @@ -232,7 +201,7 @@ if ($_POST['form_save']) { " VALUES (?,?,?,?,?,0,now(),?,?,?,'PCP')", array($form_pid,$enc,$Codetype,$Code,$Modifier,$_SESSION['authId'],$session_id,$amount)); - frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0);//insertion to 'payments' table. + frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0, $timestamp);//insertion to 'payments' table. } 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. @@ -261,7 +230,7 @@ if ($_POST['form_save']) { //-------------------------------------------------------------------------------------------------------------------- - frontPayment($form_pid, $enc, $form_method, $form_source, 0, $amount);//insertion to 'payments' table. + frontPayment($form_pid, $enc, $form_method, $form_source, 0, $amount, $timestamp);//insertion to 'payments' table. //-------------------------------------------------------------------------------------------------------------------- diff --git a/library/payment.inc.php b/library/payment.inc.php index 7f14f9518..eb44fa2ab 100644 --- a/library/payment.inc.php +++ b/library/payment.inc.php @@ -24,6 +24,43 @@ // Paul Simon K // // +------------------------------------------------------------------------------+ + +// Post a payment to the payments table. +// +function frontPayment($patient_id, $encounter, $method, $source, $amount1, $amount2, $timestamp, $auth="") { + + if (empty($auth)) { + $auth=$_SESSION['authUser']; + } + + $tmprow = sqlQuery("SELECT date FROM form_encounter WHERE " . + "encounter=? and pid=?", + array($encounter,$patient_id)); + //the manipulation is done to insert the amount paid into payments table in correct order to show in front receipts report, + //if the payment is for today's encounter it will be shown in the report under today field and otherwise shown as previous + $tmprowArray=explode(' ',$tmprow['date']); + if(date('Y-m-d')==$tmprowArray[0]) + { + if($amount1==0) + { + $amount1=$amount2; + $amount2=0; + } + } + else + { + if($amount2==0) + { + $amount2=$amount1; + $amount1=0; + } + } + $payid = sqlInsert("INSERT INTO payments ( " . + "pid, encounter, dtime, user, method, source, amount1, amount2 " . + ") VALUES ( ?, ?, ?, ?, ?, ?, ?, ?)", array($patient_id,$encounter,$timestamp,$auth,$method,$source,$amount1,$amount2) ); + return $payid; +} + //=============================================================================== //This section handles the common functins of payment screens. //===============================================================================