<!DOCTYPE html>
<html>
<head>

  <title>Installment Report</title>


  <style type="text/css">

    
    *{

        margin: 0;
     }

     /* GENERAL CSS APPLY ALL SECTIONS*/


  *{
    margin: 0;
  /*  padding-top: 6px;*/
  }
  .margin{
    padding-top: 8px;
  }

  .title{

    text-align: center;
    font-weight: bold;
  }


  .container1{

    margin-left: 7%;
    margin-right: 5%; 
    
  }

  .image-section1{

    width: 100px;
    height: 100px;
    
    
    text-align: center;
    position: absolute;
    margin-left:  -5%;
/*    top:  -500%;*/
bottom:  10%;

    
  }

  .title1{

    text-align: center;
    margin-top: 2%;
    background: #a8a8a8;
    color: #fff;
    width: 30%;
    height: 2%;
    border-radius: 15px;
    vertical-align: middle;
    line-height: 29px;
    margin-left: 34.5%;
  }

  

  .clear{

    clear: both;
  }

  .top-section{
    margin-left: 4%;
  }

  input[type=text]
  {
    

    
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 1px solid;
    font-size: 8px;
    text-align: center;
    background-color: transparent;

  }

/*  #START=> APPARTMENT SECTION */
  .main-section .row .col{
    
  
    width: 25%;
    margin-right: 30px;
    padding-right: 10px;
    float: left;
  }

  .main-section .row{

    /*margin-left: 4%;*/


  }

  .main-section .col label{
    font-size: 8px;
    /*font-weight: bold;*/
  }

  

  .main-section .row .col .check{
    vertical-align: middle;
    margin-right:  90px; 
  }

/*  #END=> APPARTMENT SECTION */




  

  
/*  #END=> OFFICE USE SECTION */

/*  #START=>  IMAGE SECTION */

 .image-section{

    width: 85px;
    height: 85px;
    
    border: 1px solid #000;
    text-align: center;
    position: absolute;
    margin-left:  83%;
    top:  18%;

    
  }



  small{
    font-size: 8px;
    margin-left: 15;
  }

     .container{

        
     }


  </style>
</head>
<body style="margin:3% 4.5% 4% 4.5%;">

      @if($format)    
        @include('documents.report_logo')
      

       <br>
     @endif

@php($type_list = [])


     <div class="container">
        <div class="main-section">
           <center> <h3>INSTALLMENT REPORT</h3></center>
         
           
      <div class="row clear" style="margin-top:3%;">
         <b>  Title: {{$title}}</b>
          <table border="1" style="border-collapse: collapse;  text-align: center; width:100%; font-size:8pt;">
            <thead>
              <tr>
              <th  style="background: #E0E0E0; "></th>
               <th colspan = "7" style="background: #E0E0E0; ">Booking Details</th>

               @foreach($installment_type as $rows)
                @php($type_list[$rows->type_of_installment] = 0)
                <th colspan = "2" style="background: #E0E0E0; ">{{$rows->type_of_installment}} Due</th>
                  
                  
                  @endforeach
                <th style="background: #E0E0E0; "></th>
                
              </tr>
              <tr>

                 <th style ="width:5%;" >Sr. </th>
                 <th>App #</th>
                  <th>{{ucwords(str_replace('_',' ',EF::branchWhiteLabel()['module']))}}</th>

                  <th>Name</th>

                  <th>Contact</th>

                  <th>Booking Details</th>

                  <th>Size</th>



                  <th>Agreed Amount</th>


                  @foreach($installment_type as $rows)

                    <th>Amount</th>

                    <th>Due Date</th>

                  @endforeach


                  <th>Balance</th>
              </tr>
            </thead>

  @php($agreed_total = 0)
 
  @php($balance_total = 0)




            @foreach($installment_list as $rows)
  @php($date = Date('Y-m-d'));
  @php($operator = '<=');
  @php($latest_duedate = 0)
  @php($booking_received = $rows->sumOfReceivedInstallments($rows->booking_id))
  @php($balance = ($rows->booking->agreed_amount)-($booking_received))



            <tr>

              <td>{{$loop->iteration}}</td>
              <td>{{$rows->ms}}</td>
              <td>{{$rows->booking->branch->name}}</td>

              <td>{{$rows->name}}</td>
              <td>{{$rows->contact}}</td>
              <td>{{$rows->plot_id}} {{$rows->block_name}}</td>
              <td>{{$rows->size}}</td>
             
              <td>{{EF::numberFormat($rows->agreed_amount)}}</td>
 @php($due_total = 0)
              @foreach($installment_type as $type)
             @php($due_amount = $rows->getTypeWiseDue($rows->booking_id,$type->type_of_installment,$from,$to))
 
              <td>{{EF::numberFormat($due_amount)}}</td>
          <td>
          {{EF::dateFormat($rows->getTypeWiseDueDate($from,$to,$rows->booking_id,$type->type_of_installment))}}
        </td>
      
        @php($type_list[$type->type_of_installment] += $due_amount)
              @endforeach
       
              <td>{{EF::numberFormat($balance)}}</td>

  @php($agreed_total += $rows->agreed_amount)

  @php($balance_total += $balance)
            </tr>
            @endforeach
            <tr>
               <th colspan = "7" style="background: #E0E0E0; ">Total</th>
               <th style="background: #E0E0E0; ">{{EF::numberFormat($agreed_total)}}</th>
               @foreach($type_list as $key => $value)
              <th style="background: #E0E0E0; ">{{EF::numberFormat($value)}}</th>
               <th style="background: #E0E0E0; "></th>
               @endforeach
              <th style="background: #E0E0E0; ">{{EF::numberFormat($balance_total)}}</th>
                
                
            </tr>  
          </table>
      </div>   
        </div>
     </div>

</body>
</html>