diff --git a/Apollo/api/application/controllers/University_Controller.php b/Apollo/api/application/controllers/University_Controller.php index e8d9fec0..852dd715 100644 --- a/Apollo/api/application/controllers/University_Controller.php +++ b/Apollo/api/application/controllers/University_Controller.php @@ -39,8 +39,45 @@ class University_Controller extends REST_Controller { $loginUserId = $reqData['localUserID']; $loginUserBranchId = $reqData['localBranchID']; $loginUserType = $reqData['localType']; + $getUniversityListDetails = $this->university_model->get_university_list();// Check if the employee exist + if ($getUniversityListDetails) + { + $getUniversityListDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getUniversityListDetails, 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 + } - print_r($reqData);exit(); + } + + public function updateUniversityDetail_post() { + + $reqData = $this->post('data'); + $loginUserId = $reqData['localUserID']; + $loginUserBranchId = $reqData['localBranchID']; + $loginUserType = $reqData['localType']; + $getUniversityListDetails = $this->university_model->get_university_list();// Check if the employee exist + if ($getUniversityListDetails) + { + $getUniversityListDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getUniversityListDetails, 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 + } } } diff --git a/Apollo/api/application/models/University_model.php b/Apollo/api/application/models/University_model.php index f3f937a5..a06aa5ac 100644 --- a/Apollo/api/application/models/University_model.php +++ b/Apollo/api/application/models/University_model.php @@ -18,6 +18,22 @@ class University_model extends CI_Model * get University Details */ - // get single employee details + // get university list + + public function get_university_list() { + $this->db->select('*'); + $this->db->order_by('CreatedOn', 'DESC'); + $this->db->from(UNIVERSITY); + $univDetails = $this->db->get(); + $universityDetails = $univDetails->result(); + if (count($universityDetails) > 0) { + $results['univList'] = true; + $results['university_details'] = $universityDetails; + } else { + $results['univList'] = false; + $results['message'] = 'No record found'; + } + return $results; + } } \ No newline at end of file diff --git a/Apollo/assets/js/controllers/universityCtrl.js b/Apollo/assets/js/controllers/universityCtrl.js index e9718b29..c9b6fc40 100644 --- a/Apollo/assets/js/controllers/universityCtrl.js +++ b/Apollo/assets/js/controllers/universityCtrl.js @@ -19,6 +19,12 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams $scope.getUniversityList(); } + // sorting function for table params + $scope.sort = function (keyname) { + $scope.sortKey = keyname; //set the sortKey to the param passed + $scope.reverse = !$scope.reverse; //if true make it false and vice versa + } + $scope.getUniversityList = function () { $scope.loader = true; var empListreq = { @@ -32,16 +38,67 @@ app.controller('universityCtrl', ["$scope", "toaster", "$filter", "ngTableParams } }; $http(empListreq).then(function (response) { - // if (response.data.employeeList) { - // $scope.loader = false; - // $scope.emptyData = true; - // $scope.data = response.data.employees_details; - // } else { - // $scope.loader = false; - // $scope.emptyData = false; - // } + if (response.data.univList) { + $scope.loader = false; + $scope.emptyUniversity = true; + $scope.data = response.data.university_details; + } else { + $scope.loader = false; + $scope.emptyUniversity = false; + } }); } + $scope.setEditId = function (id) { + // alert(id); + $scope.editId = id; + } + + $scope.cancel = function () { + $scope.getUniversityList(); + $scope.editId = -1; + } + + $scope.updateUniversityDetails = function (form, 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 { + var req = { + method: 'POST', + url: apiPoint.url + 'updateUniversityDetail/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: p, + updatedBy: localDetails.localUserID, + } + }; + $http(req).then(function (response) { + // if (response.data.updateEmpStatus = true) { + // swal("Success!", response.data.message, "success"); + // $scope.getEmployeeList(); + // $scope.editId = -1; + // } else { + // // $scope.ldloading1[loading.replace('-', '_')] = false; + // swal("Failed!", response.data.message, "error"); + // } + }); + } + } + }]); diff --git a/Apollo/assets/views/editUniversityDetails.html b/Apollo/assets/views/editUniversityDetails.html new file mode 100644 index 00000000..f5b2bf2e --- /dev/null +++ b/Apollo/assets/views/editUniversityDetails.html @@ -0,0 +1,110 @@ +
+ diff --git a/Apollo/assets/views/university.html b/Apollo/assets/views/university.html index c682fb57..f336c19c 100644 --- a/Apollo/assets/views/university.html +++ b/Apollo/assets/views/university.html @@ -24,12 +24,12 @@ -No
records found...