
<?php 
	if(isset($_SESSION['COM_ID'])){
		$com_id=$_SESSION['COM_ID'];
		date_default_timezone_set("Asia/Dhaka");
		$date=date("Y-m-d");
		$sales_details=$conn->query("SELECT id,shipping_tk,courier,cus_mobile,insert_date,f_total,others_tk,discount_tk,(select sum(amount) from accounting_fabrics where dsms_id=direct_sale_head.id and is_active=1 and pay_status in(0,1)) total_receive,(select cus_address from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_address,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_name,(select id from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_id,(select order_number from direct_sale where dstid=direct_sale_head.id and is_active=1 limit 0,1) ord_num FROM `direct_sale_head` WHERE com_id=$com_id and date(insert_date)='$date' and is_active!=0 and in_out_status=0 and is_order=0 and courier_book=0 and courier!='' order by id desc limit 0,200");
		
		mysqli_close($conn);		
?>

<ul class="nav nav-tabs">
	
    <li class="active"><a style="font-weight: bold;font-size: 16px;" onclick="getCustomerFabricsOrderListCourier('1','sales_pending','panel','');" data-toggle="tab" href="#home">Pending</a></li>
	
    <li><a style="font-weight: bold;font-size: 16px;" data-toggle="tab" onclick="getCustomerFabricsOrderListCourier('2','sales_booked','panel','');" id="attach_tbl" href="#menu1">Booked</a></li>
	
    <li><a style="font-weight: bold;font-size: 16px;" data-toggle="tab" id="order_print_delivered" onclick="getCustomerFabricsOrderListCourier('4','sales_delivered','panel','');" href="#menu2">Delivered</a></li>
    <li><a style="font-weight: bold;font-size: 16px;" data-toggle="tab" id="order_print_return" onclick="getCustomerFabricsOrderListCourier('3','sales_return','panel','');" href="#menu3">Return</a></li>
    
</ul>

<div class="tab-content" id="tabs">
    <div id="home" class="tab-pane fade in active">
	<br/>
     
	<div class="panel-group">
		 <div id="show_history">
	  
		   <div class='panel panel-info' style="color: black; box-shadow: inset 0 0 1em gray; padding: 15px;margin-left: 0px;margin-right: 0px;">
			  <div class="panel-heading">
			  <div style="overflow:hidden">
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('search_ord_num','sales_pending','','1');" placeholder="অর্ডার নম্বর" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 12%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="search_ord_num1"/>
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('cus_name_mobile','sales_pending','','1');" placeholder="মোবাইল" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 18%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="cus_name_mobile1"/>
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kstart_date','sales_pending','','1');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="Start Date" id="kstart_date1" class="form-control" />	
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kend_date','sales_pending','','1');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="End Date" id="kend_date1" class="form-control" />	
				
				<span style="float: right;font-size: 22px;">Pending</span>
				</div>
			  </div>
			 
			  <div class="panel-body">
					<div class="row" style="background: white;">
					
					<div class="col-xs-12 col-sm-12" style="">
						<button onclick="printOrder('1');" style="margin-right:15px" name="btn" id="printBtns1" value="sub" class="btn btn-info">Print</button>
						<span id="clear_action1" onclick="closeArea('1');" style="color:red;font-weight:bold;cursor:pointer">Clear</span>
							
						<span id="sales_return_print_page1"></span>
						<span id="sales_pending">
							<table id="example" class="table table-striped table-bordered">
							<thead>
								<tr>
									<th style="text-align:center">Order No.</th>
									<th style="">Courier</th>
									<th style="text-align:center;width: 20%;">Address</th>
									<th>Sales Date</th>
									<th style="text-align:right;background:#c6cdf4ba">Net Total</th>
									<th style="text-align:right">discount(Tk)</th>
									<th style="text-align:right">Total(Tk)</th>
									<th style="text-align:right">shipping</th>
									<th style="text-align:right;background: #aacae7c9;">Advance</th>
									<th style="text-align:right;background: #ffff008a;">Due</th>
									<th style="text-align:center">Action</th>
								</tr>
							</thead>
							<tbody id="tbl_two2">
								<?php 
								$gtotal=0;
								if(mysqli_num_rows($sales_details)>0){
									$i=1;$ttk=0;$others=0;$total=0;$gtotal=0;
									while($row=mysqli_fetch_array($sales_details)){
										$ttk=$row['f_total'];
										$total_receive=$row['total_receive'];
										$others=$row['others_tk'];
										$discount=$row['discount_tk'];
										$shipping_tk=$row['shipping_tk'];
										$courier=$row['courier'];
										$total=($ttk+$others)-$discount;
										$due=$total-$total_receive+$shipping_tk;
										$gtotal+=$total;
										?>
											<tr id="frow<?php echo $row['id']; ?>">
												<td style="text-align:center">
													<?php echo $row['id']; ?>
												</td>
												<td style="">
													<p><i style="color:blue"><?php echo $row['courier']; ?></i></p>
													<span style="cursor: pointer;" class="btn btn-success" onclick="bookCourier('<?php echo $row['id']; ?>');"><i>Book</i></span>
												</td>
												<td style="text-align:center;line-height: 10px;" id="cus_mobile_row<?php echo $row['id']; ?>">
													<p><?php echo $row['cus_name']; ?></p>
													<p><?php echo $row['cus_address']; ?></p>
													<p><i style=""><?php echo $row['cus_mobile']; ?></i></p>
												</td>
												<td><?php echo $row['insert_date']; ?></td>
												<td style="text-align:right;background:#c6cdf4ba" id="netpay<?php echo $row['id']; ?>"><?php echo $ttk; ?></td>
												<td style="text-align:right" id="tbl_discount_tk<?php echo $row['id']; ?>"><?php echo $discount; ?></td>
												<td style="text-align:right" id="tbl_total_tk<?php echo $row['id']; ?>"><?php echo $total; ?></td>
												<td style="text-align:right"><?php echo $shipping_tk; ?></td>
												<td style="text-align:right;background: #aacae7c9;"><?php echo $total_receive; ?></td>
												<td style="text-align:right;background: #ffff008a;"><?php echo $due; ?></td>
												
												<td style="text-align:center;"><?php 
													if($row['ord_num']=="" || $row['ord_num']=="0"){
														?>
														<span style="cursor: pointer;color:#ff0000c7;" onclick="showDetailSales('<?php echo $row['id']; ?>','1');"><i>Edit</i></span> | 
														<span style="cursor: pointer;color:green;" onclick="payDetailSales('<?php echo $row['id']; ?>','1');"><i>Pay</i></span> | 
														<span style="cursor: pointer;color:#0000ffd1;" onclick="dateWisePrint('<?php echo $row['id']; ?>','10','1');"><i>View</i></span>
														<?php 
													}
													?>
												</td>
											</tr>
										<?php 
									}
								}
								
								?>
								<tr>
									<th colspan="6" style="text-align:right">Total: </th>
									<th style="text-align:right"><?php echo $gtotal; ?></th>
								</tr>
								
							</tbody>
						</table>
						</span>
						
					</div>
				</div>
					
			  </div>
			 
		   </div>
		
	   </div>	
	</div>
</div>

	 <div id="menu1" class="tab-pane">
       <br/>
		<div class="panel-group">
		
	  
		   <div class='panel panel-info' style="color: black; box-shadow: inset 0 0 1em gray; padding: 15px;margin-left: 0px;margin-right: 0px;">
			  <div class="panel-heading">
			  <div style="overflow:hidden">
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('search_ord_num','sales_booked','','2');" placeholder="অর্ডার নম্বর" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 12%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="search_ord_num2"/>
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('cus_name_mobile','sales_booked','','2');" placeholder="মোবাইল" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 18%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="cus_name_mobile2"/>
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kstart_date','sales_booked','','2');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="Start Date" id="kstart_date2" class="form-control" />	
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kend_date','sales_booked','','2');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="End Date" id="kend_date2" class="form-control" />	

				<span style="float: right;font-size: 22px;">Booked</span>
				</div>
			  </div>
			 
			  <div class="panel-body">
					<div class="row" style="background: white;">
					
					<div class="col-xs-12 col-sm-12" style="">
						<button onclick="printOrder('2');" style="margin-right:15px" name="btn" id="printBtns2" value="sub" class="btn btn-info">Print</button>
						<span id="clear_action2" onclick="closeArea('2');" style="color:red;font-weight:bold;cursor:pointer">Clear</span>
						
						<span id="sales_return_print_page2"></span>
						
						<span id="sales_booked">
						</span>
						
					</div>
				</div>
					
			  </div>
			 
		   </div>
		
	  
	</div>
   </div>
 
	<div id="menu2" class="tab-pane">
     <br/>
			<div class="panel-group">
		
	  
		   <div class='panel panel-info' style="color: black; box-shadow: inset 0 0 1em gray; padding: 15px;margin-left: 0px;margin-right: 0px;">
			  <div class="panel-heading">
			  <div style="overflow:hidden">
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('search_ord_num','sales_delivered','','4');" placeholder="অর্ডার নম্বর" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 12%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="search_ord_num4"/>
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('cus_name_mobile','sales_delivered','','4');" placeholder="মোবাইল" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 18%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="cus_name_mobile4"/>
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kstart_date','sales_delivered','','4');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="Start Date" id="kstart_date4" class="form-control" />	
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kend_date','sales_delivered','','4');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="End Date" id="kend_date4" class="form-control" />	
				
				<span style="float: right;font-size: 22px;">Delivered</span>
				</div>
			  </div>
			 
			  <div class="panel-body">
					<div class="row" style="background: white;">
					
					<div class="col-xs-12 col-sm-12" style="">
						<button onclick="printOrder('4');" style="margin-right:15px" name="btn" id="printBtns4" value="sub" class="btn btn-info">Print</button>
						<span id="clear_action4" onclick="closeArea('4');" style="color:red;font-weight:bold;cursor:pointer">Clear</span>
						
						<span id="sales_return_print_page4"></span>
						<span id="sales_delivered">
							
						</span>
						
					</div>
				</div>
					
			  </div>
			 
		   </div>
		
	  
	</div>
    </div>
	
		<div id="menu3" class="tab-pane">
     <br/>
			<div class="panel-group">
		
	  
		   <div class='panel panel-info' style="color: black; box-shadow: inset 0 0 1em gray; padding: 15px;margin-left: 0px;margin-right: 0px;">
			  <div class="panel-heading">
			  <div style="overflow:hidden">
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('search_ord_num','sales_return','','3');" placeholder="অর্ডার নম্বর" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 12%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="search_ord_num3"/>
				<input type="text" onkeyup="getCustomerFabricsOrderListCourier('cus_name_mobile','sales_return','','3');" placeholder="মোবাইল" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;width: 18%;float:left;margin-right: 5px;" autocomplete="off" name="total_due" id="cus_name_mobile3"/>
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kstart_date','sales_return','','3');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="Start Date" id="kstart_date3" class="form-control" />	
				<input type="text" onchange="getCustomerFabricsOrderListCourier('kend_date','sales_return','','3');" style="width: 18%;float: left; margin-right: 5px;font-weight: bold;font-size:18px;" autocomplete="off" placeholder="End Date" id="kend_date3" class="form-control" />	
				
				<span style="float: right;font-size: 22px;">Return</span>
				</div>
			  </div>
			 
			  <div class="panel-body">
					<div class="row" style="background: white;">
					
					<div class="col-xs-12 col-sm-12" style="">
						<button onclick="printOrder('3');" style="margin-right:15px" name="btn" id="printBtns3" value="sub" class="btn btn-info">Print</button>
						<span id="clear_action3" onclick="closeArea('3');" style="color:red;font-weight:bold;cursor:pointer">Clear</span>
						
						<span id="sales_return_print_page3"></span>
						<span id="sales_return">
							
						</span>
						
					</div>
				</div>
					
			  </div>
			 
		   </div>
		
	  
	</div>
    </div>
	
</div>

 <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-lg" id="modal_width">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title" id="heading_id"></h4>
        </div>
        <div class="modal-body">
          <span id="smeasurement"></span>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>

  
  <script>
  
  $(function() {
		$( "#attenstart_date,#attenend_date,#attendance_date,#mstart_date,#kstart_date1,#kend_date1,#kstart_date2,#kend_date2,#kstart_date3,#kend_date3,#kend_date4,#kstart_date4,#rend_date,#pstart_date,#pend_date" ).datepicker({
			dateFormat: 'dd/mm/yy' 
		});
		$("#mend_date" ).datepicker({
			dateFormat: 'dd/mm/yy' 
		});
		
		
	});
	
$(document).ready(function(){
		$(".select2").select2();
		$("#head_measurement,#edit_measurement,#clear_action1,#printBtns1,#clear_action2,#printBtns2,#clear_action3,#printBtns3,#clear_action4,#printBtns4").hide();
});

function closeArea(param){
	$("#sales_return_print_page"+param).html(null);
	$("#clear_action"+param).hide();
	$("#printBtns"+param).hide();
}


function getCustomerFabricsOrderListCourier(searh_status,div_area,darea,other_status){
	var search_ord_num="",cus_name_mobile="",kstart_date="",kend_date="";
	if(darea=='panel'){
		var searching_status=searh_status; //$("#searching_status").val();
		other_status=searh_status;
	}else{
		search_ord_num=$("#search_ord_num"+other_status).val();
		cus_name_mobile=$("#cus_name_mobile"+other_status).val();
		kstart_date=$("#kstart_date"+other_status).val();
		kend_date=$("#kend_date"+other_status).val();
		if(other_status!=""){
			var searching_status=other_status;
		}else{
			var searching_status=other_status;//$("#searching_status").val();
		}
	}
	
	
	$.ajax({
		type: 'post',
		url: 'sql.php',
		data: {
			search_ord_num: search_ord_num,
			cus_name_mobile: cus_name_mobile,
			kstart_date: kstart_date,
			kend_date: kend_date,
			searching_status: searching_status,
			other_status: other_status,
			getCustomerFabricsOrderListCourier:1
		},
		 beforeSend: function () {
			$("#"+div_area).html('Wait..');
		},
		 success: function (response) {
			console.log(response);
			if(response!=2){
				$("#"+div_area).html(response);
			}else{
				$("#"+div_area).html("Warning! No result found.");
			}
			$("#clear_action,#printBtns").hide();
		 }
});
}

	function showDetailSales(dstblid,param){
		$.ajax({
			type: 'post',
			url: 'ajax.php',
			data: {
				dstblid:dstblid,
				param:param,
				only_fab_edit_area:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page"+param).html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
				if(response!=2){
					$("#sales_return_print_page"+param).html(response).css("color","black");
				}else{
					$("#sales_return_print_page"+param).html("No Result Found!").css("color","red");
				}
				$("#clear_action"+param).show();
				document.body.scrollTop = 0;
				document.documentElement.scrollTop = 0;
				$(".select2").select2();
			}
		});
	}
	
	function changeItemUnit(dstblid){
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				dstblid:dstblid,
				item_unit:$("#item_sizec"+dstblid).val(),
				changeItemUnit:1
			},
			 success: function (response) {
				if(response!=2){
					$("#item_sizec"+dstblid).css("border-color","blue");
				}else{
					$("#item_sizec"+dstblid).css("border-color","red");
				}
			}
		});
	}
	
	function showDetailSalesCourier(dstblid,other_area){
		$.ajax({
			type: 'post',
			url: 'ajax.php',
			data: {
				dstblid:dstblid,
				param:other_area,
				only_fab_edit_area_courier:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page"+other_area).html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
				if(response!=2){
					$("#sales_return_print_page"+other_area).html(response).css("color","black");
				}else{
					$("#sales_return_print_page"+other_area).html("No Result Found!").css("color","red");
				}
				$("#clear_action"+other_area).show();
				document.body.scrollTop = 0;
				document.documentElement.scrollTop = 0;
				$(".select2").select2();
			}
		});
	}
	
	function payDetailSales(dstblid,param){
		$.ajax({
			type: 'post',
			url: 'ajax.php',
			data: {
				dstblid:dstblid,
				param:param,
				payDetailSales:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page"+param).html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
				if(response!=2){
					$("#sales_return_print_page"+param).html(response).css("color","black");
				}else{
					$("#sales_return_print_page"+param).html("No Result Found!").css("color","red");
				}
				$("#clear_action"+param).show();
				document.body.scrollTop = 0;
				document.documentElement.scrollTop = 0;
				
			}
		});
	}
	
	function bookCourier(ord_number){
		if(confirm('আপনি কি কুরিয়ার বুকিং করতে চান?')){
			$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				dstblid:ord_number,bookCourier:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page").html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
			     console.log(response);
				if(response!=2){
					$("#frow"+ord_number).fadeOut(1000);
					$("#sales_return_print_page").html(null);
				}else{
					$("#sales_return_print_page").html("No Result Found!").css("color","red");
				}
				
			}
		});
		}
	}
	
	function unBookCourier(ord_number){
		if(confirm('আপনি কি কুরিয়ার আনবুক করতে চান?')){
			$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				dstblid:ord_number,unBookCourier:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page").html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
				if(response!=2){
					$("#frow"+ord_number).fadeOut(1000);
					$("#sales_return_print_page").html(null);
				}else{
					$("#sales_return_print_page").html("No Result Found!").css("color","red");
				}
				
			}
		});
		}
	}
	
	/* function BookCourierReturn(ord_number){
		if(confirm('আপনি কি কুরিয়ার Return করতে চান?')){
			$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				dstblid:ord_number,BookCourierReturn:1
			},
			 beforeSend: function () {
				$("#sales_return_print_page").html('<img src="img/loading.gif"/>');
			},
			 success: function (response) {
				if(response!=2){
					$("#frow"+ord_number).fadeOut(1000);
					$("#sales_return_print_page").html(null);
				}else{
					$("#sales_return_print_page").html("No Result Found!").css("color","red");
				}
				
			}
		});
		}
	} */
	
	function delPay(accounting_tbl_id,fab_head_id,param){
		if(confirm('Do you want to delete it?')){
		$.ajax({
				type: 'post',
				url: 'ajax.php',
				data: {
					accounting_tbl_id:accounting_tbl_id,
					fab_head_id:fab_head_id,
					delPay:1
				},
				 beforeSend: function () {
					$("#pay_sms").html('<img src="img/loading.gif"/>');
				},
				success: function (response) {
					console.log(response);
					if(response!=2){
						payDetailSales(fab_head_id,param);
						$("#pay_sms").html('Delete Success!');
					}else{
						$("#pay_sms").html('Delete Not Success!').css('color','red');
					}
				 }
			});
		}
	}
	
	function showLiveDiscount(sl_no){
		var due_tk=($("#fpay_total_tue_tk").val()=="")? 0 : $("#fpay_total_tue_tk").val();
		var present_tk=($("#paytxt"+sl_no).val()=="")? 0 : $("#paytxt"+sl_no).val();
		
		$("#discount_tks"+sl_no).html(parseFloat(due_tk)-parseFloat(present_tk)+" Tk.");
		$("#exdiscount"+sl_no).val(null);
	}
	
	function setDiscountTk(sl_no){
		var due_tk=($("#fpay_total_tue_tk").val()=="")? 0 : $("#fpay_total_tue_tk").val();
		var present_tk=($("#paytxt"+sl_no).val()=="")? 0 : $("#paytxt"+sl_no).val();
		$("#exdiscount"+sl_no).val(parseFloat(due_tk)-parseFloat(present_tk));
	}
	
	function payTk(div_id,param){
		var fab_head_tbl_id=$("#fab_head_tbl_id").val();
		var hide_due=$("#fpay_total_tue_tk").val();
		var exdiscount=$("#exdiscount"+div_id).val();
		var paytxt=$("#paytxt"+div_id).val();
		var payment_type=$("#payment_type"+div_id).val();
		
		if(parseFloat(exdiscount)>parseFloat(hide_due)){
			$("#stksms"+div_id).html("Invalid! Enter correct discount.").css("color","red");
			return;
		}
		
		if(parseFloat(paytxt)>parseFloat(hide_due)){
			$("#stksms"+div_id).html("Invalid! Enter correct payment.").css("color","red");
			return;
		}
		
		if($("#exdiscount"+div_id).val()=="" && $("#paytxt"+div_id).val()==""){
			$("#stksms"+div_id).html("Invalid! Enter discount or payment.").css("color","red");
			return;
		}
		
		
			if(exdiscount!=""){
				if((parseFloat(paytxt)+parseFloat(exdiscount))>parseFloat(hide_due)){
					$("#stksms"+div_id).html("Invalid! Enter correct amount.").css("color","red");
					return;
				}
			}
			
		document.getElementById("paybtns"+div_id).disabled = true;
		$.ajax({
			type: 'post',
			url: 'ajax.php',
			data: {
				fab_head_tbl_id:fab_head_tbl_id,
				hide_due:hide_due,
				exdiscount:exdiscount,
				paytxt:paytxt,
				payment_type:payment_type,
				payTk:1
			},
			 beforeSend: function () {
				$("#pay_sms").html('<img src="img/loading.gif"/>');
			},
			success: function (response) {
				console.log(response);
				if(response!=2){
					payDetailSales(fab_head_tbl_id,param);
					$("#pay_sms").html('Success!');
				}else{
					$("#pay_sms").html('Delete Not Success!').css('color','red');
				}
			 }
	});
	}
	
	function editCustomerInformation(tbl_id,cus_id,field_name,tbl_name,extra_tbl){
		var edit_cus_name=$("#"+field_name).val();
		
			$.ajax({
					type: 'post',
					url: 'sql.php',
					data: {
						tbl_id:tbl_id,
						field_name:field_name,
						edit_cus_name:edit_cus_name,
						customer_id:cus_id,
						tbl_name:tbl_name,
						extra_tbl:extra_tbl,
						editAllformation:1
					},
					
					 success: function (response) {
						console.log(response);
						if(response==1){
							$("#"+field_name).css("border-color","blue");
						}
					 }
			});
		
		
	}
	
	function updateFabQty(item_id,item_qty,item_per_price,sales_tbl_id,sales_head_id,cus_id,ord_number){
		if($("#edit_fab_qty"+sales_tbl_id).val()==0 || $("#edit_fab_qty"+sales_tbl_id).val()==""){
			alert('Warning! Enter at least one item.');
			$("#edit_fab_qty"+sales_tbl_id).css('border-color','red');
			$("#edit_fab_qty"+sales_tbl_id).focus();
			return;
		}
		
		if(parseFloat(item_qty)==parseFloat($("#edit_fab_qty"+sales_tbl_id).val())){
			$("#edit_fab_qty"+sales_tbl_id).css('border-color','blue');
			return;
		}
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				item_id:item_id,
				item_qty:item_qty,
				edit_fab_qty:$("#edit_fab_qty"+sales_tbl_id).val(),
				item_per_price:item_per_price,
				sales_tbl_id:sales_tbl_id,
				sales_head_id:sales_head_id,
				cus_id:cus_id,
				ord_num:ord_number,
				updateFabQty:1
			},
			 success: function (response) {
				if(response==1){
					$("#edit_fab_qty"+sales_tbl_id).css("border-color","blue");
					document.getElementById("update_btn"+sales_tbl_id).disabled = true;
				}else{
					$("#edit_fab_qty"+sales_tbl_id).css("border-color","red");
				}
				
			}
		});
	}

	
	function liveCheckStockQty(sl_no,tbl_id,item_id,item_qty,head_id,item_per_price,cus_id){
		
		getTotal();
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				tbl_id:tbl_id,
				item_id:item_id,
				item_qty:item_qty,
				edit_fab_qty:$("#edit_fab_qty"+sl_no).val(),
				liveCheckStockQty:1
			},
			 success: function (response) {
				if(response==3){
					alert('Item stock not available.');
					$("#edit_fab_qty"+sl_no).val(item_qty);
					$("#edit_fab_qty"+sl_no).css("border-color","red");
				}else{
					$("#edit_fab_qty"+sl_no).css("border-color","blue");
				}
				//updateFabQtyLive(sl_no,item_id,item_qty,item_per_price,tbl_id,head_id,cus_id,0);
			}
		});
	}
	
	function deleteFabricsOrder(head_id,cus_id,cus_mobile,param){
		var chk="",id_name = "";
		var fab_hidden_id=$("#fab_hidden_id").val();
		if(confirm('Do you want to cancel this order?')){
			$.ajax({
				type: 'post',
				url: 'sql.php',
				data: {
					cus_id:cus_id,
					head_id:head_id,
					cus_mobile:cus_mobile,
					deleteFabricsOrder:1
				},
				success: function (response) {
					console.log(response);
					for(var i=1;i<=fab_hidden_id;i++){
						id_name = document.getElementById("edit_fab_qty" + i);
						if (id_name != null) {
							delDetailsAndStock(fab_hidden_id,i,$("#hidden_fs_tbl_id"+i).val(),$("#hidden_purchase_price"+i).val(),head_id,0,$("#hidden_edit_item_id"+i).val(),$("#hidden_edit_fab_qty"+i).val(),'',cus_id,param);
						}
						//closeArea();
					}
				}
			});
		}
	}
	
	function delDetailsAndStock(last_id,incrementid,deltblid,price,headid,ord_num,item_id,item_qty,cus_mobile,cus_id,param){
			$.ajax({
				type: 'post',
				url: 'sql.php',
				data: {
					headid:headid,
					price:price,
					ord_num:ord_num,
					deltblid:deltblid,
					item_id:item_id,
					item_qty:item_qty,
					cus_mobile:cus_mobile,
					cus_id:cus_id,
					delDetailsAndStock:1
				},
				success: function (response) {
					 console.log(response);
					if(response==1){
						$("#usuccess").html("Delete Success.");
						if(last_id==incrementid){
							closeArea(param);
							 var elem = document.querySelector('#frow' + headid);
							elem.remove();
						}
						
					}
				}
			});
		
	}
	
		function updateAllInfo(head_id,cus_id){
		window.hfs_tblid = [];
		window.hitem_id = [];
		window.hitem_qty = [];
		window.hprice = [];
		window.litem_qty = [];
		window.lprice = [];
		window.loriginal_price = [];
	if(confirm('Do you want to update?')){
		var fab_hidden_id=$("#fab_hidden_id").val();
		var chk="",id_name = "";
		var febdis=($("#discount_percentage").val()=="")? 0 : parseFloat($("#discount_percentage").val());
		for(var i=1;i<=fab_hidden_id;i++){
			id_name = document.getElementById("edit_fab_qty"+i);
			if (id_name != null) {
				if($("#edit_fab_qty"+i).val()=="" || $("#edit_fab_qty"+i).val()==0){
					alert("Warning! Item quantity is missing.");
					$("#edit_fab_qty"+i).click();
					$("#edit_fab_qty"+i).focus();
					chk="notok";
					return;
				}
				if($("#live_item_pricec"+i).val()=="" || $("#live_item_pricec"+i).val()==0){
					alert("Warning! Item price is missing.");
					$("#live_item_pricec"+i).click();
					$("#live_item_pricec"+i).focus();
					chk="notok";
					return;
				}
				
			}
	   }
	   if(chk==""){
			for(var i=1;i<=fab_hidden_id;i++){
				id_name = document.getElementById("edit_fab_qty" + i);
				if (id_name != null) {
					hfs_tblid.push($("#hidden_fs_tbl_id"+i).val());
					hitem_id.push($("#hidden_edit_item_id"+i).val());
					hitem_qty.push($("#hidden_edit_fab_qty"+i).val());
					hprice.push($("#hidden_purchase_price"+i).val());
					
					litem_qty.push($("#edit_fab_qty"+i).val());
					loriginal_price.push($("#live_item_pricec"+i).val());
					if(parseFloat(febdis)>0){
						lprice.push(parseFloat($("#live_item_pricec"+i).val())-((parseFloat($("#live_item_pricec"+i).val())*parseFloat(febdis))/100));
					}else{
						lprice.push($("#live_item_pricec"+i).val());
					}
					
				}
		   }
		   
			var hfs_tblida = hfs_tblid.join('#sep#');
			var hitem_ida = hitem_id.join('#sep#');
			var hitem_qtya = hitem_qty.join('#sep#');
			var hpricea = hprice.join('#sep#');
		
			var litem_qtya = litem_qty.join('#sep#');
			var loriginal_pricea = loriginal_price.join('#sep#');
			var lpricea = lprice.join('#sep#');
	 }
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				head_id:head_id,
				cus_id:cus_id,
				hfs_tblida:hfs_tblida,
				hitem_ida:hitem_ida,
				hitem_qtya:hitem_qtya,
				hpricea:hpricea,
				litem_qtya:litem_qtya,
				lpricea:lpricea,
				loriginal_price:loriginal_pricea,
				ord_num:0,
				total_h:($("#total_h").val()=="")? 0 : parseFloat($("#total_h").val()),
				discount_tk:($("#discount_tk").val()=="")? 0 : parseFloat($("#discount_tk").val()),
				discount_percentage:febdis,
				advance_tk:($("#advance_tk").val()=="")? 0 : parseFloat($("#advance_tk").val()),
				shipping_tk:($("#shipping_tk").val()=="")? 0 : parseFloat($("#shipping_tk").val()),
				courier:$("#courier").val(),
				cus_address:$("#cus_address").val(),
				cus_name:$("#cus_name").val(),
				payment_type:($("#payment_type").val()=="")? 0 : $("#payment_type").val(),
				updateAllInfo:1
			},
			beforeSend: function () {
				$("#usuccess").html('<img src="img/loading.gif"/>');
				document.getElementById("update_order").disabled = true;	
			},
			 success: function (response) {
				 console.log(response);
				if(response==1){
					$("#usuccess").html("Update Success!");
				}else{
					$("#usuccess").html("Update Not Success!").css('color','red');
				}
				document.getElementById("update_order").disabled = false;
			}
		});
	}
	
	}
	

	function updateAllInfoCourier(head_id,cus_id){
		window.hfs_tblid = [];
		window.hitem_id = [];
		window.hitem_qty = [];
		window.hprice = [];
		window.litem_qty = [];
		window.lprice = [];
		window.loriginal_price = [];
	if(confirm('Do you want to done it?')){
		var fab_hidden_id=$("#fab_hidden_id").val();
		var chk="",id_name = "";
		$("#advance_tk").val($("#grant_total").val());
		
		var febdis=($("#discount_percentage").val()=="")? 0 : parseFloat($("#discount_percentage").val());
		for(var i=1;i<=fab_hidden_id;i++){
			id_name = document.getElementById("edit_fab_qty"+i);
			if (id_name != null) {
				if($("#edit_fab_qty"+i).val()=="" || $("#edit_fab_qty"+i).val()==0){
					alert("Warning! Item quantity is missing.");
					$("#edit_fab_qty"+i).click();
					$("#edit_fab_qty"+i).focus();
					chk="notok";
					return;
				}
				if($("#live_item_pricec"+i).val()=="" || $("#live_item_pricec"+i).val()==0){
					alert("Warning! Item price is missing.");
					$("#live_item_pricec"+i).click();
					$("#live_item_pricec"+i).focus();
					chk="notok";
					return;
				}
				
			}
	   }
	   if(chk==""){
			for(var i=1;i<=fab_hidden_id;i++){
				id_name = document.getElementById("edit_fab_qty" + i);
				if (id_name != null) {
					hfs_tblid.push($("#hidden_fs_tbl_id"+i).val());
					hitem_id.push($("#hidden_edit_item_id"+i).val());
					hitem_qty.push($("#hidden_edit_fab_qty"+i).val());
					hprice.push($("#hidden_purchase_price"+i).val());
					
					litem_qty.push($("#edit_fab_qty"+i).val());
					loriginal_price.push($("#live_item_pricec"+i).val());
					if(parseFloat(febdis)>0){
						lprice.push(parseFloat($("#live_item_pricec"+i).val())-((parseFloat($("#live_item_pricec"+i).val())*parseFloat(febdis))/100));
					}else{
						lprice.push($("#live_item_pricec"+i).val());
					}
					
				}
		   }
		   
			var hfs_tblida = hfs_tblid.join('#sep#');
			var hitem_ida = hitem_id.join('#sep#');
			var hitem_qtya = hitem_qty.join('#sep#');
			var hpricea = hprice.join('#sep#');
		
			var litem_qtya = litem_qty.join('#sep#');
			var loriginal_pricea = loriginal_price.join('#sep#');
			var lpricea = lprice.join('#sep#');
	 }
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				head_id:head_id,
				cus_id:cus_id,
				hfs_tblida:hfs_tblida,
				hitem_ida:hitem_ida,
				hitem_qtya:hitem_qtya,
				hpricea:hpricea,
				litem_qtya:litem_qtya,
				lpricea:lpricea,
				loriginal_price:loriginal_pricea,
				ord_num:0,
				total_h:($("#total_h").val()=="")? 0 : parseFloat($("#total_h").val()),
				discount_tk:($("#discount_tk").val()=="")? 0 : parseFloat($("#discount_tk").val()),
				discount_percentage:febdis,
				advance_tk:($("#advance_tk").val()=="")? 0 : parseFloat($("#advance_tk").val()),
				shipping_tk:($("#shipping_tk").val()=="")? 0 : parseFloat($("#shipping_tk").val()),
				courier:$("#courier").val(),
				cus_address:$("#cus_address").val(),
				cus_name:$("#cus_name").val(),
				payment_type:($("#payment_type").val()=="")? 0 : $("#payment_type").val(),
				updateAllInfoCourier:1
			},
			beforeSend: function () {
				$("#usuccess").html('<img src="img/loading.gif"/>');
				document.getElementById("update_order").disabled = true;	
			},
			 success: function (response) {
				 console.log(response);
				if(response==1){
					$("#usuccess").html("Update Success!");
					$("#delete_order").click();
					$("#frow"+head_id).fadeOut(1000);
				}else{
					$("#usuccess").html("Update Not Success!").css('color','red');
				}
				document.getElementById("update_order").disabled = false;
			}
		});
	}
	
	}
	
	function updateFabQtyLive(sl_no,item_id,item_qty,item_per_price,sales_tbl_id,sales_head_id,cus_id,ord_number){
		if($("#edit_fab_qty"+sl_no).val()==0 || $("#edit_fab_qty"+sl_no).val()==""){
			$("#edit_fab_qty"+sl_no).css('border-color','red');
			$("#edit_fab_qty"+sl_no).focus();
			return;
		}
		
		if(parseFloat(item_qty)==parseFloat($("#edit_fab_qty"+sl_no).val())){
			$("#edit_fab_qty"+sl_no).css('border-color','blue');
			return;
		}
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				item_id:item_id,
				item_qty:item_qty,
				edit_fab_qty:$("#edit_fab_qty"+sales_tbl_id).val(),
				item_per_price:item_per_price,
				sales_tbl_id:sales_tbl_id,
				sales_head_id:sales_head_id,
				cus_id:cus_id,
				ord_num:ord_number,
				updateFabQty:1
			},
			 success: function (response) {
				if(response==1){
					$("#edit_fab_qty"+sl_no).css("border-color","blue");
				}else{
					$("#edit_fab_qty"+sl_no).css("border-color","red");
				}
				
			}
		});
	}
	
	
	
	function pricef(sl_no,item_id){
		getTotal();
	}
	
	function getTotal(){
		var id_name = "";
		var fab_hidden_id=$("#fab_hidden_id").val();
		var tot=0,taitot=0;
		for(var i=1;i<=fab_hidden_id;i++){
			id_name = document.getElementById("edit_fab_qty" + i);
			if (id_name != null) {
				tot+=((($("#edit_fab_qty"+i).val()=="")? 0 : parseFloat($("#edit_fab_qty"+i).val()))*(($("#live_item_pricec"+i).val()=="")? 0 : parseFloat($("#live_item_pricec"+i).val()))); //.toFixed(3)
				$("#sub_total"+i).html(((($("#edit_fab_qty"+i).val()=="")? 0 : parseFloat($("#edit_fab_qty"+i).val()))*(($("#live_item_pricec"+i).val()=="")? 0 : parseFloat($("#live_item_pricec"+i).val()))).toFixed(2));
			}
	   }
	   
		$("#total_h").val(tot.toFixed(2));
		
		var discount_tk=($("#discount_tk").val()=="")? 0 : parseFloat($("#discount_tk").val());
		var shipping_tk=($("#shipping_tk").val()=="")? 0 : parseFloat($("#shipping_tk").val());
		$("#grant_total").val((tot-parseFloat(discount_tk)+shipping_tk).toFixed(2));
		$("#advance_tk").val((tot-parseFloat(discount_tk)+shipping_tk).toFixed(2));
		
		var advance_tk=($("#advance_tk").val()=="")? 0 : parseFloat($("#advance_tk").val());
		var grant_total=($("#grant_total").val()=="")? 0 : parseFloat($("#grant_total").val());
		
		$("#due_tk").val((parseFloat(grant_total)-parseFloat(advance_tk)).toFixed(2));
		
		var total_h=($("#total_h").val()=="")? 0 : parseFloat($("#total_h").val());
		grant_total_tk=total_h;
		$("#discount_percentage").val(((100*discount_tk)/grant_total_tk).toFixed(2));
		
	}
	
	function getNewItem(head_id,cus_id){
		var ds_item_id=$("#ds_item_id").val();
		var fab_hidden_id=$("#fab_hidden_id").val();
		$.ajax({
			type: 'post',
			url: 'sql.php',
			data: {
				cus_id:cus_id,
				head_id:head_id,
				ds_item_id:ds_item_id,
				fab_hidden_id:fab_hidden_id,
				getNewItem:1
			},
			
			 success: function (response) {
				console.log(response);
					$("#item_details").prepend(response);
					$("#fab_hidden_id").val(parseInt(fab_hidden_id)+1);
			}
		});
	}
	
	
	
	function clickToSelect(txtboxid) {
		const txtbox = document.getElementById(txtboxid);
		txtbox.focus();
		txtbox.select();
 
	}
	
	function delDetailSales(deltblid,price,headid,ord_num,item_id,item_qty,cus_mobile,param){
		 if(confirm("আপনি কি Item টি ডিলিট করতে চান?")){
			 if(ord_num=="" || ord_num=='0'){
				document.getElementById("delid"+deltblid).disabled = true;	
				$.ajax({
					type: 'post',
					url: 'sql.php',
					data: {
						headid:headid,
						price:price,
						ord_num:ord_num,
						deltblid:deltblid,
						item_id:item_id,
						item_qty:item_qty,
						cus_mobile:cus_mobile,
						delDetailSales:1
					},
					 beforeSend: function () {
						$("#del_sms").html('<img src="img/loading.gif"/>');
					},
					 success: function (response) {
						 console.log(response);
						if(response==1){
							showDetailSales(headid,param);
							var netpay=document.getElementById('netpay'+headid).innerHTML;
							var tbl_discount_tk=document.getElementById('tbl_discount_tk'+headid).innerHTML;
							var net_tk=parseFloat(netpay)-parseFloat(price);
							$("#netpay"+headid).html(net_tk);
							var udiscount=((net_tk-parseFloat(tbl_discount_tk))<=0)? '0' : (net_tk-parseFloat(tbl_discount_tk));
							$("#tbl_total_tk"+headid).html(udiscount);
							if(parseFloat(udiscount)==0){
								$("#tbl_discount_tk"+headid).html(udiscount);
							}
						}else{
							$("#del_sms").html("Not Success!").css("color","red");
						}
						
					}
				});
			 }else{
				 //alert("Sales return is not possible. Please exchange it!!");
				document.getElementById("delid"+deltblid).disabled = true;	
				$.ajax({
					type: 'post',
					url: 'sql.php',
					data: {
						headid:headid,
						price:price,
						ord_num:ord_num,
						deltblid:deltblid,
						item_id:item_id,
						item_qty:item_qty,
						cus_mobile:cus_mobile,
						delDetailSales:1
					},
					 beforeSend: function () {
						$("#del_sms").html('<img src="img/loading.gif"/>');
					},
					 success: function (response) {
						 console.log(response);
						if(response==1){
							$("#del_sms").html("Delete Success!").css("color","green");
						}else{
							$("#del_sms").html("Not Success!").css("color","red");
						}
						
					}
				});
			 }
		  }
	}
	
	
	function delDetailSalesCourier(deltblid,price,headid,ord_num,item_id,item_qty,cus_mobile,param){
		 if(confirm("আপনি কি Item টি Return করতে চান?")){
			 if(ord_num=="" || ord_num=='0'){
				document.getElementById("delid"+deltblid).disabled = true;	
				$.ajax({
					type: 'post',
					url: 'sql.php',
					data: {
						headid:headid,
						price:price,
						ord_num:ord_num,
						deltblid:deltblid,
						item_id:item_id,
						item_qty:item_qty,
						cus_mobile:cus_mobile,
						delDetailSalesCourier:1
					},
					 beforeSend: function () {
						$("#del_sms").html('<img src="img/loading.gif"/>');
					},
					 success: function (response) {
						 console.log(response);
						if(response==1){
							showDetailSalesCourier(headid,param);
							var netpay=document.getElementById('netpay'+headid).innerHTML;
							var tbl_discount_tk=document.getElementById('tbl_discount_tk'+headid).innerHTML;
							var net_tk=parseFloat(netpay)-parseFloat(price);
							$("#netpay"+headid).html(net_tk);
							var udiscount=((net_tk-parseFloat(tbl_discount_tk))<=0)? '0' : (net_tk-parseFloat(tbl_discount_tk));
							$("#tbl_total_tk"+headid).html(udiscount);
							if(parseFloat(udiscount)==0){
								$("#tbl_discount_tk"+headid).html(udiscount);
							}
						}else{
							$("#del_sms").html("Not Success!").css("color","red");
						}
						
					}
				});
			 }else{
				 //alert("Sales return is not possible. Please exchange it!!");
				document.getElementById("delid"+deltblid).disabled = true;	
				$.ajax({
					type: 'post',
					url: 'sql.php',
					data: {
						headid:headid,
						price:price,
						ord_num:ord_num,
						deltblid:deltblid,
						item_id:item_id,
						item_qty:item_qty,
						cus_mobile:cus_mobile,
						delDetailSalesCourier:1
					},
					 beforeSend: function () {
						$("#del_sms").html('<img src="img/loading.gif"/>');
					},
					 success: function (response) {
						 console.log(response);
						if(response==1){
							$("#del_sms").html("Delete Success!").css("color","green");
						}else{
							$("#del_sms").html("Not Success!").css("color","red");
						}
						
					}
				});
			 }
		  }
	}
	
	function dateWisePrint(order_number,print_type,others_area){
		var date1='';
		var date2="",extra_item="",karigor_list="",order_type="",expense_type="";
		var mobile='';
		var order_number=order_number;
		var serial_no="";
		var print_type=print_type;
		extra_item='';
		var month="",year="";
		if(print_type==14 || print_type==23){
			karigor_list=$("#karigor_list").val();
			date1="2023/01/01";
		}
		if(print_type==24){
			order_type=$("#decision_list").val();
			order_number=1;
		}
		if(print_type==15){
			order_type=$("#order_type").val();
			date1="2023/01/01";
		}
		if(print_type==16){
			expense_type=$("#expense_type").val();
			date1=$("#date1").val();
		}
		if(print_type==18){
			extra_item=$("#item_statuss").val();
			date1=$("#date1").val();
		}
		if(print_type==19){
			karigor_list=$("#emp_lists").val();
			extra_item=$("#emp_statuss").val();
			date1=$("#date1").val();
		}
		if(print_type==4 || print_type==5 || print_type==6 || print_type==7){
			order_number="123";
			month=$("#month").val();
			year=$("#year").val();
		}
		if(print_type==9){
			date1="2023/01/01";
			mobile="1";
			order_number="1";
			serial_no="1";
		}
		if(print_type==3){
			if(date1==""){
				$("#date1").css("border-color","red");
				$("#date1").focus();
				exit;
			}else{
				$("#date1").css("border-color","#CCCCCC");
				$("#send_email").show("slow");
			}
		}
		if(print_type==11 || print_type==12 || print_type==16 || print_type==8 || print_type==17 || print_type==18 || print_type==19){
			if(date1==""){
				$("#date1").css("border-color","red");
				$("#date1").focus();
				exit;
			}else{
				$("#date1").css("border-color","#CCCCCC");
				$("#send_email").show("slow");
			}
			date2=$("#date2").val();
			if(date2==""){
				$("#date2").css("border-color","red");
				$("#date2").focus();
				exit;
			}else{
				$("#date2").css("border-color","#CCCCCC");
				//$("#send_email").show("slow");
			}
		}
		if(date1=="" && mobile=="" && order_number=="" && serial_no==""){
			$("#summery_report2").html("Enter Date/Mobile/Order No.").css("color","red");
		}else{
			$.ajax({
						type: 'post',
						url: 'ajax.php',
						data: {
							month:month,
							year:year,
							print_type:print_type,
							date1:date1,
							date2:date2,
							mobile:mobile,
							order_number:order_number,
							serial_no:serial_no,
							extra_item:extra_item,
							karigor_list:karigor_list,
							order_type:order_type,
							expense_type:expense_type,
							dateWisePrint:1
						},
						 beforeSend: function () {
							$("#sales_return_print_page"+others_area).html('<img src="img/loading.gif"/>');
						},
						 success: function (response) {
							console.log(response);
							if(response==2){
								$("#sales_return_print_page"+others_area).html("No Result Found!").css("color","red");
							}else{
								$("#sales_return_print_page"+others_area).html(response).css("color","black");
								$("#printBtns"+others_area).show();
							}
							$("#clear_action"+others_area).show();
						}
			});
		}
		
	}
	
	function updateAnyColumn(id,mobile,cus_id){
		$.ajax({
				type: 'post',
				url: 'ajax.php',
				data: {
					id:id,
					cus_id:cus_id,
					mobile:mobile,
					updateAnyColumn:1
				},
				success: function (response) {
					console.log(response);
					$("#cus_mobile_row"+id).html(response);
				}
		});
	}
	
	function updateFabMobile(tbl_id,cus_id){
		$.ajax({
				type: 'post',
				url: 'ajax.php',
				data: {
					id:tbl_id,
					cus_id:cus_id,
					mobile:$("#cus_mobile_edit_field"+tbl_id).val(),
					updateFabMobile:1
				},
				success: function (response) {
					console.log(response);
					if(response==1){
						$("#cus_mobile_edit_field"+tbl_id).css('border-color','blue');
					}
					
				}
		});
	}


	
	function printOrder(param){
		var order_number="";
		var div="sales_return_print_page"+param;
		printDiv(div,order_number);
	}
	
	function printDiv(divName,order_number) {
		var printContents = document.getElementById(divName).innerHTML;
		var originalContents = document.body.innerHTML;
		document.body.innerHTML = printContents;
		window.print();
		document.body.innerHTML = originalContents;
		
	}
	
	
</script>

<style>
.chkbox{
	 -ms-transform: scale(2); /* IE */
  -moz-transform: scale(2); /* FF */
  -webkit-transform: scale(2); /* Safari and Chrome */
  -o-transform: scale(2); /* Opera */
  transform: scale(2);
  padding: 10px;
}

.checkboxtext
{
  /* Checkbox text */
  font-size: 120%;
  display: inline;
  padding-left: 6px;
  padding-right: 40px;
}
#tblhight{
			overflow-y: scroll;
		overflow-x: hidden;
</style>

<?php
	}else{
		header("location:index.php?id=1");
	}
?>
