define(['app'], function (app) {
	app.controller('EnquiryReportCtrl', function ($scope, $rootScope, AppData, $location) {

		$rootScope.menucont = true;
		$rootScope.pageLoadComp = false;
		$scope.formLoad = false;
		$scope.listFound = false;

		$scope.startdatemdl = '';
		$scope.enddatemdl = '';


		$scope.maintabselected='1';
		$scope.pageData = userEnquiryReportData[$rootScope.selLanguage];
		$scope.submenu = $scope.pageData.sidemenu;
		$scope.url = "../senddata/log/";
		$scope.pageurl = "../senddata/report/";
		$scope.exporturl = "../senddata/reportdownload/";
		$scope.commonurl = "../senddata/common/";
		$rootScope.sideselect = $scope.pageData.sidemenu[0];
		$scope.enqtype='enquirystatus';
		$('.tab-pane').on('click', 'button', function() {
			$('button.active').removeClass('active');
			$(this).addClass('active');
			// alert('in')
	});
		$scope.monthpicker = moment().format("MMM YYYY");
		$scope.currentDate = moment().format("YYYY-MM-DD");
	


		$scope.listheader=[];
		// $scope.listbody=[];
		//Check Session//
		$scope.formData = {}
		$rootScope.formData = {}
		$("#startDate").val();
		$("#endDate").val();
		$scope.segmentarr=[{id:'0',value:'Student Learner'},{id:'1',value:'Parents/Guardian'},{id:'2',value:'Instructor'}]
		$scope.viewby = '10';
		$scope.currentPage = 1;	
		$scope.dateerror=false;
		$scope.datemontherror=false;
		$scope.dealerInactive=true;
		$scope.priorityCheck=true;
		$scope.dseInactive=true;
		$scope.itemsPerPage = $scope.viewby;
		$scope.maxSize = 5; //Number of pager buttons to show
		$scope.currentDate = moment().format("YYYY-MM-DD");
		$scope.startingDate = moment().startOf('month').format('YYYY-MM-DD');
		$scope.startdatemdl=moment().startOf('month').format('MMMM YYYY');
		$scope.enddatemdl=moment().startOf('month').format('MMMM YYYY');
		$scope.typeList = [
			{ id: "1", name: "PDF" },
			{ id: "2", name: "VIDEO" }
		]
		$scope.formData.ismenuload = "Yes";
		if ($rootScope.items == undefined || $rootScope.items == null) {
			$scope.formData.ismenuload = "No";
		}
		$scope.formData.funName = "checksession";
		$scope.formData.lang = $rootScope.selLanguage;
		$scope.formData.start = 0;
		$scope.formData.limit = 2;
		
		AppData.sendData($scope.url, $scope.formData, function (res) {
			if (res.cont) {
				if ($rootScope.items == undefined || $rootScope.items == null) {
					$rootScope.items = res.item.control;

				}
				for (var i = 0; i < $rootScope.items.length; i++) {
					if ($location.path() == $rootScope.items[i].modulepath) {
						$rootScope.modulename = $rootScope.items[i].modulename;
						
						$scope.usercontrol = String($rootScope.items[i].permission).split("|");
					}
				}
				$scope.assessmentList = function () {
					var obj = {};
					obj.funName = "assessment";
					obj.lang = $rootScope.selLanguage;
					obj.atype = 0;
                    obj.user_type=0;
					AppData.sendData($scope.commonurl, obj, function (res) {
						if (res.cont) {
							$scope.assessmentData = res.item;
							$rootScope.modulename =  'report';
							$scope.formData.assessmentid = res.item[0].assessmentid;
							console.log($rootScope.modulename,'$rootScope.modulename')
						}
					})
				}
				angular.element(document.querySelector('.table_area')).bind('scroll', function(){
					$('.datepicker').datepicker("hide")
				  })
				
				$scope.getzonelist();
				//$scope.getZm();
				$scope.setPage = function (pageNo) {
					$scope.currentPage = pageNo;
				};
				$scope.pageChanged = function () {
					 $scope.userAssessmentData($scope.enqtype)
				};
				$scope.setItemsPerPage = function (num) {
					$scope.itemsPerPage = num;
					$scope.currentPage = 1; //reset to first page
					$scope.userAssessmentData($scope.enqtype)
				}
				
			} else {
				$location.path("/login");
			}
		})
		$scope.getzonelist = function () {
			$scope.formData = {}
			$scope.formData.regtype = 1;
			$scope.formData.zone = "all";
			$scope.formData.segment = '0';
			$scope.rmInactive = true;
			$scope.zmInactive = true;
			$scope.amInactive = true;
			$scope.dealerInactive=true;
			$scope.dseInactive=true;
			var zobj = {};
			zobj.funName = "zonelist";
			zobj.lang = $rootScope.selLanguage;
			AppData.sendData($scope.commonurl, zobj, function (res) {
				$scope.zone_list = res.item;
				$scope.userAssessmentData($scope.enqtype);
			})
		}
		//==
		///////////// Zone Data /////////////////
		$scope.getZm = function () {
			// alert($scope.enqtype)
			$scope.rmInactive = true;
			$scope.amInactive = true;
			$scope.dealerInactive=true;
			$scope.dseInactive=true;
			let tempsegment= $scope.formData.segment;
			if($scope.formData.zone=='all'){
				$scope.zmInactive=true;
				$scope.formData={};
				$scope.formData.zone='all';
				$scope.formData.segment=tempsegment;
				
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
				
			}else{
				//$scope.formData={};
				$scope.zmInactive=false;
				$scope.formData.zm_email = "all";
				$scope.formData.rm_email = "all";
				$scope.formData.am_email = "all";
				$scope.formData.dealer_email = "all";
				$scope.formData.dse_email = "all";
				//$scope.formData.segment='0';
				
				var zobj = {};
				zobj.funName = "zmlist";
				zobj.lang = $rootScope.selLanguage;
				zobj.zone = $scope.formData.zone;
				AppData.sendData($scope.commonurl, zobj, function (res) {
					$scope.zmuser_list = res.item;
					if($scope.maintabselected=='1'){
						$scope.userAssessmentData($scope.enqtype)
					}else if($scope.maintabselected=='2'){
						//alert("terms");
						$scope.getterms();
					}else{
						$scope.getsuspension();
					}
				})
			}
			
		}
	
		$scope.zmChange = function () {
			$scope.formData.rm_email = "all";
			$scope.formData.am_email = "all";
			$scope.formData.dealer_email = "all";
			$scope.formData.dse_email = "all";
			//$scope.formData.segment='0';
			if ($scope.formData.zm_email == "all") {
				$scope.rmInactive = true;
				$scope.amInactive = true;
				$scope.dealerInactive=true;
				$scope.dseInactive=true;
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
				
			} else {

				$scope.rmInactive = false;
				$scope.amInactive = true;
				$scope.getRm();
			}
		}
		///////////// Regional Data //////////////
		$scope.getRm = function () {
			$scope.formData.rm_email = "all";
			$scope.formData.am_email = "all";
			$scope.formData.dealer_email = "all";
			$scope.formData.dse_email = "all";
			$scope.dealerInactive=true;
			$scope.dseInactive=true;
			var robj = {};
			robj.funName = "rmlist";
			robj.lang = $rootScope.selLanguage;
			robj.zm_email = $scope.formData.zm_email;
			robj.zone= $scope.formData.zone;
			AppData.sendData($scope.commonurl, robj, function (res) {
				$scope.rmuser_list = res.item;
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
			})
		}
		$scope.rmChange = function () {
			$scope.formData.am_email = "all";
			$scope.formData.dealer_email = "all";
			$scope.formData.dse_email = "all";
			if ($scope.formData.rm_email == "all") {
				$scope.amInactive = true;
				$scope.dealerInactive=true;
				$scope.dseInactive=true;
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
			} else {
				$scope.amInactive = false;
				$scope.getAm();
			}
		}
		//////////// Area Manager Data ///////////////////
		$scope.getAm = function () {
			$scope.dealerInactive=true;
			$scope.dseInactive=true;
			var aobj = {};
			aobj.funName = "amlist";
			aobj.lang = $rootScope.selLanguage;
			aobj.rm_email = $scope.formData.rm_email;
			aobj.zm_email = $scope.formData.zm_email;
			aobj.zone = $scope.formData.zone;
			AppData.sendData($scope.commonurl, aobj, function (res) {
				$scope.amuser_list = res.item;
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
			})
		}
		// $scope.getDealer = function(){

		// }
		$scope.amChange = function () {
			$scope.formData.dealer_email='all';
			$scope.formData.dse_email='all';

			if($scope.formData.am_email =='all'){
				$scope.dealerInactive=true;
				$scope.dseInactive=true;
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					$scope.getterms();
				}else{
					$scope.getsuspension();
				}
			}else{
				$scope.dealerInactive=false;
				$scope.dseInactive=true;
				var aobj = {};
				aobj.funName = "dealerlist";
				aobj.lang = $rootScope.selLanguage;
				aobj.am_email = $scope.formData.am_email;
				aobj.rm_email = $scope.formData.rm_email;
				aobj.zm_email = $scope.formData.zm_email;
				aobj.zone = $scope.formData.zone;
				AppData.sendData($scope.commonurl, aobj, function (res) {
					$scope.dealer_userlist = res.item;
					if($scope.maintabselected=='1'){
						$scope.userAssessmentData($scope.enqtype)
					}else if($scope.maintabselected=='2'){
						//alert("terms");
						$scope.getterms();
					}else{
						$scope.getsuspension();
					}
				})
			}
			
			
			
		}
		$scope.dealerChange = function (temp){
			// alert("33")
			
			$scope.formData.dse_email='all';
			
			if($scope.formData.dealer_email !=undefined){
				if($scope.formData.dealer_email == 'all' && temp =="1"){
					$scope.dseInactive=true;
					if($scope.maintabselected=='1'){
						$scope.userAssessmentData($scope.enqtype)
					}else if($scope.maintabselected=='2'){
						//alert("terms");
						$scope.getterms();
					}else{
						$scope.getsuspension();
					}
				}else{
					if($scope.formData.dealer_email == 'all' && temp =="0"){
						$scope.dseInactive=true;
					}else{
						$scope.dseInactive=false;
					}
					
					var aobj = {};
					aobj.funName = "dselist";
					aobj.lang = $rootScope.selLanguage;
					aobj.dealer_code = $scope.formData.dealer_email;
					aobj.regtype =$scope.formData.regtype;
					aobj.segment =$scope.formData.segment;
					AppData.sendData($scope.commonurl, aobj, function (res) {
						$scope.dse_userlist = res.item;
						$scope.formData.dse_email='all';
						if($scope.maintabselected=='1'){
							$scope.userAssessmentData($scope.enqtype)
						}else if($scope.maintabselected=='2'){
							//alert("terms");
							$scope.getterms();
						}else{
							$scope.getsuspension();
						}
					})
				}
			}else{
				$scope.dseInactive=true;
			}
			
			
		}
		//==
		$scope.listtype = function(tempvalue){
			if(tempvalue == 'conversionratio'){
				$scope.segmentarr=[{id:'1',value:'Parents/Guardian'},{id:'2',value:'Instructor'}];
				$scope.formData.segment='1';

			}else{
				$scope.segmentarr=[{id:'0',value:'Student Learner'},{id:'1',value:'Parents/Guardian'},{id:'2',value:'Instructor'}];
				$scope.formData.segment='0';
			}
			$scope.enqtype = tempvalue;
			$scope.userAssessmentData($scope.enqtype);
		}
		$scope.dsechange = function(){
			if($scope.maintabselected=='1'){
				$scope.userAssessmentData($scope.enqtype)
			}else if($scope.maintabselected=='2'){
				//alert("terms");
				//$scope.getterms();
			}else{
				$scope.getsuspension();
			}
		}
		$scope.selectStatus = function(){
			if($scope.formData.dealer_email !=undefined){
				if($scope.formData.dealer_email =='all'){
					if($scope.maintabselected=='1'){
						$scope.userAssessmentData($scope.enqtype)
					}else if($scope.maintabselected=='2'){
						//alert("terms");
						//$scope.getterms();
					}else{
						$scope.getsuspension();
					}
				}else{	
					$scope.dealerChange('1');
				}
			}else{
				if($scope.maintabselected=='1'){
					$scope.userAssessmentData($scope.enqtype)
				}else if($scope.maintabselected=='2'){
					//alert("terms");
					//$scope.getterms();
				}else{
					$scope.getsuspension();
				}
			}
						
		}
		$scope.chartData = function(){
			let startdate=$("#startDate").val();
			let enddate=$("#endDate").val();
			let temp_start = new Date(startdate);
			let temp_end = new Date(enddate);
			let start_date_value = Date.parse(temp_start);
			let end_date_value = Date.parse(temp_end);
			let end_condition= temp_start.setMonth( temp_start.getMonth() + 2 );
			let end_condition_value=new Date(end_condition);
			let max_end_date = Date.parse(end_condition_value);
			if(start_date_value > end_date_value){
				$scope.dateerror=true;
				$scope.datemontherror=false;
				//alert("Start Date should not be greater than end date")
			}else{
				if (end_date_value > max_end_date) {
				//	alert ("Not more than 3 months");
					$scope.dateerror=false;
					$scope.datemontherror=true;
				}else{
					//alert("ok");
					$scope.datemontherror=false;
					$scope.dateerror=false;
					if($scope.maintabselected=='1'){
						$scope.userAssessmentData($scope.enqtype);
					}else if($scope.maintabselected=='3'){
						$scope.getsuspension();
					}else{
						
					}
				}
			}		
		}
		$scope.resetdate = function(){
			$('#startDate').datepicker("setDate", "today" );
			$('#endDate').datepicker("setDate", "today" );
			if($scope.maintabselected=='1'){
				$scope.userAssessmentData($scope.enqtype);
			}else if($scope.maintabselected=='3'){
				$scope.getsuspension();
			}else{

			}
			
		}

		//////////////// User Assessment Report ////////////////////
		$scope.userAssessmentData = function (tempvalue) {


			$scope.val = $("#startDate").val();
			$scope.valend = $("#endDate").val();

			console.log($scope.val)
			if($scope.val=='' || $scope.val==undefined){
				$('#startDate').datepicker("setDate", "today" );
				$scope.start = moment().format("YYYY-MM");
			}else{
				$scope.start = moment($("#startDate").val()).format("YYYY-MM");
				
			}

			if($scope.valend=='' || $scope.valend==undefined){
				$scope.end = moment().format("YYYY-MM");
			}else{
				$scope.end = moment($("#endDate").val()).format("YYYY-MM");
			}

			$scope.listheader=[];
			$scope.listbody=[];
			$scope.listbodysenddata=[];
			$scope.listfooter=[];
			$scope.enqtype=tempvalue;
			var aobj = {};
			aobj.funName = "enquiry_report";
			aobj.lang = $rootScope.selLanguage;
			aobj.reporttype = $scope.enqtype;
			aobj.start = $scope.start;
			aobj.regtype =$scope.formData.regtype;
			aobj.end =$scope.end;
			aobj.zm_email = $scope.formData.zm_email;
			aobj.rm_email = $scope.formData.rm_email;
			aobj.am_email = $scope.formData.am_email;
			aobj.dealer_code = $scope.formData.dealer_email;
			aobj.smpin = $scope.formData.dse_email;
			aobj.segment =$scope.formData.segment;
			aobj.zone=$scope.formData.zone

			AppData.sendData($scope.pageurl, aobj, function (res) {
				$scope.listheader=res.item.header;
				$scope.listbody=res.item.list;
				$scope.listfooter=res.item.total;
				$scope.listbody.forEach((element,index) => {
					let temp=element;
					$scope.listbodysenddata.push(temp);
				});
			})
		}

		$scope.exportData = function () {
		let tempval= '';

		$scope.val = $("#startDate").val();
		$scope.valend = $("#endDate").val();
		if($scope.maintabselected =='1'){
			console.log($scope.val)
		if($scope.val=='' || $scope.val==undefined){
			$('#startDate').datepicker("setDate", "today" );
			$scope.start = moment().format("YYYY-MM");
		}else{
			$scope.start = moment($("#startDate").val()).format("YYYY-MM");
			
		}

		if($scope.valend=='' || $scope.valend==undefined){
			$scope.end = moment().format("YYYY-MM");
		}else{
			$scope.end = moment($("#endDate").val()).format("YYYY-MM");
		}
		//  alert($scope.enqtype);
		if($scope.enqtype=='enquirytestride'){
			tempval='enquirytestridedseexport';
		}else if($scope.enqtype=='enquirystatus'){
			tempval='enquirystatusdseexport';
		}else if($scope.enqtype=='conversionratio'){
			tempval='enquiryconversionratiodseexport';
		}else if($scope.enqtype=='follow'){
			tempval='follow';
		}else if($scope.enqtype=='productivity'){
			tempval='productivitydseexport';
		}else{
			//tempval='overallratioexport';
		}
			$scope.formData.funName = tempval;
			$scope.formData.start=$scope.start;
			$scope.formData.end=$scope.end;
			$scope.formData.dealer_code = $scope.formData.dealer_email;
			 $scope.formData.smpin = $scope.formData.dse_email;
			AppData.sendData($scope.exporturl, $scope.formData, function (res) {
				if (res.cont) {
					$('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "'></iframe>");
					var setO = setTimeout(function () {
						clearTimeout(setO);
						$('#fileDownload').remove();
					}, 2000);
				}
			})
		}else if($scope.maintabselected=='2'){
			$scope.formData.funName = 'enquiry_dealer_report_terms_condition';
			$scope.formData.start=$scope.start;
			$scope.formData.end=$scope.end;
			$scope.formData.dealer_code = $scope.formData.dealer_email;
			 $scope.formData.smpin = 'all';
			AppData.sendData($scope.exporturl, $scope.formData, function (res) {
				if (res.cont) {
					$('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "'></iframe>");
					var setO = setTimeout(function () {
						clearTimeout(setO);
						$('#fileDownload').remove();
					}, 2000);
				}
			})
		}else{

			if($scope.val=='' || $scope.val==undefined){
				$('#startDate').datepicker("setDate", "today" );
				$scope.start = moment().format("YYYY-MM");
			}else{
				$scope.start = moment($("#startDate").val()).format("YYYY-MM");
				
			}
	
			if($scope.valend=='' || $scope.valend==undefined){
				$scope.end = moment().format("YYYY-MM");
			}else{
				$scope.end = moment($("#endDate").val()).format("YYYY-MM");
			}
			$scope.formData.funName = 'temp_suspension';
			$scope.formData.start=$scope.start;
			$scope.formData.end=$scope.end;
			$scope.formData.dealer_code = $scope.formData.dealer_email;
			 $scope.formData.smpin = $scope.formData.dse_email;
			AppData.sendData($scope.exporturl, $scope.formData, function (res) {
				if (res.cont) {
					$('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "'></iframe>");
					var setO = setTimeout(function () {
						clearTimeout(setO);
						$('#fileDownload').remove();
					}, 2000);
				}
			})
		}
		
		
		}
		$scope.exportDataDse = function(){
			var tempval= '';
			if($scope.enqtype=='overallratio'){
				tempval='overallratiodseexport';
			}else if($scope.enqtype=='enquirystatus'){
				tempval='enquirystatusdseexport';
			}else if($scope.enqtype=='convertedsales'){
				tempval='convertedsalesdseexport';
			}else if($scope.enqtype=='achievedvstarget'){
				tempval='achievedvstargetdseexport';
			}else if($scope.enqtype=='productivity'){
				tempval='productivitydseexport';
			}else{
				tempval='overallratiodseexport';
			}
				
				$scope.val = $("#startDate").val();
			//	console.log($scope.val)
			$scope.formData.funName = tempval;
				if($scope.val=='' || $scope.val==undefined){
					$('#startDate').datepicker("setDate", "today" );
					$scope.startMonth=moment($scope.startingMonth).format("M");
					$scope.startYear=moment($scope.startingMonth).format("YYYY");
					$scope.monthpicker = moment().format("MMM YYYY")
				}else{
					$scope.monthpicker = moment($("#startDate").val()).format("MMM YYYY")
					$scope.startMonth=moment($("#startDate").val()).format("M");
					$scope.startYear=moment($("#startDate").val()).format("YYYY");
				}
				$scope.formData.month=$scope.startMonth;
				$scope.formData.year=$scope.startYear;
				$scope.formData.dealer_code = $scope.formData.dealer_email;
				$scope.formData.history='1';
				// $scope.formData.smpin = $scope.formData.dse_email;
				if($scope.maintabselected=='1'){
					AppData.sendData($scope.exporturl, $scope.formData, function (res) {
						if (res.cont) {
							$('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "'></iframe>");
							var setO = setTimeout(function () {
								clearTimeout(setO);
								$('#fileDownload').remove();
							}, 2000);
						}
					})
				}else{
					$scope.formData.funName = 'enquiry_dealer_report_terms_condition';
					AppData.sendData($scope.exporturl, $scope.formData, function (res) {
						if (res.cont) {
							$('body').append("<iframe id='fileDownload' src='" + res.item.report_url + "'></iframe>");
							var setO = setTimeout(function () {
								clearTimeout(setO);
								$('#fileDownload').remove();
							}, 2000);
						}
					})
				}
				
		}

		$scope.exportTableData = function(){
			if($scope.maintabselected=='1'){
				$scope.formData.funName = "";
			AppData.sendData($scope.exporturl, $scope.formData, function (res) {
				if(res.cont){
					$('body').append("<iframe id='fileDownload' src='"+res.item.report_url+"' ></iframe>");
					var setO=setTimeout(function(){
						clearTimeout(setO);
						$('#fileDownload').remove();
					},2000);
				}
			})
			}else{
				$scope.formData.funName = "enquiry_report_terms_condition";
			AppData.sendData($scope.exporturl, $scope.formData, function (res) {
				if(res.cont){
					$('body').append("<iframe id='fileDownload' src='"+res.item.report_url+"' ></iframe>");
					var setO=setTimeout(function(){
						clearTimeout(setO);
						$('#fileDownload').remove();
					},2000);
				}
			})
			}
			
		}
		//==
		$scope.segmentChange = function(){
			// alert("$scope.formData.dealer_email-->"+$scope.formData.dealer_email)
			if($scope.formData.dealer_email !=undefined){
				if($scope.formData.dealer_email =='all'){
					$scope.userAssessmentData($scope.enqtype);
				}else{	
					$scope.dealerChange('1');
				}
			}else{
				$scope.userAssessmentData($scope.enqtype);
			}
		}
		$scope.getterms =function(){
			$scope.maintabselected='2';
			var aobj={};
			aobj.funName='enquiry_report_terms_condition';
			aobj.zone=$scope.formData.zone;
			aobj.zm_email=$scope.formData.zm_email;
			aobj.rm_email=$scope.formData.rm_email;
			aobj.am_email=$scope.formData.am_email;
			aobj.dealer_code=$scope.formData.dealer_email;
			AppData.sendData($scope.pageurl, aobj, function (res) {
				$scope.termslistheader=res.item.header;
				$scope.termslistbody=res.item.list;
				$scope.termslistfooter=res.item.total;

			})
		}
		$scope.getenquiry = function(){
			$scope.maintabselected='1';
			$scope.userAssessmentData($scope.enqtype);
		}
		//==
		$scope.changestartmonth = function(){
			let startdate=$("#startDate").val();
			
		}
		//==
		$scope.getsuspension = function(){
			$scope.maintabselected='3';
			$scope.val = $("#startDate").val();
			$scope.valend = $("#endDate").val();

			console.log($scope.val)
			if($scope.val=='' || $scope.val==undefined){
				$('#startDate').datepicker("setDate", "today" );
				$scope.start = moment().format("YYYY-MM");
			}else{
				$scope.start = moment($("#startDate").val()).format("YYYY-MM");
				
			}

			if($scope.valend=='' || $scope.valend==undefined){
				$scope.end = moment().format("YYYY-MM");
			}else{
				$scope.end = moment($("#endDate").val()).format("YYYY-MM");
			}

			$scope.listheader=[];
			$scope.listbody=[];
			$scope.listbodysenddata=[];
			$scope.listfooter=[];
			// $scope.enqtype=tempvalue;
			var aobj = {};
			aobj.funName = "temp_suspension";
			aobj.lang = $rootScope.selLanguage;
			// aobj.reporttype = $scope.enqtype;
			aobj.start = $scope.start;
			 aobj.regtype =$scope.formData.regtype;
			aobj.end =$scope.end;
			aobj.zm_email = $scope.formData.zm_email;
			aobj.rm_email = $scope.formData.rm_email;
			aobj.am_email = $scope.formData.am_email;
			aobj.dealer_code = $scope.formData.dealer_email;
			aobj.smpin = $scope.formData.dse_email;
			aobj.segment =$scope.formData.segment;
			aobj.zone=$scope.formData.zone

			AppData.sendData($scope.pageurl, aobj, function (res) {
				$scope.termslistheader=res.item.header;
				$scope.termslistbody=res.item.list;
				// $scope.termslistfooter=res.item.total;
				console.log("$scope.listbodysenddata--->",$scope.listbodysenddata)
			})
		}
	});
}); 
