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

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

	.dataTable {
        font-size: 15px;
	}

	.thumb img:not(.media-preview) {
    height: 100px;
}

</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>
				

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

						<div class="form-group">


							<div class="form-group has-feedback has-feedback-left  col-sm-3" >
								<label class="control-label animate multi_lang">تحديد الفئة</label>
								
								<select name="expenses_group_id_fk" id="expenses_group_id_fk" class="form-control" data-live-search="true" >
								

								</select>
								<div class="form-control-feedback">
									<i class="icon-wallet text-muted"></i>
								</div>
							</div>



							<!-- <div class="form-group form-group-material col-sm-1">

								<a  id="add_new_category_btn" class="btn btn-primary " data-popup='tooltip' data-original-title='اضافة مجموعة فرعية جديدة' style="margin-top: 25px;" data-toggle="modal" href="#add_new_sub_category"> <b><i class="icon-add"></i></b></a>
							</div> -->

							<div class="form-group has-feedback has-feedback-left  col-sm-3">
								<label class="control-label multi_lang">اسم المصروف</label>
								<input type="text" id="expenses_name" name="expenses_name" class="form-control multi_lang" placeholder=" اسم المصروف " required="required">
								<div class="form-control-feedback">
									<i class="icon-pencil4 text-muted"></i>
								</div>
							</div>

							<!-- <div class="form-group has-feedback has-feedback-left form-group-material col-sm-3">
								<label class="control-label multi_lang">الكمية</label>
								<input type="text" id="expenses_quantity" name="expenses_quantity" class="form-control multi_lang touchspin-basic" placeholder="الكمية" required="required" value="1">
								 <div class="form-control-feedback">
									<i class="icon-hash text-muted"></i>
								</div> 
							</div> -->

							<div class="form-group has-feedback has-feedback-left  col-sm-3">
								<label class="control-label multi_lang">السعر الكلي</label>
								<input type="text" id="expenses_unit_price" name="expenses_unit_price" class="form-control multi_lang" placeholder="السعر الكلي" required="required">
								<div class="form-control-feedback">
									<i class="icon-cash text-muted"></i>
								</div>
							</div>


							<div class="form-group has-feedback has-feedback-left  col-sm-3">
								<label class="control-label multi_lang">التاريخ</label>
								
								<input type="text" id="expenses_date" name="expenses_date" class="form-control daterange-single multi_lang" placeholder="التاريخ" >
								<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-3">
								<label class="control-label multi_lang">نوع العملة</label>
								<select name="expenses_currency" id="expenses_currency" class="form-control" required="required" readonly>
										<option class="multi_lang" value="" selected="selected">نوع العملة</option>
										<option class="multi_lang" selected="selected"  value="1" >دولار</option>
										<option class="multi_lang"  value="0" >عراقي</option>
								</select>
								<div class="form-control-feedback">
									<i class="icon-coin-dollar text-muted"></i>
								</div>
							</div> -->

							

							<div class="form-group has-feedback has-feedback-left  col-sm-3">
								<label class="control-label multi_lang">رقم الوصل</label>
								<input type="text" id="bill_number" name="bill_number" class="form-control multi_lang" placeholder="رقم الوصل" >
								<div class="form-control-feedback">
									<i class="icon-hash text-muted"></i>
								</div>
							</div>

							<div class="form-group has-feedback has-feedback-left  col-sm-3">
										<label class="display-block">تحميل الوصل</label>
	                    				<input type="file" name="attach_bill" id="attach_bill" class="file-styled-primary">
	                    
	                  				
							</div>	

							<div class="form-group has-feedback has-feedback-left  col-sm-3" >

								<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 class="form-group has-feedback has-feedback-left  col-sm-3">
								<label class="control-label multi_lang">الملاحظات</label>
								<input type="text" id="expenses_note" name="expenses_note" class="form-control multi_lang" placeholder="الملاحظات" >
								<div class="form-control-feedback">
									<i class="icon-info22 text-muted"></i>
								</div>
							</div>

						</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-full">
			<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="">

				<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="">

						<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 animate multi_lang">تحديد المجموعة الفرعية</label>
									
									<select name="edit_expenses_sub_group_id_fk" id="edit_expenses_sub_group_id_fk" class="form-control" data-live-search="true" required="required">
									

									</select>
									<div class="form-control-feedback">
										<i class="icon-wallet text-muted"></i>
									</div>
								</div> -->



								<!-- <div class="form-group has-feedback has-feedback-left  col-sm-4">
									<label class="control-label multi_lang">الكمية</label>
									<input type="text" id="edit_expenses_quantity" name="edit_expenses_quantity" class="form-control multi_lang touchspin-basic" placeholder="الكمية" required="required" value="1">
									<div class="form-control-feedback">
										<i class="icon-hash text-muted"></i>
									</div>
								</div> -->

								<div class="form-group has-feedback has-feedback-left col-sm-4" >
									<label class="control-label animate multi_lang">تحديد الفئة</label>
									
									<select name="edit_expenses_group_id_fk" id="edit_expenses_group_id_fk" class="form-control" data-live-search="true" >
									

									</select>
									<div class="form-control-feedback">
										<i class="icon-wallet text-muted"></i>
									</div>
								</div>

								<div class="form-group has-feedback has-feedback-left col-sm-4">
									<label class="control-label multi_lang">اسم المصروف</label>
									<input type="text" id="edit_expenses_name" name="edit_expenses_name" class="form-control multi_lang" placeholder=" اسم المصروف " required="required">
									<div class="form-control-feedback">
										<i class="icon-pencil4 text-muted"></i>
									</div>
								</div>

								<div class="form-group has-feedback has-feedback-left  col-sm-4">
									<label class="control-label multi_lang">السعر الكلي</label>
									<input type="text" id="edit_expenses_unit_price" name="edit_expenses_unit_price" class="form-control multi_lang" placeholder="السعر الكلي" required="required">
									<div class="form-control-feedback">
										<i class="icon-cash text-muted"></i>
									</div>
								</div>


								<div class="form-group has-feedback has-feedback-left  col-sm-4">
									<label class="control-label multi_lang">التاريخ</label>
									
									<input type="text" id="edit_expenses_date" name="edit_expenses_date" class="form-control daterange-single multi_lang" placeholder="التاريخ" >
									<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-4">
									<label class="control-label multi_lang">نوع العملة</label>
									<select name="edit_expenses_currency" id="edit_expenses_currency" class="form-control" required="required" readonly>
											<option class="multi_lang" value="" selected="selected">نوع العملة</option>
											<option class="multi_lang" selected="selected" value="1" >دولار</option>
											<option class="multi_lang"  value="0" >عراقي</option>
									</select>
									<div class="form-control-feedback">
										<i class="icon-coin-dollar text-muted"></i>
									</div>
								</div> -->

								
								<div class="form-group has-feedback has-feedback-left  col-sm-4">
									<label class="control-label multi_lang">رقم الوصل</label>
									<input type="text" id="edit_bill_number" name="edit_bill_number" class="form-control multi_lang" placeholder="رقم الوصل" >
									<div class="form-control-feedback">
										<i class="icon-hash text-muted"></i>
									</div>
								</div>

								



								<div class="form-group has-feedback has-feedback-left  col-sm-4">
								
										<label class="display-block">تحميل الوصل</label>
	                    				<input type="file" name="edit_attach_bill" id="edit_attach_bill" class="file-styled-primary">
	                    
	                  			</div>
								

								<div class="form-group has-feedback has-feedback-left  col-sm-4" >

									<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 class="form-group has-feedback has-feedback-left  col-sm-4">
									<label class="control-label multi_lang">الملاحظات</label>
									<input type="text" id="edit_expenses_note" name="edit_expenses_note" class="form-control multi_lang" placeholder="الملاحظات" >
									<div class="form-control-feedback">
										<i class="icon-info22 text-muted"></i>
									</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="add_new_category" class="modal fade" >
			<div class="modal-dialog modal-lg">
			<form class="form-horizontal"  name="add_new_category_form" method="post" id="add_new_category_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">
							<div>
								<div class="col-sm-12">
									<div class="form-group">
										<div class="col-sm-6">
											<div class="input-group">
												<label class="input-group-addon multi_lang">اسم المجموعة</label>
												<input type="text" placeholder=" اسم المجموعة" class="form-control multi_lang" name="objname" id="objname" required="required">
											</div>
										</div>
										<div class="col-sm-6">
											<div class="input-group">
												<label class="input-group-addon multi_lang">الوصف</label>

												<input type="text" placeholder=" الوصف " class="form-control multi_lang" name="group_description" id="group_description" >
											</div>
										</div>
									</div>
								</div>
							</div>
					</div>
					<div class="modal-footer">
						<button type="submit" id="submit_add_cat_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="add_new_sub_category" class="modal fade" >
		<div class="modal-dialog modal-lg">
			<form class="form-horizontal"  name="add_new_sub_category_form" method="post" id="add_new_sub_category_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">
							<div>
								<div class="col-sm-12">
									<div class="form-group">
										<div class="col-sm-4">
											<div class="input-group">
												<label class="input-group-addon multi_lang">اسم الفئة</label>
												<select name="expenses_group_id_fk" id="expenses_group_id_fk" class="form-control" required="required">
										
												</select>
											</div>
										</div>

										<div class="col-sm-4">
											<div class="input-group">
												<label class="input-group-addon multi_lang">اسم المجموعة</label>
												<input type="text" placeholder=" اسم المجموعة" class="form-control multi_lang" name="sub_group_name" id="sub_group_name" required="required">
											</div>
										</div>

										<div class="col-sm-4">
											<div class="input-group">
												<label class="input-group-addon multi_lang">الوصف</label>

												<input type="text" placeholder=" الوصف " class="form-control multi_lang" name="sub_group_description" id="sub_group_description" >
											</div>
										</div>
									</div>
								</div>
							</div>
					</div>
					<div class="modal-footer">
						<button type="submit" id="submit_add_sub_cat_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>


	<div class="row">
										
		<div class="col-sm-6 col-md-12">
			<div class="panel panel-body">
				<div class="media no-margin">
					<div class="media-body">
						
						<div class="col-sm-6">
								<label> First Date</label>
							
								<input class="form-control" type="date" name="first_date" id="first_date">
										
							

						</div>

						<div class="col-sm-6">
							<label> Second Date</label>
							
							<input class="form-control" type="date" name="second_date" id="second_date">
					
						</div>

						
						
						<div class="col-sm-4" style="margin-top: 10px;">

							

							<button id="filter_btn" type="button" class="btn bg-teal-400 btn-labeled btn-block"><b><i class="icon-filter4"> </i></b> <span id="inv_filter">تطبيق الفلتر</span> </button>
							
						</div>

						

						<div class="col-sm-4" style="margin-top: 10px;">

							

							<a href="index.php?p=expenses"  class="btn bg-pink-400 btn-labeled btn-block"><b><i class="icon-close2"> </i></b> <span id="inv_filter">ازالة الفلتر</span> </a>
							
						</div>

						



					</div>

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

				<!-- Individual column searching (text inputs) -->
				<div class="panel panel-flat">
					
					<table class="table datatable-column-search-inputs">
						<thead>
							<tr>
				        		<th>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"> الوصل </th>
								<th class="multi_lang"> الملاحظات </th>
								<th class="multi_lang">الفئة</th>
								<th class="multi_lang">الفرع</th>
				        		<th class="multi_lang" width="8%">العمليات</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>
				                
				            </tr>
						</tfoot>
					</table>
				</div>
				<!-- /individual column searching (text inputs) -->



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