diff --git a/Apollo/api/application/config/constants.php b/Apollo/api/application/config/constants.php index e40e8dde..e676e52d 100644 --- a/Apollo/api/application/config/constants.php +++ b/Apollo/api/application/config/constants.php @@ -100,6 +100,7 @@ defined('LEAD_DETAILS') OR define('LEAD_DETAILS','T_Lead_Details'); defined('LEAD_TRACKING') OR define('LEAD_TRACKING','T_Lead_Tracking'); defined('LEAD_TRACKING_FOLLOWUP') OR define('LEAD_TRACKING_FOLLOWUP','T_Lead_Tracking_Followup'); defined('PICK_LIST_DETAILS') OR define('PICK_LIST_DETAILS','T_PickListDetails'); +defined('BATCH') OR define('BATCH','T_BatchMaster'); //end of database table name diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 5d31a295..e68cdbe8 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -93,8 +93,9 @@ $route['updateActivityStatus'] = 'University_Controller/updateActivityStatus'; $route['changePassword'] = 'Login_Controller/changePassword'; - - +// student +$route['insertStudent'] = 'Student_Controller/addStudent'; +$route['getCourseBatchForUniv'] = 'Student_Controller/getCourseBatch'; diff --git a/Apollo/api/application/controllers/Student_Controller.php b/Apollo/api/application/controllers/Student_Controller.php new file mode 100644 index 00000000..dac2b884 --- /dev/null +++ b/Apollo/api/application/controllers/Student_Controller.php @@ -0,0 +1,112 @@ +methods['addStudent_post']['limit'] = 100; + // load the employee model + $this->load->model('Student_model', 'student_model'); + + } + + public function getCourseBatch_post() { + $data = $this->post('data'); + $getCourseBatchListDetails = $this->student_model->get_courseBatch_list($data);// Check if the employee exist + if ($getCourseBatchListDetails) + { + $getCourseBatchListDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getCourseBatchListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list 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'); + $createdBy = $this->post('createdBy'); + $createdBranch = $this->post('loginBranch'); + + $req['Firstname'] = $data['firstname']; + $req['Lastname'] = $data['lastname']; + $req['Fathername'] = $data['fathername']; + $req['EmailID'] = $data['emailId']; + $req['MotherName'] = $data['mothername']; + $req['MobileNumber'] = $data['primaryPhone']; + $req['AlternateNumber'] = $data['secondaryPhone']; + $req['Gender'] = $data['gender']; + $req['DOB'] = $data['dateofbirth']; + $req['PresentAddress'] = $data['address2']; + $req['PermanentAddress'] = $data['address1']; + $req['AadharNumber'] = $data['aadharNumber']; + $req['OtherID'] = $data['otherId']; + $req['OtherIDDetails'] = $data['otherIdDetails']; + $req['Caste'] = $data['caste']; + $req['Category'] = $data['category']; + $req['Religion'] = $data['religion']; + $req['Nationality'] = $data['nationality']; + $req['Occupation'] = $data['occupation']; + $req['Designation'] = $data['designation']; + $req['Companyname'] = $data['companyname']; + $req['ReferredBy'] = $data['referredby']; + $req['ReferersMobileNumber'] = $data['referredmobilenumber']; + $req['PreQualification'] = $data['prequalification']; + $req['IsActive'] = $data['switchsetting']; + + $req['CreatedBy'] = $createdBy; + $date = date('Y-m-d H:i:s'); + $req['CreatedOn'] = $date; + print_r($req);exit(); + $studentAdd = $this->student_model->add_student( $req );// Check if the employee exist + if ($studentAdd) + { + $studentAdd['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($studentAdd, 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 + } + } + + +} diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php new file mode 100644 index 00000000..d9ebc1d9 --- /dev/null +++ b/Apollo/api/application/models/Student_model.php @@ -0,0 +1,86 @@ +db->select('C.CourseID, C.CourseName'); + $this->db->from(COURSE.' as C'); + $this->db->where('UniversityID',$univId); + $this->db->where('IsActive',1); + $courseDetails = $this->db->get(); + if($courseDetails->result()){ + $this->db->select('B.BatchCode, B.BatchName'); + $this->db->from(BATCH.' as B'); + $this->db->where('UniversityID',$univId); + $this->db->where('IsActive',1); + $batchDetails = $this->db->get(); + if( $batchDetails->result()) { + $result['courseStatus'] = true; + $result['course_details'] = $courseDetails->result(); + $result['batch_details'] = $batchDetails->result(); + } else { + $result['courseStatus'] = false; + $result['message'] = "No records found!"; + } + } + else { + $result['courseStatus'] = false; + $result['message'] = "No records found!"; + } + + return $result; + } + + // add student + public function add_employee($empArr, $createdBy) + { + $this->db->insert(STAFF, $empArr); + if ($this->db->affected_rows() == '1') { + $branchArr['StaffID'] = $empArr['StaffID']; + $branchArr['BranchCode'] = $empArr['BranchCode']; + $branchArr['IsActive'] = $empArr['IsActive']; + $branchArr['CreatedBy'] = $createdBy; + $this->db->insert(STAFF_BRANCH, $branchArr); + if ($this->db->affected_rows() == '1') { + $loginArr['StaffID'] = $empArr['StaffID']; + $loginArr['ListCode'] = $empArr['ListCode']; + $loginArr['MobileNumber'] = $empArr['MobileNumber']; + $loginArr['EmailId'] = $empArr['EmailID']; + $loginArr['IsActive'] = $empArr['IsActive']; + $loginArr['CreatedBy'] = $createdBy; + $loginArr['Password'] = ENCR_PASSWORD; + $this->db->insert(LOGIN, $loginArr); + if ($this->db->affected_rows() == '1') { + $result['addEmpStatus'] = true; + $result['message'] = "Successfully employee details added"; + } else { + $result['addEmpStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } else { + $result['addEmpStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } else { + $result['addEmpStatus'] = 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 f92761cc..657a899d 100644 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -32,16 +32,11 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", 'occupation': '', 'designation': '', 'companyname': '', - 'referredby': '', + 'referredby': '', 'referredmobilenumber': '', 'switchsetting': true, }; - var data = ''; - $scope.roleDetails = ''; - $scope.branchDetails = ''; - $scope.employeeDetails = ''; - $scope.loader = false; - $scope.emptyData; + // 2017-11-23T00:00:00+0530 // sorting function for table params $scope.sort = function (keyname) { @@ -57,6 +52,8 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", $scope.init = function () { if (localDetail != null) { $scope.currentDate = new Date(); + $scope.getUniversityList(); + // $scope.currentPage = 1; } else { } @@ -70,27 +67,71 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", } $scope.setEditBranchId = function (id) { - $scope.getEmpBranchDetails(id); $scope.editBranchId = id; $scope.editId = -1; $scope.branchEditLoading = true; } $scope.cancel = function () { - $scope.getEmployeeList(); $scope.editId = -1; $scope.editBranchId = -1; } - $scope.empBranchDetails = ''; - $scope.empRoleDetail = ''; + + $scope.universityData = ''; - // add empolyee + $scope.getUniversityList = function () { + var empListreq = { + method: 'POST', + url: apiPoint.url + 'getUniversity/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: localDetails + } + }; + $http(empListreq).then(function (response) { + if (response.data.univList) { + $scope.universityData = response.data.university_details; + } else { + } + }); + } + + $scope.courseData = ''; + $scope.batchData = ''; + $scope.courseLoading = false; + $scope.onSlecetUniv = function() { + $scope.myModel.course= ''; + $scope.myModel.batch= ''; + $scope.courseLoading = true; + var univListreq = { + method: 'POST', + url: apiPoint.url + 'getCourseBatchForUniv/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.myModel.university + } + }; + $http(univListreq).then(function (response) { + if (response.data.courseStatus) { + $scope.courseLoading = false; + $scope.courseData = response.data.course_details; + $scope.batchData = response.data.batch_details; + } else { + $scope.courseLoading = false; + } + }); + } + + // add student $scope.studentFORM = { submit: function (form, myModel) { var firstError = null; if (form.$invalid) { - alert('error'); var field = null, firstError = null; for (field in form) { if (field[0] != '$') { @@ -105,30 +146,29 @@ 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('ok'); - // 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.myModel.dateofjoining = $filter('date')(new Date($scope.myModel.dateofjoining), formate); - // var req = { - // method: 'POST', - // url: apiPoint.url + 'insertEmployee/', - // headers: { - // 'Content-Type': 'application/json' - // }, - // data: { - // data: $scope.myModel, - // createdBy: localDetails.localUserID, - // } - // }; - // $http(req).then(function (response) { - // if (response.data.addEmpStatus == true) { - // swal("Success!", response.data.message, "success"); - // $state.go($state.current, {}, { reload: true }); - // } else { - // swal("Failed!", response.data.message, "error"); - // } - // }); + 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); + var req = { + method: 'POST', + url: apiPoint.url + 'insertStudent/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.myModel, + loginBranch: localDetails.localBranchID, + createdBy: localDetails.localUserID, + } + }; + $http(req).then(function (response) { + if (response.data.addEmpStatus == true) { + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, { reload: true }); + } else { + swal("Failed!", response.data.message, "error"); + } + }); } }, reset: function (form) { diff --git a/Apollo/assets/views/student/student_details.html b/Apollo/assets/views/student/student_details.html index 22b28719..e22a626d 100644 --- a/Apollo/assets/views/student/student_details.html +++ b/Apollo/assets/views/student/student_details.html @@ -116,37 +116,31 @@ -
{{ myModel | json }}
+