PageRenderTime 50ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/search.php

https://bitbucket.org/kenzone/hairloss
PHP | 346 lines | 280 code | 56 blank | 10 comment | 38 complexity | f53606b22e644f52a9e47ea11bb0fa76 MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <style type="text/css" title="currentStyle">
  7. @import "css/demo_page.css";
  8. @import "css/demo_table.css";
  9. </style>
  10. <script type="text/javascript" language="javascript" src="js/jquery.js"></script>
  11. <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
  12. <script type="text/javascript" charset="utf-8">
  13. /* Time between each scrolling frame */
  14. $.fn.dataTableExt.oPagination.iTweenTime = 100;
  15. $.fn.dataTableExt.oPagination.scrolling = {
  16. "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
  17. {
  18. var oLang = oSettings.oLanguage.oPaginate;
  19. var oClasses = oSettings.oClasses;
  20. var fnClickHandler = function ( e ) {
  21. if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
  22. {
  23. fnCallbackDraw( oSettings );
  24. }
  25. };
  26. var sAppend = (!oSettings.bJUI) ?
  27. '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sPrevious+'</a>'+
  28. '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button">'+oLang.sNext+'</a>'
  29. :
  30. '<a class="'+oSettings.oClasses.sPagePrevDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUIPrev+'"></span></a>'+
  31. '<a class="'+oSettings.oClasses.sPageNextDisabled+'" tabindex="'+oSettings.iTabIndex+'" role="button"><span class="'+oSettings.oClasses.sPageJUINext+'"></span></a>';
  32. $(nPaging).append( sAppend );
  33. var els = $('a', nPaging);
  34. var nPrevious = els[0],
  35. nNext = els[1];
  36. oSettings.oApi._fnBindAction( nPrevious, {action: "previous"}, function() {
  37. /* Disallow paging event during a current paging event */
  38. if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
  39. {
  40. return;
  41. }
  42. oSettings.iPagingLoopStart = oSettings._iDisplayStart;
  43. oSettings.iPagingEnd = oSettings._iDisplayStart - oSettings._iDisplayLength;
  44. /* Correct for underrun */
  45. if ( oSettings.iPagingEnd < 0 )
  46. {
  47. oSettings.iPagingEnd = 0;
  48. }
  49. var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
  50. var innerLoop = function () {
  51. if ( oSettings.iPagingLoopStart > oSettings.iPagingEnd ) {
  52. oSettings.iPagingLoopStart--;
  53. oSettings._iDisplayStart = oSettings.iPagingLoopStart;
  54. fnCallbackDraw( oSettings );
  55. setTimeout( function() { innerLoop(); }, iTween );
  56. } else {
  57. oSettings.iPagingLoopStart = -1;
  58. }
  59. };
  60. innerLoop();
  61. } );
  62. oSettings.oApi._fnBindAction( nNext, {action: "next"}, function() {
  63. /* Disallow paging event during a current paging event */
  64. if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
  65. {
  66. return;
  67. }
  68. oSettings.iPagingLoopStart = oSettings._iDisplayStart;
  69. /* Make sure we are not over running the display array */
  70. if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
  71. {
  72. oSettings.iPagingEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
  73. }
  74. var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
  75. var innerLoop = function () {
  76. if ( oSettings.iPagingLoopStart < oSettings.iPagingEnd ) {
  77. oSettings.iPagingLoopStart++;
  78. oSettings._iDisplayStart = oSettings.iPagingLoopStart;
  79. fnCallbackDraw( oSettings );
  80. setTimeout( function() { innerLoop(); }, iTween );
  81. } else {
  82. oSettings.iPagingLoopStart = -1;
  83. }
  84. };
  85. innerLoop();
  86. } );
  87. },
  88. "fnUpdate": function ( oSettings, fnCallbackDraw )
  89. {
  90. if ( !oSettings.aanFeatures.p )
  91. {
  92. return;
  93. }
  94. /* Loop over each instance of the pager */
  95. var an = oSettings.aanFeatures.p;
  96. for ( var i=0, iLen=an.length ; i<iLen ; i++ )
  97. {
  98. if ( an[i].childNodes.length !== 0 )
  99. {
  100. an[i].childNodes[0].className =
  101. ( oSettings._iDisplayStart === 0 ) ?
  102. oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
  103. an[i].childNodes[1].className =
  104. ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
  105. oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
  106. }
  107. }
  108. }
  109. }
  110. $(document).ready(function() {
  111. $('#example').dataTable( {
  112. "sPaginationType": "scrolling"
  113. } );
  114. } );
  115. </script>
  116. <!--On load check 1st radio button, disable those textbox and the drop down list, and also reset function-->
  117. <script type="text/javascript">
  118. function setvalue(){
  119. document.getElementById('search3').checked = true
  120. if (document.getElementById('search3').checked = true)
  121. {
  122. document.getElementById('ddl_state').disabled='';
  123. document.getElementById('ddl_town').disabled='';
  124. document.getElementById('txt_postcode').disabled='disabled';
  125. }
  126. }
  127. window.onload = setvalue;
  128. function disablefield(){
  129. if (document.getElementById('search2').checked == 1)
  130. {
  131. document.getElementById('txt_postcode').disabled='';
  132. }
  133. else{
  134. document.getElementById('txt_postcode').disabled='disabled';
  135. }
  136. if(document.getElementById('search3').checked == 1)
  137. {
  138. document.getElementById('ddl_state').disabled='';
  139. document.getElementById('ddl_town').disabled='';
  140. }
  141. else{
  142. document.getElementById('ddl_state').disabled='disabled';
  143. document.getElementById('ddl_town').disabled='disabled';
  144. }
  145. }
  146. function formreset()
  147. {
  148. if(document.getElementById('ddl_state').selectedIndex = 'selected')
  149. {
  150. document.getElementById('ddl_state').selectedIndex=null;
  151. }
  152. if(document.getElementById('ddl_town').selectedIndex = 'selected')
  153. {
  154. document.getElementById('ddl_town').selectedIndex=null;
  155. }
  156. if(document.getElementById('txt_postcode').value != '')
  157. {
  158. document.getElementById('txt_postcode').value=null;
  159. }
  160. }
  161. function mypopup(id)
  162. {
  163. alert(id);
  164. //mywindow = window.open("deletedoctor.php?docid=", "mywindow", "location=1,status=1,scrollbars=1,width=100,height=100");
  165. //mywindow.moveTo(50, 50);
  166. }
  167. </script>
  168. </head>
  169. <body id="dt_example">
  170. <form method="get" action="search.php" name="form1" >
  171. <table border="0" width="100%" height="100%" style="padding-left:225px;">
  172. <tr>
  173. <td width="200px;" valign="top" style="padding-top:5px;"><input type="radio" name="search1" id="search3" onChange="disablefield();"/>Search by state and town</td>
  174. <td>
  175. <table>
  176. <tr>
  177. <td>State</td>
  178. <td>
  179. <?php
  180. include "config/config.php";
  181. $sql = "SELECT strStateName FROM doctor group by strStateName";
  182. $result = mysql_query($sql);
  183. echo "<select name='ddl_state' id='ddl_state' OnChange='document.form1.submit();'>";
  184. echo "<option value=''>- Select State -</option>";
  185. while($row = mysql_fetch_array($result))
  186. {
  187. $ddl_state = $row['strStateName'];
  188. $newVariablestate = str_replace(" ", "_", $ddl_state);
  189. $selected = ($_GET['ddl_state'] == $newVariablestate)?'selected="selected"':NULL;
  190. echo "<option value=".$newVariablestate." ".$selected.">".$newVariablestate."</option>";
  191. }
  192. echo "</select>";
  193. include "config/con_close.php";
  194. ?>
  195. </td>
  196. </tr>
  197. <tr><td>Town</td>
  198. <td>
  199. <?php
  200. include "config/config.php";
  201. $oldvariable = $_GET["ddl_state"];
  202. $newVariablestate = str_replace("_", " ", $oldvariable);
  203. //replaces "_" to " "
  204. $sql = "SELECT strTownName FROM doctor where strStateName='". $newVariablestate ."' group by strTownName";
  205. $result = mysql_query($sql);
  206. echo "<select name='ddl_town' id='ddl_town' >";
  207. echo "<option value=''>- Select Town -</option>";
  208. while($row = mysql_fetch_array($result))
  209. {
  210. //replaces "" to "_"
  211. $ddl_town = $row['strTownName'];
  212. $newVariabletown = str_replace(" ", "_", $ddl_town);
  213. $selected = ($_GET['ddl_town'] == $newVariabletown)?'selected="selected"':NULL;
  214. echo "<option value=".$newVariabletown." ".$selected.">".$newVariabletown."</option>";
  215. }
  216. echo "</select>";
  217. include "config/con_close.php";
  218. ?>
  219. </td>
  220. </tr>
  221. </table>
  222. </td>
  223. </tr>
  224. <tr>
  225. <td><input type="radio" name="search1" id="search2" onChange="disablefield();"/>Search by Postcode</td>
  226. <td>Post Code<input type="text" name="postcode" id="txt_postcode"/></td>
  227. </tr>
  228. <tr>
  229. <td></td>
  230. <td><input type="button" value="Reset" name="reset" onclick="formreset()"><input type="submit" name="btn_submit" id="btn_submit" value="submit"/></td>
  231. </tr>
  232. </table>
  233. </form>
  234. <!--Start the Paging for the grid search-->
  235. <div id="container">
  236. <div id="demo">
  237. <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
  238. <thead>
  239. <tr>
  240. <th align="center">No</th>
  241. <th align="center">Clinic Name</th>
  242. <th align="center">Address1</th>
  243. <th align="center">Address2</th>
  244. <th align="center">Town</th>
  245. <th align="center">State</th>
  246. <th align="center">PostCode</th>
  247. <th align="center">Phone</th>
  248. </tr>
  249. </thead>
  250. <tbody>
  251. <?php
  252. if(isset($_GET['btn_submit']))
  253. {
  254. include "functions.php";
  255. if($_GET['ddl_state'] != "" && $_GET['ddl_town'] != ""){
  256. $state = $_GET['ddl_state'];
  257. $newVariablestate = str_replace("_", " ", $state);
  258. $town = $_GET['ddl_town'];
  259. $newVariabletown = str_replace("_", " ", $town);
  260. search_doctor_by_state_and_town($newVariablestate,$newVariabletown);
  261. }else if ($_GET['postcode'] != "")
  262. {
  263. $postcode = $_GET['postcode'];
  264. search_doctor_postcode($postcode);
  265. }
  266. ?>
  267. <?php
  268. }
  269. else
  270. {
  271. }
  272. ?>
  273. </tbody>
  274. <tfoot>
  275. <tr>
  276. <th align="center">No</th>
  277. <th align="center">Clinic Name</th>
  278. <th align="center">Address1</th>
  279. <th align="center">Address2</th>
  280. <th align="center">Town</th>
  281. <th align="center">State</th>
  282. <th align="center">PostCode</th>
  283. <th align="center">Phone</th>
  284. </tr>
  285. </tfoot>
  286. </table>
  287. </div>
  288. </div>
  289. </body>
  290. </html>