Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.50 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Admin extends H_Controller {
  3.  
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->model('Admin_model');
  7. $this->load->model('Specialist_model');
  8. $this->load->model('Procedure_model');
  9. $this->load->helper('url');
  10. $this->load->helper('string');
  11. $this->load->library('session');
  12. $this->load->library('email');
  13. $this->load->helper('form');
  14. $this->load->library('form_validation');
  15. }
  16. /* @method : index
  17. * @params:
  18. * @desc: index method is used for login
  19. */
  20. public function index(){
  21.  
  22. $this->form_validation->set_rules('username', 'User Name', 'trim|required|xss_clean');
  23. $this->form_validation->set_rules('password', 'password', 'trim|required|xss_clean');
  24. if ($this->form_validation->run() == FALSE) {
  25. $this->load->view('templates/header');
  26. $this->load->view('admin_login');
  27. $this->load->view('templates/footer');
  28.  
  29. }else{
  30. $username = $this->input->post("username");
  31. $password = $this->input->post("password");
  32.  
  33. //check if username and password is correct
  34. $usr_result = $this->Admin_model->admin_login($username, $password);
  35. if ($usr_result > 0){
  36. $sessiondata = array(
  37. 'username' => $username,
  38. //'loginuser' => TRUE
  39. );
  40. $this->session->set_userdata($sessiondata);
  41. redirect("admin_dashboard");
  42. }else{
  43. $this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Invalid username and password!</div>');
  44. // redirect('admin');
  45. }
  46. }
  47. }
  48.  
  49. /* @method : add
  50. * @params:
  51. * @desc: add method is used for adding admin
  52. */
  53.  
  54. public function add(){
  55. $result = $this->Admin_model->add_admin();
  56. if ($result == TRUE) {
  57. $data['message_display'] = 'Admin added Successfully !';
  58. redirect('admin',$data);
  59. } else {
  60. $data['message_display'] = 'error saving data';
  61. $this->load->view('admin', $data);
  62. }
  63. }
  64.  
  65. /* @method : admin_login
  66. * @params:
  67. * @desc: admin_login method is used for admin login
  68. */
  69.  
  70. public function admin_login(){
  71. $username = $this->input->post("username");
  72. $password = $this->input->post("password");
  73.  
  74. //check if username and password is correct
  75. $usr_result = $this->Admin_model->admin_login($username, $password);
  76. if ($usr_result > 0) //active user record is present
  77. {
  78. //set the session variables
  79. $sessiondata = array(
  80. 'username' => $username,
  81. //'loginuser' => TRUE
  82. );
  83.  
  84. $this->session->set_userdata($sessiondata);
  85. $this->load->view("admin_dashboard");
  86. }
  87. else
  88. {
  89. $this->session->set_flashdata('msg', '<div class="alert alert-danger text-center">Invalid username and password!</div>');
  90. redirect('admin_dashboard');
  91. }
  92.  
  93. }
  94.  
  95. /* @method : edit_user
  96. * @params:
  97. * @desc: edit_user method is used for edit user
  98. */
  99.  
  100. public function edit_user($id)
  101. {
  102. $list= $this->Admin_model->get_user_detail($id);
  103.  
  104. $this->form_validation->set_rules('username', 'User Name', 'required');
  105. if ($this->form_validation->run() === FALSE){
  106. $data= array("title"=>"Edit User",'user' => $list);
  107. $this->load->view('templates/header');
  108. $this->load->view('edit_user',$data);
  109. $this->load->view('templates/footer');
  110. }else{
  111. $this->Admin_model->edit_user($id);
  112. redirect('/admin/user_list', 'refresh');
  113. }
  114. }
  115.  
  116. // /* @method : user_list
  117. // * @params:
  118. // * @desc: user_list method is used for creating user list
  119. // */
  120. //
  121. // function user_list()
  122. // {
  123. // $userlist= $this->Admin_model->get_user();
  124. // $fns['controller'] = $this;
  125. // $data = array("title"=>"User List", "user" => $userlist,'fns' => $fns,);
  126. // $this->load->view('templates/header');
  127. // $this->load->view("user_list", $data);
  128. // $this->load->view('templates/footer');
  129. // }
  130.  
  131. /* @method : admin_dashboard
  132. * @params:
  133. * @desc: admin_dashboard method is used for listing
  134. */
  135.  
  136. function admin_dashboard(){
  137. $patient = $this->Admin_model->get_patient();
  138. $homePhysican = $this->Admin_model->get_home_physican();
  139. $procat = $this->Admin_model->get_procedure_cat();
  140. $userlist= $this->Admin_model->get_user();
  141. $splIst = $this->Admin_model->get_specialist_details();
  142.  
  143.  
  144. $fns['controller'] = $this;
  145. $data = array("title"=>"Edit Physican", "patient" => $patient , 'spList' => $splIst,'homephy' => $homePhysican ,'fns' => $fns,'cat'=>$procat, "user" => $userlist);
  146. $this->load->view('templates/header');
  147. $this->load->view("admin_dashboard", $data);
  148. $this->load->view('templates/footer');
  149.  
  150. }
  151. /* @method : admin_bookings
  152. * @params:
  153. * @desc: admin_bookings method is used for checking specialist booking
  154. */
  155.  
  156. function admin_bookings(){
  157. $data = array("title"=>"booking");
  158. $this->load->view('templates/header');
  159. $this->load->view("admin_bookings", $data);
  160. $this->load->view('templates/footer');
  161. }
  162.  
  163. /* @method : check_licence_details
  164. * @params:
  165. * @desc: check_licence_details method is used for checking licence details
  166. */
  167.  
  168. function check_licence_details(){
  169. $allData = $this->Admin_model->get_all_sp_phy_list();
  170. $data = array("title"=>"Specialist details" ,'result' => $allData);
  171. $this->load->view('templates/header');
  172. $this->load->view("check_licence_details", $data);
  173. $this->load->view('templates/footer');
  174. }
  175.  
  176.  
  177. /* @method : add_location
  178. * @params:
  179. * @desc: add_location method is used for adding sp location
  180. */
  181.  
  182. function add_location(){
  183. $CITY = $this->Specialist_model->get_all_city_id();
  184. $states = $this->Specialist_model->get_all_state_id();
  185. $this->form_validation->set_rules('state_id', 'state Name', 'required');
  186. if ($this->form_validation->run() === FALSE){
  187.  
  188. $success ="";
  189. $error = "";
  190. $data= array("title"=>"Add Location",'city' => $CITY,'state' => $states,'success' => $success ,'error' => $error,);
  191. $this->load->view('templates/header');
  192. $this->load->view('admin_add_location',$data);
  193. $this->load->view('templates/footer');
  194. }else{
  195. $result = $this->Admin_model->save_location();
  196. $success ="";
  197. $error = "";
  198. if ($result == TRUE) {
  199. $success = "Location has been saved successfully";
  200. }
  201. $CITY = $this->Specialist_model->get_all_city_id();
  202. $states = $this->Specialist_model->get_all_state_id();
  203. $data= array("title"=>"Add Location",'city' => $CITY,'state' => $states,'success' => $success ,'error' => $error,);
  204. $this->load->view('templates/header');
  205. $this->load->view('admin_add_location',$data);
  206. $this->load->view('templates/footer');
  207. }
  208. }
  209.  
  210.  
  211. /* @method : admin_procedures
  212. * @params:
  213. * @desc: admin_procedures method is used for adding procedure
  214. */
  215. public function admin_procedures(){
  216.  
  217. $this->form_validation->set_rules('procedure_cat', 'procedure cat Name', 'required');
  218. if ($this->form_validation->run() === FALSE){
  219. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  220. $success ="";
  221. $error = "";
  222. $data= array("title"=>"Add procedure",'list' => $procedureCatList,'success' => $success ,'error' => $error,);
  223. $this->load->view('templates/header');
  224. $this->load->view('add_procedure_cat_name',$data);
  225. $this->load->view('templates/footer');
  226. }else{
  227. $result = $this->Admin_model->save_admin_procedures();
  228. $success ="";
  229. $error = "";
  230. if ($result == TRUE) {
  231. $success = "Procedure has been saved successfully";
  232. }else{
  233. $error = "Procedure not save";
  234. }
  235. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  236. $data= array("title"=>"Add procedure",'list' => $procedureCatList, 'success' => $success ,'error' => $error,);
  237. $this->load->view('templates/header');
  238. $this->load->view('add_procedure_cat_name',$data);
  239. $this->load->view('templates/footer');
  240. }
  241.  
  242. }
  243.  
  244. /* @method : admin_procedures_listing
  245. * @params:
  246. * @desc: admin_procedures_listing method is used for listing all procedure
  247. */
  248. public function admin_procedures_listing(){
  249. $procedureList = $this->Admin_model->get_admin_procedure_listing();
  250.  
  251. $i = 0;
  252. $temp = array();
  253. foreach($procedureList as $list){
  254. $str = encode_id($list['ID']);
  255. $temp[$i]['ID'] = $str;
  256. $temp[$i]['procedure_cat_id'] = $list['procedure_cat_id'];
  257. $temp[$i]['procedure_name'] = $list['procedure_name'];
  258. $i++;
  259. }
  260.  
  261. $procedureName = $this->Procedure_model->get_pro_cat_list();
  262. $success ="";
  263. $error = "";
  264. if($procedureList){
  265. $data= array("title"=>"Add Location",'listing' => $temp ,'prName' => $procedureName , 'success' => $success ,'error' => $error);
  266. $this->load->view('templates/header');
  267. $this->load->view('admin_procedure_listing',$data);
  268. $this->load->view('templates/footer');
  269. }
  270. }
  271.  
  272. /* @method : admin_procedures_edit
  273. * @params:
  274. * @desc: admin_procedures_edit method is used for edit procedure
  275. */
  276. public function admin_procedures_edit($id){
  277. $ids = decode_id($id);
  278. $this->form_validation->set_rules('procedure_cat', 'procedure cat Name', 'required');
  279. if ($this->form_validation->run() === FALSE){
  280. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  281. $cat = $this->Admin_model->get_admin_pro_cat_by_id($ids);
  282. $catName = $this->Admin_model->get_admin_pro_cat_name($ids);
  283. $success ="";
  284. $error = "";
  285. $data= array("title"=>"Edit procedure",'list' => $procedureCatList, 'id' => $ids, 'cat' => $cat , 'catName' => $catName, 'success' => $success ,'error' => $error,);
  286. $this->load->view('templates/header');
  287. $this->load->view('admin_procedure_edit',$data);
  288. $this->load->view('templates/footer');
  289. }else{
  290. $result = $this->Admin_model->edit_admin_procedures($ids);
  291.  
  292. $cat = $this->Admin_model->get_admin_pro_cat_by_id($ids);
  293. $catName = $this->Admin_model->get_admin_pro_cat_name($id);
  294. if ($result == TRUE) {
  295. $success = "Procedure has been saved successfully";
  296. }else{
  297. $error = "Procedure not save";
  298. }
  299. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  300. $data= array("title"=>"Edit procedure",'list' => $procedureCatList, 'id' => $ids , 'cat' => $cat , 'catName' => $catName, 'success' => $success ,'error' => $error,);
  301. $this->load->view('templates/header');
  302. redirect('admin/admin_procedures_listing',$data);
  303. $this->load->view('templates/footer');
  304. }
  305. }
  306.  
  307. /* @method : add_procedure
  308. * @params:
  309. * @desc: add_procedure method is used for adding admin procedure
  310. */
  311. public function add_procedure(){
  312.  
  313. $this->form_validation->set_rules('procedure_cat_id', 'procedure cat Name', 'required');
  314. if ($this->form_validation->run() === FALSE){
  315. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  316. $success ="";
  317. $error = "";
  318. $data= array("title"=>"Add procedure",'list' => $procedureCatList,'success' => $success ,'error' => $error,);
  319. $this->load->view('templates/header');
  320. $this->load->view('add_admin_procedure',$data);
  321. $this->load->view('templates/footer');
  322. }else{
  323. $result = $this->Admin_model->add_admin_procedures();
  324. $success ="";
  325. $error = "";
  326. if ($result == TRUE) {
  327. $success = "Procedure has been saved successfully";
  328. }else{
  329. $error = "Procedure not save";
  330. }
  331. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  332. $data= array("title"=>"Add procedure",'list' => $procedureCatList, 'success' => $success ,'error' => $error,);
  333. $this->load->view('templates/header');
  334. $this->load->view('add_admin_procedure',$data);
  335. $this->load->view('templates/footer');
  336. }
  337.  
  338. }
  339.  
  340. /* @method : admin_all_procedures_listing
  341. * @params:
  342. * @desc: admin_all_procedures_listing method is used for listing all procedure
  343. */
  344. public function admin_all_procedures_listing(){
  345. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  346.  
  347. $procedureList = $this->Admin_model->get_admin_all_procedure_listing();
  348.  
  349.  
  350. // $procedureName = $this->Procedure_model->get_pro_cat_list();
  351. if($procedureList){
  352. $data= array("title"=>"Add Location",'listing' => $procedureList, 'cat' => $procedureCatList,);
  353. $this->load->view('templates/header');
  354. $this->load->view('admin_all_procedure',$data);
  355. $this->load->view('templates/footer');
  356. }
  357. }
  358.  
  359.  
  360. public function procedure_edit($id){
  361. $this->form_validation->set_rules('procedure_cat_id', 'procedure cat Name', 'required');
  362. if ($this->form_validation->run() === FALSE){
  363. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  364. $admin_cat = $this->Admin_model->get_admin_procedure($id);
  365. $success ="";
  366. $error = "";
  367. $data= array("title"=>"Edit procedure",'list' => $procedureCatList, 'id' => $id, 'cat' => $admin_cat , 'success' => $success ,'error' => $error,);
  368. $this->load->view('templates/header');
  369. $this->load->view('admin_prc_edit',$data);
  370. $this->load->view('templates/footer');
  371. }else{
  372. $result = $this->Admin_model->update_admin_procedures($id);
  373. $admin_cat = $this->Admin_model->get_admin_procedure($id);
  374. if ($result == TRUE) {
  375. $success = "Procedure has been saved successfully";
  376. }else{
  377. $error = "Procedure not save";
  378. }
  379. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  380. $data= array("title"=>"Edit procedure",'list' => $procedureCatList, 'id' => $id, 'cat' => $admin_cat , 'success' => $success ,'error' => $error,);
  381. $this->load->view('templates/header');
  382. redirect('admin/admin_all_procedures_listing',$data);
  383. $this->load->view('templates/footer');
  384. }
  385. }
  386.  
  387. /* @method : procedure_edit
  388. * @params:
  389. * @desc: procedure_edit method is used for edit admin procedure
  390. */
  391.  
  392. public function specialist_procedures(){
  393. $this->form_validation->set_rules('specialist_name', 'Specialist Name', 'required');
  394. if ($this->form_validation->run() === FALSE){
  395. $spList = $this->Admin_model->get_all_specialist_name();
  396. $data= array("title"=>"specialist", 'splist' => $spList);
  397. $this->load->view('templates/header');
  398. $this->load->view('admin_specialist_listing',$data);
  399. $this->load->view('templates/footer');
  400. }else{
  401. $spList = $this->Admin_model->get_all_specialist_name();
  402. $data= array("title"=>"Edit procedure",'splist' => $spList,);
  403. $this->load->view('templates/header');
  404. redirect('admin/admin_specialist_listing',$data);
  405. $this->load->view('templates/footer');
  406. }
  407. }
  408.  
  409.  
  410. /* @method : admin_all_booking
  411. * @params:
  412. * @desc: admin_all_booking method is used to show all bookings
  413. */
  414.  
  415. public function admin_all_booking(){
  416. if(isset($_POST['set_search_filter'])){
  417. $booking = $this->Admin_model->get_all_booking_for_admin();
  418. }else{
  419. $booking = $this->Admin_model->get_all_booking_for_admin();
  420. }
  421. $spList = $this->Admin_model->get_all_specalist_name();
  422. $data= array("title"=>"specialist", 'booking' => $booking,'splist' => $spList);
  423. $this->load->view('templates/header');
  424. $this->load->view('admin_all_booking',$data);
  425. $this->load->view('templates/footer');
  426.  
  427. }
  428.  
  429.  
  430.  
  431. /* @method : admin_all_booking
  432. * @params:
  433. * @desc: admin_all_booking method is used to show all bookings
  434. */
  435.  
  436. public function angular_admin_all_booking(){
  437. // query to get all specialist booking details
  438. $query = "SELECT DISTINCT hp.procedure_name , hb.booking_date , hb.booking_time, hb.status, hs.name , hpt.username FROM (hbooking hb INNER JOIN hprocedure hp ON hb.procedure_id = hp.ID ) INNER JOIN hspecialist hs ON hb.specialist_user_id = hs.userid INNER JOIN hpatient hpt ON hb.patient_user_id = hpt.userid";
  439. if(isset($_POST['set_search_filter'])){
  440. $booking = $this->Admin_model->get_angular_all_booking_for_admin($query);
  441. }else{
  442. $booking = $this->Admin_model->get_angular_all_booking_for_admin($query);
  443. }
  444. $spList = $this->Admin_model->get_all_specalist_name();
  445. $data= array("title"=>"specialist", 'booking' => $booking,'splist' => $spList);
  446. $this->load->view('templates/header');
  447. $this->load->view('admin_all_booking',$data);
  448. $this->load->view('templates/footer');
  449.  
  450. }
  451.  
  452.  
  453. /* @method : admin_angular_dashboard
  454. * @params:
  455. * @desc: admin_angular_dashboard method is used for listing
  456. */
  457.  
  458. function admin_angular_dashboard(){
  459.  
  460. $procat = $this->Admin_model->get_procedure_cat();
  461. $userlist= $this->Admin_model->get_user();
  462.  
  463. // query to get hhomephysician list
  464. $query1 = "SELECT * FROM hhomephysician";
  465. $homePhysican = $this->Admin_model->get_angular_home_physican($query1);
  466. // query to get hpatient list
  467. $query2 = "SELECT * FROM hpatient";
  468. $patient = $this->Admin_model->get_angular_patient($query2);
  469.  
  470. // query to get specialist list
  471. $query3 = "SELECT * FROM hspecialist";
  472. $splIst = $this->Admin_model->get_angular_specialist($query3);
  473.  
  474.  
  475. $fns['controller'] = $this;
  476. $data = array("title"=>"Edit Physican", "patient" => $patient , 'spList' => $splIst,'homephy' => $homePhysican ,'fns' => $fns,'cat'=>$procat, "user" => $userlist);
  477. $this->load->view('templates/header');
  478. $this->load->view("admin_dashboard", $data);
  479. $this->load->view('templates/footer');
  480.  
  481. }
  482.  
  483. /* @method : admin_all_procedures_listing
  484. * @params:
  485. * @desc: admin_all_procedures_listing method is used for listing all procedure
  486. */
  487. public function admin_angular_all_procedures_listing(){
  488.  
  489. $procedureCatList = $this->Procedure_model->get_pro_cat_list();
  490.  
  491. // query to get all procedure details
  492. $query = "SELECT * FROM hmasterprocedure";
  493. $procedureList = $this->Admin_model->get_angular_admin_all_procedure_listing($query);
  494.  
  495. if($procedureList){
  496. $data= array("title"=>"Add Location",'listing' => $procedureList, 'cat' => $procedureCatList,);
  497. $this->load->view('templates/header');
  498. $this->load->view('admin_all_procedure',$data);
  499. $this->load->view('templates/footer');
  500. }
  501. }
  502.  
  503. /* @method : admin_procedures_listing
  504. * @params:
  505. * @desc: admin_procedures_listing method is used for listing all procedure
  506. */
  507. public function angular_admin_procedures_listing(){
  508. // query to get all procedure details for admin
  509. $query = "SELECT * FROM hadminprocedure";
  510.  
  511. $procedureList = $this->Admin_model->get_angular_admin_procedure_listing($query);
  512. $i = 0;
  513. $temp = array();
  514. foreach($procedureList as $list){
  515. $str = encode_id($list['ID']);
  516. $temp[$i]['ID'] = $str;
  517. $temp[$i]['procedure_cat_id'] = $list['procedure_cat_id'];
  518. $temp[$i]['procedure_name'] = $list['procedure_name'];
  519. $i++;
  520. }
  521.  
  522. $procedureName = $this->Procedure_model->get_pro_cat_list();
  523. $success ="";
  524. $error = "";
  525. if($procedureList){
  526. $data= array("title"=>"Add Location",'listing' => $temp ,'prName' => $procedureName , 'success' => $success ,'error' => $error);
  527. $this->load->view('templates/header');
  528. $this->load->view('admin_procedure_listing',$data);
  529. $this->load->view('templates/footer');
  530. }
  531. }
  532.  
  533. /* @method : angular_check_licence_details
  534. * @params:
  535. * @desc: angular_check_licence_details method is used for checking licence details
  536. */
  537.  
  538. function angular_check_licence_details(){
  539. $query1 = $this->db->query("SELECT hs.ID,hs.name, hs.address, hs.licence_no, hs.licence_city , hs.licence_state , hu.usertype FROM (hspecialist hs INNER JOIN huser hu ON hs.userid = hu.ID)");
  540. $query2 = $this->db->query("SELECT hphy.ID, hphy.name, hphy.address, hphy.licence_no, hphy.licence_city , hphy.licence_state , hu.usertype FROM (hhomephysician hphy INNER JOIN huser hu ON hphy.userid = hu.ID)");
  541. $allData = $this->Admin_model->angular_get_all_sp_phy_list($query1, $query2);
  542. $data = array("title"=>"Specialist details" ,'result' => $allData);
  543. $this->load->view('templates/header');
  544. $this->load->view("check_licence_details", $data);
  545. $this->load->view('templates/footer');
  546. }
  547.  
  548. }
  549. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement