Advertisement
Guest User

controller

a guest
Feb 2nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.13 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Admin extends CI_Controller {
  5.  
  6. public function __construct() {
  7. parent::__construct();
  8.  
  9. $this->data['user'] = array(
  10. 'username' => $_SESSION['userData']['username'],
  11. 'dateAdded' => $_SESSION['userData']['dateAdded'],
  12. 'fullname' => $_SESSION['userData']['fullname']
  13. );
  14. }
  15.  
  16. public function admin_home() {
  17.  
  18. $this->load->view('admin/admin_view', $this->data);
  19. }
  20.  
  21. public function admin_profile(){
  22. $this->load->view('admin/admin_profile', $this->data);
  23.  
  24. }
  25.  
  26. public function admin_manage_accounts(){
  27. $query = $this->model->get_userdata();
  28.  
  29. $data1 = array(
  30. 'get_position' => $this->model->get_position(),
  31. 'get_status' => $this->model->get_status()
  32. );
  33.  
  34. $specialData = array('data' => $this->data, 'header_info' => header_info($data1));
  35.  
  36. $this->load->view('admin/admin_manage_accounts',$specialData);
  37. }
  38.  
  39. //for user searching
  40. public function loadDataTable($page = 0) {
  41.  
  42. $searchFullname = $this->input->post('searchFullname');
  43. $searchStatus = $this->input->post('searchStatus');
  44. $searchPosition = $this->input->post('searchPosition');
  45. $itemPerPage = 10;
  46. $query = $this->model->get_userdata($page, $itemPerPage, $searchFullname, $searchStatus, $searchPosition);
  47.  
  48. if($query->num_rows() > 0){
  49.  
  50. $data = array(
  51. 'result' => $query->result(),
  52. 'success' => 1,
  53. 'page' => $page
  54. );
  55.  
  56. }else {
  57.  
  58. $data = array(
  59. 'success' => 0,
  60. 'message' => 'No Results'
  61. );
  62. }
  63.  
  64. generate_json($data);
  65. }
  66.  
  67. public function inactiveUser($id = 0) {
  68. $this->model->inactiveUser($id);
  69.  
  70. $data = array(
  71. 'success' => 1
  72. );
  73.  
  74. generate_json($data);
  75. }
  76.  
  77. public function activeUser($id = 0) {
  78. $this->model->activeUser($id);
  79.  
  80. $data = array(
  81. 'success' => 1
  82. );
  83.  
  84. generate_json($data);
  85. }
  86.  
  87. public function addNewUser() {
  88. $fname = $this->input->post('txtfname');
  89. $mname = $this->input->post('txtmname');
  90. $lname = $this->input->post('txtlname');
  91. $user = $this->input->post('txtuser');
  92. $pass = $this->input->post('txtpass');
  93. $position = $this->input->post('txtposition');
  94.  
  95. $this->model->addNewUser($fname, $mname, $lname, $user, $pass, $position);
  96.  
  97. $data = array(
  98. 'success' => 1
  99. );
  100.  
  101. generate_json($data);
  102. }
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. //for instructor searching
  112. public function loadInstructorInfoTable($page = 0) {
  113. $searchinsFullname = $this->input->post('searchinsFullname');
  114. $searchinsPosition = $this->input->post('searchinsPosition');
  115. $searchinsStatus = $this->input->post('searchinsStatus');
  116. $itemPerPage = 10;
  117. $query = $this->model->get_instructorinfodata($page, $itemPerPage, $searchinsFullname, $searchinsPosition, $searchinsStatus);
  118.  
  119. if($query->num_rows() > 0){
  120.  
  121. $data = array(
  122. 'result' => $query->result(),
  123. 'success' => 1,
  124. 'page' => $page
  125. );
  126.  
  127. }else {
  128.  
  129. $data = array(
  130. 'success' => 0,
  131. 'message' => 'No Results'
  132. );
  133. }
  134.  
  135. generate_json($data);
  136. }
  137.  
  138.  
  139. // for add instructor info
  140. public function addNewInstructorInfo() {
  141. $classID = $this->input->post('txtclassID');
  142. $fname = $this->input->post('txtfname');
  143. $mname = $this->input->post('txtmname');
  144. $lname = $this->input->post('txtlname');
  145. $datereg = $this->input->post('txtdateReg');
  146. $insposition = $this->input->post('txtinsPosition');
  147. $sex = $this->input->post('txtSex');
  148. $address = $this->input->post('txtAddress');
  149. $contact = $this->input->post('txtContact');
  150. $bday = $this->input->post('txtBday');
  151. $rate = $this->input->post('txtRate');
  152. $insstatus = $this->input->post('txtinsStatus');
  153.  
  154. $this->model->addNewInstructorInfo($classID, $fname, $mname, $lname, $datereg, $insposition, $sex, $address, $contact, $bday, $rate, $insstatus);
  155.  
  156. $data = array(
  157. 'success' => 1
  158. );
  159.  
  160. generate_json($data);
  161. }
  162.  
  163.  
  164. public function editInstructorInfo(){
  165. // if (!empty($this->session->userdata('isLogin'))) {
  166. $instructorID = $this->input->post('txtinstructorID');
  167. $classID1 = $this->input->post('txtclassID1');
  168. $fname1 = $this->input->post('txtfname1');
  169. $mname1 = $this->input->post('txtmname1');
  170. $lname1 = $this->input->post('txtlname1');
  171. $datereg1 = $this->input->post('txtdateReg1');
  172. $insposition1 = $this->input->post('txtinsPosition1');
  173. $sex1 = $this->input->post('txtSex1');
  174. $address1 = $this->input->post('txtAddress1');
  175. $contact1 = $this->input->post('txtContact1');
  176. $bday1 = $this->input->post('txtBday1');
  177. $rate1 = $this->input->post('txtRate1');
  178. $insstatus1 = $this->input->post('txtinsStatus1');
  179.  
  180. if($insposition1 > 0) {
  181.  
  182. $this->model->get_editInstructorInfo($instructorID, $classID1, $fname1, $mname1, $lname1, $datereg1, $insposition1, $sex1, $address1, $contact1, $bday1, $rate1, $insstatus1);
  183.  
  184. $data = array(
  185. 'success' => 1
  186. );
  187. }else {
  188. $data = array(
  189. 'success' => 0
  190. );
  191. }
  192.  
  193. generate_json($data);
  194.  
  195. // }else {
  196. // redirect(base_url());
  197. // }
  198. }
  199.  
  200.  
  201. //for student search
  202. public function loadStudentInfoTable($page = 0) {
  203. $searchstudschoolID = $this->input->post('searchstudschoolID');
  204. $searchstudFullname = $this->input->post('searchstudFullname');
  205. $searchstudCourse = $this->input->post('searchstudCourse');
  206. $itemPerPage = 10;
  207. $query = $this->model->get_studentinfodata($page, $itemPerPage, $searchstudschoolID, $searchstudFullname, $searchstudCourse);
  208.  
  209. if($query->num_rows() > 0){
  210.  
  211. $data = array(
  212. 'result' => $query->result(),
  213. 'success' => 1,
  214. 'page' => $page
  215. );
  216.  
  217. }else {
  218.  
  219. $data = array(
  220. 'success' => 0,
  221. 'message' => 'No Results'
  222. );
  223. }
  224.  
  225. generate_json($data);
  226. }
  227.  
  228.  
  229. // for add student info
  230. public function addNewStudentInfo() {
  231. $schoolID = $this->input->post('txtschoolID');
  232. $stud_lname = $this->input->post('txtfname');
  233. $stud_fname = $this->input->post('txtmname');
  234. $stud_mname = $this->input->post('txtlname');
  235. $stud_address = $this->input->post('txtaddress');
  236. $sex = $this->input->post('txtsex');
  237. $stud_bdate = $this->input->post('txtbday');
  238. $stud_bplace = $this->input->post('txtbplace');
  239. $stud_contact = $this->input->post('txtcontact');
  240. $district = $this->input->post('txtdistrict');
  241. $bloodtype = $this->input->post('txtbloodtype');
  242. $stud_nationality = $this->input->post('txtnationality');
  243. $stud_guardian = $this->input->post('txtguardian');
  244. $guard_contact = $this->input->post('txtguardianNo');
  245. $course = $this->input->post('txtcourse');
  246. $prevCourse = $this->input->post('txtprevcourse');
  247. $dateEnrolled = $this->input->post('txtdateenroll');
  248. $dateGraduated = $this->input->post('txtdategrad');
  249. $schoolLastAttended = $this->input->post('txtlastschoolattended');
  250. $yearGradHS = $this->input->post('txtyrgradHS');
  251. $schoolHS = $this->input->post('txtgradHS');
  252.  
  253. $this->model->addNewStudentInfo($schoolID, $stud_lname, $stud_fname, $stud_mname, $stud_address, $sex,
  254. $stud_bdate, $stud_bplace, $stud_contact, $district, $bloodtype, $stud_nationality,
  255. $stud_guardian, $guard_contact, $course, $prevCourse, $dateEnrolled, $dateGraduated, $schoolLastAttended,
  256. $yearGradHS, $schoolHS);
  257.  
  258. $data = array(
  259. 'success' => 1
  260. );
  261.  
  262. generate_json($data);
  263. }
  264.  
  265.  
  266.  
  267. //for add course
  268. public function addNewCourse(){
  269.  
  270. $ccode = $this->input->post('txtcoursecode');
  271. $cname = $this->input->post('txtcoursename');
  272. $cmajor = $this->input->post('txtcoursemajor');
  273. $college = $this->input->post('txtcollege');
  274.  
  275. $this->model->addNewCourse($ccode, $cname, $cmajor, $college);
  276.  
  277. $data = array(
  278. 'success' => 1
  279. );
  280.  
  281. generate_json($data);
  282. }
  283.  
  284. //for edit course
  285. public function editCourseRecord() {
  286.  
  287. // if(!empty($this->session->userdata('isLogin'))){
  288. $courseID = $this->input->post('courseID');
  289. $txtcoursecode1 = $this->input->post('txtcoursecode1');
  290. $txtcoursename1 = $this->input->post('txtcoursename1');
  291. $txtcoursemajor1 = $this->input->post('txtcoursemajor1');
  292. $txtcollege1 = $this->input->post('txtcollege1');
  293. if($txtcollege1 > 0) {
  294.  
  295. $this->model->get_editCourseRecord($courseID, $txtcoursecode1, $txtcoursename1, $txtcoursemajor1, $txtcollege1);
  296.  
  297. $data = array(
  298. 'success' => 1
  299. );
  300. }else {
  301. $data = array(
  302. 'success' => 0
  303. );
  304. }
  305.  
  306. generate_json($data);
  307.  
  308. }
  309.  
  310. // else {
  311. // redirect(base_url());
  312. // }
  313.  
  314. // }
  315.  
  316. //for add college
  317.  
  318. public function addNewCollege(){
  319. $addcollege = $this->input->post('txtAddcollege');
  320. $this->model->addNewCollege($addcollege);
  321.  
  322. $data = array(
  323. 'success' => 1
  324. );
  325.  
  326. generate_json($data);
  327. }
  328.  
  329. //for add major
  330. public function addNewMajor(){
  331. $addmajor = $this->input->post('txtAddmajor');
  332. $this->model->addNewMajor($addmajor);
  333.  
  334. $data = array(
  335. 'success' => 1
  336. );
  337.  
  338. generate_json($data);
  339. }
  340.  
  341. //for course searching
  342. public function loadCourseDataTable($page = 0) {
  343.  
  344. $searchCoursecode= $this->input->post('searchCoursecode');
  345. $searchCollege = $this->input->post('searchCollege');
  346. $itemPerPage = 10;
  347. $query = $this->model->get_coursedata($page, $itemPerPage, $searchCoursecode, $searchCollege);
  348.  
  349. if($query->num_rows() > 0){
  350.  
  351. $data = array(
  352. 'result' => $query->result(),
  353. 'success' => 1,
  354. 'page' => $page
  355. );
  356.  
  357. }else {
  358.  
  359. $data = array(
  360. 'success' => 0,
  361. 'message' => 'No Results'
  362. );
  363. }
  364.  
  365. generate_json($data);
  366. }
  367.  
  368.  
  369. public function admin_manage_students(){
  370.  
  371. $query = $this->model->get_studentinfodata();
  372. $data1 = array(
  373. 'get_sex' => $this->model->get_sex(),
  374. 'get_district' => $this->model->get_district(),
  375. 'get_bloodtype' => $this->model->get_bloodtype(),
  376. 'get_course' => $this->model->get_course(),
  377. 'get_prevCourse' => $this->model->get_prevCourse()
  378. );
  379. $header_info = header_info($data1);
  380. $specialData = array('data' => $this->data, 'header_info' => $header_info);
  381.  
  382. $this->load->view('admin/admin_manage_students', $specialData);
  383. }
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392. public function admin_manage_instructors(){
  393.  
  394. $query = $this->model->get_instructorinfodata();
  395. $data1 = array(
  396. 'get_insposition' => $this->model->get_insposition(),
  397. 'get_sex' => $this->model->get_sex(),
  398. 'get_insstatus' => $this->model->get_insstatus()
  399. );
  400.  
  401. $specialData = array('data' => $this->data, 'header_info' => header_info($data1));
  402.  
  403. $this->load->view('admin/admin_manage_instructors', $specialData);
  404.  
  405. }
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413. public function admin_manage_courses(){
  414.  
  415. $query = $this->model->get_coursedata();
  416.  
  417. $data1 = array(
  418. 'get_college' => $this->model->get_college(),
  419. 'get_cmajor' => $this->model->get_cmajor()
  420. );
  421.  
  422. $specialData = array('data' => $this->data, 'header_info' => header_info($data1));
  423.  
  424. $this->load->view('admin/admin_manage_courses' , $specialData);
  425. }
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442. public function admin_manage_departments(){
  443. $this->load->view('admin/admin_manage_departments' , $this->data);
  444. }
  445.  
  446. public function admin_manage_schedules(){
  447. $this->load->view('admin/admin_manage_schedules', $this->data);
  448. }
  449.  
  450. public function admin_manage_grades(){
  451. $this->load->view('admin/admin_manage_grades', $this->data);
  452. }
  453.  
  454. public function admin_calendar(){
  455. $this->load->view('admin/admin_calendar', $this->data);
  456. }
  457.  
  458. public function admin_changepass(){
  459. $this->load->view('admin/admin_changepass', $this->data);
  460. }
  461.  
  462. // public function logout(){
  463. // $this->load->view('admin/index');
  464. // }
  465.  
  466.  
  467. public function getDataOfFields() {
  468.  
  469. $id = $this->input->post('id');
  470. $sql = $this->model->getDataOfFields($id);
  471.  
  472. }
  473.  
  474. public function getCourseDataField(){
  475.  
  476. $courseid =$this->input->post('courseid');
  477.  
  478. $query = $this->model->getCourseDataField($courseid);
  479.  
  480. if($query->num_rows() > 0){
  481.  
  482. $data = array(
  483. 'result' => $query->result(),
  484. 'success' => 1
  485. );
  486.  
  487. }else {
  488.  
  489. $data = array(
  490. 'success' => 0,
  491. 'message' => 'No Results'
  492. );
  493. }
  494.  
  495. generate_json($data);
  496.  
  497. }
  498.  
  499. //delete course
  500. public function getCourseID(){
  501.  
  502. $courseid = $this->input->post('courseid');
  503.  
  504. $query = $this->model->getCourseID($courseid);
  505.  
  506. }
  507.  
  508. //delete student
  509. public function getstud_id(){
  510.  
  511. $stud_id = $this->input->post('stud_id');
  512.  
  513. $query = $this->model->getstud_id($stud_id);
  514.  
  515. }
  516. //delete instructor
  517. public function getInstructorID(){
  518.  
  519. $instructorid = $this->input->post('instructorid');
  520.  
  521. $query = $this->model->getInstructorID($instructorid);
  522.  
  523. }
  524. public function getInstructorInfoeditIDfield(){
  525.  
  526. $instructorID = $this->input->post('instructorID');
  527. $query = $this->model->getInstructorInfoeditIDfield($instructorID);
  528.  
  529. if($query->num_rows() > 0){
  530. $data = array(
  531. 'result'=> $query->result(),
  532. 'success'=> 1
  533. );
  534. }else{
  535. $data = array(
  536. 'success' => 0,
  537. 'message' =>'No Result'
  538. );
  539. }
  540. generate_json($data);
  541. }
  542.  
  543. public function getStudentDataField(){
  544.  
  545. $stud_id = $this->input->post('stud_id');
  546. $query = $this->model->getStudentDataField($stud_id);
  547.  
  548. if($query->num_rows() > 0){
  549. $data = array(
  550. 'result'=> $query->result(),
  551. 'success'=> 1
  552. );
  553. }else{
  554. $data = array(
  555. 'success' => 0,
  556. 'message' => 'No Result'
  557. );
  558. }
  559. generate_json($data);
  560. }
  561.  
  562. //for edit course
  563. public function editStudentRecord() {
  564.  
  565. // if(!empty($this->session->userdata('isLogin'))){
  566. $txtstud_id1 = $this->input->post('txtstud_id1');
  567. $txtschoolID1 = $this->input->post('txtschoolID1');
  568. $txtfname1 = $this->input->post('txtfname1');
  569. $txtmname1 = $this->input->post('txtmname1');
  570. $txtlname1 = $this->input->post('txtlname1');
  571. $txtaddress1 = $this->input->post('txtaddress1');
  572. $txtsex1 = $this->input->post('txtsex1');
  573. $txtbday1 = $this->input->post('txtbday1');
  574. $txtbplace1 = $this->input->post('txtbplace1');
  575. $txtcontact1 = $this->input->post('txtcontact1');
  576. $txtdistrict1 = $this->input->post('txtdistrict1');
  577. $txtbloodtype1 = $this->input->post('txtbloodtype1');
  578. $txtnationality1 = $this->input->post('txtnationality1');
  579. $txtguardian1 = $this->input->post('txtguardian1');
  580. $txtguardianNo1 = $this->input->post('txtguardianNo1');
  581. $txtcourse1 = $this->input->post('txtcourse1');
  582. $txtprevcourse1 = $this->input->post('txtprevcourse1');
  583. $txtdateenroll1 = $this->input->post('txtdateenroll1');
  584. $txtdategrad1 = $this->input->post('txtdategrad1');
  585. $txtlastschoolattended1 = $this->input->post('txtlastschoolattended1');
  586. $txtyrgradHS1 = $this->input->post('txtyrgradHS1');
  587. $txtgradHS1 = $this->input->post('txtgradHS1');
  588.  
  589. if($txtsex1 > 0) {
  590.  
  591. $this->model->get_editStudentRecord($txtstud_id1, $txtschoolID1, $txtfname1 ,$txtmname1 ,$txtlname1 ,$txtaddress1 ,$txtsex1 ,$txtbday1 ,$txtbplace1 ,$txtcontact1 ,$txtdistrict1 ,$txtbloodtype1 ,$txtnationality1 ,$txtguardian1 ,$txtguardianNo1 ,$txtcourse1 ,$txtprevcourse1 ,$txtdateenroll1 ,$txtdategrad1 ,$txtlastschoolattended1 ,$txtyrgradHS1 ,$txtgradHS1);
  592.  
  593. $data = array(
  594. 'success' => 1
  595. );
  596. }else {
  597. $data = array(
  598. 'success' => 0
  599. );
  600. }
  601.  
  602. generate_json($data);
  603.  
  604. }
  605. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement