<?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"];
$sql = "SELECT * FROM invoice where date='$today' and user_id='$userid'";
$result=$conn->query($sql);
while($row = $result->fetch_assoc())
 
  {
 $tdaysale=$tdaysale + $row['gamount'];
 
$trecord=$trecord + 1;
  }
  
  $sql2 = "SELECT * FROM invoice where  month_name='$my' and user_id='$userid'";
$result2=$conn->query($sql2);
while($row2 = $result2->fetch_assoc())
 
  {
  $tmsale=$tmsale + $row2['gamount'];
 
$trecord2=$trecord2 + 1;
  }
  
  $sqlactive = "SELECT * FROM purchase where date='$today' and user_id='$userid'";
$resultactive=$conn->query($sqlactive);
while($rowactive = $resultactive->fetch_assoc())
 
  {
  $tdaypurchase=$tdaypurchase + $rowactive['netamount'];
 
$trecordp=$trecordp + 1;
  }
  
   $sqlinactive = "SELECT * FROM purchase where  month_name='$my' and user_id='$userid'";
$resultinactive=$conn->query($sqlinactive);
while($rowinactive = $resultinactive->fetch_assoc())
 
  {
 $tmpurchase=$tmpurchase + $rowinactive['netamount'];
 
$trecordpm=$trecordpm + 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 -->


    <!-- Left Panel -->

    <!-- Right Panel -->

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

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

             <?php include("includes/emp_menu.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">

           


            
            <!--/.col-->

            
            <!--/.col-->

            
            <!--/.col-->

            
           
		   
		    <!--/.col-->

            
             

            


          
					
					
					
					
					

          

           
			
			
			<div class="col-md-14">
                        <div class="card">
						<div class="page-title">
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Salary Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php

include 'dbc.php';


$userid=$_SESSION["userid"];
$month_name=$_REQUEST["month"];
$sess1=$_REQUEST["sess1"];
$sql = "SELECT * FROM paidsalary where month_name='$my' and user_id='$userid' ORDER BY class_name";
$result=$conn->query($sql);
?>
									 <strong class="card-title"><center><? echo $month_name; ?></center> </strong>
                                   <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                    <thead>
									<?php
                                   
echo "<tr>";
echo "<th > Date</th>";
echo "<th > Teacher Name </th>";
echo "<th > Father Name </th>";
echo "<th > Desg </th>";
echo "<th > Basic Salary</th>";
echo "<th > T.Days</th>";
echo "<th > Absent</th>";
echo "<th > Total Ded</th>";
echo "<th > Gross Salary</th>";
echo "<th > Total Allownces</th>";
echo "<th > Net Salary</th>";

echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
                                       while($row = $result->fetch_assoc())
 
  {
  $id = $row['id'];	
   echo "<tr>";
   echo "<td>" .$row['date'] . "</td>";
echo "<td>" .$row['tech_name'] . "</td>";
  echo "<td>" .$row['father_name'] .  "</td>";
 echo "<td>" .$row['class_name'] .  "</td>";
  echo "<td>" .$row['monthly_salary'] .  "</td>";
 echo "<td>" .$row['tdays'] .  "</td>";
  echo "<td>" .$row['adays'] .  "</td>";
 echo "<td>" .round($row['totalded'],0) .  "</td>";
  echo "<td>" .round($row['gsalary'],0) .  "</td>";
 echo "<td>" .round($row['totalallow'],0) .  "</td>";
  echo "<td>" .round($row['netsalary'],0) .  "</td>";
		  
		  
$trecord=$trecord + 1;
$tmonthlysalary=$tmonthlysalary + round($row['monthly_salary'],0);
$ttotalded=$ttotalded + round($row['totalded'],0);
$tgsalary=$tgsalary + round($row['gsalary'],0);
$ttotalallow=$ttotalallow + round($row['totalallow'],0);
$tnetsalary=$tnetsalary + round($row['netsalary'],0);
  }
   echo "<tr>";
	echo "<td colspan=4 align=right><b>" ."Total Records::". $trecord ."</b></td>";
	echo "<td><b>" .$tmonthlysalary . "</b></td>";
	echo "<td><b>" .":" . "</b></td>";
	echo "<td><b>" .":" . "</b></td>";
	  	echo "<td><b>" .$ttotalded . "</b></td>";
		echo "<td><b>" .$tgsalary . "</b></td>";
		echo "<td><b>" .$ttotalallow . "</b></td>";
		echo "<td><b>" .$tnetsalary . "</b></td>";
	  echo "</tr>";
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
					
					
					
					
					
					
					
					
					
					
					
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

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

</body>

</html>
<?php
}
?>