
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js"></script>
<style type="">
  .pd-left{
    padding: 30px;
  }
  .btn-default {
    color: #fff;
    background-color: #089bab;
    border-color: #089bab;
    font-weight: 500;
}
.btn-default:hover{
  color: #fff;

}
.martop30{
  margin-top: 40px;
}
</style>
            <!-- TOP Nav Bar END -->
  <div class="container-fluid">
     <div class="row">
        <div class="col-sm-12">
           <div class="iq-card">
              <div class="iq-card-header d-flex justify-content-between">
                 <div class="iq-header-title">
                    <h4 class="card-title">Daily Activities Report</h4>
                 </div>
                    <span class="table-add float-right mb-3 mr-2">
                    <!-- <a href="<?php echo base_url(); ?>customer/export/" class="btn btn-default"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Export</a><a href="javascript:void(0)" class="btn btn-default" data-toggle="modal" data-target="#import_popup"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Import</a> -->
                    <!-- <a href="<?php echo base_url(); ?>Reservation/add" class="btn btn-sm iq-bg-success"><i
                       class="ri-add-fill"><span class="pl-1">Book Now</span></i>
                    </a> -->
                    </span>
              </div>
        
       
              <form method="post" id="trip_details" novalidate="novalidate">
                <div class="row pd-left">
                    
                        <div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">
                          <div class="form-group">
                            <label>Date</label>
                            <input type="date" name="fromdt" id="fromdt" class="form-control hasDatepicker"  autocomplete="off" placeholder="Select Date..." required="" aria-required="true"><br>
                        </div>
                    </div>
                    
                        
                          
                    
                    
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12" align="right">
                          <div class="form-group">
                            <button type="submit" class="btn btn-default martop30"><i class="fa fa-paper-plane" aria-hidden="true"></i> Submit</button>
                        </div>
                    </div>
                   
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12" align="left">
                           <div class="form-group" >
                            <button type="button" class="btn btn-default martop30" onclick="tracking_export();"><i class="fa fa-file-excel-o" aria-hidden="true"></i>&nbsp Export</button>
                        </div>
                    </div>
                  </div>
                  </form>
                  
          <div class="iq-card-body">
             <div id="table" class="table-editable">
                              
             <table id="myTable" class="display table tripData"  style="width:100%">
             <thead>
                <tr>
                  <th>SL. No.</th>    
                  <th>Room Number</th>
                  <th>Guest</th>      
                  <th>Check In</th>                
                  <th>In Time</th>                
                  <th>Tarif</th>                
                  <th>Advance</th>                
                  <!-- <th>Advcr</th>                 -->
                  <th>Adjcs</th>                
                  <!-- <th>Adjcr</th>                 -->
                  <!-- <th>Refn</th>                 -->
                  <!-- <th>ExRef</th>                 -->
                  <th>Due</th>                
                  <th>Out TM</th>                
                  <th>Dep Date</th> 
                </tr>
              </thead>
              <tbody >
        <?php
                $start=0;
                $total_tarif=0;
        $total_advance=0;
        $total_adjcs=0;
        $total_advcr=0;
        $total_adjcr=0;
        $total_refn=0;
        $total_exref=0;
        $total_due=0;
        $card_collection=0;
                $start=0;
                for($i=0;$i<count($recordSet);$i++)
                   { $start++;
                   $tarif=$recordSet[$i]['amount']+$recordSet[$i]['extra_bed_price'];
      $due=0;
      $adjcs=0;
      if($yesterday==$recordSet[$i]['check_out'])
      {
      $adjcs=$tarif-$recordSet[$i]['adv_amount'];
      }
      else
      {
      $due=$tarif-$recordSet[$i]['adv_amount'];
      }
      $total_tarif=$total_tarif+$tarif;
      $total_advance=$total_advance+$recordSet[$i]['adv_amount'];
      $total_adjcs=$total_adjcs+$adjcs;
      $total_due=$total_due+$due;
      if ($recordSet[$i]['adv_amount']!='Cash') {
        $card_collection=$card_collection+$recordSet[$i]['adv_amount'];
      }
                ?>
                
                <tr class="trBack">
                  <td scope="row"><?php echo $start; ?></td>
                  <td><?php echo $recordSet[$i]['room_number']; ?></td>
                  <td><?php echo $recordSet[$i]['num_guest']; ?></td>
                  <td><?php echo $recordSet[$i]['check_in']; ?></td>
                  <td><?php echo $recordSet[$i]['check_in_time']; ?></td>
                  <td><?php echo $tarif; ?></td>
                  <td><?php echo $recordSet[$i]['adv_amount']; ?></td>
                  <!-- <td>0</td> -->
                  <td><?php echo $adjcs; ?></td>
                  <!-- <td>0</td> -->
                  <!-- <td>0</td> -->
                  <!-- <td>0</td> -->
                  <td><?php echo $due; ?></td>
                  <td><?php echo $recordSet[$i]['check_out_time']; ?></td>
                  <td><?php echo $recordSet[$i]['check_out']; ?></td>
                  
                </tr>

              <?php } ?>
              </tbody>
              <tfoot>
                <tr>
                  <th>Total:</th>    
                  <th></th>
                  <th></th>      
                  <th></th>                
                  <th></th>                
                  <th><?php echo $total_tarif; ?></th>                
                  <th><?php echo $total_advance; ?></th>                
                  <!-- <th>0</th>                 -->
                  <th><?php echo $total_adjcs; ?></th>                
                  <!-- <th>0</th>                 -->
                  <!-- <th>0</th>                 -->
                  <!-- <th>0</th>                 -->
                  <th><?php echo $total_due; ?></th>  
                  <th></th>                
                  <th></th>
                </tr>
              </tfoot>
              
            </table>
                           </div>
                        </div>
                        <?php $yesterday=date('Y-m-d'); ?>
<h2>Today Check out list <?php echo $yesterday; ?></h2>
          <div class="iq-card-body">
             <div id="table" class="table-editable">
                              
             <table id="checkout_table" class="display table"  style="width:100%">
             <thead>
                <tr>
                  <th>SL. No.</th>    
                  <th>Room Number</th>
                  <th>Ar Date</th>      
                  <th>Check In</th>                
                  <th>Days</th>                
                  <th>NOP</th>                
                  <th>Tarif</th>                
                  <th>BiAmt</th>                
                  <th>PrAdcs</th>                
                  <th>Out Time</th> 
                </tr>
              </thead>
              <tbody >
        <?php
        
                $start=0;
                $total_tarif=0;
        $total_advance=0;
        $total_adjcs=0;
        $total_advcr=0;
        $total_adjcr=0;
        $total_refn=0;
        $total_exref=0;
        $total_due=0;
        $card_collection=0;
                $start=0;
                $recordSet=$this->db->where('check_out',$yesterday)->where('status','0')->order_by("wr_id", "desc")->get('walk_in_reservation')->result_array();
                for($i=0;$i<count($recordSet);$i++)
                   { $start++;
                   $tarif=$recordSet[$i]['amount']+$recordSet[$i]['extra_bed_price'];
      $due=0;
      $adjcs=0;
      if($yesterday==$recordSet[$i]['check_out'])
      {
      $adjcs=$tarif-$recordSet[$i]['adv_amount'];
      }
      else
      {
      $due=$tarif-$recordSet[$i]['adv_amount'];
      }
      $total_tarif=$total_tarif+$tarif;
      $total_advance=$total_advance+$recordSet[$i]['adv_amount'];
      $total_adjcs=$total_adjcs+$adjcs;
      $total_due=$total_due+$due;
      if ($recordSet[$i]['adv_amount']!='Cash') {
        $card_collection=$card_collection+$recordSet[$i]['adv_amount'];
      }


      $earlier = new DateTime($recordSet[$i]['check_in']);
$later = new DateTime($recordSet[$i]['check_out']);

$pos_diff = $earlier->diff($later)->format("%r%a"); //3
                ?>
                
                <tr class="trBack">
                  <td scope="row"><?php echo $start; ?></td>
                  <td><?php echo $recordSet[$i]['room_number']; ?></td>
                  <td><?php echo $recordSet[$i]['check_in']; ?></td>
                  <td><?php echo $recordSet[$i]['check_in_time']; ?></td>
                  <td><?php echo $pos_diff; ?></td>
                  <td><?php echo $recordSet[$i]['num_guest']; ?></td>
                  <td><?php echo $tarif; ?></td>
                  <td><?php echo $tarif; ?></td>
                  <td><?php echo $tarif; ?></td>
                  <td><?php echo $recordSet[$i]['check_out_time']; ?></td>
                  
                </tr>

              <?php } ?>
              </tbody>
              
              
            </table>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
            <!-- Footer -->
      

<style type="text/css">
  table.dataTable thead .sorting, 
table.dataTable thead .sorting_asc, 
table.dataTable thead .sorting_desc {
    background : none;
}
</style>
<script type="text/javascript">
  function delete_function(id) {

$.confirm({
    title: 'Delete!',
    content: 'Are you want to delete this data?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>customer/Delete/",
          data: {id : id }, 
          success: function(html) {
            $.alert("Your data has been successfully deleted");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}

function status_change(id,status){
if (status=='1') {
  var new_status='0';
$.confirm({
    title: 'Change Status!',
    content: 'Are you want to inactive?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>employee/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });



}
else {
  var new_status='1';

$.confirm({
    title: 'Change Status!',
    content: 'Are you want to active?',
    type: 'green',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-green',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>employee/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}
}
</script>
<div class="modal fade" id="import_popup">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Import Data</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
        <div class="alert alert-success Addmsg" style="display: none;">
          <strong>Successfully Imported Your Data!</strong>
        </div>
        <div class="alert alert-danger statusfailed" style="display: none;">
          <strong>Please Try Again </strong>
        </div>
      <form id="import_form" method="post">
        <!-- Modal body -->
        <div class="modal-body">
          <div class="row">
          <div class="form-group">
              <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                  <label>Import Data</label>
                  <input type="file" name="import_data" id="import_data" class="form-control" required=""  aria-required="true">
                  <br>
              </div>
          </div>
          <div class="form-group">
              <a href="<?php echo base_url(); ?>uploads/Customer_Demo.csv" style="margin-left: 10px;"><i class="fa fa-download" aria-hidden="true"></i> &nbsp; Download CSV Format</a>
          </div>
          </div>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Save</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#import_form").validate({
rules: {
import_file: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#import_form").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#import_form').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>customer/import/',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
$('.addbtn').hide();
$('.addload').show();
},
success: function(msg) {
$(".Addmsg").show();
$('.Addmsg').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();
setInterval(function() {
// location.reload();
}, 3000);
}
});
}
});
});
</script>
<div class="modal fade" id="details_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Hotel Booking Details</h4>
        
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      <!-- Modal body -->
      <div class="modal-body">
        <div id="details_div">
          <!-- <input type="hidden" name="se_status_id" id="se_status_id" value="">
          <input type="hidden" name="update" value="response_status_update"><br> -->
        </div>
      </div>
      
    </div>
  </div>
</div>
<div class="modal fade" id="guest_modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Guest List</h4>
        
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      <!-- Modal body -->
      <div class="modal-body">
        <div id="guest_details_div">
          <!-- <input type="hidden" name="se_status_id" id="se_status_id" value="">
          <input type="hidden" name="update" value="response_status_update"><br> -->
        </div>
      </div>
      
    </div>
  </div>
</div>
<script type="text/javascript">
function details_modal(wr_id)
{
$('#details_modal').modal('show');
$.post('<?php echo base_url(); ?>Reservation/details/', {'wr_id':wr_id}, function(data) {
$("#details_div").html(data);
});
}
function guest_modal(wr_id)
{
$('#guest_modal').modal('show');
$.post('<?php echo base_url(); ?>Reservation/guest_details/', {'wr_id':wr_id}, function(data) {
$("#guest_details_div").html(data);
});
}
</script>

