@php($message = 'Booking Form against booking details (Article Name:"'.$booking->plot->plot_id.' "Type:" '.$booking->plot->type .'") has been viewed')
    @php(EF::createLogs($message,'document'))
<!DOCTYPE html>
<html>
<head>

  <title>Payment Schedule</title>


  <style type="text/css">


    *{

        margin: 0;
     }

     /* GENERAL CSS APPLY ALL SECTIONS*/


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

  .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: 12px;
    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: 8.5pt;
    /*font-weight: bold;*/
  }

  label,span{
    font-size: 8.5pt;

  }



  .main-section .row .col .check{
    vertical-align: middle;
    margin-top: 10px;
    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: 12px;
    margin-left: 15;
  }

     .container{


     }


  </style>
</head>

<body style="margin:3% 7.5% 4% 7.5%;">

      <header>
        <div  class="header">
           <center>  <img src="graphics/logo/logo.jpg" width="10%" height="0.05%" />
           <br><strong>Payment Schedule</strong> </center>
        </div>
      </header>


     <div class="container">
        <div class="main-section">

    <!-- CUSTOMER SECTION -->
        <!-- ROW-1 -->




    <div class="row clear margin">


          <div class="col margin" style="width: 31%">
            <label>Customer Name: <span style="margin-left: 25%;">{{ucfirst($user->name)}}</span></label>
          </div>

          @if($user->relation == 'S/O')
           <div class="col margin" style="width: 45%">
            <label>S / O: <span style="margin-left: 25%;">{{ucfirst($user->fname)}}</span></label>
          </div>
          @elseif($user->relation == 'D/O')
          <div class="col margin" style="width: 45%">
            <label>D / O: <span style="margin-left: 25%;">{{ucfirst($user->fname)}}</span></label>
          </div>
          @elseif($user->relation == 'W/O')
          <div class="col margin" style="width: 45%">
            <label>W / O: <span style="margin-left: 25%;">{{ucfirst($user->fname)}}</span></label>
          </div>
          @else
           <div class="col margin" style="width: 44%">
            <label>S / O: <span style="margin-left: 25%;">{{ucfirst($user->fname)}}</span></label>
          </div>
          @endif

      </div>



      <div class="row clear margin">


          <div class="col margin" style="width: 31%">
            <label>Customer Code: <span style="margin-left: 26%;">{{$user->code}}</span></label>
          </div>

          <div class="col margin" style="width: 80%">
            <label>Address: <span style="margin-left: 19%;">{{$user->per_address}}</span></label>
          </div>

      </div>

      <div class="row clear margin">


          <div class="col margin" style="width: 31%">
            <label>Registration Number: <span style="margin-left: 17%;">{{$booking->ms}}</span></label>
          </div>

          <div class="col margin" style="width: 31%">
            <label>Sale Price: <span style="margin-left: 46%;">{{EF::numberFormat($booking->agreed_amount)}}</span></label>
          </div>

      </div>




    <!-- END CUSTOMER SECTION -->

{{--
      @include('documents.customer_info')
      @include('documents.plot_info')
--}}

  @php($net_balance = 0)

      <div class="row clear">
          <table  border="0" style="border-collapse: collapse; margin-top:3%; text-align: center; width:100%; font-size: 8.5pt;">
            <thead>

              <tr>

                 <th>Description</th>

                  <th>Amount</th>

                  <th>Due Date</th>

                  <th>Delay (days)</th>

                  <th>Penalty</th>

                  <th>Balance</th>

                  <th>Payment</th>

                  <th>Net Balance</th>




              </tr>
              <tbody>
                @php ($totalamount = 0)
                @php($received = 0)
                @php($balance = 0 )
                @php($short = 0)

          <!-- DOWN PAYMENT SECTION -->
          @foreach($installment as $rows)
            @if($rows->type_of_installment === "Down Payment")
              <tr>
                 <td>{{$rows->description}} </td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::dateFormat($rows->due_date)}}</td>
                 <td>0</td>
                 <td>0</td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::numberFormat($rows->received_amount)}}</td>


                  <td>{{EF::numberFormat(($rows->amount)-($rows->received_amount))}}</td>






              </tr>
            @endif
          @endforeach
          <tr>
                <th>Total Down Payment</th>
                <th colspan="8"></th>


          </tr>
          <!-- END DOWN PAYMENT SECTION -->

          <!-- INSTALLMENT SECTION -->
          @foreach($installment as $rows)
            @if($rows->type_of_installment === "Installment")
              <tr>
                 <td>{{$rows->description}} </td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::dateFormat($rows->due_date)}}</td>
                 <td>0</td>
                 <td>0</td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::numberFormat($rows->received_amount)}}</td>
                 <td>{{EF::numberFormat(($rows->amount)-($rows->received_amount))}}</td>





                @php($totalamount += $rows->amount))

                @php($received += $rows->received_amount)



              </tr>
            @endif
          @endforeach
          <tr>
                <th>Total Installment Amount</th>
                <th>{{EF::numberFormat($totalamount)}}</th>
                <th></th>
                <th>0</th>
                <th>0</th>
                <th>{{EF::numberFormat($totalamount)}}</th>
                <th>{{EF::numberFormat($received)}}</th>
                <th>{{EF::numberFormat($totalamount - $received)}}</th>
          </tr>
          <!-- END INSTALLMENT PAYMENT SECTION -->

          <!-- OTHER PAYMENT SECTION -->
          @foreach($installment as $rows)
            @if($rows->type_of_installment != "Installment" && $rows->type_of_installment != "Down Payment")
              <tr>
                 <td>{{$rows->description}} </td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::dateFormat($rows->due_date)}}</td>
                 <td>0</td>
                 <td>0</td>
                 <td>{{EF::numberFormat($rows->amount)}}</td>
                 <td>{{EF::numberFormat($rows->received_amount)}}</td>
                      <td>{{EF::numberFormat(($rows->amount)-($rows->received_amount))}}</td>







              </tr>
            @endif
          @endforeach

          <!-- END OTHER PAYMENT SECTION -->


        </tbody>
            </thead>
          </table>
      </div>


              <!-- INSTALLMENT PLAN -->

        </div>
     </div>

     <div style="page-break-before: always;">
       <header>
        <div  class="header">
           <center>  <img src="graphics/logo/logo.jpg" width="10%" height="0.05%" />
           <br><strong>Receipt Detail</strong> </center>
        </div>
      </header>


     <div class="container">
        <div class="main-section">

    <!-- CUSTOMER SECTION -->
        <!-- ROW-1 -->




    <div class="row clear margin">


          <div class="col margin" style="width: 85%">
            <label>{{$user->name}}</label>
          </div>

          <div class="col margin" style="width: 25%">
            <label>Date: <span >{{EF::dateFormat(date('y-m-d'))}}</span></label>
          </div>



      </div>

      <div class="row clear margin">




          <div class="col margin" style="width: 85%">
            <label>Father Name: <span >{{$user->fname}}</span></label>
          </div>

          <div class="col margin" style="width: 25%">
            <label>Customer Code: <span >{{$user->code}}</span></label>
          </div>

      </div>

      <div class="row clear margin">




          <div class="col margin" style="width: 85%">

          </div>

          <div class="col margin" style="width: 25%">
            <label style="font-weight: bolder;">Reg No: <span >{{$booking->ms}}</span></label>
          </div>

      </div>








    <!-- END CUSTOMER SECTION -->

    <div class="row margin clear">

      <div class="col" style="width: 100%;">
        <table  border="0" style="border-collapse: collapse; margin-top:3%; text-align: center; width:100%; font-size: 8.5pt;">
          <thead>
            <tr>
            <th>Receipt No</th>
            <th>Date</th>

            <th>Ch #</th>

            <th>Drawn On</th>

            <th>Amount</th>
          </tr>

          </thead>
          <tbody>
            @php($reversal_amount = 0)
            @php($approval_amount = 0)

             @php($check_list = ["Installment","Commission","Transfer","Refund","Deduction","Document Charges","Baloon Charges"])
              @foreach($receipt_list as $rows)
                  @if(in_array($rows->payment_type,$check_list))

                    <tr style="@if($rows->status === 'Reversal') background: #F1F1F1; @endif">
                      <td>{{$rows->receipt_no}}</td>
                      <td>{{EF::dateFormat($rows->created_at)}}</td>
                      @if($rows->mode == 'Cash')
                      <td>Cash</td>
                      @else
                      <td>{{$rows->instrument}}</td>
                      @endif
                      <td>{{$rows->drawn_on}}</td>
                      <td>{{EF::numberFormat($rows->amount)}} {{EF::numberToWords($rows->amount)}}</td>
                    </tr>

                    @if($rows->status === 'Reversal')

                        @php($reversal_amount += $rows->amount)

                    @else

                        @php($approval_amount += $rows->amount)

                    @endif
                  @endif
              @endforeach
          </tbody>
          <tfoot>
            <tr style="font-weight: bolder;  ">
                      <td colspan="5">Total: [Debit:{{EF::numberFormat($approval_amount)}} - Credit:{{EF::numberFormat($reversal_amount)}}] = {{EF::numberFormat(($approval_amount - $reversal_amount))}}  </td>

                    </tr>
          </tfoot>
        </table>
      </div>

    </div>


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

</body>
</html>
