{foreach $allLabs 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"  class="wds5 txtc">رقم الحالة</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="wds3 txtc"> F   </th>
                            <th rowspan="2"   class="wds3 txtc"> V   </th>
                            <th rowspan="2"   class="wds3 txtc"> P   </th>
                            <th rowspan="2"   class="wds3 txtc"> D   </th>
                            <th colspan="3"    class=" txtc"> استلام المريض    </th>
                        </tr>
                        <tr>
                            <th    class=" txtc"> المستخدم      </th>
                            <th    class="wds9 txtc">  التاريخ     </th>
                            <th    class="wds15 txtc">  ملاحظات     </th>
                        </tr>
                    </thead>
                    <tbody>
                        {if  $dayLabs.labsCount > 0  }
                        {assign var=i value=1}
                        {foreach $dayLabs.labs as $lab}
                        <tr id="receiveExternalTr{$lab.resId}">
                            <td> {$lab.statusno}</td>
                            <td> 
                                <ul>
                                    <li style="float: right;">{$lab.wifename}</li>
                                    <li style="float: left;">{$lab.husdandname}</li>
                                </ul>
                            </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>
                                {if  $lab.filled == 1 }
                                <i class="fa fa-check  invStatusChange"   data-colName="filled"  data-val="0" 
                                   data-id="{$lab.resId}"    id="invFilled{$lab.resId}" 
                                   style="color: #119866;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {else}
                                <i class="fa fa-times invStatusChange"   data-colName="filled"    data-val="1" 
                                   data-id="{$lab.resId}"    id="invFilled{$lab.resId}" 
                                   style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {/if}
                            </td>

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

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


                            <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 $lab.delivered_userid  > 0 } 
                            <td> {$lab.deliveredUserName}</td>
                            <td> {$lab.delivered_date}
                                <a class="btn blue-hoki btn-xs    cancelReceive" data-resId="{$lab.resId}" 
                                   data-tableName="investigationresults" data-colName="delivered_userid"  
                                   data-btn="labDeliverySearchBtn"  data-value="0"   >
                                    <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="labDeliverySearchBtn"  data-patientId="{$lab.patientId}"   >
                                    تسليم  
                                </a>
                            </td>
                            {/if}
                        </tr>
                        {capture assign=i}{$i+1}{/capture}
                        {/foreach}
                        {/if}



                        {if  $dayLabs.dnaCount > 0  }
                        {assign var=i value=1}
                        {foreach $dayLabs.dna as $lab}
                        <tr id="receiveDnaTr{$lab.dnaResultId}">
                            <td> {$lab.statusno}</td>
                            <td> 
                                <ul>
                                    <li style="float: right;">{$lab.wifename}</li>
                                    <li style="float: right;">{$lab.husdandname}</li>
                                </ul>
                            </td>
                            <td> {$lab.investName}</td>

                            <td>
                                <div class="wds70 fleft">
                                    <a href="#"   class="btn green-jungle btn-xs"
                                       onclick="document.getElementById('dnaPdf_{$lab.dnaResultId}').click(); return false;" >
                                        <i class="fa fa-upload"></i>  </a>
                                    <input type="file" name="dnaPdf_{$lab.dnaResultId}"  id="dnaPdf_{$lab.dnaResultId}"   
                                           class=" form-control addDnaPdf" data-id="{$lab.dnaResultId}" 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/dna_pdf/{$lab.statusno}/{$lab.pdf}" id="dnaPdfDownload{$lab.dnaResultId}" >
                                        <i class="fa fa-download"></i>
                                    </a>

                                    {else}
                                    <a class="btn btn-xs blue fright" download="{$lab.investName}_{$lab.statusno}" 
                                       id="dnaPdfDownload{$lab.dnaResultId}" 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_dna{$lab.dnaResultId}" style="display: none;">
                            </td>

                            <td>

                            </td>

                            <td>
                                {if  $lab.verified == 1 }
                                <i class="fa fa-check invStatusChange"   data-colName="verified"   data-val="0"  
                                   data-id="{$lab.dnaResultId}"     data-dna="1" 
                                   style="color: #119866;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {else}
                                <i class="fa fa-times invStatusChange"   data-colName="verified"    data-val="1" 
                                   data-id="{$lab.dnaResultId}"        data-dna="1" 
                                   style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {/if}
                            </td>

                            <td>

                            </td>


                            <td id="deliverDnaSmsTd{$lab.dnaResultId}">
                                <!--
                                {if  $lab.delivered == 1 }
                                <i class="fa fa-check "  
                                   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.dnaResultId}"  data-paid="{$lab.paid}"       data-dna="1" 
                                   style="color: red;font-size: 20px;margin-top: 5%;margin-bottom: 10%;"></i> 
                                {/if}    -->
                            </td>

                            {if $lab.delivered_userid  > 0 } 
                            <td> {$lab.deliveredUserName}</td>
                            <td> {$lab.delivered_date}
                                <a class="btn blue-hoki btn-xs    cancelReceive" data-resId="{$lab.dnaResultId}" 
                                   data-tableName="dna_results" data-colName="delivered_userid"  
                                   data-btn="labDeliverySearchBtn"   data-value="0" >
                                    <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.dnaResultId}" data-colName="receivername" 
                                       data-tableName="dna_results" value="{$lab.receivername}" /> 
                            </td>
                            {else}
                            <td colspan="3" id="deliverDnaExternalTd{$lab.dnaResultId}">
                                <a class="btn blue-hoki btn-sm    deliverExternalTest" data-resId="{$lab.dnaResultId}"     data-dna="1"     data-btn="labDeliverySearchBtn"   >
                                    تسليم  
                                </a>
                            </td>
                            {/if}
                        </tr>
                        {capture assign=i}{$i+1}{/capture}
                        {/foreach}

                        {/if}
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
{/foreach}

