<?php
$permission  = explode(',',$_SESSION['permission_id']);
if(!in_array(9,$permission) && !in_array(1,$permission)  ){

?>
<script>
window.location="starter.php";
</script>
<?php
}
?>

<style >
	tfoot {
    display: table-header-group !important;
	}

	td{
	text-align: center !important;
	}
	th{
	text-align: center !important;
	}

	textarea{
	height: 38px !important;
	resize: none;
	}

	.table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
    padding: 10px 5px;

    }

    .badge:empty{
    	display: initial;
    }

    .btn_add_item{
    	padding: 0px 0px;
    }

    .bootstrap-select.btn-group .btn .filter-option{
    	text-align: center;
    }

    input[type="checkbox"] {
    	margin: -8px 0 0;
    	
    	line-height: normal;
	}

	.radio label, .checkbox label {
    	padding-right: 85px;
	}

	.radio label, .checkbox label {
    	min-height: 20px;
    	/*padding-right: 20px;*/
    	margin-bottom: 20px;
    	font-weight: normal;
    	cursor: pointer;
	}

</style>

<div id="doc_modal" class="modal fade" >

	<select  class="form-control stop_enter" name="doctor_copy_list" id="doctor_copy_list">

	</select>

</div>


<div id="select_doctors_modal" class="modal fade" >
	<div class="modal-dialog modal-full">
		<form class="form-horizontal" method="post" id="select_doctors_form" enctype="multipart/form-data">

			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close close_doc_modal" ><i class="icon-cross"></i></button>
					<h4 class="modal-title multi_lang">اختيار الاطباء</h4>
					<h4 class="modal-title text-center text-blue"><span class="multi_lang">عدد الاطباء الذين تم اختيارهم:</span> <span id="total_selected" class="text-danger"></span> <span class="multi_lang"> طبيب </span>  	
						<br/>
						مجموع  الزيارات :
						<span id="total_visits" class="text-orange"></span> <span class="multi_lang"> زيارة </span></h4>
				</div>

				<div class="modal-body">

					<input type="hidden" id="total_doctors" name="total_doctors"  value="">
					<div class="col-sm-12">
						<input type="text" dir="RTL" name="search" id="search" class="form-control" placeholder="بحث عن طبيب" style="border: 1px solid coral;">
					</div>

					<div class="col-sm-12">
						<div class="form-group" id="input_box_array_doctor">

							

						</div>
					</div>

				</div>
			<div class="modal-footer">
				<div class="text-right">
					<button type="submit" id="submit_add_prod_btn" class="btn btn-primary btn-labeled btn-labeled-left">
						<span class="multi_lang">حفظ</span> <b><i class="icon-floppy-disk"></i></b>
					</button>
					<button type="button" class="btn btn-warning close_doc_modal"  > <span class="multi_lang">اغلاق</span>
						</button>
				</div>
			</div>
		  </div>
		</form>

	</div>
</div>






<div id="add-form-cont"  class="panel-collapse collapse   panel" aria-expanded="false" >
	<div class="panel-body">
		<form class="form-horizontal" method="post" id="add_form" enctype="multipart/form-data">
			
			
			<!-- <input type="hidden" id="invoice_type" name="invoice_type" value="0"> -->
			<input type="hidden" id="total_rows" name="total_rows" value="1">
			<input type="hidden" id="total_rows_doctor" name="total_rows_doctor" value="0">
			
			<div class="col-sm-12">

				<div class="form-group">

					
					<div class="form-group has-feedback has-feedback-left col-sm-4">
						<label class="control-label multi_lang">PLan Title</label>
						<input type="text" id="plan_title" name="plan_title" class="form-control multi_lang stop_enter" placeholder="PLan Title" required="required">
						<div class="form-control-feedback">
							<i class="icon-user-tie text-muted"></i>
						</div>
					</div>

					<div class="form-group has-feedback has-feedback-left col-sm-8">
						<label class="control-label multi_lang">Description</label>
						<input type="text" id="plan_description" name="plan_description" class="form-control multi_lang stop_enter" placeholder="Description" >
						<div class="form-control-feedback">
							<i class="icon-user-tie text-muted"></i>
						</div>
					</div>

					

					<div class="form-group has-feedback has-feedback-left col-sm-3">
						<label class="control-label multi_lang">Start Date</label>
							<input type="text" id="plan_start_date" name="plan_start_date" class="form-control multi_lang daterange-single stop_enter" placeholder="Start Date" required="required"  >
							<div class="form-control-feedback">
								<i class=" icon-calendar52 text-muted"></i>
							</div>
					</div>

					<div class="form-group has-feedback has-feedback-left col-sm-3">
						<label class="control-label multi_lang">Expire Date</label>
							<input type="text" id="plan_end_date" name="plan_end_date" class="form-control multi_lang daterange-single stop_enter" placeholder="Expire Date" required="required"  >
							<div class="form-control-feedback">
								<i class=" icon-calendar52 text-muted"></i>
							</div>
					</div>

					
					
					
					
					<div class="form-group has-feedback has-feedback-left  col-sm-3">
						<label class="control-label animate multi_lang">City</label>
						
						<select  class="form-control stop_enter" name="city_id_fk" id="city_id_fk" required="required" data-width="100%" data-live-search="true" >

						</select>
					</div>


					<div class="form-group has-feedback has-feedback-left  col-sm-3">
						<label class="control-label animate multi_lang">Zone</label>
						
						<select class="form-control stop_enter" name="zone_id_fk" id="zone_id_fk"  data-width="100%" multiple="multiple" data-live-search="true" >
							
						</select>
					</div>

					<div class="form-group has-feedback has-feedback-left col-sm-3">
						<label class="control-label animate multi_lang">Sub Zone</label>
						
						<select class="form-control stop_enter" name="sub_zone_id_fk" id="sub_zone_id_fk"  data-width="100%" multiple="multiple" data-live-search="true" >

						</select>
					</div>

					<div class="form-group has-feedback has-feedback-left col-sm-3">
						<label class="control-label animate multi_lang">الحي</label>
						
						<select class="form-control stop_enter" name="quarter_id_fk" id="quarter_id_fk"  data-width="100%" multiple="multiple" data-live-search="true" >

						</select>
					</div>

					<div class="form-group has-feedback has-feedback-left col-sm-3">
						<label class="control-label animate multi_lang">الشارع</label>
						
						<select class="form-control stop_enter" name="street_id_fk" id="street_id_fk"  data-width="100%" multiple="multiple" data-live-search="true" >

						</select>
					</div>

					<div class="form-group has-feedback   col-sm-12">
						<label class="control-label animate multi_lang">Team Leaders</label>
						
						<select multiple="multiple" class="form-control stop_enter" name="team_leader_id_fk[]" id="team_leader_id_fk"  data-width="100%" data-live-search="true" >

						</select>
					</div>
					
				

					<div class="form-group has-feedback has-feedback-left  col-sm-12">
						<label class="control-label multi_lang">ملاحظات</label>
						<input type="text" id="plan_note" name="plan_note" class="form-control multi_lang stop_enter" placeholder="ملاحظات"  tabindex=""> 
						<div class="form-control-feedback">
							<i class="icon-notebook text-muted"></i>
						</div>
					</div>
					
				</div>

				<div class="form-group">
					<div class="table-responsive2">
						<table  class="table col-sm-12 table-bordered .table-sm">
							<thead>
								<tr class="alpha-orange ">
									<th>#</th>
									<th class="multi_lang">الطبيب</th>
									<th class="multi_lang">عدد الزيارات الموصى بها</th>
									<th class="multi_lang">ملاحظة</th>
									<th></th>
								</tr>
							</thead>
							<tbody id="doctor_item_body" >
								

								
								

								
								
							</tbody>
							<tfoot>
								
								
								

							</tfoot>
						</table>
					</div>

				</div>

				<div class="form-group">
					<div class="table-responsive1">
						<table  class="table col-sm-12 table-bordered .table-sm">
							<thead>
								<tr class="alpha-success ">
									<th>#</th>
									<th class="multi_lang">المادة</th>
									<th class="multi_lang">الكمية</th>
									<th class="multi_lang">سعر الوحدة</th>
									<th class="multi_lang">العرض</th>
									<th class="multi_lang">ملاحظة</th>
									<th></th>
								</tr>
							</thead>
							<tbody id="purchase_item_body" >
								<tr  id="item_row_1" >
									<td width="5%" id="num_1">1</td>

									<td width="10%" id="ttt">
										

										<select class="form-control multi_lang stop_enter" name="product_id_fk_1" id="product_id_fk_1" data-width="100%"  data-live-search="true"  required="required" tabindex="">

										</select>

									</td>


									<td width="6%">
										<input type="number" id="purchase_quantity_1" name="purchase_quantity_1"  class="form-control text-center multi_lang stop_enter" placeholder="QNTY" value="1" tabindex="">
									</td>

									<td width="9%" >
										<input id="sell_price_1" name="sell_price_1" type="text" class="form-control multi_lang text-center " placeholder="PRICE" required="required">
									</td>

									<td width="10%">
										<input id="discount_1" name="discount_1" type="text" value="" class="form-control text-center text-black text-size-large stop_enter" >
									</td>

									

									

									<td width="8%">
										<input id="sell_item_note_1" name="sell_item_note_1" type="text" class="form-control multi_lang stop_enter" placeholder="ملاحظة" tabindex="">
									</td>

							
									
									
									
									<td width="6%">
										<button class="btn btn-link btn_add_item" id="" tabindex="">
											<i  class="icon-add text-blue"></i>
										</button>
										
									</td>
								</tr>

								
								

								
								
							</tbody>
							<tfoot>
								
								
								

							</tfoot>
						</table>
					</div>

				</div>

				

			</div>
			

			<div class="text-right">
				<button type="submit" id="submit_add_btn" class="btn btn-primary btn-labeled btn-labeled-left">
					<span class="multi_lang">حفظ</span> <b><i class="icon-floppy-disk"></i></b>
				</button>
				<a href="#add-form-cont" id="add_form_cancel" class="btn btn-labeled btn-labeled-left bg-danger heading-btn" data-toggle="collapse">
					<span class="multi_lang">الغاء</span>  <b><i class="icon-cross"></i></b>
				</a>
			</div>
		</form>
	</div>
</div>

<div id="edit_form_cont" class="modal fade" style="display: none;">
	<div class="modal-dialog modal-lg" style="width: 92%;">
		<form class="form-horizontal"  name="edit_form" method="post" id="edit_form" enctype="multipart/form-data">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><i class="icon-cross"></i></button>
					<h4 class="modal-title multi_lang">تحرير </h4>
				</div>

				<div class="modal-body">
					<input type="hidden" name="edit_objid" id="edit_objid" value="">
					<input type="hidden" id="edit_total_rows" name="edit_total_rows" value="1">
					<input type="hidden" id="edit_total_rows_doctor" name="edit_total_rows_doctor" value="1">
					<input type="hidden" id="update_type" name="update_type" value="update">

					<div class="form-group">

						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
							<label class="control-label multi_lang">PLan Title</label>
							<input type="text" id="edit_plan_title" name="edit_plan_title" class="form-control multi_lang stop_enter" placeholder="PLan Title" required="required">
							<div class="form-control-feedback">
								<i class="icon-user-tie text-muted"></i>
							</div>
						</div>

						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
							<label class="control-label multi_lang">Description</label>
							<input type="text" id="edit_plan_description" name="edit_plan_description" class="form-control multi_lang stop_enter" placeholder="Description" >
							<div class="form-control-feedback">
								<i class="icon-user-tie text-muted"></i>
							</div>
						</div>

						

						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
							<label class="control-label multi_lang">Start Date</label>
								<input type="text" id="edit_plan_start_date" name="edit_plan_start_date" class="form-control multi_lang daterange-single stop_enter" placeholder="Start Date" required="required"  >
								<div class="form-control-feedback">
									<i class=" icon-calendar52 text-muted"></i>
								</div>
						</div>

						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
							<label class="control-label multi_lang">Expire Date</label>
								<input type="text" id="edit_plan_end_date" name="edit_plan_end_date" class="form-control multi_lang daterange-single stop_enter" placeholder="Expire Date" required="required"  >
								<div class="form-control-feedback">
									<i class=" icon-calendar52 text-muted"></i>
								</div>
						</div>

						
						
						
						
						<div class="form-group has-feedback has-feedback-left form-group-material  col-sm-4">
							<label class="control-label animate multi_lang">City</label>
							
							<select  class="form-control stop_enter" name="edit_city_id_fk" id="edit_city_id_fk" required="required" data-width="100%" data-live-search="true" >

							</select>
						</div>


						<div class="form-group has-feedback has-feedback-left form-group-material  col-sm-4">
							<label class="control-label animate multi_lang">Zone</label>
							
							<select class="form-control stop_enter" name="edit_zone_id_fk" id="edit_zone_id_fk"  data-width="100%" data-live-search="true" >

							</select>
						</div>

						<div class="form-group has-feedback   col-sm-12">
							<label class="control-label animate multi_lang">Team Leaders</label>
							
							<select multiple="multiple" class="form-control stop_enter" name="edit_team_leader_id_fk[]" id="edit_team_leader_id_fk"  data-width="100%" data-live-search="true" >

							</select>
						</div>
						
					

						<div class="form-group has-feedback has-feedback-left  col-sm-12">
							<label class="control-label multi_lang">ملاحظات</label>
							<input type="text" id="edit_plan_note" name="edit_plan_note" class="form-control multi_lang stop_enter" placeholder="ملاحظات"  tabindex=""> 
							<div class="form-control-feedback">
								<i class="icon-notebook text-muted"></i>
							</div>
						</div>
						

					</div>


					

					
						

					<div id="edited_purchase_contain">


					</div>


					

				</div>
				<div class="modal-footer">
					<button type="submit" id="submit_edit_btn" class="btn btn-labeled btn-labeled-left heading-btn btn-primary"> <span class="multi_lang">حفظ</span> <b><i class="icon-floppy-disk"></i></b>
					</button>
					<button type="button" class="btn btn-warning" data-dismiss="modal"> <span class="multi_lang">اغلاق</span>
					</button>
				</div>
			</div>
		</form>
	</div>
</div>




<div id="show_files" class="modal fade" >
	<div class="modal-dialog modal-lg" >

		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><i class="icon-cross"></i></button>
				<h4 class="modal-title multi_lang">صور المادة</h4>
			</div>

			<div class="modal-body">

				<div class="row" id="file_attach">

				</div>

			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-labeled btn-labeled-left heading-btn btn-primary"  data-dismiss="modal"> OK
				</button>
				<button type="button" class="btn btn-warning" data-dismiss="modal"> <span class="multi_lang">اغلاق</span>
				</button>
			</div>
		</div>

	</div>
</div>


	
	<!-- Individual column searching (text inputs) -->
	<div class="panel panel-flat">
		
		<table class="table datatable-column-search-inputs table-bordered table-hover datatable-highlight datatable-row-full datatable-key-class">
			<thead>
				<tr>
	        		<th width="5%">ID</th>
					<th class="multi_lang">Plan No.</th>
					<th class="multi_lang">Title</th>
          			<th class="multi_lang">Description</th>
          			<!-- <th class="multi_lang">المشتري</th> -->
					<th class="multi_lang">Start Date</th>
					<th class="multi_lang">Expire Date</th>
					<th class="multi_lang">Note</th>
					<th class="multi_lang">Zone</th>
					<th class="multi_lang">City</th>
					<th class="multi_lang">Status</th>
					<th class="multi_lang">Created By</th>
          			<th class="text-center multi_lang">العمليات</th>
	      </tr>
			</thead>
			<tbody>
				
			</tbody>
			<tfoot>
				<tr>
	                <td></td>
	                <td>username</td>
	                <td>full_name</td>
	                <td>EMail</td>
	                <!-- <td>Phone</td> -->
	                <!-- <td></td> -->
	                <td></td>
	                <td></td>
	                <td></td>
	                <td></td>
	                <td></td>
	                <td></td>
	                <td></td>
	                <td></td>
	            </tr>
			</tfoot>
		</table>
	</div>
	<!-- /individual column searching (text inputs) -->



<script type="text/javascript" src="controllers/plan.js?random=<?php echo uniqid(); ?>"></script>