<!DOCTYPE html>
<?php
require('../config/dbcon.php');
    $query = "SELECT timeout from timeout_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$timeout = $row['timeout'];
    }
    
    $query = "select screenwidth from width_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$width = $row['screenwidth'];
    }
    //$width = '2000';
session_start();
if(isset($_SESSION["user"]))
{
 if((time() - $_SESSION['last_time']) > $timeout) // Time in Seconds
 {
 header("location:../login/logout.php");
 }
 else
 {
 $_SESSION['last_time'] = time();
 //echo "<h1 align='center'>Welcome ".$_SESSION["user"]. "</h1>";
 //echo "<h3 align='center'>Automatic Logout after 1 minute of inactive</h3>";
 //echo "<p align='center'><a href='../login/logout.php'>Logout</a></p>";
 //echo "<p align='center'><a href='../main/welcome.php'>Welcome1</a></p>";
 }
}
else
{
 header('Location:../login/index.php');
}
$first_day = date('01-m-Y');
$last_day = date('t-m-Y');
?>
</body>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Main Menu</title>
<script type="text/javascript">
	function preventBack() {
		window.history.forward();
	}
	setTimeout("preventBack()", 0);
	window.onunload = function() {
		null
	};
</script>
<link rel="stylesheet" href="../css/style2.css">
<script src="../js/script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="../css/font-awesome.min.css">
<link rel="stylesheet" href="../css/jquery-ui.css">
<link rel="stylesheet" href="../css/bootstrap-theme.min.css">
<script src="../js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:100,200,400,500,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="stylepanel.css">
<link rel="stylesheet" href="cardstyles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body style="width: <?php echo $width; ?>;">
    <div style="width: <?php echo $width; ?>; align="center">
    <div style="width: <?php echo $width; ?>;">
    <nav style="width: <?php echo $width; ?>;">
        <div class="navbar" style="width: <?php echo $width; ?>; margin-left: 0px; margin-top: -0px;">
            <i class='bx bx-menu'></i>
            <div class="nav-links" style="width: <?php echo $width; ?>;">        
                <ul class="links">
                    <li><a style="color:white; font-size:28px;" href="index">Home</a></li>
                    <li>
                        <a style="color:white; font-size:28px;" href="#">Master</a>
                        <i class='bx bxs-chevron-down htmlcss-arrow arrow  '></i>
                        <ul class="htmlCss-sub-menu sub-menu">
                            <li><a style="color:white; font-size:28px;" href="../customer/index">Customer Master [Dr.]</a></li>
                            <li><a style="color:white; font-size:28px;" href="../supplier/index">Supplier Master [Cr.]</a></li>
                            <li><a style="color:white; font-size:28px;" href="../account/index">Account Master [Dr. and Cr]</a></li>
                            <li><a style="color:white; font-size:28px;" href="../segment/index">Segment Master</a></li>
                            <li><a style="color:white; font-size:28px;" href="../product/index">Product Master</a></li>
                            <li><a style="color:white; font-size:28px;" href="../custdiscount/index">Customer Discount Master</a></li>
                            <li><a style="color:white; font-size:28px;" href="../suppdiscount/index">Supplier Discount Master</a></li>
                            <li><a style="color:white; font-size:28px;" href="../noofrows/index">Edit Number of Rows to Show</a></li>
                            <li><a style="color:white; font-size:28px;" href="../timeout/index">Edit Time Out</a></li>
                            <li><a style="color:white; font-size:28px;" href="../width/index">Edit Page Width</a></li>
                        </ul>
                    </li>
                    <li>
                        <a style="color:white; font-size:28px;" href="#">Transaction</a>
                        <i class='bx bxs-chevron-down js-arrow arrow '></i>
                        <ul class="js-sub-menu sub-menu">
                        <li class="more">
                        <span><a style="color:white; font-size:28px;" href="#">Purchase</a>
                        <i class='bx bxs-chevron-right arrow more-arrow'></i>
                        </span>
                        <ul class="more-sub-menu sub-menu">
                            <li><a style="color:white; font-size:28px;" href="../pruchase/index">Purchase Invoice [ F3 ]</a></li>
                            <li><a style="color:white; font-size:28px;" href="../pgstdebitnote/index">Purchase Debit Note GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../pruchase/index">Purchase Debit Note W/O GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../pruchase/index">Purchase Credit Note GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../pruchase/index">Purchase Credit Note W/O GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../paymentsb/index">Pyements ( Bank )</a></li>
                            <li><a style="color:white; font-size:28px;" href="../paymentsc/index">Pyements ( Cash )</a></li>
                        
                        </ul>
                    </li>
            		  
                    <li class="more">
                        <span><a style="color:white; font-size:28px;" href="#">Sales</a>
                        <i class='bx bxs-chevron-right arrow more-arrow'></i>
                        </span>
                        <ul class="more-sub-menu sub-menu">
                            <li><a style="color:white; font-size:28px;" href="../invoice/index">Sales Invoice [ F2 ]</a></li>
                            <li><a style="color:white; font-size:28px;" href="../cgstdebitnote/index">Customer Debit Note GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../invoice/index">Customer Debit Note W/O GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../invoice/index">Customer Credit Note GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../invoice/index">Customer Credit Note W/O GST</a></li>
                            <li><a style="color:white; font-size:28px;" href="../receiptsb/index">Receipts ( Bank )</a></li>
                            <li><a style="color:white; font-size:28px;" href="../receiptsc/index">Receipts ( Cash )</a></li>
                        </ul>
                    </li>
                        <li><a style="color:white; font-size:28px;" href="../order/index">Order</a></li>
                        <li><a style="color:white; font-size:28px;" href="../invoice/phpinfo">PHP Information</a></li>
                    </ul>
                    </li>
            	    <li>
                        <a style="color:white; font-size:28px;" href="#">Report</a>
                        <i class='bx bxs-chevron-down js-arrow arrow '></i>
                        <ul class="js-sub-menu sub-menu">
                            <li><a style="color:white; font-size:28px;" href="../gstr-1/index">GSTR-1</a></li>
                            <li><a style="color:white; font-size:28px;" href="../gstr-3b/index">GSTR-3B</a></li>
                            <li><a style="color:white; font-size:28px;" href="../salesreport/index">Sales Reports</a></li>
                            <li><a style="color:white; font-size:28px;" href="../purchasereport/index">Purchase Reports</a></li>
                            <li><a style="color:white; font-size:28px;" href="../stock/index">Stock Reports</a></li>
                            <li><a style="color:white; font-size:28px;" href="../ledgerc/index">Customer Ledger</a></li>
                            <li><a style="color:white; font-size:28px;" href="../ledgerp/index">Supplier Ledger</a></li>
                            <li><a style="color:white; font-size:28px;" href="../utility/index">Utility</a></li>
                            <li><a style="color:white; font-size:28px;" href="../import/index">Import Masters</a></li>
                        </ul>
                    </li>
                    <a style="font-size:20px; font-size:28px; color: white; margin-left : 20px; width: 600px;" align="center"></i>Venkat Sales Corporation, Surat 9377811610</a>
                    <h1 style="color:white; font-size:28px;margin-left : 30px; margin-top : 15px; width: 500px;" id="demo2" align="right"></h1>
                    <li><a style="color:white; font-size:28px;margin-left : 20px;" href="../login/logout">Logout</a></li>
                </ul>
            </div>      
        </div>
    </nav>
    </div>
    </div>
    <br><br><br><br><br><br><br><br><br><br><br><br>
    <div style="color:white;" id="layoutSidenav_content">
        <main>
            <div style="color:white;" class="container-fluid px-4">                        
                <div style="margin-top:10px;" class="row">
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-primary text-white mb-4">
                        <!--i style="align-center" class="fa fa-shopping-cart" aria-hidden="true"></i><br-->
                            <?php $sql="select sum(total_sales_val),sum(total_inv_val) from invtotal_mst";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            if($row[1] == ''){
                                $val1 = '0.00';
                            }else{
                                $val1 = $row[1];
                            };
                            ?> 
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Sales</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?> / <?php echo $val1;?></div>
                            </center>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../salesreport/index">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                            </center>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-warning text-white mb-4">
                            <?php $sql="select sum(total_sales_val),sum(total_inv_val) from pinvtotal_mst";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            if($row[1] == ''){
                                $val1 = '0.00';
                            }else{
                                $val1 = $row[1];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Purchase</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?> / <?php echo $val1;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../purchasereport/index">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-success text-white mb-4">
                            <?php
                    		$sql="select sum(clbalance) from customer_mst where acc_type= 'CAS'";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Cash On Hand</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="#">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-danger text-white mb-4">
                            <?php $sql="select sum(stk_val) from item_mst";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Stock Value</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../stock/index">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-primary text-white mb-4">
                            <?php $sql="select sum(clbalance) from customer_mst where acc_type= 'SDE'";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Receivable</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../receiptsb/index">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-warning text-white mb-4">
                            <?php $sql="select sum(clbalance) from supplier_mst where acc_type= 'SCR'";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Payable</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../paymentsb/index">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-success text-white mb-4">
                            <?php
                    		$sql="select sum(clbalance) from customer_mst";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?>
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Bank Balance</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="#">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                    <div style="color:white;" class="col-xl-3 col-md-6">
                        <div style="color:white;" class="card bg-danger text-white mb-4">
                        <!--i style="align-center" class="fa fa-shopping-cart" aria-hidden="true"></i><br-->
                            <?php $sql="select sum(part_value) from order_mst";
                            $res = $connect->query($sql);
                            $row=mysqli_fetch_array($res);
                            if($row[0] == ''){
                                $val = '0.00';
                            }else{
                                $val = $row[0];
                            };
                            ?> 
                            <center>
                            <div style="color:white; font-size:28px;" class="card-body">Order Value</div>
                            <div style="color:white; font-size:28px;" class="card-body"><?php echo $val;?></div>
                            </center>
                            <div style="color:white; font-size:28px;" class="card-footer d-flex align-items-center justify-content-between">
                                <a style="color:white; font-size:28px;" class="small text-white stretched-link" href="../order/showorder">View Details</a>
                                <div style="color:white; font-size:28px;" class="small text-white"><i class="fa fa-angle-right"></i></div>
                            </div>
                        </div>
                    </div>
                </div>    
            </div>
        </main>                
    </div>
    <!--div style="color:white; font-size:28px;" class="main-part">
    	<div class="cpanel cpanel-royalblue">
    		<div class="icon-part">
    		<i class="fa fa-shopping-cart" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Sales</small>
        		<?php $sql="select sum(total_sales_val),sum(total_inv_val) from invtotal_mst";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                if($row[1] == ''){
                    $val1 = '0.00';
                }else{
                    $val1 = $row[1];
                };
                ?> 
    		    <p style="color:white; font-size:28px;"><?php echo $val;?> / <?php echo $val1;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="../salesreport/index">More Details </a>
    		</div>
    	</div>
    	<div class="cpanel cpanel-MediumSlateBlue">
    		<div class="icon-part">
    		<i class="fa fa-shopping-cart" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Purchase</small>
        		<?php $sql="select sum(total_sales_val),sum(total_inv_val) from pinvtotal_mst";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                if($row[1] == ''){
                    $val1 = '0.00';
                }else{
                    $val1 = $row[1];
                };
                ?>
    		    <p style="color:white; font-size:28px;"><?php echo $val;?> / <?php echo $val1;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="../purchasereport/index">More Details </a>
    		</div>
    	</div>
    	<div class="cpanel cpanel-royalblue">
    		<div class="icon-part">
    		<i class="fa fa-inr" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Cash on Hand</small>
        		<?php
        		$sql="select sum(clbalance) from customer_mst where acc_type= 'CAS'";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                ?>
    		    <p style="color:white; font-size:28px;"><?php echo $val;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="#">More Details </a>
    		</div>
    	</div>
    	<div class="cpanel cpanel-MediumSlateBlue">
    		<div class="icon-part">
    		<i class="fa fa-money" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Receivable</small>
        		<?php $sql="select sum(clbalance) from customer_mst where acc_type= 'SDE'";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                ?>
    		    <p style="color:white; font-size:28px;"><?php echo $val;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="../receiptsb/index">More Details </a>
    		</div>
    	</div>
    	<div class="cpanel cpanel-royalblue">
    		<div class="icon-part">
    		<i class="fa fa-money" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Payable</small>
        		<?php $sql="select sum(clbalance) from supplier_mst where acc_type= 'SCR'";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                ?>
    		    <p style="color:white; font-size:28px;"><?php echo $val;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="../paymentsb/index">More Details </a>
    		</div>
    	</div>
    	<div class="cpanel cpanel-MediumSlateBlue">
    		<div class="icon-part">
    		<i class="fa fa-bank" aria-hidden="true"></i><br>
    		<small style="color:white; font-size:28px;">Bank Balance</small>
        		<?php
        		$sql="select sum(clbalance) from customer_mst";
                $res = $connect->query($sql);
                $row=mysqli_fetch_array($res);
                if($row[0] == ''){
                    $val = '0.00';
                }else{
                    $val = $row[0];
                };
                ?>
    		    <p style="color:white; font-size:28px;"><?php echo $val;?></p>
    		</div>
    		<div class="card-content-part">
    		    <a href="#">More Details </a>
    		</div>
    	</div>
    </div-->
</body>
</html>

<?php
	$date = new DateTime();
	$current_timestamp = $date->getTimestamp();
?>
<script>

    document.onkeydown = function(){
        if(window.event && window.event.keyCode == 113) 
        {
           window.location.href = "../invoice/index"
        }
        if(window.event && window.event.keyCode == 114) 
        {
           window.location.href = "../pruchase/index"
        }
        if(window.event && window.event.keyCode == 115) 
        {
           window.location.href = "../customer/index"
        }
        if(window.event && window.event.keyCode == 117) 
        {
           window.location.href = "../supplier/index"
        }
        if(window.event && window.event.keyCode == 118) 
        {
           window.location.href = "../product/index"
        }
        if(window.event && window.event.keyCode == 119) 
        {
           window.location.href = "../order/index"
        }
    }
	flag_time = true;
	timer = '';
	setInterval(function(){phpJavascriptClock();},1000);
	
	function phpJavascriptClock()
	{
		if ( flag_time ) {
		timer = <?php echo $current_timestamp;?>*1000;
		}
		var d = new Date(timer);
		months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');		
		month_array = new Array('January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'Augest', 'September', 'October', 'November', 'December');		
		day_array = new Array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');		
		currentYear = d.getFullYear();
		month = d.getMonth();
		var currentMonth = months[month];
		var currentMonth1 = month_array[month];
		var currentDate = d.getDate();
		currentDate = currentDate < 10 ? '0'+currentDate : currentDate;
		
		var day = d.getDay();
		current_day = day_array[day];
		var hours = d.getHours();
		var minutes = d.getMinutes();
		var seconds = d.getSeconds();
		
		var ampm = hours >= 12 ? 'PM' : 'AM';
		hours = hours % 12;
		hours = hours ? hours : 12; // the hour ’0′ should be ’12′
		minutes = minutes < 10 ? '0'+minutes : minutes;
		seconds = seconds < 10 ? '0'+seconds : seconds;
		var strTime = hours + ':' + minutes+ ':' + seconds + ' ' + ampm;
		timer = timer + 1000;
		document.getElementById("demo2").innerHTML='Date : ' + currentDate+'-' +(month+1)+'-' +currentYear + ' Time : ' + strTime ;
		flag_time = false;
	}
</script>
</body>
</html>
