<html>
<head>
    <title>Material Handing</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">


    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <style>
        body{
            font-family: 'Times New Roman';
            font-size: 20px;
        }
        @media print {
          @page {
            size: A4 potrait;
        }
        .print_action{display: none;}
        .page-break  
        {
            page-break-after: always !important;
        }  
    }
    select.form-control:not([size]):not([multiple]) {
        height: calc(1.25rem + 6px);
    }
    a#dashboard, button#print {
        background-color: #008CBA;
        padding: 10px 24px;
        border: none;
        font-weight: normal;
        margin-top: 10px;
    }   
    .text-uppercase {
        text-transform: uppercase
    }
    .heading{
        font-size: 20px;
        color: #000;
        font-weight: bold;
    }
    .sub-heading{
        font-size: 20px;
        color: #000;
        font-weight: bold;
    }
    .table-bordered td, .table-bordered th {
        border: 1px solid #d3d3d3;
    }
    .table{
        text-align: center;
    }
    .table td, .table th {
        padding: 18px 10px;
    }
    .table td{
        vertical-align: middle;
        font-size: 20px;
    }
    .table-bordered thead td, .table-bordered thead th {
        border-bottom-width: 1px;
    }
    .table thead th {
        border-bottom: 1px solid #000 !important;
    }
    .table td, .table th {
        border-top: 1px solid #000; 
    }
    .table-bordered td, .table-bordered th {
        border: 1px solid #000000;
    }
    *, ::after, ::before{
        box-sizing: content-box !important;
    }
</style>
</head>
<body>
    <div class="container pt-2">
        <div class="row px-4">
            
                <div class="col-2 offset-1 pl-2">
                    <a href="{{url('/survey_material_handing')}}" id="dashboard" class="print_action btn btn-primary text-decoration-none">Back To Dashboard</a>
                </div>
                <div class="col-6 pl-5" style="margin-top: 13px;">
                <?php if(isset($_GET['pedding']) && $_GET['pedding']!=""){}else{?>
                     <form action="{{url('display_materialhanding')}}" class="print_action" method="get">
                        <div class="row">
                            <div class="col-8 pr-2" style="padding-top: 1px;">
                                <input type="hidden" name="gramse" value="{{Request::get('gramse')}}">
                                <input type="hidden" name="jillase" value="{{Request::get('jillase')}}">
                                <input type="hidden" name="talukase" value="{{Request::get('talukase')}}">
                                     <select class="form-control" name="phase_no">
                                    <option value="">All Phases</option>
                                    @foreach($phase as $ph)
                                    <option value="{{$ph->phase_no}}" @if($request['phase_no']==$ph->phase_no) Selected @endif>Phase-{{$ph->phase_no}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-2 pl-2 text-right" style="padding-top: 1px;">
                                <button class="btn btn-primary print_action" type="submit">Search</button>
                            </div>
                        </div>
                    </form>
                <?php } ?>
                    
                </div>
                <div class="col-1 pl-5">
                    <button onclick="window.print();return false;"  class="print_action btn btn-info " id="print">Print</button>
                </div>
                
            </div>
            <?php
            $jillaname=$users->super_details?$users->super_details->area_name:"";
            $talukaname=$users->parent_details?$users->parent_details->area_name:"";
            $gramname=$users->area_name??"";

            ?>
        <div class="col-10 my-3 offset-1">

            <table class="table" border="1">
                <tr class="table-primary">
                    <th colspan="4" class="heading">TELANGANA GRAM PANCHAYATS MATERIAL HANDING OVER REPORT</th>
                </tr>
                <tr class="table-success">
                    <th colspan="2" class="heading">Date : &nbsp;&nbsp;{{isset($surveylastrecord)?date('d-m-Y',strtotime($surveylastrecord->created_at)):""}}</th>
                    <th colspan="2" class="heading">Gram Panchayat Name: &nbsp;&nbsp;&nbsp;{{$gramname}}</th>
                </tr>        
                <tr class="table-warning">
                    <th colspan="2" class="heading">Mandal Name: &nbsp;&nbsp;&nbsp;{{$talukaname}}</th>
                    <th colspan="2" class="heading">District Name: &nbsp;&nbsp;&nbsp;{{$jillaname}}</th>
                </tr>
                <tr class="table-danger">
                    <th class="sub-heading">Sl.No.</th>
                    <th class="sub-heading">Description of dismantled streetlights</th>
                    <th class="sub-heading">Quantity (nos.)</th>
                    <th class="sub-heading">Remarks, if any</th>

                </tr>
                <tbody>
                    <?php $sum=0; $i=1; $fixtures = ['FTL -40W','HPSV/MH Lamps -70W','HPSV/MH Lamps -150W','HPSV/MH Lamps -250W','HPSV/MH Lamps -400W','Any Other (CFL, Bulb etc)','Arms/Clamps/Cable','LED'];
                    $query="";
                    if($request->phase_no){
                        $query=" and phase_no=".$request->phase_no;
                    }
                    foreach ($fixtures as $key => $value) {
                        $name=$value;
                        if($value=="Any Other (CFL, Bulb etc)"){
                            $value="CFL (Bulb)";
                        }
                        if($value=="FTL -40W"){
                            $value="FTL";
                        }
                    }



$data= collect(DB::select("SELECT count(*) as count , 
count(case when pole_type_of_fixture LIKE '%FTL%' then 1 else null end)as f_40w,
count(case when pole_type_of_fixture LIKE '%HPSV/MH Lamps -70W%' OR pole_type_of_fixture LIKE '%HPSV/MH LAMPS-70W%' then 1 else null end)as hpsv_70w,
count(case when pole_type_of_fixture LIKE '%150W%' then 1 else null end)as hpsv_150w,
count(case when pole_type_of_fixture LIKE '%250W%' then 1 else null end)as hpsv_250w,
count(case when pole_type_of_fixture LIKE '%400W%' then 1 else null end)as hpsv_400w,
count(case when pole_type_of_fixture LIKE '%Arms%' then 1 else null end)as arms_cb,
count(case when pole_type_of_fixture LIKE '%LED%' then 1 else null end)as p_led,
count(case when pole_type_of_fixture LIKE '%CFL%' then 1 else null end)as any_clf
FROM `pole_details` p INNER join survey_infos s on s.id=p.pole_id   where s.gram_id=".$users->id.$query))->first();
 //dd($data);




                        ?>
                        <tr>
                            <td>1</td>
                            <td>FTL -40W</td>
                            <td><?php $w1=isset($data->f_40w)?$data->f_40w:0?>{{$w1}}</td>
                            <td>N/A</td>
                        </tr>
                        <tr>
                            <td>2</td>
                            <td>HPSV/MH Lamps -70W</td>
                            <td><?php $w2=isset($data->hpsv_70w)?$data->hpsv_70w:0?>{{$w2}}</td>
                            <td>N/A</td>
                        </tr>
                        <tr>
                            <td>3</td>
                            <td>HPSV/MH Lamps -150W</td>
                            <td><?php $w3=isset($data->hpsv_150w)?$data->hpsv_150w:0?>{{$w3}}</td>
                            <td>N/A</td>
                        </tr>
                        <tr>
                            <td>4</td>
                            <td>HPSV/MH Lamps -250W</td>
                            <td><?php $w4=isset($data->hpsv_250w)?$data->hpsv_250w:0?>{{$w4}}</td>
                            <td>N/A</td>
                        </tr>
                        <tr>
                            <td>5</td>
                            <td>HPSV/MH Lamps -400W</td>
                            <td><?php $w5=isset($data->hpsv_400w)?$data->hpsv_400w:0?>{{$w5}}</td>
                            <td>N/A</td>
                        </tr>
                        <tr>
                            <td>6</td>
                            <td>Any Other (CFL, Bulb etc)</td>
                            <td><?php $w6=isset($data->any_clf)?$data->any_clf:0?>{{$w6}}</td>
                            <td>N/A</td>
                        </tr>
                         <tr>
                            <td>7</td>
                            <td>Arms/Clamps/Cable</td>
                            <td><?php $w7=isset($data->arms_cb)?$data->arms_cb:0?>{{$w7}}</td>
                            <td>N/A</td>
                        </tr>
                         <tr>
                            <td>8</td>
                            <td>LED</td>
                            <td><?php $w8=isset($data->p_led)?$data->p_led:0?>{{$w8}}</td>
                            <td>N/A</td>
                        </tr>

                <?php $total=$w1+$w2+$w3+$w4+$w5+$w6+$w7+$w8;?>

                      

                        <tr>
                            <td></td>
                            <td><b>Total</b></td>
                            <td>{{$total??'0'}}</td>
                            <td></td>
                        </tr>
                    </tbody>
                    

                </table>
            </div>

            <div class="col-10 offset-1">
                <div class="mb-4">This is to certify that the balance old clamps and arms upon the poles if any are the property of the Gram Panchayats and deemed to be advised for not to remove the existing clamps and arms for the GPs internal use.</div>
            </div>
            <div class="col-10 my-3 offset-1">

                <table class="table table-bordered">
                    <tr><th class="heading text-left">Remarks: </th></tr>
                </table>
            </div>
            <div class="col-10 my-3 offset-1 pt-3">
                <table border="1"class="table table-bordered">
                    <tr>
                        <th class="heading text-left">Material handed over by</th>
                        <th class="heading text-left">Verified by</th>
                        <th class="heading text-left">Material handed over to</th>
                    </tr>  
                    <tr>
                        <th class="heading text-left">Vendor's Representative</th>
                        <th class="heading text-left">TSREDCO Representative</th>
                        <th class="heading text-left">Panchayat Secretary </th>

                    </tr>
                    <tr>
                        <th class="sub-heading text-left">Name : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Name : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Name : &nbsp;&nbsp;&nbsp;</th>

                    </tr>
                    <tr>
                        <th class="sub-heading text-left">Designation : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Designation : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Designation : &nbsp;&nbsp;&nbsp;</th>

                    </tr>
                    <tr>
                        <th class="sub-heading text-left">Signature : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Signature : &nbsp;&nbsp;&nbsp;</th>
                        <th class="sub-heading text-left">Signature : &nbsp;&nbsp;&nbsp;</th>

                    </tr>
                </table>
               
            </div>
        </div>
    </div>
    </body>
    </html>