Current File : /home/inlingua/www/noida/icentex_noida/admin-in-centre/payment_rpt.php
<?php
include("header_cert.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();
        $month=$_REQUEST[month];
	$year=$_REQUEST[year];
	
	//$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
        //$date1="".$year."-".$month."-01";
        //$date2="".$year."-".$month."-".$num."";
        //$dat=date("F Y",strtotime($date1));
	
	$date1=$_REQUEST['startdate'];
	  $date2=$_REQUEST['enddate'];
	$dat="".$date1." to ".$date2."";
?>

			<h3>
Payment Reports 

</h3>
                        <div id="contentnew">
        <?php
        
	
        
        echo "<b>Duration : ".$dat."  For ".$_REQUEST['location']."</b>";
        
        $query="select * from timesheet_user where (usertype='fd' || fd='Y') && status='Active'";
        
        if($_REQUEST['location']!="All")
        {
        $query.=" && primarycenter='".$_REQUEST['location']."'";    
        }
        
        $query.=" order by name";
        //echo $query;
        $result=mysql_query($query);
        $tota=0;
        $totb=0;
        $totc=0;
        $totd=0;
	$tote=0;
	$toti=0;
        echo"<table width='100%'><tr  class='rowH'><td>Instructor</td>
        <td>Total</td><td>Cash</td><td>Cheque</td><td>Card</td><td>Net Banking</td><td>Invoice</td></tr>";
        while($num=mysql_fetch_array($result))
        {
            $queryTot="select sum(amount) as totreg from ingl_invoice_payment where created_by='".$num['recNo']."'  && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot=mysql_query($queryTot);
            $numTot=mysql_fetch_array($resultTot);
            
            
            $queryTot1="select sum(amount) as totreg1 from ingl_invoice_payment where created_by='".$num['recNo']."' && payment_mode='Cash' && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot1=mysql_query($queryTot1);
            $numTot1=mysql_fetch_array($resultTot1);
	    
	    $queryTot2="select sum(amount) as totreg1 from ingl_invoice_payment where created_by='".$num['recNo']."' && payment_mode='Cheque' && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot2=mysql_query($queryTot2);
            $numTot2=mysql_fetch_array($resultTot2);
            
            $queryTot3="select sum(amount) as totreg1 from ingl_invoice_payment where created_by='".$num['recNo']."' && payment_mode='Card' && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot3=mysql_query($queryTot3);
            $numTot3=mysql_fetch_array($resultTot3);
            
	    $queryTot4="select sum(amount) as totreg1 from ingl_invoice_payment where created_by='".$num['recNo']."' && payment_mode='Net Banking' && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot4=mysql_query($queryTot4);
            $numTot4=mysql_fetch_array($resultTot4);
            
	    $queryTot5="select sum(final_amount) as totreg1 from ingl_invoice_main where createdBy='".$num['recNo']."' && date(createDate)>='".$date1."' && date(createDate)<='".$date2."'";
            $resultTot5=mysql_query($queryTot5);
            $numTot5=mysql_fetch_array($resultTot5);
            
	    
	    
	    if($numTot['totreg']<=0)
	    {
		$numTot['totreg']="-";
	    }
	    
	     if($numTot1['totreg1']<=0)
	    {
		$numTot1['totreg1']="-";
	    }
	    
	     if($numTot2['totreg1']<=0)
	    {
		$numTot2['totreg1']="-";
	    }
	    
	     if($numTot3['totreg1']<=0)
	    {
		$numTot3['totreg1']="-";
	    }
	    
	     if($numTot4['totreg1']<=0)
	    {
		$numTot4['totreg1']="-";
	    }
            
	    if($numTot5['totreg1']<=0)
	    {
		$numTot5['totreg1']="-";
	    }
            ?>
            <tr><td><?php echo $num['name'] ?></td>
                <td><a href='payment_details.php?user=<?php echo $num['recNo'] ?>&date1=<?php echo $date1 ?>&date2=<?php echo $date2 ?>'><?php echo $numTot['totreg'] ?></a></td><td><?php echo $numTot1['totreg1'] ?></td>
                <td><?php echo $numTot2['totreg1'] ?></td><td><?php echo $numTot3['totreg1'] ?></td>
		<td><?php echo $numTot4['totreg1'] ?></td>
	        <td><?php echo $numTot5['totreg1'] ?></td>
	    </tr>
            <?php
            
        $tota=$tota+$numTot['totreg'];
        $totb=$totb+$numTot1['totreg1'];
        $totc=$totc+$numTot2['totreg1'];
        $totd=$totd+$numTot3['totreg1'];
	$tote=$tote+$numTot4['totreg1'];
	$toti=$toti+$numTot5['totreg1'];
            
        }
        ?>
        <tr  class='rowH'><td>Total</td>
        <td><?php echo $tota ?></td><td><?php echo $totb ?></td><td><?php echo $totc ?></td><td><?php echo $totd ?></td>
	<td><?php echo $tote ?></td>
	<td><?php echo $toti ?></td>
	</tr>
        </table>
                        </div>
                        
                        
                        
<?php
//include("05featuredemo1_visit.php");
include("footer_cert.php");
?>