{assign var = tsrealestateunitspaids  value = 0}
{assign var = tcrealestateunitspaids  value = 0}
{assign var = texpenses  value = 0}
{assign var = trestaurantrawdestruction  value = 0}



<div class="row" style="text-align: center;">
    <div class="col-lg-3">
               <h3>    المدفوع للمالك      :   <span id="tspaids"> {$tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-3">
              <h3>    المصروفات     :  <span id="tepaids">{$texpenses - $tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-3">
              <h3>  الاهلاكات     : <span id="trpaids">{$trestaurantrawdestruction} </span></h3> 
    </div>
    <div class="col-lg-3">
            <h3 > التحصيل من المستأجرين   :  <span id="tcpaids"> {$tcrealestateunitspaids} </span></h3> 
    </div>
</div>  


<div class="row" style="text-align: center;">
      <h1 id="tcspaids"> {$tcrealestateunitspaids - ($tsrealestateunitspaids - $texpenses)} </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>
            </tr>
            
          </thead>
          <tbody>
            <tr>
              <td >{$srealestateunitspaid->supplier.suppliername}</td>
              <td>{$srealestateunitspaid->realestate->realestatename}</td>
            </tr>
             <tr>
              <th scope="col">الايجار</th>
              <th scope="col">المدفوع</th>
            </tr>
             <tr>
              <td>{$srealestateunitspaid->valuerents}</td>
              <td>{$srealestateunitspaid->totalpaid}</td>
            </tr>

              
            <tr>
              <!-- <th>الاقسط</th> -->
              <!-- <th>المدفوع</th> -->
              <th>التاريخ</th>
              <th>الدفع</th>
            </tr>
            <tr>
              <td >المقدم</td>
              <td>{$srealestateunitspaid->advancepayment}</td>
            </tr>
             {foreach $srealestateunitspaid->realestateunitpaidinstallments as $realestateunitpaidinstallment}
            <tr>
              <!-- <td >{$realestateunitpaidinstallment->valuerent}</td> -->
              <!-- <td >{$realestateunitpaidinstallment->totalpaid}</td> -->
              <td >{$realestateunitpaidinstallment->installmentdate}</td>
             <!--  <td >{if $realestateunitpaidinstallment->payed gt 1}
                    تم الدفع
                   {else}
                   {$realestateunitpaidinstallment->valuerent - $realestateunitpaidinstallment->totalpaid}
                    
                   {/if}
              </td> -->
               <td >
                    {$realestateunitpaidinstallment->totalpaid}
              </td>
            </tr>
            

            {/foreach}
            <tr>
                <td colspan="4" style="background:#ccc;text-align: center;">{$srealestateunitspaid->totalpaid}</td>
            </tr>
          </tbody>
           {assign  var = tsrealestateunitspaids value = $tsrealestateunitspaids + $srealestateunitspaid->totalpaid}
           {/foreach}
        </table>
        <h2 style="text-align:center;color:#2fa938">{$tsrealestateunitspaids}</h2>






        <h3 style="text-align:center;">المصروفات    </h3>
        <table class="table table-bordered">
          {foreach $expenses as $expense}
          <thead>
            <tr>
                <th scope="col">العقار</th>
                <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 >{$expense.realestatename}</td>
              <td >{$expense.unitname}</td>
              <td >{$expense.expensestypename}</td>
              <td >{$expense.expensesname}</td>
              <td >{$expense.expensesValue}</td>
              <td >{$expense.expensesdate}</td>
            </tr>
             <tr>
                <td colspan="6" style="background:#ccc;text-align: center;">{$expense.expensesValue}</td>
            </tr>
          </tbody>
           {assign  var = texpenses value = $texpenses + $expense.expensesValue}
           {/foreach}
        </table>
        <h2 style="text-align:center;color:#2fa938">{$texpenses}</h2>


        <h3 style="text-align:center;">الاهلاكات    </h3>
        <table class="table table-bordered">
          {foreach $restaurantrawdestruction as $restaurant}
          <thead>
            <tr>
                <th scope="col">العقار</th>
                <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 >{$restaurant.realestatename}</td>
              <td >{$restaurant.unitname}</td>
              <td >{$restaurant.productName}</td>
              <td >{$restaurant.quantitynew}</td>
              <td >{$restaurant.buypricenew * $restaurant.quantitynew} </td>
              <td >{$restaurant.sysdate}</td>
            </tr>
             <tr>
                <td colspan="6" style="background:#ccc;text-align: center;">{$restaurant.buypricenew * $restaurant.quantitynew}</td>
            </tr>
          </tbody>
           {assign  var = trestaurantrawdestruction value = $trestaurantrawdestruction + ($restaurant.buypricenew * $restaurant.quantitynew)}
           {/foreach}
        </table>
        <h2 style="text-align:center;color:#2fa938">{$trestaurantrawdestruction}</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>
            </tr>
            
          </thead>
          <tbody>
            <tr>
              <td >{$crealestateunitspaid->client.clientname}</td>
              <td>{$crealestateunitspaid->realestate->realestatename}</td>
            </tr>
             <tr>
              <th scope="col">الايجار</th>
              <th scope="col">المدفوع</th>
            </tr>
             <tr>
              <td>{$crealestateunitspaid->valuerents}</td>
              <td>{$crealestateunitspaid->totalpaid}</td>
            </tr>

              
            <tr>
              <th>الوحده   / التاريخ</th>
              <th>الدفع</th>
            </tr>
            <tr>
              <td >المقدم</td>
              <td>{$crealestateunitspaid->advancepayment}</td>
            </tr>
             {foreach $crealestateunitspaid->realestateunitpaidinstallments as $realestateunitpaidinstallment}
            <tr>
              <td > {$crealestateunitspaid->realestatesunit->unitname}  / {$realestateunitpaidinstallment->installmentdate}</td>
               <td >
                    {$realestateunitpaidinstallment->totalpaid}
              </td>
            </tr>
            

            {/foreach}
            <tr>
                <td colspan="4" style="background:#ccc;text-align: center;">{$crealestateunitspaid->totalpaid}</td>
            </tr>
          </tbody>
      {assign  var = tcrealestateunitspaids value = $tcrealestateunitspaids + $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-3">
               <h3>    المدفوع للمالك      :   <span id="gtspaids"> {$tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-3">
              <h3>    المصروفات     :   <span id="gtepaids">{$texpenses - $tsrealestateunitspaids} </span></h3> 
    </div>
    <div class="col-lg-3">
              <h3>  الاهلاكات     : <span id="gtrpaids">{$trestaurantrawdestruction} </span></h3> 
    </div>
    <div class="col-lg-3">
            <h3 > التحصيل من المستأجرين   :  <span id="gtcpaids"> {$tcrealestateunitspaids} </span></h3> 
    </div>
</div>  


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

{literal}
<script type="text/javascript">
$(document).ready(function () {
      $("#tspaids").html($("#gtspaids").text());
      $("#tepaids").html($("#gtepaids").text());
      $("#trpaids").html($("#gtrpaids").text());
      $("#tcpaids").html($("#gtcpaids").text());
      $("#tcspaids").html($("#gtcspaids").text());

});  
</script>
{/literal}
