annoucement changes

This commit is contained in:
resicovenba 2017-11-30 19:52:11 +05:30
parent c3bd01a2d7
commit 60a9826f19
8 changed files with 302 additions and 83 deletions

View File

@ -94,7 +94,7 @@ $route['updateCourseDetails'] = 'Course_Controller/updateCourseDetails';
// activity
$route['addActivityDetails'] = 'University_Controller/addActivityDetails';
$route['getActivityDetails'] = 'University_Controller/getActivityDetails';
$route['updateActivityStatus'] = 'University_Controller/updateActivityStatus';
$route['updateActivityDetails'] = 'University_Controller/updateActivityDetails';
$route['changePassword'] = 'Login_Controller/changePassword';

View File

@ -186,28 +186,38 @@ public function getActivityDetails_post()
}
}
public function updateActivityStatus_post() {
// {"status":false,"updateFor":"A012","createdBy":"1"}
$ListCode = $this->post('updateFor');
/*
* update Announcement Details
* created by Surendiran
* */
public function updateActivityDetails_post()
{
$ListCode = $this->post('ListCode');
// $details['ID'] = $this->post('ID');
$details['ListName'] = $this->post('ListName');
$details['Description'] = $this->post('description');
$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)
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = date("Y-m-d", time());
$activityDetails = $this->university_model->updateActivity($details,$ListCode);// Check if the users data store contains users (in case the database result returns NULL)
if ($activityDetails)
{
$updateActivity['status'] = REST_Controller::HTTP_OK;
$activityDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($updateActivity, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
$this->response($activityDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'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

@ -20,19 +20,6 @@ class Announcement_model extends CI_Model {
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'){
@ -44,12 +31,6 @@ class Announcement_model extends CI_Model {
$result['AnnouncementStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
}
return $result;
}

View File

@ -82,8 +82,8 @@ class University_model extends CI_Model
$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']);
// $this->db->where('ListCode', $arrayDetails['ListCode']);
// $this->db->where('Description', $arrayDetails['Description']);
$checkExistActivity = $this->db->get(PICK_LIST_DETAILS);
if($checkExistActivity->result()){
@ -128,18 +128,23 @@ class University_model extends CI_Model
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;
}
/*
* update announcement details
* created by Surendiran
* */
public function updateActivity($arrayDetails=null,$ListCode=null) {
$this->db->where('ListCode',$ListCode);
$updateStatus=$this->db->update(PICK_LIST_DETAILS, $arrayDetails);
if($updateStatus){
$result['activityStatus'] = true;
$result['message'] = "Successfully Activity details updated";
}
else {
$result['activityStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
}

View File

@ -135,7 +135,7 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com
}).state('app.master.activity', {
url: '/activity',
templateUrl: "assets/views/activity.html",
resolve: loadSequence('activityCtrl','ngTable'),
resolve: loadSequence('activityCtrl','ngTable', 'ladda', 'angular-ladda'),
title: 'Activity',
ncyBreadcrumb: {
label: 'Activity'

View File

@ -13,8 +13,60 @@ app.controller("activityCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$
"switchsetting": true
};
/*
* edit batch details
* created by subaram
* */
$scope.editId = -1;
$scope.setEditId = function (pid) {
$scope.addRow = function (myModel) {
$scope.editId = pid;
$scope.viewId = -1;
};
/*
* cancel edit div
* created by subaram
* */
$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
}
$scope.activityForm = {
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 addactivity = {
method: 'POST',
url: apiPoint.url + 'addActivityDetails/',
@ -31,38 +83,22 @@ app.controller("activityCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$
};
$http(addactivity).then(function (response) {
if (response.data.status == 200 && response.data.activityStatus) {
$scope.ldloading1[loading.replace('-', '_')] = false;
$scope.init();
swal("Success!", response.data.message, "success");
$state.go($state.current, {}, { reload: true });
} else {
$scope.ldloading1[loading.replace('-', '_')] = false;
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
*
@ -93,4 +129,63 @@ app.controller("activityCtrl", ["$scope", "toaster", "$filter", "API_POINTS", "$
}
});
};
/*
* update the Activity details
* created by Surendiran
* */
$scope.updateActivity = 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 + 'updateActivityDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
ListCode: myModel.ListCode,
ListName: myModel.ListName,
description: myModel.Description,
status: myModel.IsActive,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
}
};
$http(update).then(function (response) {
if (response.data.status==200 && response.data.activityStatus) {
$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");
}
});
}
};
}]);

View File

@ -1,3 +1,13 @@
<style>
b.fa {
display: inline-block;
border-radius: 60px;
box-shadow: 0px 0px 2px #007AFF;
padding: 0.5em 0.6em;
}
</style>
<section id="page-title">
<div class="row">
<div class="col-sm-8">
@ -11,7 +21,8 @@
</section>
<div class="container-fluid container-fullw bg-white">
<div ng-controller="activityCtrl">
<form class="form-horizontal" role="form" ng-submit="addRow(companies)">
<form class="form-horizontal" role="form" id="form" name="Form" ng-submit="activityForm.submit(Form, companies, 'zoom-in')" method="post">
<!-- 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>
@ -21,25 +32,32 @@
</div>
</div>
<!-- End :Auto Generate Activity ID -->
<div class="form-group">
<div class="form-group" ng-class="{'has-error':Form.ActivityName.$dirty && Form.ActivityName.$invalid, 'has-success':Form.ActivityName.$valid}">
<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"
/>
<input type="text" class="form-control" name="ActivityName" placeholder="Enter Activity Name" ng-model="companies.ActivityName" required/>
<span class="error text-small block"
ng-if="Form.ActivityName.$dirty && Form.ActivityName.$error.required">Activity Name is required</span>
<span class="error text-small block"
ng-if="Form.ActivityName.$dirty && Form.ActivityName.$error.pattern">Invalid Activity Name </span>
</div>
</div>
<div class="form-group">
<div class="form-group" ng-class="{'has-error':Form.ActivityName.$dirty && Form.ActivityName.$invalid, 'has-success':Form.ActivityName.$valid}">
<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"
<input type="text" class="form-control" name="Description" placeholder="Enter Description" ng-model="companies.Description" required
/>
<span class="error text-small block"
ng-if="Form.Description.$dirty && Form.Description.$error.required">Activity Name is required</span>
<span class="error text-small block"
ng-if="Form.Description.$dirty && Form.Description.$error.pattern">Invalid Activity Name </span>
</div>
</div>
<div class="col-md-4 col-md-offset-4">
<div class="form-group">
<input type="submit" value="Submit" class="btn btn-primary" />
<input type="submit" value="Submit" ladda="ldloading1.zoom_in" tabindex="9" class="btn btn-wide btn-success" data-style="zoom-in"/>
</div>
</div>
@ -53,8 +71,7 @@
</th>
<th>Description
</th>
<th>Active/De-Active
</th>
</tr>
</thead>
@ -64,15 +81,24 @@
<td>{{p.ListName}}</td>
<td>{{p.Description}}</td>
<td ng-if="p.IsActive==true">
<!--<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>
</td>-->
<td>
<a href="#" class="text-azure" id="editRowBtn{{p.ListCode}}" ng-click="setEditId(p.ListCode);"><b class="fa fa-hover fa-pencil " aria-hidden="true"></b>
</a>
</td>
</tr>
<tr ng-show="editId === p.ListCode" ng-if="editId === p.ListCode" >
<td colspan="12" ng-include
src="'assets/views/editActivityDetails.html'"></td>
</tr>
</tbody>

View File

@ -0,0 +1,102 @@
<form name="Form" id="form" novalidate>
<div class="row">
<div class="col-md-12">
<div class="col-md-12">
<fieldset>
<legend>
Update Activity Details
</legend>
<div class="row">
<div class="col-md-3 form-group"
ng-class="{'has-error':Form.ListCode.$dirty && Form.ListCode.$invalid, 'has-success':Form.ListCode.$valid}">
<label>
Activity ID<span class="symbol required"></span>
</label>
<input type="text" placeholder="Enter Activity ID"
tabindex="1" class="form-control" name="ActivityID"
ng-model="p.ListCode" readonly required/>
<span class="error text-small block"
ng-if="Form.ListCode.$dirty && Form.ListCode.$error.required">Activity ID is required</span>
</div>
<div class="col-md-3 form-group"
ng-class="{'has-error':Form.ListName.$dirty && Form.ListName.$invalid, 'has-success':Form.ListName.$valid}">
<label>
Activity Name <span class="symbol required"></span>
</label>
<input type="text" placeholder="Enter Activity Name"
tabindex="1" class="form-control" name="ListName"
ng-model="p.ListName" required/>
<span class="error text-small block"
ng-if="Form.ListName.$dirty && Form.ListName.$error.required">Activity Name is required</span>
<span class="error text-small block"
ng-if="Form.ListName.$dirty && Form.ListName.$error.pattern">Invalid Activity Name </span>
</div>
<div class="col-md-3 form-group"
ng-class="{'has-error':Form.Description.$dirty && Form.Description.$invalid, 'has-success':Form.Description.$valid}">
<label>
Description <span class="symbol required"></span>
</label>
<input type="text" placeholder="Enter Description Name"
tabindex="1" class="form-control" name="Description"
ng-model="p.Description" required/>
<span class="error text-small block"
ng-if="Form.Description.$dirty && Form.Description.$error.required">Description is required</span>
<span class="error text-small block"
ng-if="Form.Description.$dirty && Form.Description.$error.pattern">Invalid Description Code </span>
</div>
<div class="col-md-3">
<label>
Active/De-Active
</label>
<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="row">
<div class="col-md-12">
<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="updateActivity(p,Form,'zoom-in')">
Save
</button>
<input type="button" class="btn btn-warning btn-wide" tabindex="10" value="Cancel"
ng-click="cancel();">
</input>
</div>
</div>
</div>
</fieldset>
</div>
</div>
</div>
</div>
</form>
<!-- class="editRowTd" -->