activity master

This commit is contained in:
resicovenba 2017-11-23 21:14:21 +05:30
parent f33a328d4e
commit e4834b18ad
7 changed files with 320 additions and 2 deletions

View File

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

View File

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

View File

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

View File

@ -85,6 +85,11 @@ app.constant('JS_REQUIRES', {
'courseCtrl': 'assets/js/controllers/courseCtrl.js',
/* *
Activity
* */
'activityCtrl': 'assets/js/controllers/activityCtrl.js',
/*
* call track

View File

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

View File

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

View File

@ -0,0 +1,83 @@
<section id="page-title">
<div class="row">
<div class="col-sm-8">
<h1 class="mainTitle" translate="Activity Details"></h1>
<!--
<span class="mainDescription">Over a dozen reusable components built to provide popovers, media objects, navigation, tooltips and much more. </span>
-->
</div>
<div ncy-breadcrumb></div>
</div>
</section>
<div class="container-fluid container-fullw bg-white">
<div ng-controller="activityCtrl">
<form class="form-horizontal" role="form" ng-submit="addRow(companies)">
<!-- Start :Auto Generate Activity ID -->
<div class="form-group" style="display:none">
<label class="col-md-2 control-label">Activity ID <span class="symbol required"></label>
<div class="col-md-3">
<input type="text" class="form-control" name="ActivityID" placeholder="Enter Activity ID" ng-model="companies.ActivityID"
/>
</div>
</div>
<!-- End :Auto Generate Activity ID -->
<div class="form-group">
<label class="col-md-2 control-label">Activity Name<span class="symbol required"></label>
<div class="col-md-3">
<input type="text" class="form-control" name="ActivityName" placeholder="Enter Activity Name" ng-model="companies.ActivityName"
/>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Description<span class="symbol required"></label>
<div class="col-md-3">
<input type="text" class="form-control" name="Description" placeholder="Enter Description" ng-model="companies.Description"
/>
</div>
</div>
<div class="col-md-4 col-md-offset-4">
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-primary" />
</div>
</div>
</form>
<table class="table table-hover" ng-init="init();">
<thead>
<tr>
<th>Activity ID
</th>
<th>Activity Name
</th>
<th>Description
</th>
<th>Active/De-Active
</th>
</tr>
</thead>
<tbody dir-paginate="p in activityInfo|orderBy:sortKey:reverse|filter:search:strict|itemsPerPage:5">
<tr>
<td>{{p.ListCode}}</td>
<td>{{p.ListName}}</td>
<td>{{p.Description}}</td>
<td ng-if="p.IsActive==true">
<switch ng-model="p.IsActive" ng-change="onclick(p.ListCode, p.IsActive)" ng-init="p.IsActive = true" class="green"></switch>
</td>
<td ng-if="p.IsActive==false">
<switch ng-model="p.IsActive" ng-change="onclick(p.ListCode, p.IsActive)" ng-init="p.IsActive = false" class="green"></switch>
</td>
</tr>
</tbody>
</table>
<dir-pagination-controls max-size="5" direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
</div>