{assign var=totalBalance value=0}
{foreach $externalLabs as  $dayDate => $dayLabs}
<input type="hidden" id="controllName" value="adddevices"/>
<table class="table table-bordered table-striped table-hover rtl"  >
    <caption class="txtc bold" style="background-color: #666;color: white;"> 
        {$dayDate} 
    </caption>
    <tbody>
        <tr>
            <td>
                <table class="table table-bordered table-striped table-hover rtl"  >
                    <thead>
                        <tr>
                            <th   class="wds5 txtc">رقم الحالة</th>
                            <th    class="txtc"> المريضة - الزوج </th>
                            <th    class=" txtc"> اسم المعمل   </th>
                            <th    class=" txtc">تاريخ الزيارة</th>
                            <th    class=" txtc">تاريخ خروج العينة</th>
                            <th    class=" txtc"> اسم التحليل  </th>
                            <th    class=" txtc"> السعر    </th>
                        </tr>
                    </thead>
                    <tbody>
                        {assign var=dayBalance value=0}
                        {assign var=i value=1}
                        {foreach $dayLabs as $lab}
                        <tr>
                            <td> {$lab.statusno}</td>
                            <td> 
                                <ul style="    padding-right: 5px;">
                                    <li style="float: right;">{$lab.wifename}</li>
                                    <li>{$lab.husdandname}</li>
                                </ul>
                            </td>
                            <td> {$lab.labName}</td>
                            <td> {$lab.visitdate}</td>
                            <td>{if $lab.lab_userid  > 0 }  {$lab.sampleDate}  {/if} </td>
                            <td> {$lab.investName}</td>
                            <td> {$lab.toLabPrice}</td>
                        </tr>
                        {capture assign=dayBalance}{$dayBalance+$lab.toLabPrice}{/capture}
                        {capture assign=totalBalance}{$totalBalance+$lab.toLabPrice}{/capture}
                        {capture assign=i}{$i+1}{/capture}
                        {/foreach}

                        <tr>
                            <th colspan="6"   class=" txtc">  إجمالى اليوم    </th>
                            <th    class=" txtc">  {$dayBalance}    </th>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
{/foreach}


<table class="table table-bordered table-striped table-hover rtl"  >
    <thead>
        <tr style=" height: 50px;">
            <th  class=" txtc bold">  إجمالى  سعر التحاليل    </th>
            <th    class=" txtc bold">  {$totalBalance}    </th>
        </tr>
    </thead>
</table>

