Current File : /home/inlingua/www/icentex/pg/payment_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";
?>

<aside class="contentbox-head"> <span class="title">Payment Report (<span class="status-row"><a href="<?php echo "reports/payment_report.xlsx" ?>" target="_blank">Download Excel Report</a></span>)
</span>
          </aside>
<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();
    mysqli_query($conn,"SET autocommit = 0;");
// Records selection sql
$sqlQuery = "SELECT a.recNo AS Mainrec,a.invoice_no,a.centre,a.student_id,a.student_name,a.student_address,a.received_by,a.payment_details,a.amount,a.tax_per,a.tax_value,a.discount_per,a.discount_value,a.final_amount,a.createdBy,a.createDate as Date ,a.modifyDate,a.status_delete,a.refunded_amount,a.refunded_details,a.refunded_by,a.refunded_date,a.type,a.isSynced,a.SyncedOn
 , m.bill_details,dt.amount as ItemAmt,dt.quantity,dt.remarks, b.location, d.incenter_source,d.mobile,d.preffered_slot,d.preffered_slot_sat, (SELECT name FROM timesheet_user user WHERE user.recNo = d.customer_detailing ) AS customer_detailing,c.recNo,c.invice_no,c.rcpt_id,c.amount,c.payment_mode,c.cheque_no,c.favour_of,c.createDate,c.modifyDate,c.created_by,c.product_id,c.isSynced,c.SyncedOn
 , d.ref_No, dt.course_id, dt.Discount AS Discountdt,dt.category_id,dt.product_id FROM ingl_invoice_main a inner JOIN timesheet_location b ON a.centre = b.recNo inner JOIN ingl_invoice_payment c ON a.invoice_no = c.rcpt_id inner JOIN ingl_admission d ON a.student_id = d.ref_No INNER JOIN ingl_invoice_detail dt ON a.invoice_no = dt.invoice_no INNER JOIN ingl_billing_main m ON m.recNo = dt.product_id WHERE  a.status_delete in (1,2,0) ";//c.amount >0

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

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

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


/*echo $sqlQuery;
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 rcpt_id ";

//echo $sqlQuery;
// 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 ;
}
//echo $sqlQuery;
// 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 listing-table' width="100%">
<tr valign='top' class='rowH'>
<th>ID</th>
<th>Centre</th>
<th>Product</th>
<th>Receipt No.</th>
<th>Date</th>
<th>Reference No.</th>
<th>Registration ID</th>
<th>Name</th>
<th>Rate</th>
<th>SGST</th>
<th>CGST</th>
<th>IGST</th>
<th>TOTAL TAX</th>
<th align="right">Amount</th>
<th>Payment Mode </th>
<th>Cheque No./<br>Transaction Id</th>
<th>Favour Of/<br>Transaction Details  </th>

</tr>
<?php
// If no records selected, print message
if (!$selectedRecords)
{	?>
	<tr><td colspan='5'>There are no entries</td></tr> 
	<?php
}
	$i=1;
$cancle=0;	        	
$tot=0;	
$trate=0;
$tCGST=0;  
$tSGST=0;  
$TTax=0;  
$tamt=0;	
$totmaterial=0;
$alldata=array();

while($objectData=$dbObject->SelectNext())
{
$alldata[]=$objectData;
$ItemAmt = (int)$objectData['ItemAmt'];
$rate=$ItemAmt/1.18;
$rate=number_format($rate, 2);
$rate=str_replace(',', '', $rate);
$tax=$rate*0.09;

$CGST=number_format($tax, 2);
$SGST=number_format($tax, 2);
$CGST=str_replace(',', '', $CGST);
$SGST=str_replace(',', '', $SGST);
$totalrate=number_format($rate,2);
$TotalTax=$CGST+$SGST;

$TotalTax=number_format($TotalTax, 2);
$TotalTax=str_replace(',', '', $TotalTax);
$tamount=$TotalTax+$rate;
$totalamt=number_format($tamount, 2);

$totalamt=str_replace(',', '', $totalamt);
if($objectData['type']=='M')
{
	$TotalTax=0;
	$CGST=0;
	$SGST=0;
	$rate=(int)$objectData['ItemAmt'];
}

if($objectData['status_delete']==1 || $objectData['status_delete']==2)
{
$sty='style="background-color:#FFFF33;"';
$cancle=$cancle+$totalamt;
}else{
$sty='';
}

	?>
	<tr valign='top' <?=$sty; ?> 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['bill_details'];?>
	</td>
	
	<td>
	<?php echo $objectData['rcpt_id'];?>
	</td>
	
	<td>
	<?php echo date("d-m-Y",strtotime($objectData['Date']));?>
	</td>
	<td>
	<?php echo $objectData['ref_No'];?>
	</td>
	
	<td><?php echo $objectData['course_id'];?></td>
	<td><?php echo $objectData['student_name'];?></td>
	<td><?php echo $rate;?></td>
	<td><?php echo $CGST;?></td>
	<td><?php echo $SGST;?></td>
	<td><?php echo '0.0';?></td>
	<td><?php echo $TotalTax;?></td>
	<td align='right'><?php echo $totalamt;?></td>
	<td><?php echo $objectData['payment_mode'];?></td>
	<td><?php echo $objectData['cheque_no'];?></td>
	<td><?php echo $objectData['favour_of'];?></td>
	</tr>
	<?php
	$i++;
	$tot=$tot+$totalamt;
	$trate=$trate+$rate;
 $tCGST=$tCGST+$CGST;  
 $tSGST=$tSGST+$SGST;  
 $TTax=$TTax+$TotalTax;  
 $tamt=$tamt+$totalamt; 
 
 $totmaterial=$totmaterial+$objectData['quantity'];
}
$grandtotal=$tamt-$cancle;
?>
<tr><td colspan="3">Total</td>
<td align='right' colspan="3"><strong>Cancle Receipt: </strong> <?php echo $cancle;?></td>
<td align='right' colspan="2"><strong>G.Total: </strong> <?php echo $grandtotal;?></td>
<td align='right'><?php echo $trate;?></td>
<td align='right'><?php echo $tCGST;?></td>
<td align='right'><?php echo $tSGST;?></td>
<td align='right'>0.0</td>
<td align='right'><?php echo $TTax;?></td>
<td align='right'><?php echo $tamt;?></td>
<td colspan="1">&nbsp;</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_payment.php");


//include("05featuredemo1.inc_payment.php");
$dbObject->CloseConnection();

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