From d0d68cc4c94ca75d77e49e162a6c847ae8d9b54a Mon Sep 17 00:00:00 2001 From: resicovenba Date: Fri, 9 Feb 2018 15:09:31 +0530 Subject: [PATCH] inactive branch details changes:kdk --- .../controllers/Student_Controller.php | 23 +- .../api/application/models/Student_model.php | 78 ++- Apollo/assets/js/controllers/studentCtrl.js | 153 ++++- .../assets/views/student/student_details.html | 574 +++++++++++++++++- 4 files changed, 794 insertions(+), 34 deletions(-) diff --git a/Apollo/api/application/controllers/Student_Controller.php b/Apollo/api/application/controllers/Student_Controller.php index d918afb2..1d578cf9 100755 --- a/Apollo/api/application/controllers/Student_Controller.php +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -128,7 +128,8 @@ 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 + $reqData = $this->post('updatedBy'); + $studentCourse = $this->student_model->get_student_course_list( $studentID, $reqData );// Check if the employee exist if ($studentCourse) { $studentCourse['status'] = REST_Controller::HTTP_OK; @@ -387,6 +388,26 @@ class Student_Controller extends REST_Controller { } } + + public function getExistingStudentDetails_post() { + $data = $this->post('data'); + $reqDetails = $this->post('check'); + $checkExisRes = $this->student_model->get_exist_stu_details( $data, $reqDetails );// Check if the employee exist + if ($checkExisRes) + { + $checkExisRes['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($checkExisRes, 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 new course for student public function insertStudentCourse_post(){ diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index f2caf1db..8c3e6bdb 100755 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -84,7 +84,7 @@ class Student_model extends CI_Model $Batch=''; $StuStatus = $getSearchData['Status']; - if($StuStatus == '' ){ + if($StuStatus == ''){ $subQuery = "SELECT S.* FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON @@ -165,7 +165,7 @@ class Student_model extends CI_Model $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('BranchCode', $loginUserBranchId); - $this->db->group_by('user_id'); + // $this->db->group_by('user_id'); $this->db->order_by('CreatedOn', 'DESC'); $stuDetails = $this->db->get(); @@ -187,8 +187,8 @@ class Student_model extends CI_Model // $this->db->where('t2.UniversityID', $getSearchData["University"]); // $this->db->where('t2.CourseID', $getSearchData["Course"]); - $University = $getSearchData['University']; - $Course = $getSearchData['Course']; + $University = $getSearchData['University']; + $Course = $getSearchData['Course']; // $Batch = $getSearchData['Batch']; $Batch=''; $StuStatus = $getSearchData['Status']; @@ -315,12 +315,14 @@ class Student_model extends CI_Model return $results; } - public function get_student_course_list($studentId) { + public function get_student_course_list($studentId, $req) { + // echo $req['localBranchID'];exit(); $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t3.Specilization1,t3.Specilization2,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('t1.BranchID', $req['localBranchID']); $this->db->where('StudentID', $studentId); $courseDetails = $this->db->get(); $checkArr = $courseDetails->result(); @@ -399,6 +401,32 @@ class Student_model extends CI_Model return $result; } + public function get_exist_stu_details($data, $reqArr) { + // echo $data;exit(); + + $this->db->select('t0.*'); + $this->db->from('' . STUDENTS . ' as t0'); + $this->db->where('t0.StudentID', $data); + $personalDetails = $this->db->get()->result(); + + $this->db->select('t1.*,t2.UniversityName,t3.CourseName,t3.Specilization1,t3.Specilization2,t4.BatchName, t5.BranchName'); + // $this->db->from('' . STUDENTS . ' as t0'); + $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->join('' . BRANCH . ' as t5', 't5.BranchCode = t1.BranchID', 'LEFT'); + $this->db->where('t1.StudentID', $data); + // $this->db->group_by('t1.StudentID'); + $courseDetails = $this->db->get()->result(); + + $result['personalDetails'] = $personalDetails; + $result['courseDetails'] = $courseDetails; + $result['existingStudentDetailsStatus'] = true; + + return $result; + } + // check exist public function check_exist($data, $checkData) { @@ -419,14 +447,25 @@ class Student_model extends CI_Model $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $data); - if ($this->db->get()->first_row()) { + $details = $this->db->get()->result(); + // echo count($details);exit(); + if (count($details) > 0) { + // print_r($details);exit(); + // echo $details[0]->StudentID;exit(); + $datas['studentId'] = $details[0]->StudentID; + $datas['type'] = 'R001'; + $result['details'] = $datas; $result['existMobile'] = true; $result['message'] = "This Mobile Number is already exist!"; } else { $this->db->select('*'); $this->db->from(LOGIN); $this->db->where('MobileNumber', $data); - if ($this->db->get()->first_row()) { + $details1 = $this->db->get()->result(); + if ( $details1 > 0) { + $datas['studentId'] = $details1[0]->StaffID; + $datas['type'] = $details1[0]->ListCode; + $result['details'] = $datas; $result['existMobile'] = true; $result['message'] = "This Mobile Number is already exist!"; } else { @@ -452,10 +491,12 @@ class Student_model extends CI_Model // 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->getBranchActiveStatusforStuAdd($Arr['BranchID'])['branch_active_status'] === '1'){ + $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; @@ -470,6 +511,12 @@ class Student_model extends CI_Model $result['message'] = "Something went wrong.please try again"; } } + }else{ + $result['addStuCourseStatus'] = false; + $result['message'] = "Cannot able create a New Cource for a Student, in In-Active Branch"; + } + + return $result; } @@ -568,7 +615,7 @@ class Student_model extends CI_Model } }else { $result['addStudentStatus'] = false; - $result['message'] = "Cannot create a new Student for In-Active Branch"; + $result['message'] = "Please, Cannot able create a new Student for In-Active Branch"; } return $result; @@ -635,8 +682,6 @@ class Student_model extends CI_Model // print_r($empArr); // print_r($updateFor); // exit(); - - $this->db->select('*'); $this->db->from(STUDENTS); $this->db->where('MobileNumber', $empArr['MobileNumber']); @@ -656,10 +701,7 @@ class Student_model extends CI_Model $this->db->where('StudentID', $updateFor); $this->db->update(STUDENTS, $empArr); if ($this->db->affected_rows() == '1') { - - - - $mobile = $empArr['MobileNumber']; + $mobile = $empArr['MobileNumber']; $email = $empArr['EmailID']; $active = $empArr['IsActive']; $updatedBy = $empArr['UpdatedBy']; diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index 8e7a1a65..24345fbc 100755 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -323,7 +323,8 @@ $scope.studentListLength = 0; 'Content-Type': 'application/json' }, data: { - studentID: studentId + studentID: studentId, + updatedBy: localDetails, } }; $http(req).then(function (response) { @@ -499,6 +500,8 @@ $scope.studentListLength = 0; }); } + $scope.existingStudentView = false; + $scope.existingStudentId = ''; // check mobile number existing $scope.checkMobileExist = function () { var checkReq = { @@ -514,13 +517,133 @@ $scope.studentListLength = 0; }; $http(checkReq).then(function (response) { if (response.data.existMobile == true) { - swal("Warning!", response.data.message, "warning"); - $scope.myModel.primaryPhone = ''; + if(response.data.details.type === 'R001'){ + swal("Warning!", response.data.message, "warning"); + $scope.myModel.primaryPhone = ''; + // $scope.existingStudentView = true; + // $scope.existingStudentId = response.data.details.studentId; + }else if (response.data.details.type === 'R002' || response.data.details.type === 'R003'){ + swal("Warning!", response.data.message, "warning"); + $scope.myModel.primaryPhone = ''; + } else { + swal("Warning!", response.data.message, "warning"); + $scope.myModel.primaryPhone = ''; + } + // swal({ + // title: 'Are you sure?', + // text: "You won't be able to revert this!", + // type: 'warning', + // showCancelButton: true, + // confirmButtonColor: '#3085d6', + // cancelButtonColor: '#d33', + // confirmButtonText: 'Yes, delete it!' + // }).then((result) => { + // if (result.value) { + // swal( + // 'Deleted!', + // 'Your file has been deleted.', + // 'success' + // ) + // } + // }) + // swal("Warning!", response.data.message + response.data.details.studentId, "warning"); + // $scope.myModel.primaryPhone = ''; } else { } }); } + $scope.getExistStudentDetails = function() { + // alert($scope.existingStudentId); + var checkExisReq = { + method: 'POST', + url: apiPoint.url + 'getExistingStudentDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.existingStudentId, + reqDetails: localDetails + } + }; + $http(checkExisReq).then(function (response) { + if (response.data.existingStudentDetailsStatus == true) { + $scope.existingStuPersonalDetails = response.data.personalDetails[0]; + $scope.existingStuCourseDetails = response.data.courseDetails; + } else { + + } + }); + } + + $scope.cancelExisStudentView = function() { + $scope.existingStudentView = false; + } + + + // add student course for existing student + $scope.addCourseExistingStudent= { + + submit: function (form, myModelCourse, p) { + 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)); + // alert(JSON.stringify(myModelCourse)); + var formate = "dd-MM-yyyy"; + $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(" ","Student course added successfully. ", "success"); + $state.go($state.current, {}, { reload: true }); + // $scope.getStudentCourseList($scope.currentStudentId); + } else { + swal(" ", response.data.message, "error"); + // $scope.getStudentCourseList($scope.currentStudentId); + } + }); + } + }, + cancel: function() { + $scope.myModelCourse = { + 'university': '', + 'course': '', + 'batch': '', + 'dateofjoining': '', + 'enrollmentid': '' + }; + } + + } + + + // check emailId existing $scope.checkEmailExist = function () { var checkReq = { @@ -630,7 +753,7 @@ $scope.studentListLength = 0; headers: { 'Content-Type': undefined, 'Process-Data': false }, }).success(function (data) { if (data.addStudentStatus == true) { - swal(" ", "Student picture added successfully.", "success"); + swal(" ", "Student added successfully.", "success"); $scope.disableButton = false; $state.go($state.current, {}, { reload: true }); } else { @@ -842,7 +965,7 @@ $scope.studentListLength = 0; } }; $http(req).then(function (response) { - if (response.data.updateStuStatus = true) { + if (response.data.updateStuStatus === true) { swal(" ", "Updated successfully.", "success"); $scope.getStudentList(); $scope.editId = -1; @@ -863,7 +986,7 @@ $scope.studentListLength = 0; transformRequest: angular.identity, headers: { 'Content-Type': undefined, 'Process-Data': false }, }).success(function (data) { - if (data.updateStuStatus == true) { + if (data.updateStuStatus === true) { swal(" ","Updated successfully." , "success"); $scope.getStudentList(); $scope.editId = -1; @@ -1231,7 +1354,9 @@ $scope.myUnivSearch = ""; 'Content-Type': 'application/json' }, data: { - studentID: studentId + studentID: studentId, + updatedBy: localDetails, + } }; $http(req).then(function (response) { @@ -1815,14 +1940,14 @@ $scope.myUnivSearch = ""; updatedBy: localDetails.localUserID, } }; - $http(req).then(function (response) { - if (response.data.updateStuStatus = true) { - swal(" ", "Updated successfully.", "success"); + $http(req).then(function (data) { + if (data.updateStuStatus === true) { + swal("", "Updated successfully.", "success"); $scope.getStudentList(); $scope.editId = -1; } else { // $scope.ldloading1[loading.replace('-', '_')] = false; - swal(" ", response.data.message, "error"); + swal("", data.message, "error"); } }); } else { @@ -1837,13 +1962,13 @@ $scope.myUnivSearch = ""; transformRequest: angular.identity, headers: { 'Content-Type': undefined, 'Process-Data': false }, }).success(function (data) { - if (data.updateStuStatus == true) { - swal(" ", "Updated successfully.", "success"); + if (data.updateStuStatus === true) { + swal("", "Updated successfully.", "success"); $scope.getStudentList(); $scope.editId = -1; } else { // $scope.ldloading1[loading.replace('-', '_')] = false; - swal(" ", data.message, "error"); + swal("", data.message, "error"); } }); } diff --git a/Apollo/assets/views/student/student_details.html b/Apollo/assets/views/student/student_details.html index 8b8ce791..3c1cf114 100755 --- a/Apollo/assets/views/student/student_details.html +++ b/Apollo/assets/views/student/student_details.html @@ -248,7 +248,7 @@ -
+
@@ -798,6 +798,578 @@
+
+ +
+
+
+ +
+
+
+
+ + Personal Details + +
+
+
+ +
+
+
+ + +
+ +
+ +
+ +
+
+
+ + + Mobile Number is required. + Enter a Valid Phone Number +
+
+ + + First Name is required + Invalid First Name +
+
+ + + Last Name is required + Invalid Last Name +
+
+
+
+ + + Father Name is required + Invalid Father Name +
+
+ + + + Mother Name is required + Invalid Mother Name +
+
+ + + Email is required. + Please, enter a valid email address. +
+
+
+
+ + + Alternate Mobile Number is required. + Enter a Valid Phone Number +
+ +
+
+ + + + + Date of Birth is required. + Enter a Valid Date of Birth +
+
+
+ +
+ + + + + Gender is required. + +
+
+
+
+
+ + + Permanent Address is required +
+
+ + + Current Address is required +
+
+ + + Aadhar Number is required. + Enter a Valid Aadhar Number +
+
+
+ +
+
+
+ + + Aadhar Number is required. + Enter a Valid Details +
+
+ + + Aadhar Number is required. + Enter a Valid Details +
+
+
+
+ + + + Invalid Caste Name +
+
+ + + + Invalid Category Name +
+
+ +
+ +
+ + + + Invalid Religion Name +
+
+ + + + Invalid Nationality Name +
+
+ + + + Enter a Valid Qualification +
+
+
+ +
+ + + + Invalid Occupation +
+
+ + + + Invalid Designation +
+
+ + + Invalid Company +
+
+
+
+ + + Invalid Referred By +
+
+ + + Refer's Mobile Number is required. + Enter a Valid Phone Number +
+
+ + + Max 100 Characters. + +
+
+
+
+ +
+ +
+
+ +
+
+
+ + + Max 100 Characters. + De-Active Comments is required +
+ +
+ + + +
+ +
+ + Course Details + + + + + + + + + + + + + + + + + + + + + + + + +
University + Course + Batch + Date of Joining + Status + Enrolled Branch +
{{s.UniversityName}}{{s.CourseName}}{{s.BatchName}}{{s.DOJ}}Active + In-Active{{s.BranchName}}
+
+ +
+
+
+ +
+
+
+
+ + Add New Cource + + +
+
+
+ + + + University is Required +
+ +
+ + +
+ fetching... +
+
+ +
+ Course is required + +
+ +
+ + +
+ fetching... +
+
+ +
+ Batch is required + +
+
+ +
+
+ +
+ + + + + Invalid Specilization 1 + + +
+
+ + + + + Invalid Specilization 2 + + +
+
+ +
+ +
+ + + + + Invalid Specilization 1 + + +
+
+ + + + + Invalid Specilization 2 + + +
+
+
+ + + Enrollment ID is required +
+
+
+ + +
+ + + + + Date of Joining is required +
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+