announcement added

This commit is contained in:
resicovenba 2017-11-29 16:35:26 +05:30
parent 8825de2e9e
commit db528a9eff
11 changed files with 784 additions and 2 deletions

View File

@ -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

View File

@ -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';

View File

@ -0,0 +1,135 @@
<?php
/**
* Created by Visual studio code.
* User: Surendiran
* Date: 11/27/17
* Time: 10:40 am
*/
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require_once APPPATH . '/libraries/REST_Controller.php';
/**
* This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array
*
* @package CodeIgniter
* @subpackage Rest Server
* @category Controller
* @author
* @license MIT
* @link
*/
class Announcement_Controller extends REST_Controller {
function __construct()
{
// Construct the parent class
parent::__construct();
// Configure limits on our controller methods
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
$this->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
}
}
}

View File

@ -0,0 +1,103 @@
<?php
/**
* Created by Visual studio code.
* User: Surendiran
* Date: 11/27/17
* Time: 3:40 pm
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Announcement_model extends CI_Model {
/*
* add announcement details
* params:heading,description,active
* created by Surendiran
* */
public function addAnnouncement($arrayDetails=null)
{
$this->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;
}
}

View File

@ -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",

View File

@ -99,7 +99,10 @@ app.constant('JS_REQUIRES', {
* batch
* */
'batchCtrl': 'assets/js/controllers/batchCtrl.js',
/* *
announcementCtrl
* */
'announcementCtrl': 'assets/js/controllers/announcementCtrl.js',
/*
* call track

View File

@ -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: '<div ui-view class="fade-in-up"> <div style="margin: auto; width: 50%;padding: 10px;"> STUDENT DETAILS </div> </div>',

View File

@ -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 = '';
}
});
};
}]);

View File

@ -0,0 +1,184 @@
<style>
b.fa {
display: inline-block;
border-radius: 60px;
box-shadow: 0px 0px 2px #007AFF;
padding: 0.5em 0.6em;
}
</style>
<!-- start: PAGE TITLE -->
<section id="page-title">
<div class="row">
<div class="col-sm-8">
<h1 class="mainTitle" translate="Add/View Announcement Details">{{ mainTitle }}</h1>
</div>
<div ncy-breadcrumb></div>
</div>
</section>
<!-- end: PAGE TITLE -->
<!-- start: TEXT EDITOR -->
<div class="container-fluid container-fullw bg-white">
<div ng-controller="CkeditorCtrl" data-ng-init="init()">
<tabset class="tabbable">
<tab heading="View Announcement">
<div class="container-fluid container-fullw">
<div class="row">
<div ng-if="loader == ''" class="col-md-12" align="center">
<!--<img src="assets/images/ajax_loader_blue.gif" style="width: 5%; height: 30%">-->
<spinner name="html5spinner"><div class="overlay"></div><div class="spinner"><div class="double-bounce1"></div> <div class="double-bounce2"></div> </div> <div class="please-wait">Please Wait...</div>
</spinner>
</div>
<div class="col-md-12" ng-if="emptyData == false && loader != ''" style="min-height: 281px;">
<p style="color: red;" align="center"><strong><h3 class="text-center">oops! No
records found... </h3></strong></p>
</div>
<div class="col-md-12" ng-if="emptyData == true">
<div class="row">
<div class="col-md-3">
<script>
$(function () {
$("#search").focus();
});
</script>
<input class="form-control" type="text" ng-model="search"
id="search" autofocus tabindex="1"
placeholder="Search"/><br><br>
</div>
</div>
<div class="table-responsive">
<fieldset>
<table class="table table-hover">
<thead>
<tr>
<th ng-click="sort('Heading')">Heading
<span class="glyphicon sort-icon" ng-show="sortKey=='Heading'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<!--<th ng-click="sort('description')">Description
<span class="glyphicon sort-icon" ng-show="sortKey=='description'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th> -->
<th ng-click="sort('Active/De-Active')">Status
<span class="glyphicon sort-icon" ng-show="sortKey=='Active/De-Active'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th></th>
</tr>
</thead>
<tbody dir-paginate="p in data|orderBy:sortKey:reverse|filter:search:strict|itemsPerPage:10">
<tr>
<td>{{p.Heading}}</td>
<!--<td>{{p.description}}</td>-->
<td><span ng-if="p.IsActive == 1"> Active </span><span ng-if="p.IsActive == 0">InActive</span></td>
<td>
<a href="#" class="text-azure" id="editRowBtn{{p.ID}}" ng-click="setEditId(p.ID);"><b class="fa fa-hover fa-pencil " aria-hidden="true"></b>
</a></td>
</tr>
<tr ng-show="editId === p.ID" ng-if="editId === p.ID" >
<td colspan="12" ng-include
src="'assets/views/announcement/editAnnouncementDetails.html'"></td>
</tr>
</tbody>
</table>
</fieldset>
<dir-pagination-controls max-size="10" direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
</div>
</div>
</div>
</tab>
<tab heading="Add Announcement">
<form name="Form" id="form" novalidate ng-submit="announcementForm.submit(Form, myModel, 'zoom-in')" method="post">
<fieldset>
<legend>
Add New Announcement Details
</legend>
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Heading <span class="symbol required"></span>
</label>
</div>
<div class="col-md-10" ng-class="{'has-error':Form.Heading.$dirty && Form.Heading.$invalid, 'has-success':Form.Heading.$valid}">
<input type="text" placeholder="Enter Heading Name"
tabindex="2" class="form-control" name="Heading"
ng-model="myModel.Heading" required/>
<span class="error text-small block"
ng-if="Form.Heading.$dirty && Form.Heading.$error.required">Heading is required</span>
</div>
</div>
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Description <span class="symbol required"></span>
</label>
</div>
<div class="col-md-10">
<!-- /// controller: 'CkeditorCtrl' - localtion: assets/js/controllers/ckeditorCtrl.js /// -->
<div ckeditor="options" class="form-control" ng-change="onReady()" ng-model="myModel.description"></div>
</div>
</div>
<!--<pre> {{ myModel.description }}</pre>-->
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Active/De-Active <span class="symbol required">
</label>
</div>
<div class="col-md-2">
<div ng-switch="myModel.switchsetting">
<div ng-switch-when="true">
<switch ng-model="myModel.switchsetting" ng-init="myModel.switchsetting = true" class="green"></switch>
</div>
<div ng-switch-when="false">
<switch ng-model="myModel.switchsetting" ng-init="myModel.switchsetting = false" class="green"></switch>
</div>
<div ng-switch-default>
<switch ng-model="myModel.switchsetting" ng-init="myModel.switchsetting = true" class="green"></switch>
</div>
</div>
</div>
</div>
<div class="col-md-12 form-group">
<div class="pull-right">
<button type="submit" ladda="ldloading1.zoom_in" tabindex="9" class="btn btn-wide btn-success" data-style="zoom-in">
Submit
</button>
<button type="reset" class="btn btn-warning btn-wide" tabindex="10"
ng-click="announcementForm.reset(Form)">
Reset
</button>
</div>
</div>
</fieldset>
</form>
</tab>
</tabset>
</div>
</div>
<!-- end: TEXT EDITOR -->

View File

@ -0,0 +1,99 @@
<form name="Form" id="form" novalidate>
<div class="row">
<div class="col-md-12">
<fieldset>
<legend>
Update Announcement Details
</legend>
<div class="row">
<form name="Form" id="form" novalidate ng-submit="announcementForm.submit(Form, myModel, 'zoom-in')" method="post">
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Heading <span class="symbol required"></span>
</label>
</div>
<div class="col-md-10" ng-class="{'has-error':Form.Heading.$dirty && Form.Heading.$invalid, 'has-success':Form.Heading.$valid}">
<input type="text" placeholder="Enter Heading Name"
tabindex="1" class="form-control" name="Heading"
ng-model="p.Heading" required/>
<span class="error text-small block"
ng-if="Form.Heading.$dirty && Form.Heading.$error.required">Heading is required</span>
</div>
</div>
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Description <span class="symbol required"></span>
</label>
</div>
<div class="col-md-10">
<!-- /// controller: 'CkeditorCtrl' - localtion: assets/js/controllers/ckeditorCtrl.js /// -->
<div ckeditor="options" class="form-control" ng-change="onReady()" ng-model="p.description"></div>
<!--<div class="well margin-top-20">
{{description}}
</div>-->
</div>
</div>
<!--<pre> {{ myModel.description }}</pre>-->
<div class="col-md-12 form-group">
<div class="col-md-2">
<label>
Active/De-Active
</label>
</div>
<div class="col-md-2">
<div class="col-md-4">
<div ng-if="p.IsActive==true">
<switch ng-model="p.IsActive" ng-init="p.IsActive = true" class="green"></switch>
</div>
<div ng-if="p.IsActive==false">
<switch ng-model="p.IsActive" ng-init="p.IsActive = false" class="green"></switch>
</div>
</div>
</div>
</div>
<div class="col-md-12 form-group">
<div class="pull-right">
<button type="submit" ladda="ldloading.zoom_in" tabindex="9" class="btn btn-wide btn-success" data-style="zoom-in" ng-click="updateAnnouncement(p,Form,'zoom-in')">
Save
</button>
<!-- <button type="submit" class="btn btn-success btn-o" tabindex="8">
Submit
</button>-->
<input type="button" class="btn btn-warning btn-wide" tabindex="10" value="Cancel"
ng-click="cancel();">
</div>
</div>
</form>
</div>
</fieldset>
<!-- class="editRowTd" -->

View File

@ -59,6 +59,11 @@
<span class="title" translate="sidebar.nav.master.EMPLOYEE"> EMPLOYEE DETAILS </span>
</a>
</li>
<li ui-sref-active="active" >
<a ui-sref="app.master.announcement">
<span class="title" translate="sidebar.nav.master.ANNOUNCEMENT"> Announcement DETAILS </span>
</a>
</li>
</ul>
@ -157,6 +162,11 @@
<span class="title" translate="sidebar.nav.master.EMPLOYEE"> EMPLOYEE DETAILS </span>
</a>
</li>
<li ui-sref-active="active" >
<a ui-sref="app.master.announcement">
<span class="title" translate="sidebar.nav.master.ANNOUNCEMENT"> Announcement DETAILS </span>
</a>
</li>
</ul>