<?php
$permission  = explode(',',$_SESSION['permission_id']);
if(!in_array(18,$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="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 multi_lang" data-dismiss="modal"> اغلاق
					</button>
				</div>
			</div>
		</form>
	</div>
</div>


<div id="add_payments_modal" class="modal fade" >
	<div class="modal-dialog modal-full">
		<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="customer_id_fk" name="customer_id_fk"  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  col-sm-6">
								<label class="control-label animate multi_lang">اسم المدين</label>
								
								<select name="payment_gived_to_id_fk" id="payment_gived_to_id_fk" class="form-control" required="required">
								

								</select>
								<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-2">
								<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="compute_remain_price(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-2">
								<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-2">
								<label class="control-label multi_lang">رقم الوصل الورقي</label>
								<input type="text" id="paper_number" name="paper_number" class="form-control multi_lang" placeholder="رقم الوصل الروقي"  required="required">
								<div class="form-control-feedback">
									<i class="icon-hash text-muted"></i>
								</div>
							</div>

							<div class="form-group has-feedback has-feedback-left form-group-material col-sm-2">
								<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 form-group-material col-sm-2" >

								<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 form-group-material col-sm-2" >

								<label class="control-label animate">Saleman</label>
								<select name="saleman_id" id="saleman_id" class="form-control"  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 multi_lang">نوع العملة</label>
								<select name="expenses_currency" id="expenses_currency" class="form-control" required="required">
										<option class="multi_lang" value="" selected="selected">نوع العملة</option>
										<option class="multi_lang"  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>

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




				<!-- 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="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>
				            </tr>
						</tfoot>
					</table>
				</div>
				<!-- /individual column searching (text inputs) -->



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