<?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>Leave Confirm Form</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">
  <!-- daterange picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/iCheck/all.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css">
  <!-- Bootstrap time Picker -->
  <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="bower_components/select2/dist/css/select2.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">
  <!-- 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>
      Leave Confirm Form
        <!--<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>
    <?php
                        $id='';
                        $where_attendance_id='';
                        if($_REQUEST['id'])
                        {
                            $attendance_id=$_GET['id'];    
                            $where_staff_id="and attendance_id='".$attendance_id."'";
                        }
                        // echo $attendance_id;


                        $sel_attts="select * from pr_daily_attendance where 1 ".$where_staff_id."";
                        $ptr_atts=mysql_query($sel_attts);
                        $t=1;
                    
                        while($data_atts=mysql_fetch_array($ptr_atts))
                        {
                           

                          $sel_attts="select name from site_setting where 1 and admin_id='".$_SESSION['admin_id']."'";
                            $ptr_atts=mysql_query($sel_staff);
                            $data_staff=mysql_fetch_array( $ptr_atts);
                        // }
                            ?>





	<?php
  //  if($_REQUEST['id'] !='')
  //  {
  //    $record_id=$_REQUEST['id'];
  //    $query="select * from pr_apply_leave where  leave_id='".$record_id."'";
  //    $ptr_data_2=mysql_query($query);
  //    $data=mysql_fetch_array( $ptr_data_2);
    //  echo $data['leave_id'];
  //  }
  //  else{
  //   $record_id='';
  //  }

	if(isset($_POST['submit']))
	{
		$date=$_POST['date'];
        $reason=$_POST['reason'];
		$punch_in=$_POST['Punch_in'];
		$punch_out=$_POST['Punch_out'];
		
    // $comment=$_POST['comment'];
    //  $approved=$_POST['approved_by'];
		$admin_id =$_SESSION['admin_id'];
		
	    $insert_salary="insert into confirm_leave(`date`,`reason`,`punch_in`,`punch_out`,`admin_id`,`cm_id`)values('".$date."','".$reason."','".$punch_in."','".$punch_out."','".$admin_id."','".$_SESSION['cm_id']."')";
		$ptr_ins=mysql_query($insert_salary);
	}
  
	?>
  
     <!-- <?php
  //  if(isset($_POST['approved']))
  // {
    
  //   $status= "Approved";
  // $comment=$_POST['comment'];
  //    $leave_id=$_POST['leave_id'];

  //    $insert_salary="UPDATE `pr_apply_leave` set `status`= '$status',`comment`='$comment' where `leave_id`=' $leave_id'";
	// 	$ptr_ins=mysql_query($insert_salary);
  // }
  //  if(isset($_POST['rejected']))
  //  {
    
  //    $status= 'Rejected';
  //    $comment=$_POST['comment'];
  //    $leave_id=$_POST['leave_id'];

  //     $insert_salary="UPDATE `pr_apply_leave` set `status`= '$status',`comment`='$comment' where `leave_id`=' $leave_id'";
	//  	 $ptr_ins=mysql_query($insert_salary);
  //  }
   ?>   
  -->
    <!-- Main content -->
    <section class="content">
	
      <!-- SELECT2 EXAMPLE -->
      <div class="box box-default">
        <!--<div class="box-header with-border">
          <h3 class="box-title">Select2</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-remove"></i></button>
          </div>
        </div>-->
        <!-- /.box-header -->
        <form name="loan_form" method="post" >
            <div class="box-body">
              <div class="row">
                <div class="col-md-6">
                  <div class="form-group">
                    <label>Date</label>
                    <input type="text" class="form-control pull-right"  name="from_date" id="datepicker" value="<?php echo date('d M y',strtotime($data_atts['date'])); ?>">
                    <!-- <input type="text" name="date" id="date" style="width: 100%;" value="<?php echo date('d M y',strtotime($data_atts['date'])); ?>"> -->
                      <!-- <option selected="selected">Select Leave Type</option>
                      <option value="casual_leave">Casual Leave</option>
                      <option value="sick_leave">Sick Leave</option>
                      <option value="privilage_leave">Privilage Leave</option>
                      <option value="compensatory_leave">Compensatory Leave</option> -->
                    </select>
                  </div>
                  <div class="form-group">
                      <label>Reason</label>
                      <textarea class="form-control" name="reason" rows="3" placeholder="Enter ..."></textarea>
                  </div>
                </div>
                <!-- /.col -->
                <div class="col-md-6">
                  <div class="form-group">
                        <label>Punch-in</label>
                        <div class="input-group">
                          <input type="text" class="form-control timepicker" id="punchin" name="punchin" value="<?php echo $data_atts['punch_in']; ?>">

                          <div class="input-group-addon"> 
                            <i class="fa fa-clock-o"></i>
                          </div>
                        </div>
                  </div>
                  <div class="form-group">
                    <!-- <div class="col-md-6"> -->
                        <label>Punch-out</label>
                        <div class="input-group">
                          <input type="text" class="form-control timepicker" id="punchout" name="punchout"value="<?php echo $data_atts['punch_out']; ?>">

                          <div class="input-group-addon">
                            <i class="fa fa-clock-o"></i>
                          </div>
                        </div>
                  </div>
                </div>
                <!-- <div class="col-md-6">
                  <div class="form-group">
                        <label>Punch-in</label>
                        <div class="input-group">
                          <input type="text" class="form-control timepicker" id="punchin" name="punchin" value="<?php echo $data_atts['punch_in']; ?>

                          <!-- <div class="input-group-addon">
                            <i class="fa fa-clock-o"></i>
                          </div> 
                        </div>
                  </div>
                  <div class="form-group">
                    <div class="col-md-6"> 
                        <label>Punch-out</label>
                        <div class="input-group">
                          <input type="text" class="form-control timepicker" id="punchout" name="punchout" value="<?php echo $data_atts['punch_out']; ?>

                          <div class="input-group-addon">
                            <i class="fa fa-clock-o"></i>
                          
                          </div>
                        </div>
                    </div>
                
                </div> -->
                
                  

                
                 
              <!-- </div> -->
                <div class="col-md-12">
                    <input type="submit" name="submit" value="Submit" class="btn btn-block btn-success">
                </div>
              <!-- /.row -->
            </div>
            </form>
            <?php
             }
            ?> 


        <!-- /.box-body -->
        <!--<div class="box-footer">
          Visit <a href="https://select2.github.io/">Select2 documentation</a> for more examples and information about
          the plugin.
        </div>-->
      </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">Past Leaves</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>
                  <tr>
                    <th>Sr. No.</th>
                    <th>Date</th>
                    <th>Reason</th>
                    <th>Punch-in</th>
                    <th>Punch-out</th>
                     <!-- <th>Status</th>  -->
                       <!-- <th>Comment</th>   -->
                     <!-- <th>Follow up</th> -->
                     <!-- <th>&nbsp;</th>
                    
                  </tr>
                  </thead> 
                   <tbody>   -->

                  <?php

                    $sel_attts="select * from confirm_leave  ";
                    $ptr_atts=mysql_query($sel_attts);
                    $t=1;
                    while($data_atts=mysql_fetch_array($ptr_atts))
                    {
                      $arr = explode(':', $data_atts['total_hrs']);
                      if (count($arr) == 2) {
                       $ts_sec =  $arr[0] * 60 + $arr[1];
                    }
                      if($ts_sec >= '524')
                    {
                        $ontime='<span class="label label-success">Yes</span>';
                      }
                        else
                      {
                          $ontime='<span class="label label-warning">No</span>';
                      }

					        ?> 
                        <!-- <tr>
                        <td><?php echo $t; ?></td>
                        <td><?php echo date('d M y',strtotime($data_atts['date']))?></td>
                        <td><?php echo $data_atts['reason']; ?> </td>
                        <td><?php echo $data_atts['punch_in']; ?> AM</td>
                        <td><?php echo $data_atts['punch_out']; ?> PM</td> -->
                        <!-- <td><?php echo $data_app['no_of_days']; ?></td> -->

                         <?php
                      //    $data_app ='status'; 
                      //   if($data_app ='status' ){
                      //     $data_app = '<span class="label label-danger">Reject</span>';

                      //  }
                      //   else{
                      //    $data_app = '<span class="label label-success">Approved</span>'; -->
                      //   }
                        // $statust=danger
                        // $statust =warning
                        // $statust=success
                        // ?> 
                        <td>
                        <?php 
                        // if($data_app['status'] =='Approved' ){
                        //   ?>
                           <!-- <span class="label label-success"><?php echo $data_app['status'] ?> </span> -->
                          <?php
                        // }
                         
                        // if($data_app['status'] =='Rejected' ){
                          ?>
                          <!-- <span class="label label-danger"><?php echo $data_app['status'] ?> </span> -->
                          <?php
                        // }
                        
                        // if($data_app['status'] =='Pending' ){
                          ?>
                          <!-- <span class="label label-warning"><?php echo $data_app['status'] ?> </span> -->
                          <?php
                        // }
                        // else if($data_app['status'] =='pending' )
                        // {
                        //   $status= 'warning';
                        // }
                        // else if($data_app['status'] =='Rejected' )
                        // {
                        //   $status= 'danger';
                        // }
                        ?>
                        <!-- </td>
                         <td><span class="label label-<?php echo $status; ?>">
                         <a href="leave_followup2.php?id=<?= $data_app['leave_id']?>" class="fa fa-edit"></a> 
                      </td> -->
                      
                        <!-- <td><a href="leave_followup2.php?id=<?= $data_app['leave_id']?>" class="fa fa-edit"></a></td>  -->
                          
                            <!-- <td><form method="post" action=""> -->
                          <!-- <textarea name ="comment"input type="hidden"></textarea> -->
                          
                        <!-- <td><a href="leave_followup2.php?id=<?= $data_app['leave_id']?>" class="fa fa-edit"></a></td>  -->
                             <!-- <input type="hidden" name="leave_id" value="<?php echo $data_app['leave_id']; ?>">  
                         <td>
                         <button type="submit" name="approved" value="Submit" span class="label label-success">Approved</button> 
                        
                         <button type="submit" name="rejected" value="Submit" span class="label label-danger">Reject</button> 
                       
                        </form></td>
                         <td><?php echo $data_app['approved_by']; ?></td>
                        
                        <td><?php echo $data_staff['name']; ?></td>     -->
                        
                      </tr> 
                    <?php
				                }
				            ?>
                  </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>
      <!-- /.box -->
    </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>
<!-- Select2 -->
<script src="bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- InputMask -->
<script src="plugins/input-mask/jquery.inputmask.js"></script>
<script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
<!-- date-range-picker -->
<script src="bower_components/moment/min/moment.min.js"></script>
<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker -->
<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- bootstrap color picker -->
<script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<!-- bootstrap time picker -->
<script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- iCheck 1.0.1 -->
<script src="plugins/iCheck/icheck.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- Page script -->
<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Datemask dd/mm/yyyy
    /*$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )*/

    //Date picker
    $('#datepicker').datepicker({
      autoclose: true,
	  format: 'dd/mm/yyyy',
	  startDate: '-0d',
	  Default: true,
	  todayHighlight: true
    })
	$('#datepicker1').datepicker({
      autoclose: true,
	  format: 'dd/mm/yyyy',
	  Default: true,
	  todayHighlight: true
    })

    //iCheck for checkbox and radio inputs
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
      checkboxClass: 'icheckbox_minimal-blue',
      radioClass   : 'iradio_minimal-blue'
    })
    //Red color scheme for iCheck
    $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
      checkboxClass: 'icheckbox_minimal-red',
      radioClass   : 'iradio_minimal-red'
    })
    //Flat red color scheme for iCheck
    $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
      checkboxClass: 'icheckbox_flat-green',
      radioClass   : 'iradio_flat-green'
    })

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    //Timepicker
    $('.timepicker').timepicker({
      showInputs: false
    })
  })
</script>
<script>
  function count_days(to_date)
  {
    var frm_date=document.getElementById("datepicker").value;
    frm_date_split=frm_date.split('/');
    new_frm_date=frm_date_split[1]+'-'+frm_date_split[0]+'-'+frm_date_split[2];

    to_date_split=to_date.split('/');
    new_to_date=to_date_split[1]+'-'+to_date_split[0]+'-'+to_date_split[2];

    const dt_date1 = new Date(new_frm_date);
    const dt_date2 = new Date(new_to_date);
    var diff = dt_date2.getDate() - dt_date1.getDate();   
    document.getElementById("leave_days").value=diff+1;
    //var daydiff = diff / (1000 * 60 * 60 * 24);   
    //alert("differance days "+diff);
  }
  </script>
</body>
</html>