<?php

if(!isset($_GET['typ'])){
?>
<script>
window.location="starter.php";
</script>
<?php
}
if( ($_GET['typ'] !='0' && $_GET['typ']!='1') || $_GET['typ'] ==''){

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

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

?>
	<script>
	window.location="starter.php";
	</script>
<?php
	}
}elseif($_GET['typ'] =='1'  ){
	if(!in_array(8,$permission) && !in_array(1,$permission)  ){
?>
	<script>
	window.location="starter.php";
	</script>
<?php
	}
}else{
?>
	<script>
	window.location="starter.php";
	</script>
<?php
}
?>


<link href="assets/stcombobox.css" type="text/css" rel="stylesheet"/>

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

	.stc-input {
		width: 120px;
	}

</style>


	<div id="add_other_modal" class="modal fade" >
			<div class="modal-dialog modal-lg">
			<form class="form-horizontal"  name="add_other_form" method="post" id="add_other_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">
							<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>
												<input type="text" placeholder="اسم المادة" class="form-control multi_lang" name="other_name" id="other_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="other_description" id="other_description" >
											</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="other_buy_price_per_unit" id="other_buy_price_per_unit" required="required">
											</div>
										</div>
										
									</div>
								</div>
							</div>
					</div>
					<div class="modal-footer">
						<button type="submit" id="submit_add_other_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_sticker_modal" class="modal fade" style="display: none;">
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="show_sticker_form" method="post" id="show_sticker_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 id="invoce_html_pay">
					<div class="modal-body" >
							<input type="hidden" name="sticker_inv_numb" id="sticker_inv_numb">
							<div id="sticker_show">
								<!-- Borderless table -->


								<!-- /borderless table -->
							</div>
					</div>
				</div>
				<div class="modal-footer">
					<div id="link_pdf_pay"></div>
					<button type="submit" class="btn btn-labeled btn-labeled-left heading-btn btn-primary" id="pdf_pay"> <span class="multi_lang">توليد  PDF</span>  <b><i class="icon-file-pdf"></i></b>
					</button>
					<button type="submit" class="btn btn-labeled btn-labeled-left heading-btn btn-success" id="print_pay"><span class="multi_lang">طباعة</span>  <b><i class=" icon-printer2"></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_payments_modal" class="modal fade" style="display: none;">
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="show_payments_form" method="post" id="show_payments_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 id="invoce_html_pay">
					<div class="modal-body" >
							<input type="hidden" name="inv_numb" id="inv_numb">
							<div id="invoice_show">
								<!-- Borderless table -->


								<!-- /borderless table -->
							</div>
					</div>
				</div>
				<div class="modal-footer">
					<div id="link_pdf_pay"></div>
					<button type="submit" class="btn btn-labeled btn-labeled-left heading-btn btn-primary" id="pdf_pay"> <span class="multi_lang">توليد  PDF</span>  <b><i class="icon-file-pdf"></i></b>
					</button>
					<button type="submit" class="btn btn-labeled btn-labeled-left heading-btn btn-success" id="print_pay"><span class="multi_lang">طباعة</span>  <b><i class=" icon-printer2"></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_payments_modal" class="modal fade" >
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="add_payments_form" method="post" id="add_payments_form" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="">
			<input type="hidden" name="inv_numb_pay" id="inv_numb_pay" 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"> <i class="icon-bag"></i><span class="multi_lang">اضافة دفعة</span>  </h4>
				</div>

				<div class="modal-body">
						<div id="invoice_pay_add">
							
							
							
						</div>
				</div>
				<div class="modal-footer">
					<button type="submit" id="submit_add_pay_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_payments_modal" class="modal fade" >
		<div class="modal-dialog modal-lg" style="width: 80%;">
			<form class="form-horizontal" method="post" id="add_payments_form" enctype="multipart/form-data">
						
					<input type="hidden" id="access_token" name="access_token"  value="">
					<input type="hidden" id="pay_type" name="pay_type"  value="Raw">
					<input type="hidden" id="customer_id_fk_pay" name="customer_id_fk_pay"  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" >

						<div class="row">
							<div class="col-sm-3">
								<div class="alert alert-info alert-styled-right alert-arrow-right alert-bordered">
									<span class="text-semibold multi_lang" > المبلغ الكلي : </span>
									<span class="text-semibold" data-original-amount="" id="total_customer_account"></span>
							    </div>
							</div>

							<div class="col-sm-3">
								<div class="alert alert-warning alert-styled-right alert-arrow-right alert-bordered">
									<span class="text-semibold multi_lang" > خصومات الحساب : </span>
									<span class="text-semibold" data-original-amount="" id="total_customer_discount"></span>
							    </div>
							</div>

							<div class="col-sm-3">
								<div class="alert alert-success alert-styled-right alert-arrow-right alert-bordered ">
									<span class="text-semibold multi_lang" >المبلغ المدفوع : </span>
									<span class="text-semibold" data-original-amount="" id="total_customer_paid"></span>
							    </div>
							</div>

							<div class="col-sm-3">
								<div class="alert alert-danger alert-styled-right alert-arrow-right alert-bordered ">
									<span class="text-semibold multi_lang" > المبلغ المتبقي : </span>
									<span class="text-semibold" data-original-amount="" id="total_customer_remaind"></span>
							    </div>
							</div>

						</div>

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

							

							<div class="form-group">


								
								
								<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="payment_withdraw_amount" name="payment_withdraw_amount" class="form-control multi_lang" placeholder=" مبلغ الدفعة " required="required" onchange="calc_general_pay(this.value,this.id);">
									<div class="form-control-feedback">
										<i class="icon-wallet 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="paid_date" name="paid_date" class="form-control daterange-single multi_lang" placeholder="التاريخ" 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-3">
									<label class="control-label multi_lang">الملاحظات</label>
									<input type="text" id="payment_note" name="payment_note" class="form-control multi_lang" placeholder="الملاحظات" >
									<div class="form-control-feedback">
										<i class="icon-info22 text-muted"></i>
									</div>
								</div>

								<div class="form-group has-feedback has-feedback-left  col-sm-3">
									<label class="control-label animate multi_lang">الصنف</label>
									
									<select name="item_type_id_fk" id="item_type_id_fk" class="form-control" >
									

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



							</div>

						</div>
					
					</div>
				
				<div class="modal-footer">
					<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>
						<button type="button" class="btn btn-warning multi_lang" data-dismiss="modal"> اغلاق
						</button>
					</div>
				</div>
				</div>
				</form>
		</div>
	</div>



<div id="edit_payments_modal" class="modal fade" >
		<div class="modal-dialog modal-lg">
		<form class="form-horizontal"  name="edit_payments_form" method="post" id="edit_payments_form" enctype="multipart/form-data">
			<input type="hidden" id="access_token" name="access_token"  value="">
			<input type="hidden" name="itemid_payment" id="itemid_payment" value="">
			<input type="hidden" name="edit_pay_inv_id" id="edit_pay_inv_id" 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"> <i class="icon-pencil15"></i><span class="multi_lang">تحرير الدفوعات</span>  </h4>
				</div>

				<div class="modal-body">
							<div class="col-sm-12" id="edit_payments_fields">


							</div>
				</div>
				<div class="modal-footer">

					</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="customer_type" name="customer_type"  value="<?php echo $_GET['typ']; ?>">

			<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="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" placeholder="اسم الزبون الكامل" class="form-control multi_lang" name="customer_full_name" id="customer_full_name" required="required">
								<div class="form-control-feedback">
									<i class="icon-profile 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" placeholder="البريد الالكتروني" class="form-control multi_lang" name="customer_email" id="customer_email" >
								<div class="form-control-feedback">
									<i class="icon-mail5 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" class="form-control multi_lang" name="customer_phone" id="customer_phone" required="required" placeholder="رقم الهاتف">
								
								<div class="form-control-feedback">
									<i class="icon-phone2 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" class="form-control multi_lang" name="customer_phone2" id="customer_phone2"  placeholder="الهاتف الثاني">
								
								<div class="form-control-feedback">
									<i class="icon-phone 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" placeholder="العنوان" class="form-control multi_lang" name="customer_address" id="customer_address" >
								<div class="form-control-feedback">
									<i class="icon-location4 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" placeholder="المهنة" class="form-control multi_lang" name="customer_job_title" id="customer_job_title" >
								<div class="form-control-feedback">
									<i class="icon-briefcase text-muted"></i>
								</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-form-cont" class="panel-collapse collapse panel" autocomplete="~~~~~~~~" 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">

			<input type="hidden" id="access_token" name="access_token"  value="">
			<input type="hidden" id="invoice_type" name="invoice_type" value="1">
			<input type="hidden" id="invoice_type_singular" name="invoice_type_singular" value="<?php echo $_GET['typ']; ?>">
			<input type="hidden" id="total_rows" name="total_rows" value="1">
			<input type="hidden" id="total_rows_other" name="total_rows_other" value="1">
			<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">اسم الزبون</label>
						
						<select class="form-control multi_lang stop_enter" data-live-search="true" name="customer_id_fk" id="customer_id_fk" data-width="100%" placeholder="اسم الزبون">

						</select>
						<div class="form-control-feedback">
							<i class="icon-user 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_category"> <b><i class="icon-add"></i></b></a>
					</div>

					<div class="form-group has-feedback has-feedback-left form-group-material col-sm-3">
						<label class="control-label"><span class="multi_lang">الدفع بعد (يوم)</span> <i class="icon-bell3 text-muted"></i></label>
						<input type="text" id="pay_term" name="pay_term" value="1" class="touchspin-basic multi_lang stop_enter" placeholder="الدفع بعد (يوم)" required="required">

						
					</div>

					<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
						<label class="control-label multi_lang">التاريخ</label>
							<input type="text" id="invoice_date" name="invoice_date" class="form-control multi_lang daterange-single stop_enter" placeholder="التاريخ" required="required">
							<div class="form-control-feedback">
								<i class=" icon-calendar52 text-muted"></i>
							</div>
					</div>
				</div>

				<div class="form-group">

					<div class="form-group has-feedback has-feedback-left col-sm-4">
						<label class="control-label multi_lang">ملف الاسعار</label>
						
						<select class="form-control multi_lang stop_enter" data-live-search="true" name="price_profile_id" id="price_profile_id" data-width="100%" placeholder="ملف الاسعار">

						</select>
						<div class="form-control-feedback">
							<i class="icon-coins 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 class="form-control multi_lang"  name="sell_discount_type" id="sell_discount_type" data-width="100%" placeholder="ملف الاسعار">
							<option class="multi_lang" value="0">نسبة مؤية</option>
							<option class="multi_lang" value="1">قيمة مطلقة</option>
						</select>
						<div class="form-control-feedback">
							<i class="icon-coins text-muted"></i>
						</div>
					</div> -->


					

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


				</div>

				<div class="form-group">
					<div class="table-responsive1">
					<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 class="multi_lang">العرض (م) / اطوال المواد</th>
								<th class="multi_lang">الارتفاع (م)</th>
								<th class="multi_lang">المساحة (م<sup>2</sup>) / الطول الكلي م</th>
								<!-- <th class="multi_lang">اخر سعر بيع</th> -->
								<th class="multi_lang">سعر البيع (م<sup>2</sup>)</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></th>
							</tr>
						</thead>
						<tbody id="purchase_item_body" >
							<tr  id="item_row_1" >
								<td width="3%" id="num_1">1</td>

								<td width="8%">
									

									<select class="form-control multi_lang stop_enter" name="product_id_fk_1" id="product_id_fk_1" data-width="100%" placeholder="رمز المادة"  data-live-search="true">

									</select>

									<input id="item_type_id_1" class="multi_lang" name="item_type_id_1" type="hidden" placeholder="رمز المادة">
								</td>

								<td width="8%" id="forign_id_1"></td>

								<td width="6%">
									<input autocomplete="~~~~~~~~" type="number" id="purchase_quantity_1" name="purchase_quantity_1"  class="form-control text-center multi_lang stop_enter" placeholder="العدد"  value="1">
								</td>

								<td width="6%" id="products_width_1" >
									<input autocomplete="~~~~~~~~" type="text" id="curtain_width_1" name="curtain_width_1"  class="form-control text-center multi_lang stop_enter" placeholder="العرض"  onchange="compute_area(this.value,this.id,1);">
									
								</td>

								<td width="6%" id="products_height_1">
									<input autocomplete="~~~~~~~~" type="text" id="curtain_height_1" name="curtain_height_1"  class="form-control text-center multi_lang stop_enter" placeholder="الارتفاع"  onchange="compute_area(this.value,this.id,1);">
								</td>

								<td width="7%" >
									<input id="total_length_1" name="total_length_1" type="text" class="form-control text-center stop_enter" readonly >
								</td>

								<!-- <td width="6%">
									<input id="last_sell_price_1" name="last_sell_price_1" type="text" class="form-control text-center multi_lang" placeholder="اخر سعر بيع" readonly >
								</td> -->
								<td width="7%">
									<input autocomplete="~~~~~~~~" id="buy_price_per_meter_1" name="buy_price_per_meter_1" type="text" class="form-control text-center multi_lang stop_enter" placeholder="سعر بيع المتر" onchange="calc_total_item_cost(this.id,1);" >
								</td>

								<!-- <td width="6%">
									<input id="last_sell_price_decor_1" name="last_sell_price_decor_1" type="text" class="form-control text-center multi_lang" placeholder="اخر سعر بيع ديكور" readonly >
								</td> -->

								<td width="7%">
									<input autocomplete="~~~~~~~~" id="buy_price_per_meter_decor_1" name="buy_price_per_meter_decor_1" type="text" class="form-control text-center multi_lang stop_enter" placeholder="سعر بيع متر الديكور" onchange="calc_total_item_cost(this.id,1);" >
								</td>


								<td width="7%">
									<input autocomplete="~~~~~~~~" id="sell_discount_1" name="sell_discount_1" data-discount-type="" data-discount-actual="" type="text" class="form-control text-center multi_lang stop_enter" placeholder="تنزيلات" onchange="calc_total_item_cost(this.id,1);" >
								</td>
								<td width="9%" >
									<input autocomplete="~~~~~~~~" id="total_item_cost_1" name="total_item_cost_1" type="text" value="0 $" class="form-control text-center stop_enter" readonly="readonly" >
								</td>
								<td width="15%">
									

									<span id="purchase_item_note_1" ></span>

									<span class="btn btn-link btn_add_note  legitRipple" idkey="1" style="float : left; display: inline; margin-top: 10px; padding: 0;" title="اضافة الملاحظة الحالية">
	        	                         <i class="icon-add text-teal-600"></i>
	        	                    </span>

								</td>
								<td width="9%" >
									<input autocomplete="~~~~~~~~" id="sell_item_delivery_name_1" name="sell_item_delivery_name_1" type="text" class="form-control text-center last_cell stop_enter" placeholder="المستلم">
								</td>
								<!-- <td width="7%" >
									<input id="product_pay_1" name="product_pay_1" type="text"  class="form-control multi_lang text-center" placeholder="المبلغ المدفوع" onchange="calc_payments(1);">
								
								</td> -->
								<td width="6%">
									<button class="btn btn-link btn_add_item " id="">
										<i  class="icon-add text-blue "></i>
									</button>
									
								</td>
							</tr>

							
							

							
							
						</tbody>
						<tfoot id="purchase_item_footer">
							<tr  id="item_row_other_1" >
								<td width="3%" id="num_1">#1</td>

								<td width="8%" colspan="2">
									<select class="form-control multi_lang stop_enter" data-live-search="true" name="other_id_fk_1" id="other_id_fk_1" data-width="100%" placeholder="مواد اخرى" >
									</select>
								</td>
								
								<td width="6%">
									<input type="number" id="other_quantity_1" name="other_quantity_1"  class="form-control text-center multi_lang stop_enter" placeholder="العدد" onchange="calc_other_cost(1);" autocomplete="~~~~~~~~">
								</td>

								<td id="products_other" colspan="2"></td>

								<td width="7%" >
									<input id="total_length_other_1" name="total_length_other_1" type="text" class="form-control text-center stop_enter" readonly >
								</td>

								<!-- <td width="6%">
									<input id="last_sell_price_other_1" name="last_sell_price_other_1" type="text" class="form-control text-center multi_lang" placeholder="اخر سعر بيع" readonly >
								</td> -->
								<td width="7%" colspan="2">
									<input id="buy_price_per_meter_other_1" name="buy_price_per_meter_other_1" type="text" class="form-control text-center multi_lang stop_enter" placeholder="سعر البيع" onchange="calc_other_cost(1);" autocomplete="~~~~~~~~">
								</td>
								<td width="7%">
									<input id="sell_discount_other_1" name="sell_discount_other_1" data-discount-type="" data-discount-actual="" type="text" class="form-control text-center multi_lang stop_enter" placeholder="تنزيلات" onchange="calc_other_cost(1);" autocomplete="~~~~~~~~">
								</td>
								<td width="9%" >
									<input id="total_item_cost_other_1" name="total_item_cost_other_1" type="text" value="0 $" class="form-control text-center stop_enter" readonly >
								
								</td>
								
								<td width="9%">
									<input autocomplete="~~~~~~~~" type="text" id="purchase_item_note_other_1" name="purchase_item_note_other_1" class="form-control multi_lang stop_enter" placeholder="ملاحظات" >
								</td>
								<td width="9%" >
									<input autocomplete="~~~~~~~~" id="sell_item_delivery_name_other_1" name="sell_item_delivery_name_other_1" type="text"  class="form-control text-center stop_enter" placeholder="المستلم" >
								
								</td>
								<!-- <td width="7%" >
									<input id="other_pay_1" name="other_pay_1" type="text"  class="form-control multi_lang text-center" placeholder="المبلغ المدفوع" onchange="calc_payments('other',1);" >
								
								</td> -->
								<td width="6%">
									<button class="btn btn-link" id="add_others_btn">
										<i  class="icon-database-add text-teal"></i>
									</button>
								</td>
							</tr>
							<tr class="alpha-teal">
								<th class="multi_lang">مجموع</th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<!-- <th></th>
								<th></th> -->
								<th></th>
								
								<th >
									<input id="purchase_total" name="purchase_total" type="text" value="0 $" class="form-control text-center stop_enter" readonly >
								</th>
								<th></th>
								<th></th>
								<!-- <th>
									<input id="total_paid" name="total_paid" type="text" value="0 $" class="form-control text-center" readonly >
								</th> -->
								<th><i  class="icon-sigma "></i></th>
							</tr>

							<tr class="alpha-danger">
								<th class="multi_lang">الدفعة</th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<th></th>
								<!-- <th></th>
								<th></th> -->
								<th></th>
								
								
								<th>
									<input autocomplete="~~~~~~~~" id="total_paid" name="total_paid" type="text" value="" class="form-control text-center submit_enter" onchange="calc_payments();">
								</th>
								<th></th>
								<th></th>
								<!-- <th>
									<input id="total_paid" name="total_paid" type="text" value="0 $" class="form-control text-center" readonly >
								</th> -->
								<th><i  class="icon-cash "></i></th>
							</tr>
						</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: 94%;">
		<form class="form-horizontal"  name="edit_form" method="post" id="edit_form" enctype="multipart/form-data">
			<input type="hidden" id="edit_invoice_id" name="edit_invoice_id" 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">تحرير المبيعات</h4>
				</div>

				<div class="modal-body">
						
					<div>
						<input type="hidden" id="edit_invoice_type" name="edit_invoice_type" value="1">
						<input type="hidden" id="edit_is_single" name="edit_is_single" value="<?php echo $_GET['typ']; ?>">
						<input type="hidden" id="edit_total_rows" name="edit_total_rows" value="1">
						<input type="hidden" id="edit_total_rows_other" name="edit_total_rows_other" value="1">
						<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">اسم الزبون</label>
									
									<input type="text" class="form-control multi_lang"  name="edit_customer_id_fk" id="edit_customer_id_fk"  placeholder="اسم الزبون" data-fk="" readonly>

									
									<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-4">
									<label class="control-label"><span class="multi_lang"> الدفع بعد (يوم) </span><i class="icon-bell3 text-muted"></i></label>
									<input type="text" id="edit_pay_term" name="edit_pay_term" value="1" class="touchspin-basic multi_lang" placeholder="الدفع بعد (يوم)" required="required">

									
								</div>

								<div class="form-group has-feedback has-feedback-left form-group-material col-sm-4">
									<label class="control-label multi_lang">التاريخ</label>
										<input type="text" id="edit_invoice_date" name="edit_invoice_date" class="form-control multi_lang daterange-single" placeholder="التاريخ" required="required">
										<div class="form-control-feedback">
											<i class=" icon-calendar52 text-muted"></i>
										</div>
								</div>
							</div>

							<div class="form-group">

								<div class="form-group has-feedback has-feedback-left col-sm-4">
									<label class="control-label multi_lang">ملف الاسعار</label>
									
									<select class="form-control multi_lang" data-live-search="true" name="edit_price_profile_id" id="edit_price_profile_id" data-width="100%" placeholder="ملف الاسعار">

									</select>
									<div class="form-control-feedback">
										<i class="icon-coins 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_invoice_number" name="edit_invoice_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="control-label multi_lang">ملاحظات</label>
									<textarea type="text" id="edit_invoice_note" name="edit_invoice_note" class="form-control multi_lang" placeholder="ملاحظات" > </textarea> 
									<div class="form-control-feedback">
										<i class="icon-notebook text-muted"></i>
									</div>
								</div>
								


							</div>

							<div class="form-group">
								<div class="table-responsive1">
								<table class="table col-sm-12 table-bordered .table-sm">
									<thead>
										<tr class="bg-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 class="multi_lang">المساحة (م<sup>2</sup>) / الطول الكلي م</th>
											<!-- <th class="multi_lang">اخر سعر بيع</th> -->
											<th class="multi_lang">سعر البيع (م<sup>2</sup>)</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></th>
										</tr>
									</thead>
									<tbody id="edit_purchase_item_body" >
										
										

										
										
									</tbody>
									<tfoot id="edit_purchase_item_footer">
										
									</tfoot>
								</table>
							</div>



							</div>

							

							



						</div>
					</div>
						
				</div>
				<div class="modal-footer">
					<button type="submit" id="submit_edit_btn" class="btn btn-labeled btn-labeled-left heading-btn btn-primary"> Save <b><i class="icon-floppy-disk"></i></b>
					</button>
					<button type="button" class="btn btn-warning" data-dismiss="modal"> Cancel
					</button>
				</div>
			</div>
		</form>
	</div>
</div>


	<div id="add_new_product" class="modal fade" >
			<div class="modal-dialog modal-lg">
			<form class="form-horizontal" method="post" id="add_new_product_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" id="fields_count" name="fields_count"  value="">
						<input type="hidden" id="rows_count" name="rows_count"  value="">
							<div class="col-sm-12">
								

								

								<div class="form-group">
									<label class="control-label multi_lang col-lg-1">القيمة العامة</label>
									<div class="col-lg-5">
										<div class="input-group">
											<input type="text" id="default_val" class="form-control multi_lang" placeholder="القيمة العامة">
											<span class="input-group-btn">
												<button id="default_val_btn" class="btn btn-primary multi_lang" type="button">تطبيق على الكل</button>
											</span>
										</div>
									</div>
								</div>
								
							</div>

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

								<div class="form-group" id="input_box_array">

									

								</div>


							</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" data-dismiss="modal"><span class="multi_lang">اغلاق</span> 
						</button>
				</div>
				</div>
			  </div>
			</form>

		</div>
	</div>

	<div id="add_new_product_from_purchase" class="modal fade" >
			<div class="modal-dialog modal-lg">
			<form class="form-horizontal" method="post" id="add_new_product_form_from_purchase" 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-center text-blue"><span class="multi_lang"> الكمية المختارة :</span> <span id="total_selected" class="text-danger"></span> <span class="multi_lang">طول قماش ( المجموع الكلي =</span>  <span id="total_sel_roll_length" class="text-orange"></span> <span class="multi_lang">متر</span>) </h4>
					</div>

					<div class="modal-body">

						<div>
						<input type="hidden" id="fields_count_purchase" name="fields_count_purchase"  value="">
						<input type="hidden" id="rolls_count_purchase" name="rolls_count_purchase"  value="">
						<input type="hidden" id="rows_count_purchase" name="rows_count_purchase"  value="">
							<div class="col-sm-12">
								

								

								
								
							</div>

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

								<div class="form-group" id="input_box_array_purchase">

									

								</div>


							</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" data-dismiss="modal"><span class="multi_lang">اغلاق</span> 
						</button>
				</div>
				</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">المبلغ الصافي</th>
								<th class="multi_lang">الحالة</th>
								<th class="multi_lang">ملاحظات</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>
				            </tr>
						</tfoot>
					</table>
				</div>
				<!-- /individual column searching (text inputs) -->



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