apollodec/Apollo/assets/js/controllers/callTrackingCtrl.js
venbatechnologies@gmail.com 2274dd9d7a call tracking
2018-10-26 13:51:42 +05:30

2081 lines
69 KiB
JavaScript
Executable File

'use strict';
/**
* controllers for ng-table
* Simple table with sorting and filtering on AngularJS
*/
app.controller('callTrackingCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
localStorage.setItem('searchName','');
localStorage.setItem('searchMobile','');
$scope.userType=JSON.parse(localStorage.getItem('localObj')).localType;
$scope.myModel = {
"studentName": "",
"mobileNumber": "",
"universityName": "",
"courseName": "",
"date": new Date(),
"activity": "",
"assignedTo": "",
"status": "",
"referedBy": '',
"comments":'',
"enquiryStatus":'',
"alterMobileNumber":'',
"address":'',
"important":false,
"branch":""
};
//get current date
$scope.hideDateSearch=true;
$scope.modifyMinDate = moment();
$scope.minDate = $filter('date')($scope.modifyMinDate, 'MM-dd-yyyy');
$scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy');
// get 30 plus date for follwup details
$scope.modifyDate = moment();
$scope.modifyDate.add(30, 'days');
$scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy');
$scope.myModel.date=$scope.currentDate;
if(localStorage.getItem('searchObj') !='' && localStorage.getItem('searchObj') !=null && localStorage.getItem('searchObj') !=undefined){
$scope.myModel.search=JSON.parse(localStorage.getItem('searchObj')).fromDate;
$scope.myModel.searchDate=JSON.parse(localStorage.getItem('searchObj')).fromDate;
$scope.myModel.dateTo = JSON.parse(localStorage.getItem('searchObj')).toDate;
$scope.search2 = JSON.parse(localStorage.getItem('searchObj')).searchName;
$scope.search3 = {
"ActivityName" :JSON.parse(localStorage.getItem('searchObj')).serachActivity
};
$scope.search4 = { "Firstname": JSON.parse(localStorage.getItem('searchObj')).searchAssignTo
};
$scope.search5 = { "statusName" : JSON.parse(localStorage.getItem('searchObj')).searchStatus
};
localStorage.setItem('searchObj','');
}
else{
$scope.myModel.search=$filter('date')(new Date(), 'yyyy-MM-dd');
$scope.myModel.searchDate=$scope.currentDate;
}
$scope.toMinDate = $filter('date')($scope.modifyMinDate, 'MM-dd-yyyy');
$scope.checkDate = function (value,type) {
// console.log(value.searchDate);
if(value.searchDate==null || value.searchDate==undefined){
$scope.myModel.search='';
$scope.toMinDate = '';
$scope.myModel.dateTo='';
}
else{
if(type=='2'){
$scope.myModel.search = $filter('date')(value.searchDate, 'yyyy-MM-dd');
$scope.toMinDate = $filter('date')(value.searchDate, 'MM-dd-yyyy');
}
}
$scope.searchDateArray(value,type);
}
/*
* check to date
* */
$scope.status='';
$scope.checkToDate = function (value,status) {
$scope.status=status;
if(value.searchDate==null || value.searchDate==undefined){
swal("Failed!", 'Please Select From Date', "error");
$scope.myModel.dateTo='';
$scope.myModel.search='';
$scope.toMinDate = '';
}
else{
if(value.searchDate!=null && value.dateTo!=null && status=='true')
{
$scope.filterSearch=$filter('date')(value.searchDate,value.dateTo);
$scope.search=$scope.filterSearch;
}
}
$scope.searchDateArray(value,status);
}
/*
* make a search date array
*/
$scope.searchDateArray=function (dateValue,status) {
var listDate = [];
if((dateValue.search !=null && dateValue.search !=undefined) && (dateValue.dateTo !=null && dateValue.dateTo !=undefined && dateValue.dateTo !='')){
var startDate =dateValue.search;
var endDate = $filter('date')(dateValue.dateTo, 'yyyy-MM-dd');
var dateMove = new Date(startDate);
var strDate = startDate;
if(strDate == endDate){
var startDate =dateValue.search;
// var endDate = $filter('date')(dateValue.searchDate, 'yyyy-MM-dd');
var strDate = startDate;
var arrayDate = $filter('date')(strDate, 'dd-MM-yyyy');
listDate.push(arrayDate);
}
else{
while (strDate < endDate){
var strDate = dateMove.toISOString().slice(0,10);
var arrayDate = $filter('date')(strDate, 'dd-MM-yyyy');
listDate.push(arrayDate);
dateMove.setDate(dateMove.getDate()+1);
};
}
}
else if((dateValue.search !=null && dateValue.search !=undefined) && (dateValue.dateTo ==null || dateValue.dateTo ==undefined || dateValue.dateTo =='')){
var startDate =dateValue.search;
// var endDate = $filter('date')(dateValue.searchDate, 'yyyy-MM-dd');
var strDate = startDate;
var arrayDate = $filter('date')(strDate, 'dd-MM-yyyy');
listDate.push(arrayDate);
}
$scope.init(listDate);
}
/*
* mark call as important
* created by kms
* */
$scope.markAsImportant = function (trackID,flag) {
var markas = {
method: 'POST',
url: apiPoint.url + 'callAsImportantFlag/',
headers: {
'Content-Type': 'application/json'
},
data: {
flag:flag,
trackId:trackID,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(markas).then(function (response) {
if (response.data.status==200 && response.data.updatedStatus) {
$scope.checkToDateForMark($scope.myModel);
} else {
$scope.checkToDateForMark($scope.myModel);
}
});
}
/*
* check to date while marking
* */
$scope.checkToDateForMark = function (value) {
if(value.searchDate==null || value.searchDate==undefined){
$scope.myModel.dateTo='';
$scope.myModel.search='';
$scope.toMinDate = '';
}
else{
$scope.filterSearch=$filter('date')(value.searchDate, 'dd-MM-yyyy');
$scope.search=$scope.filterSearch;
}
$scope.searchDateArray(value);
}
/*
* edit track details
* created by kms
* */
$scope.setEditId = function (p,search1,search2,search3,search4,search5,fromDate,toDate) {
$scope.searchData = {
"searchDate": search1,
"searchName": search2,
'serachActivity': search3,
'searchAssignTo': search4,
'searchStatus': search5,
'callFrom':"details",
"fromDate": fromDate,
"toDate": toDate,
}
localStorage.setItem('searchObj', JSON.stringify($scope.searchData));
localStorage.setItem('trackID', p.TrackingID);
localStorage.setItem('count', 0);
$rootScope.followupDetails=p;
/* $rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
$rootScope.currentDate1=new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$rootScope.myModel1.date=$rootScope.followupDetails.followupDetails[0].FollowupOn;*/
/* $scope.editId = pid;*/
$state.go('app.call.trackingFollowup');
};
/*
* Submit,update and reset track details
* @params myModel
* created by kms
* */
$scope.trackForm = {
submit: function (form, myModel,loading) {
//console.log(myModel.activity.activityName);
var string = myModel.activity.activityName;
var Upperstring = string.toUpperCase();
var checkresult = Upperstring.search("ADMISSION");
var msgactivity = 0;
if(checkresult != -1)
{
msgactivity = 1;
}
// console.log(msgactivity)
// return false;
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;
}*/
// console.log(myModel.emailId);
var addLead = {
method: 'POST',
url: apiPoint.url + 'addLeadTrackingDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
studentName: myModel.studentName,
mobileNumber: myModel.mobileNumber,
universityID: myModel.universityName,
courseName: myModel.courseName,
date: $scope.nextFollowupDate,
activity: myModel.activity.activityID,
assignedTo: myModel.assignedTo,
status: myModel.status,
referedBy: myModel.referedBy,
comments:myModel.comments,
alterMobile:myModel.alterMobileNumber,
address:myModel.address,
emailId:myModel.emailId,
enquiryStatus:myModel.enquiryStatus,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
msgactivity:msgactivity
}
};
$http(addLead).then(function (response) {
if (response.data.status==200 && response.data.leadStatus) {
$scope.ldloading1[loading.replace('-', '_')] = false;
swal(" ", "Lead tracking added successfully.", "success");
$state.go($state.current, {}, {reload: true});
} else {
$scope.ldloading1[loading.replace('-', '_')] = false;
swal(" ", response.data.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":''
};
}
};
/*
* get student exist or not for add lead details
* created by kms
* */
$scope.loading=false;
$scope.getLead = function (form,mobile) {
//call form success
if(form.mobilenumber.$valid){
$scope.loading=true;
var lead = {
method: 'POST',
url: apiPoint.url + 'getTrackingLeadDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
mobileNumber:mobile,
branchID:JSON.parse(localStorage.getItem('localObj')).localBranchID,
userType:JSON.parse(localStorage.getItem('localObj')).localType,
}
};
$http(lead).then(function (response) {
if (response.data.status==200) {
$scope.myModel.courseName=response.data.existLeadDetails.CourseID;
$scope.myModel.enquiryStatus=response.data.existLeadDetails.IsNewEnquiry;
$scope.activity=response.data.activityDetails;
$scope.status=response.data.statusDetails;
$scope.staffDetails=response.data.staffDetails;
//$scope.university=response.data.universityDetails;
// $scope.myModel.status=$scope.status[0].ListCode;
$scope.myModel.studentName=response.data.existLeadDetails.LeadName;
$scope.myModel.universityName=response.data.existLeadDetails.University;
$scope.myModel.courseName=response.data.existLeadDetails.Course;
$scope.myModel.alterMobileNumber=response.data.existLeadDetails.AlternateMobile;
$scope.myModel.address=response.data.existLeadDetails.Address;
// find index for university drop down list
/* for(var i in $scope.university) {
if($scope.university[i].universityID==response.data.existLeadDetails.UniversityID){
$scope.myModel.universityName=$scope.university[i];
}
}*/
$scope.loading=false;
} else {
$scope.loading=false;
}
});
}
else{
$scope.loading=false;
}
};
$scope.trackingTodayno=0;
/*
*get tracking list
* created by kms
* */
$scope.init = function (myModel) {
// console.log(myModel);
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE=='R005')) {
}else {
if(logcheck != null && LOCALTYPE !='R001') {
$state.go('app.dashboard');
} else {
//ipCookie.remove('cookiechk');
window.localStorage.clear();
$state.go('login.signin');
}
}
$scope.data = [];
if(myModel!='' && myModel!=undefined){
$scope.finalSearchArry=myModel;
}
else{
$scope.finalSearchArry="";
}
$scope.loader = true;
var getTrackDetails = {
method: 'POST',
url: apiPoint.url + 'getTrackingDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
searchDate: $scope.finalSearchArry,
status: $scope.status
}
};
$http(getTrackDetails).then(function (response) {
$scope.trackingTodayno=response.data.TotalCallToday;
if(response.data.pendingTrackingDetails.trackingStatus && response.data.trackingDetails.length > 0){
$scope.loader = false;
//console.log(response.data.TotalCallToday);
//console.log(response.data)
//$scope.currentDate1=$filter('date')(new Date(), 'dd-MM-yyyy');
$scope.tillPendingDetails = response.data.pendingTrackingDetails.trackingDetails;
angular.forEach($scope.tillPendingDetails, function (value, key) {
$scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
// $scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$scope.currentDate=$filter('date')(new Date(), 'yyyy-MM-dd');
var getDay = value.followupDetails.substring(0, 2);
var getMonth = value.followupDetails.substring(3, 5);
var getYear = value.followupDetails.substring(6, 10);
// var dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
$scope.dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
if (($scope.currentDate) > ( $scope.dbFollowDate) && (value.statusName!='CLOSE')) {
$scope.data.push(value);
}
});
angular.forEach(response.data.trackingDetails, function (value1, key1) {
$scope.data.push(value1);
});
$rootScope.trackingStatus = response.data.statusDetails;
localStorage.setItem('trackingList', JSON.stringify($scope.data));
}
else if (response.data.status == 200 && response.data.trackingStatus == true && response.data.pendingTrackingDetails.trackingStatus !=true) {
$scope.loader = false;
$rootScope.trackingStatus = response.data.statusDetails;
$scope.data = response.data.trackingDetails;
localStorage.setItem('trackingList', JSON.stringify($scope.data));
}
else if (response.data.trackingStatus != true && response.data.pendingTrackingDetails.trackingStatus) {
$scope.loader = false;
$rootScope.trackingStatus = response.data.statusDetails;
$scope.tillPendingDetails = response.data.pendingTrackingDetails.trackingDetails;
angular.forEach($scope.tillPendingDetails, function (value, key) {
$scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
// $scope.currentDate = new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$scope.currentDate=$filter('date')(new Date(), 'yyyy-MM-dd');
var getDay = value.followupDetails.substring(0, 2);
var getMonth = value.followupDetails.substring(3, 5);
var getYear = value.followupDetails.substring(6, 10);
// var dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
$scope.dbFollowDate = getYear+'-'+getMonth+'-'+getDay;
if (($scope.currentDate) > ($scope.dbFollowDate) && (value.statusName!='CLOSE')) {
$scope.data.push(value);
}
});
localStorage.setItem('trackingList', JSON.stringify($scope.data));
}
else if(response.data.trackingStatus == 1)
{
console.log('hai');
}
else {
$scope.loader = false;
$scope.branchInfo = '';
$scope.data='';
}
//sconsole.log($scope.data);
});
}
// 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
}
}]);
/*
* lead controller
* */
app.controller('callTrackingLeadCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
localStorage.setItem('searchName','');
localStorage.setItem('searchMobile','');
$scope.myModel = {
"leadDate": new Date(),
"search":$filter('date')(new Date(), 'yyyy-MM-dd')
};
$scope.hideDateSearch=true;
//get current date
$scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy');
$scope.maxDate=moment();
// get 30 plus date for follwup details
$scope.modifyDate = moment();
$scope.modifyDate.add(30, 'days');
$scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy');
if(localStorage.getItem('searchObj') !='' && localStorage.getItem('searchObj') !=null && localStorage.getItem('searchObj') !=undefined){
$scope.myModel.leadDate = $filter('date')(JSON.parse(localStorage.getItem('searchObj')).fromDate, 'dd-MM-yyyy');
$scope.myModel.search = JSON.parse(localStorage.getItem('searchObj')).fromDate;
localStorage.setItem('searchObj','');
}
else{
$scope.myModel.leadDate=$scope.currentDate;
}
/*
* edit track details
* created by kms
* */
$scope.setEditId = function (p,search1,search2,search3,search4,search5,fromDate) {
// alert('in');
// return false;
$scope.changeFromDate= $filter('date')(fromDate, 'yyyy-MM-dd');
$scope.searchData = {
"searchDate": search1,
"searchName": search2,
'serachActivity': search3,
'searchAssignTo': search4,
'searchStatus': search5,
'callFrom': "lead",
'fromDate':$scope.changeFromDate
}
localStorage.setItem('searchObj', JSON.stringify($scope.searchData));
localStorage.setItem('trackID', p.TrackingID);
localStorage.setItem('count', 0);
$rootScope.followupDetails=p;
/* $rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
$rootScope.currentDate1=new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$rootScope.myModel1.date=$rootScope.followupDetails.followupDetails[0].FollowupOn;*/
/* $scope.editId = pid;*/
$state.go('app.call.trackingFollowup');
};
// 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
}
/*
* mark call as important
* created by kms
* */
$scope.markAsImportant = function (trackID,flag) {
var markas = {
method: 'POST',
url: apiPoint.url + 'callAsImportantFlag/',
headers: {
'Content-Type': 'application/json'
},
data: {
flag:flag,
trackId:trackID,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(markas).then(function (response) {
if (response.data.status==200 && response.data.updatedStatus) {
$scope.init($scope.myModel);
} else {
$scope.init($scope.myModel);
}
});
}
//from date change
$scope.checkDate = function (value) {
$scope.myModel.search = $filter('date')(value.leadDate, 'yyyy-MM-dd');
$scope.init($scope.myModel);
}
/*
*get tracking list
* created by kms
* */
$scope.init = function (myModel) {
/* if(isNaN(myModel.leadDate)){
$scope.loadDate= $filter('date')(new Date(), 'yyyy-MM-dd');
}
else if(myModel.leadDate==null || myModel.leadDate==''){
$scope.loadDate="";
}
else{
$scope.getdate=new Date(myModel.leadDate).toDateString();
$scope.loadDate = $filter('date')(new Date($scope.getdate), 'yyyy-MM-dd');
}*/
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R005' || LOCALTYPE == 'R002')) {
// console.log("if");
}else {
if(logcheck != null && LOCALTYPE !='R001') {
// console.log("else if");
$state.go('app.dashboard');
} else {
// console.log("else else");
//ipCookie.remove('cookiechk');
window.localStorage.clear();
$state.go('login.signin');
}
}
$scope.loader = true;
var getRecentlead = {
method: 'POST',
url: apiPoint.url + 'getRecentLeadDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
loadDate:myModel.search,
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(getRecentlead).then(function (response) {
if (response.data.status == 200 && response.data.trackingStatus == true) {
$scope.loader = false;
$rootScope.trackingStatus = response.data.statusDetails;
$scope.data = response.data.trackingDetails;
console.log($scope.data);
localStorage.setItem('trackingList', JSON.stringify($scope.data));
// this for search box
/* $scope.search = {searchDate: ''};
$scope.tableParams = new ngTableParams({
page: 1,
count: 10,
filter: $scope.search
}, {
total: data.length,
getData: function ($defer, params) {
var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
orderedData = params.filter() ? $filter('filter')(orderedData, params.filter().followupDate) : orderedData;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});*/
} else {
$scope.loader = false;
$scope.data='';
}
});
}
}]);
/*
* close tracking controller
* */
app.controller('callTrackingCloseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
localStorage.setItem('searchName','');
localStorage.setItem('searchMobile','');
$scope.myModel = {
"closeDate": new Date(),
"search":$filter('date')(new Date(), 'yyyy-MM-dd')
};
$scope.hideDateSearch=true;
//get current date
$scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy');
$scope.maxDate=moment();
// get 30 plus date for follwup details
$scope.modifyDate = moment();
$scope.modifyDate.add(30, 'days');
$scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy');
if(localStorage.getItem('searchObj') !='' && localStorage.getItem('searchObj') !=null && localStorage.getItem('searchObj') !=undefined){
$scope.myModel.closeDate = $filter('date')(JSON.parse(localStorage.getItem('searchObj')).fromDate, 'dd-MM-yyyy');
$scope.myModel.search = JSON.parse(localStorage.getItem('searchObj')).fromDate;
localStorage.setItem('searchObj','');
}
else{
$scope.myModel.closeDate=$scope.currentDate;
}
/*
* edit track details
* created by kms
* */
$scope.setEditId = function (p,search1,search2,search3,search4,search5,fromDate) {
// alert('in');
// return false;
$scope.changeFromDate= $filter('date')(fromDate, 'yyyy-MM-dd');
$scope.searchData = {
"searchDate": search1,
"searchName": search2,
'serachActivity': search3,
'searchAssignTo': search4,
'searchStatus': search5,
'callFrom': "close",
'fromDate':$scope.changeFromDate
}
localStorage.setItem('searchObj', JSON.stringify($scope.searchData));
localStorage.setItem('trackID', p.TrackingID);
localStorage.setItem('count', 0);
$rootScope.followupDetails=p;
/* $rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
$rootScope.currentDate1=new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$rootScope.myModel1.date=$rootScope.followupDetails.followupDetails[0].FollowupOn;*/
/* $scope.editId = pid;*/
$state.go('app.call.trackingFollowup');
};
// 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
}
//from date change
$scope.checkDate = function (value) {
$scope.myModel.search = $filter('date')(value.closeDate, 'yyyy-MM-dd');
$scope.init($scope.myModel);
}
/*
* mark call as important
* created by kms
* */
$scope.markAsImportant = function (trackID,flag) {
var markas = {
method: 'POST',
url: apiPoint.url + 'callAsImportantFlag/',
headers: {
'Content-Type': 'application/json'
},
data: {
flag:flag,
trackId:trackID,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(markas).then(function (response) {
if (response.data.status==200 && response.data.updatedStatus) {
$scope.init($scope.myModel);
} else {
$scope.init($scope.myModel);
}
});
}
/*
*get tracking list
* created by kms
* */
$scope.init = function (myModel) {
/* if(isNaN(myModel.closeDate)){
$scope.loadDate= $filter('date')(new Date(), 'yyyy-MM-dd');
}
else if(myModel.closeDate==null || myModel.closeDate==''){
$scope.loadDate="";
}
else{
$scope.getdate=new Date(myModel.closeDate).toDateString();
$scope.loadDate = $filter('date')(new Date($scope.getdate), 'yyyy-MM-dd');
}*/
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R005' || LOCALTYPE == 'R002' )) {
console.log("if");
}else {
if(logcheck != null && LOCALTYPE !='R001') {
console.log("else if");
$state.go('app.dashboard');
} else {
console.log("else else");
//ipCookie.remove('cookiechk');
window.localStorage.clear();
$state.go('login.signin');
}
}
$scope.loader = true;
var getRecentclose = {
method: 'POST',
url: apiPoint.url + 'getRecentCloseDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
loadDate:myModel.search,
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(getRecentclose).then(function (response) {
if (response.data.status == 200 && response.data.trackingStatus == true) {
$scope.loader = false;
$rootScope.trackingStatus = response.data.statusDetails;
$scope.data = response.data.trackingDetails;
localStorage.setItem('trackingList', JSON.stringify($scope.data));
// this for search box
/* $scope.search = {searchDate: ''};
$scope.tableParams = new ngTableParams({
page: 1,
count: 10,
filter: $scope.search
}, {
total: data.length,
getData: function ($defer, params) {
var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
orderedData = params.filter() ? $filter('filter')(orderedData, params.filter().followupDate) : orderedData;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});*/
} else {
$scope.loader = false;
$scope.data='';
}
});
}
}]);
/*
* pending tracking controller
* */
app.controller('callTrackingPendingCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
localStorage.setItem('searchName','');
localStorage.setItem('searchMobile','');
$scope.myModel = {
"pendingDate": new Date(),
"search":$filter('date')(new Date(), 'yyyy-MM-dd')
};
$scope.hideDateSearch=true;
//get current date
$scope.currentDate=$filter('date')(new Date(), 'dd-MM-yyyy');
$scope.maxDate=moment();
// get 30 plus date for follwup details
$scope.modifyDate = moment();
$scope.modifyDate.add(30, 'days');
$scope.futureDate = $filter('date')($scope.modifyDate, 'dd-MM-yyyy');
if(localStorage.getItem('searchObj') !='' && localStorage.getItem('searchObj') !=null && localStorage.getItem('searchObj') !=undefined){
$scope.myModel.pendingDate = $filter('date')(JSON.parse(localStorage.getItem('searchObj')).fromDate, 'dd-MM-yyyy');
$scope.myModel.search = JSON.parse(localStorage.getItem('searchObj')).fromDate;
localStorage.setItem('searchObj','');
}
else{
$scope.myModel.pendingDate=$scope.currentDate;
}
/*
* edit track details
* created by kms
* */
$scope.setEditId = function (p,search1,search2,search3,search4,search5,fromDate) {
$scope.changeFromDate= $filter('date')(fromDate, 'yyyy-MM-dd');
$scope.searchData = {
"searchDate": search1,
"searchName": search2,
'serachActivity': search3,
'searchAssignTo': search4,
'searchStatus': search5,
'callFrom': "pending",
'fromDate':$scope.changeFromDate
}
localStorage.setItem('searchObj', JSON.stringify($scope.searchData));
localStorage.setItem('trackID', p.TrackingID);
localStorage.setItem('count', 0);
$rootScope.followupDetails=p;
/* $rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
$rootScope.currentDate1=new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
$rootScope.myModel1.date=$rootScope.followupDetails.followupDetails[0].FollowupOn;*/
/* $scope.editId = pid;*/
$state.go('app.call.trackingFollowup');
};
// 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
}
/*
* mark call as important
* created by kms
* */
$scope.markAsImportant = function (trackID,flag) {
var markas = {
method: 'POST',
url: apiPoint.url + 'callAsImportantFlag/',
headers: {
'Content-Type': 'application/json'
},
data: {
flag:flag,
trackId:trackID,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(markas).then(function (response) {
if (response.data.status==200 && response.data.updatedStatus) {
$scope.init($scope.myModel);
} else {
$scope.init($scope.myModel);
}
});
}
//from date change
$scope.checkDate = function (value) {
$scope.myModel.search = $filter('date')(value.pendingDate, 'yyyy-MM-dd');
$scope.init($scope.myModel);
}
/*
*get tracking list
* created by kms
* */
$scope.init = function (myModel) {
/* if(isNaN(myModel.pendingDate)){
$scope.loadDate= $filter('date')(new Date(), 'yyyy-MM-dd');
}
else if(myModel.pendingDate==null || myModel.pendingDate==''){
$scope.loadDate="";
}
else{
$scope.getdate=new Date(myModel.pendingDate).toDateString();
$scope.loadDate = $filter('date')(new Date($scope.getdate), 'yyyy-MM-dd');
}*/
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' )) {
console.log("if");
}else {
if(logcheck != null && LOCALTYPE !='R001') {
console.log("else if");
$state.go('app.dashboard');
} else {
console.log("else else");
//ipCookie.remove('cookiechk');
window.localStorage.clear();
$state.go('login.signin');
}
}
$scope.loader = true;
var getRecentclose = {
method: 'POST',
url: apiPoint.url + 'getRecentPendingDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
loadDate:myModel.search,
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(getRecentclose).then(function (response) {
if (response.data.status == 200 && response.data.trackingStatus == true) {
$scope.loader = false;
$rootScope.trackingStatus = response.data.statusDetails;
$scope.data = response.data.trackingDetails;
localStorage.setItem('trackingList', JSON.stringify($scope.data));
// this for search box
/* $scope.search = {searchDate: ''};
$scope.tableParams = new ngTableParams({
page: 1,
count: 10,
filter: $scope.search
}, {
total: data.length,
getData: function ($defer, params) {
var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
orderedData = params.filter() ? $filter('filter')(orderedData, params.filter().followupDate) : orderedData;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});*/
}
else {
$scope.loader = false;
$scope.data='';
}
});
}
}]);
app.controller('callTrackingCtrl2', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) {
$scope.userType=JSON.parse(localStorage.getItem('localObj')).localType;
$scope.afterRefresh = function () {
$rootScope.myModel1 = {
"status":'',
"date": '',
"comments": "",
"branch":""
};
$rootScope.loadFollowupDetails(localStorage.getItem('trackID'));
};
/*
* used to get tracking list
* */
$rootScope.next = function(trackID){
$scope.ListOfTracks=JSON.parse(localStorage.getItem('trackingList'));
$scope.searchedData=JSON.parse(localStorage.getItem('searchObj'));
// search date in array list
$scope.searchedTrackingList=[];
if($scope.searchedData.searchDate!='' && $scope.searchedData.searchDate!=null && $scope.searchedData.searchDate!=undefined){
angular.forEach($scope.ListOfTracks,function (value,key) {
if((value.followupDetails)==$scope.searchedData.searchDate){
$scope.searchedTrackingList.push(value);
}
});
}
else{
angular.forEach($scope.ListOfTracks,function (value,key) {
$scope.searchedTrackingList.push(value);
});
}
// search name/mobile in array list
$scope.searchedTrackingList_Name=[];
if($scope.searchedData.searchName!='' && $scope.searchedData.searchName!=null && $scope.searchedData.searchName!=undefined){
$scope.regInteger = /^\d+$/;
if($scope.regInteger.test($scope.searchedData.searchName)){
$scope.searchText = $scope.searchedData.searchName;
angular.forEach($scope.searchedTrackingList, function(item) {
if( item.MobileNumber.indexOf($scope.searchText) >= 0 ){
$scope.searchedTrackingList_Name.push(item);
}
});
}
else{
$scope.searchText = $scope.searchedData.searchName.toLowerCase();
angular.forEach($scope.searchedTrackingList, function(item) {
if( item.LeadName.toLowerCase().indexOf($scope.searchText) >= 0 ){
$scope.searchedTrackingList_Name.push(item);
}
});
}
}
else{
angular.forEach($scope.searchedTrackingList,function (value,key) {
$scope.searchedTrackingList_Name.push(value);
});
}
// serach activity in array list
$scope.searchedTrackingList_Activity=[];
if($scope.searchedData.serachActivity!='' && $scope.searchedData.serachActivity!=null && $scope.searchedData.serachActivity!=undefined){
$scope.searchText_activity = $scope.searchedData.serachActivity.toLowerCase();
angular.forEach($scope.searchedTrackingList_Name, function(item) {
if( item.ActivityName.toLowerCase().indexOf($scope.searchText_activity) >= 0 ){
$scope.searchedTrackingList_Activity.push(item);
}
});
}
else{
angular.forEach($scope.searchedTrackingList_Name,function (value,key) {
$scope.searchedTrackingList_Activity.push(value);
});
}
// serach assigned to in array list
$scope.searchedTrackingList_AssignedTo=[];
if($scope.searchedData.searchAssignTo!='' && $scope.searchedData.searchAssignTo!=null && $scope.searchedData.searchAssignTo!=undefined){
$scope.searchText_assignedTo = $scope.searchedData.searchAssignTo.toLowerCase();
angular.forEach($scope.searchedTrackingList_Activity, function(item) {
if(item.Firstname.toLowerCase().indexOf($scope.searchText_assignedTo) >= 0 ){
$scope.searchedTrackingList_AssignedTo.push(item);
}
});
}
else{
angular.forEach($scope.searchedTrackingList_Activity,function (value,key) {
$scope.searchedTrackingList_AssignedTo.push(value);
});
}
// search status in array list
$scope.searchedTrackingList_Status=[];
if($scope.searchedData.searchStatus!='' && $scope.searchedData.searchStatus!=null && $scope.searchedData.searchStatus!=undefined){
$scope.searchText_status = $scope.searchedData.searchStatus.toLowerCase();
angular.forEach($scope.searchedTrackingList_AssignedTo, function(item) {
if( item.statusName.toLowerCase().indexOf($scope.searchText_status) >= 0 ){
$scope.searchedTrackingList_Status.push(item);
}
});
}
else{
angular.forEach($scope.searchedTrackingList_AssignedTo,function (value,key) {
$scope.searchedTrackingList_Status.push(value);
});
}
/*
* used to move next track list in searched array list
* */
angular.forEach($scope.searchedTrackingList_Status,function (value,key) {
if(value.TrackingID==trackID){
$scope.nextTrack=$scope.searchedTrackingList_Status[key+1];
if($scope.nextTrack!='' && $scope.nextTrack!=undefined){
$rootScope.loadFollowupDetails($scope.nextTrack.TrackingID);
}
else{
swal("EMPTY!", "No more records to display", "info");
}
}
});
}
/*
* get previous track list in searched array list
* */
$rootScope.previous = function(trackID){
$scope.prevListOfTracks=JSON.parse(localStorage.getItem('trackingList'));
$scope.prevsearchedData=JSON.parse(localStorage.getItem('searchObj'));
// search date in array list
$scope.prevsearchedTrackingList=[];
if($scope.prevsearchedData.searchDate!='' && $scope.prevsearchedData.searchDate!=null && $scope.prevsearchedData.searchDate!=undefined){
angular.forEach($scope.prevListOfTracks,function (value,key) {
if((value.followupDetails)==$scope.prevsearchedData.searchDate){
$scope.prevsearchedTrackingList.push(value);
}
});
}
else{
angular.forEach($scope.prevListOfTracks,function (value,key) {
$scope.prevsearchedTrackingList.push(value);
});
}
// search name/mobile in array list
$scope.prevsearchedTrackingList_Name=[];
if($scope.prevsearchedData.searchName!='' && $scope.prevsearchedData.searchName!=null && $scope.prevsearchedData.searchName!=undefined){
$scope.prevregInteger = /^\d+$/;
if($scope.prevregInteger.test($scope.prevsearchedData.searchName)){
$scope.prevsearchText = $scope.prevsearchedData.searchName;
angular.forEach($scope.prevsearchedTrackingList, function(item) {
if( item.MobileNumber.indexOf($scope.prevsearchText) >= 0 ){
$scope.prevsearchedTrackingList_Name.push(item);
}
});
}
else{
$scope.prevsearchText = $scope.prevsearchedData.searchName.toLowerCase();
angular.forEach($scope.prevsearchedTrackingList, function(item) {
if( item.LeadName.toLowerCase().indexOf($scope.prevsearchText) >= 0 ){
$scope.prevsearchedTrackingList_Name.push(item);
}
});
}
}
else{
angular.forEach($scope.prevsearchedTrackingList,function (value,key) {
$scope.prevsearchedTrackingList_Name.push(value);
});
}
// serach activity in array list
$scope.prevsearchedTrackingList_Activity=[];
if($scope.prevsearchedData.serachActivity!='' && $scope.prevsearchedData.serachActivity!=null && $scope.prevsearchedData.serachActivity!=undefined){
$scope.prevsearchText_activity = $scope.prevsearchedData.serachActivity.toLowerCase();
angular.forEach($scope.prevsearchedTrackingList_Name, function(item) {
if( item.ActivityName.toLowerCase().indexOf($scope.prevsearchText_activity) >= 0 ){
$scope.prevsearchedTrackingList_Activity.push(item);
}
});
}
else{
angular.forEach($scope.prevsearchedTrackingList_Name,function (value,key) {
$scope.prevsearchedTrackingList_Activity.push(value);
});
}
// serach assigned to in array list
$scope.prevsearchedTrackingList_AssignedTo=[];
if($scope.prevsearchedData.searchAssignTo!='' && $scope.prevsearchedData.searchAssignTo!=null && $scope.prevsearchedData.searchAssignTo!=undefined){
$scope.prevsearchText_assignedTo = $scope.prevsearchedData.searchAssignTo.toLowerCase();
angular.forEach($scope.prevsearchedTrackingList_Activity, function(item) {
if( item.Firstname.toLowerCase().indexOf($scope.prevsearchText_assignedTo) >= 0 ){
$scope.prevsearchedTrackingList_AssignedTo.push(item);
}
});
}
else{
angular.forEach($scope.prevsearchedTrackingList_Activity,function (value,key) {
$scope.prevsearchedTrackingList_AssignedTo.push(value);
});
}
// search status in array list
$scope.prevsearchedTrackingList_Status=[];
if($scope.prevsearchedData.searchStatus!='' && $scope.prevsearchedData.searchStatus!=null && $scope.prevsearchedData.searchStatus!=undefined){
$scope.prevsearchText_status = $scope.prevsearchedData.searchStatus.toLowerCase();
angular.forEach($scope.prevsearchedTrackingList_AssignedTo, function(item) {
if( item.statusName.toLowerCase().indexOf($scope.prevsearchText_status) >= 0 ){
$scope.prevsearchedTrackingList_Status.push(item);
}
});
}
else{
angular.forEach($scope.prevsearchedTrackingList_AssignedTo,function (value,key) {
$scope.prevsearchedTrackingList_Status.push(value);
});
}
/*
* final previous
* result
* */
angular.forEach($scope.prevsearchedTrackingList_Status,function (value,key) {
if(value.TrackingID==trackID){
$scope.prevTrack=$scope.prevsearchedTrackingList_Status[key-1];
if($scope.prevTrack!='' && $scope.prevTrack!=undefined){
$rootScope.loadFollowupDetails($scope.prevTrack.TrackingID);
}
else{
swal("EMPTY!", "No more records to display", "info");
}
}
});
}
/*
* update the follow up details
* created by kms
* */
$rootScope.updateFollowup = function (form,followupDetails,myModel1, loading) {
// alert('com');
// return false;
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{
if(isNaN(myModel1.date)){
$scope.nextFollowupDate = myModel1.date;
}
else{
$scope.getdate=new Date(myModel1.date).toDateString();
$scope.nextFollowupDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy');
}
if(myModel1.status==null || myModel1.status=='' || myModel1.status==undefined){
swal("Warning!", 'Please select status', "warning");
}
else if (myModel1.assignStaff=='') {
swal("Warning!", 'Please select assigned to', "warning");
}
else if (myModel1.comments=='') {
swal("Warning!", 'Please enter comments', "warning");
} else {
/* if($scope.userType !='R004'){
$scope.updateBranchID = JSON.parse(localStorage.getItem('localObj')).localBranchID;
}
else{
$scope.updateBranchID = myModel1.branch;
}*/
$rootScope.ldloading2 = {};
$rootScope.ldloading2[loading.replace('-', '_')] = true;
var update = {
method: 'POST',
url: apiPoint.url + 'updateFollowupDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
trackingID: followupDetails.TrackingID,
date: $scope.nextFollowupDate,
status: myModel1.status,
assignedTo: myModel1.assignStaff,
comments: myModel1.comments,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
address: myModel1.Address,
alternateMobile: myModel1.AlternateMobile,
referredBy: myModel1.ReferredBy,
universityName: followupDetails.UniversityName,
courseName: followupDetails.CourseName,
pendingDocStatus: followupDetails.PendingDocStatus,
}
};
$http(update).then(function (response) {
if (response.data.status==200 && response.data.followupStatus) {
$rootScope.loadFollowupDetails(response.data.trackingID);
$scope.ldloading2[loading.replace('-', '_')] = false;
$rootScope.myModel1.comments='';
} else {
$scope.ldloading[loading.replace('-', '_')] = false;
swal("Failed!", response.data.message, "error");
}
});
}
}
};
$rootScope.loadFollowupDetails = function (trackID) {
// $scope.value = $rootScope.trackingid1;
// console.log($scope.value+'caltracking');
if(trackID==null || trackID=='')
{
$scope.valuesa = $rootScope.trackingid;
$scope.valuea = $rootScope.trackingid1;
if($scope.valuesa == null || $scope.valuesa == ''||$scope.valuesa == undefined)
{
$scope.value=$scope.valuea;
console.log($scope.value+'amn');
$scope.showprev = false;
$scope.shownext = false;
}
else
{
$scope.value = $scope.valuesa;
console.log($scope.value+'sa');
$scope.showprev = false;
$scope.shownext = false;
}
}
else
{
$scope.value = trackID;
$scope.showprev = true;
$scope.shownext =true;
console.log($scope.value);
}
var load = {
method: 'POST',
url: apiPoint.url + 'loadFollowupDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
trackingID: $scope.value,
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
}
};
$http(load).then(function (response) {
if (response.data.status==200 && response.data.followupStatus) {
$rootScope.followupDetails=response.data.trackingDetails[0];
$rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
if($rootScope.followupDetails.followupDetails[0].FollowupOn.length==10){
$rootScope.currentDate1 = new Date($rootScope.followupDetails.followupDetails[0].FollowupOn.substring(6,10)+'-'+$rootScope.followupDetails.followupDetails[0].FollowupOn.substring(3,5)+'-'+$rootScope.followupDetails.followupDetails[0].FollowupOn.substring(0,2));
}
else{
$rootScope.currentDate1=new Date().getFullYear() + '-' + ('0' + (new Date().getMonth() + 1)).slice(-2) + '-' + ('0' + new Date().getDate()).slice(-2);
}
if($rootScope.currentDate1>new Date()){
$rootScope.currentDate1=new Date();
}
$rootScope.myModel1.date=$rootScope.followupDetails.followupDetails[0].FollowupOn;
// get 30 plus date for follwup details
$rootScope.modifyDate1 = moment();
$rootScope.modifyDate1.add(30, 'days');
$rootScope.futureDate1 = $filter('date')($scope.modifyDate1, 'dd-MM-yyyy');
// $rootScope.myModel1.status=$rootScope.followupDetails.StatusCode;
$rootScope.trackingStatus=response.data.statusDetails;
$rootScope.myModel1.branch=$rootScope.followupDetails.CreatedBranch;
$rootScope.myModel1.assignStaff=$rootScope.followupDetails.AssignedTo;
$rootScope.myModel1.AlternateMobile=$rootScope.followupDetails.AlternateMobile;
$rootScope.myModel1.Address=$rootScope.followupDetails.Address;
$rootScope.myModel1.ReferredBy=$rootScope.followupDetails.ReferredBy;
$rootScope.staffArray='';
$rootScope.staffDetails=response.data.staffDetails;
/* hide this fun after branch level changes
if($scope.userType =='R004'){
// get deactive branch list
$scope.checkBranchData = {
BranchCode: $rootScope.followupDetails.CreatedBranch,
BranchName: $rootScope.followupDetails.CreatedBranchName +'-'+$rootScope.followupDetails.CreatedBranch
};
var branchresult = $filter('filter')($rootScope.staffDetails, $scope.checkBranchData);
if(branchresult.length==0){
$rootScope.staffDetails.push($scope.checkBranchData);
}
// end deactive branch
angular.forEach($rootScope.staffDetails, function(item) {
if(item.BranchCode==$rootScope.myModel1.branch){
$rootScope.staffArray = item.staffDetails;
}
});
// get deactive staff details list
$scope.checkEmpData = {
loginId: $rootScope.followupDetails.AssignedTo,
staffName: $rootScope.followupDetails.Firstname +'-'+$rootScope.followupDetails.StaffID
};
if($rootScope.staffArray){
var empresult = $filter('filter')($rootScope.staffArray, $scope.checkEmpData);
if(empresult.length==0){
$rootScope.staffArray.push($scope.checkEmpData);
}
}
else{
$rootScope.staffArray=[];
$rootScope.staffArray.push($scope.checkEmpData);
}
}
else{
// get deactive staff details list
$scope.checkEmpData = {
loginId: $rootScope.followupDetails.AssignedTo,
staffName: $rootScope.followupDetails.Firstname +'-'+$rootScope.followupDetails.StaffID
};
if($rootScope.staffDetails){
var empresult = $filter('filter')($rootScope.staffDetails, $scope.checkEmpData);
if(empresult.length==0){
$rootScope.staffDetails.push($scope.checkEmpData);
}
}
else{
$rootScope.staffDetails=[];
$rootScope.staffDetails.push($scope.checkEmpData);
}
}*/
// ref1 start after branch level changes
// get deactive staff details list
$scope.checkEmpData = {
loginId: $rootScope.followupDetails.AssignedTo,
staffName: $rootScope.followupDetails.Firstname +'-'+$rootScope.followupDetails.StaffID
};
if($rootScope.staffDetails){
var empresult = $filter('filter')($rootScope.staffDetails, $scope.checkEmpData);
if(empresult.length==0){
$rootScope.staffDetails.push($scope.checkEmpData);
}
}
else{
$rootScope.staffDetails=[];
$rootScope.staffDetails.push($scope.checkEmpData);
}
// ref1end after branch level changes
// get deactive status list
$scope.checkStatusData = {
ListCode: $rootScope.followupDetails.StatusCode,
ListName: $rootScope.followupDetails.statusName
};
var statusresult = $filter('filter')($rootScope.trackingStatus, $scope.checkStatusData);
if(statusresult.length==0){
$rootScope.trackingStatus.push($scope.checkStatusData);
}
} else {
alert('page not loaded');
swal("Failed!", response.data.message, "error");
}
});
$scope.value='';
localStorage.removeItem('trackID');
$rootScope.trackingid='';
$rootScope.trackingid1='';
}
/*
* get staff details while change branch
* */
$rootScope.changeBranch = function (branchCode) {
$rootScope.staffArray="";
$rootScope.myModel1.assignStaff="";
angular.forEach($rootScope.staffDetails, function(item) {
if(item.BranchCode==branchCode){
$rootScope.staffArray = item.staffDetails;
$rootScope.myModel1.assignStaff=item.staffDetails[0].loginId;
}
});
}
/*
* cancel the page
* created by kms
* */
$scope.cancel = function () {
$scope.val1 = $rootScope.trackingid;
$scope.val2 = $rootScope.trackingid1;
if($scope.val1==''|| $scope.val2)
{
$state.go('app.call.tracking');
}
if(JSON.parse(localStorage.getItem('searchObj')).callFrom=='details'){
$state.go('app.call.tracking');
}
else if(JSON.parse(localStorage.getItem('searchObj')).callFrom=='lead'){
$state.go('app.call.lead');
}
else if(JSON.parse(localStorage.getItem('searchObj')).callFrom=='close'){
$state.go('app.call.close');
}
else if(JSON.parse(localStorage.getItem('searchObj')).callFrom=='pending'){
$state.go('app.call.pending');
}
else{
$state.go('app.call.tracking');
}
};
}]);
app.filter('unique', function() {
return function(collection, primaryKey, secondaryKey) { //optional secondary key
var output = [],
keys = [];
angular.forEach(collection, function(item) {
var key;
secondaryKey === undefined ? key = item[primaryKey] : key = item[primaryKey][secondaryKey];
if(keys.indexOf(key) === -1) {
keys.push(key);
output.push(item);
}
});
return output;
};
});
/*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';
// $scope.items = ['item1', 'item2', 'item3'];
$scope.open = function (studentDetails) {
// get student view details
var getcourse = {
method: 'POST',
url: apiPoint.url + 'getStudentBasicInfo/',
headers: {
'Content-Type': 'application/json'
},
data: {
requestedBy :studentDetails.MobileNumber,
requestedFrom: 3,
branchCode:JSON.parse(localStorage.getItem('localObj')).localBranchID
}
};
$http(getcourse).then(function (response) {
if (response.data.status == 200 && response.data.studentStatus== true) {
$scope.courseEditLoading = false;
// $scope.studentDetails = response.data.studentDetails;
$scope.studentDetails = response.data;
// $scope.courseDetails = response.data.courseDetails;
var modalInstance = $modal.open({
templateUrl: 'assets/views/student/studentDetailsModal.html',
controller: 'ModalInstanceCtrl',
// size: size,
resolve: {
items: function () {
return $scope.studentDetails;
}
}
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
} else {
swal("Failed!", "This student is not registered", "warning");
$scope.courseEditLoading = false;
$scope.studentDetails = "";
$scope.courseDetails = "";
}
});
};
$scope.open1 = function (values,type) {
var modalInstance1 = $modal.open({
templateUrl: 'assets/views/student/studentPaymentModal.html',
controller: 'ModalInstanceCtrl1',
// size: size,
resolve: {
items1: function () {
var myvalues =
{
"values":values,
"type":type
};
return myvalues;
}
}
});
modalInstance1.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
$scope.printStudentDetails = function (details) {
$rootScope.pdfItems = details;
var printInstance = $modal.open({
templateUrl: 'assets/views/student/studentPdf.html',
controller: 'studentModalDemoCtrl',
});
};
// generate pdf for student view
$scope.export = function(getName) {
kendo.drawing.drawDOM($("#exportthis")).then(function(group) {
kendo.drawing.pdf.saveAs(group, getName+".pdf");
});
}
}]);
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items","WordsService", function ($scope, $modalInstance, items,WordsService) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);
app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1","WordsService", function ($scope, $modalInstance, items1,WordsService) {
$scope.items1 = items1.values;
$scope.selectedtype = items1.type;
$scope.ok = function () {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);