rtncbmis.blade.php 5.17 KB
<?php
$reportTitle = 'RTNCB MIS';
$returnblade = 'rtncbmis';

$view_path = Config::get('view.paths');
include_once($view_path[0].'/layout/module/dialer/reporthead.blade.php');

$alist=$alist->whereIn('userstatus',array('Interested', 'Reprised', 'No contact', 'Not Interested', 'Not Eligible', 'FollowUp'));
$alist=$alist->orderBy('userstatus');
$alist=$alist->get();

$i=1;
$reporthead=array("Status","Count","%","Attempt","Intensity");
$reportarray=array();

if(count($alist)) {
	$summation['Contacted']=array("Status"=>'Contacted',"Total"=>0);
	$summation['All Interested']=array("Status"=>'All Interested',"Total"=>0);
	$summation['Not Contacted']=array("Status"=>'Not Contacted',"Total"=>0);
	$summation['Total']=array("Status"=>'Total',"Total"=>0);
	foreach($alist as $aline)
	{
		$arrayheadkey = $aline->userstatus;
		if(!isset($reportarray[$arrayheadkey]))$reportarray[$arrayheadkey]=array("Status"=>"<b>".$arrayheadkey."</b>","Total"=>0);
		$reportarray[$arrayheadkey]["Attempt"]++;
		
		$arraykey = $aline->usersubstatus;
		if(!isset($reportarray[$arraykey]))$reportarray[$arraykey]=array("Status"=>$arraykey,"Total"=>0);
		$reportarray[$arraykey]["Attempt"]++;
		
		$reportarray[$arrayheadkey]["Customer_lists"][] = $aline->lan;
		$reportarray[$arraykey]["Customer_lists"][] = $aline->lan;
		
		if($aline->userstatus != 'No contact') {
			if($aline->userstatus != 'Interested') {
				$summation['All Interested']["Attempt"]++;
				$summation['All Interested']["Customer_lists"][] = $aline->lan;
			}
			$summation['Contacted']["Attempt"]++;
			$summation['Contacted']["Customer_lists"][] = $aline->lan;
		}
		else {
			$summation['Not Contacted']["Attempt"]++;
			$summation['Not Contacted']["Customer_lists"][] = $aline->lan;
		}
		$summation['Total']["Attempt"]++;
		$summation['Total']["Customer_lists"][] = $aline->lan;
		
	}

$reportarray = array_merge($reportarray, $summation);
$total_cust = (is_array($summation['Total']["Customer_lists"])) ? count(array_unique($summation['Total']["Customer_lists"])) : 0;
}
$highestColumn = sizeof($reporthead);
if(count($reportarray)) {
	$outhead="<tr>";$outstr="";
	for ($head = 0; $head < $highestColumn; $head++){
		if($reporthead[$head] == '#' && false) {
			$mode_str = "<a onclick='displayMode(".'"summation"'.");return false;' href='#'><i class='fa fa-plus-square-o'></i></a> / <a onclick='displayMode(".'"percent"'.");return false;' href='#'>%</a>";
			$outhead.="<td>".$mode_str."</td>";
		}
		else {
			$outhead.="<td>".$reporthead[$head]."</td>";
		}
	}
	$outhead.="</tr>";
	$utotalarr = array("Date"=>'Total');
	foreach($reportarray as $uid=>$uarr)
	{
		$row_cust = (is_array($uarr["Customer_lists"])) ? count(array_unique($uarr["Customer_lists"])) : 0;
		$per = ($total_cust != 0) ? number_format(@($row_cust/$total_cust) * 100, 2 ) : 0;
		$int = ($row_cust != 0) ? number_format(@($uarr['Attempt']/$row_cust), 2 ) : 0;
		$outstr.="<tr>";
		$outstr.="<td>".$uarr['Status']."</td>";
		$outstr.="<td>".$row_cust."</td>";
		$outstr.="<td>".$per."%</td>";
		$outstr.="<td>".$uarr['Attempt']."</td>";
		$outstr.="<td>".$int."</td>";
		$outstr.="</tr>";
	}

	$outstr.="<tr>";
	for ($head = 0; $head < $highestColumn; $head++)
	{
		if($head < 50) {
			$data_str = $utotalarr[$reporthead[$head]];
		}
		else {
			$data_str = '<span class="summation" style="display:block;">'.$utotalarr[$reporthead[$head]].'</span>';
			$data_str .= '<span class="percent" style="display:none;">'.number_format(@($utotalarr[$reporthead[$head]]/$utotalarr['Total']) * 100, 2 ).'%</span>';
		}
		$outstr.="<td>".$data_str."</td>";
	}
	$outstr.="</tr>";
}
else {
	$outhead.="<tr><td>No Records Found.</td></tr>";
}

if(Input::has("dllogxls"))
{
	include_once(app_path().'/lib/phpexcel/PHPExcel.php');

	$inputFileType = "Excel5";
	$objReader = PHPExcel_IOFactory::createReader($inputFileType);
	$objPHPExcel = $objReader->load("assets/extras/blank.xls");
	$baseRow = 2;


	$highestColumn = sizeof($reporthead);
	for ($head = 0; $head < $highestColumn; $head++){
		$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
		$objPHPExcel->getActiveSheet()->setCellValue($colstr."1", $reporthead[$head]);
	}

	foreach($reportarray as $uid=>$uarr)
	{
		$row = $baseRow++;
		$col = 0;

		for ($head = 0; $head < $highestColumn; $head++){
			$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
			$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $uarr[$reporthead[$head]]);
		}
	}

	$row++;
	for ($head = 0; $head < $highestColumn; $head++){
		$colstr=PHPExcel_Cell::stringFromColumnIndex($head);
		$objPHPExcel->getActiveSheet()->setCellValue($colstr.$row, $utotalarr[$reporthead[$head]]);
	}

	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment;filename="Dailyleads.xls"');
	header('Cache-Control: max-age=0');

	$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
	$objWriter->save('php://output');

	return ;
}
?>

@include('layout.module.dialer.searchform')

<div style="overflow: auto; margin-top: 10px;">
    <table id=logtable class='footable table table-striped table-bordered table-white table-primary footable-loaded' style='font-size:12px; margin:0; border:1px solid #BBB;'>
        <thead><?php echo $outhead; ?></thead>
        <?php echo $outstr; ?>
    </table>
</div>
</div>