?
Current Path : /home1/savoy/www/savoyglobal.net/sibs_draft/system/application/views/Report/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyglobal.net/sibs_draft/system/application/views/Report/targetbranchwisexls.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?> <?php if ($search == "") $search = 'search'; if($fromdate == '') $fromdate = 'fromdate'; if($todate=='') $todate = 'todate'; $branchname=$this->mastermodel->get_data_srow('ourbranch',$search,'id'); $csv_output=''; $csv_output='<html><head><body style="margin: 20px 20px 30px 20px;"> <div style="text-align:center"><b><u>Branch Target Report</u></b> </div><br/><br/>'; $csv_output.=" <table> <tr><th></th></tr> <tr><td>Branch:</td><td>$branchname->branchname</td></tr> <tr><td>Period:</td><td>"; if ($todate != 'todate'){ $csv_output .= "$fromdate to $todate"; } $csv_output.="</td> </tr> </table>"; $i=1; foreach($viewinfo as $updata22) { $csv_output.="<table width='90%' class='sort' border='1' cellpadding='1' cellspacing='-1'><thead> <tr> <th style='background-color:#80C0FF;'>Sl No</th> <th style='background-color:#80C0FF;'>Start Date</th> <th style='background-color:#80C0FF;'>End Date</th> <th style='background-color:#80C0FF;'>Target</th> <th style='background-color:#80C0FF;'>Target Type</th> </tr> <tr> <td>".$i++."</td> <td>".$this->mastermodel->convdatformat($updata22['startdate'])."</td> <td>".$this->mastermodel->convdatformat($updata22['enddate'])."</td> <td>".number_format($updata22['target'],2)."</td> <td>".$updata22['targettype']."</td> </tr> </table> <br/><br/>"; $fromdate=$this->mastermodel->convdatformat($updata22['startdate']); $todate=$this->mastermodel->convdatformat($updata22['enddate']); $viewinfoach= $this->reportmodel->generatereportsalesbra('',$fromdate,$todate,$search, substr($selected_cover, 0, strlen($selected_cover)-1)); $csv_output.="<table width='90%' class='sort' border='1' cellpadding='1' cellspacing='-1'> <thead> <tr> <th style='background-color:#80C0FF;'></th> <th style='background-color:#80C0FF;' >Cover Name</th> <th style='background-color:#80C0FF;'>Gross Premium</th> </tr> </thead>"; $grsprmtotal=0; $k=0;$j=1; $cctot=0; $actot=0; $nettot=0; $gptot=0; $brcctot=0; $bractot=0; $brnettot=0; $brgptot=0; $cvrid='unknown'; $coveridsort=array(); $ccv=0; foreach($viewinfoach as $key => $row) { $coveridsort[$key]=$row['cover_id']; } array_multisort($coveridsort, SORT_DESC, $viewinfoach); $grndtotal=0; foreach($viewinfoach as $updata) { if($updata['cover_id']!=$cvrid) { if($k!=0) { $csv_output.=" <tr> <td>".$j."</td> <td>".$cvrname."</td> <td style='text-align:right'><span id='premiumspan<?=$ccv?>'>".number_format($gptot, 2, '.', ',')."</span>"; $grsprmtotal += $gptot; $csv_output.="</td> </tr>"; $gptot=0;$j++; } $cvrid=$updata['cover_id']; $cvrname=$updata['covertype']; $ccv++; } $k++; $gp= $updata['premium']+$updata['policy_fees']; if($updata['endmode']=='Deduction') { $gp=0-$gp; } $gptot+=$gp; $grndtotal+=$gp; } if($viewinfoach) { $csv_output.="<tr> <td>".$j."</td> <td>".$updata['covertype']."</td> <td style='text-align:right'><span id='premiumspan<?=$ccv?>'>".number_format($gptot, 2, '.', ',')."</span>"; $grsprmtotal += $gptot; $csv_output.="</td> </tr> <tr> <td></td> <td style='text-align:center'><strong>Grand Total Premium(".$updata['currencycode'].")</strong></td> <td style='text-align:right' > <span><strong>".number_format($grsprmtotal,2)."</strong></span> </td> </tr>"; } $csv_output.=" <tr> <td> </td> <td style='text-align:center'><strong>Target</strong></td> <td style='text-align:right'><strong>".number_format($updata22['target'],2)." </strong></td> </tr> <tr> <td></td> <td style='text-align:center'><strong>Achieved Target</strong></td> <td style='text-align:right'><span><strong> "; $csv_output.=($grsprmtotal) / $updata22['target'] * 100; $csv_output.="</strong></span>%</td> </tr> </table>"; } $csv_output.='</body></head></html>'; $filename = "SalesTarget"; header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename.".xls"); header("Pragma: no-cache"); header("Expires: 0"); print $csv_output; exit; ?>