<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{
include 'dbc.php';
date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		 $my=$month_name . " " . $year;
$userid=$_SESSION["userid"];
$sqlsale = "SELECT * FROM invoice where date='$today' and user_id='$userid'";
$resultsale=$conn->query($sqlsale);
while($rowsale = $resultsale->fetch_assoc())
 
  {
 $tdaysalesale=$tdaysalesale + $rowsale['netamount'];
 
$trecordsale=$trecordsale + 1;
  }
  
  $sql2sale = "SELECT * FROM invoice where  month_name='$my' and user_id='$userid'";
$result2sale=$conn->query($sql2sale);
while($row2sale = $result2sale->fetch_assoc())
 
  {
  $tmsalesale=$tmsalesale + $row2sale['netamount'];
 
$trecord2sale=$trecord2sale + 1;
  }
  
  $sqlactivesale = "SELECT * FROM invoice_st where date='$today' and user_id='$userid'";
$resultactivesale=$conn->query($sqlactivesale);
while($rowactivesale = $resultactivesale->fetch_assoc())
 
  {
  $tdaypurchasesale=$tdaypurchasesale + $rowactivesale['tnetamount'];
 
$trecordpsale=$trecordpsale + 1;
  }
  
   $sqlinactivesale = "SELECT * FROM invoice_st where  month_name='$my' and user_id='$userid'";
$resultinactivesale=$conn->query($sqlinactivesale);
while($rowinactivesale = $resultinactivesale->fetch_assoc())
 
  {
 $tmpurchasesale=$tmpurchasesale + $rowinactivesale['tnetamount'];
 
$trecordpmsale=$trecordpmsale + 1;
  }
  
 
  
  
  $sqlrec = "SELECT * FROM cashrec where date='$today' and user_id='$userid'";
$resultrec=$conn->query($sqlrec);
while($rowrec = $resultrec->fetch_assoc())
 
  {
 $tdaysalerec=$tdaysalerec + $rowrec['netamount'];
 
$trecordrec=$trecordrec + 1;
  }
  
  $sql2rec = "SELECT * FROM cashrec where  month_name='$my' and user_id='$userid'";
$result2rec=$conn->query($sql2rec);
while($row2rec = $result2rec->fetch_assoc())
 
  {
  $tmsalerec=$tmsalerec + $row2rec['netamount'];
 
$trecord2rec=$trecord2rec + 1;
  }
  
  $sqlactiverec = "SELECT * FROM cashrec where date='$today' and user_id='$userid'";
$resultactiverec=$conn->query($sqlactiverec);
while($rowactiverec = $resultactiverec->fetch_assoc())
 
  {
  $tdaypurchaserec=$tdaypurchaserec + $rowactiverec['whamount'];
 
$trecordprec=$trecordprec + 1;
  }
  
   $sqlinactiverec = "SELECT * FROM cashrec where  month_name='$my' and user_id='$userid'";
$resultinactiverec=$conn->query($sqlinactiverec);
while($rowinactiverec = $resultinactiverec->fetch_assoc())
 
  {
 $tmpurchaserec=$tmpurchaserec + $rowinactiverec['whamount'];
 
$trecordpmrec=$trecordpmrec + 1;
  }




$sqlpur = "SELECT * FROM purchase where date='$today' and user_id='$userid'";
$resultpur=$conn->query($sqlpur);
while($rowpur = $resultpur->fetch_assoc())
 
  {
 $tdaysalepur=$tdaysalepur + $rowpur['netamount'];
 
$trecordpur=$trecordpur + 1;
  }
  
  $sql2pur = "SELECT * FROM purchase where  month_name='$my' and user_id='$userid'";
$result2pur=$conn->query($sql2pur);
while($row2pur = $result2pur->fetch_assoc())
 
  {
  $tmsalepur=$tmsalepur + $row2pur['netamount'];
 
$trecord2pur=$trecord2pur + 1;
  }
  
  $sqlactivepur = "SELECT * FROM purchase_return where date='$today' and user_id='$userid'";
$resultactivepur=$conn->query($sqlactivepur);
while($rowactivepur = $resultactivepur->fetch_assoc())
 
  {
  $tdaypurchasepur=$tdaypurchasepur + $rowactivepur['tnetamount'];
 
$trecordppur=$trecordppur + 1;
  }
  
   $sqlinactivepur = "SELECT * FROM purchase_return where  month_name='$my' and user_id='$userid'";
$resultinactivepur=$conn->query($sqlinactivepur);
while($rowinactivepur = $resultinactivepur->fetch_assoc())
 
  {
 $tmpurchasepur=$tmpurchasepur + $rowinactivepur['tnetamount'];
 
$trecordpmpur=$trecordpmpur + 1;
  }
  

  
  $sqlpay = "SELECT * FROM cashpaid where date='$today' and user_id='$userid'";
$resultpay=$conn->query($sqlpay);
while($rowpay = $resultpay->fetch_assoc())
 
  {
 $tdaysalepay=$tdaysalepay + $rowpay['netamount'];
 
$trecordpay=$trecordpay + 1;
  }
  
  $sql2pay = "SELECT * FROM cashpaid where  month_name='$my' and user_id='$userid'";
$result2pay=$conn->query($sql2pay);
while($row2pay = $result2pay->fetch_assoc())
 
  {
  $tmsalepay=$tmsalepay + $row2pay['netamount'];
 
$trecord2pay=$trecord2pay + 1;
  }
  
  $sqlactivepay = "SELECT * FROM cashpaid where date='$today' and user_id='$userid'";
$resultactivepay=$conn->query($sqlactivepay);
while($rowactivepay = $resultactivepay->fetch_assoc())
 
  {
  $tdaypurchasepay=$tdaypurchasepay + $rowactivepay['whamount'];
 
$trecordppay=$trecordppay + 1;
  }
  
   $sqlinactivepay = "SELECT * FROM cashpaid where  month_name='$my' and user_id='$userid'";
$resultinactivepay=$conn->query($sqlinactivepay);
while($rowinactivepay = $resultinactivepay->fetch_assoc())
 
  {
 $tmpurchasepay=$tmpurchasepay + $rowinactivepay['whamount'];
 
$trecordpmpay=$trecordpmpay + 1;
  }
  
$sqlacc = "SELECT * FROM expense_voucher where date='$today' and mtype='Expense' and user_id='$userid'";
$resultacc=$conn->query($sqlacc);
while($rowacc = $resultacc->fetch_assoc())
 
  {
 $tdaysaleacc=$tdaysaleacc + $rowacc['amount'];
 
$trecordacc=$trecordacc + 1;
  }
  
  $sql2acc = "SELECT * FROM expense_voucher where  month_name='$my' and mtype='Expense' and user_id='$userid'";
$result2acc=$conn->query($sql2acc);
while($row2acc = $result2acc->fetch_assoc())
 
  {
  $tmsaleacc=$tmsaleacc + $row2acc['amount'];
 
$trecord2acc=$trecord2acc + 1;
  }
  
  $sqlactiveacc = "SELECT * FROM invoice_details_st where date='$today' and user_id='$userid'";
$resultactiveacc=$conn->query($sqlactiveacc);
while($rowactiveacc = $resultactiveacc->fetch_assoc())
 
  {
  $tdaypurchaseacc=$tdaypurchaseacc + $rowactiveacc['diff'];
 
$trecordpacc=$trecordpacc + 1;
  }
  
   $sqlinactiveacc = "SELECT * FROM invoice_details_st where  user_id='$userid'";
$resultinactiveacc=$conn->query($sqlinactiveacc);
while($rowinactiveacc = $resultinactiveacc->fetch_assoc())
 
  {
 $tmpurchaseacc=$tmpurchaseacc + $rowinactiveacc['diff'];
 
$trecordpmacc=$trecordpmacc + 1;
  }
  

  
  
?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

    <?php include("includes/menu.php") ?><!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">

             <?php include("includes/headermenu1.php") ?>

        </header><!-- /header -->
        <!-- Header-->

        <div class="breadcrumbs">
            <div class="col-sm-6">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><? echo "" . $_SESSION["userid"]; ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li class="active"><? echo "" . $_SESSION["username"]; ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="content mt-3">
<p><h2>Sale Section</h2></p>
            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecordsale; ?></span>
							/
							<span class="count"><?php echo $tdaysalesale; ?></span>
                        </h4>
                        <p class="text-light">Today: Invoices</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2sale; ?></span>
							/
                            <span class="count"><?php echo $tmsalesale; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Invoices </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpsale; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchasesale; ?></span>
							
                        </h4>
                        <p class="text-light">Today Sale Tax Invoices </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpmsale; ?></span>
							/
                            <span class="count"><?php echo $tmpurchasesale; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Sale Tax Invoice</p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
           
            
             



            
            <!--/.col-->
			<p><h2>Receipt Section</h2></p>
<div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecordrec; ?></span>
							/
							<span class="count"><?php echo $tdaysalerec; ?></span>
                        </h4>
                        <p class="text-light">Today: Receipt</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2rec; ?></span>
							/
                            <span class="count"><?php echo $tmsalerec; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Receipt </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordprec; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchaserec; ?></span>
							
                        </h4>
                        <p class="text-light">Today Holding Tax </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpmrec; ?></span>
							/
                            <span class="count"><?php echo $tmpurchaserec; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>: Holding Tax </p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
 
            
            <!--/.col-->
			<p><h2>Purchase Section</h2></p>
 <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecordpur; ?></span>
							/
							<span class="count"><?php echo $tdaysalepur; ?></span>
                        </h4>
                        <p class="text-light">Today: Purchase</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2pur; ?></span>
							/
                            <span class="count"><?php echo $tmsalepur; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Purchase </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordppur; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchasepur; ?></span>
							
                        </h4>
                        <p class="text-light">Today Purchase Return </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpmpur; ?></span>
							/
                            <span class="count"><?php echo $tmpurchasepur; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Purchase Return </p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
           
        
            
            <!--/.col-->
<p><h2>Payment Section</h2></p>
            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecord; ?></span>
							/
							<span class="count"><?php echo $tdaysale; ?></span>
                        </h4>
                        <p class="text-light">Today: Payment Amount</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2pay; ?></span>
							/
                            <span class="count"><?php echo $tmsalepay; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Payment Amount </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordppay; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchasepay; ?></span>
							
                        </h4>
                        <p class="text-light">Today With Holding Tax </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpmpay; ?></span>
							/
                            <span class="count"><?php echo $tmpurchasepay; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:With Holding Tax </p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
           
           
		   
		    <!--/.col-->
<p><h2>Expense and Income Section</h2></p>
            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-1">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
                            <span class="count"><?php echo $trecordacc; ?></span>
							/
							<span class="count"><?php echo $tdaysaleacc; ?></span>
                        </h4>
                        <p class="text-light">Today: Expense Amount</p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart1"></canvas>
                        </div>

                    </div>

                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-2">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						 <span class="count"><?php echo $trecord2acc; ?></span>
							/
                            <span class="count"><?php echo $tmsaleacc; ?></span>
                        </h4>
                        <p class="text-light"> <?php echo $month_name; ?>:Expense Amount </p>

                        <div class="chart-wrapper px-0" style="height:70px;" height="70">
                            <canvas id="widgetChart2"></canvas>
                        </div>

                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-3">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpacc; ?></span>
							/
                            <span class="count"><?php echo $tdaypurchaseacc; ?></span>
							
                        </h4>
                        <p class="text-light">Today Income </p>

                    </div>

                    <div class="chart-wrapper px-0" style="height:70px;" height="70">
                        <canvas id="widgetChart3"></canvas>
                    </div>
                </div>
            </div>
            <!--/.col-->

            <div class="col-sm-6 col-lg-3">
                <div class="card text-white bg-flat-color-4">
                    <div class="card-body pb-0">
                        <div class="dropdown float-right">
                            
                            
                        </div>
                        <h4 class="mb-0">
						<span class="count"><?php echo $trecordpmacc; ?></span>
							/
                            <span class="count"><?php echo $tmpurchaseacc; ?></span>
                        </h4>
                        <p class="text-light"> Total Income </p>

                        <div class="chart-wrapper px-3" style="height:70px;" height="70">
                            <canvas id="widgetChart4"></canvas>
                        </div>

                    </div>
                </div>
            </div>
             

            


          
					
					
					
					
					

          

           
			
			
			
					
					
					
					
					
					


					
					
					
					
					
					
					
					
					
					
					
					
					
					
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>