Focus the search term on load
[openemr.git] / interface / reports / criteria.tab.php
blobf06c89db50d2bf2943894233b9e650130a8890cd
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 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.
22 //
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 <!-- This displays the search criteria.The master processing is done here.This page is included in the billing_report.php -->
29 <style>
30 .criteria_class1{width:125px;}
31 .criteria_class2{padding-left:5px;}
32 </style>
33 <?php
34 $ThisPageSearchCriteriaKey=array();
35 $ThisPageSearchCriteriaDataType=array();
36 $ThisPageSearchCriteriaDisplay=array();
38 $ThisPageSearchCriteriaRadioKey=array();
39 $ThisPageSearchCriteriaDisplayRadio=array();
41 $ThisPageSearchCriteriaQueryDropDown=array();
42 $ThisPageSearchCriteriaQueryDropDownDefault=array();
43 $ThisPageSearchCriteriaQueryDropDownDefaultKey=array();
45 $ThisPageSearchCriteriaInclude=array();
46 //Filling the input array.
47 $ThisPageSearchCriteriaDisplay=$ThisPageSearchCriteriaDisplayMaster;
48 $ThisPageSearchCriteriaKey=split(',',$ThisPageSearchCriteriaKeyMaster);
49 $ThisPageSearchCriteriaDataType=split(',',$ThisPageSearchCriteriaDataTypeMaster);
50 //--------------------------------------------------------------
51 //Filling the input array.
52 $NumberOfRadioThisPageSearchCriteria=0;
53 $NumberOfQueryDropDownThisPageSearchCriteria=0;
54 $NumberOfIncludeThisPageSearchCriteria=0;
55 for($ThisPageSearchCriteriaIndex=0;$ThisPageSearchCriteriaIndex<sizeof($ThisPageSearchCriteriaDataType);$ThisPageSearchCriteriaIndex++)
57 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio' || $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio_like')
59 $NumberOfRadioThisPageSearchCriteria++;
60 $ThisPageSearchCriteriaDisplayRadio[$ThisPageSearchCriteriaIndex]=$ThisPageSearchCriteriaDisplayRadioMaster[$NumberOfRadioThisPageSearchCriteria];
61 $ThisPageSearchCriteriaRadioKey[$ThisPageSearchCriteriaIndex]=split(',',$ThisPageSearchCriteriaRadioKeyMaster[$NumberOfRadioThisPageSearchCriteria]);
63 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='query_drop_down')
65 $NumberOfQueryDropDownThisPageSearchCriteria++;
66 $ThisPageSearchCriteriaQueryDropDown[$ThisPageSearchCriteriaIndex]=$NumberOfQueryDropDownThisPageSearchCriteria;
67 $ThisPageSearchCriteriaQueryDropDownDefault[$ThisPageSearchCriteriaIndex]=
68 $ThisPageSearchCriteriaQueryDropDownMasterDefault[$NumberOfQueryDropDownThisPageSearchCriteria];
69 $ThisPageSearchCriteriaQueryDropDownDefaultKey[$ThisPageSearchCriteriaIndex]=
70 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[$NumberOfQueryDropDownThisPageSearchCriteria];
72 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='include')
74 $NumberOfIncludeThisPageSearchCriteria++;
75 $ThisPageSearchCriteriaInclude[$ThisPageSearchCriteriaIndex]=$NumberOfIncludeThisPageSearchCriteria;
78 //------------------------------------------------------------------------------
80 <table width="560" border="0" cellspacing="0" cellpadding="0" >
81 <tr>
82 <td><fieldset style="border-color:#000000; border-width:1px;padding-left:5px;padding-right:0px;padding-top:0px;padding-bottom:0px;" >
83 <legend class='text'><b><?php echo htmlspecialchars( xl('Choose Criteria'), ENT_QUOTES) ?></b></legend>
84 <table width="290" border="0" cellspacing="0" cellpadding="0">
85 <tr>
86 <td class='text'><?php echo htmlspecialchars( xl('Criteria'), ENT_QUOTES) ?></td>
87 <td ></td>
88 </tr>
89 <tr>
90 <td width="140" >
91 <select name="choose_this_page_criteria" id="choose_this_page_criteria" title="Choose Criteria"
92 class="text" style="width:140px;" onChange="CriteriaVisible()" size='8' >
93 <?php
94 for ($ThisPageSearchCriteriaIndex=0;$ThisPageSearchCriteriaIndex<sizeof($ThisPageSearchCriteriaKey);$ThisPageSearchCriteriaIndex++)
96 $optionValue = $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex];
97 echo "<option value='".attr($optionValue)."'";
98 $optionLabel = $ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex];
99 echo ">".text($optionLabel)."</option>\n";
102 </select>
103 </td>
104 <td width="150" valign="top">
105 <!-- Below section comes as per the defined criteria arrays.Initially all are hidden.As per the click the corresponding items gets visible. -->
106 <?php
107 for ($ThisPageSearchCriteriaIndex=0;$ThisPageSearchCriteriaIndex<sizeof($ThisPageSearchCriteriaKey);$ThisPageSearchCriteriaIndex++)
109 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='date' ||
110 $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='datetime')
112 $DateNamePart=str_replace('.','_',$ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]);
114 <table width="150" border="0" cellspacing="0" cellpadding="0"
115 id="table_<?php echo attr($ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]) ?>" style="display:none">
116 <tr>
117 <td class='text criteria_class2' ><?php echo text($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]); ?></td>
118 </tr>
119 <tr>
120 <td width="150" class='text criteria_class2' ><?php echo generate_select_list("date_master_criteria_$DateNamePart",
121 "date_master_criteria", $_REQUEST["date_master_criteria_$DateNamePart"],
122 "Date Criteria","","text criteria_class1",
123 'calendar_function(this.value,"master_from_date_'.$DateNamePart.'","master_to_date_'.$DateNamePart.'");
124 appendOptionDateCriteria("'.attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]).'","'.
125 $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex].'",this.options[this.selectedIndex].text,'.
126 'this.options[this.selectedIndex].value," = ","master_from_date_'.$DateNamePart.'","master_to_date_'.$DateNamePart.'",
127 "'.$ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex].'")');?>
128 </td>
129 </tr>
130 <tr>
131 <td class='text' align="right" style="padding-right:5px;padding-bottom:2px;padding-top:2px">
132 <?php echo htmlspecialchars( xl('From'), ENT_QUOTES).':' ?><input type='text' size='7'
133 name='master_from_date_<?php echo $DateNamePart;?>'
134 id='master_from_date_<?php echo $DateNamePart;?>' class="text " readonly=""
135 value="<?php echo attr($_REQUEST["master_from_date_$DateNamePart"]) ?>"
136 onChange="SetDateCriteriaCustom('date_master_criteria_<?php echo $DateNamePart;?>');
137 appendOptionDateCriteria('<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]);?>',
138 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex];?>',
139 '<?php echo htmlspecialchars( xl('Custom'), ENT_QUOTES); ?>',
140 '<?php echo htmlspecialchars( xl('Custom'), ENT_QUOTES); ?>',
141 ' = ','master_from_date_<?php echo $DateNamePart;?>','master_to_date_<?php echo $DateNamePart;?>',
142 '<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')" />&nbsp;
143 <img src="<?php echo $web_root ?>/interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg"
144 align="texttop" id='img_master_fromdate_<?php echo $DateNamePart;?>' border='0' alt='[?]' style='cursor:pointer'
145 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>' />
146 <script>
147 Calendar.setup({inputField:"master_from_date_<?php echo $DateNamePart;?>", ifFormat:"%Y-%m-%d", button:"img_master_fromdate_<?php echo $DateNamePart;?>"});
148 </script>
149 </td>
150 </tr>
151 <tr>
152 <td class='text' align="right" style="padding-right:5px">
153 <?php echo htmlspecialchars( xl('To'), ENT_QUOTES).':' ?><input type='text' size='7'
154 name='master_to_date_<?php echo $DateNamePart;?>'
155 id='master_to_date_<?php echo $DateNamePart;?>' class="text " readonly=""
156 value="<?php echo attr($_REQUEST["master_to_date_$DateNamePart"]) ?>"
157 onChange="SetDateCriteriaCustom('date_master_criteria_<?php echo $DateNamePart;?>');
158 appendOptionDateCriteria('<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]);?>',
159 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex];?>',
160 '<?php echo htmlspecialchars( xl('Custom'), ENT_QUOTES); ?>',
161 '<?php echo htmlspecialchars( xl('Custom'), ENT_QUOTES); ?>',
162 ' = ','master_from_date_<?php echo $DateNamePart;?>','master_to_date_<?php echo $DateNamePart;?>',
163 '<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')" />&nbsp;
164 <img src="<?php echo $web_root ?>/interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg"
165 align="texttop" id='img_master_todate_<?php echo $DateNamePart;?>' border='0' alt='[?]' style='cursor:pointer'
166 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>' />
167 <script>
168 Calendar.setup({inputField:"master_to_date_<?php echo $DateNamePart;?>", ifFormat:"%Y-%m-%d", button:"img_master_todate_<?php echo $DateNamePart;?>"});
169 </script>
170 </td>
171 </tr>
172 </table>
173 <?php }?>
174 <?php
175 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='query_drop_down')
177 $array_query_drop_down=BuildArrayForReport($ThisPageSearchCriteriaQueryDropDownMaster[$ThisPageSearchCriteriaQueryDropDown[$ThisPageSearchCriteriaIndex]]);
178 $QueryDropDownNamePart=str_replace('.','_',$ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]);
180 <table width="150" border="0" cellspacing="0" cellpadding="0"
181 id="table_<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex] ?>" style="display:none">
182 <tr>
183 <td class='text criteria_class2' ><?php echo text($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]); ?></td>
184 </tr>
185 <tr>
186 <td width="150" class='text criteria_class2' >
188 <select style="width:140px;" name="query_drop_down_master_<?php echo $QueryDropDownNamePart;?>"
189 id="query_drop_down_master_<?php echo $QueryDropDownNamePart;?>" onchange="appendOptionRadioCriteria(
190 '<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]) ?>',
191 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex] ?>',this.options[this.selectedIndex].text,
192 this.options[this.selectedIndex].value,' = ',
193 '<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')">
195 <option value="<?php echo attr($ThisPageSearchCriteriaQueryDropDownDefaultKey[$ThisPageSearchCriteriaIndex]) ?>"
196 ><?php echo text($ThisPageSearchCriteriaQueryDropDownDefault[$ThisPageSearchCriteriaIndex]) ?></option>
198 <?php
199 foreach($array_query_drop_down as $array_query_drop_down_key => $array_query_drop_down_value)
201 if($_REQUEST["query_drop_down_master_".$QueryDropDownNamePart]==$array_query_drop_down_key)
202 $Selected=' selected ';
203 else
204 $Selected='';
206 <option value="<?php echo attr($array_query_drop_down_key) ?>" <?php echo $Selected ?>
207 ><?php echo text($array_query_drop_down_value) ?></option>
208 <?php
211 </select>
213 </td>
214 </tr>
215 </table>
216 <?php }?>
217 <?php
218 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='include')
220 $IncludeNamePart=str_replace('.','_',$ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]);
222 <table width="150" border="0" cellspacing="0" cellpadding="0"
223 id="table_<?php echo attr($ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]) ?>" style="display:none">
224 <tr>
225 <td class='text criteria_class2' ><?php echo text($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]); ?></td>
226 </tr>
227 <tr>
228 <td width="150" class='text criteria_class2' ><?php
229 $FunctionName=$ThisPageSearchCriteriaIncludeMaster[$ThisPageSearchCriteriaInclude[$ThisPageSearchCriteriaIndex]];
230 $FunctionName();
231 ?></td>
232 </tr>
233 </table>
234 <?php }?>
235 <?php
236 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='text' ||
237 $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='text_like')
239 $TextNamePart=str_replace('.','_',$ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]);
240 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='text')
242 $TextSeperator=' = ';
244 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='text_like')
246 $TextSeperator=' like ';
249 <table width="150" border="0" cellspacing="0" cellpadding="0"
250 id="table_<?php echo attr($ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]) ?>" style="display:none">
251 <tr>
252 <td class='text criteria_class2' ><?php echo text($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]); ?></td>
253 </tr>
254 <tr>
255 <td width="150" class='text criteria_class2' ><input type="text" name="text_master_<?php echo attr($TextNamePart);?>"
256 id="text_master_<?php echo attr($TextNamePart);?>" value="<?php echo attr($_REQUEST["text_master_$TextNamePart"]) ?>"
257 onkeyup="appendOptionTextCriteria('<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]) ?>',
258 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex] ?>',this.value,this.value,'<?php echo $TextSeperator ?>',
259 '<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')"
260 onchange="appendOptionTextCriteria('<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]) ?>',
261 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex] ?>',this.value,this.value,'<?php echo $TextSeperator ?>',
262 '<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')"
263 size="15" autocomplete="off" /></td>
264 </tr>
265 </table>
266 <?php }?>
267 <?php
268 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio' ||
269 $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio_like')
272 <table width="150" border="0" cellspacing="0" cellpadding="0"
273 id="table_<?php echo attr($ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]) ?>" style="display:none">
274 <tr>
275 <td class='text criteria_class2' width="150" ><?php echo text($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]); ?></td>
276 </tr>
277 <?php
278 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio')
280 $RadioSeperator=' = ';
282 if($ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex]=='radio_like')
284 $RadioSeperator=' like ';
286 for ($ThisPageSearchCriteriaRadioIndex=0;
287 $ThisPageSearchCriteriaRadioIndex<sizeof($ThisPageSearchCriteriaDisplayRadio[$ThisPageSearchCriteriaIndex]);
288 $ThisPageSearchCriteriaRadioIndex++)
290 $RadioNamePart=str_replace('.','_',$ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex]);
291 if($_REQUEST["radio_".$RadioNamePart]==
292 $ThisPageSearchCriteriaRadioKey[$ThisPageSearchCriteriaIndex][$ThisPageSearchCriteriaRadioIndex])
293 $Checked=' checked ';
294 else
295 $Checked='';
297 <tr>
298 <td class='text'><input type="radio" name="radio_<?php echo attr($RadioNamePart) ?>"
299 id="radio_<?php echo attr($RadioNamePart.$ThisPageSearchCriteriaRadioIndex) ?>"
300 value="<?php echo attr($ThisPageSearchCriteriaRadioKey[$ThisPageSearchCriteriaIndex][$ThisPageSearchCriteriaRadioIndex]) ?>"
301 <?php echo $Checked;?>
302 onClick="appendOptionRadioCriteria('<?php echo attr($ThisPageSearchCriteriaDisplay[$ThisPageSearchCriteriaIndex]) ?>',
303 '<?php echo $ThisPageSearchCriteriaKey[$ThisPageSearchCriteriaIndex] ?>',
304 '<?php echo attr($ThisPageSearchCriteriaDisplayRadio[$ThisPageSearchCriteriaIndex][$ThisPageSearchCriteriaRadioIndex]) ?>',
305 '<?php echo $ThisPageSearchCriteriaRadioKey[$ThisPageSearchCriteriaIndex][$ThisPageSearchCriteriaRadioIndex] ?>',
306 '<?php echo $RadioSeperator ?>','<?php echo $ThisPageSearchCriteriaDataType[$ThisPageSearchCriteriaIndex] ?>')" />
307 <?php echo text($ThisPageSearchCriteriaDisplayRadio[$ThisPageSearchCriteriaIndex][$ThisPageSearchCriteriaRadioIndex]) ?>
308 </td>
309 </tr>
310 <?php
313 </table>
314 <?php
317 <?php
320 </td>
321 </tr>
322 </table>
323 </fieldset>
324 </td>
325 <td valign="top"><fieldset style="border-color:#000000; border-width:1px;padding-left:5px;padding-right:0px;padding-top:0px;padding-bottom:0px;" >
326 <legend class='text'><b><?php echo htmlspecialchars( xl('Current Criteria'), ENT_QUOTES) ?></b></legend>
327 <table width="260" border="0" cellspacing="0" cellpadding="0">
328 <tr>
329 <td width="117" class='text'><?php echo htmlspecialchars( xl('Criteria'), ENT_QUOTES) ?></td>
330 <td width="118" class='text'><?php echo htmlspecialchars( xl('Set To'), ENT_QUOTES) ?></td>
331 <td width="25" class='text'></td>
332 </tr>
333 <tr>
334 <td colspan="2"><select name='final_this_page_criteria[]' id='final_this_page_criteria'
335 size='8' style="width:235px;" class='text' title='Criteria' multiple="multiple" >
336 <?php
337 for($final_this_page_criteria_index=0;$final_this_page_criteria_index<sizeof($_REQUEST['final_this_page_criteria']);
338 $final_this_page_criteria_index++)
341 <option value="<?php echo attr($_REQUEST['final_this_page_criteria'][$final_this_page_criteria_index]) ?>" >
342 <?php echo xlt($_REQUEST['final_this_page_criteria_text'][$final_this_page_criteria_index]) ?></option>
343 <?php
347 </select>
348 <select name='final_this_page_criteria_text[]' id='final_this_page_criteria_text' style="display:none" multiple="multiple" >
349 <?php
350 for($final_this_page_criteria_index=0;$final_this_page_criteria_index<sizeof($_REQUEST['final_this_page_criteria']);
351 $final_this_page_criteria_index++)
354 <option value="<?php echo attr($_REQUEST['final_this_page_criteria_text'][$final_this_page_criteria_index]) ?>" >1</option>
355 <?php
359 </select>
360 </td>
361 <td valign="top"><a href="#" onClick="removeOptionSelected()"><img src="<?php echo $web_root ?>/interface/pic/Delete.gif" border="0" /></a></td>
362 </tr>
363 </table>
364 </fieldset>
365 </td>
366 </tr>
367 </table><?php //print_r($_REQUEST['final_this_page_criteria']); ?>
368 <!-- ============================================================================================================================================= -->
369 <!-- Criteria section Ends -->
370 <!-- ============================================================================================================================================= -->