{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 rowspan="2"  >     </th>
                            <th rowspan="2"  class="wds5 txtc">رقم الحالة</th>
                            <th rowspan="2"   class="wds15"> المريضة - الزوج </th>
                            <th rowspan="2"   class=" txtc"> اسم المعمل   </th>
                            <th rowspan="2"   class=" txtc"> اسم التحليل  </th>
                            <th rowspan="2"   class="wds10 txtc"> PDF   </th>
                            <th rowspan="2"   class=" txtc">   الإستقبال </th>
                            <th colspan="2"   class=" txtc">   المعمل  </th>
                            {if !($ext_lab > 0 ) }
                            <th rowspan="2"   class="wds3 txtc"> D   </th>
                            <th rowspan="2"   class=" txtc"> المستلم   </th>
                            <th rowspan="2"   class="wds9 txtc"> تاريخ الاستلام   </th>
                            <th colspan="3"    class=" txtc"> استلام المريض    </th>
                            {/if}
                        </tr>
                        <tr>
                            <th    class=" txtc"> المستخدم      </th>
                            <th    class="wds9 txtc">  التاريخ     </th>
                            {if !($ext_lab > 0 ) }
                            <th    class=" txtc"> المستخدم      </th>
                            <th    class="wds9 txtc">  التاريخ     </th>
                            <th    class="wds11 txtc">  المستلم     </th>
                            {/if}
                        </tr>
                    </thead>
                    <tbody>
                        {assign var=i value=1}
                        {foreach $dayLabs as $lab}
                        <tr id="receiveExternalTr{$lab.resId}">
                            <td>
                                <a href="#"   class="btn blue btn-xs printExternal"  style="padding: 3px;"
                                   data-resId="{$lab.resId}" ><i class="fa fa-print"></i>  </a>
                            </td>
                            <td> {$lab.statusno}</td>

                            <td> 
                                <ul style="margin-bottom: 22px;">
                                    <li style="float: right;    margin-right: -15%;">{$lab.wifename}</li>
                                </ul>
                                <ul style="margin-bottom: 22px;">
                                    <li style="float: right;    margin-right: -15%;">{$lab.husdandname}</li>
                                </ul>
                            </td>

                            <td> {$lab.labName}</td>
                            <td> {$lab.investName}</td>

                            <td>
                                <div class="wds70 fleft">
                                    <a href="#"   class="btn green-jungle btn-xs"
                                       onclick="document.getElementById('invPdf_{$lab.resId}').click(); return false;" >
                                        <i class="fa fa-upload"></i>  </a>
                                    <input type="file" name="invPdf_{$lab.resId}"  id="invPdf_{$lab.resId}"   
                                           class=" form-control addInvPdfExtrnal" data-id="{$lab.resId}" style="visibility:hidden;"  >
                                </div>

                                <div class="wds30 fright">
                                    {if  $lab.pdf != ''  &&  $lab.pdf != '.'  &&  $lab.pdf != Null &&  $lab.pdf != 'no image'  }
                                    <a class="btn  btn-xs blue  fright"   data-statusno="{$lab.statusno}" 
                                       download="{$lab.investName}_{$lab.statusno}"  
                                       href="{$hosturl}/../upload/inv_pdf/{$lab.statusno}/{$lab.pdf}" id="pdfDownload{$lab.resId}" >
                                        <i class="fa fa-download"></i>
                                    </a>

                                    {else}
                                    <a class="btn btn-xs blue fright" download="{$lab.investName}_{$lab.statusno}" 
                                       id="pdfDownload{$lab.resId}" style="display: none;" data-statusno="{$lab.statusno}"  >
                                        <i class="fa fa-download"></i>
                                    </a>
                                    {/if}

                                </div>
                                <img src="{$hosturl}/../upload/loading.gif" id="talks-loading{$lab.resId}" style="display: none;">
                            </td>

                            <td>{$lab.sendUserName}</td>

                            {if $lab.lab_userid  > 0 } 
                            <td> {$lab.labUserName}</td>
                            <td> {$lab.lab_date}
                                <a class="btn blue-hoki btn-xs    cancelReceive" data-tableName="investigationresults" 
                                   data-resId="{$lab.resId}" data-colName="lab_userid"   data-value="0"
                                   data-btn="externalSearchBtn"  >
                                    <i class="fa fa-times "  style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i>   
                                </a>
                            </td>
                            {else}
                            <td colspan="2" id="labExternalTd{$lab.resId}">
                                <a class="btn green-haze btn-sm    labExternalTest" data-resId="{$lab.resId}"  data-btn="externalSearchBtn"  >
                                    استلام 
                                </a>
                            </td>
                            {/if}

                            {if !($ext_lab > 0 ) }
                            <td id="deliverSmsTd{$lab.resId}">
                                {if  $lab.delivered == 1 }
                                <i class="fa fa-check invReDeliver "      data-id="{$lab.resId}"  data-paid="{$lab.paid}"  data-val="1" 
                                   style="color: #119866;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {else}
                                <i class="fa fa-times invStatusChange"    data-colName="delivered"    data-val="1" 
                                   data-id="{$lab.resId}"  data-paid="{$lab.paid}" 
                                   style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {/if}
                            </td>
                            {/if}

                            {if !($ext_lab > 0 ) }
                            {if $lab.receive_userid  > 0 } 
                            <td> {$lab.receiveUserName}</td>
                            <td> {$lab.receive_date}
                                <a class="btn blue-hoki btn-xs    cancelReceive" data-tableName="investigationresults" 
                                   data-resId="{$lab.resId}" data-colName="receive_userid"   data-value="0" 
                                   data-btn="externalSearchBtn"  >
                                    <i class="fa fa-times "  style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i>   
                                </a>
                            </td>
                            {else}
                            <td colspan="2" id="receiveExternalTd{$lab.resId}">
                                <a class="btn green-haze btn-sm    receiveExternalTest" data-resId="{$lab.resId}"  data-btn="externalSearchBtn"  >
                                    استلام 
                                </a>
                            </td>
                            {/if}
                            {/if}


                            {if !($ext_lab > 0 ) }
                            {if $lab.delivered_userid  > 0 } 
                            <td> {$lab.deliveredUserName}</td>
                            <td> {$lab.delivered_date}
                                <a class="btn blue-hoki btn-xs    cancelReceive" data-tableName="investigationresults" 
                                   data-resId="{$lab.resId}" data-colName="delivered_userid"   data-value="0" 
                                   data-btn="externalSearchBtn"  >
                                    <i class="fa fa-times "  style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i>   
                                </a>
                            </td>
                            <td>
                                <input type="text" class="form-control updateElement" data-id="{$lab.resId}" data-colName="receivername" 
                                       data-tableName="investigationresults" value="{$lab.receivername}" /> 
                            </td>
                            {else}
                            <td colspan="3" id="deliverExternalTd{$lab.resId}">
                                <a class="btn blue-hoki btn-sm    deliverExternalTest" data-resId="{$lab.resId}"  data-btn="externalSearchBtn"  >
                                    تسليم  
                                </a>
                            </td>
                            {/if}
                            {/if}
                        </tr>
                        {capture assign=i}{$i+1}{/capture}
                        {/foreach}
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
{/foreach}

