<?php $__env->startSection('index-content'); ?>
<style>
    .modal-backdrop {
        z-index: 0;
    }
    .modal-open .modal {
      z-index: 9999;
  }
    .text-ur{
      text-orientation: upright;
    writing-mode: vertical-lr;
    }
    .table-responsive {
        width: 100%;
        height: 76vh;
    }
    th,
    td {
        padding: 3px;
        font-size: 13px;
    }
    table .tr1 td:first-child {
        position: sticky;
        width: 50px;
        left: 0;
        background: #fff;
        color: #000;
        z-index: 9;
    }
    table .tr1 td:nth-child(2) {
        position: sticky;
        left: 49px;
        background: #fff;
        color: #000;
        z-index: 9;
    }
    table tr th:first-child {
        position: sticky;
        width: 50px;
        left: 0;
        /*   background: #fff;*/
        color: #000;
        z-index: 10;
    }
    table tr th:nth-child(2) {
        position: sticky;
        left: 49px;
        /*   background: #fff !important;*/
        color: #000;
        z-index: 10;
    }
    tr.table-success {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #fff !important;
    }
    tr.table-success {
        top: 0px !important;
        position: sticky !important;
    }
    .table-success,
    .table-success > td,
    .table-success > th {
        background-color: #c3e6cb;
    } 
    
</style>
<div class="row px-3">


  <section role="main" class="content-body">
     <header class="page-header">
    <div class="row">
      <div class="col-lg-5">
        <h2>Gram Wise Approved Report</h2>  
      </div>
    
      <div class="col-lg-5">
        <ol class="breadcrumbs">
            <li>
              <a href="<?php echo e(url('index')); ?>">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <?php if($with_makername): ?>
             <li><a href="<?php echo e(url('/approved_districtwise_report')); ?>?with=makername"><span class="active"><?php echo e($district->parent_details->area_name??"District"); ?></span></li>
            <li><a href="<?php echo e(url('/approved_mandalwise_report')); ?>?with=makername&id=<?php echo e($district->parent_details->id); ?>"><span class="active"><?php echo e($district->area_name??"Mandal"); ?></span></a></li>
            <li><span class="active">Gram Panchayats</span></li>
            <?php else: ?>
            <li><a href="<?php echo e(url('approved_districtwise_report')); ?>"><span class="active"><?php echo e($district->parent_details->area_name??"District"); ?></span></li>
            <li><a href="<?php echo e(url('approved_mandalwise_report')); ?>?id=<?php echo e($district->parent_details->id); ?>"><span class="active"><?php echo e($district->area_name??"Mandal"); ?></span></a></li>
            <li><span class="active">Gram Panchayats</span></li>
            <?php endif; ?>
          </ol>
      </div>
      <div class="col-lg-2">
        <div class="back-btn-div">
          <button class="btn btn-primary back-btn" onclick="window.history.back()" style="margin-right: 25px;">Back</button>
        </div>
    </div>
  </header>
    <!-- <header class="page-header">
      <h2>Gram Wise Approved Report</h2>
    </header>
     <?php if($with_makername): ?>
    <div class="row">
      <div class="col-xs-12">
        <div class="right-wrapper">
          <ol class="breadcrumbs">
            <li>
              <a href="<?php echo e(url('index')); ?>">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><a href="<?php echo e(url('/approved_districtwise_report')); ?>?with=makername"><span class="active"><?php echo e($district->parent_details->area_name??"District"); ?></span></li>
            <li><a href="<?php echo e(url('/approved_mandalwise_report')); ?>?with=makername&id=<?php echo e($district->parent_details->id); ?>"><span class="active"><?php echo e($district->area_name??"Mandal"); ?></span></a></li>
            <li><span class="active">Gram Panchayats</span></li>
          </ol>
        </div>
      </div>
    </div>
    <?php else: ?>
     <div class="row">
      <div class="col-xs-12">
        <div class="right-wrapper">
          <ol class="breadcrumbs">
            <li>
              <a href="<?php echo e(url('index')); ?>">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><a href="<?php echo e(url('approved_districtwise_report')); ?>"><span class="active"><?php echo e($district->parent_details->area_name??"District"); ?></span></li>
            <li><a href="<?php echo e(url('approved_mandalwise_report')); ?>?id=<?php echo e($district->parent_details->id); ?>"><span class="active"><?php echo e($district->area_name??"Mandal"); ?></span></a></li>
            <li><span class="active">Gram Panchayats</span></li>
          </ol>
        </div>
      </div>
    </div> 

    </div>
    <?php endif; ?>-->


    <!-- start: page -->
    <section class="panel">
      <!-- <header class="panel-heading">
    
        <h4 class="my-0">Gram Wise Approved Report</h4>   
        <div class="back-btn-div">
          <button class="btn btn-primary back-btn" onclick="window.history.back()">Back</button>
        </div>
      </header>    <br> -->
    <form action="<?php echo e(url('updatephaseSignature')); ?>" method="post">
    <?php echo csrf_field(); ?>
    <div class="row">
      
      <div class="col-md-12 mt-2">
        <button class="btn btn-primary btn_click" type="submit" id="selectalls" disabled>Submit</button>

        <a target="_blank" class="btn btn-primary btn_click" href="<?php echo e(url('mandal_wise_report_list')); ?>?id=<?php echo e($district->id); ?>">Mandal Report By Selected GP'S</a>
        <a href="<?php echo e(url('/approved_gramwise_report')); ?>?with=makername&id=<?php echo e(Request::get('id')); ?>&mandalid=<?php echo e(Request::get('mandalid')); ?>&selected_date=<?php echo e(Request::get('selected_date')); ?>&to_date=<?php echo e(Request::get('to_date')); ?>" class="btn btn-primary">With Make Name</a>
        <a href="<?php echo e(url('/approved_gramwise_report')); ?>?id=<?php echo e(Request::get('id')); ?>&mandalid=<?php echo e(Request::get('mandalid')); ?>&selected_date=<?php echo e(Request::get('selected_date')); ?>&to_date=<?php echo e(Request::get('to_date')); ?>" class="btn btn-primary">Without Make Name</a>
      </div>
    </div>
    <!-- Static Table -->
      <!-- <div class="table-responsive mt-4">

        <table border="1" class="mb-3">
          <thead>
             <tr class="table-success">
                  <th style="white-space: pre-wrap;">Gram Wise Report</th>
                  <th>S.NO</th>
                  <th>Gram Name</th>
                  <th>Approved Date</th>
                  <th>Make Name</th>
                  <th>18&nbsp;W</th>
                  <th>35&nbsp;W</th>
                  <th>70&nbsp;W</th>
                  <th>110&nbsp;W</th>
                  <th>190&nbsp;W</th>
                  <th>Total</th>
                  <th>Action</th>
                  <th>Upload&nbsp;Files</th>
                  <th> Files&nbsp;Names</th>
                  <th>Signatures</th>
                  <th>Signature&nbsp;Dates</th>
              </tr>
          </thead>
          <tbody>
              <tr class="tr1">
                  <td rowspan="3">
                      <div>
                          <input type="checkbox" name="">
                      </div>
                  </td>
                  <td rowspan="3">1</td>
                  <td rowspan="3">Alimpur (Phase-1)</td>
                  <td rowspan="3">20/11/2022</td>
                  <tr>                      
                      <td>Bajaj</td>
                      <td>117</td>
                      <td>9</td>
                      <td>0</td>
                      <td>0</td>
                      <td>0</td>
                      <td>126</td>
                      <td rowspan="2">
                          <div>
                              <a target="_blank" href="" class="btn btn-primary mr-1 my-1">Survey&nbsp;View</a>

                              <a target="_blank" href="" class="btn btn-primary mr-1 my-1">DIC&nbsp;Installation</a>

                              <a target="_blank" href="" class="btn btn-primary mr-1 my-1">Material&nbsp;Handling</a>
                          </div>
                          <div>
                              <a target="_blank" class="btn btn-primary mr-1 my-1" href="" style="text-decoration: none; color: white;">Abstract&nbsp;Report</a>

                              <a target="_blank" class="btn btn-primary mr-1 my-1" href="" style="text-decoration: none; color: white;">GP&nbsp;Completion&nbsp;Report </a>

                              <a target="_blank" class="btn btn-primary mr-1 my-1" href="" style="text-decoration: none; color: white;">GP&nbsp;Cumulative&nbsp;Report</a>
                          </div>

                      </td>
                      <td rowspan="2">
                          <button type="button" class="btn btn-primary mr-1 my-1 btn_upload" id="btn_upload" data-target="#exampleModalLong" data-toggle="modal" data-id="">
                              Upload&nbsp;File
                          </button>
                      </td>
                      <td rowspan="2">abcd</td>
                      <td rowspan="2">
                          <button type="button" class="btn btn-primary mr-1 my-1 date_upload" id="date_upload" data-target="#exampleModal" data-toggle="modal">
                           Signature&nbsp;Date
                          </button>
                      </td>
                      <td rowspan="2">16/06/2023</td>
                  </tr>
                  <tr>                      
                      <td>Flux lite</td>
                      <td>117</td>
                      <td>9</td>
                      <td>0</td>
                      <td>0</td>
                      <td>0</td>
                      <td>126</td>
                  </tr>
              </tr>
              <tr>
                <td colspan="4">
                </td>
                <td>Total</td>
                <td><b>109</b></td>
                <td><b>15</b></td>
                <td><b>0</b></td>
                <td><b>0</b></td>
                <td><b>0</b></td>
                <td><b>124</b></td>
              </tr>
          </tbody>
        </table> 
        </div>   --> 

      <!-- End of Static Table -->

        <div class="table-responsive my-3">
      <?php if($with_makername): ?>      
      <table border="1" class="my-0">
         <thead>
         <tr class="table-success">
         
         

          <th style="white-space: pre-wrap;">Gram Wise Report</th>

          <!-- <th>Mandal Wise Report</th> -->
           <th>S NO</th>
           <th>Gram Name</th>
              <th>Last Date of Installation</th>
              <th>Approved Date</th>
               
           <th>Make Name</th>
           <th>18 W</th>
           <th>35 W</th>
           <th>70 W</th>
           <th>110 W</th>
           <th>190 W</th>
           <th>Total</th>
            <th>25 mm</th>
           <th>32 mm</th>
           <th>40 mm</th>
            <th>Total</th>
             
              <th class="text-ur">CCMS</th>
           <th style="width: 50px;">Cable  (1c x 10 sq.mm)</th>
           <th>Action</th>
           <th>Upload Files</th>
            <th> Files Names</th>
            <th>Signatures</th>
            <th>Signature Dates</th>
           
            
         </tr>
       </thead>
      <tbody>
       <?php $tvw1=0;$tvw2=0;$tvw3=0;$tvw4=0;$tvw5=0;$tvw6=0;$tvw7=0;$tvw8=0;$tvw9=0;$tvw10=0;$tcountarmvw=0;  $tcountvw=0;$countvw=0;$phaseids=[]; $i=0;?>
         <?php $__currentLoopData = $gramwise_report; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $report): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php $ww1=0;$ww2=0;$ww3=0;$ww4=0;$ww5=0; 
        $list=[];
        $query="";
        if(Request::get('selected_date')){
          $query = " and DATE(s.created_at) >='".date('Y-m-d',strtotime(Request::get('selected_date')))."' and DATE(s.created_at) <='".date('Y-m-d',strtotime(Request::get('to_date')))."'";
        } 
//                         $counts= DB::select("SELECT count(*) as count , pole_maker_name, 
// count(case pole_led_wattage  when '18 W'then 1 else null end)as w_18 ,
// count(case pole_led_wattage  when '35 W'then 1 else null end)as w_35 ,
// count(case pole_led_wattage  when '70 W'then 1 else null end)as w_70 ,
// count(case pole_led_wattage  when '110 W'then 1 else null end)as w_110 ,
// count(case pole_led_wattage  when '190 W'then 1 else null end)as w_190,
// count(case pole_type_of_arms  when '25mm Dia 1.2mt'then 1 else null end)as arm_25 ,
// count(case pole_type_of_arms  when '32mm Dia 1.2mt'then 1 else null end)as arm_32 ,
// count(case pole_type_of_arms  when '40mm Dia 1.2mt'then 1 else null end)as arm_40 
// FROM `pole_details` p INNER join survey_infos s on s.id=p.pole_id  where approve_status=1 ".$query." and gram_id=".$report->id." GROUP by pole_maker_name order by pole_maker_name");

 $counts= DB::select("SELECT count(*) as count , pole_maker_name,Max(s.created_at) as last_date, 
count(case pole_led_wattage  when '18 W'then 1 else null end)as w_18 ,
count(case pole_led_wattage  when '35 W'then 1 else null end)as w_35 ,
count(case pole_led_wattage  when '70 W'then 1 else null end)as w_70 ,
count(case pole_led_wattage  when '110 W'then 1 else null end)as w_110 ,
count(case pole_led_wattage  when '190 W'then 1 else null end)as w_190,
count(case pole_type_of_arms  when '25mm Dia 1.2mt'then 1 else null end)as arm_25 ,
count(case pole_type_of_arms  when '32mm Dia 1.2mt'then 1 else null end)as arm_32 ,
count(case pole_type_of_arms  when '40mm Dia 1.2mt'then 1 else null end)as arm_40 
FROM  survey_infos s INNER join pole_details b on s.id=b.pole_id  where s.gram_id=".$report->gram_id." and s.approve_status=1 and s.phase_no=".$report->phase_no." ".$query."   GROUP by b.pole_maker_name order by last_date DESC");




    $cable_used3 = DB::select("SELECT install_qty  
                                AS instaaa,cable_used AS cbl_used 
                                FROM ccms_types inner JOIN phases p on p.gram_id=ccms_types.gram_id and p.phase_no=ccms_types.phase_no inner JOIN area_masters m on m.id=ccms_types.gram_id  where ccms_types.gram_id=".$report->gram_id." ");
     $cable_used3_count=array_sum(array_column($cable_used3,'instaaa'));
     $cable_used4_count=array_sum(array_column($cable_used3,'cbl_used'));

 
                          
        $c = 1 ; $i++; $vw1=0;$vw2=0;$vw3=0;$vw4=0;$vw5=0;$vw6=0;$vw7=0;$vw8=0;$vw9=0;$vw10=0;$j=0;

                        ?>  <tr  class="tr1">  
                            <?php $c++; $tr=1;?>
                           <td rowspan="<?php echo e(count($counts)+1); ?>"><input type="checkbox"  <?php if($report->mandal_wise_gram ==1){echo 'checked';}?> class="mandal_wise_report" status="1" data-gram_id="<?php echo e($report->gram_id); ?>" data-phase="<?php echo e($report->phase_no); ?>"></td>
                            <td rowspan="<?php echo e(count($counts)+1); ?>"><?php echo e($i); ?></td> 
                            <td rowspan="<?php echo e(count($counts)+1); ?>"><?php echo e($report->area_name); ?> (Phase-<?php echo e($report->phase_no); ?>)</td>
                                      <td rowspan="<?php echo e(count($counts)+1); ?>"><?php if(isset($counts[0])): ?><?php echo e(Carbon\Carbon::parse($counts[0]->last_date)->format('d/m/Y')); ?> <?php endif; ?></td>
                                      <td rowspan="<?php echo e(count($counts)+1); ?>"> <?php echo e(Carbon\Carbon::parse($report->created_at)->format('d/m/Y')); ?></td>
                         
                            
                            </tr>
     <?php $__currentLoopData = $counts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 

                           <tr>
                             
                            <td><?php echo e($value->pole_maker_name); ?></td>
                            <td><?php $w1=isset($value->w_18)?$value->w_18:0?><?php echo e($w1); ?></td>
                            <td><?php $w2=isset($value->w_35)?$value->w_35:0?><?php echo e($w2); ?></td>
                            <td><?php $w3=isset($value->w_70)?$value->w_70:0?><?php echo e($w3); ?></td>
                            <td><?php $w4=isset($value->w_110)?$value->w_110:0?><?php echo e($w4); ?></td>
                            <td><?php $w5=isset($value->w_190)?$value->w_190:0?><?php echo e($w5); ?></td>
                                          
                            <td><b><?php $sumofmake=$w1+$w2+$w3+$w4+$w5;?><?php echo e($sumofmake??'0'); ?></b></td>
                             <td><?php $w6=isset($value->arm_25)?$value->arm_25:0?><?php echo e($w6); ?></td>
                            <td><?php $w7=isset($value->arm_32)?$value->arm_32:0?><?php echo e($w7); ?></td>
                            <td><?php $w8=isset($value->arm_40)?$value->arm_40:0?><?php echo e($w8); ?></td>
                            <td><b><?php $sumarmofmake=$w6+$w7+$w8;?><?php echo e($sumarmofmake??'0'); ?></b></td>
                             <?php if($tr==1): ?>
                              <td rowspan="<?php echo e(count($counts)+1); ?>"><?php $w9=isset($cable_used3_count)?$cable_used3_count:0?><?php echo e($w9); ?></td>
                            <td rowspan="<?php echo e(count($counts)+1); ?>"><?php $w10=isset($cable_used4_count)?$cable_used4_count:0?><?php echo e($w10); ?></td>
                             <?php $vw9=$w9+$vw9;
                                 $vw10=$w10+$vw10; ?>
                               <td rowspan="<?php echo e(count($counts)+1); ?>">
        <div class="d-flex">

          <a target="_blank" href="<?php echo e(url('displayallsearch')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary px-3 my-1" data-toggle="tooltip" data-placement="top" title="Survey View"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
           <a target="_blank" href="<?php echo e(url('dic_installation')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&from_date=<?php echo e(date('Y-m-d')); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary ml-1 px-3 my-1"  data-toggle="tooltip" data-placement="top" title="DIC Installation"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
           <a target="_blank" href="<?php echo e(url('display_materialhanding')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary px-3 ml-1 my-1" data-toggle="tooltip" data-placement="top" title="Material Handling"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
           
         
          </div>
          <div class="d-flex">
              <a target="_blank" class="btn btn-primary px-3 my-1" href="<?php echo e(url('abstractreport/'.$report->gram_id)); ?>?phase_no=<?php echo e($report->phase_no); ?>" data-toggle="tooltip" data-placement="top" title="Abstract Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
          
              <a target="_blank" class="btn btn-primary px-3 ml-1 my-1" href="<?php echo e(url('grampanchayat_completion')); ?>?id=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" data-toggle="tooltip" data-placement="top" title="GP Completion Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
              <a target="_blank" class="btn btn-primary px-3 ml-1 my-1" href="<?php echo e(url('phase_survey_report')); ?>?id=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" data-toggle="tooltip" data-placement="top" title="GP Cumulative Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a> 
          </div>

        </td>
        <td rowspan="<?php echo e(count($counts)+1); ?>">

              <button type="button" class="btn btn-primary px-3 my-1 btn_upload" id="btn_upload" data-target="#exampleModalLong" data-toggle="modal" data-id="<?php echo e($report->gram_id); ?>" data-toggle="tooltip" data-placement="top" title="  Upload File"><i class="fa fa-upload" aria-hidden="true"></i>
 
            </button>
        </td> 
        <td rowspan="<?php echo e(count($counts)+1); ?>"><?php echo e($report->signed_files??""); ?></td>
         <td rowspan="<?php echo e(count($counts)+1); ?>">

          <button type="button" class="btn btn-primary mr-1 my-1 date_upload" id="date_upload" data-target="#exampleModal" data-toggle="modal" data-id="<?php echo e($report->gram_id); ?>">
                             Sign Date
                          </button>
         </td>
         <td rowspan="<?php echo e(count($counts)+1); ?>"><?php if("0000-00-00" != $report->signature_date){echo $report->signature_date;} ?></td>
         <?php endif; ?>
                            <?php $tr++;
                                $vw1=$w1+$vw1;
                                $vw2=$w2+$vw2;
                                $vw3=$w3+$vw3;
                                $vw4=$w4+$vw4;
                                $vw5=$w5+$vw5;
                                $vw6=$w6+$vw6;
                                $vw7=$w7+$vw7;
                                $vw8=$w8+$vw8;
                                 
                            ?>

                      
                          
                            
                          </tr>  
                            
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
                         <tr></tr>   
                          <?php  $countvw= $vw1+$vw2+$vw3+$vw4+$vw5;
                                  $countarmvw= $vw6+$vw7+$vw8;
                        $tvw1=$vw1+$tvw1;
                                $tvw2=$vw2+$tvw2;
                                $tvw3=$vw3+$tvw3;
                                $tvw4=$vw4+$tvw4;
                                $tvw5=$vw5+$tvw5;
                                  $tvw6=$vw6+$tvw6;
                                $tvw7=$vw7+$tvw7;
                                $tvw8=$vw8+$tvw8;
                                $tvw9=$vw9+$tvw9;
                                $tvw10=$vw10+$tvw10;
                                $tcountvw= $tvw1+$tvw2+$tvw3+$tvw4+$tvw5;
                                $tcountarmvw= $tvw6+$tvw7+$tvw8;  ?>
                        <tr>

                        
                            <td colspan="5"><b></b></td>


                            <td><b>Total</b></td>
                            <td><b><?php echo e($vw1); ?></b></td>
                            <td><b><?php echo e($vw2); ?></b></td>
                            <td><b><?php echo e($vw3); ?></b></td>
                            <td><b><?php echo e($vw4); ?></b></td>
                            <td><b><?php echo e($vw5); ?></b></td>
                            <td><b><?php echo e($countvw); ?></b></td> 
                             <td><b><?php echo e($vw6); ?></b></td>
                            <td><b><?php echo e($vw7); ?></b></td>
                            <td><b><?php echo e($vw8); ?></b></td>
                            <td><b><?php echo e($countarmvw); ?></b></td> 
                             <td><b><?php echo e($vw9); ?></b></td>
                            <td><b><?php echo e($vw10); ?></b></td>
                           <td colspan="2"><b></b></td>
                            <td colspan="3"><b></b></td>
                            
                            

                       
       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       <tr>
        <td></td>
      
       
         <td colspan="5"><b>Total</b></td>

          <td><b><?php echo e($tvw1); ?></b></td>
          <td><b><?php echo e($tvw2); ?></b></td>
          <td><b><?php echo e($tvw3); ?></b></td>
          <td><b><?php echo e($tvw4); ?></b></td>
          <td><b><?php echo e($tvw5); ?></b></td>
          <td><b><?php echo e($tcountvw); ?></b></td>
            <td><b><?php echo e($tvw6); ?></b></td>
          <td><b><?php echo e($tvw7); ?></b></td>
          <td><b><?php echo e($tvw8); ?></b></td>
          <td><b><?php echo e($tcountarmvw); ?></b></td>
           <td><b><?php echo e($tvw9); ?></b></td>
          <td><b><?php echo e($tvw10); ?></b></td>

         <td colspan="5"><b></b></td>
          
         
          
       </tr>
     </tbody>


    </table>
  </div>
    <?php else: ?>
    

    <table border="1" class="my-0">
       <thead>
         <tr class="table-success">
          <th><input type="checkbox" name="" id="selectAll" style="width: 46px;"></th>
          <th>S.NO</th>
           <th>Gram Name</th>
          <th>Last Date of Installation</th>
           <th>Approved Date</th>
           
           <th>18 W</th>
           <th>35 W</th>
           <th>70 W</th>
           <th>110 W</th>
           <th>190 W</th>
           <th>Total</th>
           <th>25 mm</th>
           <th>32 mm</th>
           <th>40 mm</th>
            <th>Total</th>
            <th class="text-ur">CCMS</th>
           <th style="width: 50px;">Cable  (1c x 10 sq.mm)</th>
            <th>Action</th>
            <th>Upload Files</th>
                        <th> Files Names</th>
<th>Signatures</th>
            <th>Signature Dates</th>
         </tr>
       </thead>
       <tbody>
        <?php $tvw1=0;$tvw2=0;$tvw3=0;$tvw4=0;$tvw5=0;$tvw6=0;$tvw7=0;$tvw8=0;$tvw9=0;$tvw10=0;
        $tw1=0;$tw2=0;$tw3=0;$tw4=0;$tw5=0;$tw6=0;$tw7=0;$tw8=0;$tw9=0;$tw10=0;
        $tcountarmvw=0;  $tcountvw=0;$countvw=0;$countarmvw=0;$phaseids=[]; $i=0;?>
         <?php $__currentLoopData = $gramwise_report; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $report): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php $ww1=0;$ww2=0;$ww3=0;$ww4=0;$ww5=0; 
        $list=[];
        $query="";
        if(Request::get('selected_date')){
          $query = " and DATE(s.created_at) >='".date('Y-m-d',strtotime(Request::get('selected_date')))."' and DATE(s.created_at) <='".date('Y-m-d',strtotime(Request::get('to_date')))."'";
        } 
                        $counts= collect(DB::select("SELECT count(*) as count , pole_maker_name,Max(s.created_at) as last_date, 
count(case pole_led_wattage  when '18 W'then 1 else null end)as w_18 ,
count(case pole_led_wattage  when '35 W'then 1 else null end)as w_35 ,
count(case pole_led_wattage  when '70 W'then 1 else null end)as w_70 ,
count(case pole_led_wattage  when '110 W'then 1 else null end)as w_110 ,
count(case pole_led_wattage  when '190 W'then 1 else null end)as w_190,
count(case pole_type_of_arms  when '25mm Dia 1.2mt'then 1 else null end)as arm_25 ,
count(case pole_type_of_arms  when '32mm Dia 1.2mt'then 1 else null end)as arm_32 ,
count(case pole_type_of_arms  when '40mm Dia 1.2mt'then 1 else null end)as arm_40 
FROM  survey_infos s INNER join pole_details b on s.id=b.pole_id  where s.gram_id=".$report->gram_id." and s.approve_status=1 and s.phase_no=".$report->phase_no." ".$query."  GROUP by s.gram_id order by last_date DESC"))->first();

                       //dd($counts);

    $cable_used3 = DB::select("SELECT install_qty  
                                AS instaaa,cable_used AS cbl_used 
                                FROM ccms_types inner JOIN phases p on p.gram_id=ccms_types.gram_id and p.phase_no=ccms_types.phase_no inner JOIN area_masters m on m.id=ccms_types.gram_id  where ccms_types.gram_id=".$report->gram_id." and ccms_types.phase_no=".$report->phase_no." ");
     $cable_used3_count=array_sum(array_column($cable_used3,'instaaa'));
     $cable_used4_count=array_sum(array_column($cable_used3,'cbl_used'));


 
                          
        $c = 1 ; $i++; $vw1=0;$vw2=0;$vw3=0;$vw4=0;$vw5=0;$vw6=0;$vw7=0;$vw8=0;$vw9=0;$vw10=0;$j=0;

                        ?> 

 <tr>  
      <td>
        <!-- <?php echo $report->view;?> -->
        <input type="checkbox" name="phase[]" <?php if($report->view =="1"){echo 'checked';}?> onchange="check()" id="singcheck" value="<?php echo e($report->id); ?>">
        <?php $phaseids[$i] = $report->gram_id; ?>
      </td>
      <td><?php echo e($i); ?></td>
      <td><?php echo e($report->area_name); ?> (Phase-<?php echo e($report->phase_no); ?>)</td>
      <td><?php echo e((isset($counts->last_date))?Carbon\Carbon::parse($counts->last_date)->format('d/m/Y'):''); ?> </td>
       <td> <?php echo e(Carbon\Carbon::parse($report->created_at)->format('d/m/Y')); ?></td>
                         
    










                                          





     <td><?php $w1=isset($counts->w_18)?$counts->w_18:0?><?php echo e($w1); ?></td>
            <td><?php $w2=isset($counts->w_35)?$counts->w_35:0?><?php echo e($w2); ?></td>
           <td><?php $w3=isset($counts->w_70)?$counts->w_70:0?><?php echo e($w3); ?></td>
           <td><?php $w4=isset($counts->w_110)?$counts->w_110:0?><?php echo e($w4); ?></td>
          <td><?php $w5=isset($counts->w_190)?$counts->w_190:0?><?php echo e($w5); ?></td>
           <td><b><?php $sumofmake=isset($counts->count)?$counts->count:0?><?php echo e($sumofmake); ?></b></td>
                                          
         <td><?php $w6=isset($counts->arm_25)?$counts->arm_25:0?><?php echo e($w6); ?></td>
        <td><?php $w7=isset($counts->arm_32)?$counts->arm_32:0?><?php echo e($w7); ?></td>

        <td><?php $w8=isset($counts->arm_40)?$counts->arm_40:0?><?php echo e($w8); ?></td>
        <td><b><?php $sumarmofmake=$w6+$w7+$w8;?><?php echo e($sumarmofmake??'0'); ?></b></td>

    
       <td><?php $w9=isset($cable_used3_count)?$cable_used3_count:0?><?php echo e($w9??'0'); ?></td>
       <td><?php $w10=isset($cable_used4_count)?$cable_used4_count:0?><?php echo e($w10??'0'); ?></td>
    
      <td>
        <div class="d-flex">

          <a target="_blank" href="<?php echo e(url('displayallsearch')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary px-3 my-1" data-toggle="tooltip" data-placement="top" title="Survey View"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
           <a target="_blank" href="<?php echo e(url('dic_installation')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&from_date=<?php echo e($counts->last_date??''); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary ml-1 px-3 my-1" data-toggle="tooltip" data-placement="top" title="DIC Installation"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
            <a target="_blank" href="<?php echo e(url('display_materialhanding')); ?>?jillase=<?php echo e($report->super_id); ?>&&talukase=<?php echo e($report->parent_id); ?>&&gramse=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" class="btn btn-primary ml-1 px-3 my-1" data-toggle="tooltip" data-placement="top" title="Material Handling"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
         </div>
         <div class="d-flex">
          
            <a target="_blank" class="btn btn-primary px-3 my-1" href="<?php echo e(url('abstractreport/'.$report->gram_id)); ?>?phase_no=<?php echo e($report->phase_no); ?>"  data-toggle="tooltip" data-placement="top" title="Abstract Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
          
         
          <a target="_blank" class="btn btn-primary ml-1 px-3 my-1" href="<?php echo e(url('grampanchayat_completion')); ?>?id=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" data-toggle="tooltip" data-placement="top" title="GP Completion Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a>
          <a target="_blank" class="btn btn-primary ml-1 px-3 my-1" href="<?php echo e(url('phase_survey_report')); ?>?id=<?php echo e($report->gram_id); ?>&&phase_no=<?php echo e($report->phase_no); ?>" data-toggle="tooltip" data-placement="top" title="GP Cumulative Report"><i class="fa fa-file-pdf-o" aria-hidden="true"></i></a> 
          </div>
      </td>
       <td>


         <button type="button" class="btn btn-primary mr-1 my-1 btn_upload" id="btn_upload" data-target="#exampleModalLong" data-toggle="modal" data-id="<?php echo e($report->gram_id); ?>"  data-toggle="tooltip" data-placement="top" title="  Upload File"><i class="fa fa-upload" aria-hidden="true"></i>

            </button>
         </td> 
         <td><?php echo e($report->signed_files??""); ?></td>
          
         <td>

         <button type="button" class="btn btn-primary mr-1 my-1 date_upload" id="date_upload" data-target="#exampleModal" data-toggle="modal" data-id="<?php echo e($report->gram_id); ?>">
                             Signature&nbsp;Date
                          </button>
         </td>
           <td ><?php if("0000-00-00" != $report->signature_date){echo $report->signature_date;} ?></td>
          
                          
                         
       </tr>

       <?php 
       $tw1=$w1+$tw1;
       $tw2=$w2+$tw2;
       $tw3=$w3+$tw3;
       $tw4=$w4+$tw4;
       $tw5=$w5+$tw5;
       $tw6=$w6+$tw6;
        $tw7=$w7+$tw7;
        $tw8=$w8+$tw8;
        $tw9=$w9+$tw9;
       $tw10=$w10+$tw10;

         $tcountvw= $tw1+$tw2+$tw3+$tw4+$tw5;
        $tcountarmvw= $tw6+$tw7+$tw8; ?>
        
                         
       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       <tr>
         <td></td> 
         <td></td>
         <td></td>
         <td></td>
         <td><b>Total</b></td>
          <td><b><?php echo e($tw1); ?></b></td>
          <td><b><?php echo e($tw2); ?></b></td>
          <td><b><?php echo e($tw3); ?></b></td>
          <td><b><?php echo e($tw4); ?></b></td>
          <td><b><?php echo e($tw5); ?></b></td>
          <td><b><?php echo e($tcountvw); ?></b></td> 
       <td><b><?php echo e($tw6); ?></b></td>
        <td><b><?php echo e($tw7); ?></b></td>
           <td><b><?php echo e($tw8); ?></b></td>
          <td><b><?php echo e($tcountarmvw); ?></b></td>
            <td><b><?php echo e($tw9); ?></b></td>
          <td><b><?php echo e($tw10); ?></b></td>
          
       </tr>
      </tbody>


    </table>

    <?php endif; ?>
  <input type="hidden" name="phaseids" value="<?php echo implode(',', $phaseids);?>">
  </form>
  </div>



<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true" data-backdrop="static">

    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
          <div class="modal-header">

            <h5 class="modal-title" id="exampleModalLongTitle">Upload File</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
          </button>
      </div>
      <div class="modal-body">
        <form action="<?php echo e(url('uploadfilegram')); ?>" method="post"  enctype="multipart/form-data" >
            <?php echo csrf_field(); ?>

         <input type="hidden" name="district_id" value="<?php echo e(Request::get('id')); ?>">
         <input type="hidden" name="mandal_id" value="<?php echo e(Request::get('mandalid')); ?>">
         <input type="hidden" name="gram_id" id="gram_id" value="">
         <input type="hidden" name="type"  value="approved">
         

            <div class="form-group">
                <label for="files">File upload</label>

                <input type="file" class="form-control" name="files" id="files"  required=""  />
            </div>
           


            

            <div class="modal-footer px-0 border-top-0">
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Submit</button>
            </div>

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


<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true" data-backdrop="static">

    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
          
      <div class="modal-body">
        <form action="<?php echo e(url('approve_gramwise_report')); ?>" method="post"   >
            <?php echo csrf_field(); ?>
            <div class="form-group">
                <label for="signature_date">Signature Date</label>
                <input type="hidden"  id="id" name="id">
                <input type="date" class="form-control" name="signature_date" id="signature_date"   required=""  />
            </div>
            <div class="modal-footer px-0 border-top-0">
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Submit</button>
            </div>

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


  </section>
</section>

<script type="text/javascript">
$(document).ready(function(){
$(".btn_upload").on("click",function(){
   var id=$(this).data('id');
    $('#gram_id').val(id);

 });
  $('.mandal_wise_report').change(function(){
    var id=$(this).data('gram_id');
    var phase=$(this).data('phase');
    var status=0;
    if($(this).is(":checked")){
       status=1;
    }
        $.ajax({
        url: "<?php echo e(url('mandal_wise_report_grams')); ?>",
        type: "get",
        data: {id : id,phase:phase,status:status},
        dataType: "html",
        success: function(html){
          
        }
      });
  });
});

$(document).ready(function(){
$(".date_upload").on("click",function(){
   var id=$(this).data('id');
    $('#id').val(id);

 });
});
/*--------------------Signature---------------------------*/

$('#selectAll').click(function (e) {
    $(this).closest('table').find('td input:checkbox').prop('checked', this.checked);
  check();
});
$('#singcheck').click(function (e) {
    //$(this).closest('table').find('td input:checkbox').prop('checked', this.checked);
  check();
});
function check(){
  if($("#singcheck:checked").length  > 0) {
    $('#selectalls').removeAttr('disabled');
  }else{
    $('#selectalls').attr('disabled','disabled');
  } 
}
/*--------------------Signature---------------------------*/
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/neefc25/public_html/tgredco.fovea.in/resources/views/backend/reports/approved_gramwise_report.blade.php ENDPATH**/ ?>