<meta charset="utf8">
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">

            <div class="col-md-12 ">
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption fright">

                            الحجوزات
                        </div>
                        <div class="tools fleft">
                            <a href="#" class="collapse" title="تصغير / تكبير"></a>
                            <!--a class="fff bold" href="{$hosturl}/controllers/{$controllname}.php?ac=show">عرض جميع  الحجوزات </a-->
                        </div>
                    </div>

                    <div class="portlet-body">
                        <div class="table-toolbar">

                        </div>  
                        <table class="table table-bordered  table-hover rtl">
                            <tr>
                                <th style="width: 18%;">القسم</th>
                                <td>
                                    <select class="select2h" style="width: 100%;"  id="reserve_dept" placeholder="اختر القسم " required >
                                        <option value=""></option>
                                        {foreach $departs as $row}
                                        <option value="{$row->id}">{$row->name}</option>
                                        {/foreach}
                                    </select>
                                </td>
                                <td style="width: 18%;" >
                                    <a href="javascript:;"  id="deptClinicsDisplay"
                                       class="btn blue-soft btn-block btn-xs">غرف العيادة </a>
                                    <span id="clinicsError"  style="color: red;display: none;">اختر قسم أولا ....</span>
                                </td>
                            </tr>
                        </table>

                        <div id="dept_clinics_div">
                            <div class="table-toolbar">
                                <a href="javascript:;"  id="reserve_cancel"
                                   class="btn red btn-block btn-xs fleft wds10">إلغاء حجز   </a>
                                <span id="reserve_cancelError"  style="color: red;display: none;float: left;">اختر ساعات محجوزة أولا  </span>


                            </div>  

                            <div class="tabbable tabbable-custom tabbable-noborder">
                                <ul class="nav nav-tabs" id="rowTab" style="float: right;">
                                    <li class="fright aw_3d_list active"> <a href="#tab1" data-toggle="tab"> السبت  </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab2" data-toggle="tab"> الأحد  </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab3" data-toggle="tab"> الإثنين </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab4" data-toggle="tab"> الثلاثاء </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab5" data-toggle="tab"> الأربعاء </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab6" data-toggle="tab"> الخميس </a> </li>
                                    <li class="fright aw_3d_list"> <a href="#tab7" data-toggle="tab"> الجمعة </a> </li>
                                </ul>
                            </div>


                            <div class="tab-content">
                                {foreach $days as $day }
                                <div class="tab-pane {if $day.no == 1}active {/if} " id="tab{$day.no}">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <table class="table  table-bordered table-hover">
                                                <caption style="text-align: center;font-weight: bolder">ساعات اليوم  

                                                    <a href="javascript:;"  data-dayNo="{$day.no}"
                                                       class="btn green-haze btn-block btn-xs fleft wds10 printDay">  طباعة   </a>
                                                </caption>
                                                <thead>
                                                    <tr>
                                                        <th></th>
                                                        {foreach $day.hours as $hour}
                                                        <th>{$hour} </th>
                                                        {/foreach}
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    {foreach $rooms as $room}
                                                    <tr>
                                                        <td> {$room.name} </td>
                                                        {foreach $day.hours as $hour}


                                                        {if $day.no == 1 }
                                                        {if in_array($hour, $room.resHours1)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours1}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" >
                                                            {if $key !== false}
                                                            {$room.resNames1[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 2 }
                                                        {if in_array($hour, $room.resHours2)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours2}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames2[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 3 }
                                                        {if in_array($hour, $room.resHours3)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours3}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames3[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 4 }
                                                        {if in_array($hour, $room.resHours4)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours4}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames4[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 5 }
                                                        {if in_array($hour, $room.resHours5)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours5}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames5[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 6 }
                                                        {if in_array($hour, $room.resHours6)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours6}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames6[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {else if $day.no == 7 }
                                                        {if in_array($hour, $room.resHours7)} 
                                                        {assign var="key" value=$hour|array_search:$room.resHours7}
                                                        <td class="dayBusy" data-dayNo="{$day.no}" data-room="{$room.id}"  data-hour="{$hour}" > 
                                                            {if $key !== false}
                                                            {$room.resNames7[$key]}
                                                            {/if}
                                                        </td>
                                                        {else}
                                                        <td class="dayFree" data-dayNo="{$day.no}" data-room="{$room.id}"   
                                                            data-hour="{$hour}" >
                                                        </td>
                                                        {/if}
                                                        <!------------------------------------------------------------------------------------------------------------>
                                                        {/if}

                                                        {assign var="i" value="3"}
                                                        {assign var="k" value=""}
                                                        {/foreach}
                                                    </tr>
                                                    {/foreach}
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                </div>
                                {/foreach}
                            </div>



                        </div>

                        <table class="table table-bordered  table-hover rtl" id="reserve_action_div" style="display: none;">
                            <tr>
                                <th style="width: 18%;">الطبيب </th>
                                <td>
                                    <select  style="width: 100%;"  id="reserve_doctor" placeholder="اختر الطبيب " required >
                                    </select>
                                </td>
                                <th style="width: 10%;">بدءا من  </th>
                                <td style="width: 10%;" >
                                    <input class="form-control patientvisitidCheckDate  datepicker edited"
                                           type="text"  id="start_date"  value="{$today}">
                                </td>
                                <td style="width: 18%;" >
                                    <a href="javascript:;"  id="reserve_clinic"
                                       class="btn blue-soft btn-block btn-xs">حجز  </a>
                                    <span id="reserve_clinicError"  style="color: red;display: none;"> </span>
                                </td>
                            </tr>
                        </table>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<input type="hidden" id="controllName" value="reserve_clinic"/>

<div id="displayClinicsDiv"></div>
<div id="printDayDiv"></div>
