diff --git a/Apollo/api/application/controllers/Course_Controller.php b/Apollo/api/application/controllers/Course_Controller.php new file mode 100644 index 00000000..070dcb6b --- /dev/null +++ b/Apollo/api/application/controllers/Course_Controller.php @@ -0,0 +1,115 @@ +methods['addCourseDetails_get']['limit'] = 500; // 500 requests per hour per user/key + $this->methods['addCourseDetails_post']['limit'] = 100; // 100 requests per hour per user/key + $this->methods['addCourseDetails_delete']['limit'] = 50; // 50 requests per hour per user/key + $this->methods['getCourseDetails_post']['limit'] = 500; // 50 requests per hour per user/key + $this->methods['updateCourseDetails_post']['limit'] = 500; + // load the model + $this->load->model('Course_model', 'course_model'); + + } + + /* + * This method used to add Course details + * created by kms + * */ + + public function addCourseDetails_post() + { + + $details['CourseID'] = $this->post('courseID'); + $details['CourseName'] = $this->post('courseName'); + $details['UniversityID'] = $this->post('universityName'); + $details['CreatedBy'] = $this->post('createdBy'); + $details['IsActive'] = $this->post('status'); + $courseDetails = $this->course_model->addCourse($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($courseDetails) + { + $courseDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($courseDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + /* + * get course details + * created by kms + * */ + public function getCourseDetails_post() + { + $requestedBy = $this->post('requestedBy'); + $getCourse = $this->course_model->getCourse($requestedBy); + + if ($getCourse) + { + $getCourse['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No records found!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + /* + * update the course details + * created by kms + * */ + public function updateCourseDetails_post() + { + $details['CourseID'] = $this->post('courseCode'); + $details['CourseName'] = $this->post('courseName'); + $details['IsActive'] = $this->post('status'); + $details['UpdatedBy'] = $this->post('updatedBy'); + $details['UpdatedOn'] = date("Y-m-d", time()); + $updateDetails = $this->course_model->updateCourse($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($updateDetails) + { + $updateDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + + +} \ No newline at end of file diff --git a/Apollo/api/application/models/Course_model.php b/Apollo/api/application/models/Course_model.php new file mode 100644 index 00000000..1379ccb4 --- /dev/null +++ b/Apollo/api/application/models/Course_model.php @@ -0,0 +1,111 @@ +db->select('CourseID'); + $this->db->where('CourseID', $arrayDetails['CourseID']); + if($this->db->get(COURSE)->first_row()){ + $result['courseStatus'] = false; + $result['message'] = "This course id is already exist!"; + } else { + $this->db->insert(COURSE, $arrayDetails); + if ($this->db->affected_rows() == '1') { + + $result['courseStatus'] = true; + $result['message'] = "Successfully course details added"; + } else { + $result['courseStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + return $result; + + } + + + /* + * get branch details + * parama id + * created by kms + * */ + + public function getCourse() + { + $this->db->select('CU.CourseID,CU.CourseName,CU.IsActive,US.UniversityID,US.UniversityName'); + $this->db->from(COURSE.' as CU'); + $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID'); + $this->db->order_by('CourseID','DESC'); + $courseDetails = $this->db->get(); + + if($courseDetails->result()){ + + $result['courseStatus'] = true; + $result['details'] = $courseDetails->result(); + } + else { + $result['courseStatus'] = false; + $result['message'] = "No records found!"; + } + + $result['universityDetails'] = $this->getUniversityDetails(); + + return $result; + + } + + /* + * update course details + * created by kms + * */ + public function updateCourse($arrayDetails=null) + { + $this->db->where('CourseID',$arrayDetails['CourseID']); + $upateStatus=$this->db->update(COURSE, $arrayDetails); + if($upateStatus){ + + $result['courseStatus'] = true; + $result['message'] = "Successfully course details updated"; + } + + else { + $result['courseStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + + } + + + return $result; + + } + /* + * get university details + * created by kms + * */ + public function getUniversityDetails() + { + $this->db->select('UniversityID,UniversityName'); + $this->db->order_by('UniversityID','ASC'); + $this->db->order_by('IsActive','1'); + $universityDetails = $this->db->get(UNIVERSITY); + return $universityDetails->result(); + } + + + +} \ No newline at end of file diff --git a/Apollo/assets/js/controllers/courseCtrl.js b/Apollo/assets/js/controllers/courseCtrl.js index e69de29b..ea6c7410 100644 --- a/Apollo/assets/js/controllers/courseCtrl.js +++ b/Apollo/assets/js/controllers/courseCtrl.js @@ -0,0 +1,202 @@ +'use strict'; +/** + * controllers for ng-table + * Simple table with sorting and filtering on AngularJS + */ + +app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) { + $scope.myModel = { + "courseCode": "", + "courseName": "", + "universityName":"", + "switchsetting": true + }; + + /* + * edit branch details + * created by kms + * */ + $scope.editId = -1; + $scope.setEditId = function (pid) { + + $scope.editId = pid; + $scope.viewId = -1; + }; + + /* + * cancel edit div + * created by kms + * */ + $scope.cancel = function () { + $scope.init(); + $scope.editId = -1; + + }; + + // 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 + } + + /* + * Submit,update and reset course details + * @params myModel + * created by kms + * */ + $scope.courseForm = { + submit: function (form, myModel,loading) { + 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 { + + $scope.ldloading1 = {}; + + $scope.ldloading1[loading.replace('-', '_')] = true; + + + var addCourse = { + method: 'POST', + url: apiPoint.url + 'addCourseDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + courseID: myModel.courseCode, + courseName: myModel.courseName, + universityName: myModel.universityName, + status: myModel.switchsetting, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(addCourse).then(function (response) { + if (response.data.status==200 && response.data.courseStatus) { + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, {reload: true}); + } else { + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + + + } + }, + reset: function (form) { + + $scope.myModel = angular.copy($scope.master); + form.$setPristine(true); + } + }; + /* + * update the course details + * created by kms + * */ + $scope.updateCourse = function (myModel, form, loading) { + + 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].$stop_name; + } + + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + } else { + $scope.ldloading = {}; + + $scope.ldloading[loading.replace('-', '_')] = true; + + + var update = { + method: 'POST', + url: apiPoint.url + 'updateCourseDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + courseCode: myModel.CourseID, + courseName: myModel.CourseName, + status: myModel.IsActive, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(update).then(function (response) { + if (response.data.status==200 && response.data.courseStatus) { + $scope.ldloading[loading.replace('-', '_')] = false; + swal("Success!", response.data.message, "success"); + $scope.editId = -1; + $scope.init(); + + } else { + $scope.ldloading[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + } + }; + /* + *get course details when page loading called from view file + * + * created by kms + * */ + $scope.loader=''; + + $scope.emptyData=''; + + $rootScope.init = function () { + + var getBranch = { + method: 'POST', + url: apiPoint.url + 'getCourseDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(getBranch).then(function (response) { + if (response.data.status==200 && response.data.courseStatus) { + $scope.emptyData=true; + $scope.loader=true; + + $scope.data = response.data.details; + $scope.university=response.data.universityDetails; + + + + } else { + $scope.emptyData=false; + $scope.loader=false; + $scope.university=response.data.universityDetails; + + } + }); + }; + + + + +}]); diff --git a/Apollo/assets/views/branchDetails.html b/Apollo/assets/views/branchDetails.html index 0bc7d2f4..36b32c85 100644 --- a/Apollo/assets/views/branchDetails.html +++ b/Apollo/assets/views/branchDetails.html @@ -85,7 +85,7 @@ --> - +
@@ -137,6 +137,7 @@
+
@@ -185,9 +186,9 @@ tabindex="1" class="form-control" name="branchcode" ng-model="myModel.branchCode" ng-pattern="/^[a-zA-Z0-9.\s]*$/" required/> Branch Code required + ng-if="Form.branchcode.$dirty && Form.branchcode.$error.required">Branch code is required Invalid Branch Code + ng-if="Form.branchcode.$dirty && Form.branchcode.$error.pattern">Invalid branch code @@ -203,9 +204,9 @@ tabindex="2" class="form-control" name="branchname" ng-model="myModel.branchName" ng-pattern="/^[a-zA-Z0-9.\s]*$/" required/> Branch Name required + ng-if="Form.branchname.$dirty && Form.branchname.$error.required">Branch name is required Invalid Branch Name + ng-if="Form.branchname.$dirty && Form.branchname.$error.pattern">Invalid branch name @@ -246,9 +247,9 @@ ng-pattern="/^[0-9]*$/" required> Primary phone is required. + ng-hide="Form.primaryPhone.$error.maxlength || Form.primaryPhone.$error.minlength || Form.primaryPhone.$error.pattern">Phone number is required. Enter a Valid Phone Number + ng-if="Form.primaryPhone.$error.maxlength || Form.primaryPhone.$error.minlength || Form.primaryPhone.$error.pattern">Enter a valid phone number @@ -265,7 +266,7 @@ ng-minlength="10" ng-maxlength="12" ng-pattern="/^[0-9]*$/"/> Enter a Valid Phone Number + ng-if="Form.secondaryPhone.$error.maxlength || Form.secondaryPhone.$error.minlength || Form.secondaryPhone.$error.pattern">Enter a valid phone number
@@ -279,7 +280,7 @@ ng-minlength="11" ng-maxlength="13" ng-pattern="/^[0-9-]*$/"/> Enter a Valid Number + ng-if="Form.Landline.$error.maxlength || Form.Landline.$error.minlength || Form.Landline.$error.pattern">Enter a valid number
diff --git a/Apollo/assets/views/courseDetails.html b/Apollo/assets/views/courseDetails.html index 86069801..09eb3910 100644 --- a/Apollo/assets/views/courseDetails.html +++ b/Apollo/assets/views/courseDetails.html @@ -52,51 +52,35 @@ - - - - + + - - - - + + + + - + + src="'assets/views/editCourseDetails.html'"> @@ -125,139 +109,66 @@
-
+
- Add New Branch Details + Add New Course Details
-
+
- + Branch Code required + ng-if="Form.coursecode.$dirty && Form.coursecode.$error.required">Course id is required Invalid Branch Code + ng-if="Form.coursecode.$dirty && Form.coursecode.$error.pattern">Invalid course id + +
+ + +
+ + + + Course name is required + Invalid course name
- -
+
- - + Branch Name required - Invalid Branch Name - - + ng-if="Form.university.$dirty && Form.university.$invalid">University is required +
- -
- - - Email is required. - Please, enter a valid email address. - -
-
-
- -
- - - Primary phone is required. - Enter a Valid Phone Number - -
- -
- - - Enter a Valid Phone Number -
-
- - - Enter a Valid Number -
-
-
- -
- - - Address is required - - -
-
+
@@ -279,7 +190,6 @@
-
diff --git a/Apollo/assets/views/editBranchDetails.html b/Apollo/assets/views/editBranchDetails.html index b5b1abf8..54d68f32 100644 --- a/Apollo/assets/views/editBranchDetails.html +++ b/Apollo/assets/views/editBranchDetails.html @@ -19,9 +19,9 @@ tabindex="1" class="form-control" name="branchcode" ng-model="p.BranchCode" ng-pattern="/^[a-zA-Z0-9.\s]*$/" readonly required/> Branch Code required + ng-if="Form.branchcode.$dirty && Form.branchcode.$error.required">Branch code is required Invalid Branch Code + ng-if="Form.branchcode.$dirty && Form.branchcode.$error.pattern">Invalid branch code
@@ -37,9 +37,9 @@ tabindex="2" class="form-control" name="branchname" ng-model="p.BranchName" ng-pattern="/^[a-zA-Z0-9.\s]*$/" required/> Branch Name required + ng-if="Form.branchname.$dirty && Form.branchname.$error.required">Branch name is required Invalid Branch Name + ng-if="Form.branchname.$dirty && Form.branchname.$error.pattern">Invalid branch name
@@ -80,9 +80,9 @@ ng-pattern="/^[0-9]*$/" required> Primary phone is required. + ng-hide="Form.primaryPhone.$error.maxlength || Form.primaryPhone.$error.minlength || Form.primaryPhone.$error.pattern">Phone number is required. Enter a Valid Phone Number + ng-if="Form.primaryPhone.$error.maxlength || Form.primaryPhone.$error.minlength || Form.primaryPhone.$error.pattern">Enter a valid phone number
@@ -99,7 +99,7 @@ ng-minlength="10" ng-maxlength="12" ng-pattern="/^[0-9]*$/"/> Enter a Valid Phone Number + ng-if="Form.secondaryPhone.$error.maxlength || Form.secondaryPhone.$error.minlength || Form.secondaryPhone.$error.pattern">Enter a valid phone number
@@ -113,7 +113,7 @@ ng-minlength="11" ng-maxlength="13" ng-pattern="/^[0-9-]*$/"/> Enter a Valid Number + ng-if="Form.Landline.$error.maxlength || Form.Landline.$error.minlength || Form.Landline.$error.pattern">Enter a valid number
diff --git a/Apollo/assets/views/editCourseDetails.html b/Apollo/assets/views/editCourseDetails.html new file mode 100644 index 00000000..c610abd3 --- /dev/null +++ b/Apollo/assets/views/editCourseDetails.html @@ -0,0 +1,251 @@ + +
+
+
+ + Update Course Details + +
+
+ + + + Course id is required + Invalid course id + +
+ + +
+ + + + Course name is required + Invalid course name + + +
+ +
+ + + University is required + +
+ +
+ +
+ + + +
+
+ + +
+ +
+ +
+ +
+
+ + + + + +
+
+
+
+
+ + + + +
Course ID - + Course ID + Course Name - + Course Name + University - + University +
{{p.BranchCode}}{{p.BranchName}}{{p.Address}}{{p.CourseID}}{{p.CourseName}}{{p.UniversityName}} + + +