apollodec/Apollo/assets/js/controllers/newreg_reportCtrl.js
venbatechnologies@gmail.com e4d9536bb4 excelname
2018-08-21 15:38:23 +05:30

243 lines
5.3 KiB
JavaScript

'use strict';
/*** controller***/
app.controller('newreg_reportCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage" ,"$http", "$state","$modal","$log",
function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http,ipCookie ,$state,$modal,$log){
//function ($scope, apiPoint, $http, SweetAlert, $state,$modal, md5, ipCookie, $window, dateListDescService) {
// DataTables configurable options
$scope.filters = {
"from_date": "",
"to_date": "",
};
var localDetails = JSON.parse(localStorage.getItem('localObj'));
//var localDetails = ipCookie('cookiechk');
console.log(localDetails);
// $scope.initHead = function() {
//console.log('rfd');
var logcheck = JSON.parse(localStorage.getItem('localObj'));
const LOCALTYPE = logcheck.localType;
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE == 'R005')) {
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.universitySearchData = '';
$scope.init = function()
{
// alert()
var getuniv = {
method: 'POST',
url: apiPoint.url + 'AllgetUniversity/',
headers: {
'Content-Type': 'application/json'
},
data: {
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
}
};
$http(getuniv).then(function (response) {
if(response.status == 200)
{
$scope.universitySearchData=response.data.details;
}
});
};
//$scope.opinctotal='';
$scope.newreglist='';
$scope.isLoaderShow ='';
$scope.load = '';
$scope.isShow= '';
$scope.fromd='';
$scope.tod='';
$scope.getDetails = function (form,myModel)
{
// alert('in')
//console.log(form.$dirty);
var from = $scope.filters.from_date;
var to = $scope.filters.to_date;
var university = myModel.myUnivSearch ;
// console.log(from)
var f = new Date(from),
month = '' + (f.getMonth() + 1),
day = '' + f.getDate(),
year = f.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var from_dt = [day, month ,year].join('-');
var t = new Date(to),
month = '' + (t.getMonth() + 1),
day = '' + t.getDate(),
year = t.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var to_dt = [day, month ,year].join('-');
$scope.fromd = from_dt;
$scope.tod = to_dt;
var getstudentdetails = {
method: 'POST',
url: apiPoint.url + 'NewregDetails/',
headers: {
'Content-Type': 'application/json'
},
data: {
university: university,
from : $scope.filters.from_date,
to : $scope.filters.to_date
}
}
$http(getstudentdetails).then(function (response) {
if(response.data.status == 200 && response.data.searchst==true)
{
console.log(response.data);
$scope.newreglist = response.data.details;
$scope.isShow=true;
$scope.isLoaderShow=false;
}
else
{
$scope.isLoaderShow=true;
$scope.isShow=false;
}
});
}
$scope.exportData = function ()
{
//alert()
$scope.sam = 'New-Registration List from '+$scope.fromd+' to '+$scope.tod;
var mystyle = {
sheetid:$scope.sam,
headers: true,
caption: {
title: $scope.sam,
width: '1000px',
style:'font-size:50px;bold:true'
},
// style:'background:#00FF00',
column: {
style:'font-size:12px'
},
};
console.log(mystyle);
//console.log($scope.fullincomedetail);
alasql('SELECT Firstname as Name,Fathername,CourseName,BatchName,UniversityName,DOJ as RegistrationDate,MobileNumber INTO XLS("New Registration report.xls",?) FROM ?',[mystyle,$scope.newreglist]);
};
$scope.OpenWindowStatus = false;
$scope.editId = -1;
$scope.setEditId = function (P)
{
//alert(P);
$scope.editId = P;
}
$scope.close = function ()
{
$scope.editId = -1;
}
$scope.fdate ='';
$scope.tdate ='';
//$scope.Subtypes = '';
}]);