Current File : /home/inlingua/public_html/faridabad/icentex/admin_oral/reports_result.php |
<?php
// Created on: 18-02-2015
session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{ echo "Please <a href='index.php'>login</a> first.";
exit(0);
}
*/
// Include header
include "header_oral.php";
?>
<h3>Reports</h3>
<aside class="contentbox-head"> <span class="title">Oral Report (<span class="status-row"><a href="<?php echo "reports/oral_reports.xlsx" ?>" target="_blank">Download Excel Report</a></span>)
</span>
</aside>
<?php
// Include the database connection details
require('../dbConnection.php');
// Include common functions
require('../commonFunc.php');
// Include common functions
require('../globalVars.php');
// Include the table handler class
require('../dbHandler.class.php');
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();
?>
<div id="contentnew">
<table border='1' width='90%'>
<tr style="background-color:#cccccc;font-weight:bold;">
<td>Oral Type</td>
<?php
$queryloc="select * from timesheet_location where status='1' ";
if($_REQUEST['location']!=""){
$queryloc.=" && recNo='".$_REQUEST['location']."'";
}
$resultloc=mysqli_query($conn,$queryloc) or die(mysql_error($conn));
$loc=array();
while ($numloc=mysqli_fetch_array($resultloc))
{
/*echo "<pre>";
print_r($numloc);//exit;*/
echo"<td>".$numloc['location']."</td>";
$loc[$numloc['code_prefix']]=$numloc['location'];
}
//print_r($loc);exit;
?>
<td>Amount<br>(Rs.)</td>
</tr>
<?php
$queryTy="select * from ingl_oral_type";
$resultTy=mysqli_query($conn,$queryTy);
$ky=1;
$totalarray=array();
$oraltype=array();
$ftot_a_1=array();
$ftot_a_2=array();
$ftot_a_3=array();
$tot_final=0;
while($numTy=mysqli_fetch_array($resultTy)){
echo"<tr>";
echo"<td>".$numTy['type_oral']."</td>";
//$ftot=0;
$tot_1=0;
foreach($loc as $key=>$val){
$query="select oral_".$ky."_1,oral_".$ky."_2,oral_".$ky."_3,oral_".$ky."_4,oral_".$ky."_5,oral_".$ky."_6,oral_".$ky."_7,oral_".$ky."_8,oral_".$ky."_9,oral_".$ky."_10,oral_".$ky."_11,oral_".$ky."_12,oral_".$ky."_13,rates_apply from (select * from ingl_oral where 1=1 ";
if($_REQUEST['startdate']!="" && $_REQUEST['enddate']!=""){
$query.=" && dates >='".$_REQUEST['startdate']."' && dates <='".$_REQUEST['enddate']."'";
}
$query.=" && (oral_".$ky."_1 like '".$key."%' || oral_".$ky."_2 like '".$key."%' || oral_".$ky."_3 like '".$key."%' || oral_".$ky."_4 like '".$key."%' || oral_".$ky."_5 like '".$key."%' || oral_".$ky."_6 like '".$key."%' || oral_".$ky."_7 like '".$key."%' || oral_".$ky."_8 like '".$key."%' || oral_".$ky."_9 like '".$key."%' || oral_".$ky."_10 like '".$key."%' || oral_".$ky."_11 like '".$key."%' || oral_".$ky."_12 like '".$key."%' || oral_".$ky."_13 like '".$key."%')) a left join ingl_oral_main b on a.main_id=b.recNo where b.status='Send'";
if($_REQUEST['customer_detailing']!=""){
$query.=" && b.instructor='".$_REQUEST['customer_detailing']."'";
}
//echo $query;exit;
$result=mysqli_query($conn,$query);
$co=0;
while($num=mysqli_fetch_array($result)){
for($k=0;$k<=12;$k++)
{
if($num[$k]!="")
{
$ec=explode("-",$num[$k]);
if($ec[0]==$key){
$co=$co+1;
$tot_1=$tot_1+$num['rates_apply'];
}
}
}
}
/*$totalcenter=count($loc);
echo $totalcenter;*/
/*echo end($loc);
print_r($val);
exit;*/
if($ky=="1"){
$ftot_a_1[$key]=$co;
if(end($loc)==$val)
{
$totalarray[] = $ftot_a_1;
$oraltype[]=array($numTy['type_oral'],$tot_1);
}
}
if($ky=="2"){
$ftot_a_2[$key]=$co;
if(end($loc)==$val)
{
$totalarray[]=$ftot_a_2;
$oraltype[]=array($numTy['type_oral'],$tot_1);
}
}
if($ky=="3"){
$ftot_a_3[$key]=$co;
if(end($loc)==$val)
{
$totalarray[]=$ftot_a_3;
$oraltype[]=array($numTy['type_oral'],$tot_1);
}
}
echo"<td>".$co."</td>";
//$ftot=$ftot+$co;
}
echo"<td>".$tot_1."</td>";
$tot_final=$tot_final+$tot_1;
echo"</tr>";
$ky++;
}
/*echo "<pre>";
print_r($totalarray);
print_r($oraltype);
exit;*/
?>
<tr>
<tr><td>Total</td>
<?php
foreach($loc as $key=>$val){
$tt=$ftot_a_1[$key]+$ftot_a_2[$key]+$ftot_a_3[$key];
echo"<td>".$tt."</td>";
}
?>
<td><?php echo $tot_final ?></td>
</tr>
</tr>
</table>
</div>
<?php
include("05featuredemo1_oral.php");
//include("05featuredemo1.inc_payment.php");
$dbObject->CloseConnection();
// Include footer
include "footer_oral.php";
?>