
PK 
<?php
ob_start();
//error_reporting(E_ALL ^ E_NOTICE);
@session_start();
ini_set('allow_url_include',1);
date_default_timezone_set("Asia/Kolkata");
set_time_limit(600);
ini_set('max_execution_time',600);
include '../includes/settings/constant.php';
//include '../includes/settings/db.php';
require_once '../includes/settings/PDODB.php';
include '../includes/modules/functions.php';
$function = new FUNCTIONS();
if(empty($_SESSION['adminId_cheesyBites'])){
header("Location: ../index.php");
exit();
}
$ipAddress = $function->getRealIpAddr();
if(isset($_POST['acsearch'])){
//print_r($from_date); exit;
$from_date = !empty($_POST['from_date'])?$_POST['from_date']:"";
$to_date = !empty($_POST['to_date'])?$_POST['to_date']:"";
if(!empty($from_date) && !empty($to_date)){
//$getOrderdata = $function->getAllOrderDetails($pId=NULL,$paymentMode=NULL,$isActive=1,$from_date=$from_date,$to_date=$to_date,$orderBy='DESC');
$from_date =date('Y-m-d', strtotime($from_date));
$to_date =date('Y-m-d', strtotime($to_date));
$pdodb = PDODB::getInstance();
$sql2 = "SELECT id, purchaseId, inventoryId, rateperunit, qty, balStockQty, total, createDate
FROM purchase_items
WHERE DATE(invoiceDate) BETWEEN '$from_date' AND '$to_date'";
$result2 = $pdodb->query($sql2);
// Group the results by inventoryId
$groupedResults = $function->groupByInventoryId($result2);
}
}else{
//echo "else"; //exit;
$pdodb = PDODB::getInstance();
$sql2 = "SELECT id, purchaseId, inventoryId, rateperunit, qty, balStockQty, total, createDate FROM purchase_items";
$result2 = $pdodb->query($sql2);
// Group the results by inventoryId
$groupedResults = $function->groupByInventoryId($result2);
}
//delete inventory
if(!empty($_GET['id']) && ($_GET['action']=='Del')) {
$id=$_GET['id'];
$pdodb = PDODB::getInstance();
$sql = "UPDATE `purchase` SET isActive=0 WHERE pId = '".$id."'";
//print_r($sql); exit;
$result = $pdodb->query($sql);
$sql2 = "UPDATE `purchase_items` SET isActive=0 WHERE purchaseId = '".$id."'";
$result2 = $pdodb->query($sql2);
PDODB::closeInstance();
if(!empty($result)){
echo '<script type="text/javascript">location.replace("purchase-list.php");</script>';
}
}
//end delete inventory
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>INSPINIA | Basic Form</title>
<?php include_once '../layout/style.php'; ?>
<style type="text/css">
.inpt-width {width: 60px;}
.itemCode {width: 60px;}
.hsnCode {width: 60px;}
.unit {width: 60px;}
.gstRate {width: 10px;}
.rateperunit {width: 60%;}
.qty {width: 60px;}
.total {width: 60%;}
.inpt-bgbord { border: none; background: transparent; }
</style>
</head>
<body>
<div id="wrapper">
<?php $currentPage = 'item-report'; include_once '../layout/side-bar.php'; ?>
<div id="page-wrapper" class="gray-bg">
<?php include_once '../layout/header.php'; ?>
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-6">
<h2>Item Wise Report</h2>
</div>
<div class="col-lg-6">
<form method="POST" action="" autocomplete="off">
<div class="form-group" id="data_5">
<label class="font-noraml">Range select</label>
<div class="input-daterange input-group" id="datepicker">
<input type="text" class="input-sm form-control" id="from_date" name="from_date" value=""/>
<span class="input-group-addon">to</span>
<input type="text" class="input-sm form-control" id="to_date" name="to_date" value="" />
</div>
<div class="form-group" style="margin-top: 10px;">
<button class="btn btn-sm btn-primary" name="acsearch" id="acsearch">Search</button>
<a href="" class="btn btn-sm btn-primary">Clear</a>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="row">
<div class="col-lg-12" style="padding:0px;">
<div class="ibox float-e-margins">
<div class="ibox-title">
<?php if (!empty($statusMsg)) { ?>
<div class="alert alert-success" role="alert">
<button type="button" class="close" data-dismiss="alert">x</button>
<?=$statusMsg;?>
</div>
<?php } ?>
</div>
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover dataTables-example">
<thead>
<tr>
<th>S.No</th>
<th>Item Name</th>
<th>Total Amount</th>
<th>Total Quantity</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
$grandTotalAmount = 0; // Initialize grand total for Total Amount
$grandTotalQuantity = 0; // Initialize grand total for Total Quantity
foreach ($groupedResults as $inventoryId => $items) {
$getinventorydata = $function->getInventory($id=$inventoryId, $itemCode=NULL, $itemType=NULL, $isActive=NULL, $orderBy='ASC');
$itemname = $getinventorydata[0]['itemName'];
$totalQuantity = 0;
$totalAmount = 0;
foreach ($items as $item) {
// Accumulate the total quantity and total amount for this inventory item
$totalQuantity += (float)$item['qty'];
$totalAmount += (float)$item['total'];
}
// Add to grand totals
$grandTotalAmount += $totalAmount;
$grandTotalQuantity += $totalQuantity;
$i++;
?>
<tr>
<td><?=$i;?></td>
<td><?=$itemname;?></td>
<td><?=$totalAmount;?></td>
<td><?=$totalQuantity;?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th colspan="2">Total</th>
<th><?=$grandTotalAmount;?></th> <!-- Display Grand Total Amount -->
<th><?=$grandTotalQuantity;?></th> <!-- Display Grand Total Quantity -->
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once '../layout/script.php'; ?>
<!-- Page-Level Scripts -->
<script>
$(document).ready(function(){
$('.dataTables-example').DataTable({
dom: '<"html5buttons"B>lTfgitp',
pageLength: 20,
buttons: [
{ extend: 'copy'},
{extend: 'csv'},
/*{extend: 'excel', title: 'ExampleFile'},
{extend: 'pdf', title: 'ExampleFile'},*/
/*{extend: 'print',
customize: function (win){
$(win.document.body).addClass('white-bg');
$(win.document.body).css('font-size', '10px');
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}*/
]
});
});
</script>
<script type="text/javascript">
$('#data_5 .input-daterange').datepicker({
keyboardNavigation: false,
forceParse: false,
autoclose: true
});
</script>
</body>
</html>


PK 99