study material report call tracking reload chnages

This commit is contained in:
gandhimathi 2018-08-23 13:21:24 +05:30
parent b6db762e97
commit a20c3907a8

View File

@ -89,7 +89,12 @@ app.controller('report_study_material_statusCtrl', ["$scope", "$filter","$rootSc
$scope.show = false;
$scope.onSubmit = function (form) {
$scope.filterUniv = angular.fromJson($scope.univModel.university);
if(angular.isString($scope.univModel.university)) {
$scope.filterUniv = angular.fromJson($scope.univModel.university);
}
else{
$scope.filterUniv=$scope.univModel.university;
}
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -165,10 +170,235 @@ $scope.exportExcel= function () {
alasql('SELECT * INTO CSV("Study_material_status.csv",{headers:true}) \
FROM HTML("#data",{headers:true})');
}
/*modal controller
* */
app.controller('studentModalDemoCtrl', ["$scope","$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope,$rootScope, $modal, $log, apiPoint, $http) {
/**
* Auto Call Tracking Status
*/
$scope.selectedStudentsID = [];
$scope.isCheckAll = function(e){
var val = (e.target.checked ? true : false);
if(val)
{
// $scope.disable = false;
var len = $scope.study_mat_data.length;
var i = 0;
for(i=0;i<len;i++)
{
if($scope.selectedStudentsID.indexOf($scope.study_mat_data[i]) === -1)
{
$scope.selectedStudentsID.push($scope.study_mat_data[i]);
}
}
}
else
{
// $scope.disable = true;
$scope.selectedStudentsID = [];
}
if($scope.selectedStudentsID !=''){
$scope.disable = false;
}else{
$scope.disable = true;
}
}
$scope.isClick = function(e){
var ide = e.target;
var val = (ide.checked ? true : false);
var sid = e.target.id;
//console.log(sid);
angular.forEach($scope.study_mat_data,function(value,key){
// console.log()
if(sid == value.Student_id)
{
sid = value;
}
});
var pos = $scope.selectedStudentsID.indexOf(sid);
if(val)
{
if( pos == -1)
{
$scope.selectedStudentsID.push(sid);
}
}
else
{
$scope.selectedStudentsID.splice(pos,1);
}
//
if(val){
$scope.disable = false;
}else{
$scope.disable = true;
}
}
$scope.calltracking = function(){
//$rootScope.student = $scope.selectedStudentsID;
if($scope.selectedStudentsID ==''){
swal('Select Check box','','warning');
return false;
}else{
$scope.controller = 'ng-controller="report_study_material_statusCtrl"';
var lead = {
method: 'POST',
url: apiPoint.url + 'getTrackingLeadDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
student:$scope.selectedStudentsID,
branchID:JSON.parse(localStorage.getItem('localObj')).localBranchID,
userType:JSON.parse(localStorage.getItem('localObj')).localType,
}
};
$http(lead).then(function (response) {
if (response.data.status==200) {
$rootScope.activity = response.data.activityDetails;
$rootScope.status = response.data.statusDetails;
$rootScope.staffDetails = response.data.staffDetails;
$rootScope.studentDetails = $scope.selectedStudentsID;
// $scope.modalopen($scope.activity);
// define modal in root scope
$rootScope.modalInstance = $modal.open({
templateUrl: 'assets/views/autoCalltracking.html',
controller: 'report_study_material_statusCtrl',
// size: size,
resolve: {
pdfitems: function () {
return $scope.activity;
}
}
});
$rootScope.modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}
});
}
}
$scope.trackForm = {
submit: function (form, myModel,loading,selectedStudents) {
if(isNaN(myModel.date)){
$scope.nextFollowupDate = myModel.date;
}
else{
$scope.getdate=new Date(myModel.date).toDateString();
$scope.nextFollowupDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy');
}
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;
/* hide this fun after branch level changes
if($scope.userType !='R004'){
$scope.updateBranchID = JSON.parse(localStorage.getItem('localObj')).localBranchID;
$scope.updateAssignTo = myModel.assignedTo;
}
else{
$scope.updateBranchID = myModel.branch.BranchCode;
$scope.updateAssignTo = myModel.assignedTo;
}*/
var addLead = {
method: 'POST',
url: apiPoint.url + 'autoAddlead/',
headers: {
'Content-Type': 'application/json'
},
data: {
student:selectedStudents,
date: $scope.nextFollowupDate,
activity: myModel.activity.activityID,
assignedTo: myModel.assignedTo,
status: myModel.status,
referedBy: myModel.referedBy,
comments:"Call Tracking For Study Material Status Report ",
enquiryStatus:myModel.enquiryStatus,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(addLead).then(function (response) {
if (response.data.status==200 && response.data.leadDetails.leadStatus == true) {
swal(" ", response.data.leadDetails.message, "success");
$rootScope.modalInstance.close();
$state.go($state.current, {}, { reload: true });
} else {
swal(" ", response.data.leadDetails.message, "error");
}
});
}
},
reset: function (form) {
$scope.myModel = angular.copy($scope.master);
form.$setPristine(true);
$scope.myModel = {
"studentName": "",
"mobileNumber": "",
"universityName": "",
"courseName": "",
"activity": "",
"assignedTo": "",
"status": "",
"referedBy": '',
"comments":''
};
}
};
/*
*End Call Tracking Status
*/
}]);
/*modal controller
* */
app.controller('studentModalDemoCtrl', ["$scope","$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope,$rootScope, $modal, $log, apiPoint, $http) {
//Tooltip for print button
$scope.dynamicTooltip = 'Student View';
@ -286,7 +516,7 @@ app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items", "Words
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
$modalInstance.dismiss('cancel');
};
@ -306,240 +536,6 @@ app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1", "Wor
}]);
/**
* Auto Call Tracking Status
*/
$scope.selectedStudentsID = [];
$scope.isCheckAll = function(e){
var val = (e.target.checked ? true : false);
if(val)
{
// $scope.disable = false;
var len = $scope.study_mat_data.length;
console.log(len);
console.log($scope.study_mat_data);
var i = 0;
for(i=0;i<len;i++)
{
if($scope.selectedStudentsID.indexOf($scope.study_mat_data[i]) === -1)
{
$scope.selectedStudentsID.push($scope.study_mat_data[i]);
}
}
}
else
{
// $scope.disable = true;
$scope.selectedStudentsID = [];
}
if($scope.selectedStudentsID !=''){
$scope.disable = false;
}else{
$scope.disable = true;
}
console.log($scope.selectedStudentsID);
}
$scope.isClick = function(e){
var ide = e.target;
var val = (ide.checked ? true : false);
var sid = e.target.id;
//console.log(sid);
angular.forEach($scope.study_mat_data,function(value,key){
// console.log()
if(sid == value.Student_id)
{
sid = value;
}
});
console.log(sid);
var pos = $scope.selectedStudentsID.indexOf(sid);
//alert(val);
if(val)
{
if( pos == -1)
{
//console.log("PUSH");
$scope.selectedStudentsID.push(sid);
}
}
else
{
//console.log("POP");
$scope.selectedStudentsID.splice(pos,1);
}
//
if(val){
$scope.disable = false;
}else{
$scope.disable = true;
}
console.log($scope.selectedStudentsID);
}
$scope.calltracking = function(){
//$rootScope.student = $scope.selectedStudentsID;
if($scope.selectedStudentsID ==''){
swal('Select Check box','','warning');
return false;
}else{
$scope.controller = 'ng-controller="report_study_material_statusCtrl"';
var lead = {
method: 'POST',
url: apiPoint.url + 'getTrackingLeadDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
student:$scope.selectedStudentsID,
branchID:JSON.parse(localStorage.getItem('localObj')).localBranchID,
userType:JSON.parse(localStorage.getItem('localObj')).localType,
}
};
$http(lead).then(function (response) {
if (response.data.status==200) {
$rootScope.activity = response.data.activityDetails;
$rootScope.status = response.data.statusDetails;
$rootScope.staffDetails = response.data.staffDetails;
$rootScope.studentDetails = $scope.selectedStudentsID;
// $scope.modalopen($scope.activity);
var modalInstance = $modal.open({
templateUrl: 'assets/views/autoCalltracking.html',
controller: 'report_study_material_statusCtrl',
// size: size,
resolve: {
pdfitems: function () {
return $scope.activity;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}
});
}
}
$scope.trackForm = {
submit: function (form, myModel,loading,selectedStudents) {
//console.log(selectedStudents);
if(isNaN(myModel.date)){
$scope.nextFollowupDate = myModel.date;
}
else{
$scope.getdate=new Date(myModel.date).toDateString();
$scope.nextFollowupDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy');
}
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;
/* hide this fun after branch level changes
if($scope.userType !='R004'){
$scope.updateBranchID = JSON.parse(localStorage.getItem('localObj')).localBranchID;
$scope.updateAssignTo = myModel.assignedTo;
}
else{
$scope.updateBranchID = myModel.branch.BranchCode;
$scope.updateAssignTo = myModel.assignedTo;
}*/
var addLead = {
method: 'POST',
url: apiPoint.url + 'autoAddlead/',
headers: {
'Content-Type': 'application/json'
},
data: {
student:selectedStudents,
date: $scope.nextFollowupDate,
activity: myModel.activity.activityID,
assignedTo: myModel.assignedTo,
status: myModel.status,
referedBy: myModel.referedBy,
comments:"Call Tracking For Study Material Status Report ",
enquiryStatus:myModel.enquiryStatus,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(addLead).then(function (response) {
console.log(response);
if (response.data.status==200 && response.data.leadDetails.leadStatus == true) {
swal(" ", response.data.leadDetails.message, "success");
window.location.reload();
} else {
swal(" ", response.data.leadDetails.message, "error");
window.location.reload();
}
});
}
},
reset: function (form) {
$scope.myModel = angular.copy($scope.master);
form.$setPristine(true);
$scope.myModel = {
"studentName": "",
"mobileNumber": "",
"universityName": "",
"courseName": "",
"activity": "",
"assignedTo": "",
"status": "",
"referedBy": '',
"comments":''
};
}
};
/*
*End Call Tracking Status
*/
}]);