campaignwise.blade.php 6.08 KB
@php

if($dllogxls)
{
	include_once(app_path().'/lib/PHP_XLSXWriter_master/xlsxwriter.class.php');

	$headerexcel = [];
	$filename	= $filename.".xlsx";

	foreach($reporthead as $cachekey)
	{
		if($cachekey!='')
		{
			$headerexcel[$cachekey] = 'string';
		}
	}

	header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
	header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
	header('Content-Transfer-Encoding: binary');
	header('Cache-Control: must-revalidate');
	header('Pragma: public');

	$writer = new XLSXWriter();
	$styles1 = array( 'font'=>'Arial','font-size'=>10,'font-style'=>'bold', 'fill'=>'#eee', 'halign'=>'center', 'border'=>'left,right,top,bottom');
	$writer->writeSheetHeader('Sheet1', $headerexcel,$styles1,['freeze_rows'=>1, 'freeze_columns'=>1]);

	if($reportArr){

		foreach($reportArr as $row)
		{
			$newRow = [];

			$newRow['campaign']			= $row['campaign'];
		    $newRow['dials']			= $row['dials'];
		    $newRow['connects']			= $row['connects'];
		    $newRow['contacts']			= $row['contacts'];
		    $newRow['callbacks']		= $row['callbacks'];
		    $newRow['sales']			= $row['sales'];
		    $newRow['no_answer']		= $row['no_answer'];
		    $newRow['busy']				= $row['busy'];
		    $newRow['sit_tones']		= $row['sit_tones'];
		    $newRow['abandoned']		= $row['abandoned'];
		    $newRow['connects_per']		= $row['connects_per'];
		    $newRow['no_answer_per']	= $row['no_answer_per'];
		    $newRow['busy_per']			= $row['busy_per'];
		    $newRow['sit_tones_per']	= $row['sit_tones_per'];
		    $newRow['abandoned_per']	= $row['abandoned_per'];

			$writer->writeSheetRow('Sheet1', $newRow, $newRow_options = ['height'=>15]);
		}
	}

	$writer->writeToStdOut();

	return;
}

@endphp


<style>
	#logTableData.td{vertical-align:top;padding:20px;}
	#logTableData.tr{height:28px;overflow-y:hidden;}
</style>

<div class=innerAll>
	<h4 style="float:left;width:50%;margin:10px 0;">Campaign Report </small></h4>
	<div style="float:right;width:50%">
	@if(Auth::user()->username=='admin')
		<button class="pull-right btn btn-sm btn-default" onclick='dlAgentlogXls();return false;' title='Download'><i class='fa fa-download'></i> Download</button>  
	@endif
	</div>
	<div style="clear:both"></div>
	<hr style="margin-bottom: 5px;">
	<div>
		Search <input id=filter name="filter" type="text" style="border:1px solid #efefef; padding: 2px 10px;">&nbsp;&nbsp;
		Date: From <input size=10 id='modfrom' name='modfrom' type='text' value='<?php echo date("Y-m-d",$logdate); ?>' /> 
		<select id="modtime" style="border:1px solid #efefef;">
			<?php 
			foreach (range(0,23) as $hour) {
				$selected = ($hour == $logtime) ? "selected" : "";
				echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
			}
			?>
		</select>
		To <input size=10 id='modto' name='modto' type='text' value='<?php echo date("Y-m-d",$logdateto); ?>'/>
		<select id="modtimeto" style="border:1px solid #efefef;">
			<?php 
			foreach (range(0,23) as $hour) {
				$selected = ($hour == $logtimeto) ? "selected" : "";
				echo "<option value='$hour' $selected>".str_pad($hour, 2, "0", STR_PAD_LEFT) . ":00</option>";
			}
			?></select>&nbsp;&nbsp;
		<input type="button" value='Submit' class="btn btn-xs btn-info" onclick='statusLogReloadFun("");'>
	</div>

	<div style="clear:both"></div>
	<hr style="margin:5px;">

	<div style="overflow: auto; margin-top: 10px;">
		<table id=logTableData class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
		<thead>
        <th>Campaign</th>
        <th>Dials</th>
        <th>Connects</th>
		<th>Contacts</th>
        <th>Callbacks</th>
        <th>Sales</th>
        <th>No Answer</th>
        <th>Busy</th>
        <th>Sit Tones</th>
        <th>Abandoned</th>
        <th>Connect %</th>
        <th>No Answer %</th>
        <th>Busy %</th>
        <th>Sit Tones %</th>
        <th>Abandoned %</th>
        </thead>

        <tbody>
        @foreach($reportArr as $value)
        <tr>
        <td>{{$value['campaign']}}</td>
        <td>{{$value['dials']}}</td>
        <td>{{$value['connects']}}</td>
        <td>{{$value['contacts']}}</td>
        <td>{{$value['callbacks']}}</td>
        <td>{{$value['sales']}}</td>
        <td>{{$value['no_answer']}}</td>
        <td>{{$value['busy']}}</td>
        <td>{{$value['sit_tones']}}</td>
        <td>{{$value['abandoned']}}</td>
        <td>{{$value['connects_per']}}<span>%</span></td>
        <td>{{$value['no_answer_per']}}<span>%</span></td>
        <td>{{$value['busy_per']}}<span>%</span></td>
        <td>{{$value['sit_tones_per']}}<span>%</span></td>
        <td>{{$value['abandoned_per']}}<span>%</span></td>
        </tr>
        @endforeach
        </tbody>
		</table>
	</div>

	<div id=dialoglog></div>
</div>

<script>
$(document).ready(function() {
	if(!$('#dialoglog').hasClass('ui-dialog-content'))
	{
		$('#dialoglog').dialog({
			autoOpen: false,
			width: '70%',
			buttons: {
				"Ok": function() { 
					$(this).dialog("close"); 
				}, 
				"Cancel": function() { 
					$(this).dialog("close"); 
				} 
			}
		});
	}
	waitKeyUpRun("filter",function() { filter2(document.getElementById('filter'), 'logTableData') },"2000");
	$('#modfrom').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
	$('#modto').datepicker({dateFormat: 'yy-mm-dd',inline: true,changeYear: true,selectOtherMonths: true,yearRange: '<?php echo (date('Y')-70).":".(date('Y')+5); ?>'});
});

function dataString()
{
	return 'logdate='+$("#modfrom").val()+'&logtime='+$("#modtime").val()+'&logdateto='+$("#modto").val()+'&logtimeto='+$("#modtimeto").val();
}
function statusLogReloadFun(sortby)
{
	var sortstr='';if(sortby!="")sortstr="&sort="+sortby
	var searchStr = dataString();
	doAjax('report/campaignwise?'+searchStr+sortstr,'','rightmainreportdiv','ajax_dialer_reports','singlethis','GET');
}
function dlAgentlogXls()
{
	var searchStr = dataString();
	window.open('report/campaignwise?dllogxls=1&'+searchStr);
	return false;
}
</script>