<meta charset="utf8">
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
    <div class="page-content">
        <!--go-->
        <!-- BEGIN PAGE HEADER--  >
        <h3 class="page-title">
            {$shcontrollname}
        </h3>
        <div class="page-bar">
            <ul class="page-breadcrumb">
                {$breadcrumbs}
            </ul>
        </div>
        <!-- END PAGE HEADER-->
        <!-- BEGIN PAGE CONTENT-->
        <div class="row">
            <div class="col-md-12 ">

                <!-- BEGIN SAMPLE FORM PORTLET-->
                <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 form">

                        <!--<form method="post">-->
                        <div class="form-body">
                            <div class="clinick rtl">
                                <div class="row">
                                    <input type="hidden"    id="addVisitControl"  value="1">
                                    <input type="hidden" id="controllName" value="visits"/>
                                    <form action="#" id="myvisitform" method="post" class="awval">
                                        <div class="row">
                                            <div class="col-md-1">

                                                {if $programesetting->programview  == 1} 
                                                <label for="form_control_1">رقم المريضة</label>
                                                {else}
                                                <label for="form_control_1">رقم المريض</label>
                                                {/if}

                                                <div class="form-group  form-md-floating-label has-info">

                                                    <select  class="form-control select2me patientvisitidCheck getTotalBalance" name="patientid" id="patientvisitidNo" placeholder="اختر  " required="required">
                                                        <option value=""></option>
                                                        {foreach $allPatients as $row}
                                                        <option value="{$row->id}" {if $patientid == {$row->id}}selected{/if}>{$row->statusno}</option>
                                                        {/foreach}

                                                    </select>

                                                </div>
                                            </div>



                                            {if $programesetting->visitsform  != 1}  <div class="col-md-3"> {else}<div class="col-md-5">  {/if}

                                                    {if $programesetting->programview  == 1} 
                                                    <label for="form_control_1">اسم المريضة</label>
                                                    {else}
                                                    <label for="form_control_1">اسم المريض</label>
                                                    {/if}

                                                    <div class="form-group  form-md-floating-label has-info">

                                                        <select  class="form-control select2me patientvisitidCheck getTotalBalance" name="patientid" id="patientvisitid" placeholder="اختر  " required="required">
                                                            <option value=""></option>
                                                            {foreach $allPatients as $row}
                                                            <option value="{$row->id}" {if $patientid == {$row->id}}selected{/if}>{$row->wifename}</option>
                                                            {/foreach}

                                                        </select>

                                                    </div>
                                                </div>


                                                <div class="col-md-2">
                                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                        <!--<input class="form-control datepicker22 edited" name="visitdate"   type="text" value="{$smarty.now|date_format:'%Y-%m-%d'}"  id="visitdate" required disabled>-->
                                                        <input class="form-control patientvisitidCheckDate  datepicker edited"  type="text"  id="visitdate" name="visitdate" required value="{$today}">
                                                        <label for="form_control_1"  class="txtr">تاريخ الزيارة </label>
                                                    </div>
                                                </div>

                                                {if $programesetting->visit_period  == 1} 
                                                <input type="hidden"    id="visitPeriod"  value="1">
                                                <div class="col-md-2">
                                                    <label for="form_control_1">فترة  الكشف</label>
                                                    <div class="form-group  form-md-floating-label has-info">
                                                        <select  class="form-control select2me visit_periods" name="visit_period" id="visit_period" 
                                                                 placeholder="اختر  الفترة  " required="required"  >
                                                            <option value=""></option>
                                                            {assign var=i value=1}
                                                            {foreach $visit_periods as $data}
                                                            <option value="{$data->id}"   {if $i == 1}selected {/if}    >{$data->name}</option>
                                                            {capture assign=i}{$i+1}{/capture}
                                                            {/foreach}
                                                            <option value="-2" class="deleteoptincompo">حذف</option>
                                                        </select>
                                                    </div>
                                                </div>

                                                <div class="col-md-1">
                                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                        <input  class="form-control"  type="text" value="" id="periodPatCount" readonly="">
                                                        <label for="form_control_1"  class="txtr">  عدد الحجوزات   </label>
                                                    </div>
                                                </div>

                                                {/if}

                                                {if $programesetting->visit_period  == 1}  
                                                <div class="col-md-3"> 
                                                    {else}
                                                    <div class="col-md-6"> 
                                                        {/if}
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input type="text" name="notes" id="notes"    class="form-control txtc ">
                                                            <label for="notes"  class="txtr">  ملاحظات </label>
                                                        </div>
                                                    </div>



                                                </div>

                                                <div class="row">

                                                    {if $programesetting->visitsform  != 1}
                                                    <div class="col-md-3 wds20">
                                                        <label for="form_control_1">نوع الكشف</label>
                                                        <div class="form-group  form-md-floating-label has-info">
                                                            <select  class="form-control " name="detectionid" id="detectionid" placeholder="اختر نوع الكشف " required select-tableName="visits" data-tableName="visits" data-maintable = "detections" data-colName="detectionid" data-id="0">
                                                                <option value=""></option>
                                                                {assign var=i value=1}
                                                                {foreach $allDetections as $row}
                                                                {if $i == 1}{assign var=k value={$row->detectionval}}{/if}
                                                                <option value="{$row->id}" {if $i == 1}selected{/if}>{$row->title}</option>
                                                                {capture assign=i}{$i+1}{/capture}
                                                                {/foreach}
                                                                {if $programesetting->balance  == 1}
                                                                <option value="-99" >دفع قسط </option>
                                                                {/if}
                                                                <option value="-1">إضافة كشف</option>
                                                                <option value="0" class="deleteoptincompo">حذف</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control digitsOnly detectionvalue"  type="text"  id="totaldetectionvalue" value="{$k}" name="totaldetectionvalue" required="required">
                                                            <label for="form_control_1"  class="txtr"> قيمة الكشف </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control digitsOnly detectionvalue"  type="text"  id="discount" value="0" name="discount" required="required">
                                                            <label for="form_control_1"  class="txtr">  الخصم </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control digitsOnly detectionvalue"  type="text"  id="detectionvalue_cash" value="{$k}" name="detectionvalue_cash" required="required">
                                                            <label for="form_control_1"  class="txtr">  كاش </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control digitsOnly detectionvalue"  type="text"  id="detectionvalue_visa" value="0" name="detectionvalue_visa" required="required">
                                                            <label for="form_control_1"  class="txtr">  فيزا </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control digitsOnly"  type="text"  id="restdetectionvalue" value="0" name="restdetectionvalue" required="required" readonly="">
                                                            <label for="form_control_1"  class="txtr">  المتبقى </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-2 wds9">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input type="text" class="form-control  timepicker-10" 
                                                                   name="approx_time" id="approx_time"  readonly >
                                                            <label for="form_control_1"  class="txtr">  التوقيت  </label>
                                                        </div>
                                                    </div>

                                                    {else}
                                                    <div class="col-md-3">
                                                        <label for="form_control_1">القسم </label>
                                                        <div class="form-group  form-md-floating-label has-info">
                                                            <select  class="form-control " name="detectionid" id="detectionid" placeholder="اختر القسم " required select-tableName="visits" data-tableName="visits" data-maintable = "detections" data-colName="detectionid" data-id="0">
                                                                <option value=""></option>
                                                                {assign var=i value=1}
                                                                {foreach $allDetections as $row}
                                                                {if $i == 1}{assign var=k value={$row->detectionval}}{/if}
                                                                <option value="{$row->id}" {if $i == 1}selected{/if}>{$row->title}</option>
                                                                {capture assign=i}{$i+1}{/capture}
                                                                {/foreach}
                                                                <option value="-1">إضافة قسم</option>
                                                                <option value="0" class="deleteoptincompo">حذف</option>
                                                            </select>
                                                        </div>
                                                    </div>

                                                    {/if}      
                                                    <div class="col-md-1 wds7">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control"  type="checkbox"  id="urgent" value="1" name="urgent" >
                                                            <label for="form_control_1"  class="txtr">إنتظار </label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-1 wds6">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control"  type="checkbox"  id="payVisit" value="1" name="payVisit" checked="checked">
                                                            <label for="form_control_1"  class="txtr">دفع</label>
                                                        </div>
                                                    </div>

                                                    <div class="col-md-1 wds12" style="display: none;" id="patientEditDiv">
                                                        <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                            <input  class="form-control"  type="checkbox"  id="patient_edit" value="1" name="patient_edit">
                                                            <label for="patient_edit"  class="txtr">تعديل من المريض</label>
                                                        </div>
                                                    </div>


                                                    <div class="col-md-2 wds10">
                                                        <input type="submit" name="submit" id="visitaddsubmit"  {if $found == 1}disabled="disabled"{/if} 
                                                               class="btn blue btnsve addbtnvisit " value="إضافة" />
                                                        <a class=" bg-green btn  saveEditVisit " id="saveEditVisit" 
                                                           data-visitId="0" style="display: none; margin: 17px 0 0 0;">حفظ </a>
                                                        <a class=" bg-red btn  cancelEditVisit " id="cancelEditVisit" 
                                                           data-visitId="0" style="display: none;  margin: 17px 0 0 0;">إلغاء</a>

                                                        <input type="hidden"  name="editView"  id="editView"  value="0">
                                                        <input type="hidden"  name="mVisitId"  id="mVisitId"  value="0">
                                                    </div>
                                                    <span id="checkvisitbefore" {if $found != 1}style="display: none; " {/if}>عفواً,لقد تمت الزيارة من قبل لهذه الحالة  </span>
                                                </div>

                                                </form>
                                                {if $programesetting->balance  == 1}
                                                <div class="col-md-12 ">
                                                    <div >
                                                        <div class="portlet box blue">
                                                            <div class="portlet-title">
                                                                <div class="caption fright">
                                                                    إضافة للمبلغ  الاجمالى
                                                                </div>
                                                            </div>
                                                            <div class="portlet-body form">
                                                                <div class="col-md-2">
                                                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                                        <input  class="form-control"  type="text"  id="balance" disabled="disabled" value="0">

                                                                        {if $programesetting->programview  == 1} 
                                                                        <label for="form_control_1"  class="txtr"> المبلغ المتبقى على المريضة  </label>
                                                                        {else}
                                                                        <label for="form_control_1"  class="txtr"> المبلغ المتبقى على المريض </label>
                                                                        {/if}
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-2">
                                                                    <div class="form-group form-md-line-input form-md-floating-label has-info">
                                                                        <input  class="form-control digitsOnly"  type="text"  id="newBalance"  name="newBalance" value="0">
                                                                        <label for="form_control_1"  class="txtr"> المبلغ المراد إضافته </label>
                                                                    </div>
                                                                </div>
                                                                <div class="col-md-1">
                                                                    <input type="button"  id="addBalance"  value="إضافة" class="btn blue  wds100" />
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <!--
                                                    </div>
                                                        <!-- END SAMPLE FORM PORTLET-->
                                                    </div>
                                                    <!-- END SAMPLE FORM PORTLET-->
                                                </div>

                                                {/if}
                                            </div>
                                        </div>
                                </div>
                                <!--</form>-->
                            </div>
                        </div>
                    </div>

                    <div  id="lastVisitDetails"> </div>
                    <div  id="restDiv"> </div>

                    <div class="col-md-12 ">
                        <div class="todayvisit" >
                            <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" id="showList">قائمة الإنتظار   </a>
                                        <!--a class="fff bold" href="{$hosturl}/controllers/{$controllname}.php?ac=getalldepts"
                                        >تفريغ  الحجوزات</a-->
                                    </div>
                                </div>
                                <div class="portlet-body form"> 
                                    <div class="table-toolbar" style="margin-bottom: 0;">
                                        <div class="row" style="margin: 10px !important;direction: rtl;">

                                            <div class="col-md-3">
                                                <div class="form-group">
                                                    <label class="control-label ls2">التاريخ الى </label>
                                                    <input type="text"  id="date_to" value="{$today}" 
                                                           class="searchvisitIndex form-control  datepicker" 
                                                           placeholder="التاريخ إلى"/>                                                    
                                                </div>
                                            </div>

                                            <div class="col-md-3">
                                                <div class="form-group">
                                                    <label class=" control-label ls2">التاريخ من  </label>
                                                    <input type="text"  id="date_from" value="{$today}" 
                                                           class="searchvisitIndex form-control  datepicker" 
                                                           placeholder="التاريخ من "/>
                                                </div>
                                            </div>

                                            <div class="col-md-4">
                                                <div class="form-group">
                                                    <label class="control-label ls2">اسم المريضة  </label>
                                                    <input type="hidden" class="form-control searchvisitIndex"    id="patientIdRemote"  >
                                                </div>
                                            </div>

                                            <div class="col-md-2">
                                                <div class="form-group">
                                                    <label class="control-label ls2">رقم  المريضة  </label>
                                                    <input type="text"  id="statusNoRemote"  
                                                           class="form-control  txtc searchPatRemote positiveNo " >
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div id="visitNew">

                                    </div>
                                </div>
                            </div>
                            <!--                                           
                        </div>
                            <!-- END SAMPLE FORM PORTLET-->
                        </div>
                        <!-- END SAMPLE FORM PORTLET-->
                    </div>

                    <!-- END PAGE CONTENT-->
                </div>
            </div>
            <!-- END CONTENT -->
            <!--<div class="modal fade" id="detectionforview" tabindex="-1" role="basic" aria-hidden="true">
            
            </div>-->
            <div class="bootbox modal fade bootbox-alert in" tabindex="-1" role="dialog" aria-hidden="false"  id="edit_detectionforview">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                            <h4 class="modal-title"> Edit </h4>
                        </div>
                        <div class="modal-body">
                            <div class="portlet-body form">
                                <form action="" id="" method="post" class="form-horizontal  emptyform" >
                                    <div class="form-body">
                                        <!------===========================================------->
                                        <div>
                                            <div id="detectionforview" class=""> </div>
                                        </div>


                                        <!------===========================================------->
                                        <div class="modal-footer">
                                            <!--                                <button type="button" class="btn green" id="editmodel_submit"> Update </button>-->
                                            <button type="button" id="amountcloseinput"   class="btn default" data-dismiss="modal">Close</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                </div>
            </div>
            {if $programesetting->visitsform  != 1}
            <div class="modal fade" id="detectionadd" tabindex="-1" role="basic" aria-hidden="true">
                <meta charset="utf8"/>
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button style="float: left;" type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                            <h4 class="modal-title txtr bold"> إضافة كشف </h4>
                            <span id="sucssmsg" style="display: none;">لقد تم إضافة كشف جديد</span>
                        </div>
                        <div class="modal-body modtbl"  style="margin: 15px;">
                            <from  id="form_add_detection" action="" method="post">
                                <table class="table table-bordered table-striped table-hover">
                                    <thead>
                                    <th>نوع الكشف</th>
                                    <th class="wds20">قيمة الكشف</th>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <div class="input-group wds100" >
                                                    <input type="text" class="form-control" name="detectiontp" id="detectiontp" placeholder="ادخل نوع الكشف">
                                                </div>
                                            </td>
                                            <td>
                                                <div class="input-group">
                                                    <input type="text" class="form-control positivefloat" name="detectionvl"  id="detectionvl" placeholder="ادخل قيمة الكشف">
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </from>

                            <div class="modal-footer">
                                <button type="button" class="btn default" data-dismiss="modal">إغلاق</button>
                                <button type="button" class="btn blue" id="detectionadd_submit" >حفظ</button>

                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>

            {else}
            <div class="modal fade" id="detectionadd" tabindex="-1" role="basic" aria-hidden="true">
                <meta charset="utf8"/>
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button style="float: left;" type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                            <h4 class="modal-title txtr bold"> إضافة قسم </h4>
                            <span id="sucssmsg" style="display: none;">لقد تم إضافة قسم جديد</span>
                        </div>
                        <div class="modal-body modtbl"  style="margin: 15px;">
                            <from  id="form_add_detection" action="" method="post">
                                <table class="table table-bordered table-striped table-hover">
                                    <thead>
                                    <th>اسم القسم</th>
                                    <th style="display: none;" >قيمة الكشف</th>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <div class="input-group wds100" >
                                                    <input type="text" class="form-control" name="detectiontp" id="detectiontp" placeholder="ادخل اسم القسم">
                                                </div>
                                            </td>
                                            <td style="display: none;"> 
                                                <div class="input-group">
                                                    <input type="text" class="form-control positivefloat" name="detectionvl" value="0" id="detectionvl" placeholder="ادخل قيمة الكشف">
                                                </div>
                                            </td>

                                        </tr>
                                    </tbody>
                                </table>
                            </from>

                            <div class="modal-footer">
                                <button type="button" class="btn default" data-dismiss="modal">إغلاق</button>
                                <button type="button" class="btn blue" id="detectionadd_submit" >حفظ</button>

                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>
            {/if}



            <div id="editModalDiv"></div>
            <div id="waitingListDiv"> </div>