

<?php $__env->startSection('pageTitle', 'Vega Soft'); ?>
<?php $__env->startSection('page-content'); ?>

 <input type="hidden" id="table_settings_field" branch_id="" branch_name=""  column_heading="<?= $rows->column_heading;?>" column_width="<?= $rows->column_width;?>" column_alighn="<?= $rows->column_alighn;?>"  column_conversion="<?= $rows->column_conversion;?>" settings_row_id="<?= $id;?>" sp_date_picker="<?= $rows->sp_date_picker;?>"  header_from_date="<?=date('d-m-Y', strtotime('-7 days')); ?>"   header_till_date="<?=date('d-m-Y'); ?>"  sp_sort="<?= $rows->menu_id; ?>"  active_mn="<?= $rows->root;?>"  active_mnt="<?= $rows->menu_type;?>">

<style>
#dynamic_ajax_table_length ,.dt-buttons ,#dynamic_ajax_table_filter{
    //float: left;
}
.custom-design-modal{
max-width:70%;
}
.dt-buttons{
    height: 34px;
}

.form-group {
  margin-bottom: 1rem;
}
#emp_info tr td{
  padding:0px;
}


#barcode{
  height: 40px;
  border:2px solid gray;
}


</style>


<div class="page-header">
<div class="row align-items-center">
<div class="col">
<h3 class="page-title"><?= $rows->menu_name;?></h3>
</div>
<div class="col-auto float-end ms-auto">

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


<div class="row filter-row">


<div class="card">
<div class="card-body">


<div class="col-lg-12">


<div class="row">


<div class="col-lg-6 col-md-6">

<div class="row">


<div class="col-lg-3">
<div class="form-group">
<label class="col-form-label">Date </label>
<input class="form-control form-control-sm focusable " readonly type="text" id="entry_date"> 
</div>    
</div>

<div class="col-lg-3">
<div class="form-group">
<label class="col-form-label">Time </label>
<input class="form-control focusable  form-control-sm" readonly type="text" id="p_time"> 
</div>
</div>

</div>
<div class="col-lg-6 col-md-6">

<div class="form-group">
<label class="col-form-label">Employee </label>
<input class="form-control focusable  form-control-sm" readonly type="text" id="emp_name" emp_id="0"> 
</div>






</div>

<div class="col-lg-6 col-md-6">

<div class="row">


<div class="col-lg-6">
<div class="form-group">
<!-- <label class="col-form-label">Status </label>
<input class="form-control form-control-sm focusable "  type="text" id="">  -->
</div>    
</div>

<div class="col-lg-6">
<div class="form-group">
<!-- <label class="col-form-label">Time </label>
<input class="form-control focusable  form-control-sm"  type="text" id="">  -->
</div>
</div>

</div>






</div>



</div>


</div>


<br>

<div class="col-lg-12">
<div class="review-header text-center">
    <input type="text" id="barcode"   >

</div>
</div>




</div>




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


</div>



<div id="error_msg" style="background:red;color:white;font-weight:bold;" ></div>

<input type="hidden" id="hidden_status" value="0">
<input type="hidden" id="row_id" value="0">
<input type="hidden" id="flag" value="0">
<input type="hidden" id="shdl_id" value="0">




<div id="schdl_mdl" class="modal custom-modal fade add_main_modal" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-md " role="document">
<div class="modal-content">
<div class="modal-header">

<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" >

<div class="container">

<div class="row">

<div class="col-lg-6 col-md-6">

<div class="col-lg-12">

<div class="review-header text-center">
<h3 class="review-title" >Todays Info</h3>
<div id="">


<table class="table table-sm">

<tbody id="emp_info">

</tbody>

</table>

</div>

</div>



</div>


</div>

<div class="col-lg-6 col-sm-6 col-md-6">
<div class="col-md-10" id="shdl_mdl_bdy">



</div>
<div class="col-lg-12">

<button type="button" class="btn btn-sm btn-warning" onclick="sv_schdl();">Save</button>

</div>

</div>



</div>


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


</div>
</div>
<?php $__env->stopSection(); ?>




<?php $__env->startSection('page-script'); ?>
<script src="<?php echo e(asset('project-js\vega-front-scripts.js')); ?>"></script>
<script type="text/javascript">
set_mn();

$("#error_msg").hide();


$("#barcode").focus().click();
    
$('.tab-pane:first-child').addClass('active');
function submit_save_form(){

form_id=$("div.tab-content div.active").attr('form_id');

if(status==0){
  Save_form();
}



}



// $("#barcode").on('keyup',function(){
// $("#schdl_mdl").modal("show");
// });



var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();

today = dd + '/' + mm + '/' + yyyy;
$("#entry_date").val(today)






function currentTime() {
  var date = new Date(); 
  var hour = date.getHours();
  var min = date.getMinutes();
  var sec = date.getSeconds();
  var midday = "AM";
  midday = (hour >= 12) ? "PM" : "AM";
  hour = (hour == 0) ? 12 : ((hour > 12) ? (hour - 12): hour); 
  hour = updateTime(hour);
  min = updateTime(min);
  sec = updateTime(sec);
  time=hour + " : " + min + " : " + sec + " " + midday;
 $("#p_time").val(time);
    var t = setTimeout(currentTime, 1000); 
}

function updateTime(k) { 
  if (k < 10) {
    return "0" + k;
  }
  else {
    return k;
  }
}

currentTime();



//fetch_view_table();



//http://192.168.18.128/prl_api/ij/prl_branch_edit.php



  function Save_form() {

 
    var dataArray = {};
    msg_title='';
    var row_id=0;


    

    arr={
              'cid':"<?php echo e(Session::get('cid')); ?>",
              'hidden_status':$.trim($('#hidden_status').val()),
              'row_id':$.trim($('#row_id').val()),
              'CID': "<?php echo e(Session::get('CID')); ?>",
              'branch_id': "<?php echo e(Session::get('b_id')); ?>",
              'emp_id':$("#emp_name").attr('emp_id'),
              'emp_name':$("#emp_name").val(),
              'shdl_id':$("#shdl_id").val(),
              'flag':$("#flag").val(),
              'remarks':'',
              'added_by':"<?php echo e(Session::get('user_id')); ?>",
};


           $.ajax({
          url: "/store_data",
          type: "POST",
          data:{
             '_token': "<?php echo e(csrf_token()); ?>",
              json_data: JSON.stringify(arr),
              url1:'prl_save_punch.php'
             
          },
          success:function(response){
            
            // console.log(response);

            $("#error_msg").show();

            if (response) {



$("#error_msg").text(response['msg'])

            
            $("#shdl_id").val(0);
            $("#flag").val(0);
            $("#emp_name").val('');
            $("#barcode").val('');
            $("#emp_info").html('');
            $("#emp_name").attr('emp_id',0);
               $('.add_main_modal').modal('hide');
               fetch_view_table();
            }else{

            }
          },
          error: function(response) {

            console.log(response)
          }
         });
  }




  $( ".add_main_modal" ).on('hidden.bs.modal', function(){ $('#add_btn').show();
$('#edit_btn').hide();
 $('#hidden_status').val(0);
 $('.add_main_modal .form-control form-control-sm').val('');
});


$('#barcode').keypress(function (e) {
 var key = e.which;
 if(key == 13)  // the enter key code
  {
  
    fetch_pnch();
  }
}); 


$("#barcode").on('blur',function(){



});




function fetch_pnch(){


  $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                     row_id: $.trim($('#barcode').val()),
                     CID: "<?php echo e(Session::get('CID')); ?>",
              url1:'prl_fetch_emp_pnch.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
cust_data=response.cust_data;
cnt=response.cnt;
flag=response.l_flag;
pnch_data=response.pnch_data;
status=0;
console.log(pnch_data)

  ttr='';
if(pnch_data.length>0){


$(pnch_data).each(function(key,val){
  ttr+='<tr>';

ttr+='<td class="text-muted">'+val['desc_name']+'</td>';  
ttr+='<td class="text-muted">'+val['p_time']+'</td>';  
ttr+='</tr>';

});
$("#emp_info").html(ttr)
}
else{
  // alert("No Schedule Setup");
  // status=1;
  // return;
}




if($.isEmptyObject(cust_data)){

  alert("Not Valid code");
  $("#barcode").val('');
  status=1;
}else{


  $("#emp_name").val(cust_data[0]['emp_name']);
$("#emp_name").attr('emp_id',cust_data[0]['emp_id']);
$("#flag").val(flag);

if(cnt==0 && cust_data[0]['id']!=0){

  status=0;



}
else{
  status=1;
  load_schedules(flag);
  
}


}



if(status==0){
  Save_form(); 
}

         
     
            
        
        }
          
     });

}


function load_schedules(flag){
 


  $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data_shdl',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                     row_id: flag,
                     emp_id: $("#emp_name").attr('emp_id'),
                     
                      CID: "<?php echo e(Session::get('CID')); ?>",
              url1:'prl_fetch_schdl.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
                  $("#schdl_mdl").modal("show");
 datas=response.edit;


 tr='';
$(datas).each(function(key,val){


tr+='  <div class="radio"><label>';

tr+='<input type="radio" name="shdl_radio" value="'+val['id']+'"  data-flg="'+val['type']+'">'+val['desc_name'];


tr+='</label></div>';

});
          $("#shdl_mdl_bdy").html(tr);
         
            
     
        }
          
     });




}







function sv_schdl(){


$("#flag").val($("input[name='shdl_radio']:checked").attr('data-flg'));
$("#shdl_id").val($("input[name='shdl_radio']:checked").val())
Save_form();

}




</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\xampp\htdocs\payroll\resources\views/punching_master.blade.php ENDPATH**/ ?>