<?php include 'inc_classes.php';
include "admin_authentication.php";
?> 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Finance Summary</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <!-- Morris chart -->
  <link rel="stylesheet" href="bower_components/morris.js/morris.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="bower_components/jvectormap/jquery-jvectormap.css">
  <!-- Date Picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <?php include "include/header-main.php"; ?>
  <!-- Left side column. contains the logo and sidebar -->
  <?php include "include/menu_left.php"; ?>
  <!-- Content Wrapper. Contains page content -->
    <!-- Left side column. contains the logo and sidebar -->
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Finance Summary
        <!--<small>Version 2.0</small>-->
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Dashboard</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      
      <div class="row">
        <div class="col-md-12" style="display:none">
          <div class="box">
            <!--<div class="box-header with-border">
              <h3 class="box-title">Monthly Recap Report</h3>

              <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                </button>
                <div class="btn-group">
                  <button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown">
                    <i class="fa fa-wrench"></i></button>
                  <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                  </ul>
                </div>
                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
              </div>
            </div>-->
            <!-- /.box-header -->
            <div class="box-body">
              <div class="row" >
                <div class="col-md-8">
                  <p class="text-center">
                    <strong>Sales: 1 Jan, 2014 - 30 Jul, 2014</strong>
                  </p>

                  <div class="chart">
                    <!-- Sales Chart Canvas -->
                    <canvas id="salesChart" style="height: 180px;"></canvas>
                  </div>
                  <!-- /.chart-responsive -->
                </div>
                <!-- /.col -->
                
                <!-- /.col -->
              </div>
              <!-- /.row -->
            </div>
      
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- Main row -->
      <div class="row">
     	<!--<div class="col-md-3">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Todays</h3>
            </div>
            <div class="box-body">
              <ul class="products-list product-list-in-box">
                <li class="item">
                	<button type="button" class="btn btn-block btn-success btn-lg">Check In</button>
                </li>
                <li class="item">
                	<a href="javascript:void(0)" class="uppercase">Check-In </a>
                    <span class="pull-right text-green"><i class="fa fa-angle-left"></i> 10.30 AM</span></a></li>
                </li>
                <li class="item">
                	<a href="javascript:void(0)" class="uppercase">Check-Out</a>
                    <span class="pull-right text-green"><i class="fa fa-angle-left"></i> 7.30 PM</span></a></li>
                </li>
                <li class="item">
                	<a href="javascript:void(0)" class="uppercase">Total Hours</a>
                    <span class="pull-right text-green"><i class="fa fa-angle-left"></i> 9 Hrs.</span></a></li>
                </li>
              </ul>
            </div>
          </div>
        </div>-->
        <!--===Start col for info box 2======-->
        <div class="col-md-6">
          <div class="box box-primary">
            <div class="box-header with-border">
            	<?php
				$curr_date= date('Y-m-d');
				$salary_date= date('Y-m').'-11';
				
                $prv_month=Date('M', strtotime('-2 months',strtotime($curr_date)));
				$prv_month_n=Date('m', strtotime('-2 months',strtotime($curr_date)));
				$prv_year_n=Date('Y', strtotime('-2 months',strtotime($curr_date)));
				
				$currentMonth =date('Y').'-'.date('m').date('d');
				echo '<br/>'.$prv_month=Date('F', strtotime('-1 month',strtotime($currentMonth)));
				echo '<br/>'.$prv_month1=Date('m', strtotime('-1 month',strtotime($currentMonth)));

				
				$cur_month_t=Date('M', strtotime('-1 months',strtotime($curr_date)));
				$cur_month=Date('m', strtotime('-1 months',strtotime($curr_date)));
				$curr_year=Date('Y', strtotime('-1 months',strtotime($curr_date)));
				if($curr_date < $salary_date)
				{
					$curr_month_t = $prv_month;
					$curr_year = $prv_year_n;
					$curr_month = $prv_month_n;
				}
				else
				{
					$curr_month_t = $cur_month_t;//Date('M',strtotime('-1 month',strtotime($curr_date)));
					$curr_year=$curr_year;//Date('Y', strtotime($curr_date));
					$curr_month = $cur_month;//Date('m', strtotime($curr_date));
				}
				?>
              <h3 class="box-title"><i class="fa fa-th"></i>  Salary Summary <?php echo $curr_month_t.'  '.$curr_year; ?></h3>
              <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="glyphicon glyphicon-triangle-left"></i>
                </button>
                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="glyphicon glyphicon-triangle-right"></i></button>
              </div>
            </div>
            <?php
			$sel_leave="select * from pr_leave_management where 1 and cm_id='".$_SESSION['cm_id']."' and month='".$curr_month."' and year='".$curr_year."'";
			$ptr_leave=mysql_query($sel_leave);
			$data_leave=mysql_fetch_array($ptr_leave);
			
			$select_exc = "select * from pr_staff_salary_management where 1 and cm_id='".$_SESSION['cm_id']."' AND month='".$curr_month."' AND year='".$curr_year."' AND employee_id='".$_SESSION['admin_id']."'";
			$payment1 = mysql_query($select_exc);
			$data_pay = mysql_fetch_array($payment1);
			$pay_type='';
			if($data_pay['payment_mode']==1)
			{
				$pay_type='Cash';
			}
			else if($data_pay['payment_mode']==2)
			{
				$pay_type='Chaque';
			}
			else if($data_pay['payment_mode']==5)
			{
				$pay_type='Bank Transfer';
			}
			$lop = $data_pay['working_days'] - $data_pay['final_paid_days'];
            ?>
            <!-- /.box-header -->
            <div class="box-body">
            	<div class="col-md-6">
                  <ul class="products-list product-list-in-box">
                    <li class="item">
                    </li>
                    <li class="item">
                        <span class="uppercase"><strong>Working Day</strong></span>
                        <span class="pull-right text-green"> <?php echo $data_leave['no_of_working_days']; ?> Day</span></a></li>
                    </li>
                    <!-- /.item -->
                    <li class="item"><strong>Payment Mode</strong></strong></span>
                        <span class="pull-right text-green"><?php echo $pay_type; ?></span></a></li>
                    </li>
                  </ul>
                </div>
                <div class="col-md-6">
                  <ul class="products-list product-list-in-box">
                    <li class="item">
                    </li>
                    <li class="item">
                        <span class="uppercase"><strong>Loss of Pay</strong></span>
                        <span class="pull-right text-green"><?php echo $lop; ?> Day.</span></a></li>
                    </li>
                    <!-- /.item -->
                    <li class="item">
                        <span class="uppercase"><strong>View Pay Slip</strong></span>
                        <span class="pull-right text-green"><a target="_blank" href="invoice.php?emp_id=<?php echo $data_pay['employee_id']; ?>&m=<?php echo $curr_month; ?>&y=<?php echo $curr_year;?>&cm_id=<?php echo $data_pay['cm_id'];?>"><button type="button" class="btn btn-block btn-success btn-xs">View</button></a></span></li>
                    </li>
                  </ul>
                </div>
            </div>
            <!-- /.box-body -->
            <!--<div class="box-footer text-center">
              <a href="javascript:void(0)" class="uppercase">Past Leaves</a>
            </div>-->
                <!-- /.box-footer -->
            </div>
        </div>
        <!--==========End col info box=======-->
        <div class="col-md-6">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title"><i class="fa fa-th"></i>  Loans & Deduction</h3>
              <!--<div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="glyphicon glyphicon-triangle-left"></i>
                </button>
                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="glyphicon glyphicon-triangle-right"></i></button>
              </div>-->
            </div>
            <!-- /.box-header -->
            <div class="box-body">
            	<div class="col-md-6">
                  <ul class="products-list product-list-in-box">
                    <li class="item">
                    </li>
                    <li class="item">
                        <span class="uppercase"><strong>Total Outstanding</strong></span>
                        <span class="pull-right text-green"> 20000</span></a></li>
                    </li>
                    <!-- /.item -->
                    <li class="item"><strong>EMI for Month</strong></strong></span>
                        <span class="pull-right text-green"> 10000</span></a></li>
                    </li>
                  </ul>
                </div>
                <div class="col-md-6">
                  <ul class="products-list product-list-in-box">
                    <li class="item">
                    </li>
                    <li class="item">
                        <span class="uppercase"><strong>Remaining Term</strong></span>
                        <span class="pull-right text-green"> 2</span></a></li>
                    </li>
                    <!-- /.item -->
                    <li class="item">
                        <span class="uppercase"><strong>EMI Date</strong></span>
                        <span class="pull-right text-green"> 12 Dec 21</span></a></li>
                    </li>
                  </ul>
                </div>
            </div>
            <!-- /.box-body -->
            <!--<div class="box-footer text-center">
              <a href="javascript:void(0)" class="uppercase">Past Leaves</a>
            </div>-->
                <!-- /.box-footer -->
            </div>
        </div>
        <!--==========End col info box=======-->
        
      </div>
      <div class="row">
        <!-- Left col -->
        <div class="col-md-12">
          <!-- TABLE: LATEST ORDERS -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title">Summary</h3>

              <!--<div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                </button>
                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
              </div>-->
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <div class="table-responsive">
                <table class="table no-margin">
                  <thead>
                  <tr>
                    <th>Sr. No.</th>
                    <th>Month</th>
                    <th>CTC/Month</th>
                    <th>Deductions</th>
                    <th>Payble Amount</th>
                    <th>Payment Date</th>
                    <th>Pay Slip</th>
                  </tr>
                  </thead>
                  <tbody>
                  <?php
				  $select_exc = "select * from pr_staff_salary_management where 1 and cm_id='".$_SESSION['cm_id']."' and employee_id='".$_SESSION['admin_id']."' and year > '2020' order by staff_salary_id desc";
				  $payment1 = mysql_query($select_exc);
				  $s=1;
				  while($data_salarys= mysql_fetch_array($payment1))
				  {
					  $monthNum=$data_salarys['month'];
					  $monthName = date('F', mktime(0, 0, 0, $monthNum, 10)); // March
					  
					?>
					<tr>
						<td><?php echo $s; ?></td>
						<td><?php echo $monthName.' '.$data_salarys['year']; ?></td>
						<td><?php echo $data_salarys['salary']; ?></td>
						<td><?php echo $data_salarys['salary']- $data_salarys['salary_to_be_paid']; ?></td>
						<td><?php echo $data_salarys['salary_to_be_paid']; ?></td>
						<td><?php echo date('d M Y',strtotime($data_salarys['added_date'])); ?></td>
						<td><a target="_blank" href="invoice.php?emp_id=<?php echo $data_salarys['employee_id']; ?>&m=<?php echo $data_salarys['month']; ?>&y=<?php echo $data_salarys['year'];?>&cm_id=<?php echo $data_salarys['cm_id'];?>"><button type="button" class="btn btn-block btn-warning btn-sm">View</button></a></td>
						<!--<td>
						  <div class="sparkbar" data-color="#00a65a" data-height="20">90,80,90,-70,61,-83,63</div>
						</td>-->
					</tr>
					<?php  
					$s++;
				  }
				  ?>
                  
                  <!--<tr>
                    <td><a href="pages/examples/invoice.html">2</a></td>
                    <td>Sept 21</td>
                    <td>50000</td>
                    <td>4000</td>
                    <td>46000</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>
                  <tr>
                    <td><a href="pages/examples/invoice.html">3</a></td>
                    <td>Oct 21</td>
                    <td>50000</td>
                    <td>3500</td>
                    <td>46500</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>
                  <tr>
                    <td><a href="pages/examples/invoice.html">4</a></td>
                    <td>Nov 21</td>
                    <td>50000</td>
                    <td>4500</td>
                    <td>44500</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>
                  <tr>
                    <td><a href="pages/examples/invoice.html">5</a></td>
                    <td>Dec 21</td>
                    <td>50000</td>
                    <td>4500</td>
                    <td>44500</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>
                  <tr>
                    <td><a href="pages/examples/invoice.html">6</a></td>
                    <td>Jan 21</td>
                    <td>50000</td>
                    <td>4500</td>
                    <td>44500</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>
                  <tr>
                    <td><a href="pages/examples/invoice.html">6</a></td>
                    <td>Feb 21</td>
                    <td>50000</td>
                    <td>4500</td>
                    <td>44500</td>
                    <td>10 Sept 2021</td>
                    <td><button type="button" class="btn btn-block btn-warning btn-sm">View</button></td>
                  </tr>-->
                  </tbody>
                </table>
              </div>
              <!-- /.table-responsive -->
            </div>
            <!-- /.box-body -->
            <div class="box-footer clearfix">
              <!--<a href="javascript:void(0)" class="btn btn-sm btn-info btn-flat pull-left">Place New Order</a>
              <a href="javascript:void(0)" class="btn btn-sm btn-default btn-flat pull-right">View All Orders</a>-->
            </div>
            <!-- /.box-footer -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
	  </div>
      
      <!--<div class="row">
        <div class="col-md-4">
          <div class="info-box bg-yellow">
            <span class="info-box-icon"><i class="ion ion-ios-pricetag-outline"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Inventory</span>
              <span class="info-box-number">5,200</span>

              <div class="progress">
                <div class="progress-bar" style="width: 50%"></div>
              </div>
              <span class="progress-description">
                    50% Increase in 30 Days
                  </span>
            </div>
          </div>
          <div class="info-box bg-green">
            <span class="info-box-icon"><i class="ion ion-ios-heart-outline"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Mentions</span>
              <span class="info-box-number">92,050</span>

              <div class="progress">
                <div class="progress-bar" style="width: 20%"></div>
              </div>
              <span class="progress-description">
                    20% Increase in 30 Days
                  </span>
            </div>
          </div>
          <div class="info-box bg-red">
            <span class="info-box-icon"><i class="ion ion-ios-cloud-download-outline"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Downloads</span>
              <span class="info-box-number">114,381</span>

              <div class="progress">
                <div class="progress-bar" style="width: 70%"></div>
              </div>
              <span class="progress-description">
                    70% Increase in 30 Days
                  </span>
            </div>
          </div>
          <div class="info-box bg-aqua">
            <span class="info-box-icon"><i class="ion-ios-chatbubble-outline"></i></span>

            <div class="info-box-content">
              <span class="info-box-text">Direct Messages</span>
              <span class="info-box-number">163,921</span>

              <div class="progress">
                <div class="progress-bar" style="width: 40%"></div>
              </div>
              <span class="progress-description">
                    40% Increase in 30 Days
                  </span>
            </div>
          </div>
          
        </div>
      </div>-->
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <?php include "include/footer-main.php"; ?>
</div>
<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- Sparkline -->
<script src="bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!-- jvectormap  -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- ChartJS -->
<script src="bower_components/chart.js/Chart.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard2.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
</body>
</html>