


<?php $__env->startSection('dynamic_css'); ?>
    <style type="text/css">
        .ml-25 {
             margin-left: -25px !important;
        }
        
        .custom_card{
            box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0), 0 0px 0px 0 rgba(0, 0, 0, 0) !important;
            border-radius: 0rem !important;
           
        }
        .custom_card_card_header {
           border-bottom: 0px solid rgba(0, 0, 0, .125) !important; 
       }
    </style>
<?php $__env->stopSection(); ?>

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

<?php $__env->startSection('content'); ?>
<div class="container">
  <div class="row container_layout">
      <div class="col-md-12">
<?php
   $year=0;
   $month=0;
   $monthyearDisplay='';
    
   $yearly_data=0; 
    
?>


    
    
    <div class="row">
           <div class="col-md-12 text-right" id="programs_div">
                <?php $__currentLoopData = $programs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $li): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        if($li->program_id==1){
                            $progam_style="orange";
                        }elseif ($li->program_id==2){
                            $progam_style="blue";
                        }elseif($li->program_id==3){
                            $progam_style="red";
                        }elseif ($li->program_id==4){
                            $progam_style="green";
                        }elseif ($li->program_id==5){
                            $progam_style="brown";
                        }
                    ?>
                        <span style="font-size: 13px"><i class="fa fa-circle" style="color: <?php echo e($progam_style); ?>;"></i> <?php echo e($li->program_name); ?></span>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </div>
    </div>

<?php if($level!=4): ?>
   <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view_task_wise_graph')): ?>
     <div class="row">
        <div class="col-md-12 mt-0 ml-25" >
            <button type="button" class="btn btn-primary">
              TASK WISE PERFORMANCE <i class="fa fa-angle-double-right " aria-hidden="true"></i>
            </button>
         </div>
     </div>
     <div class="row mb-4">
         <div class="col-md-12 mb-2 " >
            <div class="btn-group float-right">

            <?php if(!empty($month_array)): ?>
                  <div class="dropdown second_level_dropdown" id="second_level_dropdown_month">

                   
                        <?php
                           $year=$month_array[0]['year'];
                           $month=$month_array[0]['month'];
                           $monthyearDisplay=$month_array[0]['disply_text'];
                        ?>
                    <!--Trigger-->
                    <button class="btn btn-default waves-effect dropdown-toggle mr-4 btn-select-sub" type="button" id="dropdownMenu1" data-toggle="dropdown"
                      aria-haspopup="true" aria-expanded="false" style="min-width: 12.2rem;"><?php echo e($month_array[0]['disply_text']); ?></button>


                    <!--Menu-->
                    <div class="dropdown-menu dropdown-primary">
                    <?php $__currentLoopData = $month_array; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $month_data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                       <a class="dropdown-item btn-select-sub" href="#" data-value1="<?php echo e($month_data['month']); ?>" data-value2="<?php echo e($month_data['year']); ?>"><?php echo e($month_data['disply_text']); ?></a>
                         <div class="dropdown-divider"></div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>

                  
                  </div>
                
                  <div class="dropdown second_level_dropdown display_none" id="second_level_dropdown_year">

                    <?php if(count($year_array)>0): ?>

                        <?php
                           $yearly_data=$year_array[0]->year;
                        ?>
                         <button class="btn btn-default waves-effect dropdown-toggle mr-4 btn-select-sub1" type="button" id="dropdownMenu2" data-toggle="dropdown"
                          aria-haspopup="true" aria-expanded="false" style="min-width: 12.2rem;"><?php echo e($year_array[0]->year); ?></button>


                        <!--Menu-->
                        <div class="dropdown-menu dropdown-primary">
                            <?php $__currentLoopData = $year_array; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year_data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                               <a class="dropdown-item btn-select-sub1" href="#" data-value1="<?php echo e($year_data->year); ?>"><?php echo e($year_data->year); ?></a>
                                 <div class="dropdown-divider"></div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>  

                   <?php endif; ?>
                  </div>
                
                
                <!-- Basic dropdown -->
                <div class="dropdown">
                  <button class="btn btn-secondary waves-effect dropdown-toggle btn-select" type="button" data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false" style="min-width: 10rem;">Monthly</button>

                  <div class="dropdown-menu">
                    <a class="dropdown-item btn-select" href="#" data-value="all">All</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item btn-select " href="#" data-value="monthly" selected>Monthly</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item btn-select" href="#" data-value="yearly">Yearly</a>
                  </div>
                </div>
                
                
              <?php endif; ?>
              <!-- Basic dropdown -->
            </div>            
                
                
         </div>
        <div class="col-md-12" >
		  <div class="bg-white p20" style="overflow-x: auto;">
			   <div style="width:100%; min-height:400px;" >
                 <?php if($month): ?> 
				    <canvas id="myChart" style="height: -webkit-fill-available; min-width:500px;"></canvas>
                 <?php endif; ?>
			   </div>
		  </div>
        </div>
    </div>
   <?php endif; ?>

    
    
    
  <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view_task_assigned_employees')): ?>  
    <div class="row mb-4">
        <div class="col-md-12 mt-3 ml-25" >
            <button type="button" class="btn btn-primary">
              TASK DETAILS <i class="fa fa-angle-double-right " aria-hidden="true"></i>
            </button>
         </div>
     </div>   
          
          
     <div class="row mb-4">   
        <div class="col-md-12 mb-2 " >
            <div class="btn-group float-right">
              <?php if(!empty($month_array)): ?>  
                <!-- Basic dropdown -->
                <div class="dropdown">
                  <button class="btn btn-default  waves-effect dropdown-toggle btn-select-month mr-4" type="button" data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false" style="min-width: 10rem;"><?php echo e($month_array[0]['disply_text']); ?></button>

                  <div class="dropdown-menu">
                    <?php $__currentLoopData = $month_array; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $month_data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                       <a class="dropdown-item btn-select-month <?php if($month_data['disply_text']==$month_array[0]['disply_text']): ?> <?php echo e('active'); ?> <?php endif; ?>" href="#" data-value1="<?php echo e($month_data['month']); ?>" data-value2="<?php echo e($month_data['year']); ?>"><?php echo e($month_data['disply_text']); ?></a> 
                         <div class="dropdown-divider"></div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </div>
                </div>
              <?php endif; ?>   
                
            
                <!-- Basic dropdown -->
             <?php if($level==1): ?>
               <?php if(!empty($district_array)): ?>
                <div class="dropdown">
                  <button class="btn btn-info  waves-effect dropdown-toggle btn-select-district " type="button" data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false" style="min-width: 10rem;">All District</button>

                  <div class="dropdown-menu" id="btn-select-district_id">
                        <a class="dropdown-item btn-select-district active" href="#" data-value1="1">All District</a> 
                         <div class="dropdown-divider"></div>
                  
                    <?php $__currentLoopData = $district_array; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $district_data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                       <a class="dropdown-item btn-select-district" href="#" data-value1="<?php echo e($district_data->district_code); ?>"><?php echo e($district_data->district_name); ?></a> 
                         <div class="dropdown-divider"></div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
               
                  </div>
                </div>
               <?php endif; ?>
             <?php endif; ?>
            </div>            
                
                
         </div>
        
        <div class="col-md-12" >
		  <div class="bg-white p20" style="overflow-x: auto;min-height:200px;">
              
                 <div class="accordion md-accordion" id="accordionEx" role="tablist" aria-multiselectable="true">

                  </div>
              
		  </div>
        </div>
    </div>  
  <?php endif; ?>  
    
    
    <!--$$$$$$$$$$$$$$$$$ District dashboard $$$$$$$$$$$$$$$$$$$$-->
    <div class="row">  
    </div>	
<?php endif; ?>

    <!--$$$$$$$$$$$$$$$$$ Employee dashboard $$$$$$$$$$$$$$$$$$$$-->
    <div class="row">  
        
    </div>	
</div>
</div>
</div>
<script src="<?php echo e(asset('js/lib/Chart.bundle.js')); ?>"></script>
<script src="<?php echo e(asset('js/lib/Chart.bundle.min.js')); ?>"></script>

<?php if($level!=4): ?>
<script>
   var temp_flag=0; 
   var myBarChart;
    
   var monthyearDisplay=''; 
   var month_flag=0;
    
   var yearDisplay=''; 
   var year_flag=0;   
 $(document).on('click','a.btn-select',function(e){
     e.preventDefault();
     $('button.btn-select').empty();
     $('button.btn-select').append($(this).text());
     
     if($(this).data('value')=='all'){
         $('.second_level_dropdown').hide(500);
         get_task_wise_performance_data(<?php echo e($month); ?>,<?php echo e($year); ?>,2);   
     }else if($(this).data('value')=='monthly'){
         $('.second_level_dropdown').hide(500);
         $('#second_level_dropdown_month').show(500);
         if(monthyearDisplay!=''){
             $('button.btn-select-sub').empty();
             $('button.btn-select-sub').append(monthyearDisplay);
         }
         get_task_wise_performance_data(<?php echo e($month); ?>,<?php echo e($year); ?>,1);
     }else{
         
         if(yearDisplay!=''){
             $('button.btn-select-sub1').empty();
             $('button.btn-select-sub1').append(yearDisplay);
         }        
         
         get_task_wise_performance_data(<?php echo e($month); ?>,<?php echo e($yearly_data); ?>,3);     
         $('.second_level_dropdown').hide(500);
         $('#second_level_dropdown_year').show(500);
         
     }
     

     
 })   
  
    
 $(document).on('click','a.btn-select-sub',function(e){
     e.preventDefault();
     if(month_flag==0){
         monthyearDisplay=$('button.btn-select-sub').text();
         month_flag=1;
     }
     $('button.btn-select-sub').empty();
     $('button.btn-select-sub').append($(this).text());  
     var month=$(this).data('value1'); 
     var year=$(this).data('value2'); 
     get_task_wise_performance_data(month,year,1);
     

 })
    
 $(document).on('click','a.btn-select-sub1',function(e){
     e.preventDefault();
     if(year_flag==0){
         yearDisplay=$('button.btn-select-sub1').text();
         year_flag=1;
     }
     $('button.btn-select-sub1').empty();
     $('button.btn-select-sub1').append($(this).text()); 
     var year=$(this).data('value1');
     get_task_wise_performance_data(<?php echo e($month); ?>,year,3);

 })  
    
    
    
    
  
 $(document).on('click','a.btn-select-month',function(e){
     e.preventDefault();
     if(month_flag==0){
         monthyearDisplay=$('button.btn-select-month').text();
         month_flag=1;
     }
     $('button.btn-select-month').empty();
     $('button.btn-select-month').append($(this).text());  
     var month=$(this).data('value1'); 
     var year=$(this).data('value2'); 
     
     $('a.btn-select-month').removeClass('active');
     $(this).addClass('active');
     
     get_target_assigned_district_by_month(month,year); 
     get_task_assigned_data(month,year,1,1);  
 }) 
    
    
    
    
    
    
    
  $(document).on('click','a.btn-select-district',function(e){
     e.preventDefault();
     $('button.btn-select-district').empty();
     $('button.btn-select-district').append($(this).text());  
     var district=$(this).data('value1'); 
     
     $('a.btn-select-district').removeClass('active');
     $(this).addClass('active');
      
    var month=$('a.btn-select-month.active').data('value1'); 
    var year=$('a.btn-select-month.active').data('value2');
    if(district!=1){
        get_task_assigned_data(month,year,district,2);
    }else{
        get_task_assigned_data(month,year,district,1);
    }
         
 }) 
    
    
    
    
function get_target_assigned_district_by_month(month,year){
    
        $('.page-loader-wrapper').fadeIn();
        $.ajax({
            type: "GET",
            url:"<?php echo e(route('performance.target_assigned_district_list')); ?>",
            data:{year:year,month:month},
            dataType: "json",
            success: function (data) {
                if (data.msgType == true) {
                    
                   $('#btn-select-district_id').empty();
                   $('#btn-select-district_id').append('<a class="dropdown-item btn-select-district active" href="#" data-value1="1">'+
                                                       'All District'+
                                                       '</a><div class="dropdown-divider"></div>'); 

                    $.each(data.data, function (key, val) {
                        $('#btn-select-district_id').append('<a class="dropdown-item btn-select-district" href="#" data-value1="'+val.district_code+'">'+val.district_name+
                                                       '</a><div class="dropdown-divider"></div>');
                    });
                    $('button.btn-select-district').empty();
                    $('button.btn-select-district').append('All District');  
  
                }else {
                   toastr.error(data.msg);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {

                callAjaxErrorFunction(jqXHR, textStatus, errorThrown);
            },
            complete: function (data) {
                $('.page-loader-wrapper').fadeOut();
            }
        });    
}
       
    
    
 
    
 function get_task_wise_performance_data(month,year,flag){
     
        $('.page-loader-wrapper').fadeIn();
        $.ajax({
            type: "GET",
            url:"<?php echo e(route('performance.get_task_wise_performance_data')); ?>",
            data:{year:year,month:month,flag:flag},
            dataType: "json",
            success: function (data) {
                if (data.msgType == true) {
                   /* $('#myChart').remove();*/

                    
                    var district = [];
                    var targets = [];
                    var achieve=[];
                
                    $.each(data.data, function (key, val) {
                        district.push(val['task_name']);
                        targets.push(val['task_target']);
                        achieve.push(val['task_achive']);
                    });
                    
                    var ctx = document.getElementById("myChart");

                    var data = {
                      labels:district,
                      datasets: [{
                        label: "Task Target",
                        backgroundColor: "rgba(255, 99, 132, 0.2)",
                        borderColor: "rgba(255,99,132,1)",
                        borderWidth: 1,
                        hoverBackgroundColor: "rgba(255,99,132,1)",
                        hoverBorderColor: "rgba(255,99,132,1)",
                        data:targets,
                      },{
                        label: "Target Achieved",
                        backgroundColor: "rgba(75, 192, 192, 0.2)",
                        borderColor: "rgba(75, 192, 192, 1)",
                        borderWidth: 1,
                        hoverBackgroundColor: "rgba(75, 192, 192, 1)",
                        hoverBorderColor: "rgba(75, 192, 192, 1)",
                        data:achieve,
                      }]
                    };

                    var options = {
                      responsive: true,
                      maintainAspectRatio: false,
                      scales: {
                        xAxes: [{
                          ticks: {
                            autoSkip: false,
                            maxRotation: 90,
                            minRotation: 45
                          },
                          scaleLabel: {
                            display: true,
                            labelString: 'Task List'
                          }
                        }],
                        yAxes: [{
                          gridLines: {
                            display: true
                          },
                          scaleLabel: {
                            display: true,
                            labelString: 'Task Amount'
                          }
                        }]
                      },
                        legend: {
                            position: 'top',
                            display: true
                        },
                        title: {
                            display: true,
                            text: 'District Wise Assigned Task'
                        }
                    };

                    /*Chart.Bar('myChart', {
                      options: options,
                      data: data
                    });*/
                    
                   
                    
                    if(temp_flag==1){

                      myBarChart.destroy();  
                       
                    }
                    
                   myBarChart = new Chart('myChart', {
                        type: 'bar',
                        data: data,
                        options: options
                    });
                    temp_flag=1;
                  
                } else {
                   toastr.error(data.msg);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {

                callAjaxErrorFunction(jqXHR, textStatus, errorThrown);
            },
            complete: function (data) {
                $('.page-loader-wrapper').fadeOut();
            }
        });
     
     
 }   
    
    
function get_task_assigned_data(month,year,district,flag){
     
        $('.page-loader-wrapper').fadeIn();
        $.ajax({
            type: "GET",
            url:"<?php echo e(route('performance.get_task_assigned_employee_data')); ?>",
            data:{year:year,month:month,district:district,flag:flag},
            dataType: "json",
            success: function (data) {
                if (data.msgType == true) {
                      
                    $('#accordionEx').empty();
                    var progam_style='';
                    $.each(data.data, function (key, val) {
							if (val.program_id==1){
                                progam_style="orange";
                            }else if (val.program_id==2){
                            	progam_style="blue";
                            }else if(val.program_id==3){
                            	progam_style="red";
                            }else if (val.program_id==4){
                            	progam_style="green";
                            }else if (val.program_id==5){
                            	progam_style="brown";
                            }
                        

                        
                        
                        
                        
                        $('#accordionEx').append('<div class="card custom_card mb-2" style=" border-left: 6px solid '+progam_style+';">'+
                                                 '<div class="card-header custom_card_card_header" role="tab" id="heading'+val.id+'">'+
                                                 '<a data-toggle="collapse" data-parent="#accordionEx" href="#collapseOne'+val.id+'" aria-expanded="true" aria-controls="collapseOne'+val.id+'">'+
                                                 '<h6 class="mb-0"><div class="row">'+
                                                 '<div class="col-md-6 f-13">'+val.task_title+'</div>'+ 
                                                 '<div class="col-md-3 f-13 ">'+
                                                 '<span class="mr-4">Total Target : '+val.district_targets+'</span>'+
                                                 '</div>'+
                                                 '<div class="col-md-3 f-13 ">'+
                                                 '<span class="mr-4">Target Achieved : '+val.target_achieved+'</span>'+
                                                 '<i class="fa fa-angle-down rotate-icon pull-right"></i>'+
                                                 '</div>'+
                                                 '</div></h6>'+
                                                 '</a>'+
                                                 '</div>'+

                                                 '<div id="collapseOne'+val.id+'" class="collapse" role="tabpanel" aria-labelledby="headingOne'+val.id+'" data-parent="#accordionEx">'+
                                                 '<div class="card-body" id="body'+val.id+'">'+
                                                 

                                                      
                                                 '</div>'+
                                                 '</div>'+
                                                 '</div>');
                        
                        
                        
                        var employee_list='';
                        var employee_data='';
                        if(val.employee_data.length>0){
                            var i=0;
                            
                            $.each(val.employee_data, function (key, val1) {
                                i=i+1;
                                employee_list=employee_list+'<tr>'+
                                              '<td class="pt-3-half" contenteditable="false">'+i+'</td>'+
                                              '<td class="pt-3-half" contenteditable="false">'+val1.employee_code+'</td>'+
                                              '<td class="pt-3-half" contenteditable="false">'+val1.name+'</td>'+
                                              '<td class="pt-3-half" contenteditable="false">'+val1.designation_name+'</td>'+
                                              '<td class="pt-3-half" contenteditable="false">'+val1.employee_target+'</td>'+
                                              '<td class="pt-3-half" contenteditable="false">'+val1.employee_achieve_target+'</td>'+
                                            '</tr>';
                            });
                          $('#body'+val.id).empty();  
                          $('#body'+val.id).append('<table class="table table-bordered table-responsive-md table-striped text-center">'+
                              '<thead>'+
                                    '<tr>'+
                                      '<th class="text-center">SL.No</th>'+
                                      '<th class="text-center">Employee Code</th>'+
                                      '<th class="text-center">Name</th>'+
                                      '<th class="text-center">Designation</th>'+
                                      '<th class="text-center">Target</th>'+
                                      '<th class="text-center">Target Achieved</th>'+
                                    '</tr>'+
                              '</thead>'+
                              '<tbody>'+employee_list+
                                
                               '</tbody>'+
                              '</table>');
                        }else{
                            $('#body'+val.id).append('<div class="row"><div class="col-md-12 text-center"> This Task Is Not Assign To Employee Till Date.</div> </div>');
                        }  
                    });
                    
                    
                    
                    

                    
                  
                }else {
                   toastr.error(data.msg);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {

                callAjaxErrorFunction(jqXHR, textStatus, errorThrown);
            },
            complete: function (data) {
                $('.page-loader-wrapper').fadeOut();
            }
        });
     
     
 }   
    
<?php if($month): ?>  
    
  get_task_assigned_data(<?php echo e($month); ?>,<?php echo e($year); ?>,1,1);  
  get_task_wise_performance_data(<?php echo e($month); ?>,<?php echo e($year); ?>,1);  
    
<?php endif; ?>    
</script>
<?php endif; ?>
<?php $__env->stopSection(); ?>


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