MMCT TEAM
Server IP : 217.21.85.138  /  Your IP : 216.73.216.103
Web Server : LiteSpeed
System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u915722082 ( 915722082)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u915722082/public_html/ettgroups/../at/sae1/src/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u915722082/public_html/ettgroups/../at/sae1/src/../over_all_report.php
<?php
	session_start();
	require_once"_config.php";
	
	if(!isset($_SESSION["logs"])){
		redirect("index.php");
	}
	
	$data["fdate"] = date("d-m-Y");
	$data["tdate"] = date("d-m-Y");
	$data["title"] = "over all report ";
	$data["link"] = "";
	if(isset($_POST["submit"])){
		
		$fdate = date_db_format($_POST["fdate"]);
		$tdate = date_db_format($_POST["tdate"]);
		
		$data["fdate"] = $_POST["fdate"];
		$data["tdate"] = $_POST["tdate"];
		
		if($_POST["type"] == "1"){
			$data["link"] = "over_all_report_print.php?fdate={$fdate}&tdate={$tdate}";
			$data["title"] = "over all report product wise - ".$data["fdate"]." to ".$data["tdate"];
		
			$sql="select * from tbl_products order by pname";
			$data["rows"] = resultSet($con,$sql);
		
			
			$data["ledger"] = [];
			foreach($data["rows"] as $row){
				 
				$opn = single($con,"select sum(dr)-sum(cr) as opn,sum(if(ttype='PURCHASE',total,0)) as total_dr,sum(if(ttype='SALES',total,0)) as total_cr from `{$_SESSION["fyear"]}_tbl_transactions` t inner join tbl_products p on t.pid=p.pid  where tdate<'{$fdate}' and  t.pid='{$row["pid"]}'");
				
				$pur = single($con,"select sum(dr) as opn,sum(total) as total from `{$_SESSION["fyear"]}_tbl_transactions` where tdate>='{$fdate}' and tdate<='{$tdate}' and  pid='{$row["pid"]}' and ttype='PURCHASE'");
				
				$sal = single($con,"select sum(cr) as opn,sum(total) as total from `{$_SESSION["fyear"]}_tbl_transactions` where tdate>='{$fdate}' and tdate<='{$tdate}' and  pid='{$row["pid"]}' and ttype='SALES'");
				 
				$cls = single($con,"select sum(dr)-sum(cr) as opn,sum(if(ttype='PURCHASE',total,0)) as total_dr,sum(if(ttype='SALES',total,0)) as total_cr  from `{$_SESSION["fyear"]}_tbl_transactions` where tdate<='{$tdate}' and  pid='{$row["pid"]}'");
				
				
				$data["ledger"][$row["pid"]]=[
					"opn"=>round($opn["opn"],2),
					"opn_val"=>round($opn["total_dr"]-$opn["total_cr"],2),
					"pur"=>round($pur["opn"],2),
					"pur_val"=>round($pur["total"],2),
					"sal"=>round($sal["opn"],2),
					"sal_val"=>round($sal["total"],2),
					"cls"=>round($cls["opn"],2),
					"cls_val"=>round($cls["total_dr"]-$cls["total_cr"],2),
				];
			}
		}else{
			
			$data["title"] = "over all report category wise - ".$data["fdate"]." to ".$data["tdate"];
			$data["link"] = "over_all_report_cate_print.php?fdate={$fdate}&tdate={$tdate}";
			$sql="select p.cid,p.pid,c.cname as pname from tbl_products p inner join tbl_category c on p.cid=c.cid group by p.cid order by cname";
			$data["rows"] = resultSet($con,$sql); 
			
			
			$data["ledger"] = [];
			foreach($data["rows"] as $row){
				
				$opn = single($con,"select sum(dr)-sum(cr) as opn,sum(if(ttype='PURCHASE',total,0)) as total_dr,sum(if(ttype='SALES',total,0)) as total_cr from `{$_SESSION["fyear"]}_tbl_transactions` t inner join tbl_products p on t.pid=p.pid where tdate<'{$fdate}' and  cid='{$row["cid"]}'");
				
			
				 
				 
				$pur = single($con,"select sum(dr) as opn,sum(total) as total from `{$_SESSION["fyear"]}_tbl_transactions` t inner join tbl_products p on t.pid=p.pid where tdate>='{$fdate}' and tdate<='{$tdate}' and  cid='{$row["cid"]}' and ttype='PURCHASE'");
				
			
				
				$sal = single($con,"select sum(cr) as opn,sum(total) as total from `{$_SESSION["fyear"]}_tbl_transactions` t inner join tbl_products p on t.pid=p.pid where tdate>='{$fdate}' and tdate<='{$tdate}' and  cid='{$row["cid"]}' and ttype='SALES'");
				 
				$cls = single($con,"select sum(dr)-sum(cr) as opn,sum(if(ttype='PURCHASE',total,0)) as total_dr,sum(if(ttype='SALES',total,0)) as total_cr from `{$_SESSION["fyear"]}_tbl_transactions` t inner join tbl_products p on t.pid=p.pid where tdate<='{$tdate}' and  cid='{$row["cid"]}'");
				
				$data["ledger"][$row["pid"]]=[
					"opn"=>round($opn["opn"],2),
					"opn_val"=>round($opn["total_dr"]-$opn["total_cr"],2),
					"pur"=>round($pur["opn"],2),
					"pur_val"=>round($pur["total"],2),
					"sal"=>round($sal["opn"],2),
					"sal_val"=>round($sal["total"],2),
					"cls"=>round($cls["opn"],2),
					"cls_val"=>round($cls["total_dr"]-$cls["total_cr"],2),
				];
			}
			
		}
	}
?>

<!DOCTYPE html>
<html lang="en">
<?php include "_header.php"; ?>
<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">

<script>var defaultThemeMode = "light"; var themeMode; if ( document.documentElement ) { if ( document.documentElement.hasAttribute("data-theme-mode")) { themeMode = document.documentElement.getAttribute("data-theme-mode"); } else { if ( localStorage.getItem("data-theme") !== null ) { themeMode = localStorage.getItem("data-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-theme", themeMode); }</script>
	
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">

<div class="app-page  flex-column flex-column-fluid " id="kt_app_page">  
<?php include"_navbar.php"; ?>

<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
<?php include"_sidebar.php"; ?>

<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
<div class="d-flex flex-column flex-column-fluid">

<!-- Tool bar -->
<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
	<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
		<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
			<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">Over All Report</h1>
			<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
				<li class="breadcrumb-item text-muted">
					<a href="#" class="text-muted text-hover-primary">Home</a>
				</li>
				<li class="breadcrumb-item">
					<span class="bullet bg-gray-400 w-5px h-2px"></span>
				</li>
				<li class="breadcrumb-item text-muted"><a href='over_all_report.php'>Over All Report</a></li>
			</ul>
		</div>
	</div>
</div>
<!-- Page Body -->
<div id="kt_app_content" class="app-content  flex-column-fluid ">
<div id="kt_app_content_container" class="app-container  container-xxl "> 					
	<div class="card card-flush">
		<div class="card-header align-items-center py-5 gap-2 gap-md-5" style='display:block!important;'>
			<form id="frm" class="form" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method='post'>
				<div class='row'> 
				
					<div class="d-flex flex-column mb-8 fv-row col-md-3">
						<label class="d-flex align-items-center fs-6 fw-semibold mb-2 ">
							<span class="required">From Date</span>
							<i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip" title="Select From Date"></i>
						</label>
						<input type="text" class="form-control form-control-solid datepicker" placeholder="Select From Date" name="fdate"  value="<?php echo $data["fdate"]; ?>" required />
					</div>
					
					<div class="d-flex flex-column mb-8 fv-row col-md-3">
						<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
							<span class="required">To Date</span>
							<i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip" title="Select To Date"></i>
						</label>
						<input type="text" class="form-control form-control-solid datepicker" placeholder="Select To Date" name="tdate" required  value="<?php echo $data["tdate"]; ?>"  />
					</div>
					<div class="d-flex flex-column mb-8 fv-row col-md-3">
						<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
							<span class="required">To Date</span>
							<i class="fas fa-exclamation-circle ms-2 fs-7" data-bs-toggle="tooltip" title="Select To Date"></i>
						</label>
						<select class="form-select form-select-solid"   data-control="select2" data-placeholder="Select Product" name='type' id='type' required>
							<?php if($_SESSION["roll"] == "ADMIN"):?>
								<option value='1'>Product Wise</option>
							<?php endif; ?>
							
							<option value='2'>Category Wise</option>
						</select>
					</div> 
					<div class="col-md-2">
						<button type="submit" id="btn-submit" class="btn btn-primary btn-submit" style='margin-top:30px;' name='submit'>
							View Report
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<?php if(isset($data["rows"])): ?>
	<input type='hidden' value='<?php echo $data["title"]; ?>' id='title' >
	
	<div class="card card-flush">
		<div class="card-header align-items-center py-5 gap-2 gap-md-5">
			<div class="card-title">
				<!--begin::Search-->
				<div class="d-flex align-items-center position-relative my-1">
					<!--begin::Svg Icon | path: icons/duotune/general/gen021.svg-->
					<span class="svg-icon svg-icon-1 position-absolute ms-4">
						<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
							<rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546" height="2" rx="1" transform="rotate(45 17.0365 15.1223)" fill="currentColor" />
							<path d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z" fill="currentColor" />
						</svg>
					</span>
					<!--end::Svg Icon-->
					<input type="text" data-kt-ecommerce-order-filter="search" class="form-control form-control-solid w-250px ps-14" placeholder="Search Report" />
				</div>
				<!--end::Search-->
				<!--begin::Export buttons-->
				<div id="kt_ecommerce_report_sales_export" class="d-none"></div>
				<!--end::Export buttons-->
			</div>
			<div class="card-toolbar flex-row-fluid justify-content-end align-items-center">
			
				<a href='<?php echo $data["link"]; ?>'  target='_blank' id="btn-submit" class="btn btn-primary btn-submit" style='margin-right:30px;' name='submit'>
					Download PDF
				</a>
	
			
					<!--begin::Daterangepicker
					<input class="form-control form-control-solid w-100 mw-250px" placeholder="Pick date range" id="kt_ecommerce_report_sales_daterangepicker" />-->
					<!--end::Daterangepicker-->
					<!--begin::Export dropdown-->
					<button type="button" class="btn btn-light-primary" data-kt-menu-trigger="click" data-kt-menu-placement="bottom-end">
					<!--begin::Svg Icon | path: icons/duotune/arrows/arr078.svg-->
					<span class="svg-icon svg-icon-2">
						<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
							<rect opacity="0.3" x="12.75" y="4.25" width="12" height="2" rx="1" transform="rotate(90 12.75 4.25)" fill="currentColor" />
							<path d="M12.0573 6.11875L13.5203 7.87435C13.9121 8.34457 14.6232 8.37683 15.056 7.94401C15.4457 7.5543 15.4641 6.92836 15.0979 6.51643L12.4974 3.59084C12.0996 3.14332 11.4004 3.14332 11.0026 3.59084L8.40206 6.51643C8.0359 6.92836 8.0543 7.5543 8.44401 7.94401C8.87683 8.37683 9.58785 8.34458 9.9797 7.87435L11.4427 6.11875C11.6026 5.92684 11.8974 5.92684 12.0573 6.11875Z" fill="currentColor" />
							<path opacity="0.3" d="M18.75 8.25H17.75C17.1977 8.25 16.75 8.69772 16.75 9.25C16.75 9.80228 17.1977 10.25 17.75 10.25C18.3023 10.25 18.75 10.6977 18.75 11.25V18.25C18.75 18.8023 18.3023 19.25 17.75 19.25H5.75C5.19772 19.25 4.75 18.8023 4.75 18.25V11.25C4.75 10.6977 5.19771 10.25 5.75 10.25C6.30229 10.25 6.75 9.80228 6.75 9.25C6.75 8.69772 6.30229 8.25 5.75 8.25H4.75C3.64543 8.25 2.75 9.14543 2.75 10.25V19.25C2.75 20.3546 3.64543 21.25 4.75 21.25H18.75C19.8546 21.25 20.75 20.3546 20.75 19.25V10.25C20.75 9.14543 19.8546 8.25 18.75 8.25Z" fill="currentColor" />
						</svg>
					</span>
					<!--end::Svg Icon-->Export Report</button>
					<!--begin::Menu-->
					<div id="kt_ecommerce_report_sales_export_menu" class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-600 menu-state-bg-light-primary fw-semibold fs-7 w-200px py-4" data-kt-menu="true">
						<!--begin::Menu item-->
						
						<div class="menu-item px-3">
							<a href="#" class="menu-link px-3" data-kt-ecommerce-export="excel">Export as Excel</a>
						</div>
						
						<!--end::Menu item-->
					</div>
					<!--end::Menu-->
					<!--end::Export dropdown-->
				</div>
		</div>
		<div class="card-body pt-0">
			<div id="kt_ecommerce_category_table_wrapper" class="dataTables_wrapper dt-bootstrap4 no-footer">									
				<div class="table-responsive">
					<table class="table align-middle table-row-dashed fs-6 gy-5" id="kt_ecommerce_report_sales_table">
						<thead>
							<tr class="text-start text-gray-400 fw-bold fs-7 text-uppercase gs-0">
								
								<th class="text-center w-10px pe-2" style='vertical-align:top;'>SNo</th>
								<th class='text-center' style='vertical-align:top;'>MATERIAL  PARTICULARS</th>
								<th></th>
								<th class='text-center'>OPENING</th>  
								<th></th>
								<th class='text-center'>PURCHASE</th>  
								<th></th> 
								<th class='text-center'>TOTAL</th>  
								<th></th>
								<th class='text-center'>CONSUMPTION</th>  
								<th></th>
								<th class='text-center'>CLOSING</th>  
							
								
							</tr>
							
						</thead>
						<tbody class="fw-semibold text-gray-600" id='tbody'>
							<tr class="text-start text-gray-400 fw-bold fs-7 text-uppercase gs-0">
								<td></th>
								<td></th>
								<td class='text-center'>QTY</td> 
								<td class='text-center'>TOTAL</td> 
								
								<td class='text-center'>QTY</td> 
								<td class='text-center'>TOTAL</td> 
								
								<td class='text-center'>QTY</td> 
								<td class='text-center'>TOTAL</td> 
								
								<td class='text-center'>QTY</td> 
								<td class='text-center'>TOTAL</td> 
								
								<td class='text-center'>QTY</td> 
								<td class='text-center'>TOTAL</td> 
							</tr>
							
							<?php
								$total = [0,0,0,0,0];
								$qty = [0,0,0,0,0];
								for($i=0;$i<count($data["rows"]);$i++):
								
									$row = $data["rows"][$i];	
									$ledger = $data["ledger"][$row["pid"]];	
									
							?>
							
							<tr>
								<td><?php echo $i+1; ?></td>
								<td><?php echo $row["pname"]; ?></td> 
								<td class='text-end'><?php echo $ledger["opn"]!=0?$ledger["opn"]:""; ?></td> 
								<td class='text-end'><?php echo $ledger["opn_val"]!=0?$ledger["opn_val"]:""; ?></td> 
								<?php 
									$qty[0]+=$ledger["opn"];
									$total[0]+=$ledger["opn_val"];
								?>
								
								<td class='text-end'><?php echo $ledger["pur"]!=0?$ledger["pur"]:""; ?></td> 
								<td class='text-end'><?php echo $ledger["pur_val"]!=0?$ledger["pur_val"]:""; ?></td> 
								<?php 
									$qty[1]+=$ledger["pur"];
									$total[1]+=$ledger["pur_val"];
								?>
								
								<td class='text-end'><?php echo $ledger["opn"]+$ledger["pur"]!=0?$ledger["opn"]+$ledger["pur"]:""; ?></td> 
								<td class='text-end'><?php echo $ledger["opn_val"]+$ledger["pur_val"]!=0?$ledger["opn_val"]+$ledger["pur_val"]:""; ?></td> 
								<?php 
									$qty[2]+=$ledger["pur"]+$ledger["opn"];
									$total[2]+=$ledger["opn_val"]+$ledger["pur_val"];								
								?>
								
								
								<td class='text-end'><?php echo $ledger["sal"]!=0?$ledger["sal"]:""; ?></td> 
								<td class='text-end'><?php echo $ledger["sal_val"]!=0?$ledger["sal_val"]:""; ?></td> 
								<?php 
									$qty[3]+=$ledger["sal"];
									$total[3]+=$ledger["sal_val"];								
								?>
								
								<td class='text-end'><?php echo $ledger["cls"]!=0?$ledger["cls"]:""; ?></td> 
								<td class='text-end'><?php echo $ledger["cls_val"]!=0?$ledger["cls_val"]:""; ?></td>  
								<?php 
									$qty[4]+=$ledger["cls"];
									$total[4]+=$ledger["cls_val"];						
								?>
							</tr>
							<?php endfor; ?>
						
							<tr>
								<td class='text-right'></td>
								<td class='text-right'>Total</td>
								<td class='text-end'></td>
								<td class='text-end'><?php echo format($total[0]); ?></td>
								  
								<td class='text-end'></td>
								<td class='text-end'><?php echo format($total[1]); ?></td>
								  
								<td class='text-end'></td>
								<td class='text-end'><?php echo format($total[2]); ?></td>
								 
								<td class='text-end'></td>
								<td class='text-end'><?php echo format($total[3]); ?></td>
								  
								<td class='text-end'></td>
								<td class='text-end'><?php echo format($total[4]); ?></td>
								
								
							</tr>
						</tbody>
					</table>											
				</div>
			</div>
		</div>   
	</div>
	<?php endif; ?>
</div>
</div>
<?php include "_footer_content.php"; ?>
</div>
</div>
</div>
</div>

		  

<?php include "_footer.php";?>
<script>
$(document).ready(function(){ 
$('#pid').select2();
$('#cid').select2();

var fileName = $("#title").val(); 
var KTAppEcommerceReportSales = function() {
    var t, e;
    return {
        init: function() {
            (t = document.querySelector("#kt_ecommerce_report_sales_table")) && (t.querySelectorAll("tbody tr").forEach((t => {
                const e = t.querySelectorAll("td"),
			
                    r = moment(e[0].innerHTML, "MMM DD, YYYY").format();
                e[0].setAttribute("data-order", r)
            })), e = $(t).DataTable({
                info: !1,
                order: [],
                pageLengtd: 10,
				paging: false
            }),(() => {
                const e = fileName;
                new $.fn.dataTable.Buttons(t, {
                    buttons: [{
                        extend: "excelHtml5", 
                        title: e
                    }]
                }).container().appendTo($("#kt_ecommerce_report_sales_export")), document.querySelectorAll("#kt_ecommerce_report_sales_export_menu [data-kt-ecommerce-export]").forEach((t => {
                    t.addEventListener("click", (t => {
                        t.preventDefault();
                        const e = t.target.getAttribute("data-kt-ecommerce-export");
                        document.querySelector(".dt-buttons .buttons-" + e).click()
                    }))
                }))
            })(), document.querySelector('[data-kt-ecommerce-order-filter="search"]').addEventListener("keyup", (function(t) {
                e.search(t.target.value).draw()
            })))
        }
    }
}();
KTUtil.onDOMContentLoaded((function() {
    KTAppEcommerceReportSales.init()
}));
	
});

</script>
</body>
</html>

MMCT - 2023