

// When the user clicks anywhere outside of the modal, close it
/* window.onclick = function(event) {
    document.getElementById('feedbackModal-star').style.display = "none";		
	document.getElementById('feedbackModal-smiley').style.display = "none";
} */

/***** add more text box	send alert emails in "feedback settings" *****/
$(document).ready(function(){
	var addButton = $('.add_button'); //Add button selector
	var wrapper = $('.field_wrapper'); //Input field wrapper
	var fieldHTML = '<div class="col-lg-4 remove-div"><div class="input-group"><input type="text" id="input-small" name="alert-emails[]" class="form-control alert-disabled" /><span class="input-group-btn remove_button"><button type="button" class="btn btn-custom alert-disabled close-dis"><i class="fa fa-times" aria-hidden="true"></button></span></div></div>'; //New input field html 
	$(addButton).click(function(){ //Once add button is clicked
		$(wrapper).append(fieldHTML); // Add field html
	});
	$(wrapper).on('click', '.remove_button', function(e){ //Once remove button is clicked
		e.preventDefault();
		$(this).parents('.col-lg-4.remove-div').remove(); //Remove field html
	});
});

function addEmailTextbox(unitid) {
	// var wrapper3 = $('.outlet_wrapper'+unitid);
	$('.outlet_wrapper'+unitid).append('<div class="col-lg-4 remove-outlet-div'+unitid+' outlet-wise-textbox"><div class="input-group"><input type="email" id="outlet-input-small" name="outlet-alert-emails#'+unitid+'[]" class="form-control alert-disabled" data-parsley-required data-parsley-type="email" data-parsley-trigger="keyup" data-parsley-errors-messages-disabled /><span class="input-group-btn remove_outlet_button'+unitid+'"><button type="button" class="btn btn-custom alert-disabled close-dis"><i class="fa fa-times" aria-hidden="true"></button></span></div></div>');

	$('.outlet_wrapper'+unitid).on('click', '.remove_outlet_button'+unitid, function(e){ //Once remove button is clicked
		e.preventDefault();
		$(this).parents('.col-lg-4.remove-outlet-div'+unitid).remove(); //Remove field html
	});
}

function removeEmail(del, unitid, emailid, sid) {
	// $('.col-lg-4.remove-email'+emailid).remove();
	// $(this).parents('.col-lg-4.remove-email'+emailid).remove();
	$.ajax({
		type: 'post',
		url: 'save_fb_settings_data.php',
		data: 'act='+del+'&unitid='+unitid+'&emailid='+emailid,
		success: function(data){
			// console.log('hi ');
			$('.remove-email'+sid).remove();
			$.toast({
			    text: "Email id is deleted", // Text that is to be shown in the toast
			    heading: 'Oulet Alert Email', // Optional heading to be shown on the toast
			    icon: 'success', // Type of toast icon
			    showHideTransition: 'fade', // fade, slide or plain
			    allowToastClose: true, // Boolean value true or false
			    hideAfter: 3000, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
			    stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
			    position: 'top-right', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
			    
			    
			    
			    textAlign: 'left',  // Text alignment i.e. left, right or center
			    loader: true,  // Whether to show loader or not. True by default
			    loaderBg: '#9EC600',  // Background color of the toast loader
			    beforeShow: function () {}, // will be triggered before the toast is shown
			    afterShown: function () {}, // will be triggered after the toat has been shown
			    beforeHide: function () {}, // will be triggered before the toast gets hidden
			    afterHidden: function () {}  // will be triggered after the toast has been hidden
			});
		}
	});
}


function removeAllOutletEmail(del, unitid, emailid, sid) {
	// $('.col-lg-4.remove-email'+emailid).remove();
	// $(this).parents('.col-lg-4.remove-email'+emailid).remove();
	$.ajax({
		type: 'post',
		url: 'save_fb_settings_data.php',
		data: 'act='+del+'&unitid='+unitid+'&emailid='+emailid,
		success: function(data){
			// console.log('hi ');
			$('.remove-alloutlet-email'+sid).remove();
			$.toast({
			    text: "Email id is deleted", // Text that is to be shown in the toast
			    heading: 'All Oulet Alert Email', // Optional heading to be shown on the toast
			    icon: 'success', // Type of toast icon
			    showHideTransition: 'fade', // fade, slide or plain
			    allowToastClose: true, // Boolean value true or false
			    hideAfter: 3000, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
			    stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
			    position: 'top-right', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
			    
			    
			    
			    textAlign: 'left',  // Text alignment i.e. left, right or center
			    loader: true,  // Whether to show loader or not. True by default
			    loaderBg: '#9EC600',  // Background color of the toast loader
			    beforeShow: function () {}, // will be triggered before the toast is shown
			    afterShown: function () {}, // will be triggered after the toat has been shown
			    beforeHide: function () {}, // will be triggered before the toast gets hidden
			    afterHidden: function () {}  // will be triggered after the toast has been hidden
			});
		}
	});
}

/*function validateEmail(emailid) {
	var emailfilter = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(emailid == ''){
		$('.text-danger').html('Email ID is required');
		return false;
	} else if(!emailfilter.test(emailid)) { //Check email is valid or not
		$('.text-danger').html('Email is not valid');
		return false;
	} else {
		$('.text-danger').html('');
		return true;
	}
}*/

/*function validateEmail(email,vid) {
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (email == '') {
		$('#outlet-input-small'+vid).css({'color': '#B94A48','background-color':'#F2DEDE','border': '1px solid #EED3D7'});
		return false;
	} else if (emailPattern.test(email)) {
		$('#outlet-input-small'+vid).css({'color': '#B94A48','background-color':'#F2DEDE','border': '1px solid #EED3D7'});
		return false;
	} else {
		$('#outlet-input-small'+vid).css({'color': '#000000','background-color':'#ffffff','border': '1px solid #c2cfd6'});
		return true;
    }
}*/

/***** enable/disable of switch *****/
$(document).ready(function(){
	// for dine in
	$("input[name=dinein-switch]:checkbox").change(function(){
		if($(this).is(":checked")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=dinein_on&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".dine-disabled").removeAttr("disabled");
			$(".dine-disabled").removeAttr("style");
			$(".btn-popup").removeAttr("style");
		}
		if($(this).is(":not(:checked)")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=dinein_off&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".dine-disabled").attr("disabled","disabled");
			$(".dine-disabled").css("color","#ccc");
			$(".btn-popup").css("cursor","not-allowed");
		}
	});

	// for delivery
	$("input[name=delivery-switch]:checkbox").change(function(){
		if($(this).is(":checked")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=delivery_on&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".del-disabled").removeAttr("disabled");
			$(".del-disabled, .del-online").removeAttr("style");
			$(".btn-del-edit").removeAttr("style");
		}
		if($(this).is(":not(:checked)")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=delivery_off&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".del-disabled").attr("disabled","disabled");
			$(".del-disabled, .del-online").css("color","#ccc");
			$(".btn-del-edit").css("cursor","not-allowed");
		}
	});
	
	// for reminder
	$("input[name=reminder-switch]:checkbox").change(function(){
		if($(this).is(":checked")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=reminder_on&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".remind-disabled").removeAttr("disabled");
			$(".remind-disabled").removeAttr("style");
		}
		if($(this).is(":not(:checked)")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=reminder_off&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".remind-disabled").attr("disabled","disabled");
			$(".remind-disabled").css("color","#ccc");
		}
	});
	
	// for alert settings
	$("input[name=alert-switch]:checkbox").change(function(){
		if($(this).is(":checked")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=alert_on&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".alert-disabled").removeAttr("disabled");
			$(".input-alert-disable").removeAttr("readonly");
			$(".alert-disabled, close-dis, .input-alert-disable, .btn-popup").removeAttr("style");
		}
		if($(this).is(":not(:checked)")){
			var mode= $(this).prop('checked');
			// alert(mode);
			$.ajax({
				type: 'post',
				url: 'save_fb_settings_data.php',
				data: 'act=alert_off&mode='+mode,
				success: function(data){
					console.log(data);
					
				}
			});
			$(".alert-disabled").attr("disabled","disabled");
			$(".input-alert-disable").attr("readonly",true);
			$(".alert-disabled").css("color","#ccc");
			$(".input-alert-disable").css("background-color","#ccc");
			$(".close-dis, .btn-popup").css("cursor","not-allowed");
		}
	});

	$("input[name=outlet-check]:checkbox").change(function(){
		if($(this).is(":checked")) {
			$("#outlet-email-area").css("display","block");
		} else {
			$("#outlet-email-area").css("display","none");
		}
	});
});


/*$(document).load(function(){
	
		if($(this).is(":checked")){
			$(".dine-disabled").removeAttr("disabled");
			$(".dine-disabled").removeAttr("style");
			$(".btn-popup").removeAttr("style");
		}
		if($(this).is(":not(:checked)")){
			$(".dine-disabled").attr("disabled","disabled");
			$(".dine-disabled").css("color","#ccc");
			$(".btn-popup").css("cursor","not-allowed");
		}
	
});
*/
/***** edit and save feedback popup form for dine in *****/
function edit_row(id) {
	var name=document.getElementById("fb_topic_name"+id).innerHTML;

	document.getElementById("fb_topic_name"+id).innerHTML="<input type='text' id='name_text"+id+"' value='"+name+"'>";
	
	document.getElementById("edit_button"+id).style.display="none";
	document.getElementById("save_button"+id).style.display="block";
}

function save_row(id, quesfor) {
	var name=document.getElementById("name_text"+id).value;
	
	$.ajax({
		type:'post',
		url:'save_data.php',
		data:{
			edit_row:'edit_row',
			row_id:id,
			name_val:name,
			ques_for:quesfor
		},
		success:function(response) {
			
			document.getElementById("fb_topic_name"+id).innerHTML=name;
			document.getElementById("edit_button"+id).style.display="block";
			document.getElementById("save_button"+id).style.display="none";
			
		}
	});
}


function edit_row_del(id) {
	var name=document.getElementById("fb_topic_name_del"+id).innerHTML;

	document.getElementById("fb_topic_name_del"+id).innerHTML="<input type='text' id='name_text_del"+id+"' value='"+name+"'>";
	
	document.getElementById("edit_button_del"+id).style.display="none";
	document.getElementById("save_button_del"+id).style.display="block";
}

function save_row_del(id,quesfor) {
	var name=document.getElementById("name_text_del"+id).value;
	
	$.ajax({
		type:'post',
		url:'save_data.php',
		data:{
			edit_row:'edit_row_del',
			row_id:id,
			name_val:name,
			ques_for:quesfor
		},
		success:function(response) {
			
			document.getElementById("fb_topic_name_del"+id).innerHTML=name;
			document.getElementById("edit_button_del"+id).style.display="block";
			document.getElementById("save_button_del"+id).style.display="none";
			
		}
	});
}




/* $(document).ready(function(){
	$('#dinemodal').click(function() {
		if (!$("input[name='dine-radios']:checked").val()== true || !$("input[name='res-dine']:checked").val()==true) {
			$(".text-danger").html("Please select feedback method and type.");
			$("#feedbackModal").css("display","none");
			return false;
		}
		else {
			$("#feedbackModal").css("display","block");
			$(".text-danger").empty();
		}
		
	});
});


$(document).ready(function(){
	$('#delmodal').click(function() {
		if (!$("input[name='delivery-radios']:checked").val()== true || !$("input[name='res-deliver']:checked").val()==true) {
			$(".text-danger1").html("Please select feedback method and type.");
			$("#feedbackModal").css("display","none");
			return false;
		}
		else {
			$("#feedbackModal").css("display","block");
			$(".text-danger1").empty();
		}
		
	});
}); */

/*$(document).ready(function(){
	$('#dateofbirth, #anniversary').datepicker({
		format: 'dd-mm-yyyy',
		autoclose: true,
		todayHighlight: true
	});
});*/


function crntMonthData(filter) {
	$.ajax({
		url:'fb_crnt_mnth_data.php?act='+filter,
		success : function(data){
			console.log(data);
			var data1 = JSON.parse(data);
			
			var my = data1.mtyr;
            var total = data1.overall;
            var overallstar = data1.overallstar;
            var fbsent = data1.fbsent;
            var sentData = data1.sentData;
            var sentDate = data1.sentDate;
            var fbdone = data1.fbdone;
            var recData = data1.recData;
            var recDate = data1.recDate;
            var notInt = data1.notinterest;
            var fbdoneper = data1.fbdoneper;
            var percentData = data1.percentData;
            var percentDate = data1.percentDate;
            var dyquesdata = data1.dyquesdata;
            $(".mnth-yr").html(my);
            $(".overall-rating").html(total);
            $(".overall-rating-star").html(overallstar);
            $(".fb-sent").html(fbsent);
            $(".fb-done").html(fbdone);
            $(".fb-notint").html(notInt);
            $(".fb-done-per").html(fbdoneper);
            $("#dynamic-ques-data").html(dyquesdata);
			
			// Graph for Overall Experience
			var chartdata = {
				labels: data1.date,
				
				datasets: [
					{
						label: "Customer Rating",
						fill: true,
						lineTension: 0.1,
						backgroundColor: [
			                'rgba(181, 207, 83, 0.4)'
			                /*'rgba(54, 162, 235, 0.2)',
			                'rgba(255, 206, 86, 0.2)',
			                'rgba(75, 192, 192, 0.2)',
			                'rgba(153, 102, 255, 0.2)',
			                'rgba(255, 159, 64, 0.2)'*/
			            ],
			            borderColor: [
			                'rgba(111, 126, 54, 1)'
			                /*'rgba(54, 162, 235, 1)',
			                'rgba(255, 206, 86, 1)',
			                'rgba(75, 192, 192, 1)',
			                'rgba(153, 102, 255, 1)',
			                'rgba(255, 159, 64, 1)'*/
			            ],
						pointHoverBackgroundColor: "rgba(59, 89, 152, 1)",
						pointHoverBorderColor: "rgba(59, 89, 152, 1)",
						borderWidth: 1,
						data: data1.fbvalue
					}
				]
			};
			
			var ctx = $("#main-chart");

			var chart = new Chart(ctx, {
				type: 'line',
				data: chartdata,
				options: {
					title : {
						display : false,
						position : "top",
						text : "",
						fontSize : 18,
						fontColor : "#111"
					},
					scales: {
						yAxes: [{
							ticks: {
								beginAtZero:true
							},
							scaleLabel: {
								 display: false,
								 labelString: '',
								 fontSize: 14 
							  }
						}]
					}
				}
			});

			// Graph for Feedback Sent
			var chartdata2 = {
			    labels: data1.sentDate,
			    datasets: [
			      	{
				        label: 'feedback sent',
				        backgroundColor: $.brandInfo,
				        borderColor: 'rgba(255,255,255,.55)',
				        data: data1.sentData
			      	},
			    ]
			};
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
				        gridLines: {
				          	color: 'transparent',
				          	zeroLineColor: 'transparent'
				        },
				        ticks: {
				          	fontSize: 2,
				          	fontColor: 'transparent',
				        }

			     	}],
			      	yAxes: [{
				        display: false,
				        ticks: {
				          	display: false,
				          	/*min: Math.min.apply(Math, data.datasets[0].data) - 5,
				          	max: Math.max.apply(Math, data.datasets[0].data) + 5,*/
				        }
			      	}],
			    },
			    elements: {
			      	line: {
				        tension: 0.00001,
				        borderWidth: 1
			      	},
				    point: {
				        radius: 4,
				        hitRadius: 10,
				        hoverRadius: 4,
			      	},
			    }
			};
			var ctx = $('#card-chart2');
			var cardChart2 = new Chart(ctx, {
			    type: 'line',
			    data: chartdata2,
			    options: options
			});


			// Graph for Feedback Received
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
			        	display: false
			      	}],
			      	yAxes: [{
			        	display: false
			      	}],
			    },
			    elements: {
			      	line: {
			        	borderWidth: 2
			      	},
			      	point: {
				        radius: 0,
				        hitRadius: 10,
				        hoverRadius: 4,
			      	},
			    }
			};
			var chartdata3 = {
			    labels: data1.recDate,
			    datasets: [
			      	{
				        label: 'Feedback Receive',
				        backgroundColor: 'rgba(255,255,255,.2)',
				        borderColor: 'rgba(255,255,255,.55)',
				        data: data1.recData
			      	},
			    ]
			};
			var ctx = $('#card-chart3');
			var cardChart3 = new Chart(ctx, {
			    type: 'line',
			    data: chartdata3,
			    options: options
			});


			// Graph for Feedback Received Percentage
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
				        display: false,
				        barPercentage: 0.6,
			      	}],
			      	yAxes: [{
			        	display: false,
			      	}]
			    },

			};
			var chartdata4 = {
			    labels: data1.percentDate,
			    datasets: [
			      	{
				        backgroundColor: 'rgba(255,255,255,.3)',
				        borderColor: 'transparent',
				        data: data1.percentData
			      	},
			    ]
			};
			var ctx = $('#card-chart4');
			var cardChart4 = new Chart(ctx, {
			    type: 'bar',
			    data: chartdata4,
			    options: options
			});
		}
	});
}


function selectOutlet(city) {
	$.ajax({
		url: 'fb_crnt_mnth_data.php?act=scity&city='+city,
		success : function(data){
			console.log(data);
			$('#outlet').html(data);
		}
	});
}


function customDateData(crd,city,outlet,type,ordersrc,dateran) {
	$.ajax({
		url:'fb_crnt_mnth_data.php?act='+crd+'&city='+city+'&outlet='+outlet+'&ordtype='+type+'&ordsrc='+ordersrc+'&dateran='+dateran,
		success : function(data){
			console.log(data);
			var data1 = JSON.parse(data);
			
			var my = data1.mtyr;
            var total = data1.overall;
            var overallstar = data1.overallstar;
            var fbsent = data1.fbsent;
            var sentData = data1.sentData;
            var sentDate = data1.sentDate;
            var fbdone = data1.fbdone;
            var recData = data1.recData;
            var recDate = data1.recDate;
            var notInt = data1.notinterest;
            var fbdoneper = data1.fbdoneper;
            var percentData = data1.percentData;
            var percentDate = data1.percentDate;
            var dyquesdata = data1.dyquesdata;
            $(".mnth-yr").html(my);
            $(".overall-rating").html(total);
            $(".overall-rating-star").html(overallstar);
            $(".fb-sent").html(fbsent);
            $(".fb-done").html(fbdone);
            $(".fb-notint").html(notInt);
            $(".fb-done-per").html(fbdoneper);
            $("#dynamic-ques-data").html(dyquesdata);

			// Graph for Overall Experience
			var chartdata = {
				labels: data1.date,
				
				datasets: [
					{
						label: "Customer Rating",
						fill: true,
						lineTension: 0.1,
						backgroundColor: [
			                'rgba(181, 207, 83, 0.4)'
			                /*'rgba(54, 162, 235, 0.2)',
			                'rgba(255, 206, 86, 0.2)',
			                'rgba(75, 192, 192, 0.2)',
			                'rgba(153, 102, 255, 0.2)',
			                'rgba(255, 159, 64, 0.2)'*/
			            ],
			            borderColor: [
			                'rgba(111, 126, 54, 1)'
			                /*'rgba(54, 162, 235, 1)',
			                'rgba(255, 206, 86, 1)',
			                'rgba(75, 192, 192, 1)',
			                'rgba(153, 102, 255, 1)',
			                'rgba(255, 159, 64, 1)'*/
			            ],
						pointHoverBackgroundColor: "rgba(59, 89, 152, 1)",
						pointHoverBorderColor: "rgba(59, 89, 152, 1)",
						borderWidth: 1,
						data: data1.fbvalue
					}
				]
			};
			
			var ctx = $("#main-chart");

			var chart = new Chart(ctx, {
				type: 'line',
				data: chartdata,
				options: {
					title : {
						display : false,
						position : "top",
						text : "",
						fontSize : 18,
						fontColor : "#111"
					},
					scales: {
						yAxes: [{
							ticks: {
								beginAtZero:true
							},
							scaleLabel: {
								 display: false,
								 labelString: '',
								 fontSize: 14 
							  }
						}]
					}
				}
			});


			// Graph for Feedback Sent
			var chartdata2 = {
			    labels: data1.sentDate,
			    datasets: [
			      	{
				        label: 'feedback sent',
				        backgroundColor: $.brandInfo,
				        borderColor: 'rgba(255,255,255,.55)',
				        data: data1.sentData
			      	},
			    ]
			};
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
				        gridLines: {
				          	color: 'transparent',
				          	zeroLineColor: 'transparent'
				        },
				        ticks: {
				          	fontSize: 2,
				          	fontColor: 'transparent',
				        }

			     	}],
			      	yAxes: [{
				        display: false,
				        ticks: {
				          	display: false,
				          	/*min: Math.min.apply(Math, data.datasets[0].data) - 5,
				          	max: Math.max.apply(Math, data.datasets[0].data) + 5,*/
				        }
			      	}],
			    },
			    elements: {
			      	line: {
				        tension: 0.00001,
				        borderWidth: 1
			      	},
				    point: {
				        radius: 4,
				        hitRadius: 10,
				        hoverRadius: 4,
			      	},
			    }
			};
			var ctx = $('#card-chart2');
			var cardChart2 = new Chart(ctx, {
			    type: 'line',
			    data: chartdata2,
			    options: options
			});


			// Graph for Feedback Received
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
			        	display: false
			      	}],
			      	yAxes: [{
			        	display: false
			      	}],
			    },
			    elements: {
			      	line: {
			        	borderWidth: 2
			      	},
			      	point: {
				        radius: 0,
				        hitRadius: 10,
				        hoverRadius: 4,
			      	},
			    }
			};
			var chartdata3 = {
			    labels: data1.recDate,
			    datasets: [
			      	{
				        label: 'Feedback Receive',
				        backgroundColor: 'rgba(255,255,255,.2)',
				        borderColor: 'rgba(255,255,255,.55)',
				        data: data1.recData
			      	},
			    ]
			};
			var ctx = $('#card-chart3');
			var cardChart3 = new Chart(ctx, {
			    type: 'line',
			    data: chartdata3,
			    options: options
			});


			// Graph for Feedback Received Percentage
			var options = {
			    maintainAspectRatio: false,
			    legend: {
			      	display: false
			    },
			    scales: {
			      	xAxes: [{
				        display: false,
				        barPercentage: 0.6,
			      	}],
			      	yAxes: [{
			        	display: false,
			      	}]
			    },

			};
			var chartdata4 = {
			    labels: data1.percentDate,
			    datasets: [
			      	{
				        backgroundColor: 'rgba(255,255,255,.3)',
				        borderColor: 'transparent',
				        data: data1.percentData
			      	},
			    ]
			};
			var ctx = $('#card-chart4');
			var cardChart4 = new Chart(ctx, {
			    type: 'bar',
			    data: chartdata4,
			    options: options
			});
		}
	});
}



function feedbackLogsData(logdt,city,outlet,type,logdate,operator,starnumber) {
	$.ajax({
		url: 'fb_crnt_mnth_data.php?act='+logdt+'&city='+city+'&outlet='+outlet+'&type='+type+'&logdate='+logdate+'&operator='+operator+'&starnum='+starnumber,
		success : function(data){
			console.log(data);
			// $('#paginate-customer').html(data);
			var data2 = JSON.parse(data);
			var csdetail = data2.customerDetails;
			var exlLink = data2.exlLink;
			$('#paginate-customer').html(csdetail);
			$('.cutomer-log-excel').html(exlLink);
		}
	});
}


function customerViewDetails(detail,fbno,outletid,invid) {
	$.ajax({
		url: 'fb_crnt_mnth_data.php?act='+detail+'&fbno='+fbno+'&outletid='+outletid+'&invoiceid='+invid,
		success : function(data){
			console.log(data);
			var data2 = JSON.parse(data);
			var fbdetail = data2.feedbackDetail;
			var odrinfo = data2.orderInfo;
			$('#customer-fb-detail').html(fbdetail);
			$('#customer-order-info').html(odrinfo);
		}
	});
}


function getCustomerData(cname) {
	$.ajax({
		url: 'fb_crnt_mnth_data.php?act=custName&name='+cname,
		success : function(data){
			console.log(data);
			$('#paginate-customer').html(data);
		}
	});
}


function customerTakeFeedback(takefb,outletid,invoiceid) {
	// $('#callbackModal').show();
	$.ajax({
		url: 'take_fb.php?act='+takefb+'&outletid='+outletid+'&invoiceid='+invoiceid,
		success : function(data){
			console.log(data);			
			$('#customer-cb-detail').html(data);			
			$('#cbdob, #cbanniversary').datepicker({
				format: 'dd-mm-yyyy',
				autoclose: true,
				todayHighlight: true,
				orientation: "bottom auto"
			});
		}
	});

	$.ajax({
		url: 'get_order_info.php?act='+takefb+'&outletid='+outletid+'&invoiceid='+invoiceid,
		success : function(data){
			console.log(data);			
			$('#customer-cb-info').html(data);		
		}
	});

}





function feedbackCallData(callback,outlet,daterange) {
	$.ajax({
		url: 'fb_crnt_mnth_data.php?act='+callback+'&outlet='+outlet+'&daterange='+daterange,
		success : function(data){
			console.log(data);
			$('.blade-callback').html(data);
		}
	});
}


function callbackSubmit(inputvalue,outletid,invoiceid,email,dob,anniversary,comments) {
	alert(inputvalue);
	$.ajax({
		url: 'save_fb_settings_data.php?act=cbfeedback&inputvalue='+inputvalue+'&outletid='+outletid+'&invoiceid='+invoiceid+'&email='+email+'&dob='+dob+'&anniversary='+anniversary+'&comments='+comments,
		success : function(data){
			console.log(data);
			
		}
	});
}