



<?php $__env->startSection('badcome'); ?>

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

<?php $__env->startSection('dynamic_css'); ?>
<style>
	@media (max-width: 768px)
	{
		.col {
			-ms-flex-preferred-size: 0;
			flex-basis:auto;
			-webkit-box-flex: 1;
			-ms-flex-positive: 1;
			flex-grow: 1;
			max-width: 100%;
		}
	}
    
.custom-select {
    height: calc(2.75rem + 2px);
}
    
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row justify-content-center container_layout">
        <div class="col-md-12">
            <div class="card" style="">
                <div class="card-body" style="padding: .5rem;"> 
                      <div class="row justify-content-center mt5">
                         
                          <div class="col-md-4 mt5">
                                <select class="browser-default custom-select f-16" name="salary_month" id="salary_month">
                                    <option selected disabled>Please select a month</option>
                              <?php $__currentLoopData = $month_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $md): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                  <option value="<?php echo e($md['month']); ?>,<?php echo e($md['salary_year']); ?>" class="mt5 mb5"><?php echo e($md['month_text'].' , '.$md['salary_year']); ?></option>
                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                          </div>
                          <div class="col-md-2 text-right"> <button type="button" id="download_pdf" class="btn btn-outline-info btn-rounded waves-effect"><i class="fa fa-download mr-2" aria-hidden="true"></i>Get Slip</button></div>
                      </div>
                </div>
            </div>
        </div>
 


        <div class="col-md-12 display_none" id="payslip_preview">
			
            <div class="card mt20" style="overflow: auto;">
                <div class="card-body" style="min-width: 650px;"> 
                     <div class="row justify-content-center mt5">
                          <div class="col-md-12" id="print_preview">
                         </div>
                    </div>
                    <div class="row mt5">
                        <form class="col-md-12 d-flex flex-row-reverse" action="<?php echo e(route('downoadpayslip')); ?>" method="POST">
                            <?php echo e(csrf_field()); ?>

                            <input type="hidden" name="month" id="month" value="">
                            <input type="hidden" name="year" id="year" value="">
                            <div class="col-md-3 text-right"> <button type="submit" class="btn btn-outline-success btn-sm btn-rounded waves-effect"><i class="fa fa-download mr-2" aria-hidden="true"></i>Download</button></div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
 
    </div>

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

<?php $__env->startSection('dynamic_js'); ?>
<script>

   $(document).on('click','#download_pdf',function(e){
       e.preventDefault();
       var month_data=$('#salary_month').val();
       if(month_data){
            var split_value = month_data.split(",");
            var month = split_value[0];
            var year = split_value[1];
            $('#month').val();
            $('#year').val();
                $.ajax({
                    type: "GET",
                    url: "<?php echo e(route('getpayslip')); ?>",
                    dataType: "json",
                    data:{month:month,year:year},
                    success: function (data) {
                        
                        $('#print_preview').empty();
                        if (data.msgType == true) {
                           $('#month').val(month);
                           $('#year').val(year);
                           $('#print_preview').html(data.data);
                           $('#payslip_preview').show();
                        }else{
                          $('#payslip_preview').hide();
                          toastr.error(data.msg);
                        }
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        callAjaxErrorFunction(jqXHR, textStatus, errorThrown);
                    },
                    complete: function (data) {
                        $('.page-loader-wrapper').fadeOut();
                    }
                });
           
       }

   })


</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.appuser', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>