{assign var = tsrealestateunitspaids  value = 0}
{assign var = tcrealestateunitspaids  value = 0}
<div class="row" style="text-align: center;">
    <div class="col-lg-6">
               <h3>    المدفوع للمالك      :   <span id="tspaids"> {$tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-6">
            <h3 > التحصيل من المستأجرين   :  <span id="tcpaids"> {$tcrealestateunitspaids} </span></h3> 
    </div>
</div>  
<div class="row" style="text-align: center;">
      <h1 id="tcspaids"> {$tcrealestateunitspaids - $tsrealestateunitspaids} </h1> 
</div>  
<div class="row">
    <div class="col-lg-6">
        <h3 style="text-align:center;">المدفوع للمالك </h3>
        <table class="table table-bordered">
          {foreach $srealestateunitspaids as $srealestateunitspaid}
          <thead>
            <tr>
              <th scope="col">المالك</th>
              <th scope="col">العقار</th>
              <th scope="col">الايجار</th>
              <th scope="col">المدفوع</th>
              <th scope="col">المتبقى</th>
            </tr>
            
          </thead>
          <tbody>
            <tr>
              <td >{$srealestateunitspaid->supplier.suppliername}</td>
              <td>{$srealestateunitspaid->realestate->realestatename}</td>
              <td>{$srealestateunitspaid->valuerents}</td>
              <td>{$srealestateunitspaid->totalpaid}</td>
              <td>{$srealestateunitspaid->valuerents - $srealestateunitspaid->totalpaid}</td>
            </tr>
            <tr>
              <th scope="col" colspan="2">الايجار</th>
              <th scope="col" >التاريخ</th>
              <th scope="col">المدفوع</th>
              <th scope="col">المتبقى</th>
            </tr>
             {foreach $srealestateunitspaid->realestateunitpaidinstallments as $realestateunitpaidinstallment}
            <tr>
              <td colspan="2">{$realestateunitpaidinstallment->valuerent}</td>
              <td >{$realestateunitpaidinstallment->installmentdate}</td>
              <td >{$realestateunitpaidinstallment->totalpaid}</td>
              <td>{$realestateunitpaidinstallment->valuerent - $realestateunitpaidinstallment->totalpaid}</td>
            </tr>
            {/foreach}
            <tr>
                <td colspan="5" style="background:#ccc;text-align: center;">..............</td>
            </tr>
          </tbody>
           {assign  var = tsrealestateunitspaids value = $tsrealestateunitspaids + ($srealestateunitspaid->valuerents - $srealestateunitspaid->totalpaid)}
           {/foreach}
        </table>
        <h2 style="text-align:center;color:#2fa938">{$tsrealestateunitspaids}</h2>
    </div>
    <div class="col-lg-6">
        <h3 style="text-align:center;">التحصيل من  المستأجرين</h3>
        <table class="table table-bordered">
          {foreach $crealestateunitspaids as $crealestateunitspaid}
          <thead>
            <tr>
              <th scope="col">المستاجر</th>
              <th scope="col">العقار</th>
              <th scope="col">الايجار</th>
              <th scope="col">المدفوع</th>
              <th scope="col">المتبقى</th>
            </tr>
            
          </thead>
          <tbody>
            <tr>
              <td>{$crealestateunitspaid->client.clientname}</td>
              <td>{$crealestateunitspaid->realestate->realestatename} / {$crealestateunitspaid->realestatesunit->unitname}</td>
              <td>{$crealestateunitspaid->valuerents}</td>
              <td>{$crealestateunitspaid->totalpaid}</td>
              <td>{$crealestateunitspaid->valuerents - $crealestateunitspaid->totalpaid}</td>
            </tr>
              
            <tr>
              <th scope="col" colspan="2">الايجار</th>
              <th scope="col" >التاريخ</th>
              <th scope="col" >المدفوع</th>
              <th scope="col">المتبقى</th>
            </tr>
             {foreach $crealestateunitspaid->realestateunitpaidinstallments as $realestateunitpaidinstallment}
            <tr>
              <td colspan="2">{$realestateunitpaidinstallment->valuerent}</td>
              <td >{$realestateunitpaidinstallment->installmentdate}</td>
              <td >{$realestateunitpaidinstallment->totalpaid}</td>
              <td>{$realestateunitpaidinstallment->valuerent - $realestateunitpaidinstallment->totalpaid}</td>
            </tr>
            {/foreach}
            <tr>
                <td colspan="5" style="background:#ccc;text-align: center;">................</td>
            </tr>
          </tbody>
           {assign  var = tcrealestateunitspaids value = $tcrealestateunitspaids + ($crealestateunitspaid->valuerent - $crealestateunitspaid->totalpaid)}
           {/foreach}
        </table>
        <h2 style="text-align:center;color:#2fa938">{$tcrealestateunitspaids}</h2>

    </div>
</div>

<div class="row" style="text-align: center;">
    <div class="col-lg-6">
               <h3>    المدفوع للمالك      :   <span id="gtspaids"> {$tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-6">
            <h3 > التحصيل من المستأجرين   :  <span id="gtcpaids"> {$tcrealestateunitspaids} </span></h3> 
    </div>
</div>  


<div class="row" style="text-align: center;">
      <h1 id="gtcspaids"> {$tcrealestateunitspaids - $tsrealestateunitspaids} </h1> 
</div>  
