diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 83e5cd2b..e4a20f1e 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -86,6 +86,11 @@ $route['getCourseDetails'] = 'Course_Controller/getCourseDetails'; $route['addCourseDetails'] = 'Course_Controller/addCourseDetails'; $route['updateCourseDetails'] = 'Course_Controller/updateCourseDetails'; +// activity +$route['addActivityDetails'] = 'University_Controller/addActivityDetails'; +$route['getActivityDetails'] = 'University_Controller/getActivityDetails'; +$route['updateActivityStatus'] = 'University_Controller/updateActivityStatus'; + diff --git a/Apollo/api/application/controllers/University_Controller.php b/Apollo/api/application/controllers/University_Controller.php index 9da2bf8b..646f4ee8 100644 --- a/Apollo/api/application/controllers/University_Controller.php +++ b/Apollo/api/application/controllers/University_Controller.php @@ -147,4 +147,67 @@ class University_Controller extends REST_Controller { } } + + public function addActivityDetails_post() { + $details['ListCode'] = $this->post('activityID'); + $details['ListName'] = $this->post('activityName'); + $details['ListGroup'] = "2"; + $details['Description'] = $this->post('description'); + $details['CreatedBy'] = $this->post('createdBy'); + $details['IsActive'] = $this->post('status'); + $activityDetails = $this->university_model->addactivity($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($activityDetails) { + $activityDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($activityDetails, 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 + } + } + +public function getActivityDetails_post() + { + $requestedBy = $this->post('requestedBy'); + $getActivity = $this->university_model->getActivity($requestedBy); + if ($getActivity) + { + $getActivity['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getActivity, 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 + } + } + +public function updateActivityStatus_post() { +// {"status":false,"updateFor":"A012","createdBy":"1"} + $ListCode = $this->post('updateFor'); + $details['IsActive'] = $this->post('status'); + $details['UpdatedBy'] = $this->post('createdBy'); + $date = date('Y-m-d H:i:s'); + $details['UpdatedOn'] = $date; + $updateActivity = $this->university_model->updateActivity($ListCode, $details); + if ($updateActivity) + { + $updateActivity['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updateActivity, 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 + } + + } } diff --git a/Apollo/api/application/models/University_model.php b/Apollo/api/application/models/University_model.php index 7d570ecd..a3e34f4a 100644 --- a/Apollo/api/application/models/University_model.php +++ b/Apollo/api/application/models/University_model.php @@ -76,5 +76,70 @@ class University_model extends CI_Model } return $result; } + + public function addactivity($arrayDetails=null) + { + $this->db->select('ListName,ListCode,Description'); + $this->db->where('ListGroup', '2'); + $this->db->where('ListName', $arrayDetails['ListName']); + $this->db->where('ListCode', $arrayDetails['ListCode']); + $this->db->where('Description', $arrayDetails['Description']); + $checkExistActivity = $this->db->get(PICK_LIST_DETAILS); + + if($checkExistActivity->result()){ + $result['activityStatus'] = false; + $result['details'] = "This activity is already added"; + } + else{ + $this->db->insert(PICK_LIST_DETAILS, $arrayDetails); + if($this->db->affected_rows() == '1'){ + $result['activityStatus'] = true; + $result['message'] = "Successfully activity is added"; + } + else { + $result['activityStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + return $result; + + } + + /* + * get Activity details + * parama id + * created by Surendiran + * */ + + public function getActivity() + { + $this->db->select('ListCode,ListName,Description,IsActive'); + $this->db->where('ListGroup','2'); + $this->db->order_by('ListCode','DESC'); + $activityDetails = $this->db->get(PICK_LIST_DETAILS); + if($activityDetails->result()){ + $result['activityStatus'] = true; + $result['details'] = $activityDetails->result(); + } + else { + $result['activityStatus'] = false; + $result['message'] = "No records found!"; + } + return $result; + + } + public function updateActivity($updateFor, $arr) { + $this->db->where('ListCode',$updateFor); + $this->db->update( PICK_LIST_DETAILS ,$arr); + if($this->db->affected_rows()== '1'){ + $result['activityUpdateStatus'] = true; + $result['message'] = "Updated successfully!"; + } + else { + $result['activityUpdateStatus'] = false; + $result['message'] = "No records found!"; + } + return $result; + } } \ No newline at end of file diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 68334d23..1136865e 100644 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -85,6 +85,11 @@ app.constant('JS_REQUIRES', { 'courseCtrl': 'assets/js/controllers/courseCtrl.js', + /* * + Activity + * */ + 'activityCtrl': 'assets/js/controllers/activityCtrl.js', + /* * call track diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 082d1013..96aaebdf 100644 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -122,9 +122,10 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com label: 'Course' }, // resolve: loadSequence('iconsCtrl') - }).state('app.master.activity', { + }).state('app.master.activity', { url: '/activity', - templateUrl: "assets/views/ui_line_icons.html", + templateUrl: "assets/views/activity.html", + resolve: loadSequence('activityCtrl','ngTable'), title: 'Activity', ncyBreadcrumb: { label: 'Activity' diff --git a/Apollo/assets/js/controllers/activityCtrl.js b/Apollo/assets/js/controllers/activityCtrl.js new file mode 100644 index 00000000..27dfc9de --- /dev/null +++ b/Apollo/assets/js/controllers/activityCtrl.js @@ -0,0 +1,96 @@ +'use strict'; +/** + * controllers for ng-table + * Simple table with sorting and filtering on AngularJS + */ +// var helloApp = angular.module("helloApp", []); +app.controller("activityCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$localStorage", "$http", "$state", function ($scope, toaster, $filter, apiPoint, $localStorage, $http, $state) { + + $scope.companies = { + "ActivityID": "", + "ActivityName": "", + "Description": "", + "switchsetting": true + + }; + + $scope.addRow = function (myModel) { + var addactivity = { + method: 'POST', + url: apiPoint.url + 'addActivityDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + activityID: myModel.ActivityID, + activityName: myModel.ActivityName, + description: myModel.Description, + status: myModel.switchsetting, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(addactivity).then(function (response) { + if (response.data.status == 200 && response.data.activityStatus) { + $scope.init(); + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, { reload: true }); + } else { + swal("Failed!", response.data.message, "error"); + } + }); + + }; + + $scope.onclick = function (id, status) { + status = status === true ? 1 : 0; + var addactivity = { + method: 'POST', + url: apiPoint.url + 'updateActivityStatus/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + status: status, + updateFor: id, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(addactivity).then(function (response) { + if (response.data.status == 200 && response.data.activityUpdateStatus) { + $scope.init(); + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + /* +*get Activity details when page loading called from view file +* +* created by surendiran +* */ + $scope.loader = ''; + $scope.emptyData = ''; + $scope.init = function () { + var getActivity = { + method: 'POST', + url: apiPoint.url + 'getActivityDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(getActivity).then(function (response) { + if (response.data.status == 200 && response.data.activityStatus) { + $scope.emptyData = true; + $scope.loader = true; + $scope.activityInfo = response.data.details; + } else { + $scope.emptyData = false; + $scope.loader = false; + $scope.activityInfo = ""; + } + }); + }; +}]); \ No newline at end of file diff --git a/Apollo/assets/views/activity.html b/Apollo/assets/views/activity.html new file mode 100644 index 00000000..a2359a54 --- /dev/null +++ b/Apollo/assets/views/activity.html @@ -0,0 +1,83 @@ +
+
+
+

+ +
+
+
+
+
+
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
Activity ID + Activity Name + Description + Active/De-Active +
{{p.ListCode}}{{p.ListName}}{{p.Description}} + + + + + +
+ + +
+
\ No newline at end of file