@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'))
@php($app_name ="Sky Lite")
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Confirmation of Allotment</title>


@if(EF::getUrl() != "letterdata")
<style type="text/css">
  

 .container{
  
  /*border: 1px solid #000;*/
  width: 100%;
  margin-left: 2%;
  margin-right: -15;
  margin-top:2%;
  font-size: 14px;
  font-family: "Calibri"!important;
  text-align: justify;
  text-justify:inter-word;
  line-height: 14pt;



 }
.letterimage
 {
 
    
    width:100px;
    height:100px; 
    border:1px solid;
    margin-top:-14px;


 }

  .right_div
 {
      float:right;
 }
 .date_style
 {
    margin-top: -41px;
    margin-right: 20px;
 }
 
.ref_style
 {
    
    margin-top: -25px;
    margin-right: 27px; 
 }

 .left_div
 {
      float:left;
 }
 .hrstyle
 {
     border: 1px solid black;
 }


 footer {
    position: fixed; 
    bottom: 160px !important; 
    left: 100px; 
    right: 20px;
}

.footerinfo{
    font-size: 14px;
    margin-left: 20px;
    padding-top: 5px;
    margin-bottom: 40px;
}

</style>
@endif

@if(EF::getUrl() == "letterdata")
<style type="text/css">
.letterimage
 {
 
  
    width:120px;
    height:100px; 
    border:1px solid;  
    margin-right:-109px;
   

 }
 .right_div
 {
      float:right;
 }

 .left_div
 {
      float:left;
 }
 .date_style
 {
    float:right;
    margin-top: -41px;
    margin-right: 20px;
 }
 .ref_style
 {
    float:right;
    margin-top: -25px;
    margin-right: 27px; 
 }
  .hrstyle
 {
     border: 1px solid black;
 }

 footer {
    position: fixed; 
    bottom: 2000px; 
    left: 100px; 
    right: 20px;
}

.footerinfo{
    font-size: 14px;
    margin-left: 20px;
    padding-top: 5px;
}

</style>
@endif

</head>
 
<body class="pdf-body" style="margin-top: 6%; margin-bottom: 10%;">
    
    @if(EF::getUrl() != "letterdata")
         <footer>
               <br>

            <hr align="left" width="25%" class = "hrstyle">
            <div>Authorised Signatory</div>
               <div>Skylite Builders</div>
           <div style="position:absolute;bottom:50px;right: 10px;">Date Printed: {{EF::dateFormat(date('d-M-Y'))}}</div>
        </footer>
    @endif
    <div class="container">
        @if(EF::getUrl() == "letterdata")
            <div class = "card  mb-2"  style = "width:850.92px; height:100%;   float: none;">
            <!-- @include('letters.header_letter') -->
        @endif
        <br><br>
        <div class = "row "  style =" text-align: justify;  margin-left: 5%; margin-right: 5%;  ">
            <div class = "col-md-12" >
                <!-- STRT -->
                <div class = "right_div" style="margin-top:30px">
                    <p style="line-height:25pt !important;" class = "date_style">{{EF::dateFormat($booking->created_at)}}</p>
                    <br>
                    @if(EF::getUrl() != "letterdata")
                        <br>
                    @endif
                    <p class=""><b>{{strtoupper($booking->ref)}}</b></p>
                    @if(!isset($co_owner->id))
                        <img style = "margin-left:30px; margin-top:0.5px;" class= "letterimage" src="{{ EF::getFile($user->dp) }}" >
                    
                        <p style = "  margin-top:-155px; margin-right:20px;"><b>Reg No: {{$booking->reference_number}}</b></p>
                    @else
                        <img  style = "width: 80px; margin-top:1px;" class= "letterimage" src="{{ EF::getFile($user->dp) }}" >
                        <img  style = "width: 80px; margin-top:1px;" class= "letterimage" src="{{ EF::getFile($co_owner->dp) }}" >
                        
                        <p style = "width:120px; margin-top:-155px; "><b style="word-wrap: normal;">Reg No: {{$booking->reference_number}}</b></p>
                    @endif
                </div>
                @if(!isset($co_owner->id))
                    <div style=" width: 80%; margin-right: 0px;">
                        <p style="width: 70%;">
                        @if($user->relation == "S/O") <b>MR.</b> @elseif($user->relation == "D/O") MISS. @else MRS. 
                        @endif {{strtoupper($user->name)}} <br>
                        @if($user->relation == "S/O")
                        <b>S / O</b> {{strtoupper($user->fname)}}  <br>
                        @elseif($user->relation == "D/O")
                        <b>D / O</b> {{$user->fname}}  <br>
                        @elseif($user->relation == "W/O")
                        <b>W / O</b> {{strtoupper($user->fname)}}  <br>
                        @else
                        <b>S / O</b> {{strtoupper($user->fname)}}  <br>
                        @endif
                        <b>CNIC NO : </b> {{$user->cnic}}  <br>
                        <b>Address : </b>{{$user->temp_address}}<br>

                        <b>Mobile:</b> {{$user->contact}} <br>
                        <b>Phone: </b> {{$user->other_contact}} <br>
                        </p>
                    </div>
                @else
                    <div style=" width: 35%;height: 224px; border:1px solid; display: inline-block;">
                        <span style="padding-left: 4px;padding-top: 4px;">
                            @if($user->relation == "S/O")Mr. @elseif($user->relation == "D/O") Miss. @else Mrs. 
                            @endif {{strtoupper($user->name)}}
                        </span> <br>
                        <span style="padding-left: 4px;">
                            @if($user->relation == "S/O")
                            S / O: {{strtoupper($user->fname)}}  <br>
                            @elseif($user->relation == "D/O")
                            D / O: {{strtoupper($user->fname)}}  <br>
                            @elseif($user->relation == "W/O")
                            W / O: {{strtoupper($user->fname)}}  <br>
                            @else
                            S / O: {{strtoupper($user->fname)}}  <br>
                            @endif
                        </span>
                        <span style="padding-left: 4px;">
                            CNIC NO: {{$user->cnic}}
                        </span><br>
                        <br>
                        <span style="padding-left: 4px;"> Mobile: {{$user->contact}}</span> <br>
                        <span style="padding-left: 4px;"> Phone:  {{$user->other_contact}}</span> <br>
                        <p style="width: 100%;padding-left: 4px;padding-right: 4px;word-spacing: normal;line-height: normal;margin-right: 3px;">Address: {{strtoupper($user->temp_address)}} </p> 
                        <br>
                    </div>

                    <div style=" width: 35%;height: 224px; border:1px solid; display: inline-block;">
                        <span style="padding-left: 4px;padding-top: 4px;">
                            @if($co_owner->relation == "S/O")Mr. @elseif($co_owner->relation == "D/O") Miss. @else Mrs. 
                            @endif {{strtoupper($co_owner->name)}}
                        </span><br>
                        <span style="padding-left: 4px;">
                            @if($co_owner->relation == "S/O")
                            S / O: {{strtoupper($co_owner->fname)}}  <br>
                            @elseif($co_owner->relation == "D/O")
                            D / O: {{strtoupper($co_owner->fname)}}  <br>
                            @elseif($co_owner->relation == "W/O")
                            W / O: {{strtoupper($co_owner->fname)}}  <br>
                            @else
                            S / O: {{strtoupper($co_owner->fname)}}  <br>
                            @endif
                        </span>
                        <span style="padding-left: 4px;"> CNIC NO: {{$co_owner->cnic}} </span> <br>
                        
                       <br>
                        <span style="padding-left: 4px;">Mobile: {{$co_owner->contact}}</span> <br>
                        <span style="padding-left: 4px;"> Phone:  {{$co_owner->other_contact}} </span> <br>
                        <p style="width: 100%;padding-left: 4px;padding-right: 4px;word-spacing: normal;line-height: normal;">Address: {{strtoupper($co_owner->temp_address)}} </p> 
                    </div>
                @endif
            </div>
            
            <div class = "subject_div">Subject: <b><u>CONFIRMATION OF ALLOTMENT - {{strtoupper($booking->branch->name)}}</u></b>
            </div>

            <div style = "line-height: 1rem;">
                <p style = "  font-family: Calibri Regular !important;"><b>Dear Sir/Madam,</b></p>
                <p>With reference to your application for booking of {{$plot->type}} in {{strtoupper($booking->branch->name)}} {{strtoupper($plot->location)}} We are pleased to inform you that your application has been approved. Your allotment details are mentioned below:</p>
                <p>Type: {{$plot->type}}, Category: {{strtoupper($plot->category)}},{{strtoupper($plot->feature_description)}},Registration no. {{$booking->reference_number}}
                    <br>
                    Size: {{strtoupper($plot->size)}}, Location:{{$plot->location}}
                </p>
             
            </div>
            <br>
            <div style="padding-left: 2px;">            
                <ul style="list-style-type: none; margin-top:-25px;">
                    <li><b>Total Price:</b> Rs. {{EF::numberFormat($plot->rate)}} <small>(Rupees {{EF::numberToWords($plot->rate)}})</small></li>
                    <li><b>Received Payment:</b> Rs. {{EF::numberFormat($balancedetail['debit'])}}  <small>(Rupees {{EF::numberToWords($balancedetail['debit'])}})</small></li>
                    <li><b>Balance Receivable: </b>Rs. {{EF::numberFormat($balancedetail['credit'])}}  <small>(Rupees {{EF::numberToWords($balancedetail['credit'])}})</small></li>
                    <li><b>Payment Term:</b> {{$payment_term}}</small></li>
                </ul>

                <br>

                <div style = "margin-top: -20px;">
                      
                    
                      @if(False && $booking->branch->id != 5)
                        <p style = "line-height: 1rem;">
                        The purchaser acknowledges that the Owner has determined the flat price on the bases of current rate of Rs.5,800 Per Sq Ft. Price of the flat will be adjusted at the time of completion on the bases of saleable premises area rate according to variation rise/fall due to the construction input market cost.
                        </p>

                        @endif


                    <p>This allotment is subject to the terms and conditions mentioned in the <b>RESERVATION FORM.</b> </p>
                    <!-- <p>As per our construction schedule we are planning to complete the construction of the {{strtoupper($booking->branch->name)}}, by {{EF::dateFormat($booking->branch->end_date)}}.</p> -->
                    <p>Therefore timely payment by the allottee is of vital importance.</p>
                
                    <p>The purchaser is responsible for following all the <b>organizational and governmental policies and taxes</b> as applicable from time to time.</p> 
                 
                    <!-- <p>We acknowledge the receipt of payments as mentioned below:</p> -->
                    <p style ="">Once again we congratulate you for the confirmation of the {{$plot->type}} and assure you the best of co-operation and services.Please don't hesitate to contact us if you have any further questions or queries.</p>
                </div>

                <br>
                <!-- <p>All Receipts are enclosed for your record.</p> -->
                <!-- <p>The purchaser is responsible for following all the <b>organizational and governmental policies and taxes</b> as applicable from time to time.</p> -->
                
                {{-- @if(EF::getUrl() != "letterdata")
                
                    <footer>
                        <div id="footer_info">
                            <div>Authorized Signature</div>
                            <div><u>  Skylite Builders</u></div>
                        </div>
                    </footer>
                
                @endif --}}

                @php($net_balance = 0)

                <div class="row clear" style="page-break-before: always;">
                    <div style="margin: 5%;"></div>

                    @if(EF::getUrl() != "letterdata")

                        <div class = "left_div">
                
                            @if($user->relation == "S/O")MR. @elseif($user->relation == "D/O")      MISS. @else MRS. @endif {{strtoupper($user->name)}} <br>
                                Father/Husband Name: {{strtoupper($user->fname)}}  <br>

                        </div>
                    @elseif(EF::getUrl() == "letterdata")
                        <div class = ""  style="margin-top:15px; margin-left:-65px; float:left !important;">
                        
                            @if($user->relation == "S/O")MR. @elseif($user->relation == "D/O") MISS. @else MRS. @endif {{strtoupper($user->name)}} <br>
                            Father/Husband Name: {{strtoupper($user->fname)}}  <br>

                        </div>
                    @endif

                          
             
                
                    @if(EF::getUrl() != "letterdata")

                        <div style="margin-top:7px" class="subject_div"><br><br>Subject: <b><u>            Installment Schedule</u></b>
                        </div>
                    @elseif(EF::getUrl() == "letterdata")
                        <div style="margin-top:30px; margin-left:-190px; float:left !important;">
                            <br><br>Subject:<b><u>Installment Schedule</u></b>
                        </div>
                    @endif

                    <div style = "line-height: 0.75rem; ">
                        <p style = "line-height: 0.75rem; margin-top:10px; font-family: Calibri Regular !important;"><b>Dear Sir/Madam,</b><br><br> <span style = "line-height: 1rem; ">Mentioned below is the Installment Schedule which is done to be followed strictly as per the payment due dates. This will help us to complete the project timely and secure you from the late paymet penalties, as per day terms and conditions.</span></p>
                    </div>

                <div class="" >
                    <h3><u>PAYMENT SCHEDULE</u></h3>
                    <table  border="0" style="border-collapse: collapse;
                    margin-bottom:20%; text-align: center; width:100%; font-size: 8.5pt;">
                        <thead>
                            <tr>
                                <th>Description</th>

                                <th>Amount</th>

                                <th>Due Date</th>

                                <th>Balance</th>

                                <th>Payment</th>

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

                        <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>{{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="6"></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>{{EF::numberFormat($rows->amount)}}</td>
                                        <td>{{EF::numberFormat($rows->received_amount)}}</td>


                                        @if($rows->received_amount > 0)

                                            @php($net_balance += ($rows->amount)-($rows->received_amount))

                                            <td>{{EF::numberFormat($net_balance)}}</td>

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

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

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

                                        @php($balance = $balance +(($rows->amount)-($rows->received_amount)))
                                    </tr>
                                @endif
                            @endforeach
                            <tr>
                                <th>Total Installment Amount</th>
                                <th>{{EF::numberFormat($totalamount)}}</th>
                                <th></th>

                                <th>{{EF::numberFormat($totalamount)}}</th>
                                <th>{{EF::numberFormat($received)}}</th>
                                <th>{{EF::numberFormat($balance)}}</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>{{EF::numberFormat($rows->amount)}}</td>
                                        <td>{{EF::numberFormat($rows->received_amount)}}</td>

                                        @if($rows->received_amount > 0)

                                            @php($net_balance += ($rows->amount)-($rows->received_amount))

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

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

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

                                        @php($balance = $balance +(($rows->amount)-($rows->received_amount)))

                                    </tr>
                                @endif
                            @endforeach

                            <!-- END OTHER PAYMENT SECTION -->
                        </tbody>
                    </table>
                </div>
                </div>

                <!-- END -->
            </div>
            @if(EF::getUrl() == "letterdata")
                <div class = "row">
                    <div class = "col-md-12" style ="text-align:center; margin-bottom:13%;">
                        <button type = "submit" style ="margin-top: 15%; font-size: 16px; font-weight: bolder; width:100%;" class = "btn btn-primary fa fa-print"> Print</button>
                    </div>
                </div>
            @endif

            

        </div>

      
    </div>  
</body>


</html>