PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/Admin/search.php

https://bitbucket.org/kenzone/hairloss
PHP | 363 lines | 296 code | 57 blank | 10 comment | 38 complexity | 5a95fe130c4071ec93bca6a3e774bf7a 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="170px;"><a href="logout.php" >Logout</a></td>
  174. <td></td>
  175. </tr>
  176. </table>
  177. <table border="0" width="100%" height="100%" style="padding-left:225px;">
  178. <tr>
  179. <td width="200px;" valign="top" style="padding-top:5px;"><input type="radio" name="search1" id="search3" onChange="disablefield();"/>Search by state and town</td>
  180. <td>
  181. <table>
  182. <tr>
  183. <td>State</td>
  184. <td>
  185. <?php
  186. include "../config/config.php";
  187. $sql = "SELECT strStateName FROM doctor group by strStateName";
  188. $result = mysql_query($sql);
  189. echo "<select name='ddl_state' id='ddl_state' OnChange='document.form1.submit();'>";
  190. echo "<option value=''>- Select State -</option>";
  191. while($row = mysql_fetch_array($result))
  192. {
  193. $ddl_state = $row['strStateName'];
  194. $newVariablestate = str_replace(" ", "_", $ddl_state);
  195. $selected = ($_GET['ddl_state'] == $newVariablestate)?'selected="selected"':NULL;
  196. echo "<option value=".$newVariablestate." ".$selected.">".$newVariablestate."</option>";
  197. }
  198. echo "</select>";
  199. include "../config/con_close.php";
  200. ?>
  201. </td>
  202. </tr>
  203. <tr><td>Town</td>
  204. <td>
  205. <?php
  206. include "../config/config.php";
  207. $oldvariable = $_GET["ddl_state"];
  208. $newVariablestate = str_replace("_", " ", $oldvariable);
  209. //replaces "_" to " "
  210. $sql = "SELECT strTownName FROM doctor where strStateName='". $newVariablestate ."' group by strTownName";
  211. $result = mysql_query($sql);
  212. echo "<select name='ddl_town' id='ddl_town' >";
  213. echo "<option value=''>- Select Town -</option>";
  214. while($row = mysql_fetch_array($result))
  215. {
  216. //replaces "" to "_"
  217. $ddl_town = $row['strTownName'];
  218. $newVariabletown = str_replace(" ", "_", $ddl_town);
  219. $selected = ($_GET['ddl_town'] == $newVariabletown)?'selected="selected"':NULL;
  220. echo "<option value=".$newVariabletown." ".$selected.">".$newVariabletown."</option>";
  221. }
  222. echo "</select>";
  223. include "../config/con_close.php";
  224. ?>
  225. </td>
  226. </tr>
  227. </table>
  228. </td>
  229. </tr>
  230. <tr>
  231. <td><input type="radio" name="search1" id="search2" onChange="disablefield();"/>Search by Postcode</td>
  232. <td>Post Code<input type="text" name="postcode" id="txt_postcode"/></td>
  233. </tr>
  234. <tr>
  235. <td></td>
  236. <td><input type="button" value="Reset" name="reset" onclick="formreset()"><input type="submit" name="btn_submit" id="btn_submit" value="submit"/></td>
  237. </tr>
  238. </table>
  239. <?php echo "<script type='text/javascript'>","function url(){newwindow=window.open('insertdoctor.php','name','height=300,width=400,left=450,top=250'); newwindow.focus();};","</script>";
  240. ?>
  241. <table border="0" width="100%" height="100%" style="padding-left:225px;">
  242. <tr>
  243. <td width="170px;">Insert New Doctor Detail</td>
  244. <td><input type="button" value="Insert" name="insert" onclick="url();"></td>
  245. </tr>
  246. </table>
  247. </form>
  248. <!--Start the Paging for the grid search-->
  249. <div id="container">
  250. <div id="demo">
  251. <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
  252. <thead>
  253. <tr>
  254. <th align="center">No</th>
  255. <th align="center">Clinic Name</th>
  256. <th align="center">Address1</th>
  257. <th align="center">Address2</th>
  258. <th align="center">Town</th>
  259. <th align="center">State</th>
  260. <th align="center">PostCode</th>
  261. <th align="center">Phone</th>
  262. <th align="center">Delete</th>
  263. </tr>
  264. </thead>
  265. <tbody>
  266. <?php
  267. if(isset($_GET['btn_submit']))
  268. {
  269. include "../functions.php";
  270. if($_GET['ddl_state'] != "" && $_GET['ddl_town'] != ""){
  271. $state = $_GET['ddl_state'];
  272. $newVariablestate = str_replace("_", " ", $state);
  273. $town = $_GET['ddl_town'];
  274. $newVariabletown = str_replace("_", " ", $town);
  275. search_doctor_by_state_and_town_admin($newVariablestate,$newVariabletown);
  276. }else if ($_GET['postcode'] != "")
  277. {
  278. $postcode = $_GET['postcode'];
  279. search_doctor_postcode_admin($postcode);
  280. }
  281. ?>
  282. <?php
  283. }
  284. else
  285. {
  286. }
  287. ?>
  288. </tbody>
  289. <tfoot>
  290. <tr>
  291. <th align="center">No</th>
  292. <th align="center">Clinic Name</th>
  293. <th align="center">Address1</th>
  294. <th align="center">Address2</th>
  295. <th align="center">Town</th>
  296. <th align="center">State</th>
  297. <th align="center">PostCode</th>
  298. <th align="center">Phone</th>
  299. <th align="center">Delete</th>
  300. </tr>
  301. </tfoot>
  302. </table>
  303. </div>
  304. </div>
  305. </body>
  306. </html>