diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index fdcfb814..ea53accc 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -127,6 +127,7 @@ $route['insertStudentCourse'] = 'Student_Controller/insertStudentCourse'; $route['insertStudentImg'] = 'Student_Controller/insertStudentImg'; $route['updateStudentImgDetails'] = 'Student_Controller/updateStudentImgDetails'; $route['getBranchListDetails'] = 'Student_Controller/getBranchListDetails'; +$route['getBranchActiveStatusforStuAdd'] = 'Student_Controller/getBranchActiveStatusforStuAdd'; //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 664ee568..d918afb2 100755 --- a/Apollo/api/application/controllers/Student_Controller.php +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -57,6 +57,28 @@ class Student_Controller extends REST_Controller { } } + // check the branch active for add a new student + public function getBranchActiveStatusforStuAdd_post() { + $reqData = $this->post('data'); + $branchId = $reqData['localBranchID']; + // print_r($reqData);exit(); + $checkBranchActiveStatis = $this->student_model->getBranchActiveStatusforStuAdd($branchId);// Get Branch list + if ($checkBranchActiveStatis) + { + $checkBranchActiveStatis['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($checkBranchActiveStatis, 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 getStudentList_post() { $reqData = $this->post('data'); $searchReqData = $this->post('search'); diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index 863c96e1..3788ca62 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -128,7 +128,7 @@ class Employee_model extends CI_Model $this->db->where('t2.StaffID', $EmpId); $this->db->where('t2.IsActive', 1); $this->db->join('' . BRANCH . ' as t3', 't2.BranchCode = t3.BranchCode', 'LEFT'); - $this->db->where('t3.IsActive', 1); + // $this->db->where('t3.IsActive', 1); // $this->db->join('T_StaffDetails as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $branchDetails = $this->db->get(); $result['branchStatus'] = true; diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index 65a9b0b4..f254861b 100755 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -17,7 +17,7 @@ class Student_model extends CI_Model public function get_branch_list() { $this->db->select('t1.BranchCode,t1.BranchName'); $this->db->from('' . BRANCH . ' as t1'); - $this->db->where('t1.IsActive', 1); + // $this->db->where('t1.IsActive', 1); $branchDetails = $this->db->get(); $checkArr = $branchDetails->result(); if (count($checkArr) > 0) { @@ -29,6 +29,24 @@ class Student_model extends CI_Model return $result; } + // check the branch active status for student add + public function getBranchActiveStatusforStuAdd($branchId){ + $this->db->select('t1.IsActive'); + $this->db->from('' . BRANCH . ' as t1'); + $this->db->where('BranchCode', $branchId); + $statusDetails = $this->db->get()->first_row(); + // echo $statusDetails->IsActive;exit(); + $result['branch_active_status'] = $statusDetails->IsActive; + return $result; + // if (count($checkArr) > 0) { + // $result['branDetailstatus'] = true; + // $result['branch_details'] = $branchDetails->result(); + // } else { + // $result['branDetailstatus'] = false; + // } + // return $result; + } + // get student list based on login user public function get_student_list($loginUserId, $loginUserBranchId, $loginUserType, $getSearchData) @@ -446,7 +464,9 @@ if($StuStatus == '' ){ // add student public function add_student($Arr, $courseArr, $imagename, $imageSource, $size) - { + { + if($this->getBranchActiveStatusforStuAdd($courseArr['BranchID']) === '1'){ + if( $imageSource == '') { // add employee without image $imageNameDb = 'default.jpeg'; $Arr['ProfilePicPath'] = "student/".$imageNameDb; @@ -533,6 +553,11 @@ if($StuStatus == '' ){ $result['message'] = "Something went wrong.please try again"; } } + } + }else { + $result['addStudentStatus'] = false; + $result['message'] = "Cannot create a new Student for In-Active Branch"; + } return $result; } diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index 65a03902..8e7a1a65 100755 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -56,6 +56,31 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }; $scope.addStudentView = function () { + // check the local branch is active for add a new student for this branch + var checkBranchActiveForStuAdd = { + method: 'POST', + url: apiPoint.url + 'getBranchActiveStatusforStuAdd/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: localDetails + } + }; + $http(checkBranchActiveForStuAdd).then(function (response) { + if (response.data) { + var checkStatus = response.data.branch_active_status; + if(checkStatus == "0"){ + $scope.inActiveBranchStatus = true; + swal(" ", "Cannot create a new Student for In-Active Branch", "warning"); + }else { + // $scope.inActiveBranchStatus = false; + } + } else { + } + }); + + // $scope.myModelCourseAdd = { // 'university': '', // 'course': '', @@ -971,7 +996,34 @@ app.controller('studentSuperAdminCtrl', ["$scope", "toaster", "$filter", "ngTabl 'enrollmentid': '' }; + $scope.inActiveBranchStatus = false; $scope.addStudentView = function () { + // check the local branch is active for add a new student for this branch + // alert(); + var checkBranchActiveForStuAdd = { + method: 'POST', + url: apiPoint.url + 'getBranchActiveStatusforStuAdd/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: localDetails + } + }; + $http(checkBranchActiveForStuAdd).then(function (response) { + if (response.data) { + var checkStatus = response.data.branch_active_status; + if(checkStatus == "0"){ + $scope.inActiveBranchStatus = true; + swal(" ", "Cannot create a new Student for In-Active Branch", "warning"); + }else { + // $scope.inActiveBranchStatus = false; + } + } else { + } + }); + + // $scope.myModelCourseAdd = { // 'university': '', // 'course': '', @@ -1552,6 +1604,7 @@ $scope.myUnivSearch = ""; } else { // $scope.ldloading1[loading.replace('-', '_')] = false; swal(" ", data.message, "error"); + $scope.disableButton = false; } }); } else { @@ -1580,7 +1633,7 @@ $scope.myUnivSearch = ""; // $scope.tabActive('tabactive1'); } else { - // $scope.disableButton = false; + $scope.disableButton = false; swal(" ", response.data.message, "error"); } }); diff --git a/Apollo/assets/views/student/student_details_SuperAdmin.html b/Apollo/assets/views/student/student_details_SuperAdmin.html index 5a981578..a194ba92 100644 --- a/Apollo/assets/views/student/student_details_SuperAdmin.html +++ b/Apollo/assets/views/student/student_details_SuperAdmin.html @@ -271,7 +271,7 @@ - +