more organization of autoloaded files (#424)
[openemr.git] / library / ajax / payment_ajax.php
blobe477052d05868d9ec6a264a96187286f50986a4d
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //===============================================================================
28 //This section handles ajax for insurance,patient and for encounters.
29 //===============================================================================
30 require_once("../../interface/globals.php");
31 require_once("$srcdir/formatting.inc.php");
32 //=================================
33 if (isset($_REQUEST["ajax_mode"]))
35 AjaxDropDownCode();
37 //=================================
38 function AjaxDropDownCode()
40 if ($_REQUEST["ajax_mode"] == "set")//insurance
42 $CountIndex=1;
43 $StringForAjax="<div id='AjaxContainerInsurance'><table width='552' border='1' cellspacing='0' cellpadding='0'>
44 <tr class='text' bgcolor='#dddddd'>
45 <td width='50'>".htmlspecialchars( xl('Code'), ENT_QUOTES)."</td>
46 <td width='300'>".htmlspecialchars( xl('Name'), ENT_QUOTES)."</td>
47 <td width='200'>".htmlspecialchars( xl('Address'), ENT_QUOTES)."</td>
48 </tr>".
49 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
50 //PlaceValues(event,'&nbsp;','')==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
51 //PutTheValuesClick('&nbsp;','')==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
52 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
53 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);PlaceValues(event,'&nbsp;','')\" onclick=\"PutTheValuesClick('&nbsp;','')\">
54 <td colspan='3' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
55 </tr>";
56 $insurance_text_ajax=formData('insurance_text_ajax','',true);
57 $res = sqlStatement("SELECT insurance_companies.id,name,city,state,country FROM insurance_companies
58 left join addresses on insurance_companies.id=addresses.foreign_id where name like '$insurance_text_ajax%' or insurance_companies.id like '$insurance_text_ajax%' ORDER BY name");
59 while ($row = sqlFetchArray($res))
61 if($CountIndex%2==1)
63 $bgcolor='#ddddff';
65 else
67 $bgcolor='#ffdddd';
69 $CountIndex++;
70 $Id=$row['id'];
71 $Name=$row['name'];
72 $City=$row['city'];
73 $State=$row['state'];
74 $Country=$row['country'];
75 $Address=$City.', '.$State.', '.$Country;
76 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
77 onkeydown='ProcessKeyForColoring(event,$CountIndex);PlaceValues(event,\"".htmlspecialchars($Id,ENT_QUOTES)."\",\"".htmlspecialchars($Name,ENT_QUOTES)."\")'
78 onclick='PutTheValuesClick(\"".htmlspecialchars($Id,ENT_QUOTES)."\",\"".htmlspecialchars($Name,ENT_QUOTES)."\")'>
79 <td><a id='anchor_insurance_code_$CountIndex' href='#'>".htmlspecialchars($Id)."</a></td>
80 <td><a href='#'>".htmlspecialchars($Name)."</a></td>
81 <td><a href='#'>".htmlspecialchars($Address)."</a></td>
82 </tr>";
84 $StringForAjax.="</table></div>";
85 echo strlen($_REQUEST['insurance_text_ajax']).'~`~`'.$StringForAjax;
86 die;
88 //===============================================================================
89 if ($_REQUEST["ajax_mode"] == "set_patient")//patient.
90 {//From 2 areas this ajax is called.So 2 pairs of functions are used.
91 //PlaceValues==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
92 //PutTheValuesClick==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
93 //PlaceValuesDistribute==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
94 //PutTheValuesClickDistribute==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
95 if(isset($_REQUEST['patient_code']) && $_REQUEST['patient_code']!='')
97 $patient_code=formData('patient_code','',true);
98 if(isset($_REQUEST['submit_or_simple_type']) && $_REQUEST['submit_or_simple_type']=='Simple')
100 $StringToAppend="PutTheValuesClickPatient";
101 $StringToAppend2="PlaceValuesPatient";
103 else
105 $StringToAppend="PutTheValuesClickDistribute";
106 $StringToAppend2="PlaceValuesDistribute";
108 $patient_code_complete=$_REQUEST['patient_code'];//we need the spaces here
110 elseif(isset($_REQUEST['insurance_text_ajax']) && $_REQUEST['insurance_text_ajax']!='')
112 $patient_code=formData('insurance_text_ajax','',true);
113 $StringToAppend="PutTheValuesClick";
114 $StringToAppend2="PlaceValues";
115 $patient_code_complete=$_REQUEST['insurance_text_ajax'];//we need the spaces here
117 $CountIndex=1;
118 $StringForAjax="<div id='AjaxContainerPatient'><table width='452' border='1' cellspacing='0' cellpadding='0'>
119 <tr class='text' bgcolor='#dddddd'>
120 <td width='50'>".htmlspecialchars( xl('Code'), ENT_QUOTES)."</td>
121 <td width='100'>".htmlspecialchars( xl('Last Name'), ENT_QUOTES)."</td>
122 <td width='100'>".htmlspecialchars( xl('First Name'), ENT_QUOTES)."</td>
123 <td width='100'>".htmlspecialchars( xl('Middle Name'), ENT_QUOTES)."</td>
124 <td width='100'>".htmlspecialchars( xl('Date of Birth'), ENT_QUOTES)."</td>
125 </tr>".
126 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
127 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
128 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'&nbsp;','')\" onclick=\"$StringToAppend('&nbsp;','')\">
129 <td colspan='5' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
130 </tr>
133 $res = sqlStatement("SELECT pid as id,fname,lname,mname,DOB FROM patient_data
134 where fname like '$patient_code%' or lname like '$patient_code%' or mname like '$patient_code%' or
135 CONCAT(lname,' ',fname,' ',mname) like '$patient_code%' or pid like '$patient_code%' ORDER BY lname");
136 while ($row = sqlFetchArray($res))
138 if($CountIndex%2==1)
140 $bgcolor='#ddddff';
142 else
144 $bgcolor='#ffdddd';
146 $CountIndex++;
147 $Id=$row['id'];
148 $fname=$row['fname'];
149 $lname=$row['lname'];
150 $mname=$row['mname'];
151 $Name=$lname.' '.$fname.' '.$mname;
152 $DOB=oeFormatShortDate($row['DOB']);
153 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
154 onkeydown='ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,\"".htmlspecialchars($Id,ENT_QUOTES)."\",\"".htmlspecialchars($Name,ENT_QUOTES)."\")' onclick=\"$StringToAppend('".addslashes($Id)."','".htmlspecialchars(addslashes($Name),ENT_QUOTES)."')\">
155 <td><a id='anchor_insurance_code_$CountIndex' href='#' >".htmlspecialchars($Id)."</a></td>
156 <td><a href='#'>".htmlspecialchars($lname)."</a></td>
157 <td><a href='#'>".htmlspecialchars($fname)."</a></td>
158 <td><a href='#'>".htmlspecialchars($mname)."</a></td>
159 <td><a href='#'>".htmlspecialchars($DOB)."</a></td>
160 </tr>";
162 $StringForAjax.="</table></div>";
163 echo strlen($patient_code_complete).'~`~`'.$StringForAjax;
164 die;
166 //===============================================================================
167 if ($_REQUEST["ajax_mode"] == "encounter")//encounter
169 //PlaceValuesEncounter==>Used while -->KEY PRESS<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
170 //PutTheValuesClickEncounter==>Used while -->CLICK<-- over list.List vanishes and the clicked one gets listed in the parent page's text box.
171 if(isset($_REQUEST['encounter_patient_code']))
173 $patient_code=formData('encounter_patient_code','',true);
174 $StringToAppend="PutTheValuesClickEncounter";
175 $StringToAppend2="PlaceValuesEncounter";
177 $CountIndex=1;
178 $StringForAjax="<div id='AjaxContainerEncounter'><table width='202' border='1' cellspacing='0' cellpadding='0'>
179 <tr class='text' bgcolor='#dddddd'>
180 <td width='100'>".htmlspecialchars( xl('Encounter'), ENT_QUOTES)."</td>
181 <td width='100'>".htmlspecialchars( xl('Date'), ENT_QUOTES)."</td>
182 </tr>".
183 //ProcessKeyForColoring(event,$CountIndex)==>Shows the navigation in the listing by change of colors and focus.Happens when down or up arrow is pressed.
184 "<tr class='text' height='20' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
185 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'&nbsp;','')\" onclick=\"$StringToAppend('&nbsp;','')\">
186 <td colspan='2' align='center'><a id='anchor_insurance_code_$CountIndex' href='#'></a></td>
187 </tr>
190 $res = sqlStatement("SELECT date,encounter FROM form_encounter
191 where pid ='$patient_code' ORDER BY encounter");
192 while ($row = sqlFetchArray($res))
194 if($CountIndex%2==1)
196 $bgcolor='#ddddff';
198 else
200 $bgcolor='#ffdddd';
202 $CountIndex++;
203 $Date=$row['date'];
204 $Date=explode(' ',$Date);
205 $Date=oeFormatShortDate($Date[0]);
206 $Encounter=$row['encounter'];
207 $StringForAjax.="<tr class='text' bgcolor='$bgcolor' id=\"tr_insurance_$CountIndex\"
208 onkeydown=\"ProcessKeyForColoring(event,$CountIndex);$StringToAppend2(event,'".htmlspecialchars($Encounter,ENT_QUOTES)."','".htmlspecialchars($Date,ENT_QUOTES)."')\" onclick=\"$StringToAppend('".htmlspecialchars($Encounter,ENT_QUOTES)."','".htmlspecialchars($Date,ENT_QUOTES)."')\">
209 <td><a id='anchor_insurance_code_$CountIndex' href='#' >".htmlspecialchars($Encounter)."</a></td>
210 <td><a href='#'>".htmlspecialchars($Date)."</a></td>
211 </tr>";
213 $StringForAjax.="</table></div>";
214 echo $StringForAjax;
215 die;