From db528a9eff5fdb2ac385f01f471cc98d24ed8e56 Mon Sep 17 00:00:00 2001 From: resicovenba Date: Wed, 29 Nov 2017 16:35:26 +0530 Subject: [PATCH] announcement added --- Apollo/api/application/config/constants.php | 1 + Apollo/api/application/config/routes.php | 8 + .../controllers/Announcement_Controller.php | 135 ++++++++++ .../application/models/Announcement_model.php | 103 ++++++++ Apollo/assets/i18n/en.json | 3 +- Apollo/assets/js/config.constant.js | 5 +- Apollo/assets/js/config.router.js | 8 + .../assets/js/controllers/announcementCtrl.js | 230 ++++++++++++++++++ .../views/announcement/Announcement.html | 184 ++++++++++++++ .../announcement/editAnnouncementDetails.html | 99 ++++++++ Apollo/assets/views/partials/nav.html | 10 + 11 files changed, 784 insertions(+), 2 deletions(-) create mode 100644 Apollo/api/application/controllers/Announcement_Controller.php create mode 100644 Apollo/api/application/models/Announcement_model.php create mode 100644 Apollo/assets/js/controllers/announcementCtrl.js create mode 100644 Apollo/assets/views/announcement/Announcement.html create mode 100644 Apollo/assets/views/announcement/editAnnouncementDetails.html diff --git a/Apollo/api/application/config/constants.php b/Apollo/api/application/config/constants.php index 940ae6c4..af611e46 100644 --- a/Apollo/api/application/config/constants.php +++ b/Apollo/api/application/config/constants.php @@ -103,6 +103,7 @@ defined('PICK_LIST_DETAILS') OR define('PICK_LIST_DETAILS','T_PickListDetails'); defined('BATCH') OR define('BATCH','T_BatchMaster'); defined('STUDENTCOURSE') OR define('STUDENTCOURSE','T_Student_CourseDetails'); defined('STUDENTS') OR define('STUDENTS','T_StudentDetails'); +defined('ANNOUNCEMENT') OR define('ANNOUNCEMENT','T_AnnouncementDetails'); //end of database table name diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 8dc8a7a7..e5099bd2 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -115,6 +115,14 @@ $route['addBatchDetails'] = 'Batch_Controller/addBatchDetails'; $route['updateBatchDetails'] = 'Batch_Controller/updateBatchDetails'; $route['getBatchDetails'] = 'Batch_Controller/getBatchDetails'; +/*Announcement*/ +$route['addAnnouncementDetails'] = 'Announcement_Controller/addAnnouncementDetails'; +$route['getAnnouncementDetails'] = 'Announcement_Controller/getAnnouncementDetails'; +$route['updateAnnouncementDetails'] = 'Announcement_Controller/updateAnnouncementDetails'; + +// dash board +$route['getDashboardCallTrack'] = 'Call_Tracking_Controller/getDashboardCallTrack'; + diff --git a/Apollo/api/application/controllers/Announcement_Controller.php b/Apollo/api/application/controllers/Announcement_Controller.php new file mode 100644 index 00000000..d919d4b9 --- /dev/null +++ b/Apollo/api/application/controllers/Announcement_Controller.php @@ -0,0 +1,135 @@ +methods['addAnnouncementDetails_get']['limit'] = 500; // 500 requests per hour per user/key + $this->methods['addAnnouncementDetails_post']['limit'] = 100; // 100 requests per hour per user/key + $this->methods['addAnnouncementDetails_delete']['limit'] = 50; // 50 requests per hour per user/key + $this->methods['getAnnouncementDetails_post']['limit'] = 500; // 50 requests per hour per user/key + $this->methods['updateAnnouncementDetails_post']['limit'] = 500; + // load the model + $this->load->model('Announcement_model', 'announcement_model'); + + } + + /* + * This method used to add Announcement Details + * created by Surendiran + * */ + + public function addAnnouncementDetails_post() + { + $details['Heading'] = $this->post('Heading'); + $details['Description'] = $this->post('description'); + $details['CreatedBy'] = $this->post('createdBy'); + $details['IsActive'] = $this->post('status'); + $announcementDetails = $this->announcement_model->addAnnouncement($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($announcementDetails) + { + $announcementDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($announcementDetails, 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 Announcement Details + * created by Surendiran + * */ + public function getAnnouncementDetails_post() + { + $requestedBy = $this->post('requestedBy'); + + $getAnnouncement = $this->announcement_model->getAnnouncement(); + + if ($getAnnouncement) + { + $getAnnouncement['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getAnnouncement, 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 Announcement Details + * created by Surendiran + * */ + public function updateAnnouncementDetails_post() + { + $updateID = $this->post('updateID'); + // $details['ID'] = $this->post('ID'); + $details['Heading'] = $this->post('Heading'); + $details['Description'] = $this->post('description'); + $details['IsActive'] = $this->post('status'); + $details['UpdatedBy'] = $this->post('updatedBy'); + $details['UpdatedOn'] = date("Y-m-d", time()); + $announcementDetails = $this->announcement_model->updateAnnouncement($details,$updateID);// Check if the users data store contains users (in case the database result returns NULL) + + if ($announcementDetails) + { + $announcementDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($announcementDetails, 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/Announcement_model.php b/Apollo/api/application/models/Announcement_model.php new file mode 100644 index 00000000..a2e7ce2b --- /dev/null +++ b/Apollo/api/application/models/Announcement_model.php @@ -0,0 +1,103 @@ +db->select('Heading'); + $this->db->where('Heading', $arrayDetails['Heading']); + if($this->db->get(ANNOUNCEMENT)->first_row()){ + $result['AnnouncementStatus'] = false; + $result['message'] = "This Announcement is already exist!"; + } else { + $this->db->select('Description'); + $this->db->where('Description', $arrayDetails['Description']); + if($this->db->get(ANNOUNCEMENT)->first_row()){ + $result['AnnouncementStatus'] = false; + $result['message'] = "This Announcement name is already exist!"; + } else{ + $this->db->insert(ANNOUNCEMENT, $arrayDetails); + if($this->db->affected_rows() == '1'){ + + $result['AnnouncementStatus'] = true; + $result['message'] = "Successfully Announcement details added"; + } + + else { + $result['AnnouncementStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + + } + + + + return $result; + + } + public function getAnnouncement() + { + $this->db->select('Heading,description,CreatedOn,IsActive,ID'); + $this->db->order_by('CreatedOn','DESC'); + $announcementDetails = $this->db->get(ANNOUNCEMENT); + + if($announcementDetails->result()){ + + $result['AnnouncementStatus'] = true; + $result['details'] = $announcementDetails->result(); + } + else { + $result['AnnouncementStatus'] = false; + $result['message'] = "No records found!"; + } + + return $result; + + } + + /* + * update announcement details + * created by Surendiran + * */ + + public function updateAnnouncement($arrayDetails=null,$updateID=null) + { + $this->db->where('ID',$updateID); + $updateStatus=$this->db->update(ANNOUNCEMENT, $arrayDetails); + + if($updateStatus){ + + $result['AnnouncementStatus'] = true; + $result['message'] = "Successfully Announcement details updated"; + } + + else { + $result['AnnouncementStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + + } + + + return $result; + + } + +} \ No newline at end of file diff --git a/Apollo/assets/i18n/en.json b/Apollo/assets/i18n/en.json index f1e96bde..683dd34b 100644 --- a/Apollo/assets/i18n/en.json +++ b/Apollo/assets/i18n/en.json @@ -64,7 +64,8 @@ "UNIVERSITY": "UNIVERSITY DETAILS", "COURSE": "COURSE DETAILS", "ACTIVITY": "ACTIVITY DETAILS", - "EMPLOYEE": "EMPLOYEE DETAILS" + "EMPLOYEE": "EMPLOYEE DETAILS", + "ANNOUNCEMENT": "ANNOUNCEMENT DETAILS" }, "student": { "MAIN": "STUDENTS DETAILS", diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index ce06c3a3..0c34372e 100644 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -99,7 +99,10 @@ app.constant('JS_REQUIRES', { * batch * */ 'batchCtrl': 'assets/js/controllers/batchCtrl.js', - + /* * + announcementCtrl + * */ + 'announcementCtrl': 'assets/js/controllers/announcementCtrl.js', /* * call track diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index dc1ce976..8d1485c0 100644 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -141,6 +141,14 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com label: 'Activity' }, // resolve: loadSequence('iconsCtrl') + }).state('app.master.announcement', { + url: '/announcement', + templateUrl: "assets/views/announcement/Announcement.html", + resolve: loadSequence('ckeditor-plugin', 'ckeditor', 'announcementCtrl','ladda', 'angular-ladda','ngTable'), + title: 'Announcement', + ncyBreadcrumb: { + label: 'Announcement' + }, }).state('app.student', { url: '/student', template: '
STUDENT DETAILS
', diff --git a/Apollo/assets/js/controllers/announcementCtrl.js b/Apollo/assets/js/controllers/announcementCtrl.js new file mode 100644 index 00000000..676753b8 --- /dev/null +++ b/Apollo/assets/js/controllers/announcementCtrl.js @@ -0,0 +1,230 @@ +'use strict'; +/** + * controller for angular-ckeditor +*/ +app.controller("CkeditorCtrl", ["$scope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope, toaster, ngTableParams, $filter, apiPoint, $localStorage, $http, $state) { + + $scope.myModel = { + "Heading": "", + "description": "", + "switchsetting": true + + }; + + /* +* edit announcement details +* created by Surendiran +* */ + $scope.editId = -1; + $scope.setEditId = function (pid) { + + $scope.editId = pid; + $scope.viewId = -1; + }; + + /* + * cancel edit div + * created by Surendiran + * */ + $scope.cancel = function () { + $scope.init(); + $scope.editId = -1; + + }; + + // Editor options. + $scope.options = { + language: 'en', + allowedContent: true, + entities: false + }; + + + + + + // Called when the editor is completely ready. + $scope.onReady = function () { + // ... + // alert(); + $scope.myModel.description + + console.log($scope.myModel.description); + }; + + // $scope.submitForm = function() { + // alert(JSON.stringify($scope.myModel.description)); + // } + + + + + + $scope.announcementForm = { + 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 addAnnouncement = { + method: 'POST', + url: apiPoint.url + 'addAnnouncementDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + Heading: myModel.Heading, + description: myModel.description, + status: myModel.switchsetting, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(addAnnouncement).then(function (response) { + if (response.data.status == 200 && response.data.AnnouncementStatus) { + $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); + $scope.myModel = { + "Heading": "", + "description": "", + "switchsetting": true + + }; + + } + }; + + + + /* + * update the announcement details + * created by Surendiran + * */ + $scope.updateAnnouncement = 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 + 'updateAnnouncementDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + Heading: myModel.Heading, + description: myModel.description, + status: myModel.IsActive, + updateID: myModel.ID, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(update).then(function (response) { + if (response.data.status == 200 && response.data.AnnouncementStatus) { + + $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 announcementForm details when page loading called from view file + * + * created by Surendiran + * */ + $scope.loader = ''; + $scope.announcementInfo = ''; + $scope.emptyData = ''; + + + $scope.init = function () { + + var getAnnouncement = { + method: 'POST', + url: apiPoint.url + 'getAnnouncementDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(getAnnouncement).then(function (response) { + if (response.data.status == 200 && response.data.AnnouncementStatus) { + $scope.emptyData = true; + $scope.loader = true; + + $scope.data = response.data.details; + + + } else { + $scope.emptyData = false; + $scope.loader = true; + + $scope.announcementInfo = ''; + + } + }); + }; + + +}]); \ No newline at end of file diff --git a/Apollo/assets/views/announcement/Announcement.html b/Apollo/assets/views/announcement/Announcement.html new file mode 100644 index 00000000..31c7edf1 --- /dev/null +++ b/Apollo/assets/views/announcement/Announcement.html @@ -0,0 +1,184 @@ + + +
+
+
+

{{ mainTitle }}

+ +
+
+
+
+ + +
+
+ + +
+
+
+ +
Please Wait...
+
+
+ +
+

oops! No + records found...

+
+
+
+ +
+ +

+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Heading + + Status + +
{{p.Heading}} Active InActive + +
+
+ + +
+ +
+
+
+ +
+ + + + +
+
+ + Add New Announcement Details + +
+
+ +
+
+ + Heading is required +
+
+ +
+
+ +
+
+ + +
+ + +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/Apollo/assets/views/announcement/editAnnouncementDetails.html b/Apollo/assets/views/announcement/editAnnouncementDetails.html new file mode 100644 index 00000000..46be6f91 --- /dev/null +++ b/Apollo/assets/views/announcement/editAnnouncementDetails.html @@ -0,0 +1,99 @@ +
+
+ +
+
+ + Update Announcement Details + + + + +
+ + +
+ +
+ +
+
+ + Heading is required +
+ + + +
+ + +
+
+ +
+
+ + +
+ + +
+
+ +
+
+ +
+
+
+ +
+ + + +
+
+ + +
+ +
+ +
+
+
+
+ + + + + +
+
+ + + + + +
+ +
+ + + diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index d4f08409..c70bb59c 100644 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -59,6 +59,11 @@ EMPLOYEE DETAILS +
  • + + Announcement DETAILS + +
  • @@ -157,6 +162,11 @@ EMPLOYEE DETAILS +
  • + + Announcement DETAILS + +