

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



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

.fc td:hover{
    cusror:pointer;
}


.leav-dys{
  background:black !important;
  color:white;
}

.fc-day-top:hover{
cursor:pointer;
}
.fc-day:hover{
cursor:pointer;
}
#calendar1 {
    max-width: 800px;
    max-height: 700px;
    margin: 0 auto;
  }


.fc-time{
  display:none;
}

.page-header{
  margin-bottom:0px !important;
}

.fc-toolbar.fc-header-toolbar{
  margin-bottom:0px !important;

}
</style>
   <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;?>">
    <?php if($rows->sedp != ""): ?>
  <?php $__currentLoopData = explode(',', $rows->sedp); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $z=>$info): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 
     <?php if($info == "1" && $z==1): ?>
       <input type="hidden" class="additional_btns" btn_icon="fa fa-pencil" btn_text="Edit" btn_click_function="call_edit_modal" btn_class="btn btn-success btn-sm btn-dtbl" col_width="30" >
     <?php endif; ?> 
     <?php if($info == "1" && $z==2): ?>
        <input type="hidden" class="additional_btns" btn_icon="fa fa-trash-o " btn_text="Remove" btn_click_function="call_remove_modal" btn_class="btn btn-danger btn-sm btn-dtbl" col_width="40"  >
     <?php endif; ?> 
     <?php if($info == "1" && $z==3): ?>
          <input type="hidden" class="additional_btns" btn_icon="fa fa-print" btn_text="Print" btn_click_function="call_print_function2" btn_class="btn btn-info btn-sm btn-dtbl" col_width="40"  >
     <?php endif; ?>
  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php endif; ?>


<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">
<!-- <a href="#" class="btn add-btn" data-bs-toggle="modal" data-bs-target="#add_employee"><i class="fa fa-plus"></i>Add Holiday</a> -->

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


<div class="row filter-row">




</div>

<div class="row">
<div class="col-md-12">
<div id="calendar1"></div>

</div>
</div>
<input type="hidden" id="hidden_status" value="0">
<input type="hidden" id="row_id" value="0">




<div id="add_employee" class="modal custom-modal fade add_main_modal" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-lg custom-design-modal" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><?= $rows->menu_name;?></h5>
<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="modal-body">
<form>
<div class="form-group">
<label>Event Name <span class="text-danger">*</span></label>
<input class="form-control" type="text" id="h_name">
</div>
<div class="form-group">
<label>Event Date <span class="text-danger">*</span></label>
<div class="cal-icon">
<input class="form-control date_cls" type="text" readonly id="h_date">
</div>
</div>

</form>
</div>

<div class="submit-section">

<button type="button" id="add_btn" class="btn btn-info btn-lg" onclick="submit_form();">Save</button>
<button type="button" id="edit_btn" class="btn btn-success btn-lg" onclick="submit_form();">Edit</button>
<button type="button" class="btn btn-danger btn-lg">Reset</button>
</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">
  /*var table = $('#dynamic_ajax_table').DataTable({
    dom: 'lBfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'colvis'
        ],
    "bLengthChange": true,
    "bSort" : true,
     "lengthMenu": [[ 20, 50,75,100, -1], [ 20, 50,75,100, "All"]],
     "pagingType": "full_numbers",
        columnDefs: [ {
            visible: false
        } ]
    
        
    });



    


$("#dynamic_ajax_table_wrapper").addClass("row");
$('#dynamic_ajax_table_length').addClass("col-lg-2 col-sm-2 col-md-2 col-2");
    $('#dynamic_ajax_table_length').after('<div id="space" class="col-lg-6 col-sm-6 col-md-6 col-6"> <div class="row filter-row"><div class="col-sm-4 col-md-4 col-lg-4  col-4">   <div class="form-group form-focus focused"><div class="cal-icon"><input class="form-control floating datetimepicker fr_date" type="text"></div><label class="focus-label">From</label></div></div><div class="col-sm-4 col-md-4 col-lg-4  col-4">   <div class="form-group form-focus focused"><div class="cal-icon"><input class="form-control floating datetimepicker to_date" type="text"></div><label class="focus-label">To</label></div></div><div class="col-sm-4 col-md-4 col-lg-4  col-4"><a href="#" class="btn btn-success btn-sm "> Load </a></div></div></div>');
$(".dt-buttons").addClass("col-lg-4 col-sm-4 col-md-4 col-4");*/

//$('#dynamic_ajax_table_length').after('<div id="space" class="col-lg-6 col-sm-6 col-md-6 col-6"> <div class="row filter-row"><div class="col-sm-4 col-md-4 col-lg-4  col-4">   <div class="form-group form-focus focused"><div class="cal-icon"><input class="form-control floating datetimepicker fr_date" type="text"></div><label class="focus-label">From</label></div></div><div class="col-sm-4 col-md-4 col-lg-4  col-4">   <div class="form-group form-focus focused"><div class="cal-icon"><input class="form-control floating datetimepicker to_date" type="text"></div><label class="focus-label">To</label></div></div><div class="col-sm-4 col-md-4 col-lg-4  col-4"><a href="#" class="btn btn-success btn-sm "> Load </a></div></div></div>');


set_mn();

fetch_view_table();

// $(document).on('click', '.fc-day,.fc-day-top', function (e) {

// if($(this).hasClass("leav-dys")){
//   $(this).removeClass("leav-dys");
//   $(this).append('')
// }else{
//   $(this).addClass("leav-dys");
//   $(this).append('<br><div><input type="text" class="form-control form-control-sm h_name" placeholder="Holiday"/></div>')
// }



// });





function submit_form() {
 status=0;




 if($.trim($('#h_name').val())==""){
    alert('Enter Holiday');
    $('#h_name').focus();
    status==1;
    return;
 }
 




 if (status==0) {
Save_form();
 }
}
//http://192.168.18.128/prl_api/ij/prl_branch_edit.php

function call_edit_modal(row_id) {
$('#add_btn').hide();
$('#edit_btn').show();

    $('#row_id').val(row_id);
    $('#hidden_status').val(1);
        $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                     row_id: row_id,
              url1:'prl_district_edit.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
 datas=response.edit;

          
              $('.add_main_modal').modal('show');
            $('#state_id').val(datas[0]['state_id']); 
            $('#district_name').val(datas[0]['district_name']); 
     
            
       // start_focus();   
        }
          
     });  
}

  function Save_form() {




  arr={
              'cid':"<?php echo e(Session::get('cid')); ?>",
              'hidden_status':$.trim($('#hidden_status').val()),
              'row_id':$.trim($('#row_id').val()),

              'h_name':$.trim($('#h_name').val()),
              'h_date':$.trim($('#h_date').val()),

              'CID': "<?php echo e(Session::get('CID')); ?>",
              
              '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_holiday_save.php'
             
          },
          success:function(response){
            
            console.log(response);
            if (response) {
              alert(response['msg']);
            
               $('.add_main_modal').modal('hide');
               fetch_view_table();
            }else{

            }
          },
          error: function(response) {
          }
         });
  }

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



function load_events(){

  resp='';
  $.ajax({
              type: 'POST',
               async: false,
                url: '/get_data',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                    'CID':"<?php echo e(Session::get('CID')); ?>",
               
              url1:'prl_fetch_holidy.php'
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {

resp=response;
          
           
        }
          
     });


return resp;

}





$(document).ready(function() {  
  var date = new Date();  
  var d = date.getDate();  
  var m = date.getMonth();  
  var y = date.getFullYear();  
  
  var calendar = $('#calendar1').fullCalendar({  
   editable: true,  
   header: {  
    left: 'prev,next today',  
    center: 'title',  
    right: 'month'  
   },  
  
   events:load_events(),  
  
   eventRender: function(event, element, view) {  
    if (event.allDay === 'true') {  
     event.allDay = true;  
    } else {  
     event.allDay = false;  
    }  
   },  
   selectable: true,  
   selectHelper: true,  
   select: function(start, end, allDay) {  
   var title = prompt('Event Title:');  
  
   if (title) {  
   var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");  
   var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");  


   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')); ?>",
             'start':start,
             'end':end,
             'title':title,
              '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_holiday_save.php'
             
          },  
       success: function(json) {  
       alert('Added Successfully');  
       }  
   });  
   calendar.fullCalendar('renderEvent',  
   {  
       title: title,  
       start: start,  
       end: end,  
       allDay: allDay  
   },  
   true  
   );  
   }  
   calendar.fullCalendar('unselect');  
   },  
  
   editable: true,  
   eventDrop: function(event, delta) {  
   var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");  
   var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");  

   arr={
              'cid':"<?php echo e(Session::get('cid')); ?>",
              'hidden_status':1,
              'row_id':event.id,
              'CID': "<?php echo e(Session::get('CID')); ?>",
             'start':start,
             'end':end,
            
              '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_holiday_save.php'
             
          }, 
       success: function(json) {  
        alert("Updated Successfully");  
       }  
   });  
   },  
   eventClick: function(event) {  
    var decision = confirm("Do you really want to delete that?");   
    if (decision) {  

      arr={
              'cid':"<?php echo e(Session::get('cid')); ?>",
              'hidden_status':2,
              'row_id':event.id,
              'CID': "<?php echo e(Session::get('CID')); ?>",
           
             
              '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_holiday_save.php'
             
          }, 
         success: function(json) {  
             $('#calendar').fullCalendar('removeEvents', event.id);  
              alert("Deleted Successfully");
              location.reload()
            }  
    });  
    }  
    },  
   eventResize: function(event) {  
       var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm:ss");  
       var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm:ss");  


       arr={
              'cid':"<?php echo e(Session::get('cid')); ?>",
              'hidden_status':1,
              'row_id':event.id,
              'CID': "<?php echo e(Session::get('CID')); ?>",
             'start':start,
             'end':end,
             'title':title,
              '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_holiday_save.php'
             
          },   
        success: function(json) {  
         alert("Updated Successfully");  
        }  
       });  
    }  
     
  });  
    
 });  
  


	







</script>


<script src="<?php echo e(asset('new_theme/js/fullcalendar.min.js')); ?>"></script>
<script src="<?php echo e(asset('new_theme/js/jquery.fullcalendar.js')); ?>"></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/holiday_schedule.blade.php ENDPATH**/ ?>