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

?>
<script>
window.location="starter.php";
</script>
<?php
}
?>
<style >
	tfoot {
    display: table-header-group !important;
}
</style>

<div id="add-form-cont" class="panel-collapse collapse panel" aria-expanded="false" style="height: 0px; position: relative; top:-3px; width:98%; margin:0px auto;">
	<div class="panel-body">
		<form class="form-horizontal" method="post" id="add_form" enctype="multipart/form-data">
			<div>
			<input type="hidden" id="access_token" name="access_token"  value="">	

				<div class="col-sm-12">

					<div class="form-group">
						
							<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
								<label class="control-label multi_lang">اسم المستخدم</label>
								<input type="text" id="username" name="username" class="form-control multi_lang" placeholder="اسم المستخدم" required="required">
								<div class="form-control-feedback">
									<i class="icon-user text-muted"></i>
								</div>
							</div>
						
							<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
								<label class="control-label multi_lang">الاسم الكامل</label>
								<input type="text" id="full_name" name="full_name" class="form-control multi_lang" placeholder="الاسم الكامل" required="required">
								<div class="form-control-feedback">
									<i class="icon-users2 text-muted"></i>
								</div>
							</div>
					</div>

					<div class="form-group">
						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
							<label class="control-label multi_lang">البريد الالكتروني</label>
							<input type="email" id="email" name="email" class="form-control multi_lang" placeholder="البريد الالكتروني" required="required">
							<div class="form-control-feedback">
								<i class="icon-envelop5 text-muted"></i>
							</div>
						</div>
						
						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
							<label class="control-label multi_lang">الهاتف</label>
							<input type="text" id="phone_number" name="phone_number" class="form-control multi_lang" placeholder="الهاتف" required="required">
							<div class="form-control-feedback">
								<i class="icon-phone-plus text-muted"></i>
							</div>
						</div>

					</div>

					<div class="form-group">
						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
							<label class="control-label multi_lang">كلمة السر</label>
							<input type="password" id="password" name="password" class="form-control multi_lang" placeholder="كلمة السر" required="required">
							<div class="form-control-feedback">
								<i class="icon-key text-muted"></i>
							</div>
						</div>
						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
							<label class="control-label multi_lang">اعادة كتابة كلمة السر</label>
							<input type="password" id="repassword" name="repassword" class="form-control multi_lang" placeholder="اعادة كتابة كلمة السر" required="required">
							<div class="form-control-feedback">
								<i class="icon-key text-muted"></i>
							</div>
						</div>
					</div>

	                <div class="form-group form-group-material col-sm-6" >
						<label class="control-label animate">الفرع</label>
						<select name="branch_id_fk" id="branch_id_fk" class="form-control" required="required" data-live-search="true">
							
						</select>
					</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">
		<form class="form-horizontal"  name="edit_form" method="post" id="edit_form" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="<?php echo $_SESSION['access_token']; ?>">

			<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="itemid" id="edit_objid" value="">
						<div>
							

							<div class="col-sm-12">

								<div class="form-group">
									
										<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
											<label class="control-label multi_lang">اسم المستخدم</label>
											<input type="text" id="edit_username" name="edit_username" class="form-control multi_lang" placeholder="اسم المستخدم" required="required">
											<div class="form-control-feedback">
												<i class="icon-user text-muted"></i>
											</div>
										</div>
									
										<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
											<label class="control-label multi_lang">الاسم الكامل</label>
											<input type="text" id="edit_full_name" name="edit_full_name" class="form-control multi_lang" placeholder="الاسم الكامل" required="required">
											<div class="form-control-feedback">
												<i class="icon-users2 text-muted"></i>
											</div>
										</div>
								</div>

								<div class="form-group">
									<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
										<label class="control-label multi_lang">البريد الالكتروني</label>
										<input type="email" id="edit_email" name="edit_email" class="form-control multi_lang" placeholder="البريد الالكتروني" required="required">
										<div class="form-control-feedback">
											<i class="icon-envelop5 text-muted"></i>
										</div>
									</div>
									
									<div class="form-group has-feedback has-feedback-left col-sm-6">
										<label class="control-label multi_lang">الهاتف</label>
										<input type="text" id="edit_phone_number" name="edit_phone_number" class="form-control multi_lang" placeholder="الهاتف" required="required">
										<div class="form-control-feedback">
											<i class="icon-phone-plus text-muted"></i>
										</div>
									</div>

									<div class="form-group form-group-material col-sm-6" >
										<label class="control-label animate">الفرع</label>
										<select name="edit_branch_id_fk" id="edit_branch_id_fk" class="form-control" required="required" data-live-search="true">
											
										</select>
									</div>

								</div>

  

							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" 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="edit_form_cont1" class="modal fade" style="display: none;">
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="edit_formPass" method="post" id="edit_formPass" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="">

			<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="itemid" id="edit_objidPass" value="">
						<div>
							

							<div class="col-sm-12">

								<div class="form-group">
									
										<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
											<label class="control-label multi_lang">كلمة السر الجديدة</label>
											<input type="password" id="edit_password" name="edit_password" class="form-control multi_lang" placeholder="كلمة السر الجديدة" required="required">
											<div class="form-control-feedback">
												<i class="icon-key2 text-muted"></i>
											</div>
										</div>
									
										<div class="form-group has-feedback has-feedback-left form-group-material col-sm-6">
											<label class="control-label multi_lang">اعادة كتابة كلمة السر</label>
											<input type="password" id="edit_repassword" name="edit_repassword" class="form-control multi_lang" placeholder="اعادة كتابة كلمة السر" required="required">
											<div class="form-control-feedback">
												<i class="icon-key2 text-muted"></i>
											</div>
										</div>
								</div>


							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" 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="edit_profile" class="modal fade" style="display: none;">
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="edit_form_profile" method="post" id="edit_form_profile" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="">

			<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="itemid" id="edit_objidProfile" value="">
							<div class="col-sm-12">
								<div class="form-group">									
									<div class="form-group form-group-material1 col-sm-6">
										<label class="control-label animate multi_lang">تعريف المستخدم</label>
										<select name="profile_type" id="profile_type" class="form-control">
											<option class="multi_lang" value="" selected="selected">اختيار التعريف</option>
											<option class="multi_lang" value="2">Super Admin</option>
											<option class="multi_lang" value="1">Admin</option>
											<option class="multi_lang" value="0">Staff</option>
										</select>
									</div>


									<div class="form-group form-group-material1 col-sm-6">
										<label class="control-label animate multi_lang">Permission Type</label>
										<select name="permission_type" id="permission_type" class="form-control">
											<option class="multi_lang" value="" selected="selected">Select Permission</option>
											
											<option class="multi_lang" value="1">Just View</option>
											<option class="multi_lang" value="0">Can Add, Edit and Delete </option>
										</select>
									</div>
								</div>
							</div>
				</div>



				<div class="modal-footer">
					<button type="submit" 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="edit_role" class="modal fade" style="display: none;">
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="edit_form_role" method="post" id="edit_form_role" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="">

			<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="itemid" id="edit_objidrole" value="">
							<div class="col-sm-12">
								<div class="form-group">									
									<div class="form-group form-group-material col-sm-12">
										<label class="control-label animate multi_lang">صلاحيات المستخدم</label>
										<select name="user_role" id="user_role" multiple="multiple" class="form-control listbox-no-selection">
											
										</select>
									</div>
								</div>
							</div>
				</div>
				<div class="modal-footer">
					<button type="submit" 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="edit_sub_role" class="modal fade" style="display: none;">
	<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="edit_form_sub_role" method="post" id="edit_form_sub_role" 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="user_id" id="user_id" value="">
					<div class="form-group has-feedback has-feedback-left   col-sm-12">
						<label class="control-label animate multi_lang">Sub-Roles</label>
						
						<select class="form-control stop_enter" name="sub_role_id_fk" id="sub_role_id_fk"  multiple="multiple" data-width="100%" data-live-search="true" >
							<option value="1">Customer Account Filter</option>
							<option value="2">Products Filter</option>
							<option value="3">Purchase Filter</option>
							<option value="4">Supplier Payments Filter</option>
							<option value="5">Expenses Filter</option>
							<option value="6">Sell Filter</option>
							<option value="7">Profit Filter</option>
							<option value="8">Loan Filter</option>
							<option value="9">Assets Filter</option>
							<option value="10">Owner Filter</option>
							<option value="11">Safe Filter</option>
							<option value="12">Sold Product Filter</option>
							<option value="13">Saleman Recieved Payments Filter</option>
							<option value="14">Sold Product Full Details Filter</option>
							<option value="15">Return Product Full Details Filter</option>
							
							

						</select>
					</div>
				</div>
				<div class="modal-footer">
					<button type="submit" 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>

				<!-- Individual column searching (text inputs) -->
				<div class="panel panel-flat">
					
					<table class="table datatable-column-search-inputs">
						<thead>
							<tr>
				                <th width="5%">ID</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 class="multi_lang">عدد مرات تسجيل الدخول</th>
				                <th class="multi_lang">Permission Type</th>
				                <th class="multi_lang">الحالة</th>
				                <th class="multi_lang">الفرع</th>
				                <th class="text-center multi_lang" width="15%">العمليات</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>
				            </tr>
						</tfoot>
					</table>
				</div>
				<!-- /individual column searching (text inputs) -->



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