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

?>
<script>
window.location="starter.php";
</script>
<?php
}
?>
<style >
	tfoot {
    display: table-header-group !important;
	}
	.dataTable {
        font-size: 12px;
	}
</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="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon"> اسم المخزن </label>
								<input type="text" placeholder=" اسم المخزن " class="form-control" name="objname" id="objname" required="required">
							</div>
						</div>
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon"> الوصف </label>
								<select name="stock_type" id="stock_type" class="form-control" required="required">
										<option value="" selected="selected">نوع المخزن</option>
										<option value="0" >خزن</option>
										<option value="1" >انتاج</option>
								</select>
							</div>
						</div>


					</div>

					<div class="form-group" >
						<div class="form-group has-feedback has-feedback-left form-group-material col-sm-12">
							<label class="control-label">الملاحظات</label>
							<textarea type="text" id="stock_note" name="stock_note" class="form-control" placeholder="الملاحظات" > </textarea> 
							<div class="form-control-feedback">
								<i class="icon-notebook 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">
					حفظ <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">
					اغلاق  <b><i class="icon-cross"></i></b>
				</a>
			</div>
		</form>
	</div>
</div>

<input type="hidden" name="product_id" id="product_id" value="">
<input type="hidden" name="on_hand_qty" id="on_hand_qty" value="">

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

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

							<input type="hidden" name="product_stock_id" id="product_stock_id" value="">
							<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="stock_id" id="stock_id" class="form-control stock_class multi_lang" data-live-search="true" required="required">
													
											</select>
										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> المادة </label>
											<select name="product_id_fk" id="product_id_fk" class="form-control multi_lang" data-live-search="true" 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" name="recieved_quantity" id="recieved_quantity" class="form-control multi_lang" required="required">
													
										
										</div>
									</div>

								</div>
								
								<div class="form-group">
									

									<!-- <div class="col-sm-6">
										<div class="input-group">
											<label class="input-group-addon multi_lang">  الملاحظة </label>
											<input type="text" name="resons" id="resons" class="form-control multi_lang" >
													
										
										</div>
									</div> -->

								</div>

								

							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" id="btn_transfer" 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_damage_form_cont" class="modal fade" style="display: none;">
	<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="add_damage_form" method="post" id="add_damage_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>
					<h4 class="modal-title text-success"><span class="multi_lang">الكمية المتوفرة</span>  : <span class="on_hand_qty text-black text-danger"></span> </h4>
				</div>

				<div class="modal-body">
						<input type="hidden" name="id_damage" id="id_damage" value="">
						<input type="hidden" name="on_hand_qty_damage" id="on_hand_qty_damage" value="">

						<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="stock_id_damage" id="stock_id_damage" class="form-control stock_class multi_lang" required="required">
													
											</select>
										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> الكمية التالفة </label>
											<input type="number" name="damage_qty" id="damage_qty" class="form-control multi_lang" required="required" placeholder=" الكمية التالفة" >

										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> السبب </label>
											<input type="text" name="damage_resons" id="damage_resons" class="form-control multi_lang"  placeholder=" السبب" >

										</div>
									</div>

								</div>

								

							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" id="btn_damage" 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_expire_form_cont" class="modal fade" style="display: none;">
	<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="add_expire_form" method="post" id="add_expire_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>
					<h4 class="modal-title text-success"><span class="multi_lang">الكمية المتوفرة</span>  : <span class="on_hand_qty text-black text-danger"></span> </h4>
				</div>

				<div class="modal-body">
						<input type="hidden" name="id_expire" id="id_expire" value="">
						<input type="hidden" name="on_hand_qty_expire" id="on_hand_qty_expire" value="">

						<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="stock_id_expire" id="stock_id_expire" class="form-control stock_class multi_lang" required="required">
													
											</select>
										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> الكمية المنتهية الصلاحية </label>
											<input type="number" name="expire_qty" id="expire_qty" class="form-control multi_lang" required="required" placeholder=" الكمية المنتهية الصلاحية" >

										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> السبب </label>
											<input type="text" name="expire_resons" id="expire_resons" class="form-control multi_lang"  placeholder=" السبب" >

										</div>
									</div>

								</div>

								

							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" id="btn_expire" 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="production_form_cont" class="modal fade" style="display: none;">
	<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="production_form" method="post" id="production_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>
					<h4 class="modal-title text-success"><span class="multi_lang">الكمية المتوفرة</span>  : <span class="on_hand_qty text-black text-danger"></span> </h4>
				</div>

				<div class="modal-body">
						<input type="hidden" name="id_production" id="id_production" value="">
						<input type="hidden" name="on_hand_qty_used" id="on_hand_qty_used" value="">

						<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="stock_id_used" id="stock_id_used" class="form-control stock_class multi_lang" required="required">
													
											</select>
										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> الكمية المستخدمة (الطول) </label>
											<input type="number" name="used_length" id="used_length" class="form-control multi_lang" required="required" placeholder=" الكمية المستخدمة" >

										</div>
									</div>

									<div class="col-sm-4">
										<div class="input-group">
											<label class="input-group-addon multi_lang"> السبب </label>
											<input type="text" name="used_resons" id="used_resons" class="form-control multi_lang"  placeholder=" السبب" >

										</div>
									</div>

								</div>

								

							</div>
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" id="btn_used" 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 table-bordered table-hover datatable-highlight datatable-row-full datatable-key-class">
						<thead>
							
							<tr>
				                
				                <th>ID</th>
				                
				                <th class="multi_lang">Invoice No.</th>
				                <th class="multi_lang">Invoice Date</th>
				                <th class="multi_lang">Type</th>
				                
				                <th class="multi_lang">Customer</th>
				                <th class="multi_lang">Product</th>
				                <th class="multi_lang">Sold Quantity</th>
				                <th class="multi_lang">Cost Price Per Unit</th>
				                <th class="multi_lang">Sell Price Per Unit</th>
				                <th class="multi_lang">Branch</th>
				                <th class="multi_lang">Saleman</th>
				                <!-- <th class="multi_lang">ملاحظة</th> -->
				                <th  class="text-center multi_lang" >Action</th>
				            </tr>
						</thead>
						<tbody>
							
						</tbody>
						<tfoot>
							<tr>
				               
				                <td>Name</td>
				                <td>Position</td>
				                <td>Start date</td>
				                <td>Salary</td>
				                
				                <td></td>
				                <td></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/cost_return.js?random=<?php echo uniqid(); ?>"></script>