@if($projectType->id == \App\ProjectType::society)
{{-- Development Charges --}}

<div class="col-lg-12">
    <div class="white-box1">
        <div class="table-responsive" style="clear: both;">
            <table  class="table table-bordered">
                <thead class="bg-color">
                    <tr style="text-align: center">
                        <th style="color: #fff;font-size: 13px;">Payment Head</th>
                        <th style="color: #fff;font-size: 13px;">Due Date</th>
                        <th style="color: #fff;font-size: 13px;">Due Amt.</th>
                        <th style="color: #fff;font-size: 13px;">Received Amt.</th>
                        <th class="no-print" style="color: #fff;font-size: 13px;">Balance</th>
                        <th style="color: #fff;font-size: 13px;">Payment Mode</th>
                        <!-- <th class="no-print">Detail</th> -->
                        <th style="color: #fff;font-size: 13px;">Receipt #</th>
                        <!-- <th>Ref#</th> -->
                        <th style="color: #fff;font-size: 13px;">Receipt Date</th>

                        <th style="color: #fff;font-size: 13px;">Surcharge Amt</th>
                        <th style="color: #fff;font-size: 13px;">Balance Amt.</th>
                        <!-- <th>Net Amt</th> -->
                    </tr>
                </thead>
                <tbody> 
                    <?php $development_due = 0;
                    $development_received = 0;
                    $development_balance = 0;
                    $development_surcharge = 0;
                    $development_net_payable = 0;
                    $count = 1;
                    $development_total = $property->development_fee;
                   
                     $otherArray = [];
                    ?>

                    @foreach($periorities as $periority)

                    @foreach($property->statement->where('payment_head',\App\CustomerStatement::development) as $development_statement)

                    @if($development_statement->due > 0 && ($development_statement->payment_head == $periority->payment_head ) || ($development_statement->payment_head == \App\CustomerStatement::other && !in_array($development_statement->payment_head , $otherArray)))

                        @php
                    
                    if($development_statement->payment_head == \App\CustomerStatement::other)
                    {
                      $otherArray[] = $development_statement->payment_head;
                    }
                  
                    @endphp
                    
                    @if($development_statement->balance > 0 && $development_statement->due_date < Carbon\Carbon::today())
                        <tr style="background-color: #e8e3c1;">
                    @else
                        <tr>
                    @endif

                    
                    
                   
                     @if($development_statement->payment_head == \App\CustomerStatement::development)
                    <td class="printFV">Development</td>
                    
                    @else
                    <td class="printFV"></td>
                    @endif

                        <!-- <td class="printFV">{{$development_statement->inst_no}}</td> -->
                        <td class="printFV">
                            {{date('d-m-Y', strtotime($development_statement->due_date)) }}

                            <!-- @if($development_statement->payment_head == \App\CustomerStatement::possession) 
                            <a href="JavaScript:void(0)" onclick="return changePossessionDate('{{$development_statement->id}}' , '{{date('Y-m-d', strtotime($development_statement->due_date)) }}');"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                             @endif -->
                             </td>
                        <td class="printFV text-right">{{number_format($development_statement->due)}}</td><?php $development_due += $development_statement->due; ?>
                        <td class="printFV text-right">
                            @if($development_statement->is_deleted == false){{number_format($development_statement->received)}}<?php $development_received += $development_statement->received; ?>
                        @else 
                        0
                        @endif
                    </td>
                     <td class="printFV no-print text-right">
                            @if($development_statement->is_deleted == false){{number_format($development_statement->balance)}}
                            @else
                            {{number_format($development_statement->due)}}
                        @endif
                    </td>

                        @if($development_statement->is_deleted == false)

                        @if($development_statement->receipt)

                        @if($development_statement->receipt->payment_method == \App\Receipt::cash)
                        <td>Cash</td>
                        @elseif($development_statement->receipt->payment_method == \App\Receipt::bank)
                        <td>Bank</td>
                        @elseif($development_statement->receipt->payment_method == \App\Receipt::adjustment)
                        <td>Adjustment</td>
                        @elseif($development_statement->receipt->payment_method == \App\Receipt::cheque)
                        <td>Cheque</td>
                        @elseif($development_statement->receipt->payment_method == \App\Receipt::merging)
                        <td>Merging</td>
                        @else
                        <td></td>
                        @endif
                            
                        @else
                        <td></td>
                        @endif
                        @else
                        <td></td>
                        @endif


                    
                        <td class="printFV">@if($development_statement->is_deleted == false) {{$development_statement->rcpt_no}} @endif</td>
                        <!-- <td class="printFV"> {{$development_statement->ref_no}} </td> -->
                        <td class="printFV text-right">@if($development_statement->is_deleted == false)  {{ $development_statement->rcpt_date ? date('d-m-Y', strtotime($development_statement->rcpt_date)) : '' }} @endif</td>


                        <td class="printFV text-right">{{number_format($development_statement->surcharge)}}
                            <?php $surcharge += $development_statement->surcharge; 
                        ?></td>

                        @if($development_statement->is_deleted == false)
                        @if($development_statement->received)
                        <?php $development_total -=$development_statement->received;?>
                        <td class="printFV text-right"> {{number_format($development_total)}}</td>
                        @else
                        <td class="printFV"></td>
                        @endif
                        @else
                        <td class="printFV"></td>
                        @endif
                        <!-- <?php $development_balance += $development_statement->balance; ?>-->


                        

                        
                    </tr>
                    @endif
                    @endforeach

                    @endforeach
                    <tr>
                        <td colspan="2" class="printFV text-center"><b>Total</b></td>
                        <td class="printFV text-right"><b>{{number_format($development_due)}}</b></td>
                        <td  class="printFV text-right"><b>{{number_format($development_received)}}</b></td>
                        <!-- <td colspan="3"></td> -->
                        <td colspan="5" class="printFV text-right">  Total WaveOff ({{$waiveOff}}) <b>{{number_format($development_surcharge - $waiveOff)}}</b></td>
                        <td  class="printFV text-right"><b>{{number_format($development_total)}}</b></td>

                        
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <br>

</div>
@endif
     {{-- End Development Charges --}}



     @if($projectType->id == \App\ProjectType::society)
     {{-- Development Charges --}}

     <div class="col-lg-12">
         <div class="white-box1">
             <div class="table-responsive" style="clear: both;">
                 <table  class="table table-bordered">
                     <thead class="bg-color">
                         <tr style="text-align: center">
                             <th style="color: #fff;font-size: 13px;">Payment Head</th>
                             <th style="color: #fff;font-size: 13px;">Due Date</th>
                             <th style="color: #fff;font-size: 13px;">Due Amt.</th>
                             <th style="color: #fff;font-size: 13px;">Received Amt.</th>
                             <th class="no-print" style="color: #fff;font-size: 13px;">Balance</th>
                             <th style="color: #fff;font-size: 13px;">Payment Mode</th>
                             <!-- <th class="no-print">Detail</th> -->
                             <th style="color: #fff;font-size: 13px;">Receipt #</th>
                             <!-- <th>Ref#</th> -->
                             <th style="color: #fff;font-size: 13px;">Receipt Date</th>

                             <th style="color: #fff;font-size: 13px;">Surcharge Amt</th>
                             <th style="color: #fff;font-size: 13px;">Balance Amt.</th>
                             <!-- <th>Net Amt</th> -->
                         </tr>
                     </thead>
                     <tbody> 
                         <?php $development_due = 0;
                         $development_received = 0;
                         $development_balance = 0;
                         $development_surcharge = 0;
                         $development_net_payable = 0;
                         $count = 1;
                         $development_total = $property->development_fee;
                        
                          $otherArray = [];
                         ?>

                         @foreach($periorities as $periority)

                         @foreach($property->statement->where('payment_head',\App\CustomerStatement::development) as $statement)

                         @if($statement->due > 0 && ($statement->payment_head == $periority->payment_head ) || ($statement->payment_head == \App\CustomerStatement::other && !in_array($statement->payment_head , $otherArray)))

                             @php
                         
                         if($statement->payment_head == \App\CustomerStatement::other)
                         {
                           $otherArray[] = $statement->payment_head;
                         }
                       
                         @endphp
                         
                         @if($statement->balance > 0 && $statement->due_date < Carbon\Carbon::today())
                             <tr style="background-color: #e8e3c1;">
                         @else
                             <tr>
                         @endif

                         
                         
                        
                          @if($statement->payment_head == \App\CustomerStatement::development)
                         <td class="printFV">Development</td>
                         
                         @else
                         <td class="printFV"></td>
                         @endif

                             <!-- <td class="printFV">{{$statement->inst_no}}</td> -->
                             <td class="printFV">
                                 {{date('d-m-Y', strtotime($statement->due_date)) }}

                                 <!-- @if($statement->payment_head == \App\CustomerStatement::possession) 
                                 <a href="JavaScript:void(0)" onclick="return changePossessionDate('{{$statement->id}}' , '{{date('Y-m-d', strtotime($statement->due_date)) }}');"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                                  @endif -->
                                  </td>
                             <td class="printFV text-right">{{number_format($statement->due)}}</td><?php $development_due += $statement->due; ?>
                             <td class="printFV text-right">
                                 @if($statement->is_deleted == false){{number_format($statement->received)}}<?php $development_received += $statement->received; ?>
                             @else 
                             0
                             @endif
                         </td>
                          <td class="printFV no-print text-right">
                                 @if($statement->is_deleted == false){{number_format($statement->balance)}}
                                 @else
                                 {{number_format($statement->due)}}
                             @endif
                         </td>

                             @if($statement->is_deleted == false)

                             @if($statement->receipt)

                             @if($statement->receipt->payment_method == \App\Receipt::cash)
                             <td>Cash</td>
                             @elseif($statement->receipt->payment_method == \App\Receipt::bank)
                             <td>Bank</td>
                             @elseif($statement->receipt->payment_method == \App\Receipt::adjustment)
                             <td>Adjustment</td>
                             @elseif($statement->receipt->payment_method == \App\Receipt::cheque)
                             <td>Cheque</td>
                             @elseif($statement->receipt->payment_method == \App\Receipt::merging)
                             <td>Merging</td>
                             @else
                             <td></td>
                             @endif
                                 
                             @else
                             <td></td>
                             @endif
                             @else
                             <td></td>
                             @endif


                         
                             <td class="printFV">@if($statement->is_deleted == false) {{$statement->rcpt_no}} @endif</td>
                             <!-- <td class="printFV"> {{$statement->ref_no}} </td> -->
                             <td class="printFV text-right">@if($statement->is_deleted == false)  {{ $statement->rcpt_date ? date('d-m-Y', strtotime($statement->rcpt_date)) : '' }} @endif</td>


                             <td class="printFV text-right">{{number_format($statement->surcharge)}}
                                 <?php $surcharge += $statement->surcharge; 
                             ?></td>

                             @if($statement->is_deleted == false)
                             @if($statement->received)
                             <?php $development_total -=$statement->received;?>
                             <td class="printFV text-right"> {{number_format($development_total)}}</td>
                             @else
                             <td class="printFV"></td>
                             @endif
                             @else
                             <td class="printFV"></td>
                             @endif
                             <!-- <?php $development_balance += $statement->balance; ?>-->


                             

                             
                         </tr>
                         @endif
                         @endforeach

                         @endforeach
                         <tr>
                             <td colspan="2" class="printFV text-center"><b>Total</b></td>
                             <td class="printFV text-right"><b>{{number_format($development_due)}}</b></td>
                             <td  class="printFV text-right"><b>{{number_format($development_received)}}</b></td>
                             <!-- <td colspan="3"></td> -->
                             <td colspan="5" class="printFV text-right">  Total WaveOff ({{$waiveOff}}) <b>{{number_format($development_surcharge - $waiveOff)}}</b></td>
                             <td  class="printFV text-right"><b>{{number_format($development_total)}}</b></td>

                             
                         </tr>
                     </tbody>
                 </table>
             </div>
         </div>
         <br>
     
     </div>
     @endif
          {{-- End Development Charges --}}