<table class="table table-striped table-hover table-bordered rtl" style="width: 98%;margin-left: 1%;margin-bottom: 10px;">
    <thead>
        <tr>
            <th class=" txtc wds10">الإسم   </th>
            <td>{$name}</td>
            <th class=" txtc wds10">رقم الحالة    </th>
            <td class=" txtc wds15">{$statusno}</td>
            <th class=" txtc wds10">النوع   </th>
            <td class=" txtc wds15">{$gender}</td>
        </tr>
    </thead>
</table>

<table class="table table-striped table-hover table-bordered rtl" style="width: 98%;margin-left: 1%;margin-bottom: 10px;">
    <thead>
        <tr>
            {if $showBranchName == 1 }
            <th class=" txtc wds10">الفرع    </th>
            <td class=" txtc wds12">{$branchName}</td>
            {/if}
            <th class=" txtc wds10">الجهة    </th>
            <td>{$for}</td>
            <th class=" txtc wds10">السن    </th>
            <td class=" txtc wds13 ">{$age}</td>
            
            
            {if $invLink != -1 && $invLink != '' && $invLink != null }
            <td class=" txtc wds5 ">
                <a class="btn green btn-xs fright" target="_blank" href="{$invLink}" style=" float: left;">
                    <i class="fa fa-external-link-square"></i> Web
                </a>
            </td>
            {/if}

            {if $allowChange == 1 }
            <td class=" txtc wds5 ">
                <a class="btn green btn-xs fright" target="_blank"
                   href="{$hosturl}/controllers/{$controllname}.php?ac=showdetails&id={$visitid}&patientid={$patientid}" style=" float: left;" >
                    <i class="fa fa-pencil"></i> Report
                </a>
            </td>
            {/if}


            <td class=" txtc wds5 ">
                <a class="btn btn-success btn-xs printResults " data-role ="{$role_id}"  href="javascript:;" > <i class="fa fa-print"></i>   </a>
            </td>
        </tr>
    </thead>
    <tbody>

    </tbody>
</table>


{if $allowChange != 1 }

<table class="table table-striped table-hover table-bordered" style="width: 98%;margin-left: 1%;">
    <thead>
        <tr>
            <th>
                <input type="checkbox"  class="checkAll" id="checkAll" name="invCheckAll">
            </th>
            <th class=" txtl">Test  </th>
            <th class="wds11">Sample No </th>
            <th class="wds5 txtc"> PDF</th>
            <th class=" wds20 txtc">Result</th>
            <th class="wds5 txtc"> F </th>
            <th class="wds5 txtc"> V </th>
            <th class="wds5 txtc"> P </th>
            <th class="wds5 txtc"> D </th>
            <th class="wds5 txtc"> S </th>
        </tr>
    </thead>
    <tbody id="calculationContainer">
        {assign var=i value=1}
        {foreach $requests as $data}
        <tr>
            <td>
                <input type="checkbox"  class="checkGroup" value="{$data.id}" name="invCheck[]">
            </td>
            <td class="txtl">
                
                {$data.invName} 
            </td>
                         <td class="sampleNo" >
                 {$data.sample_id}
 </td>
            <td>
                {if  $data.pdf != ''  &&  $data.pdf != '.'  &&  $data.pdf != Null &&  $data.pdf != 'no image'  }
                <a class=" btn-xs  fright" download="{$data.invName}_{$statusno}" 
                   href="{$hosturl}/../upload/inv_pdf/{$statusno}/{$data.pdf}" 
                   {if $paid != 1 } style="pointer-events: none" {/if}   >
                    <i class="fa fa-download"></i>
                </a>
                {/if}
            </td>
            <td>
                {if  $data.res != -1}
                {$data.res} 
                {/if}
            </td>

            <td>
                {if  $data.filled == 1 }
                <i class="fa fa-check "   style="color: #119866;font-size: 20px;margin-top: 5%;"></i> 
                {else}
                <i class="fa fa-times "       style="color: red;font-size: 20px;margin-top: 5%;"></i> 
                {/if}
            </td>

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

            <td>
                {if  $data.printed == 1 }
                <i class="fa fa-check "   style="color: #119866;font-size: 20px;margin-top: 5%;"></i> 
                {else}
                <i class="fa fa-times "       style="color: red;font-size: 20px;margin-top: 5%;"></i> 
                {/if}
            </td>

            <td>
                {if $role_id == 3 }
                {if  $data.delivered == 1 }
                <i class="fa fa-check invReDeliver "      data-id="{$data.id}" data-val="1"  data-paid="{$paid}" 
                   style="color: #119866;font-size: 20px;margin-top: 5%;"></i> 
                {else}
                <i class="fa fa-times invStatusChange"    data-colName="delivered"    data-val="1" 
                   data-id="{$data.id}"   data-paid="{$paid}" 
                   style="color: red;font-size: 20px;margin-top: 5%;"></i> 
                {/if}
                {else}
                {if  $data.delivered == 1 }
                <i class="fa fa-check "   style="color: #119866;font-size: 20px;margin-top: 5%;"></i> 
                {else}
                <i class="fa fa-times "       style="color: red;font-size: 20px;margin-top: 5%;"></i> 
                {/if}
                {/if}
            </td>

            <td>
                {if  $data.sent == 1 }
                <i class="fa fa-check "   style="color: #119866;font-size: 20px;margin-top: 5%;"></i> 
                {else}
                <i class="fa fa-times "       style="color: red;font-size: 20px;margin-top: 5%;"></i> 
                {/if}
            </td>


        </tr>
        {capture assign=i}{$i+1}{/capture}
        {/foreach}
    </tbody>
</table>



{else}
<table class="table table-striped table-hover table-bordered" style="width: 98%;margin-left: 1%;">
    <thead>
        <tr>
            <th>
                <input type="checkbox"  class="checkAll" id="checkAll" name="invCheckAll">
            </th>
            <th class=" txtl">Test  </th>
            <th class=" wds11">Sample No </th>
            <th class="wds5 txtc"> PDF</th>
            <th class=" wds20 txtc">Result</th>
               <th class="wds5 txtc"> 
                <span class="wds100  btn btn-xs invStatusChangeAll" data-visitid="{$visitid}" data-colName="filled" style="font-size: 15px;"> F
                </span>
            </th>
            <th class="wds5 txtc"> 
                <span class="wds100  btn btn-xs invStatusChangeAll" data-visitid="{$visitid}"   
                      data-colName="verified" style="font-size: 15px;">V </span> </th>
            <th class="wds5 txtc"> P </th>
            <th class="wds5 txtc">  
                <span class="wds100  btn btn-xs invStatusChangeAll" data-visitid="{$visitid}"  data-paid="{$paid}"   
                      data-colName="delivered" style="font-size: 15px;">D </span> </th>
            <th class="wds5 txtc"> S </th>
        </tr>
    </thead>
    <tbody id="calculationContainer">
        {assign var=i value=1}
        {foreach $requests as $data}
        <tr>
            <td>
                <input type="checkbox"  class="checkGroup" value="{$data.id}" name="invCheck[]">
            </td>
            <td class="txtl">
                

                <a target="_blank"
                   href="{$hosturl}/controllers/{$controllname}.php?ac=showdetails&id={$visitid}&patientid={$patientid}" style=" float: left;" >
                    {$data.invName} 
                </a>
            </td>
                         <td class="sampleNo" >
                 {$data.sample_id}
 </td>
            <td>
                {if  $data.pdf != ''  &&  $data.pdf != '.'  &&  $data.pdf != Null &&  $data.pdf != 'no image'  }
                <a class=" btn-xs  fright" download="{$data.invName}_{$statusno}" 
                   href="{$hosturl}/../upload/inv_pdf/{$statusno}/{$data.pdf}" 
                   {if $paid != 1 } style="pointer-events: none" {/if}   >
                    <i class="fa fa-download"></i>
                </a>
                {/if}
            </td>
            <td>
                {if  $data.res == -1}
                <a href="{$hosturl}/controllers/{$controllname}.php?ac=showdetails&id={$data.visitid}&patientid={$data.patientid}" 
                   target="_blank" > See Report  </a>
                {else}
                {$data.res} 
                {/if}
            </td>

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

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

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

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

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


        </tr>
        {capture assign=i}{$i+1}{/capture}
        {/foreach}
    </tbody>
</table>
{/if}



<table class="table table-striped table-hover table-bordered rtl" style="width: 98%;margin-left: 1%;margin-bottom: 10px;">
    <thead>
        <tr>
            <th class=" txtc wds10">ملاحظات   </th>
            <td>
                <input type="text"   class="form-control updateElement " data-id="{$visitid}"  
                       data-colName="notes" data-tableName="visits"   value="{$visitNotes}"
                       {if $allowChange != 1 } disabled=""  {/if}>
            </td>
        </tr>
    </thead>
</table>



<input type="hidden" id="controllName" value="invsdept"/>
<input type="hidden" id="visitId" value="{$visitid}" name="visitId"/>

<div id="printDiv"></div>

<div id="pdfDiv">

</div>


{literal}
<script>
     $('#checkAll').click(function (event) {
        if (this.checked) {
            // Iterate each checkbox
            $('.checkGroup').each(function () {
                this.checked = true;
            });
        }
        else {
            // Iterate each checkbox
            $(".checkGroup").each(function () {
                this.checked = false;
            });
        }
    });
</script>
{/literal}