Current File : /home/inlingua/public_html/noida/icentex_noida/pg/backup/invoice_report_result.php
<?php
//  Created on: 13-04-2013
session_start();
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{	echo "Please <a href='index.php'>login</a> first.";
	exit(0);
}
*/

// Include header
include "header_in.php";
?>

<h3 class='pa-nor-navbar'>Invoice Report (<a href="<?php echo "reports/pg_report.xlsx" ?>" target="_blank">Download Excel Report</a>)</h3>
<div id="contentnew">


<?php if ($_SESSION['dispMesg'][1] != "" && (date("U") - $_SESSION['dispMesg'][0] < 7)) 
{ 	?>
	<span id='mesgSpan'><font color='#da0000'><?php echo $_SESSION['dispMesg'][1];?></font></span>
	<script>
	setTimeout(function() {   $('#mesgSpan').fadeOut('slow'); }, 4000); // <-- time in milliseconds 
	</script>
	<br>
	<?php
}
unset($_SESSION['dispMesg']);
?>
<?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();

// Records selection sql
$sqlQuery = "SELECT a.*,b.location,c.*,c.amount as amt,d.ref_No FROM ingl_invoice_main a left join timesheet_location b on
a.centre=b.recNo left join ingl_invoice_detail c on a.recNo=c.main_id left join ingl_admission d on a.student_id=d.recNo  where 1=1 ";


if($_REQUEST['startdate']!="" && $_REQUEST['enddate']!=""){
$sqlQuery.=" && ( Date(a.createDate) >='".$_REQUEST['startdate']."' && Date(a.createDate) <='".$_REQUEST['enddate']."') ";	
}

if($_REQUEST['location']!=""){
$sqlQuery.=" && location='".$_REQUEST['location']."'";	
}

if($_REQUEST['category'][0]!="" && $_REQUEST['category'][0]!="0"){
$sqlQuery.="  && category_id='".$_REQUEST['category'][0]."'";	
}

if($_REQUEST['product'][0]!="" && $_REQUEST['product'][0]!="0"){
$sqlQuery.=" && product_id='".$_REQUEST['product'][0]."'";	
}

$sqlQuery.=" order by b.location,a.createDate desc";


// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page

// Prepare add on URL
$addOnUrl = "";
$offset=$_REQUEST['offset'];
if ($resultsPerPage > 0)
{	//$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	//$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}

// Print navigation bar
function printArray($element) { echo "$element"; }

if ($resultsPerPage > 0 && $prev_next_links && count($prev_next_links) > 1)
{	//echo "Page: ";
	//array_walk($prev_next_links, 'printArray'); 
}

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);
?>

<table border='0' class='pa-nor pa-table' width="100%">
<tr valign='top' class='rowH'>
<td>ID</td>
<td>Centre</td>
<td>Invoice No.</td>
<td>Date</td>
<td>Ref. No.</td>
<td>Name</td>
<td>Category</td>
<td>Product</td>
<td align="right">Amount</td>

</tr>
<?php
// If no records selected, print message
if (!$selectedRecords)
{	?>
	<tr><td colspan='5'>There are no entries</td></tr> 
	<?php
}
	$i=1;
	        $prodcat= new dbHandler();
                $prodcat->connect();
                $query_prodcat="select recNo,bill_category from ingl_billing_cat order by bill_category";
		
                $result_prodcat=$prodcat->select($query_prodcat);
		$prodcat_array=array();
		
		while($data_prodcat=$prodcat->SelectNext($result_prodcat)){
			  $prodcat_array[''.$data_prodcat[recNo].'']=$data_prodcat['bill_category'];
			}
			
		$subprodcat_array=array();
		$subprodcat= new dbHandler();
                $subprodcat->connect();
                $query_subprodcat="select recNo,bill_details from ingl_billing_main";
	        $result_subprodcat=$subprodcat->select($query_subprodcat);
				
				while($data_subprodcat=$subprodcat->SelectNext($result_subprodcat))
              {
			  $subprodcat_array[''.$data_subprodcat[recNo].'']=$data_subprodcat['bill_details'];
			  
			  }	
$tot=0;		
while($objectData=$dbObject->SelectNext())
{
	
	?>
	<tr valign='top' onmouseover="this.className='pa-row-highlight'" onmouseout="this.className='pa-nor'">
	<td><?php echo $i;?></td>
	<td><?php echo $objectData['location'];?></td>
	<td>
	<?php echo $objectData['invoice_no'];?>
	</td>
        <td>
	<?php echo date("d-m-Y",strtotime($objectData['createDate']));?>
	</td>
	<td><?php echo $objectData['ref_No'];?></td>
	<td><?php echo $objectData['student_name'];?></td>
	<td><?php echo $prodcat_array[$objectData['category_id']];?></td>
	<td><?php echo $subprodcat_array[$objectData['product_id']];?></td>
	<td align='right'><?php echo $objectData['amt'];?></td>
	</tr>
	<?php
	$i++;
	$tot=$tot+$objectData['amt'];
}
?>
<tr><td colspan="7">Total</td><td align='right'><?php echo $tot?></td></tr>
</table>

<?php
// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links  && count($prev_next_links) > 1)
{	//echo "Page: ";
	//array_walk($prev_next_links, 'printArray'); 
	//echo "<br>";
}
?>
</div>
<script type="text/javascript">
function confDel()
{	var agree = confirm("Click OK to Cancel");
	if (agree)
		return true;
	else
		return false;
}
</script>

<?php
include("05featuredemo1_pg.php");
$dbObject->CloseConnection();

// Include footer
include "footer_in.php";
?>