<table class="table table-bordered table-striped table-hover rtl dataTable">
    <thead>
        <tr>
            <th class="wds3 txtc">م</th>
            <th class="txtc">اسم الحالة</th>
            <th class="wds5 txtc">رقم الحالة</th>
            {if $programesetting->system_lang  == 1}    
            <th class="txtc"> اسم الزوج </th>
            {/if} 
            <th class="txtc"> الموبايل </th>
            <th class="txtc"> نوع الكشف </th>
            <th class="txtc"> التاريخ </th>
            <th class="txtc"> القسم </th>
            {if $programesetting->system_lang  == 1}    
            <th class="txtc"> المريض </th>
            {/if} 
            <th class="txtc"> الوقت </th>
            <th class="txtc"> المستخدم  </th>
            <th class="txtc"> ملاحظات  </th>
            <th class="wds3 txtc"> الايصال </th>
            {if $programesetting->confirm_attend  == 1}  
            <th class="wds6 txtc"> الحضور  </th>
            {/if} 

            {if $programesetting->whatsapp_sms  == 1}  
            <th class="wds3 txtc"> Whatsapp  </th>
            {/if} 


            {if $programesetting->attend_today  == 1}  
            <th class="wds3 txtc"> تم الحضور  </th>
            {/if} 
            <th class="wds3 txtc"> تعديل</th> 
            <th class="wds3 txtc"> حذف</th>
        </tr>
    </thead>
    <tbody>
        {assign var=i value=1}
        {foreach $allvisit as $row}
        <tr class="{if $row->for_department eq 12}is_lab{else}not_lab{/if} {if $row->for_department eq 5}is_ray_lab{else}not_ray_lab{/if}"  
            {if $row->detectionid == 9999}style="background-color: #efc9cc;" 
            {else if $row->tempPatient == 1} style="background-color: #e1caf4;"   
            {else if $row->customer_add == 1} style="background-color: #f1f16d;"  
            {else if $row->confirm_attend == 1 && $programesetting->confirm_attend  == 1} style="background-color: #d0f09f;"  
            {else if $row->confirm_attend == 2 && $programesetting->confirm_attend  == 1} style="background-color: #d1a6d1;"  
            {else if $row->confirm_attend == 3 && $programesetting->confirm_attend  == 1} style="background-color: #fd8591;"   {/if} >


            <td> {$i}</td>
            <td>  {$row->patientName}  </td>
            <td> {$row->patientstatusno}</td>
            {if $programesetting->system_lang  == 1}    
            <td> {$row->husbandname}</td>
            {/if}
            <td> 
                <ul style="padding-right: unset;"> 
                    <li>{$row->phone}</li>
                    <li>{$row->mobile}</li>
                </ul>
            </td>
            <td>{$row->detection}</td>
            <td> {$row->visitdate}</td>
            <td >
                {$row->for_department_name} {if !empty($row->operation_time) }({$row->operation_time}){/if}
                {if $row->for_department eq 12}
                <a class=" bg-green dltbtn  printLR" data-visitId="{$row->id}"><i class="fa fa-print"></i></a>
                {/if}
            </td>

            {if $programesetting->system_lang  == 1}    
            <td>
                {if $row->for_husband eq 1} الزوج 
                {else if $row->for_husband eq 2}    
                {if $row->child_gender eq 1} طفل {else} طفلة  {/if}
                {if $row->child_name != ''  && $row->child_name != null }  ({$row->child_name}) {/if} 
                {else} الزوجه{/if}
            </td>
            {/if} 
            {if $programesetting->system_type  == 2}    
            <td> {$row->visitHour}</td>
            {else}
            <td> {$row->visit_time}</td>
            {/if} 

            <td> {$row->user_name}</td>
            <td>   
                {if $row->showRedirectNote  == 1}    
                <span class="fleft ltr"> Dr Note :   </span>   <span>{$row->redirect_note} </span>
                {/if}
                <textarea class="form-control  txtc  ltr" rows="2"   placeholder="Enter more text" data-toggle="popover" 
                          data-trigger="hover" data-placement="bottom" data-content="" id="visitComment{$row->id}">{$row->notes}</textarea>
                <a class="label  label-primary saveVisitComment"  data-visitId="{$row->id}" ><i class="fa fa-save"></i></a>
            </td>

            <td>
                {if $row->printserial > 0 && $row->detectionvalue_cash > 0 } 
                <a class="label  label-success printVisitRecept"  data-visitId="{$row->id}" ><i class="fa fa-print"></i></a>
                {/if}
            </td>

            {if $programesetting->confirm_attend  == 1}  
            <td> 
                <select class="form-control visitAttend updateElementSelect" id="confirmAttend{$row->id}" 
                        data-id="{$row->id}"  data-colName="confirm_attend"  data-tableName="visits" data-ajax="1" >
                    <option value="0">اختر </option>
                    <option value="1" {if  $row->confirm_attend == 1 }  selected  {/if}  style="background-color: #d0f09f ;">تأكيد </option>
                    <option value="2"  {if  $row->confirm_attend == 2 }  selected  {/if}   style="background-color: #d1a6d1 ;">تاجيل </option>
                    <option value="3"  {if  $row->confirm_attend == 3 }  selected  {/if}   style="background-color: #fd8591 ;">الغاء </option>
                </select>
            </td>
            {/if} 


            {if $programesetting->whatsapp_sms  == 1}  
            <td> 
                {if $row->phone != ''   && $row->phone != null }  
                <a class="btn btn-success btn-sm" id="whatsSmsBtn"   target="_blank"
                   href="https://wa.me/2{$row->phone }/?text={$programesetting->whatsapp_txt }"><i class="fa fa-whatsapp"></i>  </a>
                {/if} 
            </td>
            {/if} 

            {if $programesetting->attend_today  == 1}  
            <td>  
                <a class="btn btn-danger btn-sm todayListChange" id="todayListCanc{$row->id}"  data-visitId="{$row->id}"   
                   data-val="0"    {if $row->today_list != 1  } style="display: none;"       {/if} >إلغاء  </a>
                <a class="btn btn-success btn-sm todayListChange"  id="todayListConf{$row->id}"  data-visitId="{$row->id}"  
                   data-val="1"  {if $row->today_list == 1  } style="display: none;"       {/if} >تم  </a>

            </td>
            {/if} 

            {if $row->tempPatient == 1} 
            <td>
                <a class="bg-blue dltbtn" href="{$hosturl}/controllers/patients.php?ac=edit&id={$row->patientid}">Profile</a>
            </td>
            {else}

            {if $allowEditVisit  == 1 || ($row->customer_add == 1 &&  $row->service_edit != 1   )}  
            {if $row->detectionid == 9999} 
            <td><a class=" bg-green dltbtn  editRefundVisit" data-visitId="{$row->id}" id="editvisit{$row->id}">
                    <i class="fa fa-pencil"></i>
                </a>
            </td>
            {else if $row->detectionid == 999} 
            <td><a class=" bg-green dltbtn  editPayValVisit" data-visitId="{$row->id}" id="editvisit{$row->id}">
                    <i class="fa fa-pencil"></i>
                </a>
            </td>
            {else}
            <td><a class=" bg-green dltbtn  editVisit" data-visitId="{$row->id}" id="editvisit{$row->id}" data-isLab="{$isLab}">
                    <i class="fa fa-pencil"></i>
                </a>
            </td>
            {/if}

            {else}        
            <td></td>
            {/if} 
            {/if} 


            {if $allowDeleteVisit  == 1 || ($row->customer_add == 1 &&  $row->service_edit != 1   )} 
            <td>
                <a class=" bg-red dltbtn deletevisitAjax "  data-today="0" id="deletevisit{$row->id}" data-id="{$row->id}" data-link="visits" data-fn="del">
                    <i class="fa fa-close"></i>
                </a>
            </td>
            {else}        
            <td></td>
            {/if} 
        </tr>
        {capture assign=i}{$i+1}{/capture}
        {/foreach}
    </tbody>
</table>

{if $smarty.session.role_id eq 12}
{literal}
<style>
    .not_lab{
        display: none;
    }
</style>
{/literal}
{/if}

{if $smarty.session.role_id eq 5}
{literal}
<style>
    .not_ray_lab{
        display: none;
    }
</style>
{/literal}
{/if}

{literal}
<script>
    $('.dataTable').dataTable();
    //   $('.visitAttend').select2();
</script>
{/literal}