From ba395f572d3340395e987d6c00336393bb13d5c7 Mon Sep 17 00:00:00 2001 From: resicovenba Date: Wed, 29 Nov 2017 15:02:53 +0530 Subject: [PATCH] student details added --- Apollo/api/application/config/routes.php | 1 + .../controllers/Student_Controller.php | 38 ++++ .../api/application/models/Student_model.php | 23 ++ Apollo/assets/js/controllers/sessionCtrl.js | 2 +- Apollo/assets/js/controllers/studentCtrl.js | 204 ++++++++++++----- Apollo/assets/views/partials/nav.html | 127 +++++++++-- .../student/editStudentCourseDetails.html | 212 +++++++++++++----- .../assets/views/student/student_details.html | 21 +- 8 files changed, 496 insertions(+), 132 deletions(-) diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 6e196527..8dc8a7a7 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -108,6 +108,7 @@ $route['chkUpdateStuExistDetail'] = 'Student_Controller/chkUpdateStuExistDetail' $route['getStudentCourseList'] = 'Student_Controller/getStudentCourseList'; $route['getStudentCourseDetails'] = 'Student_Controller/getStudentCourseDetails'; $route['updateStudentCourseDetail'] = 'Student_Controller/updateStudentCourseDetail'; +$route['insertStudentCourse'] = 'Student_Controller/insertStudentCourse'; //batch $route['addBatchDetails'] = 'Batch_Controller/addBatchDetails'; diff --git a/Apollo/api/application/controllers/Student_Controller.php b/Apollo/api/application/controllers/Student_Controller.php index ca3eed1e..10a7536b 100644 --- a/Apollo/api/application/controllers/Student_Controller.php +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -249,6 +249,44 @@ class Student_Controller extends REST_Controller { } } + + // add new course for student + public function insertStudentCourse_post(){ + $addStudent = $this->post('addStudent'); + $coursedata = $this->post('coursedata'); + $createdBy = $this->post('createdBy'); + $createdBranch = $this->post('loginBranch'); + + $reqCourse['StudentID'] = $addStudent; + $reqCourse['UniversityID'] = $coursedata['university']; + $reqCourse['CourseID'] = $coursedata['course']; + $reqCourse['BatchCode'] = $coursedata['batch']; + $reqCourse['DOJ'] = $coursedata['dateofjoining']; + $reqCourse['BranchID'] = $createdBranch; + $reqCourse['IsActive'] = '1'; + $reqCourse['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $reqCourse['CreatedOn'] = $date; +// print_r($reqCourse);exit(); + + + $studentAddCourse = $this->student_model->add_student_course( $addStudent , $reqCourse);// Check if the employee exist + if ($studentAddCourse) + { + $studentAddCourse['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentAddCourse, 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 + } + } + // add student public function addStudent_post() { $data = $this->post('data'); diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index f4282497..58bd5c28 100644 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -209,6 +209,29 @@ class Student_model extends CI_Model return $result; } + // add student course + public function add_student_course( $studID, $Arr) { + $this->db->select('*'); + $this->db->from(STUDENTCOURSE); + $this->db->where('StudentID', $studID); + $this->db->where('CourseID', $Arr['CourseID']); + + if($this->db->get()->first_row()) { + $result['addStuCourseStatus'] = false; + $result['message'] = "This Student Already exist for this course"; + } else { + $this->db->insert(STUDENTCOURSE, $Arr); + if ($this->db->affected_rows() == '1') { + $result['addStuCourseStatus'] = true; + $result['message'] = "Successfully Student Course Details Updated"; + } else { + $result['addStuCourseStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + return $result; + } + // add student public function add_student($Arr, $courseArr) { diff --git a/Apollo/assets/js/controllers/sessionCtrl.js b/Apollo/assets/js/controllers/sessionCtrl.js index bc362828..644a083b 100644 --- a/Apollo/assets/js/controllers/sessionCtrl.js +++ b/Apollo/assets/js/controllers/sessionCtrl.js @@ -19,7 +19,7 @@ app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', if (localDetail.localType == 'R004') { $scope.getLoginDash = 'superAdmin'; } else if (localDetail.localType == 'R003') { - $scope.getLoginDash = 'superAdmin'; + $scope.getLoginDash = 'Admin'; } else if (localDetail.localType == 'R002') { $scope.getLoginDash = 'staff'; } diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index b707824f..e31e1b6b 100644 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -45,6 +45,16 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", 'enrollmentid': '' }; + $scope.addStudentView = function () { + $scope.myModelCourse = { + 'university': '', + 'course': '', + 'batch': '', + 'dateofjoining': '', + 'enrollmentid': '' + }; + } + // 2017-11-23T00:00:00+0530 @@ -64,7 +74,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", $scope.currentDate = new Date(); $scope.getStudentList(); $scope.getUniversityList(); - // $scope.currentPage = 1; } else { } @@ -103,9 +112,9 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } $scope.setEditCourseId = function (id) { - $scope.list = false; $scope.getStudentCourseList(id); + $scope.currentStudentId = id; // $scope.getStudentCourseDetails(id); $scope.editCourseId = id; $scope.editId = -1; @@ -118,9 +127,83 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", $scope.editCourseId = -1; } - $scope.getStudentCourseList = function(studentId) { + $scope.cancelCourseDetails = function () { + $scope.getStudentCourseList($scope.currentStudentId); + // $scope.editId = -1; + // $scope.editCourseId = -1; + } + + $scope.addStudentCourse = function () { + $scope.myModelCourse = { + 'university': '', + 'course': '', + 'batch': '', + 'dateofjoining': '', + 'enrollmentid': '' + }; + $scope.list = false; + $scope.courseEdit = false; + $scope.courseAdd = true; + } + + // add student course + $scope.addCourseFORM = { + + submit: function (form, myModelCourse, p) { + // alert(); + var firstError = null; + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + 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(JSON.stringify(p.StudentID)); + var formate = "dd-MM-yyyy"; + // $scope.myModel.switchsetting = $scope.myModel.switchsetting === true ? 1 : 0; + // $scope.myModel.dateofbirth = $filter('date')(new Date($scope.myModel.dateofbirth), formate); + $scope.myModelCourse.dateofjoining = $filter('date')(new Date($scope.myModelCourse.dateofjoining), formate); + var req = { + method: 'POST', + url: apiPoint.url + 'insertStudentCourse/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + addStudent: p.StudentID, + coursedata: $scope.myModelCourse, + loginBranch: localDetails.localBranchID, + createdBy: localDetails.localUserID, + } + }; + $http(req).then(function (response) { + if (response.data.addStuCourseStatus == true) { + swal("Success!", response.data.message, "success"); + $scope.getStudentCourseList($scope.currentStudentId); + } else { + swal("Failed!", response.data.message, "error"); + $scope.getStudentCourseList($scope.currentStudentId); + } + }); + } + } + } + + // get Student Course List + $scope.getStudentCourseList = function (studentId) { + $scope.courseEditLoading = true; $scope.list = true; $scope.courseEdit = false; + $scope.courseAdd = false; var req = { method: 'POST', url: apiPoint.url + 'getStudentCourseList/', @@ -141,9 +224,12 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } + // get student particular course details : params : studentCourseID $scope.getStudentCourseDetails = function (studentcourseID) { + $scope.courseEditLoading = true; $scope.stucour = ''; $scope.list = false; + $scope.courseAdd = false; $scope.courseEdit = true; var req = { method: 'POST', @@ -159,15 +245,62 @@ 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.stucour = $scope.studentCourse[0]; } else { } }); } + // update sutdent course details + $scope.updateStudentCourseDetails = function (form, datas) { + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + 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(datas.DOJ); + var formate = "dd-MM-yyyy"; + 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); + alert(datas.DOJ); + var req = { + method: 'POST', + url: apiPoint.url + 'updateStudentCourseDetail/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: datas, + updatedBy: localDetails.localUserID, + } + }; + $http(req).then(function (response) { + if (response.data.updateStuCourseStatus) { + swal("Success!", response.data.message, "success"); + $scope.getStudentCourseList($scope.currentStudentId); + // $scope.editCourseId = false; + } else { + // $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + $scope.getStudentCourseList($scope.currentStudentId); + } + }); + } + } + $scope.universityData = ''; - $scope.getUniversityList = function () { var empListreq = { method: 'POST', @@ -187,11 +320,17 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } - $scope.onSlecetUnivEdit = function(id) { + $scope.onSlecetUnivEdit = function (id) { $scope.myModelCourse.university = id; $scope.onSlecetUniv(); } + $scope.onChangeSlecetUnivEdit = function (id) { + $scope.myModelCourse.university = id; + $scope.onSlecetUniv(); + $scope.stucour.CourseID = ''; + $scope.stucour.BatchCode = ''; + } $scope.courseLoading = false; $scope.onSlecetUniv = function () { $scope.courseData = ''; @@ -349,7 +488,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } - // update check mobile exist + // update check mobile exist $scope.updateCheckMobileExist = function (p) { var checkReq = { method: 'POST', @@ -394,11 +533,11 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } }); } - + // update student details $scope.updateStuDetails = function (form, p) { var firstError = null; - if (form.$invalid) { + if (form.$invalid) { var field = null, firstError = null; for (field in form) { if (field[0] != '$') { @@ -412,7 +551,7 @@ 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 { + } else { // alert(p.DOB); var formate = "dd-MM-yyyy"; var checkDOB = $filter('date')(new Date(p.DOB), formate); @@ -442,49 +581,6 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } } - $scope.updateStudentCourseDetails = function (form, datas) { - if (form.$invalid) { - var field = null, firstError = null; - for (field in form) { - if (field[0] != '$') { - if (firstError === null && !form[field].$valid) { - firstError = form[field].$name; - } - if (form[field].$pristine) { - form[field].$dirty = true; - } - } - } - 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 { - var formate = "dd-MM-yyyy"; - 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/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: datas, - updatedBy: localDetails.localUserID, - } - }; - $http(req).then(function (response) { - if (response.data.updateStuCourseStatus = true) { - swal("Success!", response.data.message, "success"); - $scope.getStudentList(); - $scope.editCourseId = -1; - } else { - // $scope.ldloading1[loading.replace('-', '_')] = false; - swal("Failed!", response.data.message, "error"); - } - }); - } - } + }]); diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index b8e5543d..d4f08409 100644 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -61,6 +61,104 @@ + + + +
  • + +
    +
    + +
    +
    + CALL TRACKING +
    +
    +
    + +
  • + + + + + + + + + + + + + + diff --git a/Apollo/assets/views/student/editStudentCourseDetails.html b/Apollo/assets/views/student/editStudentCourseDetails.html index 60c38064..14fb0db2 100644 --- a/Apollo/assets/views/student/editStudentCourseDetails.html +++ b/Apollo/assets/views/student/editStudentCourseDetails.html @@ -1,64 +1,67 @@ -
    -
    +
    +
    +
    + +

    Fetching ...

    +
    -
    - -

    Fetching ...

    -
    -
    -
    - - Course Details - - -
    - - - - - - - - - - - - - - - - - - - -
    University - Course - Batch - Date of Join -
    {{s.UniversityName}}{{s.CourseName}}{{s.BatchName}}{{s.DOJ}}Edit
    -
    -
    -
    - + -
    - - - - -
    +
    + + + +
    +
    + + + + University is Required +
    + +
    + + +
    + fetching... +
    +
    + +
    + Course is required + +
    + +
    + + +
    + fetching... +
    +
    + +
    + Batch is required + +
    +
    +
    +
    + + + Enrollment ID required +
    + +
    + + + + + Date of Joining required +
    +
    +
    +
    +
    + + +
    +
    +
    + + +
    +
    - +
    \ No newline at end of file diff --git a/Apollo/assets/views/student/student_details.html b/Apollo/assets/views/student/student_details.html index 9cb1ab15..06dc3588 100644 --- a/Apollo/assets/views/student/student_details.html +++ b/Apollo/assets/views/student/student_details.html @@ -65,7 +65,7 @@ - + @@ -102,7 +102,7 @@ - +
    @@ -468,14 +468,21 @@ /> Enrollment ID required
    - +
    - + .dropdown-menu { + position: relative; + /*top: -225px !important;*/ + } + + + placeholder="Select Date of Joining" close-text="Close" required="required" datepicker-position="top"/> + Date of Joining required
    @@ -492,8 +499,8 @@
    -
     {{ myModel | json }}
    -
     {{ myModelCourse | json }}
    +