<? global $vis_language;
    if($total==0)
    {
		echo '<script> $("#pdfSlaDiv").hide();</script>';
		echo $vis_language['TXTNOMATCHFOUND'];
	}
    else {
		$labelData = json_encode(array("Overdue","Maintain"));
		$report = round($report,2);
		$maintain = round((100-$report),2);
		$dataSla = json_encode(array($report,$maintain));
		$colors = $this->generateUniqueHexColors(count($channelCount)+5);
		$uniqueColorsChannels = json_encode(array_unique($colors));
		$opArea = "#slaOps";$chartArea = "#slaOps_chart";
		?>
		<script>
		var staff = $('.staffId option:selected').text();$('.otherSelected').val(staff);
		var durationID = $('#duration option:selected').val(); if(durationID == 4){var custom = $('#vis_staff_sla_report_from_date').val()+ " to " +$('#vis_staff_sla_report_to_date').val(); $('.durationSelected').val(custom);}else{var duration = $('#duration option:selected').text();$('.durationSelected').val(duration);}
		</script>
		<?
		if($display==0){echo "<script>display_pie_charts($dataSla,$labelData,$dataSla,$uniqueColorsChannels,'".$opArea."','".$chartArea."');</script>"; }
	}
?>
<div class="col-sm-6 portlet" >
<div class="panel-body text-center" id="slaChart">
	<div class="list-group no-radius no-border text-xs text-left pull-left" id="slaOps">
	</div>
	<div id="slaOps_chart"></div>
</div>
</div>
<input class="durationSelected" type="hidden">
<input class="otherSelected" type="hidden">
<script>
	function generateStaffSlaPDF(titlePdf,durationPdf,staffPdf,overdue,maintain,slaPdf,pdfDate,dateSel)
	{
		var durationSel = $('.durationSelected').val();
		var otherSel = $('.otherSelected').val();
		var ele = $('#slaOps_chart');
		html2canvas([ele.get(0)], {
			onrendered: function(canvas) {
				var imgData = canvas.toDataURL('image/png');
				var doc = new jsPDF('landscape');
				doc.setFontSize(12);
				doc.text(20,15,'Title - '+titlePdf);
				doc.text(20,25,durationPdf+": "+durationSel);
				doc.text(20,35,staffPdf+": "+otherSel);
				doc.text(20,45,pdfDate+": "+dateSel);
				doc.addImage(imgData, 'PNG', 40, 60, 150, 50);
				doc.text(50,70,overdue+": <?php echo $report."%"; ?>");
				doc.text(50,80,maintain+": <?php echo $maintain."%"; ?>");
				//Set PDF properities
				doc.setProperties({
					title: titlePdf+' report',
				});
				doc.output('dataurlnewwindow');
			}
		});
	}
</script>
