From fee8aa4cf15483580695bdc5dc3cfb38fde8d67d Mon Sep 17 00:00:00 2001 From: resicovenba Date: Tue, 28 Nov 2017 20:21:32 +0530 Subject: [PATCH] student add details --- Apollo/api/application/config/routes.php | 2 + .../controllers/Student_Controller.php | 53 +++++++++++++ .../api/application/models/Student_model.php | 47 ++++++++++- Apollo/assets/js/controllers/studentCtrl.js | 54 +++++++++---- .../student/editStudentCourseDetails.html | 78 +++++++++++++++---- 5 files changed, 200 insertions(+), 34 deletions(-) diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 0ec723df..7f6163f3 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -100,7 +100,9 @@ $route['chkStudentExistDetail'] = 'Student_Controller/chkStudentExistDetail'; $route['getStudentList'] = 'Student_Controller/getStudentList'; $route['updateStudentExistDetail'] = 'Student_Controller/updateStudentExistDetail'; $route['chkUpdateStuExistDetail'] = 'Student_Controller/chkUpdateStuExistDetail'; +$route['getStudentCourseList'] = 'Student_Controller/getStudentCourseList'; $route['getStudentCourseDetails'] = 'Student_Controller/getStudentCourseDetails'; +$route['updateStudentCourseDetail'] = 'Student_Controller/updateStudentCourseDetail'; diff --git a/Apollo/api/application/controllers/Student_Controller.php b/Apollo/api/application/controllers/Student_Controller.php index 5dff53dd..b7fafb14 100644 --- a/Apollo/api/application/controllers/Student_Controller.php +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -61,6 +61,26 @@ class Student_Controller extends REST_Controller { } + + public function getStudentCourseList_post() { + $studentID = $this->post('studentID'); + $studentCourse = $this->student_model->get_student_course_list( $studentID );// Check if the employee exist + if ($studentCourse) + { + $studentCourse['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + public function getStudentCourseDetails_post() { $studentID = $this->post('studentID'); $studentCourse = $this->student_model->get_student_course( $studentID );// Check if the employee exist @@ -102,6 +122,39 @@ class Student_Controller extends REST_Controller { } } + public function updateStudentCourseDetail_post() { + $data = $this->post('data'); + $updatedBy = $this->post('updatedBy'); + $id = $data['ID']; + + $req['StudentID'] = $data['StudentID']; + $req['UniversityID'] = $data['UniversityID']; + $req['CourseID'] = $data['CourseID']; + $req['BatchCode'] = $data['BatchCode']; + $req['DOJ'] = $data['DOJ']; + $req['IsActive'] = $data['IsActive']; + $req['BranchID'] = $data['BranchID']; + $req['UpdatedBy'] = $updatedBy; + $date = date('Y-m-d H:i:s'); + $req['UpdatedOn'] = $date; + + $studentCourseUpdate = $this->student_model->update_student_course( $req, $id ); + if ($studentCourseUpdate) + { + $studentCourseUpdate['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentCourseUpdate, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + public function updateStudentExistDetail_post(){ $data = $this->post('data'); $updatedBy = $this->post('updatedBy'); diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index 4544baf2..2ab9d86b 100644 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -91,6 +91,24 @@ class Student_model extends CI_Model } return $results; } + + public function get_student_course_list($studentId) { + $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t4.BatchName'); + $this->db->from('' . STUDENTCOURSE . ' as t1'); + $this->db->join('' . UNIVERSITY . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); + $this->db->join('' . COURSE . ' as t3', 't3.CourseID = t1.CourseID', 'LEFT'); + $this->db->join('' . BATCH . ' as t4', 't4.BatchCode = t1.BatchCode', 'LEFT'); + $this->db->where('StudentID', $studentId); + $courseDetails = $this->db->get(); + $checkArr = $courseDetails->result(); + if (count($checkArr) > 0) { + $result['stuCourseDetails'] = true; + $result['course_details'] = $courseDetails->result(); + } else { + $result['stuCourseDetails'] = false; + } + return $result; + } // get student course details public function get_student_course($studentId) { @@ -109,7 +127,6 @@ class Student_model extends CI_Model } - //get course for university public function get_courseBatch_list($univId) { @@ -312,6 +329,32 @@ class Student_model extends CI_Model } return $result; } - + + + public function update_student_course($reqArr, $id) { + // print_r($id); + // print_r($reqArr); + // exit(); + $this->db->select('*'); + $this->db->from(STUDENTCOURSE); + $this->db->where('StudentID', $reqArr['StudentID']); + $this->db->where('CourseID', $reqArr['CourseID']); + $this->db->where_not_in('ID', $id); + if($this->db->get()->first_row()) { + $result['updateStuCourseStatus'] = false; + $result['message'] = "This Student Already exist for this course"; + } else { + $this->db->where('ID', $id); + $this->db->update(STUDENTCOURSE, $reqArr); + if ($this->db->affected_rows() == '1') { + $result['updateStuCourseStatus'] = true; + $result['message'] = "Successfully Student Course Details Updated"; + } else { + $result['updateStuCourseStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + return $result; + } } \ No newline at end of file diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index 89bec977..e7c73f1c 100644 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -102,7 +102,10 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } $scope.setEditCourseId = function (id) { - $scope.getStudentCourseDetails(id); + $scope.stucour = ''; + $scope.list = false; + $scope.getStudentCourseList(id); + // $scope.getStudentCourseDetails(id); $scope.editCourseId = id; $scope.editId = -1; $scope.courseEditLoading = true; @@ -114,7 +117,31 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", $scope.editCourseId = -1; } + $scope.getStudentCourseList = function(studentId) { + $scope.list = true; + var req = { + method: 'POST', + url: apiPoint.url + 'getStudentCourseList/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + studentID: studentId + } + }; + $http(req).then(function (response) { + if (response.data.stuCourseDetails) { + $scope.courseEditLoading = false; + $scope.studentCourseList = response.data.course_details; + $scope.stucour = $scope.studentCourse[0]; + } else { + } + }); + } + $scope.getStudentCourseDetails = function (studentId) { + $scope.list = false; + $scope.courseEdit = true; var req = { method: 'POST', url: apiPoint.url + 'getStudentCourseDetails/', @@ -129,6 +156,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", if (response.data.stuCourseDetails) { $scope.courseEditLoading = false; $scope.studentCourse = response.data.course_details; + $scope.stucour = $scope.studentCourse[0]; // $scope.branchArr = []; // angular.forEach($scope.empBranchs, function (item, index) { // // alert(item.BranchName); @@ -166,16 +194,14 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } $scope.onSlecetUnivEdit = function(id) { - // $scope.stucour.CourseID = ''; - // $scope.stucour.UniversityID = ''; $scope.myModelCourse.university = id; $scope.onSlecetUniv(); } - $scope.courseData = ''; - $scope.batchData = ''; $scope.courseLoading = false; $scope.onSlecetUniv = function () { + $scope.courseData = ''; + $scope.batchData = ''; $scope.myModelCourse.course = ''; $scope.myModelCourse.batch = ''; $scope.courseLoading = true; @@ -200,9 +226,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } - - - // check mobile number existing $scope.checkMobileExist = function () { var checkReq = { @@ -249,7 +272,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", // add student $scope.studentFORM = { - submit: function (form, myModel, myModelCourse) { var firstError = null; if (form.$invalid) { @@ -295,7 +317,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } }, reset: function (form) { - // $scope.myModel = angular.copy($scope.master); form.$setPristine(true); $scope.myModel = { @@ -336,7 +357,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", // update check mobile exist $scope.updateCheckMobileExist = function (p) { - var checkReq = { method: 'POST', url: apiPoint.url + 'chkUpdateStuExistDetail/', @@ -444,11 +464,11 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", angular.element('.ng-invalid[name=' + firstError + ']').focus(); // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); } else { - // alert(p.DOB); var formate = "dd-MM-yyyy"; - var checkDOB = $filter('date')(new Date(p.DOB), formate); - p.IsActive = p.IsActive === true ? 1 : 0; - p.DOB = checkDOB == "NaN-NaN-0NaN" ? p.DOB : $filter('date')(new Date(p.DOB), formate); + var checkDOJ = $filter('date')(new Date(datas.DOJ), formate); + datas.IsActive = datas.IsActive === true ? 1 : 0; + datas.DOJ = checkDOJ == "NaN-NaN-0NaN" ? datas.DOJ : $filter('date')(new Date(datas.DOJ), formate); + var req = { method: 'POST', url: apiPoint.url + 'updateStudentCourseDetail/', @@ -461,10 +481,10 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } }; $http(req).then(function (response) { - if (response.data.updateStuStatus = true) { + if (response.data.updateStuCourseStatus = true) { swal("Success!", response.data.message, "success"); $scope.getStudentList(); - $scope.editId = -1; + $scope.editCourseId = -1; } else { // $scope.ldloading1[loading.replace('-', '_')] = false; swal("Failed!", response.data.message, "error"); diff --git a/Apollo/assets/views/student/editStudentCourseDetails.html b/Apollo/assets/views/student/editStudentCourseDetails.html index 40cbda89..33424fc1 100644 --- a/Apollo/assets/views/student/editStudentCourseDetails.html +++ b/Apollo/assets/views/student/editStudentCourseDetails.html @@ -11,10 +11,39 @@ Course Details + +
+ + + + + + + + + + + + + + + + + + + +
University + Course + Batch + Date of Join +
{{s.UniversityName}}{{s.CourseName}}{{s.BatchName}}{{s.DOJ}}Edit
+
+ +
 {{studentCourse | json }} 
-
-
+
+
+ +
- +
Course is required
+ +
- +
Batch is required
-
- {{ stucour.ID}} - - - Invalid Entrollment ID -
+
+
- Date of Joining is required
+
+ +
+ +
+
+ +
+
+
-
+