<?php 
session_start();
ob_start();
ini_set('max_execution_time', 600); //300 seconds = 5
include'db.php';
include'library.php';
if(isset($_SESSION['USER']) && isset($_SESSION['COM'])){
	
  
  
	if(isset($_REQUEST['sms_id'])){
		$sms_id=$_REQUEST['sms_id'];
		$sqltext=$conn->query("select * from dsms where id=$sms_id and is_active=1");
		$trow=mysqli_fetch_array($sqltext);
		$stxt=$trow['txt_sms'];
		
		$sqlmobile=$conn->query("select * from dsms_mobile where sms_id=$sms_id");
		mysqli_close($conn);
		while($row=mysqli_fetch_array($sqlmobile)){
			$mobile[]=$row['umobile'];
		}
		
		echo implode(",",$mobile)."#sep#".$stxt;
		
	}
	
	if(isset($_REQUEST['combo'])){
		$com_id=$_SESSION['COM_ID'];
		$psmsquery=$conn->query("select * from dsms where is_active=1 and com_id='$com_id' order by id desc limit 0,5");
			echo '<option value="">Select One</option>';
					while($row=mysqli_fetch_array($psmsquery)){
				?>
				 <option value="<?php echo $row['id'] ?>"><?php echo $row['insert_date'] ?></option>
				<?php
			}	
			
		
	}
	
	if(isset($_REQUEST['page_btn'])){
		
		if($_REQUEST['page']=="set_sms"){
			

	$com_id=$_SESSION['COM_ID'];
	
	@$textsql=$conn->query("select * from set_text where com_id=$com_id order by id desc limit 0,15");
	mysqli_close($conn);
	echo "<h5>Set SMS Text(<b>$_SESSION[COM]</b>)</h5>";
?>


  <div class="panel-group">
   <div class="panel panel-info">
      <div class="panel-heading">Set Text For SMS</div>
      <div class="panel-body">
		
				
			<div class="form-group">
			  <label for="comment">Message(English/Bangla):</label>
			  <textarea class="form-control" rows="5" name="txt_sms" id="txt_sms" required></textarea>
			</div>
			
			<button onclick="setSms();" name="btn" value="sub" class="btn btn-success">Set</button>
			<span id="sms"></span><br/><br/>
			
			<div id="setpanel">
			<?php 
				$m=1;
				while($row=mysqli_fetch_array($textsql)){
					if($row['is_active']==1){
					?>
					<div class="panel panel-success">
					  <div class="panel-heading"><?php echo $m++; ?></div>
					  <div class="panel-body"><?php echo $row['sms_text']; ?></div>
					  
					   <a href="javascript:void(0)" style="margin:15px" class="btn btn-success">Active</a>
					  
					</div>
					<?php 
					}else{
						?>
						<div class="panel panel-warning">
						  <div class="panel-heading"><?php echo $m++; ?></div>
						  <div class="panel-body"><?php echo $row['sms_text']; ?></div>
						   <a href="javascript:void(0)" onclick="activeInactive('<?php echo $row['id']; ?>','1')" style="margin:15px" class="btn btn-warning">In Active</a>
						</div>
					<?php 
					}
				}
				?>
			</div>
	  </div>
    </div>

  </div>
  
  <script>
	

	
</script>
<?php 
		}else if($_REQUEST['page']=="history"){
			

		$com_id=$_SESSION['COM_ID'];
	
		$last_id=intval($_POST['last_id']);
		$date=date("Y-m-d");
		$count=$last_id+5;
		$i=$last_id+1;
	
	    $psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.amount,ds.cus_name,ds.discount,ds.factory_status from dsms ds where ds.is_active=1 and ds.phy_dv_date IS NULL and ds.occasion=0 and ds.com_id='$com_id' order by ds.id desc limit $last_id,5");
		
			if(mysqli_num_rows($psmsquery)>0){
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$order_type=$row['order_type'];
					
					@$amount=$row['amount'];
					@$discount=$row['discount'];
					
					@$umobile=$row['umobile']; //implode(",",$mobiles);
					$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.receive_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
					
					if($date==$row['indate']){
						echo "<div class='panel panel-info' style='margin-top:5px'>";
						
					}else{
						
						echo "<div class='panel panel-success' style='margin-top:5px'>";
					}
				if(mysqli_num_rows($chk_com_p)<=0){
					$conn->query("update dsms set is_active=0 where id=$sms_id");
				}
			?>
	
  
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending"; else echo " sent"; ?></div>
	 
      <div class="panel-body">
			
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				<label for="comment">Delivery Date:</label>
					<input type="text" style="font-weight: bold;font-size:18px;font-style: italic;color:green" name="date1" id="date1<?php echo $j; ?>" value="<?php echo $dv_date; ?>" class="form-control" data-select="date">
				<label for="comment">Customer Name: <span style="color:green"></span></label>
					<input type="text" class="form-control" value="<?php echo $row['cus_name']; ?>" style="font-weight: bold;font-size:18px;font-style: italic;color:green"  name="cus_name" id="cus_name<?php echo $j; ?>" />		
				<input type="hidden" class="form-control" name="sms_id" id="sms_id<?php echo $j; ?>" value="<?php echo $sms_id; ?>" />
				<input type="hidden"  name="org_dv_date" id="org_dv_date<?php echo $j; ?>" value="<?php echo $dv_date; ?>" />
				
				
				<label for="comment">Mobile Number:</label>
				<input type="text" class="form-control" value="<?php echo $umobile; ?>" maxlength="11" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color:green" name="mobile" id="mobile<?php echo $j; ?>" />
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
			</div>
			<div class="col-xs-12 col-sm-6">
				<span for="">Dress Details:</span>
				<table id="example" class="table table-striped table-bordered">
				
					<thead>
						<tr>
							<th>SL</th>
							<th>Dress/Order Number</th>
							<th>Qty</th>
						</tr>
					</thead>
					<tbody>
					<?php 
					$jj=1;
					while($rrows=mysqli_fetch_array($chk_com_p)){
						$pname=$rrows['pname'];
						$pqty=$rrows['pqty'];
						$order_number=$rrows['order_number'];
						$receive_qty=$rrows['receive_qty'];
						if($receive_qty<$pqty){
							$rd="<span id='dqty$jj$j'>($receive_qty)</span>";
						}else{
							$rd="<span style='color:blue' id='dqty$jj$j'>($receive_qty)</span>";
						}
						?>
						<tr>
							<td>
								<b><?php echo $jj++; ?></b>
							</td>
							<td><b>
								<?php echo $pname." ".$rd; ?>
							</b>
							</td>
							<td><b>
								<?php echo $pqty; ?>
							</b>
							</td>
						
						</tr>
						<?php  
					}
					
					?>
					</tbody>
				</table>
				<button onclick="updateOrder('<?php echo $j; ?>');" name="btn" value="sub" id="updatebtn<?php echo $j; ?>" class="btn btn-success">Update</button>
				<span id="sms<?php echo $j; ?>"></span>
			</div>
		</div>
	  </div>
	 
    </div>
	
	
	
 <?php
 
 } 
 ?>
  <script type="text/javascript" src="cal/js/apiajax.js"></script>
	
	<script type="text/javascript" src="cal/js/mousewheel.js"></script>
	<script type="text/javascript" src="cal/js/jquery.dateselect.js"></script> 
 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
	}else if($_REQUEST['page']=="more_urgent"){
		$com_id=$_SESSION['COM_ID'];
	
		$last_id=intval($_POST['last_id']);
		$date=date("Y-m-d");
		$i=$last_id+1;
	
	    $psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.amount,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.phy_dv_date IS NULL and ds.occasion=0 and ds.order_type=1 and ds.factory_status not in(1,2) and ds.com_id='$com_id' order by ds.id asc limit $last_id,10");
		
			if(mysqli_num_rows($psmsquery)>0){
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					$dv_date=$row['fddate'];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$order_type=$row['order_type'];
					@$phy_ord_num=$row['phy_ord_num'];
					
					@$amount=$row['amount'];
					
					@$umobile=$row['umobile']; //implode(",",$mobiles);
					$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
					
					
			?>
	<div class='panel panel-info'>
  
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending"; else echo " sent"; ?></div>
	 
      <div class="panel-body">
			
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				 <p for="comment">Customer Name: <b><?php echo $row['cus_name']; ?></b></p>
				 <p for="comment">Mobile Number: <b><?php echo $umobile; ?></b></p>
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
				<p for="comment">Factory Delivery Date:</p>
					<input type="text" style="font-weight: bold;font-size:18px;font-style: italic;" name="date1" id="date1<?php echo $j; ?>" value="<?php echo $dv_date; ?>" class="form-control" data-select="date">
				<input type="hidden"  name="sms_id" id="sms_id<?php echo $j; ?>" value="<?php echo $sms_id; ?>" />
				<input type="hidden"  name="org_dv_date" id="org_dv_date<?php echo $j; ?>" value="<?php echo $dv_date; ?>" />
				<input type="hidden"  name="cus_name" id="cus_name<?php echo $j; ?>" value="<?php echo $row['cus_name']; ?>" />
				<input type="hidden" name="mobile"  id="mobile<?php echo $j; ?>" value="<?php echo $umobile; ?>" />
				
			</div>
			<div class="col-xs-12 col-sm-6">
				<span for="">Dress Details:</span>
				<table id="example" class="table table-striped table-bordered">
				
					<thead>
						<tr>
							<th>SL</th>
							<th>Dress/Order Number</th>
							<th>Qty</th>
						</tr>
					</thead>
					<tbody>
					<?php 
					$jj=1;
					while($rrows=mysqli_fetch_array($chk_com_p)){
						$pname=$rrows['pname'];
						$pqty=$rrows['pqty'];
						$order_number=$rrows['order_number'];
						?>
						<tr>
							<td>
								<b><?php echo $jj++; ?></b>
							</td>
							<td><b>
								<?php echo $pname; ?>(<?php echo $order_number; ?>)
							</b>
							</td>
							<td><b>
								<?php echo $pqty; ?>
							</b>
							</td>
						
						</tr>
						<?php  
					}
					
					?>
					</tbody>
				</table>
				<span id="urgsms<?php echo $j; ?>"></span>
			</div>
		</div>
	  </div>
	 
    </div>
	
	
	
 <?php
 
 } 
 ?>
 
  <script type="text/javascript" src="cal/js/apiajax.js"></script>
	
	<script type="text/javascript" src="cal/js/mousewheel.js"></script>
	<script type="text/javascript" src="cal/js/jquery.dateselect.js"></script> 
 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
	}else if($_REQUEST['page']=="more_today"){
		$com_id=$_SESSION['COM_ID'];
	
		$last_id=intval($_POST['last_id']);
		$i=$last_id+1;
	
	    $com_id=$_SESSION['COM_ID'];
		@$dv_date =date('Y-m-d'); // and ds.sms_status=0
		$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_dv_date,ds.phy_ord_num,ds.amount,ds.cus_name,ds.discount,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.factory_status not in(1,2) and ds.com_id='$com_id' and ds.dv_date='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc limit $last_id,10");
		
		if(mysqli_num_rows($psmsquery)>0){
		?>
		<div class="panel-group">
 
   <?php 
		
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					//$dv_date=$row['fddate'];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$phy_ord_num=$row['phy_ord_num'];
					
					@$umobile=$row['umobile'];
					
				
				
			?>
	
   <div class='panel panel-info'>
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending "; else echo " sent "; ?></div>
	 
      <div class="panel-body">
			
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				<p for="comment">Customer Name: <b><?php echo $row['cus_name']; ?></b></p>
				<p for="comment">Mobile Number: <b><?php echo $umobile; ?></b></p>
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
				<p for="comment">Delivery Date: <b><?php echo $dv_date; ?></b></p>
				<input type="hidden" class="form-control" name="txt_sms" id="txt_sms<?php echo $j; ?>" />
				<input type="hidden" class="form-control" name="sms_id" id="sms_id<?php echo $j; ?>" value="<?php echo $sms_id; ?>" />
			
			
			
			<!----------------------------------------->
			<?php
			
			$total_tk=$row['amount'];
			$discount=$row['discount'];
			$total_tk1=intval($total_tk)-((intval($total_tk)*intval($row['discount']))/100);
			$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.id ord_id,sd.receive_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
			$payment_detail=$conn->query("SELECT * FROM `accounting` WHERE `com_id`=$com_id and is_active=1 and `dsms_id`=$sms_id");
			
			$ptbl='<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>SL</th>
						<th>Dres/Order Number</th>
						<th>Qty</th>
					</tr>
				</thead>
				<tbody>';
				$ptbl2="";	
				$m=1;
				while($rrows=mysqli_fetch_array($chk_com_p)){
					$n=$m++;
					$pname=$rrows['pname'];
					$pqty=$rrows['pqty'];
					$order_number=$rrows['order_number'];
					$receive_qty=$rrows['receive_qty'];
					if($receive_qty<$pqty){
						$rd="<span id='dqty$n$j'>($receive_qty)</span>";
					}else{
						$rd="<span style='color:blue' id='dqty$n$j'>($receive_qty)</span>";
					}
					$ptbl2.="<tr>
						<td>
							<b>$n</b>
						</td>
						<td><b>
							$pname $rd
						</b>
						</td>
						<td><b>
							$pqty
						</b>
						</td>
					
					</tr>";
				}
				
					
				$ptbl3='</tbody>
				</table>';
			$ptblf=$ptbl.$ptbl2.$ptbl3;
			
			$payspan="<span id='payment_tbl$j'>";
			$paytbl='<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>Description</th>
						<th style="text-align:right">Taka</th>
					</tr>
				</thead>
				<tbody id="payable">';
				@$paytblhead.="<tr>
						<td>
							<b>Total</b>
						</td>
						<td><b>
							<input style='text-align:right;border: 1px solid #F9F9F9;background: #F9F9F9;width:100%' type='text' readonly value='$total_tk'/>
						</b>
						</td>
						</tr><tr><td>
							<b>Discount(%)</b>
						</td><td style='text-align:right'>$discount</td></tr>";
				$paytbl2="";	
				$sum=0;
				while($payrows=mysqli_fetch_array($payment_detail)){
					$due_tk=$payrows['amount'];
					$accounting_tbl_id=$payrows['id'];
					$sum+=intval($due_tk);
					if(isset($row['phy_dv_date'])){
						$del="";
						$paid="(<span style='color:blue'>Paid</span>)";
					}else{
						$del="(<a href='javascript:void(0)' onclick='delPay($accounting_tbl_id,$j);'>Del</a>)";
						$paid="";
					}
					if($payrows['pay_status']==1){
						$paytbl2.="<tr>
						<td>
							Advance $del
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
					}else{
						$paytbl2.="<tr>
						<td>
							Pay $del
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
					}
				
				}
				$due=intval($total_tk1)-$sum;
				@$paytbldue.="<input type='hidden' value='$due' id='hide_due$j'/><tr>
						<td>
							<b>Due $paid</b>
						</td>
						<td style='text-align:right'><b>
							$due
						</b>
						</td>
						</tr>";
				if($due!=0){
					if(isset($row['phy_dv_date'])){
						@$paytblpay.="<input type='hidden' value='$sms_id' id='dsms_ids$j'/>
						<input type='hidden' value='$total_tk' id='total_tk$j'/>
						<span id='stksms$j'></span>";
					}else{ 
				@$paytblpay.="<tr>
						<td>
							---
						</td>
						<td>
						<input style='text-align:right;width:100%' type='text' id='paytxt$j'/>
						<input type='hidden' value='$sms_id' id='dsms_ids$j'/>
						<input type='hidden' value='$total_tk' id='total_tk$j'/>
						<span id='stksms$j'></span>
						</td>
						</tr>";
					}
				}else{
					$paytblpay="<input type='hidden' value='$total_tk' id='total_tk$j'/><input type='hidden' value='$sms_id' id='dsms_ids$j'/>";
				}
					
				$paytbl3='</tbody>
					</table>';
				$payspan_end="</span>";
				echo "<input type='hidden' id='discount$j' value='$discount' />
				<input type='hidden' id='discount_tot$j' value='$total_tk1' /><hr/>";
			$paytblf=$payspan.$paytbl.$paytblhead.$paytbl2.$paytbldue.$paytblpay.$paytbl3.$payspan_end;
			
			?>
				
				
					<span for="">Dress Details:</span>
					<span id="pdetail">
					 <?php echo $ptblf; ?>
					</span>
				</div>
			<div class="col-xs-12 col-sm-6">
					<span for="">Payment Details:</span>
					<span id="paydetail">
						<?php echo $paytblf; ?>
					</span>
			
			<!----------------------------------------->
				<span id="order_delivery_sms<?php echo $j; ?>"></span>
				<input type="hidden" id="hide_sms_id<?php echo $j; ?>" value="<?php echo $row['id']; ?>" />
			</div>
		</div>
	  </div>
	 
    </div>
	
 <?php 
 $paytblf=$payspan=$paytbl=$paytblhead=$paytbl2=$paytbldue=$paytblpay=$paytbl3=$payspan_end="";
			$ptblf=$ptbl=$ptbl2=$ptbl3="";
		echo "<hr/>";	
 }
 ?>
 </div>

	
 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
	}else if($_REQUEST['page']=="more_tomorrow"){
		
		$last_id=intval($_POST['last_id']);
		$i=$last_id+1;
		$com_id=$_SESSION['COM_ID'];
		@$dv_date =date('Y-m-d', strtotime(date('Y-m-d'). ' + 1 days'));
		$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.factory_status not in(1,2) and ds.com_id='$com_id' and ds.dv_date='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc limit $last_id,10");
		
		if(mysqli_num_rows($psmsquery)>0){
		?>
		
		<div class="panel-group">
 
   <?php 
		
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					//$dv_date=$row['fddate'];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$phy_ord_num=$row['phy_ord_num'];
					
					@$umobile=$row['umobile'];
					$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.receive_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
				
				
			?>
	
   <div class='panel panel-info'>
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending "; else echo " sent "; ?></div>
	 
      <div class="panel-body">
			
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				<p for="comment">Customer Name: <b><?php echo $row['cus_name']; ?></b></p>
				<p for="comment">Mobile Number: <b><?php echo $umobile; ?></b></p>
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
				<p for="comment">Delivery Date: <span > <b><?php echo $dv_date; ?></b></span></p>
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;" name="date1" id="date2<?php echo $j; ?>" value="<?php echo $dv_date; ?>" class="form-control" data-select="date">
				<input type="hidden" style="" name="date1" id="date_org<?php echo $j; ?>" value="<?php echo @$dv_date; ?>" />
				<input type="hidden" style="" name="mobile" id="mobilet<?php echo $j; ?>" value="<?php echo @$umobile; ?>" />
				
			</div>
			<div class="col-xs-12 col-sm-6">
			<span for="">Dress Details:</span>
			<table id="example" class="table table-striped table-bordered">
			
				<thead>
					<tr>
						<th>SL</th>
						<th>Dress/Order Number</th>
						<th>Qty</th>
					</tr>
				</thead>
				<tbody>
				<?php 
				$jj=1;
				while($rrows=mysqli_fetch_array($chk_com_p)){
					$m=$jj++;
					$pname=$rrows['pname'];
					$pqty=$rrows['pqty'];
					$order_number=$rrows['order_number'];
					$receive_qty=$rrows['receive_qty'];
					if($receive_qty<$pqty){
						$rd="<span id='dqty$m$j'>($receive_qty)</span>";
					}else{
						$rd="<span style='color:blue' id='dqty$m$j'>($receive_qty)</span>";
					}
					?>
					<tr>
						<td>
							<b><?php echo $m; ?></b>
						</td>
						<td><b>
							<?php echo $pname; ?>(<?php echo $order_number; ?>)
						</b>
						</td>
						<td><b>
							<?php echo $pqty; ?>
						</b>
						</td>
					
					</tr>
					<?php  
				}
				
				?>
				</tbody>
			</table>
			
				<span id="only_date_update_sms<?php echo $j; ?>"></span>
				<input type="hidden" id="hide_sms_ids<?php echo $j; ?>" value="<?php echo $row['id']; ?>" />
			</div>
		</div>
	  </div>
	 
    </div>
	
 <?php } ?>
 </div>
<script type="text/javascript" src="cal/js/apiajax.js"></script>
	<script type="text/javascript" src="cal/js/mousewheel.js"></script>
	<script type="text/javascript" src="cal/js/jquery.dateselect.js"></script> 
 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
		
	}else if($_REQUEST['page']=="more_expired"){
		
		$last_id=intval($_POST['last_id']);
		$i=$last_id+1;
		$com_id=$_SESSION['COM_ID'];
		@$dv_date =date('d/m/Y');
		$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.com_id='$com_id' and str_to_date(ds.fddate,'%d/%m/%Y') <= str_to_date('$dv_date','%d/%m/%Y') and ds.factory_status not in(1,2) and ds.phy_dv_date IS NULL order by ds.id asc limit $last_id,10");
		
		if(mysqli_num_rows($psmsquery)>0){
		?>
		
		<div class="panel-group">
 
   <?php 
		
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$phy_ord_num=$row['phy_ord_num'];
					
					@$umobile=$row['umobile'];
					//$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.receive_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
				$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.id ord_id,sd.receive_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.is_active=1 and sd.dsms_id=$sms_id");
				if(mysqli_num_rows($chk_com_p)<=0){
					$conn->query("update dsms set is_active=0 where id=$sms_id");
				}
				
			?>
	
   <div class='panel panel-info'>
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending "; else echo " sent "; ?></div>
	 
      <div class="panel-body">
			
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				<p for="comment">Customer Name: <b><?php echo $row['cus_name']; ?></b></p>
				<p for="comment">Mobile Number: <b><?php echo $umobile; ?></b></p>
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
				<p for="comment" style="">Factory Delivery Date: <b><?php echo $row['fddate']; ?></b></p>
				<p for="comment">Delivery Date: <span > <b><?php echo $dv_date; ?></b></span></p>
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;" name="date1" id="date2<?php echo $j; ?>" value="<?php echo $dv_date; ?>" class="form-control" data-select="date">
				<input type="hidden" style="" name="date1" id="date_org<?php echo $j; ?>" value="<?php echo @$dv_date; ?>" />
				<input type="hidden" style="" name="mobile" id="mobilet<?php echo $j; ?>" value="<?php echo @$umobile; ?>" />
				
			</div>
			<div class="col-xs-12 col-sm-6">
			<span for="">Dress Details:</span>
			<table id="example" class="table table-striped table-bordered">
			
				<thead>
					<tr>
						<th>SL</th>
						<th>Dress/Order Number</th>
						<th>Qty</th>
					</tr>
				</thead>
				<tbody>
				<?php 
				$jj=1;
				while($rrows=mysqli_fetch_array($chk_com_p)){
					$m=$jj++;
					$pname=$rrows['pname'];
					$pqty=$rrows['pqty'];
					$order_number=$rrows['order_number'];
					$receive_qty=$rrows['receive_qty'];
					if($receive_qty<$pqty){
						$rd="<span id='dqty$m$j'>($receive_qty)</span>";
					}else{
						$rd="<span style='color:blue' id='dqty$m$j'>($receive_qty)</span>";
					}
					?>
					<tr>
						<td>
							<b><?php echo $m; ?></b>
						</td>
						<td><b>
							<?php echo $pname; ?><?php echo $rd; ?>
						</b>
						</td>
						<td><b>
							<?php echo $pqty; ?>
						</b>
						</td>
					
					</tr>
					<?php  
				}
				
				?>
				</tbody>
			</table>
			
				<span id="only_date_update_sms<?php echo $j; ?>"></span>
				<input type="hidden" id="hide_sms_ids<?php echo $j; ?>" value="<?php echo $row['id']; ?>" />
			</div>
		</div>
	  </div>
	 
    </div>
	
 <?php } ?>
 </div>
<script type="text/javascript" src="cal/js/apiajax.js"></script>
	<script type="text/javascript" src="cal/js/mousewheel.js"></script>
	<script type="text/javascript" src="cal/js/jquery.dateselect.js"></script> 
 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
		
	}else if($_REQUEST['page']=="more_n3d"){

		$last_id=intval($_POST['last_id']);
		$i=$last_id+1;
		$com_id=$_SESSION['COM_ID'];
		@$dv_date =date('Y-m-d', strtotime(date('Y-m-d'). ' + 2 days'));
		$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.factory_status not in(1,2) and ds.com_id='$com_id' and ds.dv_date='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc limit $last_id,10");
		
		if(mysqli_num_rows($psmsquery)>0){
		?>
		
		<div class="panel-group">
 
   <?php 
		
				while($row=mysqli_fetch_array($psmsquery)){
					$j=$i++;
					$sms_id=$row['id'];
					$sms_status=$row['sms_status'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					//$dv_date=$row['fddate'];
					@$txt_sms=$row['txt_sms'];
					@$tagnum=$row['tagnum'];
					@$phy_ord_num=$row['phy_ord_num'];
					
					@$umobile=$row['umobile'];
					
				$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.receive_qty,sd.order_number FROM `order_record` sd WHERE sd.com_id=$com_id and sd.dsms_id=$sms_id");
				
			?>
	
   <div class='panel panel-info'>
      <div class="panel-heading"><?php  echo $j.". (".date('d/m/Y',strtotime($row['indate'])).")"; if($sms_status==0) echo " pending "; else echo " sent "; ?></div>
	 
      <div class="panel-body">
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<p for="comment">Serial: <span style='cursor: pointer;color:red;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
					<?php echo $row['phy_ord_num']; ?>
				</span></p>
				<p for="comment">Customer Name: <b><?php echo $row['cus_name']; ?></b></p>
				<p for="comment">Mobile Number: <b><?php echo $umobile; ?></b></p>
				<p for="comment" style="color:blue">Production Receive: <b><?php echo ($row['factory_status']==1 || $row['factory_status']==2)? "Yes" : "No"; ?></b></p>
				<p for="comment">Delivery Date: <b><?php echo $dv_date; ?></b></p>
			</div>
			<div class="col-xs-12 col-sm-6">
			<span for="">Dress Details:</span>
			<table id="example" class="table table-striped table-bordered">
			
				<thead>
					<tr>
						<th>SL</th>
						<th>Dress/Order Number</th>
						<th>Qty</th>
					</tr>
				</thead>
				<tbody>
				<?php 
				$jj=1;
				while($rrows=mysqli_fetch_array($chk_com_p)){
					$pname=$rrows['pname'];
					$pqty=$rrows['pqty'];
					$order_number=$rrows['order_number'];
					$receive_qty=$rrows['receive_qty'];
					if($receive_qty<$pqty){
						$rd="<span id='dqty'>($receive_qty)</span>";
					}else{
						$rd="<span style='color:blue' id='dqty'>($receive_qty)</span>";
					}
					?>
					<tr>
						<td>
							<b><?php echo $jj++; ?></b>
						</td>
						<td><b>
							<?php echo $pname." ".$rd; ?>
						</b>
						</td>
						<td><b>
							<?php echo $pqty; ?>
						</b>
						</td>
					
					</tr>
					<?php  
				}
				
				?>
				</tbody>
			</table>
			</div>
		</div>
		
	  </div>
	 
    </div>
	
 <?php } ?>
 </div>


 <?php 
 mysqli_close($conn);
		}else{
			echo 2;
		}
	}
	}
	
	if(isset($_REQUEST['more_srch'])){
		
		$mobile=trim($_REQUEST['mobile']);
		$com_id=($_SESSION['COM_ID']);
		
		$last_id=intval($_POST['last_id']);
		$date=date("Y-m-d");
			$chk_com=$conn->query("select DISTINCT(ds.id),date(ds.insert_date) order_date,ds.sms_status,ds.order_type,ds.dv_date,ds.sent_time,ds.tagnum,ds.phy_dv_date,ds.phy_ord_num,ds.amount,ds.cus_name,ds.cus_mobile,ds.discount,ds.factory_status,ds.factory_receive_date,ds.box_number from dsms ds,order_record ord where ds.id=ord.dsms_id and ds.is_active=1 and ds.occasion=0 and ord.com_id=$com_id and (ord.order_number='$mobile' or ds.cus_mobile='$mobile' or ds.phy_ord_num='$mobile') and ord.is_active=1 order by ds.id desc limit $last_id,3");
		
		if(mysqli_num_rows($chk_com)>0){
			$si=$last_id+1;
			while($rrow=mysqli_fetch_array($chk_com)){
			$s=$si++;
			$sid=$rrow['id'];
			$total_tk=$rrow['amount'];
			$discount=$rrow['discount'];
			$box_number=$rrow['box_number'];
			$phy_ord_num=$rrow['phy_ord_num'];
			if($discount>0){
				$total_tk=round(($total_tk+$discount));
			}
			$total_tk1=intval($total_tk-$discount);
			$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.receive_qty,sd.id ord_id,sd.delivery_qty,sd.master_cutting_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.is_active=1 and sd.dsms_id=$sid");
			$payment_detail=$conn->query("SELECT * FROM `accounting` WHERE `com_id`=$com_id and is_active=1 and `dsms_id`=$sid");
			$fab_taka_sql=$conn->query("SELECT f_total,total_receive FROM direct_sale_head dsh,`direct_sale` ds WHERE dsh.id=ds.`dstid` and ds.`order_number`='$phy_ord_num'");
			if(mysqli_num_rows($fab_taka_sql)>0){
			$fab_taka_row=mysqli_fetch_array($fab_taka_sql);
			$f_total_taka=$fab_taka_row['f_total'];
			}else{
				$f_total_taka=0;
			}
			echo "<div class='row'><div class='col-xs-12 col-sm-12'>";
			$ptbl='<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>SL</th>
						<th>Dress/Order Number</th>
						<th>Qty</th>
					</tr>
				</thead>
				<tbody>';
				$ptbl2="";	
				$i=1;
				//$all_measurement=array();
				while($rrows=mysqli_fetch_array($chk_com_p)){
					$j=$i++;
					$code_no=$rrows['ord_id'];
					$pname=$rrows['pname'];
					$pqty=$rrows['pqty'];
					$order_number=$rrows['order_number']."#sep#".$rrows['ord_id']."#sep#".$s;
					$receive_qty=$rrows['receive_qty'];
					$delivery_qty=$rrows['delivery_qty'];
					$master_cutting_qty=$rrows['master_cutting_qty'];
					
					if($master_cutting_qty<$pqty){
						$cutting="<input type='number' style='width:45px;text-align:center' id='cdressQtys$j$s'/>
							<input type='hidden' value='$order_number' id='chidebtn$j$s'/>
							<button style='background: #0000ff42;color: #000000c4;' onclick='recCuttingBtn($j$s);' name='btn' id='dressCuttingBtn$j$s' value='sub'>Cutting Done</button>
							<span style='color:#0000ff' id='cqty$j$s'>($master_cutting_qty)</span>";
					}else{
						$cutting="<span style='color:#0000ff' id='cqty$j$s'>($master_cutting_qty)</span>";
					}
					
					if($receive_qty<$pqty){
						$rd="<input type='number' style='width:45px;text-align:center' id='dressQtys$j$s'/>
							<input type='hidden' value='$order_number' id='hidebtn$j$s'/>
							<button style='background: #0e9a8421;color: #000000bd;' onclick='recDressBtn($j$s);' name='btn' id='dressReceiveBtn$j$s' value='sub'>Making Done</button>
							<span style='color:#0e9a84' id='dqty$j$s'>($receive_qty)</span>";
					}else{
						$rd="<span style='color:#0e9a84' id='dqty$j$s'>($receive_qty)</span>";
					}
					
					if($delivery_qty<$pqty){
						$pdelivery="<input type='hidden' value='$order_number' id='pdelivery$j$s'/>
							<input type='number' style='width:45px;text-align:center' id='pdeliveryQtys$j$s'/>
							<button style='background: #c041f559;color: #000000c2;' onclick='pdeliveryBtn($j$s);' name='btn' id='pdeliveryBtn$j$s' value='sub'>Delivery</button>
							<span style='color:#c041f5' id='ddqty$j$s'>($delivery_qty)</span>";
					}else{
						$pdelivery="<span style='color:#c041f5' id='ddqty$j$s'>($delivery_qty)</span>";
					}
					
					//$all_measurement[]=$rrows['order_number'];
					$ptbl2.="<tr>
						<td>
							<b>$j</b>
						</td>
						<td><b style='font-size: 12px;'>
							[$code_no] $pname $cutting | $rd | $pdelivery
						</b>
						</td>
						<td><b>
							$pqty
						</b>
						</td>
					
					</tr>";
				}
				
				//$all_measurement=implode(",",$all_measurement);		
				$ptbl3="<input type='hidden' id='totid$s' value='$j'/></tbody>
				</table>";
			$ptblf=$ptbl.$ptbl2.$ptbl3;
			
			$payspan="<span id='payment_tbl$s'>";
			$paytbl='<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>Description</th>
						<th style="text-align:right;width: 32%;">Taka</th>
					</tr>
				</thead>
				<tbody id="payable">';
				@$paytblhead.="<tr>
						<td>
							<b>Total</b>
						</td>
						<td><b>
							<input style='text-align:right;border: 1px solid #F9F9F9;background: #F9F9F9;width: 100%' type='text' readonly value='$total_tk'/>
						</b>
						</td>
						</tr><tr><td>
							<b>Discount(%)</b>
						</td><td style='text-align:right'>$discount</td></tr>";
				$paytbl2="";	
				$i=1;$sum=0;
				while($payrows=mysqli_fetch_array($payment_detail)){
					$due_tk=$payrows['amount'];
					$accounting_tbl_id=$payrows['id'];
					$sum+=intval($due_tk);
					if(isset($rrow['phy_dv_date'])){
						$del="";
						$paid="(<span style='color:blue'>Paid</span>)";
					}else{
						$del="(<a href='javascript:void(0)' onclick='delPay($accounting_tbl_id,$s);'>Del</a>)";
						$paid="";
					}
					if($payrows['pay_status']==1){
						$paytbl2.="<tr>
						<td>
							Advance $del
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
					}else{
						$paytbl2.="<tr>
						<td>
							Pay $del
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
					}
				
				}
				$due=intval($total_tk1)-$sum;
				@$paytbldue.="<input type='hidden' value='$due' id='hide_due$s'/><tr>
						<td>
							<b>Due $paid</b>
						</td>
						<td style='text-align:right'><b>
							$due
						</b>
						</td>
						</tr>";
				if($due!=0){
					if(isset($rrow['phy_dv_date'])){
						@$paytblpay.="<input type='hidden' value='$sid' id='dsms_ids$s'/>
						<input type='hidden' value='$total_tk' id='total_tk$s'/>
						<span id='stksms$s'></span><tr>
						<td style='color:red'>
							Discount <span style='color:black;cursor:pointer' onclick='setDiscountTk($s)' id='discount_tks$s'></span>
						</td>
						<td>
						<input style='text-align: right;width: 100%;background: #61c5cf87;' type='text' id='exdiscount$s'/>
						</td>
						</tr>
						<tr>
						<tr>
						
						<td>
							<button onclick='payTk($s);' name='btn' id='paybtns$s' value='sub' class='btn btn-success'>Pay</button>
							<select style='height: 30px;' id='payment_type$s'>
								<option value='Cash'>Cash</option>
								<option value='Bkash'>Bkash</option>
								<option value='Rocket'>Rocket</option>
								<option value='Nagad'>Nagad</option>
								<option value='Upay'>Upay</option>
								<option value='Sure Cash'>Sure Cash</option>
								<option value='Tap'>Tap</option>
								<option value='POS Machine'>POS Machine</option>
								<option value='Bank'>Bank</option>
							</select>
						</td>
						<td>
						<input style='text-align:right;width: 100%;' type='text' onkeyup='showLiveDiscount($s)' onclick='clickToSelect(paytxt$s)' id='paytxt$s'/>
						</td>
						</tr>";
					}else{
				@$paytblpay.="<tr>
					<td style='color:red'>
							Discount <span style='color:black;cursor:pointer' onclick='setDiscountTk($s)' id='discount_tks$s'></span>
						</td>
						<td>
						<input style='text-align: right;width: 100%;background: #61c5cf87;' type='text' id='exdiscount$s'/>
						</td>
				</tr><tr>
						<td>
							<button onclick='payTk($s);' name='btn' id='paybtns$s' value='sub' class='btn btn-success'>Pay</button>
							<select style='height: 30px;' id='payment_type$s'>
								<option value='Cash'>Cash</option>
								<option value='Bkash'>Bkash</option>
								<option value='Rocket'>Rocket</option>
								<option value='Nagad'>Nagad</option>
								<option value='Upay'>Upay</option>
								<option value='Sure Cash'>Sure Cash</option>
								<option value='Tap'>Tap</option>
								<option value='POS Machine'>POS Machine</option>
								<option value='Bank'>Bank</option>
							</select>
						</td>
						<td>
						<input style='text-align:right;width: 100%;' onkeyup='showLiveDiscount($s)' onclick='clickToSelect(paytxt$s)' type='text' id='paytxt$s'/>
						<input type='hidden' value='$sid' id='dsms_ids$s'/>
						<input type='hidden' value='$total_tk' id='total_tk$s'/>
						<span id='stksms$s'></span>
						</td>
						</tr>";
					}
				}else{
					$paytblpay="<input type='hidden' value='$total_tk' id='total_tk$s'/><input type='hidden' value='$sid' id='dsms_ids$s'/>";
				}
					
				$paytbl3='</tbody>
					</table>';
				$payspan_end="</span>";
			$paytblf=$payspan.$paytbl.$paytblhead.$paytbl2.$paytbldue.$paytblpay.$paytbl3.$payspan_end;
			
			if(isset($rrow['phy_dv_date'])){
				$phy_dv_date=date('d/m/Y',strtotime($rrow['phy_dv_date']));
			}else{
				$phy_dv_date=2;
			}
			?>
			<div class="row">
				<div class="col-xs-12 col-sm-8">
						<div style="overflow: hidden;">
							<p style="float: left;" for="">Serial: <b><input type="text" onclick="copyOrderNumber('<?php echo $s; ?>');" style="width: 70px;color:red;cursor: pointer;" id="copying<?php echo $s; ?>" value="<?php echo @$rrow['phy_ord_num']; ?>"/></b></p>
							<p style="float:right" for="">SL: <span  id="tag_num"><?php echo $s; ?></span></p>
						</div>	
					<p for="">Customer Name: <b><span style="color:green" id="phy_ord_no"><?php echo @$rrow['cus_name']; ?></span></b></p>
					<p for="">Mobile: <b><span style="color:green" id="phy_ord_no"><?php echo $rrow['cus_mobile']; ?></span></b></p>
					<p for="">Order Date: <b><span id="ord_date"><?php echo date('d/m/Y',strtotime($rrow['order_date'])); ?></span></b></p>
					<p for="">Production Receive: <b><?php echo ($rrow['factory_status']==1 || $rrow['factory_status']==2)? "Yes" : "No"; ?></b></p>
					<p for="">Production Receive Date: <b><?php if(@$rrow['factory_receive_date']!="") echo date('d/m/Y',strtotime(@$rrow['factory_receive_date'])); ?></b></p>
					<p for="">Delivery Date: <b><span id="dv_date<?php echo $s; ?>"><?php echo date('d/m/Y',strtotime($rrow['dv_date'])); ?></span></b></p>
					<p for="">Physical Delivery Date: <b><span id="phy_dv_date<?php echo $s; ?>"><?php echo ($phy_dv_date==2)? "N/A" : $phy_dv_date; ?></span></b></p>
					<p for="">Order Type: <b><span id="ord_type"><?php echo ($rrow['order_type']==0)? "Normal": "Urgent"; ?></span></b></p>
					<p for="">Sms: <b><span id="chksms"><?php echo ($rrow['sms_status']==0)? "Pending": "Sent" ?></span></b></p>
					
					<div class="row">	
						<div class="col-xs-12 col-sm-12">
							<div class="row">
								<div class="col-xs-12 col-sm-9">
								<label for="comment" class="txt_color">Box Number: </label><br/>
								<input style="width: 80%;height: 30px;text-align:center;font-weight:bold;color:red" type="text" id="box_number<?php echo $s; ?>" value="<?php echo @$box_number; ?>"/> 
								<button style="" onclick="onlyBoxUpdateBtn('<?php echo $s; ?>','<?php echo @$rrow['phy_ord_num']; ?>');" name="btn" id="only_boxupdate<?php echo $s; ?>" value="sub" class="btn btn-info">Update</button>&nbsp;&nbsp;<br/>
								<span id="box_update_sms<?php echo $s; ?>"></span>
								</div>
							</div>
							<input type="hidden" value="<?php echo $f_total_taka; ?>" id="fab_total_tk<?php echo $s; ?>"/>
						</div>
					</div>
					
					<span for="">Dress Details:(<span style='color:#ec68d0;cursor: pointer;' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('<?php echo $s; ?>','<?php echo @$rrow['phy_ord_num']; ?>')"><b>Measurement</b></span>)</span>
						<span id="pdetail">
						 <?php echo $ptblf; ?>
						</span>
				</div>
			<div class="col-xs-12 col-sm-4">
					<span for="">Payment Details:</span>
					<span id="paydetail">
						<?php echo $paytblf; ?>
					</span>
					<p></p>	
				<?php if($phy_dv_date==2){
					//if($rrow['factory_status']==0){
				?>
				
				<button onclick="orderDeliveryBtn(<?php echo $s; ?>);" name="btn" id="order_delivery<?php echo $s; ?>" value="sub" class="btn btn-warning">Delivery</button>&nbsp;&nbsp;
				<span id="order_delivery_sms<?php echo $s; ?>"></span>
				<input type="hidden" id="hide_sms_id<?php echo $s; ?>" value="<?php echo $rrow['id']; ?>" />
				<span id="order_deny_sms<?php echo $s; ?>"></span>
				
				<div class="row" style="margin-top: 15px;">
					<div class="col-xs-12 col-sm-6">	
						Date(calendar)
						<input type="date" id="date3<?php echo $s; ?>" data-format="dd/mm/YYYY" class="form-control" name="bday">
						<input type="hidden" id="hide_sms_ids<?php echo $s; ?>" value="<?php echo $rrow['id']; ?>" />
						<input type="hidden" id="mobile3<?php echo $s; ?>" value="<?php echo $rrow['cus_mobile']; ?>" />
						<input type="hidden" style="" name="date1" id="date_org3<?php echo $s; ?>" value="<?php echo date('d/m/Y',strtotime($rrow['dv_date'])); ?>" />
					</div>
					<div class="col-xs-12 col-sm-6">
						<button style="margin-top: 19px;" onclick="onlyDateUpdateBtn(<?php echo $s; ?>);" name="btn" id="only_dateupdate<?php echo $s; ?>" value="sub" class="btn btn-success">Send SMS</button>&nbsp;&nbsp;
						<span id="only_date_update_sms<?php echo $s; ?>"></span>
					</div>
				</div>
			</div>
		</div>
				<?php } ?>
			<input type="hidden" id="mobile3<?php echo $s; ?>" value="<?php echo $rrow['cus_mobile']; ?>" />
			<?php 
			echo "<input type='hidden' id='discount$s' value='$discount' />
				<input type='hidden' id='discount_tot$s' value='$total_tk1' /></div></div><hr/>";
			$paytblf=$payspan=$paytbl=$paytblhead=$paytbl2=$paytbldue=$paytblpay=$paytbl3=$payspan_end="";
			$ptblf=$ptbl=$ptbl2=$ptbl3="";
			}
			
			
		}else{
			echo 2;
		}
		
	}
	
	
	
	if(isset($_REQUEST['get_item_detail'])){
		$ex=explode("#sep#",$_REQUEST['item_id']);
		$item_type=$_REQUEST['item_type'];
		$increment_number=$_REQUEST['increment_number'];
		$item_id=$ex[0];
		$group_id=$ex[1];
		$item_name=$ex[2];
		$com_id=($_SESSION['COM_ID']);
		$item_details=$conn->query("SELECT mh.title,mh.mtype,mh.id,mh.group_id,mh.amount FROM `measurement_head` mh WHERE mh.is_active=1 and mh.ptype=$item_type and mh.group_id=$group_id order by mh.steps asc"); // and mh.com_id=$com_id
			mysqli_close($conn);
			if(mysqli_num_rows($item_details)>0){
			while($rows=mysqli_fetch_array($item_details)){
				if($rows['mtype']==1){
				$txtf[]=$rows['title'];
				$txtfid[]=$rows['id'];
				}
				if($rows['mtype']==2){
				@$txtselect[]=$rows['title'];
				@$txtselectid[]=$rows['id'];
				@$txtselectgfid[]=$rows['group_id'];
				@$txtselectamountid[]=$rows['amount'];
				}
				if($rows['mtype']==3){
				$txtchk[]=$rows['title'];
				$txtchkid[]=$rows['id'];
				$txtchkamountid[]=$rows['amount'];
				}
				if($rows['mtype']==4){
				$txtarea[]=$rows['title'];
				$txtareaid=$rows['id'];
				}
			}
		?>
		<div id="delete_measurement<?php echo $increment_number; ?>" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-top: 10px;">
		<div class="row">
			
				
				<?php 
					if($_SESSION['SVERSION']==0){ //0= correcnt, 1=old order
				?>
				<input type="hidden" id="phy_ord_num" value="0"/>
				<input type="hidden" id="tbl_ord_num" value="0"/>
				<?php 
					}
				?>
				
			
			<input type="hidden" id="item_id<?php echo $increment_number; ?>" value="<?php echo $item_id; ?>"/>
			<input type="hidden" id="item_id_info<?php echo $increment_number; ?>" value="<?php echo $_REQUEST['item_id']; ?>"/>
			
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Qty:</label>
				<input class="form-control" onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" style="background: #ffc107;font-weight:bold;text-align: center;" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="" type="text" value="1" id="item_qty<?php echo $increment_number; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Rate:</label>
				<input class="form-control" onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;font-weight:bold;" type="text" value="<?php echo getItemPrice($item_id); ?>" id="item_rate<?php echo $increment_number; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Others:</label>
				<input class="form-control" readonly onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;font-weight:bold;" type="text" value="0" id="item_others<?php echo $increment_number; ?>"/>
				
			</div>
			
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Amount:</label>
				<input class="form-control" readonly autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;color: blue;font-weight: bold;" type="text" id="item_amount<?php echo $increment_number; ?>"/>
			</div>
			
			<div class="col-xs-12 col-sm-2">
		
			<input type="hidden" id="item_type<?php echo $increment_number; ?>" value="<?php echo $item_type; ?>"/>
				<label for="comment">Item:</label>
				
				<input class="form-control" readonly style="font-weight:bold;" type="text" id="item_name<?php echo $increment_number; ?>" value="<?php echo $item_name; ?>"/>
			</div>
			<input type="hidden" id="master_id<?php echo $increment_number; ?>" value="0"/>
			<input type="hidden" id="karigor_id<?php echo $increment_number; ?>" value="0"/>
			
			
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Group Name:</label>
				
				<input class="form-control" type="text" id="group_name<?php echo $increment_number; ?>" value=""/>
			</div>
			<div>
				<button style="margin-top: 25px;" onclick="deleteMeasurement('<?php echo $increment_number; ?>');" name="btn" style="" value="sub" id="" class="btn btn-danger">Remove</button><span style="margin-top:20px;position: fixed; margin-left: 6px;" id="dtls_load"></span>
			</div>
		</div>
		<!--<hr style="border-top: 1px solid #d8c3c3;"> </hr>-->
		<div class="row">
		
			<?php
				if($group_id==1 && $item_type==1){
			?>
			
				<?php 
				for($i=0;$i<10;$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" type="hidden" value="1" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				
				<?php
				}
				?>
				
				<?php 
				for($i=10;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-weight: bold'>
					<input class="form-control" onkeydown="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" type="hidden" value="1" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
				 }else{ 
				for($i=0;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" type="hidden" value="1" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
			} ?>
			<input type="hidden" id="sizetot<?php echo $increment_number; ?>" value="<?php echo count($txtfid); ?>" />
			
		</div>
		<div class="row" style="overflow:hidden">
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;display: none;">
			<table style="width: 100%;">
				<?php 
				if(isset($txtselect)){
				for($i=0;$i<count($txtselect);$i++){
				?>
				<input type="hidden" id="propertice_title<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtselectid[$i]; ?>" />
				<input type="hidden" id="select_amount<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtselectamountid[$i]; ?>" />
				<tr>
					<td>
						<select id="propertice<?php echo $increment_number; ?><?php echo $i; ?>" onchange="calculateSelectAmount('<?php echo $increment_number; ?>','<?php echo $i; ?>');" class="form-control" style="margin-bottom: 10px;float: left;width: 89% !important;">
							<option value=""><?php echo $txtselect[$i]; ?></option>
							<?php 
								echo getSelectDetail_Sh($txtselect[$i],$txtselectgfid[$i],$item_type); //$item_type
							?>
						</select>
						<span>&nbsp;[<span style="color:blue"><?php echo $txtselectamountid[$i]; ?></span>]</span>
					</td>
				</tr>				
				
				
				<?php
				
				}
			
				?>
			
			<input type="hidden" id="propertice_title_tot<?php echo $increment_number; ?>" value="<?php echo count($txtselectid); ?>" />
			<?php } ?>
			</table>
			</div>
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
				<?php 
				if(isset($txtchk)){
				for($i=0;$i<count($txtchk);$i++){
				?>
				<div class="col-xs-12 col-sm-12" style="display: none;">
				<input type="hidden" id="check_amount<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtchkamountid[$i]; ?>" />
				<input style="margin-right: 10px;margin-bottom: 10px;" onclick="getCheckBoxAmount('<?php echo $increment_number; ?>')" type="checkbox" class="chkbox" id="expropertice<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtchkid[$i]; ?>" /><?php echo $txtchk[$i]; ?>-[<span style="color:blue"><?php echo $txtchkamountid[$i]; ?></span>]
				</div>
				<?php
				}
				}
				?>
				<input type="hidden" id="expropertice_tot<?php echo $increment_number; ?>" value="<?php echo count(@$txtchkid); ?>" />
			</div>
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
				<?php
					if($item_type==1){ //For gents
					if($_SESSION['SHOW_DESIGN']==1){
						if($item_name=="Shirt"){
							?>
							<img src="img/1.png" style="width:150px"/>
							<?php 
						}else if($item_name=="Fatua"){
							?>
							<img src="img/2.png" style="width:150px"/>
							<?php 
						}else if($item_name=="Pant"){
							?>
							<img src="img/3.png" style="width:150px;height: 215px;"/>
							<?php 
						}else if($item_name=="Panjabi"){
							?>
							<img src="img/4.png" style="width:180px;height: 215px;"/>
							<?php 
						}else if($item_name=="Mujib Coat"){
							?>
							<img src="img/5.png" style="width:150px"/>
							<?php 
						}else if($item_name=="Coat"){
							?>
							<img src="img/6.png" style="width:180px;height: 180px;"/>
							<?php 
						}else if($item_name=="Jubbah"){
							?>
							<img src="img/7.png" style="width: 180px;height: 215px;"/>
							<?php 
						}else if($item_name=="Sherwani"){
							?>
							<img src="img/8.png" style="width:180px"/>
							<?php 
						}else if($item_name=="Prince Coat"){
							?>
							<img src="img/9.png" style="width:150px;height: 180px;"/>
							<?php 
						}else if($item_name=="Waistcoat"){
							?>
							<img src="img/10.png" style="width:150px"/>
							<?php 
						}else if($item_name=="Kabli"){
							?>
							<img src="img/11.png" style="width:180px;height: 180px;"/>
							<?php 
						}else if($item_name=="Pajama"){
							?>
							<img src="img/12.png" style="width:150px;height: 215px;"/>
							<?php 
						}
					}
					}else{
						
					}
				?>
			</div>
		</div>
		<div class="row" style="overflow:hidden">
			<?php 
				if(isset($txtarea)){
				?>
				<div class="col-xs-12 col-sm-12" style="display: none;">
					<textarea style="margin-bottom: 10px;" id="extra_remarks<?php echo $increment_number; ?>" rows="2" cols="5" class="form-control"></textarea>
				</div>
				<?php
				
				}
				?>
				<input type="hidden" id="txtareaid<?php echo $increment_number; ?>" value="<?php if(isset($txtareaid)) echo @$txtareaid; else echo 0; ?>" />
		</div>
	</div>
		<?php 
			}else{
				echo 2;
			}
		
	}
	
	if(isset($_REQUEST['showPurchaseDetails'])){
		$com_id=($_SESSION['COM_ID']);
		@$tbl_id=trim($_REQUEST['tbl_id']);
		$sales_head=$conn->query("select f_total,discount_tk,others_tk,total_receive
			FROM `direct_sale_head` ds WHERE ds.is_order=0 and is_active=1 and id=$tbl_id");
		$item_details=$conn->query("select (select product_name from product where id=ds.item_id) item,ds.item_qty
			FROM `direct_sale` ds WHERE ds.dstid=$tbl_id and is_active=1");
			mysqli_close($conn);
			$sales_head_rows=mysqli_fetch_array($sales_head);
			
				?>
				<div class="row">
				<div class="col-xs-12 col-sm-12">
				
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">Sl</th>
								<th style="width:35%;">Item</th>
								<th style="width:20%;text-align: center;">Qty (গজ)</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;
								if(mysqli_num_rows($item_details)>0){
									while($row=mysqli_fetch_array($item_details)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td><?php echo $row['item']; ?></td>
											<td style="text-align: center;"><?php echo $row['item_qty']; ?></td>
										</tr>
										
										<?php 
									}
								}
							?>
						</tbody>
						
					</table>
					<h3>Payment Details</h3>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 85%;text-align: right;">Total</th><th style="text-align:right"><?php echo $sales_head_rows['f_total']; ?>/=</th>
							</tr>
							<tr>							
								<td style="text-align: right;">Others</td><th style="text-align:right"><?php echo $sales_head_rows['others_tk']; ?>/=</th>
							</tr>
							<tr>							
								<td style="text-align: right;">Discount</td><th style="text-align:right">(-)<?php echo $sales_head_rows['discount_tk']; ?>/=</th>
							</tr>	
							<tr>
								<th style="text-align: right;">Advance</th><th style="text-align:right">(-)<?php echo $sales_head_rows['total_receive']; ?>/=</th>
							</tr>
							<tr>							
								<th style="text-align: right;">Due</th><th style="text-align:right"><?php echo ($sales_head_rows['f_total']+$sales_head_rows['others_tk']-$sales_head_rows['discount_tk']-$sales_head_rows['total_receive']); ?>/=</th>
							</tr>
						</thead>
						
					</table>
								
				</div>
				</div>
				<?php 
		
	}
	
	if(isset($_REQUEST['showOnlyFabricsPrice'])){
		$com_id=($_SESSION['COM_ID']);
		@$todays_date=trim($_REQUEST['todays_date']);
		@$total_tk=trim($_REQUEST['total_tk']);
		$fabrics_taka1=$conn->query("SELECT CASE WHEN `taka`>0 THEN `taka` ELSE 0 END ord_tk,ord_number as order_number,insert_date FROM `only_febrics_tk` WHERE `is_active`=1 and date(`insert_date`)='$todays_date'");
		$fabrics_taka2=$conn->query("SELECT CASE WHEN `total_receive`>0 THEN `total_receive` ELSE 0 END ord_tk,tax as order_number,insert_date FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=0 and date(`insert_date`)='$todays_date'");
		$fabrics_taka3=$conn->query("SELECT case when `total_receive`<=`f_total` THEN total_receive ELSE f_total END ord_tk,(select DISTINCT(direct_sale.order_number) from direct_sale where direct_sale.dstid=direct_sale_head.id) order_number,insert_date FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=1 and date(`insert_date`)='$todays_date'");
			mysqli_close($conn);
			
				?>
				<div class="row">
				<div class="col-xs-12 col-sm-12">
				
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">Sl</th>
								<th style="width:35%;text-align: center;">Date</th>
								<th style="width:20%;text-align: center;">Order Number</th>
								<th style="width:20%;text-align: right;">Taka</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;
								if(mysqli_num_rows($fabrics_taka1)>0){
									while($row=mysqli_fetch_array($fabrics_taka1)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
								if(mysqli_num_rows($fabrics_taka2)>0){
									while($row=mysqli_fetch_array($fabrics_taka2)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
								if(mysqli_num_rows($fabrics_taka3)>0){
									while($row=mysqli_fetch_array($fabrics_taka3)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
							?>
						</tbody>
						<tr>
							<td colspan="3" style="text-align: right;font-weight:bold">Total: </td>
							<td style="text-align: right;font-weight:bold"><?php echo $total_tk; ?></td>
						</tr>
					</table>
					
								
				</div>
				</div>
				<?php 
		
	}
	
	if(isset($_REQUEST['showOnlyFabricsPriceTotal'])){
		$com_id=($_SESSION['COM_ID']);
		@$todays_date=trim($_REQUEST['todays_date']);
		@$end_date=trim($_REQUEST['end_date']);
		@$total_tk=trim($_REQUEST['total_tk']);
		$fabrics_taka1=$conn->query("SELECT CASE WHEN `taka`>0 THEN `taka` ELSE 0 END ord_tk,ord_number as order_number,insert_date FROM `only_febrics_tk` WHERE `is_active`=1 and date(`insert_date`) between '$todays_date' and '$end_date'");
		$fabrics_taka2=$conn->query("SELECT CASE WHEN `total_receive`>0 THEN `total_receive` ELSE 0 END ord_tk,tax as order_number,insert_date FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=0 and date(`insert_date`) between '$todays_date' and '$end_date'");
		$fabrics_taka3=$conn->query("SELECT case when `total_receive`<=`f_total` THEN total_receive ELSE f_total END ord_tk,(select DISTINCT(direct_sale.order_number) from direct_sale where direct_sale.dstid=direct_sale_head.id) order_number,insert_date FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=1 and date(`insert_date`) between '$todays_date' and '$end_date'");
			mysqli_close($conn);
			
				?>
				<div class="row">
				<div class="col-xs-12 col-sm-12">
				
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">Sl</th>
								<th style="width:35%;text-align: center;">Date</th>
								<th style="width:20%;text-align: center;">Order Number</th>
								<th style="width:20%;text-align: right;">Taka</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;
								if(mysqli_num_rows($fabrics_taka1)>0){
									while($row=mysqli_fetch_array($fabrics_taka1)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
								if(mysqli_num_rows($fabrics_taka2)>0){
									while($row=mysqli_fetch_array($fabrics_taka2)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
								if(mysqli_num_rows($fabrics_taka3)>0){
									while($row=mysqli_fetch_array($fabrics_taka3)){
										?>
										<tr>
											<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
											<td style="text-align: center;"><?php echo $row['insert_date']; ?></td>
											<td style="text-align: center;"><?php echo $row['order_number']; ?></td>
											<td style="text-align: right;"><?php echo $row['ord_tk']; ?></td>
										</tr>
										<?php 
									}
								}
							?>
						</tbody>
						<tr>
							<td colspan="3" style="text-align: right;font-weight:bold">Total: </td>
							<td style="text-align: right;font-weight:bold"><?php echo $total_tk; ?></td>
						</tr>
					</table>
					
								
				</div>
				</div>
				<?php 
		
	}
	
		if(isset($_REQUEST['showEmployeesDetails'])){
		$com_id=($_SESSION['COM_ID']);
		@$d1=trim($_REQUEST['d1']);
		@$d2=trim($_REQUEST['d2']);
		@$search_type=trim($_REQUEST['search_type']);
		@$emp_id=trim($_REQUEST['emp_id']);
		@$emp_name=trim($_REQUEST['emp_name']);
		//@$tbl_id=trim($_REQUEST['tbl_id']);
		$mob_ex=explode("(",$emp_name);
		$emp_mobile=rtrim($mob_ex[1], ")");
		if($d1!=""){
			$con="and date(insert_date) between '$d1' and '$d2'";
		}else{
			$con="and date(insert_date)<='$d2'";
		}
		
		if($search_type=='earning'){
			$status=0;
			$balance=$conn->query("SELECT * FROM `wages_head` WHERE `emp_id`=$emp_id");
		
		$sales_head=$conn->query("SELECT date(`insert_date`) idate FROM `wages_details` WHERE 
		`is_active`=1 and status=$status $con and `emp_id`=$emp_id GROUP BY date(`insert_date`)");
		
				?>
				<div class="row">
				<div class="col-xs-12 col-sm-12">
					<h3><?php echo $emp_name; ?></h3>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">সিরিয়াল</th>
								<th style="">তারিখ</th>
								<th style="width:40%;">
									<table border='0' style="width:100%">
										<tr>
											<td style="width: 60%;">আইটেম</td>
											<td style="text-align: center;width: 15%;">সংখ্যা</td>
											<td style="text-align: right;">টাকা</td>
										</tr>
									</table>
								</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;$tk=0;
								if(mysqli_num_rows($sales_head)>0){
									
									while($row=mysqli_fetch_array($sales_head)){
										$idate=$row['idate'];
										$sales_head_earning=$conn->query("SELECT sum(`item_qty`) item_qty,sum(`taka`) taka,`item_name` FROM `wages_details` WHERE 
										`is_active`=1 and status=$status and date(insert_date)='$idate' and `emp_id`=$emp_id group by item_name");
										?>
									<tr>
									<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
										<td><?php echo $idate; ?></td>
										<td>
										<table border='0' style="width:100%">
										<?php 
										while($rows=mysqli_fetch_array($sales_head_earning)){
										$tk+=$rows['taka'];
										$qty+=$rows['item_qty'];
										?>
										<tr>
											<td style="width: 60%;"><?php echo $rows['item_name']; ?></td>
											<td style="text-align: center;width: 15%;"><?php echo $rows['item_qty']; ?></td>
											<td style="text-align: right;"><?php echo $rows['taka']; ?></td>
										</tr>
										
										<?php 
										}
										?>
										
										</table>
										</td>
									</tr>
										<?php 
									}
								}
							?>
							<tr>
								<th colspan="2" style="text-align: right;">আইটেম সংখ্যা/মজুরি(জমা): </th>
								<th><span style="padding-left: 191px;"><?php echo $qty; ?></span><span style="float:right"><?php echo $tk; ?></span> </th>
							</tr>
						</tbody>
						
					</table>
						<?php
						if(mysqli_num_rows($balance)>0){
							$row=mysqli_fetch_array($balance);
							$total_balance=$row['taka'];		
						}
						?>
					
					<table border='1' style="width: 40%; margin-left: 60%;">
						<caption style="color: black;"><?php echo $emp_name; ?></caption>
						<tr style="color:red">
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold">মোট ব্যালান্স (টাকা)</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold;font-size: 18px;">
							<i id="set_balance"><?php echo $total_balance; ?></i>
							<input type="hidden" value="<?php echo $total_balance; ?>" id="total_balance_taka"/>
							<input type="hidden" value="<?php echo $emp_id; ?>" id="payment_emp_id"/>
							<input type="hidden" value="<?php echo $emp_mobile; ?>" id="worker_mobile"/>
							</td>
						</tr>
						<tr>
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold">পরিশোধ (টাকা)</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold">
							<input type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="total_item_qty" onkeyup="autoCalculator();" id="payment_taka" required/>
							</td>
						</tr>
						<tr>
							<td style="width: 60%;padding: 5px;font-weight:bold">
								<input type="text" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;" autocomplete="off" name="total_item_qty" id="payemnt_remarks" required/>
							</td>
							<td style="width: 25%; text-align: right; padding: 5px;font-weight:bold">
							মন্তব্য
							</td>
							
						</tr>
						<tr>
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold;color:blue">
							জের: <span id="due_taka"></span>
							</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold">
							<button onclick="savePaymentLive();" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="save_order" class="btn btn-success">Save</button>
							</td>
						</tr>
					</table>
					<span style="color:green;margin-left: 60%;" id="blnc_success"></span>
				</div>
				</div>
				<?php 
				mysqli_close($conn);
	}else{
		date_default_timezone_set("Asia/Dhaka");
		$date=date("Y-m-d");
		$status=1;
		$sales_head=$conn->query("SELECT id,`taka`,`item_name`,`item_qty`,`order_num`,`remarks`,date(`insert_date`) idate,ord_record_tblid,status FROM `wages_details` WHERE 
		`is_active`=1 and status=$status $con and `emp_id`=$emp_id order by date(insert_date) desc");
		mysqli_close($conn);
		?>
		<div class="row">
				<div class="col-xs-12 col-sm-12">
					<h3><?php echo $emp_name; ?> | <span style="color:green;font-weight:bold" id="payment_sms"></span></h3>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">Sl</th>
								<th style="">Date</th>
								<th style="">Remarks</th>
								<th style="width:15%;text-align: right;">Payment (Tk.)</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;$tk=0;
								if(mysqli_num_rows($sales_head)>0){
									while($row=mysqli_fetch_array($sales_head)){
										$tk+=$row['taka'];
										?>
										<tr>
											<td style="width: 5%;text-align: center;">
										
											<button onclick="delItemPayment('<?php echo $row['id']; ?>','3','<?php echo $row['taka']; ?>','<?php echo $emp_id; ?>','<?php echo $row['status']; ?>','<?php echo $row['ord_record_tblid']; ?>');" name='btn' id='delpaybtns<?php echo $row['id']; ?>' class="btn btn-danger form-control"><?php echo $sl3++; ?></button>
										
											
											</td>
											<td><?php echo $row['idate']; ?></td>
											<td><?php echo $row['remarks']; ?></td>
											<td style="text-align: right;"><?php echo $row['taka']; ?></td>
										</tr>
										
										<?php 
									}
								}
							?>
						</tbody>
						<tr>
							<th colspan="3" style="text-align: right;">Total: </th>
							<th style="text-align: right;"><?php echo $tk; ?></th>
						</tr>
					</table>
								
				</div>
				</div>
		<?php 
	}
		
	}
	
	if(isset($_REQUEST['showEmployeesStaffDetails'])){
		$com_id=($_SESSION['COM_ID']);
		@$d1=trim($_REQUEST['d1']);
		@$d2=trim($_REQUEST['d2']);
		@$search_type=trim($_REQUEST['search_type']);
		@$emp_id=trim($_REQUEST['emp_id']);
		@$emp_name=trim($_REQUEST['emp_name']);
		//@$tbl_id=trim($_REQUEST['tbl_id']);
		if($d1!=""){
			$con="and date(insert_date) between '$d1' and '$d2'";
		}else{
			$con="and date(insert_date)<='$d2'";
		}
		
		if($search_type=='earning'){
			$status=0;
			$balance=$conn->query("SELECT * FROM `wages_head` WHERE `emp_id`=$emp_id");
		
		$sales_head=$conn->query("SELECT date(`insert_date`) idate,sum(actual_salary) asalary FROM `salary_transaction` WHERE 
		`is_active`=1 and status=$status $con and `emp_id`=$emp_id GROUP BY date(`insert_date`)");
		
				?>
				<div class="row">
				<div class="col-xs-12 col-sm-12">
					<h3><?php echo $emp_name; ?></h3>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">সিরিয়াল</th>
								<th style="">তারিখ</th>
								<td style="text-align: right;">টাকা</td>
								
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;$tk=0;
								if(mysqli_num_rows($sales_head)>0){
									
									while($row=mysqli_fetch_array($sales_head)){
										$idate=$row['idate'];
										$asalary=$row['asalary'];
										$tk+=$asalary;
										?>
									<tr>
									<td style="width: 5%;text-align: center;"><?php echo $sl3++; ?></td>
										<td><?php echo date_format(date_create($idate),"d/m/Y"); ?></td>
										<td style="text-align: right;"><?php echo $asalary; ?></td>
										
									</tr>
										<?php 
									}
								}
							?>
							<tr>
								<th colspan="2" style="text-align: right;">বেতন জমা: </th>
								<th><span style="float:right"><?php echo $tk; ?></span> </th>
							</tr>
						</tbody>
						
					</table>
						<?php
						if(mysqli_num_rows($balance)>0){
							$row=mysqli_fetch_array($balance);
							$total_balance=$row['taka'];		
						}
						?>
					
					<table border='1' style="width: 40%; margin-left: 60%;">
						<caption style="color: black;"><?php echo $emp_name; ?></caption>
						<tr style="color:red">
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold">মোট ব্যালান্স (টাকা)</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold;font-size: 18px;">
							<i id="set_balance"><?php echo $total_balance; ?></i>
							<input type="hidden" value="<?php echo $total_balance; ?>" id="total_balance_taka"/>
							<input type="hidden" value="<?php echo $emp_id; ?>" id="payment_emp_id"/>
							</td>
						</tr>
						<tr>
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold">পরিশোধ (টাকা)</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold">
							<input type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="total_item_qty" onkeyup="autoCalculator();" id="payment_taka" required/>
							</td>
						</tr>
						<tr>
							<td style="width: 60%;padding: 5px;font-weight:bold">
								<input type="text" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;" autocomplete="off" name="total_item_qty" id="payemnt_remarks" required/>
							</td>
							<td style="width: 25%; text-align: right; padding: 5px;font-weight:bold">
							মন্তব্য
							</td>
							
						</tr>
						<tr>
							<td style="width: 60%;padding: 5px;font-weight:bold">
								<input type="text" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;" autocomplete="off" value="<?php echo date('d/m/Y'); ?>" name="total_item_qty" id="payemnt_date" required/>
							</td>
							<td style="width: 25%; text-align: right; padding: 5px;font-weight:bold">
							তারিখ
							</td>
							
						</tr>
						<tr>
							<td style="width: 60%; text-align: right; padding: 5px;font-weight:bold;color:blue">
							জের: <span id="due_taka"></span>
							</td>
							<td style="width: 25%;text-align: right;padding: 5px;font-weight:bold">
							<button onclick="saveStaffPaymentLive();" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="save_order" class="btn btn-success">Save</button>
							</td>
						</tr>
					</table>
					<span style="color:green;margin-left: 60%;" id="blnc_success"></span>
				</div>
				</div>
				<?php 
				mysqli_close($conn);
	}else{
		date_default_timezone_set("Asia/Dhaka");
		$date=date("Y-m-d");
		$status=1;
		$sales_head=$conn->query("SELECT id,`actual_salary` taka,`remarks`,date(`insert_date`) idate,status,salary_month,salary_year FROM `salary_transaction` WHERE 
		`is_active`=1 and status=$status $con and `emp_id`=$emp_id order by date(insert_date) desc");
		mysqli_close($conn);
		?>
		<div class="row">
				<div class="col-xs-12 col-sm-12">
					<h3><?php echo $emp_name; ?> | <span style="color:green;font-weight:bold" id="payment_sms"></span></h3>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 5%;text-align: center;">Sl</th>
								<th style="">Date</th>
								<th style="">Remarks</th>
								<th style="width:15%;text-align: right;">Payment (Tk.)</th>
							</tr>
						</thead>
						<tbody>
							<?php 
								$sl3=1;$order_tk3=0;$qty=0;$tk=0;
								if(mysqli_num_rows($sales_head)>0){
									while($row=mysqli_fetch_array($sales_head)){
										$tk+=$row['taka'];
										
										?>
										<tr style="color:<?php echo ($row['salary_month']!="")? 'blue' : ''; ?>">
											<td style="width: 5%;text-align: center;">
											<?php 
											if($date==$row['idate']){
											?>
											<button onclick="delItemStaffPayment('<?php echo $row['id']; ?>','3','<?php echo $row['taka']; ?>','<?php echo $emp_id; ?>','<?php echo $row['status']; ?>');" name='btn' id='delpaybtns<?php echo $row['id']; ?>' class="btn btn-danger form-control"><?php echo $sl3++; ?></button>
											<?php }else{
												 echo $sl3++; 
											} ?>
											
											</td>
											<td><?php echo date_format(date_create($row['idate']),"d/m/Y"); ?></td>
											<td><?php echo ($row['salary_month']!="")? $row['salary_month'].'-'.$row['salary_year'].' Salary' : ''; ?> [ <?php echo $row['remarks']; ?> ]</td>
											<td style="text-align: right;"><?php echo $row['taka']; ?></td>
										</tr>
										
										<?php 
									}
								}
							?>
						</tbody>
						<tr>
							<th colspan="3" style="text-align: right;">Total: </th>
							<th style="text-align: right;"><?php echo $tk; ?></th>
						</tr>
					</table>
								
				</div>
				</div>
		<?php 
	}
		
	}
	
	if(isset($_REQUEST['savePaymentLive'])){
		$due_tk="";
		$com_id=($_SESSION['COM_ID']);
		$user_id=($_SESSION['USER_ID']);
		$emp_id=($_REQUEST['emp_id']);
		$total_balance_taka=($_REQUEST['total_balance_taka']);
		$payment_taka=($_REQUEST['payment_taka']);
		@$payemnt_remarks=($_REQUEST['payemnt_remarks']);
		@$worker_mobile=trim($_REQUEST['worker_mobile']);
		
		$emp_info=$conn->query("SELECT id,taka from wages_head where emp_id=$emp_id and com_id=$com_id");
		if(mysqli_num_rows($emp_info)>0){
			$row=mysqli_fetch_array($emp_info);
			$id=$row['id'];
			$utaka=($row['taka']-$payment_taka);
			$due_tk=$utaka;
			$last_insert_head=$conn->query("update wages_head set taka='$utaka' where id=$id");
		}else{
			$last_insert_head=$conn->query("insert into wages_head(com_id,emp_id,taka) values ($com_id,$emp_id,'$payment_taka')");
		}
		$last_insert=$conn->query("insert into wages_details(com_id,
			emp_id,
			taka,
			remarks,
			status,
			insert_by
			) values($com_id,
			$emp_id,
			'$payment_taka',
			'$payemnt_remarks',
			'1',
			$user_id)");
			
		if($wages_sms==1){ // 1=means worker payment/assign smsm 
			$cus_mobile=$worker_mobile;
			if(check_internet_connection()==1){
				send_sms($cus_mobile,$cus_mobile,$payment_taka,$due_tk,12);
			}
		
		}
			
		
		if($last_insert){
			echo 1;
		}else{
			echo 2;
		}
	}
	
if(isset($_REQUEST['saveStaffPaymentLive'])){
		$due_tk="";
		$com_id=($_SESSION['COM_ID']);
		$user_id=($_SESSION['USER_ID']);
		$emp_id=($_REQUEST['emp_id']);
		$total_balance_taka=($_REQUEST['total_balance_taka']);
		$payment_taka=($_REQUEST['payment_taka']);
		@$payemnt_remarks=($_REQUEST['payemnt_remarks']);
		@$payemnt_date=($_REQUEST['payemnt_date']);
		
		$date_extend=date('H:i:s');
		
		if(@$payemnt_date!=""){
			$ex3=explode("/",$payemnt_date);
			$order_date1=$ex3[2]."-".$ex3[1]."-".$ex3[0];
			$order_date1=$order_date1.' '.$date_extend;
			
		}
		else{
			$order_date1=date('Y-m-d').' '.$date_extend;
		}
		
		$emp_info=$conn->query("SELECT id,taka from wages_head where emp_id=$emp_id and com_id=$com_id");
		if(mysqli_num_rows($emp_info)>0){
			$row=mysqli_fetch_array($emp_info);
			$id=$row['id'];
			$utaka=($row['taka']-$payment_taka);
			$due_tk=$utaka;
			$last_insert_head=$conn->query("update wages_head set taka='$utaka' where id=$id");
		}else{
			$last_insert_head=$conn->query("insert into wages_head(com_id,emp_id,taka) values ($com_id,$emp_id,'$payment_taka')");
		}
		$last_insert=$conn->query("insert into salary_transaction(emp_id,
			actual_salary,
			remarks,
			status,
			insert_by,
			insert_date
			) values('$emp_id',
			'$payment_taka',
			'$payemnt_remarks',
			'1',
			$user_id,'$order_date1')");
			
			
		
		if($last_insert){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	
	if(isset($_REQUEST['smeasurement'])){
		$com_id=($_SESSION['COM_ID']);
		@$order_number=trim($_REQUEST['ord_num']);
		$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
			(select artisan_price from product where id=ord.item_id) karigor_price,ds.cus_name,ds.cus_mobile,ds.insert_date,ds.phy_ord_num,
			(select product_name from product where id=ord.item_id) product,ord.group_name,
			ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.phy_dv_date,ds.fdtime,
			(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.maker) karigor,(select user_name from user where id=ord.karigor_id) fkarigor,
			(select user_name from user where id=ord.master_emp_id) master,(select user_name from user where id=ord.master_id) fmaster,ord.item_qty
			FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ord.order_number='$order_number' and ord.is_active=1");
			//mysqli_close($conn);
		
			$i=1;
			while($rows=mysqli_fetch_array($order_details)){
				@$master=$rows['master'];
				@$fmaster=$rows['fmaster'];
				@$karigor=$rows['karigor'];
				@$fkarigor=$rows['fkarigor'];
				@$item_id=$rows['item_id'];
				@$ord_id=$rows['id'];
				
				$karigor_details=$conn->query("SELECT (select user_name from user where id=wages_details.emp_id) karigor,item_qty,emp_type,date(insert_date) adate from wages_details where order_num='$order_number' and is_active=1 and ord_record_tblid=$ord_id");
				//$karigor_details=$conn->query("SELECT (select user_name from user where id=wages_details.emp_id) karigor,item_qty,emp_type from wages_details where order_num='$order_number' and is_active=1 and item_ids=$item_id");
					$kname="";
					$mname="";
					if(mysqli_num_rows($karigor_details)>0){
						$kname=array();
						$mname=array();
						while($rows_karigor=mysqli_fetch_array($karigor_details)){
							if($rows_karigor['emp_type']==2 || $rows_karigor['emp_type']==0){ //2=karigor 
								$date="<span style='font-size: 12px;color: #8a6d3b;'>(".date_format(date_create($rows_karigor['adate']),"d/m/Y").")</span>";
								$kname[]=$rows_karigor['karigor']."(".$rows_karigor['item_qty'].")".$date;
							}else{ // master=1
								$date="<span style='font-size: 12px;color: #8a6d3b;'>(".date_format(date_create($rows_karigor['adate']),"d/m/Y").")</span>";
								$mname[]=$rows_karigor['karigor']."(".$rows_karigor['item_qty'].")".$date;
							}
						}
						$kname=(count($kname)>0)? implode(', ',$kname) : $fkarigor;
						$mname=(count($mname)>0)? implode(', ',$mname) : $fmaster;
						
				}
		
				$mname=($master=="")? $fmaster : $mname;
				$kname=($karigor=="")? $fkarigor : $kname;
				?>
				<div class="row" style="overflow: hidden;border-bottom: 1px solid #e2e2ead1;margin: 0 auto;margin-bottom: 10px;">
					<?php if($i==1){ ?>
					<p style="font-size: 15px;margin-right: 25px;color:#f22ee0;"><b>Order No- </b><?php echo $rows['phy_ord_num']; ?></p>
					<p style="font-size: 12px;margin-right: 25px;color:#000000c4"><b>কাস্টমার- </b><?php echo $rows['cus_name']; ?> [<?php echo $rows['cus_mobile']; ?>] <br/><b>Order Date:</b> <?php echo date_format(date_create($rows['insert_date']),"d/m/Y"); ?> | <b>Delivery Date:</b> <?php echo date_format(date_create($rows['dv_date']),"d/m/Y"); ?> | <b>Receive Date:</b> <?php echo date_format(date_create(@$rows['factory_receive_date']),"d/m/Y"); ?> | <b>Physical Delivery:</b> <?php echo date_format(date_create(@$rows['phy_dv_date']),"d/m/Y"); ?></p>
					<?php } ?>
					<p style="font-size: 12px;float: left;margin-right: 25px;"><b><?php echo $i++; ?>)</b> <span style='color: #4444d1b8;'><b><?php echo $rows['product']; ?>[<?php echo $rows['id']; ?>]</b> (<?php echo $rows['item_qty']; ?>)</span></p>
					<p style="font-size: 12px;float: left;margin-right: 25px;"><b>গ্রুপ নাম- </b><?php echo $rows['group_name']; ?></p>
					<p style="font-size: 12px;float: left;margin-right: 25px;"><b>মাস্টার- </b><?php echo $mname; ?></p>
					<p style="font-size: 12px;"><b>কারিগর- </b><?php echo $kname; ?></p>
					
						
							<div class="" style="margin-top:0px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($rows['ptype']==1){
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['product']=="Shirt"){
									?>
										<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
									<?php 
									}else if($rows['product']=="Fatua"){
										?>
										<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
										<?php 
									}else if($rows['product']=="Pant"){
										?>
										<img src="img/3.png" style="width: 100px;height: 110px;"/>
										<?php 
									}else if($rows['product']=="Panjabi"){
										?>
										<img src="img/4.png" style="width: 128px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Mujib Coat"){
										?>
										<img src="img/5.png" style="width:110px;height: 136px;"/>
										<?php 
									}else if($rows['product']=="Coat"){
										?>
										<img src="img/6.png" style="width: 130px;height: 125px;"/>
										<?php 
									}else if($rows['product']=="Jubbah"){
										?>
										<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
										<?php 
									}else if($rows['product']=="Sherwani"){
										?>
										<img src="img/8.png" style="width: 120px;height: 135px;"/>
										<?php 
									}else if($rows['product']=="Prince Coat"){
										?>
										<img src="img/9.png" style="width: 105px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Waistcoat"){
										?>
										<img src="img/10.png" style="width:85px"/>
										<?php 
									}else if($rows['product']=="Kabli"){
										?>
										<img src="img/11.png" style="width: 115px;height:120px;"/>
										<?php 
									}else if($rows['product']=="Pajama"){
										?>
										<img src="img/12.png" style="width:92px;height: 120px;"/>
										<?php 
									}
								}
								}else{
									
								}
								?>
							</div>
						
				</div>
				
				<?php 
			}
			?>
			<div class="row" style="overflow: hidden;border-bottom: 1px solid #e2e2ead1;margin: 0 auto;margin-bottom: 10px;">
					
					<?php 
						$item_details=$conn->query("select (select product_name from product where id=direct_sale.item_id) item_name,item_qty from direct_sale where order_number='$order_number' and is_active=1");
						
					?>
					
						
			</div>
			<label style="font-weight: bold;text-decoration: underline;">ফ্যাব্রিক্স আইটেম:</label>
				<table id="dynamic-table" class="table table-striped table-bordered table-hover">
					<thead>
						<thead>
						<tr>
							<th style="text-align:center">Sl</th>
							<th style="">Item</th>
							<th style="text-align:center">Item Qty (গজ)</th>
							</tr>
					</thead>
					<tbody>
						<?php 
							$sl2=1;
							if(mysqli_num_rows($item_details)>0){
								while($rows=mysqli_fetch_array($item_details)){
								?>
									<tr>
									<td style="text-align:center"><?php echo $sl2++; ?></td>
									<td>
										<?php echo $rows['item_name']; ?>
									</td>
									<td style="text-align:center">
										<?php echo $rows['item_qty']; ?>
									</td>
									
									</tr>
									<?php 
								}
							}
						?>
					</tbody>
					
				</table>
				</div>
			<?php 
			$i++;
			mysqli_close($conn);
	}
	
	if(isset($_REQUEST['showExpenseBreakdown'])){
		$com_id=($_SESSION['COM_ID']);
		$expense_title=$_REQUEST['expense_title'];
		$expense_type=$_REQUEST['expense_type'];
		$d1=$_REQUEST['sdate'];
		$d2=$_REQUEST['tdate'];
		$expense_type_sql=$conn->query("SELECT expense extk,expense_type,insert_date,remarks,(select et.expense from expense_type et where et.id=expenses.expense_type) expense_title FROM `expenses` WHERE `is_active`=1 and `expense_type`=$expense_type and date(`insert_date`) BETWEEN '$d1' and '$d2'");
		
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($expense_type_sql)>0){
								?>
								<label><?php echo $expense_title; ?></label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:20%;">Date</th>
											<th style="width:55%;">Remarks</th>
											<th style="width:20%;text-align:right">Taka/=</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($expense_type_sql)){
													$c=$sl++;
													$tot_qty+=$rows['extk'];
													?>
													<tr>
														<td style="text-align: center;"><?php echo $c; ?></td>
														<td>
															<?php echo $rows['insert_date']; ?>
														</td>
														<td>
															<?php echo $rows['remarks']; ?>
														</td>
														<td style="text-align: right;"><?php echo $rows['extk']; ?>/=</td>
													</tr>
													<?php 
												}
										?>
										<tr>
											<td colspan="3" style="text-align: right;font-weight:bold">Total</td>
											<td style="text-align: right;font-weight:bold"><?php echo $tot_qty; ?>/=</td>
										</tr>
									</tbody>
									
								</table>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					</div>
							
					</div>
					<?php 
	}
	
	if(isset($_REQUEST['get_selected_item'])){
		$com_id=($_SESSION['COM_ID']);
		$item_type=$_REQUEST['item_type'];
		$order_details=$conn->query("SELECT * FROM `product` WHERE com_id=$com_id and is_active=1 and ptype=$item_type order by steps asc");
		if(mysqli_num_rows($order_details)>0){
			$ic=1;
			while($rows=mysqli_fetch_array($order_details)){
				$jj=$ic++;
				if($rows['ptype']==1){
				?>
				<button  onclick="itemIdWiseDetails('<?php echo $rows['id']."#sep#".$rows['group_id']."#sep#".$rows['product_name']."#sep#".$jj; ?>');" name="btn" value="sub" id="item_btn<?php echo $jj; ?>" class="btn btn-primary"><?php echo $rows['product_name']; ?></button>
				<?php 
				}else{
					?>
					<button  onclick="itemIdWiseDetails('<?php echo $rows['id']."#sep#".$rows['group_id']."#sep#".$rows['product_name']."#sep#".$jj; ?>');" name="btn" value="sub" id="item_btn<?php echo $jj; ?>" class="btn btn-success"><?php echo $rows['product_name']; ?></button>
					<?php 
				}
			}
		}else{
			
		}
	}
	
	if(isset($_REQUEST['select_item_type'])){
		$com_id=($_SESSION['COM_ID']);
		$item_type=$_REQUEST['item_type'];
		$order_details=$conn->query("SELECT * FROM `product` WHERE com_id=$com_id and is_active=1 and ptype=$item_type order by steps asc");
		if(mysqli_num_rows($order_details)>0){
			echo '<option value="">Select Any Item</option>';
			while($rows=mysqli_fetch_array($order_details)){
				?>
				<option value='<?php echo $rows['id']."#sep#".$rows['group_id']."#sep#".$rows['product_name']; ?>'><?php echo $rows['product_name']."(".$rows['group_id'].")"; ?></option>
				<?php 
			}
		}else{
			?>
			<option value=''></option>
			<?php 
		}
	}
	
	if(isset($_REQUEST['setOrdNum'])){
		$com_id=($_SESSION['COM_ID']);
		if($_SESSION['SVERSION']==0){ //0= current, 1=old order
			$ex=getOrderNumber($com_id); 
			//echo "A".$ex[0];
			?>
			<input type='text' maxlength='15' value='' class='form-control' onkeydown='enterEventSelection("phy_ord_num","mobile")' onkeyup='DuplicateOrderChking();' style='width:15%;font-weight: bold;font-size:25px;font-style: italic; background:#4a9505;color: white;float: left;margin-right: 5px;text-transform:uppercase' autocomplete='off' id='phy_ord_num'/><span id='ord_success'></span><input type='hidden' value='$ex' id='hidden_phy_ord_num'/>
			<?php 
		}else if($_SESSION['SVERSION']==1){
			//echo getOrderNumber($com_id); 
			echo "<input type='text' maxlength='15' class='form-control' onkeyup='checkPreviousOrder()' style='width:15%;font-weight: bold;font-size:25px;font-style: italic; background:#0e924f;;color: white;float: left;margin-right: 5px;text-transform:uppercase' autocomplete='off' id='phy_ord_num'/><span id='ord_success'></span>"; 
		}else if($_SESSION['SVERSION']==2){
			echo "<input type='text' maxlength='15' class='form-control' onkeyup='checkPreviousOrderAndMearge()' style='width:15%;font-weight: bold;font-size:25px;font-style: italic; background:#1066ad;color: white;float: left;margin-right: 5px;text-transform:uppercase' autocomplete='off' id='phy_ord_num'/><span id='ord_success'></span>"; 
		}
	}
	
	if(isset($_REQUEST['checkPreviousOrder'])){
		$manual_book_ord=$_REQUEST['phy_ord_num'];
		$com_id=($_SESSION['COM_ID']);
		$duplicate_order=$conn->query("SELECT cus_mobile,cus_name,(select id from customer where cus_mobile=dsms.cus_mobile) cus_id from dsms where phy_ord_num='$manual_book_ord' and com_id=$com_id and is_active=1"); 
		if(mysqli_num_rows($duplicate_order)>0){
			$rows=mysqli_fetch_array($duplicate_order);
			echo 1; // duplicate order number
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['checkPreviousOrder2'])){
		$manual_book_ord=$_REQUEST['phy_ord_num'];
		$com_id=($_SESSION['COM_ID']);
		$duplicate_order=$conn->query("SELECT cus_mobile,cus_name,(select id from customer where cus_mobile=dsms.cus_mobile and is_active=1 limit 0,1) cus_id from dsms where phy_ord_num='$manual_book_ord' and com_id=$com_id and is_active=1"); 
		if(mysqli_num_rows($duplicate_order)>0){
			$rows=mysqli_fetch_array($duplicate_order);
			echo $rows['cus_mobile']."#sep#".$rows['cus_id']."#sep#".$rows['cus_name']; // duplicate order number
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['newMeasurement'])){
		$ord_tbl_id=$_REQUEST['ord_tbl_id'];
		$design_cost=$_REQUEST['design_cost'];
		$amount_cost=$_REQUEST['amount_cost'];
		$item_qty=$_REQUEST['item_qty'];
		$item_type=$_REQUEST['ptye'];
		$item_id=$_REQUEST['item_id'];
		$group_id=$_REQUEST['group_id'];
		$item_name=$_REQUEST['item_name'];
		$master_id=$_REQUEST['master_id'];
		$karigor_id=$_REQUEST['karigor_id'];
		$orderinfo=explode("_",$_REQUEST['orderinfo']);
		$increment_number=$_REQUEST['increment_number'];
		$com_id=($_SESSION['COM_ID']);
		$item_details=$conn->query("SELECT mh.title,mh.mtype,mh.id,mh.group_id,mh.amount FROM `measurement_head` mh WHERE mh.is_active=1 and mh.ptype=$item_type and mh.group_id=$group_id order by mh.steps asc"); // and mh.com_id=$com_id
			mysqli_close($conn);
			if(mysqli_num_rows($item_details)>0){
			while($rows=mysqli_fetch_array($item_details)){
				if($rows['mtype']==1){
				$txtf[]=$rows['title'];
				$txtfid[]=$rows['id'];
				}
				if($rows['mtype']==2){
				$txtselect[]=$rows['title'];
				$txtselectid[]=$rows['id'];
				$txtselectgfid[]=$rows['group_id'];
				$txtselectamountid[]=$rows['amount'];
				}
				if($rows['mtype']==3){
				$txtchk[]=$rows['title'];
				$txtchkid[]=$rows['id'];
				$txtchkamountid[]=$rows['amount'];
				}
				if($rows['mtype']==4){
				$txtarea=$rows['title'];
				$txtareaid=$rows['id'];
				}
			}
			$item_rate=getItemPrice($item_id);
			@$group_name=getGoupName($ord_tbl_id);
		?>
		<div id="delete_measurement<?php echo $increment_number; ?>" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-top: 10px;">
		<div class="row">
		<input type="hidden" id="item_id<?php echo $increment_number; ?>" value="<?php echo $item_id; ?>"/>
		<input type="hidden" id="item_id_info<?php echo $increment_number; ?>" value="<?php echo $item_id."#sep#".$group_id."#sep#".$item_name; ?>"/>
		<div class="col-xs-12 col-sm-1">
				<label for="comment">Qty:</label>
				<input class="form-control" onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" style="background: #ffc107;font-weight:bold;text-align: center;" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="" type="text" value="<?php echo $item_qty; ?>" id="item_qty<?php echo $increment_number; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Rate:</label>
				<input class="form-control" readonly onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo $item_rate; ?>" id="item_rate<?php echo $increment_number; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Others:</label>
				<input class="form-control" readonly onkeyup="itemAmountChange('<?php echo $increment_number; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo @$design_cost; ?>" id="item_others<?php echo $increment_number; ?>"/>
				
			</div>
			
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Amount:</label>
				<input class="form-control" readonly autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;color: blue;font-weight: bold;" type="text" value="<?php echo @$amount_cost; ?>" id="item_amount<?php echo $increment_number; ?>"/>
			</div>
			
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Item:</label>
				
				<input class="form-control" readonly type="text" id="item_name<?php echo $increment_number; ?>" value="<?php echo $item_name; ?>"/>
					
				
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 12%;">
				<label for="comment">Master: <span id="pending_master<?php echo $increment_number; ?>"></span></label>
				<select id="master_id<?php echo $increment_number; ?>"  onchange="getPendingTask('1','master_id','pending_master','<?php echo $increment_number; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('1',$master_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 13%;">
				<label for="comment">Karigor: <span id="pending_karigor<?php echo $increment_number; ?>"></span></label>
				<select id="karigor_id<?php echo $increment_number; ?>"  onchange="getPendingTask('2','karigor_id','pending_karigor','<?php echo $increment_number; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('2',$karigor_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2">
			<input type="hidden" id="item_type<?php echo $increment_number; ?>" value="<?php echo $item_type; ?>"/>
				<label for="comment">Group Name:</label>
				
				<input class="form-control" type="text" id="group_name<?php echo $increment_number; ?>" value="<?php echo $group_name; ?>"/>
			</div>
			<div>
				<label for="comment" style="color: blue;cursor: pointer;float: right;padding-right: 16px;"><i onclick="copyOnlyMeasurement('<?php echo $item_id; ?>','<?php echo $increment_number; ?>');">Paste</i><input type="radio" style="margin-left: 5px;cursor: pointer;" name="paste_id" onclick="selectedItem('<?php echo $increment_number; ?>')" value="<?php echo $increment_number; ?>"/></label>
				<button onclick="deleteMeasurement('<?php echo $increment_number; ?>');" name="btn" style="" value="sub" id="" class="btn btn-danger">Remove</button><span style="margin-top:20px;position: fixed; margin-left: 6px;" id="dtls_load"></span>
			</div>
		</div>
		<hr style="border-top: 1px solid #d8c3c3;"> </hr>
		<div class="row">
			
			
			<?php
				if($group_id==1 && $item_type==1){
			?>
			
				<?php 
				for($i=0;$i<10;$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeyup="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				
				<?php
				}
				?>
				
				<?php 
				for($i=10;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold'>
					<input class="form-control" onkeyup="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
				 }else{ 
				for($i=0;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeyup="enterEvent('size<?php echo $increment_number; ?>','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="size<?php echo $increment_number; ?><?php echo $i; ?>"/>
					<input type="hidden" id="sizetxt<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
			} ?>
			<input type="hidden" id="sizetot<?php echo $increment_number; ?>" value="<?php echo count($txtfid); ?>" />
			
		</div>
		<div class="row" style="overflow:hidden">
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
			<table style="width: 100%;">
				<?php 
				for($i=0;$i<count($txtselect);$i++){
				?>
				<input type="hidden" id="propertice_title<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtselectid[$i]; ?>" />
				<input type="hidden" id="select_amount<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtselectamountid[$i]; ?>" />
				<tr>
					<td>
						<select id="propertice<?php echo $increment_number; ?><?php echo $i; ?>" onchange="calculateSelectAmount('<?php echo $increment_number; ?>','<?php echo $i; ?>');" class="form-control" style="margin-bottom: 10px;float: left;width: 89% !important;">
							<option value=""><?php echo $txtselect[$i]; ?></option>
							<?php 
								echo getSelectDetail_ShEdit($txtselect[$i],$txtselectgfid[$i],$item_type,$ord_tbl_id); //$item_type
							?>
						</select><span>&nbsp;[<span style="color:blue"><?php echo $txtselectamountid[$i]; ?></span>]</span>
					</td>
				</tr>
				<?php
				
				}
				?>
			
			<input type="hidden" id="propertice_title_tot<?php echo $increment_number; ?>" value="<?php echo count($txtselectid); ?>" />
			</table>
			</div>
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
				<?php 
				if(isset($txtchk)){
				for($i=0;$i<count($txtchk);$i++){
				?>
				<div class="col-xs-12 col-sm-12">
				<input type="hidden" id="check_amount<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtchkamountid[$i]; ?>" />
				<input style="margin-right: 10px;margin-bottom: 10px;" <?php if(getEditMeasurement($ord_tbl_id,$txtchkid[$i],3)==$txtchkid[$i]) echo "checked"; else echo ""; ?> type="checkbox" onclick="getCheckBoxAmount('<?php echo $increment_number; ?>')" class="chkbox" id="expropertice<?php echo $increment_number; ?><?php echo $i; ?>" value="<?php echo $txtchkid[$i]; ?>" /><?php echo $txtchk[$i]; ?>-[<span style="color:blue"><?php echo $txtchkamountid[$i]; ?></span>]
				</div>
				<?php
				}
				}
				?>
				<input type="hidden" id="expropertice_tot<?php echo $increment_number; ?>" value="<?php echo count(@$txtchkid); ?>" />
			</div>
			
		</div>
		<div class="row" style="overflow:hidden;padding-top: 10px;">
			<?php 
				if(isset($txtarea)){
				?>
				<div class="col-xs-12 col-sm-12">
					<textarea style="margin-bottom: 10px;" id="extra_remarks<?php echo $increment_number; ?>" rows="2" cols="5" class="form-control"><?php echo getEditMeasurement($ord_tbl_id,$txtareaid,4); ?></textarea>
				</div>
				<?php
				}
				?>
				<input type="hidden" id="txtareaid<?php echo $increment_number; ?>" value="<?php if(isset($txtareaid)) echo @$txtareaid; else echo 0; ?>" />
		</div>
		</div>
		<?php 
			}else{
				echo 2;
			}
		
	}
	
	if(isset($_REQUEST['get_item_detail_edit_customer'])){
		$master_id=$_REQUEST['master_id'];
		$karigor_id=$_REQUEST['karigor_id'];
		$ord_tbl_id=$_REQUEST['ord_tbl_id'];
		$design_cost=$_REQUEST['design_cost'];
		$amount_cost=$_REQUEST['amount_cost'];
		$item_qty=$_REQUEST['item_qty'];
		$item_type=$_REQUEST['ptye'];
		$item_id=$_REQUEST['item_id'];
		$group_id=$_REQUEST['group_id'];
		$item_name=$_REQUEST['item_name'];
		$orderinfo=$_REQUEST['orderinfo'];
		$com_id=($_SESSION['COM_ID']);
		$item_details=$conn->query("SELECT mh.title,mh.mtype,mh.id,mh.group_id,mh.amount FROM `measurement_head` mh WHERE mh.is_active=1 and mh.ptype=$item_type and mh.group_id=$group_id order by mh.steps asc"); // and mh.com_id=$com_id
			mysqli_close($conn);
			if(mysqli_num_rows($item_details)>0){
			while($rows=mysqli_fetch_array($item_details)){
				if($rows['mtype']==1){
				$txtf[]=$rows['title'];
				$txtfid[]=$rows['id'];
				}
				if($rows['mtype']==2){
				@$txtselect[]=$rows['title'];
				$txtselectid[]=$rows['id'];
				$txtselectgfid[]=$rows['group_id'];
				$txtselectamountid[]=$rows['amount'];
				}
				if($rows['mtype']==3){
				$txtchk[]=$rows['title'];
				$txtchkid[]=$rows['id'];
				$txtchkamountid[]=$rows['amount'];
				}
				if($rows['mtype']==4){
				$txtarea=$rows['title'];
				$txtareaid=$rows['id'];
				}
			}
			$item_rate=getItemPrice($item_id);
			@$group_name=getGoupName($ord_tbl_id);
		?>
		<div style="">
		<div class="row">
		<input type="hidden" id="previous_item_qty" value="<?php echo $item_qty; ?>"/>
		<input type="hidden" id="previous_item_rate" value="<?php echo $item_rate; ?>"/>
		<input type="hidden" id="previous_design_cost" value="<?php echo $design_cost; ?>"/>
		<input type="hidden" id="previous_amount_cost" value="<?php echo $amount_cost; ?>"/>
		<input type="hidden" id="previous_group_name" value="<?php echo $group_name; ?>"/>
		<input type="hidden" id="previous_orderinfo" value="<?php echo $orderinfo; ?>"/>
		<input type="hidden" id="calculate_item_id" value="<?php echo $item_id; ?>"/>
		<input type="hidden" id="item_sl_no" value="<?php echo @$_REQUEST['sl_no']; ?>"/>
		<input type="hidden" id="ord_tbl_id" value="<?php echo $ord_tbl_id; ?>"/>
		<div class="col-xs-12 col-sm-1">
				<label for="comment">Qty:</label>
				<input class="form-control" onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" style="background: #ffc107;font-weight:bold;text-align: center;" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="" type="text" value="<?php echo $item_qty; ?>" id="item_qtye<?php echo $item_id; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Rate:</label>
				<input class="form-control" readonly onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo $item_rate; ?>" id="item_ratee<?php echo $item_id; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Others:</label>
				<input class="form-control" readonly onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo @$design_cost; ?>" id="item_otherse<?php echo $item_id; ?>"/>
				
			</div>
			
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Amount:</label>
				<input class="form-control" readonly autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;color: blue;font-weight: bold;" type="text" value="<?php echo @$amount_cost; ?>" id="item_amounte<?php echo $item_id; ?>"/>
			</div>
			
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Item:</label>
				
				<input class="form-control" readonly type="text" id="item_namee<?php echo $item_id; ?>" value="<?php echo $item_name; ?>"/>
					
				
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 12%;">
				<label for="comment">Master: <span id="pending_mastere<?php echo $item_id; ?>"></span></label>
				<select id="master_ide<?php echo $item_id; ?>"  onchange="getPendingTask('1','master_ide','pending_mastere','<?php echo $item_id; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('1',$master_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 13%;">
				<label for="comment">Karigor: <span id="pending_karigore<?php echo $item_id; ?>"></span></label>
				<select id="karigor_ide<?php echo $item_id; ?>"  onchange="getPendingTask('2','karigor_ide','pending_karigore','<?php echo $item_id; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('2',$karigor_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Group Name:</label>
				
				<input class="form-control" type="text" id="group_namee<?php echo $item_id; ?>" value="<?php echo $group_name; ?>"/>
			</div>
		</div>
		<hr style="border-top: 1px solid #d8c3c3;"> </hr>
		<div class="row" style="display: none;">
			
			
			<?php
				if($group_id==1 && $item_type==1){
			?>
			
				<?php 
				for($i=0;$i<10;$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				
				<?php
				}
				?>
				
				<?php 
				for($i=10;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
				 }else{ 
				for($i=0;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
			} ?>
			<input type="hidden" id="sizetote" value="<?php echo count($txtfid); ?>" />
			
		</div>
		<div class="row" style="overflow:hidden;display: none;">
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
			<table style="width: 100%;">
				<?php 
				if(count($txtselect)>0){
				for($i=0;$i<count($txtselect);$i++){
				?>
				<input type="hidden" id="propertice_titlee<?php echo $i; ?>" value="<?php echo $txtselectid[$i]; ?>" />
				<input type="hidden" id="select_amounte<?php echo $i; ?>" value="<?php echo $txtselectamountid[$i]; ?>" />
				<tr>
					<td>
						<select id="properticee<?php echo $i; ?>" onchange="calculateSelectAmountEdit('<?php echo $item_id; ?>','<?php echo $i; ?>');" class="form-control" style="margin-bottom: 10px;float: left;width: 89% !important;">
							<option value=""><?php echo $txtselect[$i]; ?></option>
							<?php 
								echo getSelectDetail_ShEdit($txtselect[$i],$txtselectgfid[$i],$item_type,$ord_tbl_id); //$item_type
							?>
						</select><span>&nbsp;[<span style="color:blue"><?php echo $txtselectamountid[$i]; ?></span>]</span>
					</td>
				</tr>
				<?php
				}
				}
				?>
			
			<input type="hidden" id="propertice_title_tote" value="<?php echo count($txtselectid); ?>" />
			</table>
			</div>
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
				<?php 
				if(isset($txtchk)){
				for($i=0;$i<count($txtchk);$i++){
				?>
				<div class="col-xs-12 col-sm-12">
				<input type="hidden" id="check_amounte<?php echo $i; ?>" value="<?php echo $txtchkamountid[$i]; ?>" />
				<input style="margin-right: 10px;margin-bottom: 10px;" <?php if(getEditMeasurement($ord_tbl_id,$txtchkid[$i],3)==$txtchkid[$i]) echo "checked"; else echo ""; ?> type="checkbox" onclick="getCheckBoxAmountEdit('<?php echo $item_id; ?>')" class="chkbox" id="exproperticee<?php echo $i; ?>" value="<?php echo $txtchkid[$i]; ?>" /><?php echo $txtchk[$i]; ?>-[<span style="color:blue"><?php echo $txtchkamountid[$i]; ?></span>]
				</div>
				<?php
				}
				}
				?>
				<input type="hidden" id="expropertice_tote" value="<?php echo count(@$txtchkid); ?>" />
			</div>
			
		</div>
		<div class="row" style="overflow:hidden;padding-top: 10px;display: none;">
			<?php 
				if(isset($txtarea)){
				?>
				<div class="col-xs-12 col-sm-12">
					<textarea style="margin-bottom: 10px;" id="extra_remarkse" rows="2" cols="5" class="form-control"><?php echo getEditMeasurement($ord_tbl_id,$txtareaid,4); ?></textarea>
				</div>
				<?php
				}
				?>
				<input type="hidden" id="txtareaide" value="<?php if(isset($txtareaid)) echo @$txtareaid; else echo 0; ?>" />
		</div>
		</div>
		<?php 
			}else{
				echo 2;
			}
		
	}

	
	if(isset($_REQUEST['get_item_detail_edit'])){
		$master_id=$_REQUEST['master_id'];
		$karigor_id=$_REQUEST['karigor_id'];
		$ord_tbl_id=$_REQUEST['ord_tbl_id'];
		$design_cost=$_REQUEST['design_cost'];
		$amount_cost=$_REQUEST['amount_cost'];
		$item_qty=$_REQUEST['item_qty'];
		$item_type=$_REQUEST['ptye'];
		$item_id=$_REQUEST['item_id'];
		$group_id=$_REQUEST['group_id'];
		$item_name=$_REQUEST['item_name'];
		$orderinfo=$_REQUEST['orderinfo'];
		$com_id=($_SESSION['COM_ID']);
		$item_details=$conn->query("SELECT mh.title,mh.mtype,mh.id,mh.group_id,mh.amount FROM `measurement_head` mh WHERE mh.is_active=1 and mh.ptype=$item_type and mh.group_id=$group_id order by mh.steps asc"); // and mh.com_id=$com_id
			mysqli_close($conn);
			if(mysqli_num_rows($item_details)>0){
			while($rows=mysqli_fetch_array($item_details)){
				if($rows['mtype']==1){
				$txtf[]=$rows['title'];
				$txtfid[]=$rows['id'];
				}
				if($rows['mtype']==2){
				@$txtselect[]=$rows['title'];
				$txtselectid[]=$rows['id'];
				$txtselectgfid[]=$rows['group_id'];
				$txtselectamountid[]=$rows['amount'];
				}
				if($rows['mtype']==3){
				$txtchk[]=$rows['title'];
				$txtchkid[]=$rows['id'];
				$txtchkamountid[]=$rows['amount'];
				}
				if($rows['mtype']==4){
				$txtarea=$rows['title'];
				$txtareaid=$rows['id'];
				}
			}
			$item_rate=getItemPrice($item_id);
			@$group_name=getGoupName($ord_tbl_id);
		?>
		<div style="">
		<div class="row">
		<input type="hidden" id="previous_item_qty" value="<?php echo $item_qty; ?>"/>
		<input type="hidden" id="previous_item_rate" value="<?php echo $item_rate; ?>"/>
		<input type="hidden" id="previous_design_cost" value="<?php echo $design_cost; ?>"/>
		<input type="hidden" id="previous_amount_cost" value="<?php echo $amount_cost; ?>"/>
		<input type="hidden" id="previous_group_name" value="<?php echo $group_name; ?>"/>
		<input type="hidden" id="previous_orderinfo" value="<?php echo $orderinfo; ?>"/>
		<input type="hidden" id="calculate_item_id" value="<?php echo $item_id; ?>"/>
		<input type="hidden" id="item_sl_no" value="<?php echo @$_REQUEST['sl_no']; ?>"/>
		<input type="hidden" id="ord_tbl_id" value="<?php echo $ord_tbl_id; ?>"/>
		<div class="col-xs-12 col-sm-1">
				<label for="comment">Qty:</label>
				<input class="form-control" onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" style="background: #ffc107;font-weight:bold;text-align: center;" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="" type="text" value="<?php echo $item_qty; ?>" id="item_qtye<?php echo $item_id; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Rate:</label>
				<input class="form-control" readonly onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo $item_rate; ?>" id="item_ratee<?php echo $item_id; ?>"/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Others:</label>
				<input class="form-control" readonly onkeyup="itemAmountChangeEdit('<?php echo $item_id; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo @$design_cost; ?>" id="item_otherse<?php echo $item_id; ?>"/>
				
			</div>
			
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Amount:</label>
				<input class="form-control" readonly autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;color: blue;font-weight: bold;" type="text" value="<?php echo @$amount_cost; ?>" id="item_amounte<?php echo $item_id; ?>"/>
			</div>
			
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Item:</label>
				
				<input class="form-control" readonly type="text" id="item_namee<?php echo $item_id; ?>" value="<?php echo $item_name; ?>"/>
					
				
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 12%;">
				<label for="comment">Master: <span id="pending_mastere<?php echo $item_id; ?>"></span></label>
				<select id="master_ide<?php echo $item_id; ?>"  onchange="getPendingTask('1','master_ide','pending_mastere','<?php echo $item_id; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('1',$master_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2" style="width: 13%;">
				<label for="comment">Karigor: <span id="pending_karigore<?php echo $item_id; ?>"></span></label>
				<select id="karigor_ide<?php echo $item_id; ?>"  onchange="getPendingTask('2','karigor_ide','pending_karigore','<?php echo $item_id; ?>');" class="form-control">
					<option value="">Select One</option>
						<?php 
							echo getEmpname('2',$karigor_id);
						?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Group Name:</label>
				
				<input class="form-control" type="text" id="group_namee<?php echo $item_id; ?>" value="<?php echo $group_name; ?>"/>
			</div>
		</div>
		<hr style="border-top: 1px solid #d8c3c3;"> </hr>
		<div class="row">
			
			
			<?php
				if($group_id==1 && $item_type==1){
			?>
			
				<?php 
				for($i=0;$i<10;$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				
				<?php
				}
				?>
				
				<?php 
				for($i=10;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
				 }else{ 
				for($i=0;$i<count($txtf);$i++){
				?>
				<div class='col-xs-12 col-sm-2'>
					<p style='font-size: 10px;text-align: center; line-height: 0px;'><?php echo $txtf[$i]; ?></p>
					<p style='font-weight: bold;'>
					<input class="form-control" onkeydown="enterEvent('sizee','<?php echo $i; ?>')" autocomplete="off" style="text-align: center;" value="<?php echo getEditMeasurement($ord_tbl_id,$txtfid[$i],1); ?>" type="text" id="sizee<?php echo $i; ?>"/>
					<input type="hidden" id="sizetxte<?php echo $i; ?>" value="<?php echo $txtfid[$i]; ?>" />
					</p>
				</div>
				<?php
				}
			} ?>
			<input type="hidden" id="sizetote" value="<?php echo count($txtfid); ?>" />
			
		</div>
		<div class="row" style="overflow:hidden">
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
			<table style="width: 100%;">
				<?php 
				if(count($txtselect)>0){
				for($i=0;$i<count($txtselect);$i++){
				?>
				<input type="hidden" id="propertice_titlee<?php echo $i; ?>" value="<?php echo $txtselectid[$i]; ?>" />
				<input type="hidden" id="select_amounte<?php echo $i; ?>" value="<?php echo $txtselectamountid[$i]; ?>" />
				<tr>
					<td>
						<select id="properticee<?php echo $i; ?>" onchange="calculateSelectAmountEdit('<?php echo $item_id; ?>','<?php echo $i; ?>');" class="form-control" style="margin-bottom: 10px;float: left;width: 89% !important;">
							<option value=""><?php echo $txtselect[$i]; ?></option>
							<?php 
								echo getSelectDetail_ShEdit($txtselect[$i],$txtselectgfid[$i],$item_type,$ord_tbl_id); //$item_type
							?>
						</select><span>&nbsp;[<span style="color:blue"><?php echo $txtselectamountid[$i]; ?></span>]</span>
					</td>
				</tr>
				<?php
				}
				}
				?>
			
			<input type="hidden" id="propertice_title_tote" value="<?php echo count($txtselectid); ?>" />
			</table>
			</div>
			<div class="col-xs-12 col-sm-4" style="margin-top:6px;">
				<?php 
				if(isset($txtchk)){
				for($i=0;$i<count($txtchk);$i++){
				?>
				<div class="col-xs-12 col-sm-12">
				<input type="hidden" id="check_amounte<?php echo $i; ?>" value="<?php echo $txtchkamountid[$i]; ?>" />
				<input style="margin-right: 10px;margin-bottom: 10px;" <?php if(getEditMeasurement($ord_tbl_id,$txtchkid[$i],3)==$txtchkid[$i]) echo "checked"; else echo ""; ?> type="checkbox" onclick="getCheckBoxAmountEdit('<?php echo $item_id; ?>')" class="chkbox" id="exproperticee<?php echo $i; ?>" value="<?php echo $txtchkid[$i]; ?>" /><?php echo $txtchk[$i]; ?>-[<span style="color:blue"><?php echo $txtchkamountid[$i]; ?></span>]
				</div>
				<?php
				}
				}
				?>
				<input type="hidden" id="expropertice_tote" value="<?php echo count(@$txtchkid); ?>" />
			</div>
			
		</div>
		<div class="row" style="overflow:hidden;padding-top: 10px;">
			<?php 
				if(isset($txtarea)){
				?>
				<div class="col-xs-12 col-sm-12">
					<textarea style="margin-bottom: 10px;" id="extra_remarkse" rows="2" cols="5" class="form-control"><?php echo getEditMeasurement($ord_tbl_id,$txtareaid,4); ?></textarea>
				</div>
				<?php
				}
				?>
				<input type="hidden" id="txtareaide" value="<?php if(isset($txtareaid)) echo @$txtareaid; else echo 0; ?>" />
		</div>
		</div>
		<?php 
			}else{
				echo 2;
			}
		
	}
	
	
	if(isset($_REQUEST['get_order_details'])){
		$com_id=($_SESSION['COM_ID']);
		$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
		(select artisan_price from product where id=ord.item_id) karigor_price,
		(select product_name from product where id=ord.item_id) product,
		ord.order_number,ord.master_id,ord.group_id,(select user_name from user where id=ord.insert_by) insert_by,
		(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
		FROM `order_record` ord WHERE ord.com_id=$com_id and ord.is_active=0");
			$c=0;$j=0;@$cus_price=0;
			if(mysqli_num_rows($order_details)>0){
			echo '<div id="print_main_body">';
			while($rows=mysqli_fetch_array($order_details)){
				$j=$c++;
				$cus_price+=(intval($rows['item_qty'])*intval($rows['item_price']));
				if($_SESSION['MEASURE_TYPE']==0){
				?>
				<button onclick="delOrderFnc('<?php echo $rows['id']; ?>',<?php echo $j; ?>);" style="margin: 12px;" name="btn" value="sub" id="delOrder<?php echo $j; ?>" class="btn btn-danger">Delete</button>
				
				<div style="border: 1px solid gray;padding-left:5px;padding-right: 5px;padding-top:3px;margin-bottom: 12px;width:604px;height:349px;display: block; page-break-before: always;">
					<div style="border-bottom: 1px solid gray;overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;">অর্ডার নম্বর- <b><span id="ord_one<?php echo $j; ?>"></span></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <?php echo $rows['masters']; ?></p>
							<p style="width: 259px;font-size: 12px;">কারিগর- <?php echo $rows['karigor']; ?></p>
							<input type="hidden" value="<?php echo $rows['product']; ?>" id="item<?php echo $j; ?>"/>
							<input type="hidden" value="<?php echo $rows['item_qty']; ?>" id="item_qty<?php echo $j; ?>"/>
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 12px;">অর্ডার তা.- <span id="ord_date<?php echo $j; ?>"></span></p>
							<p style="font-size: 12px;">ডেলিভারি তা.- <span id="del_date<?php echo $j; ?>"></span></p>
							<p style="font-size: 11px;">আইটেম- <?php echo $rows['product']."-".$rows['item_qty']." পিছ"; ?></p>
						</div>
					</div>
					
					
					
					<div style="height: 225px;border-bottom: 1px solid gray;">
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 14px;">
							<?php echo getMeasurement($rows['id'],1); //1=measurement ?>
						
						</div>
					<div class="row" style="overflow:hidden;">
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
							<?php 
							echo getMeasurement($rows['id'],2); // selected data
							?>
							
						</div>
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
							<?php 
							echo getMeasurement($rows['id'],3); // checkbox data
							?>
						</div>
						<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float: left; !important">
							<?php
							if($rows['ptype']==1){ //For Gents
							if($_SESSION['SHOW_DESIGN']==1){
								if($rows['product']=="Shirt"){
									?>
										<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
									<?php 
									}else if($rows['product']=="Fatua"){
										?>
										<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
										<?php 
									}else if($rows['product']=="Pant"){
										?>
										<img src="img/3.png" style="width: 100px;height: 110px;"/>
										<?php 
									}else if($rows['product']=="Panjabi"){
										?>
										<img src="img/4.png" style="width: 128px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Mujib Coat"){
										?>
										<img src="img/5.png" style="width:110px;height: 136px;"/>
										<?php 
									}else if($rows['product']=="Coat"){
										?>
										<img src="img/6.png" style="width: 130px;height: 125px;"/>
										<?php 
									}else if($rows['product']=="Jubbah"){
										?>
										<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
										<?php 
									}else if($rows['product']=="Sherwani"){
										?>
										<img src="img/8.png" style="width: 120px;height: 135px;"/>
										<?php 
									}else if($rows['product']=="Prince Coat"){
										?>
										<img src="img/9.png" style="width: 105px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Waistcoat"){
										?>
										<img src="img/10.png" style="width:85px"/>
										<?php 
									}else if($rows['product']=="Kabli"){
										?>
										<img src="img/11.png" style="width: 115px;height:120px;"/>
										<?php 
									}else if($rows['product']=="Pajama"){
										?>
										<img src="img/12.png" style="width:92px;height: 120px;"/>
										<?php 
									}
							}
							}else{
								
							}
							?>
						</div>
					</div>
					<div class="row" style="overflow:hidden;padding-top: 10px;padding-left:15px">
						<?php 
							echo getMeasurement($rows['id'],4); // Txtarea data
						?>
					</div>
				</div>
					
					<div class="row" style="line-height: 11px; margin-top: 12px;margin-bottom: 5px;">
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;">অর্ডার নম্বর- <b><span id="ord_two<?php echo $j; ?>"></span></b></p>
						<p style="width: 259px;font-size: 12px;">টাকা- <span id="taka<?php echo $j; ?>"><?php echo @$rows['karigor_price']; ?>/=</span></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;">আইটেম- <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;">সংখ্যা- <?php echo $rows['item_qty']."  পিছ"; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigors<?php echo $j; ?>"><?php echo $rows['karigor']; ?></span></p>
						<p style="width: 259px;font-size: 12px;">মাস্টার- <span id="masters<?php echo $j; ?>"><?php echo $rows['masters']; ?></span></p>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;">অর্ডার তা.-  <span id="ord_date2<?php echo $j; ?>"></span></p>
						<p style="font-size: 12px;">ডেলিভারি তা.- <span  id="del_date2<?php echo $j; ?>"></span></p>
						</div>
						
					</div>
				</div>
			
				<?php 
			}else{
				
				?>
				<button onclick="delOrderFnc('<?php echo $rows['id']; ?>',<?php echo $j; ?>);" style="margin: 12px;" name="btn" value="sub" id="delOrder<?php echo $j; ?>" class="btn btn-danger">Delete</button>
				<div style="margin-left:50px;margin-top: -5px;padding-left:30px;padding-right: 15px;margin-bottom: 12px;width:604px;height:684px;display: block; page-break-before: always;">
					<div style="overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;"> <b><span id="ord_one<?php echo $j; ?>"></span></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <?php echo $rows['masters']; ?></p>
							<input type="hidden" value="<?php echo $rows['product']; ?>" id="item<?php echo $j; ?>"/>
							<input type="hidden" value="<?php echo $rows['item_qty']; ?>" id="item_qty<?php echo $j; ?>"/>
							
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy"; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 12px;"> <span id="del_date<?php echo $j; ?>"></span></p>
							<p style="font-size: 11px;"> <?php echo $rows['product']."-".$rows['item_qty'].""; ?></p>
						</div>
					</div>
					
					
					
					<div style="height:385px;padding-left: 40px;">
						<span style="float: left;font-size: 11px;font-style: italic;">Received By- <?php echo $rows['insert_by']; ?></span>
						<span style="float: right;font-size: 11px;font-style: italic;">EasyTech24</span>
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 60px;width: 555px;">
							<?php echo getMeasurement($rows['id'],1); //1=measurement ?>
						
						</div>
					<div class="row" style="overflow:hidden;">
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
							<?php 
							echo getMeasurement($rows['id'],2); // selected data
							?>
							
						</div>
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
							<?php 
							echo getMeasurement($rows['id'],3); // checkbox data
							?>
						</div>
						<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float: left; !important">
							<?php
							if($rows['ptype']==1){ //For Gents
							if($_SESSION['SHOW_DESIGN']==1){
								if($rows['product']=="Shirt"){
									?>
										<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
									<?php 
									}else if($rows['product']=="Fatua"){
										?>
										<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
										<?php 
									}else if($rows['product']=="Pant"){
										?>
										<img src="img/3.png" style="width: 100px;height: 110px;"/>
										<?php 
									}else if($rows['product']=="Panjabi"){
										?>
										<img src="img/4.png" style="width: 128px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Mujib Coat"){
										?>
										<img src="img/5.png" style="width:110px;height: 136px;"/>
										<?php 
									}else if($rows['product']=="Coat"){
										?>
										<img src="img/6.png" style="width: 130px;height: 125px;"/>
										<?php 
									}else if($rows['product']=="Jubbah"){
										?>
										<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
										<?php 
									}else if($rows['product']=="Sherwani"){
										?>
										<img src="img/8.png" style="width: 120px;height: 135px;"/>
										<?php 
									}else if($rows['product']=="Prince Coat"){
										?>
										<img src="img/9.png" style="width: 105px;height: 130px;"/>
										<?php 
									}else if($rows['product']=="Waistcoat"){
										?>
										<img src="img/10.png" style="width:85px"/>
										<?php 
									}else if($rows['product']=="Kabli"){
										?>
										<img src="img/11.png" style="width: 115px;height:120px;"/>
										<?php 
									}else if($rows['product']=="Pajama"){
										?>
										<img src="img/12.png" style="width:92px;height: 120px;"/>
										<?php 
									}
								}
							}else{
								
							}
							?>
						</div>
					</div>
					<div class="row" style="overflow:hidden;padding-top: 10px;">
						<?php 
							echo getMeasurement($rows['id'],4); // Txtarea data
						?>
					</div>
				</div>
					
					<span style="float: right;font-size: 15px;font-weight: bold;padding-top: 25px;">Job Slip</span>
					<div class="row" style="line-height: 11px; margin-top:50px;margin-bottom: 5px;">
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;"> <b><span id="ord_two<?php echo $j; ?>"></span></b></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"> <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;"> <?php echo $rows['item_qty']." "; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigors<?php echo $j; ?>"><?php echo $rows['karigor']; ?></span></p>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"> <span  id="del_date2<?php echo $j; ?>"></span></p>
						</div>
						
					</div>
				</div>
				<?php 
				}
			}
			echo "</div><input type='hidden' value='$c' id='last_ids'/>";
			echo "<input type='hidden' value='$cus_price' id='tot_cus_price'/>";
			}else{
				echo 2;
			}
	}
	
	if(isset($_REQUEST['del_get_order_details'])){
		$com_id=($_SESSION['COM_ID']);
		$date=date("Y-m-d");
		
		$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
		(select artisan_price from product where id=ord.item_id) karigor_price,
		(select product_name from product where id=ord.item_id) product,
		ord.order_number,ord.master_id,ord.group_id,
		(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
		FROM `order_record` ord WHERE ord.com_id=$com_id and ord.is_active=2 and date(insert_date)='$date' order by ord.id desc");
			$c=0;$j=0;@$cus_price=0;
			echo '<div id="print_main_body_del">';
			if(mysqli_num_rows($order_details)>0){
			while($rows=mysqli_fetch_array($order_details)){
				$j=$c++;
				$cus_price+=(intval($rows['item_qty'])*intval($rows['item_price']));
				?>
				<button onclick="activeOrderFnc('<?php echo $rows['id']; ?>',<?php echo $j; ?>);" style="margin: 12px;" name="btn" value="sub" id="actOrder<?php echo $j; ?>" class="btn btn-info">Active</button>
				<div style="border: 1px solid gray;padding-left:5px;padding-right: 5px;padding-top:5px;margin-bottom: 12px;width:604px;height:716px;display: block; page-break-before: always;">
					<div style="border-bottom: 1px solid gray;overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;">অর্ডার নম্বর- <b><?php //echo $rows['order_number']; ?></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <?php echo $rows['masters']; ?></p>
							<p style="width: 259px;font-size: 12px;">কারিগর- <?php echo $rows['karigor']; ?></p>
							<input type="hidden" value="<?php echo $rows['product']; ?>" id="item<?php echo $j; ?>"/>
							<input type="hidden" value="<?php echo $rows['item_qty']; ?>" id="item_qty<?php echo $j; ?>"/>
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 12px;">অর্ডার তা.- <span id="ord_date<?php echo $j; ?>"></span></p>
							<p style="font-size: 12px;">ডেলিভারি তা.- <span id="del_date<?php echo $j; ?>"></span></p>
							<p style="font-size: 11px;">আইটেম- <?php echo $rows['product']."-".$rows['item_qty']." পিছ"; ?></p>
						</div>
					</div>
					
					
					
					<div style="height: 400px;border-bottom: 1px solid gray;">
						<span style="float: right;font-size: 11px;font-style: italic;">EasyTech24</span>
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 14px;">
							<?php echo getMeasurementDel($rows['id'],1); //1=measurement ?>
						
						</div>
					<div class="row" style="overflow:hidden;">
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
							<?php 
							echo getMeasurementDel($rows['id'],2); // selected data
							?>
							
						</div>
						<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
							<?php 
							echo getMeasurementDel($rows['id'],3); // checkbox data
							?>
						</div>
						<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float: left; !important">
							<?php
							if($rows['ptype']==1){ //For Gents
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									}
							}else{
								
							}
							?>
						</div>
					</div>
					<div class="row" style="overflow:hidden;padding-top: 10px;padding-left: 15px;">
						<?php 
							echo getMeasurementDel($rows['id'],4); // Txtarea data
						?>
					</div>
				</div>
					
					<span style="float: right;font-size: 15px;font-weight: bold;padding-top: 3px;">Job Slip</span>
					<div class="row" style="line-height: 11px; margin-top: 25px;margin-bottom: 5px;">
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;">অর্ডার নম্বর- <b><?php echo $rows['order_number']; ?></b></p>
						<p style="width: 259px;font-size: 12px;">টাকা- <span id="taka<?php echo $j; ?>"><?php echo @$rows['karigor_price']; ?>/=</span></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;">আইটেম- <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;">সংখ্যা- <?php echo $rows['item_qty']."  পিছ"; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigors<?php echo $j; ?>"><?php echo $rows['karigor']; ?></span></p>
						<p style="width: 259px;font-size: 12px;">মাস্টার- <span id="masters<?php echo $j; ?>"><?php echo $rows['masters']; ?></span></p>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;">অর্ডার তা.-  <span id="ord_date2<?php echo $j; ?>"></span></p>
						<p style="font-size: 12px;">ডেলিভারি তা.- <span  id="del_date2<?php echo $j; ?>"></span></p>
						</div>
						
					</div>
				</div>
			
				<?php 
			}
			}
			
	}
	
	if(isset($_REQUEST['showMasterMemo'])){
		$com_id=($_SESSION['COM_ID']);
		$memo_id=$_REQUEST['memo_id'];
		$emp_type=($_REQUEST['emp_type']==1)? 'মাস্টার' : 'কারিগর';
		$emp_name=$_REQUEST['emp_name'];
		$mdate=$_REQUEST['mdate'];
		
		$memo_details=$conn->query("SELECT ds.*,(select product_name from product where id=ds.item_ids) item_name FROM `wages_details` ds WHERE ds.`is_active`=1 and ds.`memo_id`=$memo_id");
		
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($memo_details)>0){
								?>
								<label>Memo No: <?php echo $memo_id; ?> <br/> <span style="color:blue"><?php echo $emp_type.': '.$emp_name; ?></span> <br/> তারিখ: <?php echo $mdate; ?></label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:15%;text-align:center">Order</th>
											<th style="width:55%;">Item</th>
											<th style="width:15%;text-align:center">Qty</th>
											<th style="width:20%;text-align:right">Taka/=</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($memo_details)){
													$c=$sl++;
													$tot_qty+=$rows['taka'];
													?>
													<tr>
														<td style="text-align: center;"><?php echo $c; ?></td>
														<td style="text-align:center">
															<?php echo $rows['order_num']; ?>
														</td>
														<td>
															<?php echo $rows['item_name']; ?>
														</td>
														<td style="text-align:center">
															<?php echo $rows['item_qty']; ?>
														</td>
														<td style="text-align: right;"><?php echo $rows['taka']; ?>/=</td>
													</tr>
													<?php 
												}
										?>
										<tr>
											<td colspan="4" style="text-align: right;font-weight:bold">Total</td>
											<td style="text-align: right;font-weight:bold"><?php echo $tot_qty; ?>/=</td>
										</tr>
									</tbody>
									
								</table>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					</div>
							
					</div>
					<?php 
	}
	
	if(isset($_REQUEST['showKarigorDayWiseLaser'])){
		
		$com_id=($_SESSION['COM_ID']);
		$emp_id=$_REQUEST['emp_id'];
		$start_date=$_REQUEST['start_date'];
		$end_date=$_REQUEST['end_date'];
		$emp_type=($_REQUEST['emp_type']==1)? 'মাস্টার' : 'কারিগর';
		$emp_types=$_REQUEST['emp_type'];
		$emp_name=$_REQUEST['emp_name'];
		$emp_mobile=$_REQUEST['emp_mobile'];
		//$mdate=$_REQUEST['mdate'];
		
		$mstart_dates=explode("-",$start_date);
		$mend_dates=explode("-",$end_date);
		@$mstart_date=$mstart_dates[2].'/'.$mstart_dates[1].'/'.$mstart_dates[0];
		@$mend_date=$mend_dates[2].'/'.$mend_dates[1].'/'.$mend_dates[0];
		
		$memo_details=$conn->query("SELECT sum(`taka`) taka,sum(`item_qty`) item_qty,(select product_name from product where id=wages_details.item_ids limit 0,1) item_name,GROUP_CONCAT(`order_num`) order_num FROM `wages_details` WHERE `is_active`=1 and `status`=0 and `emp_type`=$emp_types and date(insert_date) between '$start_date' and '$end_date' and emp_id=$emp_id GROUP by wages_details.`item_ids`");
		
				?>
					<div style="background:white">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($memo_details)>0){
								?>
								<div class="panel-body">
			
							<div class="row">
							<button onclick="printOrder('summery_report2');" style="margin-right:15px" name="btn" id="printBtns" value="sub" class="btn btn-info">Print</button>
							<button onclick="showKarigorDayWise('<?php echo $emp_types; ?>','<?php echo $emp_id; ?>','<?php echo $emp_mobile; ?>','<?php echo $emp_name; ?>','<?php echo $start_date; ?>','<?php echo $end_date; ?>');" style="margin-right:15px" name="btn" id="printBtns" value="sub" class="btn btn-success">POS Printer</button>
								<span id="summery_report2">
								<div id='print_area' style='overflow:hidden;margin-top:5px;margin-bottom: 6px; width:100%;display: block; page-break-before: always;'>
									<div style='overflow:hidden;padding-top:25px;'>	
										<div style='line-height: 5px;padding-top:15px;text-align:center;'>	
											<p style='font-size: 16px;font-weight: bold;padding-top:0px;'><?php echo $_SESSION['COM']; ?></p>
											<p style='font-size: 13px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_ADDRESS']; ?></p>
											<p style='font-size: 12px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['EMAIL']; ?></p>
											<p style='font-size: 12px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_MOBILE']; ?></p>
										</div>
										
									</div>
									
									<div style='overflow:hidden;margin-top: 20px;'>	
										<div style='float:left; padding-left: 6px;'>	
											<p style='font-size: 12px;'><b>Date:</b> <?php echo $mstart_date.' to '.$mend_date; ?></span>
										</div>
										<div style='float:right; padding-right: 6px;'>	
											<p style='font-size: 10px;'><?php //echo $dates; ?></p>
										</div>
									</div>
									<div style='overflow:hidden;margin-top: 0px;'>	
										<div style='float:left; padding-left: 6px;width: 50%;'>	
											<p style='font-size: 12px;'><b><?php echo $emp_type; ?>:</b> <?php echo $emp_name; ?></span>
										</div>
										<div style='float:left; padding-right: 6px;width:50%;text-align:right;'>	
											<p style='font-size: 12px;'><?php echo $emp_mobile; ?></p>
										</div>
									</div>
									<div style='overflow:hidden;margin-top: -3px;margin-left: 6px;
											margin-right: 6px;'>	
									
									<table style="width:100%" border="1">
										<tr>
											<td style="text-align:center">Sl</td>
											<td>Item</td>
											<td>Order</td>
											<td style="text-align:center">Qty</td>
											<td style="text-align:right">Taka</td>
										</tr>
										<?php 
										$sl=1;$tot_qty=0;$tot_taka=0;
										while($rows=mysqli_fetch_array($memo_details)){
												$c=$sl++;
												$tot_taka+=$rows['taka'];
												$tot_qty+=$rows['item_qty'];
												$ord=explode(',',$rows['order_num']);
												$onum=implode(' ',$ord);
												?>
											<tr>
												<td style="text-align:center"><?php echo $c; ?></td>
												<td><?php echo $rows['item_name']; ?></td>
												<td><?php echo $onum; ?></td>
												<td style="text-align:center"><?php echo $rows['item_qty']; ?></td>
												<td style="text-align:right"><?php echo $rows['taka']; ?>/=</td>
											</tr>
											
										<?php 
											}
										?>
										<tr>
											<td colspan="3" style="text-align:right;font-weight:bold">Total Qty|Taka: </td>
											<td style="text-align:center;font-weight:bold"><?php echo $tot_qty; ?></td>
											<td style="text-align:right;font-weight:bold"><?php echo $tot_taka; ?>/=</td>
										</tr>
									</table>
									
									</div>
									<div style="overflow:hidden">
										<div style='padding-top: 15px;float: left;padding-left: 6px;'>	
												Print By: <?php echo $_SESSION['USER']; ?>
										</div>
										<div style='padding-top: 15px;text-align: right;padding-right: 7px;'>	
												Print Date: <?php echo date('d/m/Y'); ?>
										</div>
									</div>
									<div style='width: 100%;text-align: center;padding-top: 25px;padding-bottom: 50px;'>	
											*** Thank You ***
									</div>
									
								</div>
							</span>
							</div>
					 </div>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					
							
					</div>
					<?php 
	}
	
	if(isset($_REQUEST['showMasterDayWise'])){
		
		$com_id=($_SESSION['COM_ID']);
		$emp_id=$_REQUEST['emp_id'];
		$start_date=$_REQUEST['start_date'];
		$end_date=$_REQUEST['end_date'];
		$emp_type=($_REQUEST['emp_type']==1)? 'মাস্টার' : 'কারিগর';
		$emp_types=$_REQUEST['emp_type'];
		$emp_name=$_REQUEST['emp_name'];
		$emp_mobile=$_REQUEST['emp_mobile'];
		//$mdate=$_REQUEST['mdate'];
		
		$mstart_dates=explode("-",$start_date);
		$mend_dates=explode("-",$end_date);
		@$mstart_date=$mstart_dates[2].'/'.$mstart_dates[1].'/'.$mstart_dates[0];
		@$mend_date=$mend_dates[2].'/'.$mend_dates[1].'/'.$mend_dates[0];
		
		$memo_details=$conn->query("SELECT sum(`taka`) taka,sum(`item_qty`) item_qty,(select product_name from product where id=wages_details.item_ids limit 0,1) item_name,GROUP_CONCAT(`order_num`) order_num FROM `wages_details` WHERE `is_active`=1 and `status`=0 and `emp_type`=$emp_types and date(insert_date) between '$start_date' and '$end_date' and emp_id=$emp_id GROUP by wages_details.`item_ids`");
		
				?>
					<div style="background:white">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($memo_details)>0){
								?>
								<div class="panel-body">
			
							<div class="row">
							<button onclick="printOrder('summery_report2');" style="margin-right:15px" name="btn" id="printBtns" value="sub" class="btn btn-info">Print</button>
							<button onclick="showKarigorDayWiseLaser('<?php echo $emp_types; ?>','<?php echo $emp_id; ?>','<?php echo $emp_mobile; ?>','<?php echo $emp_name; ?>','<?php echo $start_date; ?>','<?php echo $end_date; ?>');" style="margin-right:15px" name="btn" value="sub" class="btn btn-success">Laser Printer</button>
								
								<span id="summery_report2">
								<div id='print_area' style='overflow:hidden;margin-top:5px;margin-bottom: 6px; width:336px;display: block; page-break-before: always;'>
									<div style='overflow:hidden;padding-top:25px;'>	
										<div style='line-height: 5px;padding-top:17px;text-align:center;'>	
											<p style='font-size: 16px;font-weight: bold;padding-top:0px;'><?php echo $_SESSION['COM']; ?></p>
											<p style='font-size: 15px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_ADDRESS']; ?></p>
											<p style='font-size: 15px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['EMAIL']; ?></p>
											<p style='font-size: 16px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_MOBILE']; ?></p>
										</div>
										
									</div>
									
									<div style='overflow:hidden;margin-top: 20px;'>	
										<div style='float:left; padding-left: 6px;'>	
											<p style='font-size: 14px;'><b>Date: <?php echo $mstart_date.' to '.$mend_date; ?></b></span>
										</div>
										<div style='float:right; padding-right: 6px;'>	
											<p style='font-size: 14px;'></p>
										</div>
									</div>
									<div style='overflow:hidden;margin-top: 0px;'>	
										<div style='float:left; padding-left: 6px;width: 50%;'>	
											<p style='font-size: 14px;'><b><?php echo $emp_type; ?>: <?php echo $emp_name; ?></b></span>
										</div>
										<div style='float:left; padding-right: 6px;width:50%;text-align:right;font-weight:bold'>	
											<p style='font-size: 14px;'><?php echo $emp_mobile; ?></p>
										</div>
									</div>
									<div style='overflow:hidden;margin-top: -3px;margin-left: 6px;
											margin-right: 6px;'>	
									<div style='width: 100%;margin-bottom: -6px;'>	
											---------------------------------------------------------------------
									</div>
										<div style='overflow:hidden;font-size: 15px;
											font-weight: bold;text-align:center;margin-bottom: -7px;'>	
											<div style='float:left;width: 7%;'>	
												Sl
											</div>
											<div style='float:left;width:20%;text-align:left'>	
												Order
											</div>
											<div style='float:left;width: 33%;text-align:left'>	
												Item
											</div>
											<div style='float:left;width: 20%;text-align: center;'>	
												Qty
											</div>
											<div style='float:left;width: 20%;text-align: right;padding-right: 5px;'>	
												Taka
											</div>
										</div>
									<div style='width: 100%;margin-bottom: -6px;'>	
											---------------------------------------------------------------------
									</div>
									<div style=''>
										<div style='overflow:hidden;font-size: 14px;
											font-weight:bold;text-align:center;'>	
											<?php 
												$sl=1;$tot_qty=0;$tot_taka=0;
												while($rows=mysqli_fetch_array($memo_details)){
														$c=$sl++;
														$tot_taka+=$rows['taka'];
														$tot_qty+=$rows['item_qty'];
														$ord=explode(',',$rows['order_num']);
														$onum=implode(' ',$ord);
														?>
														<div style="overflow:hidden;margin-bottom: 8px;border-bottom: 1px dotted gray;">
															<div style='float:left;width: 7%;'>	
																<?php echo $c; ?>
															</div>
															<div style='float:left;width: 20%;text-align:left;font-size:14px'>	
																<?php echo $onum; ?>
															</div>
															<div style='float:left;width: 33%;text-align:left'>	
																<?php echo $rows['item_name']; ?>
															</div>
															<div style='float:left;width: 20%;text-align: center;'>	
																<?php echo $rows['item_qty']; ?>
															</div>
															<div style='float:left;width: 20%;text-align: right;padding-right: 5px;'>	
																<?php echo $rows['taka']; ?>/=
															</div>
														</div>
														
														<?php 
													}
											?>
										</div>
									</div>
									<div style='width: 100%;margin-bottom: -6px;'>	
											---------------------------------------------------------------------
									</div>
										<div style='overflow:hidden;font-size: 14px;
											font-weight: bold;text-align:center;padding-bottom: 3px;'>	
											<div style='float: left;text-align: right;width: 198px;'>	
												Total Qty|Taka: 
											</div>
											<div style='float: left;text-align: right;width: 52px;'>	
												<?php echo $tot_qty; ?>
											</div>
											<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
												<?php echo $tot_taka; ?>/=
											</div>
											
										</div>
										
									<div style='width: 100%;'>	
											---------------------------------------------------------------------
									</div>
									
									</div>
									<div style='width: 100%;text-align: center;padding-top: 15px;padding-bottom: 8px;font-size:16px;font-weight:bold'>	
											Print By: <?php echo $_SESSION['USER']; ?>
									</div>
									<div style='width: 100%;text-align: center;padding-top: 15px;padding-bottom: 15px;font-size:16px;font-weight:bold'>	
											Print Date: <?php echo date('d/m/Y'); ?>
									</div>
									<div style='width: 100%;text-align: center;padding-top: 10px;padding-bottom: 50px;font-size:16px;font-weight:bold'>	
											*** Thank You ***
									</div>
									
								</div>
							</span>
							</div>
					 </div>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					
							
					</div>
					<?php 
	}
	
	if(isset($_REQUEST['dateWisePrint'])){
		$com_id=($_SESSION['COM_ID']);
		$print_type=trim($_REQUEST['print_type']);
		@$mobile=trim($_REQUEST['mobile']);
		@$order_number=trim($_REQUEST['order_number']);
		if($_REQUEST['date1']!=""){
			$date1=trim($_REQUEST['date1']);
			$ex=explode("/",$date1);
			$date1=$ex[2]."-".$ex[1]."-".$ex[0];
		}
		if($print_type==2){
			if($_SESSION['MEASURE_TYPE']==0){ //stardard
				//echo printMoneyReceipt2($order_number);
				echo printMoneyReceipt2ForPos($order_number);
			}else{ //local copy and normal copy
				if($_REQUEST['date1']!=""){
			
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
				(select artisan_price from product where id=ord.item_id) karigor_price,
				(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
				ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
				(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
				FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and date(ds.insert_date)='$date1' and ord.is_active=1");
				}
				
				if($_REQUEST['mobile']!=""){
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.cus_mobile='$mobile' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
				
				if(@$_REQUEST['serial_no']!=""){
					$serial_no=trim($_REQUEST['serial_no']);
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.phy_ord_num='$serial_no' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
		
				if($_REQUEST['order_number']!=""){
					
					$order_number=explode(",",$_REQUEST['order_number']);
					for($i=0;$i<count($order_number);$i++){
						@$all_ord.="'".$order_number[$i]."',";
					}
					@$all_ord=substr($all_ord,0,-1);
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
					(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
					FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ord.order_number in($all_ord) and ord.is_active=1");
				}
		
		mysqli_close($conn);
		if(mysqli_num_rows($order_details)>0){
			$c=0;$j=0;@$cus_price=0;
			$dday=$_SESSION['FAC_DELIVERY'];
			while($rows=mysqli_fetch_array($order_details)){
				$j=$c++;
				@$karigor_dv_date =date('Y-m-d', strtotime($rows['dv_date']. " - $dday days"));
				if($_SESSION['MEASURE_TYPE']==2){ //border: 1px solid gray;
				?>
				<div id="main_body" style="margin-left: 160px;padding-left:5px;padding-right: 5px;padding-top:3px;margin-bottom: 12px;width:395px;height:550px;display: block; page-break-before: always;">
					<div style="border-bottom: 1px solid gray;overflow:hidden">
						
						<div style="text-align: center;line-height: 9px; margin-top: 8px;">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						
					</div>
					
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>SL: <?php echo $rows['order_number']; ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b><?php echo $rows['product']."-".$rows['item_qty']." পিছ"; ?></b></p>
						</div>
					</div>
					
					<div style="height: 400px;border-bottom: 1px solid gray;">
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 14px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2)." ".getMeasurement2($rows['id'],3)." ".getMeasurement2($rows['id'],4); // selected data
								?>
								
							</div>
							
							<div class="" style="margin-top:-10px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									}else{
										
									}
								}
								?>
							</div>
						</div>
						
					</div>
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>অর্ডার তা.-  <span><?php echo date('d/m/Y',strtotime($rows['insert_date'])); ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b>ডেলিভারি তা.- <span><?php echo (@$rows['fddate']=="")? date('d/m/Y',strtotime($karigor_dv_date)) : $rows['fddate']." ".$rows['fdtime']; ?></b></p>
						</div>
					</div>
				
				</div>
				<?php 
				}else if($_SESSION['MEASURE_TYPE']==1){ //Normal Copy
					?>
					<div id="main_body" style="margin-left:50px;margin-top: 0px;padding-left:30px;padding-right: 15px;padding-top:5px;margin-bottom: 12px;width:604px;height:684px;display: block; page-break-before: always;">
					<div style="overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <span id="master<?php echo $j; ?>" onclick="setEmployee2(<?php echo $j; ?>);"><?php if($rows['masters']=="") echo "---"; else echo $rows['masters']; ?></span><span id="master_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['master_id']."#sep#1#sep#".$rows['id']; ?>" id="master_hidden_id<?php echo $j; ?>"/>
							
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 11px;"> <span id="del_date<?php echo $j; ?>"><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></span></p>
							<p style="font-size: 11px;"><?php echo $rows['product']."-".$rows['item_qty'].""; ?></p>
						</div>
					</div>
					
					<div style="height:385px;padding-left: 40px;">
						<span style="float: left;font-size: 11px;font-style: italic;">Received By- <?php echo $rows['insert_by']; ?></span>
						<span style="float: right;font-size: 11px;font-style: italic;">Atompac Limited</span>
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 60px;width: 555px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2); // selected data
								?>
								
							</div>
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],3); // checkbox data
								?>
							</div>
							<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									
									}else{
										
									}
								}
								?>
							</div>
						</div>
						<div class="row" style="overflow:hidden;padding-top: 10px;padding-left: 15px;">
						<?php 
							echo getMeasurement2($rows['id'],4); // Txtarea data
						?>
						</div>
					</div>
					<span style="float: right;font-size: 15px;font-weight: bold;padding-top: 25px;">Job Slip</span>
					<div class="row" style="line-height: 11px; margin-top: 50px;margin-bottom: 5px;">
					
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"> <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;">Qty- <?php echo $rows['item_qty']." "; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigor<?php echo $j; ?>" onclick="setEmployee(<?php echo $j; ?>)"><?php if($rows['karigor']=="") echo "---"; else echo $rows['karigor']; ?></span><span id="karigor_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"><span  id="del_date2<?php echo $j; ?>"><b><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></b></span></p>
						</div>
						
					</div>
				</div>
				<?php
				}				
			}
			}else{
				echo 2;
			}
				
			}
		}else if($print_type==20){
			if($_SESSION['MEASURE_TYPE']==0){ //stardard
				echo printMoneyReceiptOnlyCustomer2($order_number);
			}else{ //local copy and normal copy
				if($_REQUEST['date1']!=""){
			
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
				(select artisan_price from product where id=ord.item_id) karigor_price,
				(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
				ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
				(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
				FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and date(ds.insert_date)='$date1' and ord.is_active=1");
				}
				
				if($_REQUEST['mobile']!=""){
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.cus_mobile='$mobile' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
				
				if(@$_REQUEST['serial_no']!=""){
					$serial_no=trim($_REQUEST['serial_no']);
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.phy_ord_num='$serial_no' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
		
				if($_REQUEST['order_number']!=""){
					
					$order_number=explode(",",$_REQUEST['order_number']);
					for($i=0;$i<count($order_number);$i++){
						@$all_ord.="'".$order_number[$i]."',";
					}
					@$all_ord=substr($all_ord,0,-1);
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
					(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
					FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ord.order_number in($all_ord) and ord.is_active=1");
				}
		
		mysqli_close($conn);
		if(mysqli_num_rows($order_details)>0){
			$c=0;$j=0;@$cus_price=0;
			$dday=$_SESSION['FAC_DELIVERY'];
			while($rows=mysqli_fetch_array($order_details)){
				$j=$c++;
				@$karigor_dv_date =date('Y-m-d', strtotime($rows['dv_date']. " - $dday days"));
				if($_SESSION['MEASURE_TYPE']==2){ //border: 1px solid gray;
				?>
				<div id="main_body" style="margin-left: 160px;padding-left:5px;padding-right: 5px;padding-top:3px;margin-bottom: 12px;width:395px;height:550px;display: block; page-break-before: always;">
					<div style="border-bottom: 1px solid gray;overflow:hidden">
					
						<div style="text-align: center;line-height: 9px; margin-top: 8px;">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
					
					</div>
					
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>SL: <?php echo $rows['order_number']; ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b><?php echo $rows['product']."-".$rows['item_qty']." পিছ"; ?></b></p>
						</div>
					</div>
					
					<div style="height: 400px;border-bottom: 1px solid gray;">
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 14px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2)." ".getMeasurement2($rows['id'],3)." ".getMeasurement2($rows['id'],4); // selected data
								?>
								
							</div>
							
							<div class="" style="margin-top:-10px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									}else{
										
									}
								}
								?>
							</div>
						</div>
						
					</div>
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>অর্ডার তা.-  <span><?php echo date('d/m/Y',strtotime($rows['insert_date'])); ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b>ডেলিভারি তা.- <span><?php echo (@$rows['fddate']=="")? date('d/m/Y',strtotime($karigor_dv_date)) : $rows['fddate']." ".$rows['fdtime']; ?></b></p>
						</div>
					</div>
				
				</div>
				<?php 
				}else if($_SESSION['MEASURE_TYPE']==1){ //Normal Copy
					?>
					<div id="main_body" style="margin-left:50px;margin-top: 0px;padding-left:30px;padding-right: 15px;padding-top:5px;margin-bottom: 12px;width:604px;height:684px;display: block; page-break-before: always;">
					<div style="overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <span id="master<?php echo $j; ?>" onclick="setEmployee2(<?php echo $j; ?>);"><?php if($rows['masters']=="") echo "---"; else echo $rows['masters']; ?></span><span id="master_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['master_id']."#sep#1#sep#".$rows['id']; ?>" id="master_hidden_id<?php echo $j; ?>"/>
							
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 11px;"> <span id="del_date<?php echo $j; ?>"><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></span></p>
							<p style="font-size: 11px;"><?php echo $rows['product']."-".$rows['item_qty'].""; ?></p>
						</div>
					</div>
					
					<div style="height:385px;padding-left: 40px;">
						<span style="float: left;font-size: 11px;font-style: italic;">Received By- <?php echo $rows['insert_by']; ?></span>
						<span style="float: right;font-size: 11px;font-style: italic;">Atompac Limited</span>
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 60px;width: 555px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2); // selected data
								?>
								
							</div>
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],3); // checkbox data
								?>
							</div>
							<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									
									}else{
										
									}
								}
								?>
							</div>
						</div>
						<div class="row" style="overflow:hidden;padding-top: 10px;padding-left: 15px;">
						<?php 
							echo getMeasurement2($rows['id'],4); // Txtarea data
						?>
						</div>
					</div>
					<span style="float: right;font-size: 15px;font-weight: bold;padding-top: 25px;">Job Slip</span>
					<div class="row" style="line-height: 11px; margin-top: 50px;margin-bottom: 5px;">
					
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"> <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;">Qty- <?php echo $rows['item_qty']." "; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigor<?php echo $j; ?>" onclick="setEmployee(<?php echo $j; ?>)"><?php if($rows['karigor']=="") echo "---"; else echo $rows['karigor']; ?></span><span id="karigor_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"><span  id="del_date2<?php echo $j; ?>"><b><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></b></span></p>
						</div>
						
					</div>
				</div>
				<?php
				}				
			}
			}else{
				echo 2;
			}
				
			}
		}else if($print_type==22){ //only code printing area
			
				if(@$_REQUEST['order_number']!=""){
					$serial_no=trim($_REQUEST['order_number']);
				?>
				<div id="main_body" style="margin-left: 15px;padding-left:5px;padding-right: 5px;padding-top:3px;margin-bottom: 12px;display: block; page-break-before: always;">
					<?php echo onlyCodePrint($serial_no); ?>
				</div>
				<?php 
				}else{
					echo 2;
				}
		
		
		}else if($print_type==21){
			if($_SESSION['MEASURE_TYPE']==0){ //stardard
				echo printMoneyReceiptOnlyMeasurment2($order_number);
			}else{ //local copy and normal copy
				if($_REQUEST['date1']!=""){
			
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
				(select artisan_price from product where id=ord.item_id) karigor_price,
				(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
				ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
				(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
				FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and date(ds.insert_date)='$date1' and ord.is_active=1");
				}
				
				if($_REQUEST['mobile']!=""){
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.cus_mobile='$mobile' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
				
				if(@$_REQUEST['serial_no']!=""){
					$serial_no=trim($_REQUEST['serial_no']);
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price, 
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ds.insert_date) insert_date,
					(select user_name from user where id=ord.master_id) masters,ds.dv_date,
					ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ds.fddate,ds.fdtime,
					ord.item_qty FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ds.phy_ord_num='$serial_no' and ds.is_active=1 and ord.is_active=1 limit 0,10");
				}
		
				if($_REQUEST['order_number']!=""){
					
					$order_number=explode(",",$_REQUEST['order_number']);
					for($i=0;$i<count($order_number);$i++){
						@$all_ord.="'".$order_number[$i]."',";
					}
					@$all_ord=substr($all_ord,0,-1);
					
					$order_details=$conn->query("SELECT ord.id,ord.item_id,ord.ptype,(select cus_price from product where id=ord.item_id) item_price,
					(select artisan_price from product where id=ord.item_id) karigor_price,
					(select product_name from product where id=ord.item_id) product,(select user_name from user where id=ord.insert_by) insert_by,
					ord.order_number,ord.master_id,ord.group_id,date(ord.insert_date) insert_date,ds.dv_date,ds.fddate,ds.fdtime,
					(select user_name from user where id=ord.master_id) masters,ord.karigor_id,(select user_name from user where id=ord.karigor_id) karigor,ord.item_qty
					FROM `order_record` ord,dsms ds WHERE ds.id=ord.dsms_id and ord.com_id=$com_id and ord.order_number in($all_ord) and ord.is_active=1");
				}
		
		mysqli_close($conn);
		if(mysqli_num_rows($order_details)>0){
			$c=0;$j=0;@$cus_price=0;
			$dday=$_SESSION['FAC_DELIVERY'];
			while($rows=mysqli_fetch_array($order_details)){
				$j=$c++;
				@$karigor_dv_date =date('Y-m-d', strtotime($rows['dv_date']. " - $dday days"));
				if($_SESSION['MEASURE_TYPE']==2){ //border: 1px solid gray;
				?>
				<div id="main_body" style="margin-left: 160px;padding-left:5px;padding-right: 5px;padding-top:3px;margin-bottom: 12px;width:395px;height:550px;display: block; page-break-before: always;">
					<div style="border-bottom: 1px solid gray;overflow:hidden">
					
						<div style="text-align: center;line-height: 9px; margin-top: 8px;">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
					
					</div>
					
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>SL: <?php echo $rows['order_number']; ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b><?php echo $rows['product']."-".$rows['item_qty']." পিছ"; ?></b></p>
						</div>
					</div>
					
					<div style="height: 400px;border-bottom: 1px solid gray;">
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 14px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2)." ".getMeasurement2($rows['id'],3)." ".getMeasurement2($rows['id'],4); // selected data
								?>
								
							</div>
							
							<div class="" style="margin-top:-10px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									}else{
										
									}
								}
								?>
							</div>
						</div>
						
					</div>
					<div style="padding-top:5px;overflow:hidden">
						<div style="float:left;">
							<p style=""><b>অর্ডার তা.-  <span><?php echo date('d/m/Y',strtotime($rows['insert_date'])); ?></b></p>
						</div>
						<div style="float: right;">
							<p style=""><b>ডেলিভারি তা.- <span><?php echo (@$rows['fddate']=="")? date('d/m/Y',strtotime($karigor_dv_date)) : $rows['fddate']." ".$rows['fdtime']; ?></b></p>
						</div>
					</div>
					
				</div>
				<?php 
				}else if($_SESSION['MEASURE_TYPE']==1){ //Normal Copy
					?>
					<div id="main_body" style="margin-left:50px;margin-top: 0px;padding-left:30px;padding-right: 15px;padding-top:5px;margin-bottom: 12px;width:604px;height:684px;display: block; page-break-before: always;">
					<div style="overflow:hidden">
						<div class="" style="width: 25%;padding-right:15px;line-height: 9px; margin-top: 8px;float:left !important">
							<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
							<p style="width: 259px;font-size: 12px;">মাস্টার- <span id="master<?php echo $j; ?>" onclick="setEmployee2(<?php echo $j; ?>);"><?php if($rows['masters']=="") echo "---"; else echo $rows['masters']; ?></span><span id="master_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['master_id']."#sep#1#sep#".$rows['id']; ?>" id="master_hidden_id<?php echo $j; ?>"/>
							
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div style="width: 47%;padding-left:15px;padding-right:15px;text-align: center;line-height: 9px;margin-top: 8px;float:left !important">
							<p style=""><b><?php echo $_SESSION['COM']; ?></b></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
							<p style="font-size: 13px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
							<p style="font-size: 12px;text-decoration: underline;font-weight: bold;"><?php echo "Production Copy";//$_SESSION['COM_ADDRESS']; ?></p>
						</div>
						<div class="" style="width: 28%;padding-left:15px;padding-right:15px;line-height: 9px;margin-top: 8px;float:left !important">
							<p style="font-size: 11px;"> <span id="del_date<?php echo $j; ?>"><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></span></p>
							<p style="font-size: 11px;"><?php echo $rows['product']."-".$rows['item_qty'].""; ?></p>
						</div>
					</div>
					
					<div style="height:385px;padding-left: 40px;">
						<span style="float: left;font-size: 11px;font-style: italic;">Received By- <?php echo $rows['insert_by']; ?></span>
						<span style="float: right;font-size: 11px;font-style: italic;">Atompac Limited</span>
						<div style="margin-left: 0px;margin-right: 0px;overflow: hidden;padding-top: 60px;width: 555px;">
								<?php echo getMeasurement2($rows['id'],1); //1=measurement ?>
							
						</div>
						<div class="row" style="overflow:hidden;">
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:15px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],2); // selected data
								?>
								
							</div>
							<div class="" style="margin-top:8px;padding-left:15px;padding-right:20px;float:left !important">
								<?php 
								echo getMeasurement2($rows['id'],3); // checkbox data
								?>
							</div>
							<div class="" style="margin-top:6px;padding-left:15px;padding-right:15px;float:left !important">
								<?php
								if($_SESSION['SHOW_DESIGN']==1){
									if($rows['ptype']==1){
										if($rows['product']=="Shirt"){
										?>
											<img src="img/1.png" style="width: 80px;margin-top: -9px;height: 110px;"/>
										<?php 
										}else if($rows['product']=="Fatua"){
											?>
											<img src="img/1.png" style="width:80px;margin-top:-9px;height:110px;"/>
											<?php 
										}else if($rows['product']=="Pant"){
											?>
											<img src="img/3.png" style="width: 100px;height: 110px;"/>
											<?php 
										}else if($rows['product']=="Panjabi"){
											?>
											<img src="img/4.png" style="width: 128px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Mujib Coat"){
											?>
											<img src="img/5.png" style="width:110px;height: 136px;"/>
											<?php 
										}else if($rows['product']=="Coat"){
											?>
											<img src="img/6.png" style="width: 130px;height: 125px;"/>
											<?php 
										}else if($rows['product']=="Jubbah"){
											?>
											<img src="img/7.png" style="width: 115px;height: 114px; margin-top: -11px;"/>
											<?php 
										}else if($rows['product']=="Sherwani"){
											?>
											<img src="img/8.png" style="width: 120px;height: 135px;"/>
											<?php 
										}else if($rows['product']=="Prince Coat"){
											?>
											<img src="img/9.png" style="width: 105px;height: 130px;"/>
											<?php 
										}else if($rows['product']=="Waistcoat"){
											?>
											<img src="img/10.png" style="width:85px"/>
											<?php 
										}else if($rows['product']=="Kabli"){
											?>
											<img src="img/11.png" style="width: 115px;height:120px;"/>
											<?php 
										}else if($rows['product']=="Pajama"){
											?>
											<img src="img/12.png" style="width:92px;height: 120px;"/>
											<?php 
										}
									
									}else{
										
									}
								}
								?>
							</div>
						</div>
						<div class="row" style="overflow:hidden;padding-top: 10px;padding-left: 15px;">
						<?php 
							echo getMeasurement2($rows['id'],4); // Txtarea data
						?>
						</div>
					</div>
					<span style="float: right;font-size: 15px;font-weight: bold;padding-top: 25px;">Job Slip</span>
					<div class="row" style="line-height: 11px; margin-top: 50px;margin-bottom: 5px;">
					
						<div class="" style="width: 26%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 13px;"> <b><?php echo $rows['order_number']; ?></b></p>
						</div>
						<div class="" style="width: 22%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"> <?php echo $rows['product']; ?></p>
						<p style="font-size: 12px;">Qty- <?php echo $rows['item_qty']." "; ?></p>
						</div>
						<div class="" style="width: 25%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="width: 259px;font-size: 12px;">কারিগর- <span id="karigor<?php echo $j; ?>" onclick="setEmployee(<?php echo $j; ?>)"><?php if($rows['karigor']=="") echo "---"; else echo $rows['karigor']; ?></span><span id="karigor_select_box<?php echo $j; ?>"></span></p>
							<input type="hidden" value="<?php echo @$rows['karigor_id']."#sep#2#sep#".$rows['id']; ?>" id="karigor_hidden_id<?php echo $j; ?>"/>
						</div>
						<div class="" style="width: 27%;padding-left:15px;padding-right:15px;float:left !important">
						<p style="font-size: 12px;"><span  id="del_date2<?php echo $j; ?>"><b><?php echo date('d/m/Y',strtotime($karigor_dv_date)); ?></b></span></p>
						</div>
						
					</div>
				</div>
				<?php
				}				
			}
			}else{
				echo 2;
			}
				
			}
		}else if($print_type==13){
			echo printMoneyReceipt32($order_number);
		}else if($print_type==1){
			
			if($_REQUEST['mobile']!=""){
				echo getCustomerRecept2($_REQUEST['mobile']);
			}else if($_REQUEST['order_number']!=""){
				echo getCustomerReceptNormal($_REQUEST['order_number']);
			}
			else if($_REQUEST['date1']!=""){
				$date1=trim($_REQUEST['date1']);
				$ex=explode("/",$date1);
				$date1=$ex[2]."-".$ex[1]."-".$ex[0];
				echo getCustomerRecept2($date1);
			}
			
		}else if($print_type==4){
			
			echo getCustomerRecept3();
			
		}else if($print_type==3){
			date_default_timezone_set("Asia/Dhaka");
			if($date1!=""){
				$date2=trim($_REQUEST['date2']);
				$ex=explode("/",$date2);
				$date2=$ex[2]."-".$ex[1]."-".$ex[0];
			
				$order_listsql="SELECT ds.id,ds.phy_ord_num,ds.paymentType,(select sum(amount) from accounting where dsms_id=ds.id and date(insert_date)=date(ds.insert_date) and is_active=1 and pay_status in(1)) taka FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date is null and date(ds.insert_date) between '$date1' and '$date2'";
				$order_list=$conn->query($order_listsql);
				
				$order_delsql="SELECT ds.id,ds.phy_ord_num,(select sum(amount) from accounting where dsms_id=ds.id and date(insert_date)=date(ds.phy_dv_date) and is_active=1 and delivery_status in(1)) taka,(select payment_type from accounting where dsms_id=ds.id and date(insert_date)=date(ds.phy_dv_date) and is_active=1 and delivery_status in(1) limit 0,1) payment_type FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date between '$date1' and '$date2' and ds.phy_dv_date is not null";
				$order_del=$conn->query($order_delsql);
				
				$fabrics_pay_delsql="SELECT id,amount,payment_type,(select (select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) from direct_sale_head where id=ds.dsms_id limit 0,1) cus_name FROM accounting_fabrics ds WHERE ds.is_active=1 and ds.pay_status=0 and date(ds.insert_date) between '$date1' and '$date2'";
				$fabrics_pay=$conn->query($fabrics_pay_delsql);
				
					
			  $method_listsql="SELECT sum(`amount`) method_tk,method_name FROM `transaction` WHERE `com_id`=$com_id and is_active=1 and date(insert_date) between '$date1' and '$date2' and `status`=1 group by method_name";
			  $method_list=$conn->query($method_listsql);
			  $receivable_listsql="SELECT `amount` receive_tk,remarks FROM `transaction` WHERE `com_id`=$com_id and is_active=1 and date(insert_date) between '$date1' and '$date2' and `status`=1 and transaction_type in(1,2)";
					
				
				
				$receivable_list=$conn->query($receivable_listsql);
				$direct_salesql="SELECT ds.total_receive,ds.cus_mobile,ds.payment_type,(select cus_name from customer where cus_mobile=ds.cus_mobile and is_active=1 limit 0,1) cus_name,ds.id FROM direct_sale_head ds WHERE ds.is_active=1 and ds.is_order=0 and ds.in_out_status=0 and ds.com_id=$com_id and date(ds.insert_date) between '$date1' and '$date2'";
				$direct_sale=$conn->query($direct_salesql);
				$expensesql="SELECT ex.expense,ex.expense_type,ex.remarks,method,(select expense from expense_type where id=ex.expense_type) ex_type FROM expenses ex WHERE ex.is_active=1 and com_id=$com_id and date(insert_date) between '$date1' and '$date2'";
				$expense=$conn->query($expensesql);
				$wasessql="SELECT ex.taka expense,(select user_name from user where id=ex.emp_id) emp_name FROM wages_details ex WHERE ex.is_active=1 and ex.com_id=$com_id and ex.status=1 and date(ex.insert_date) between '$date1' and '$date2'";
				$wases=$conn->query($wasessql);
				
				$salarysql="SELECT ex.actual_salary expense,(select user_name from user where id=ex.emp_id) emp_name FROM salary_transaction ex WHERE ex.is_active=1 and ex.status=1 and date(ex.insert_date) between '$date1' and '$date2'";
				$salary_staff=$conn->query($salarysql);
				
				$only_fab_sql="select (pay_tbl.pay_only_fab+dsale_tbl.only_fab+dsale_tbl_ord.ord_tk) fab_total_taka from (SELECT CASE WHEN sum(`taka`)>0 THEN sum(`taka`) ELSE 0 END  pay_only_fab FROM `only_febrics_tk` WHERE `is_active`=1 and date(`insert_date`) between '$date1' and '$date2') pay_tbl,
					(SELECT CASE WHEN sum(`total_receive`)>0 THEN sum(`total_receive`) ELSE 0 END only_fab FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=0 and date(`insert_date`) between '$date1' and '$date2') dsale_tbl,
					(SELECT CASE WHEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END)>0 THEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END) ELSE 0 END ord_tk FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=1 and date(`insert_date`) between '$date1' and '$date2') dsale_tbl_ord";
				$only_fab_row=$conn->query($only_fab_sql);
				
				$dis=0;
				$exdate=explode("-",$date1);
				$paymentDate = $exdate[0]."/".$exdate[1]."/".$exdate[2];
				$day = date('l', strtotime($paymentDate));
				?>
				<input type="hidden" id="order_sql" value="<?php echo $order_listsql; ?>"/>
				<input type="hidden" id="order_del" value="<?php echo $order_delsql; ?>"/>
				<input type="hidden" id="receivable_list" value="<?php echo $receivable_listsql; ?>"/>
				<input type="hidden" id="direct_sale" value="<?php echo $direct_salesql; ?>"/>
				<input type="hidden" id="expense" value="<?php echo $expensesql; ?>"/>
				<div class="container" style="background:white;width: 800px !important;">
					<div class="col-xs-12 col-sm-12">
						<div style="overflow: hidden;width: 50%;margin: 0 auto;text-align: center;">
							
							<div style="margin-top: 11px;margin-bottom: 6px;">
								<p style="text-align: center;line-height: 1px;"><b><?php echo $_SESSION['COM']; ?></b></p>
								<p style="text-align: center;line-height: 11px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
								<p style="text-align: center;line-height: 0px;margin-bottom: 16px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
								<span style="font-weight: bold;text-align: center;border: 1px solid gray; padding: 4px 6px 4px 6px; border-radius: 9px;">Daily Report</span>
								<p style="margin-top: 10px;">তারিখ: <b><?php echo Converter::en2bn(date($exdate[2]."/".$exdate[1]."/".$exdate[0])); ?></b></p>
							
								
							</div>
							<div style="">
								
							</div>
						</div>
						<div style="overflow: hidden;width: 100%;margin: 0 auto;">
							<div style="float: left;width: 100%;margin-right:5px">
						
								
								<label style="margin-top: 14px;">আইটেম সেলস</label>
								<table border="1" style="width:100%">
									<thead>
										<tr>
											<th style="width:5%;text-align:center">Sl</th>
											<th style="width:60%;padding-left:5px">Customer</th>
											<th style="width:20%;padding-left:5px">Mobile</th>
											<th style="text-align:right;padding-right:5px;">টাকা</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl3=1;$order_tk3=0;$qty=0;
											if(mysqli_num_rows($direct_sale)>0){
												while($row=mysqli_fetch_array($direct_sale)){
													$order_tk3+=($row['total_receive']);
													?>
													<tr style="cursor:pointer" data-toggle="modal" data-target="#myModal" onclick="showPurchaseDetails('<?php echo $row['id']; ?>')">
													<td style="text-align:center"><?php echo $sl3++; ?></td>
													<td style="padding-left:5px"><?php echo $row['cus_name']; ?> (<span style="color:blue"><?php echo ($row['payment_type']=='Cash')? '' : $row['payment_type']; ?></span>)</td>
													<td style="padding-left:5px"><?php echo $row['cus_mobile']; ?></td>
													<td style="width:35%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($row['total_receive']); ?>/=</td>
													</tr>
													<?php 
												}
											}
										?>
										<?php 
											$order_tk8=0;$qty=0;
											if(mysqli_num_rows($fabrics_pay)>0){
												while($row=mysqli_fetch_array($fabrics_pay)){
													$order_tk8+=($row['amount']);
													?>
													<tr style="cursor:pointer" data-toggle="modal" data-target="#myModal" onclick="showPurchaseDetails('<?php echo $row['id']; ?>')">
													<td style="text-align:center"><?php echo $sl3++; ?></td>
													<td style="padding-left:5px"><?php echo $row['cus_name']; ?> (<span style="color:blue"><?php echo ($row['payment_type']=='Cash')? '' : $row['payment_type']; ?></span>)</td>
													<td style="padding-left:5px"><?php //echo $row['cus_mobile']; ?></td>
													<td style="width:35%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($row['amount']); ?>/=</td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tr>
										<th colspan="3"  style="text-align:right">মোট: </th>
										<th style="width:40%;text-align:right;padding-right:5px;"> <?php 
										echo Converter::en2bn($order_tk3+$order_tk8); 
										
										?>/=</th>
									</tr>
									
									
								</table>
								
							</div>
							<div style="float: left;width: 100%;">
								<label style="margin-top: 14px;">খরচ(ব্যয়)</label>
								<table border="1" style="width:100%">
									<thead>
										<tr>
											<th style="width:5%;text-align:center">Sl</th>
											<th style="width:80%;padding-left:5px">খরচের ধরন</th>
											<th style="text-align:right;padding-right:5px;">টাকা</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl3=1;$order_tk4=0;$textk=0;$bk=0;$ng=0;$ro=0;$up=0;
											if(mysqli_num_rows($expense)>0){
												while($row=mysqli_fetch_array($expense)){
													$order_tk4+=$row['expense'];
													if($row['expense_type']=='14'){
														$textk+=$row['expense'];
													}
													$bk+=($row['method']=="Bkash")? $row['expense'] : 0;
													$ng+=($row['method']=="Nagad")? $row['expense'] : 0;
													$ro+=($row['method']=="Rocket")? $row['expense'] : 0;
													$up+=($row['method']=="Upay")? $row['expense'] : 0;
													?>
													<tr>
													<td style="text-align:center"><?php echo $sl3++; ?></td>
													<td style="padding-left:5px"><?php echo $row['ex_type']; ?><span style="font-size:10px;color:blue"> (<?php echo $row['remarks'].' '.$row['method']; ?>)</span></td>
													<td style="width:35%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($row['expense']); ?>/=</td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tbody>
										<?php 
											$order_tk5=0;
											if(mysqli_num_rows($wases)>0){
												while($row=mysqli_fetch_array($wases)){
													$order_tk5+=$row['expense'];
													?>
													<tr>
													<td style="text-align:center"><?php echo $sl3++; ?></td>
													<td style="padding-left:5px"><?php echo $row['emp_name']; ?>(Wages)</td>
													<td style="width:35%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($row['expense']); ?>/=</td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tbody>
										<?php 
											$storder_tk6=0;
											if(mysqli_num_rows($salary_staff)>0){
												while($row=mysqli_fetch_array($salary_staff)){
													$storder_tk6+=$row['expense'];
													?>
													<tr>
													<td style="text-align:center"><?php echo $sl3++; ?></td>
													<td style="padding-left:5px"><?php echo $row['emp_name']; ?>(Salary)</td>
													<td style="width:35%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($row['expense']); ?>/=</td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									
									<tr>
										<th colspan="2"  style="text-align:right">মোট: </th>
										<th style="width:40%;text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk4+$order_tk5+$storder_tk6); ?>/=</th>
									</tr>
								</table>
								
								
								<label style="padding-left:10px;padding-top: 15px; padding-bottom: 5px;">Summary Report</label>
								<table border="1" style="width:100%;background: azure;">
										<thead>
											<tr>
												<th style="text-align:right">---</th>
												<th style="text-align:right;padding-right:5px;">টাকা</th>
											</tr>
										
											<tr>
												<th style="text-align:right;padding-right:5px;">আইটেম সেলস: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk3+$order_tk8); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">বাকি গ্রহণ: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn(@$receivable_tk); ?>/=</th>
											</tr>
											<tr style="background:#F5F5F5;color: #b93333;">
												<th style="text-align:right;padding-right:5px;">মোট: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn((@$order_tk+@$order_tk2+@$order_tk3+@$order_tk8+@$receivable_tk)); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">খরচ(ব্যয়)(-): </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn(@$order_tk4+@$order_tk5+@$storder_tk6); ?>/=</th>
											</tr>
											<tr style="background:#F5F5F5;color: #0c71a5;">
												<th style="text-align:right;padding-right:5px;">সর্ব মোট: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn((@$order_tk+@$order_tk2+@$order_tk3+@$order_tk8+@$receivable_tk)-@$order_tk4-@$order_tk5-@$storder_tk6); ?>/=</th>
											</tr>
										</thead>
										
									</table>
							
								
							</div>
							
						</div>
						
					</div>
					
				</div>
				<?php 
			}else{
				echo "";// plz date select
			}
		}else if($print_type==5){
			/* $date=date("F-Y", strtotime("-1 months")); 
			$mnt=date("m", strtotime("-1 months")); 
			$ex=explode("-",$date); */
			$month=$_REQUEST['month'];
			$year=$_REQUEST['year'];
			$order=$conn->query("select count(phy_ord_num) ord_num,date(insert_date) dates from dsms where is_active=1 and com_id=$com_id and month(insert_date)=$month and year(insert_date)=$year group by date(insert_date) order by date(insert_date) asc");
			
			?>
			<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<div style="overflow: hidden;">
							<div style="float: left;width: 37%;">
								<p style="">Search Date: <b><?php echo date("d/m/Y"); ?></b></p>
								<p style="line-height: 0px;">Month: <b><?php echo getMonth($month); ?></b></p>
							</div>
							<div style="float: left;margin-top: 11px;margin-bottom: 6px;">
								<p style="text-align: center;line-height: 1px;margin-left: 37px;"><b><?php echo $_SESSION['COM']; ?></b></p>
								<p style="text-align: center;line-height: 11px;margin-left: 37px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
								<p style="text-align: center;line-height: 0px;margin-bottom: 16px;margin-left: 37px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
								<span style="font-weight: bold;text-align: center;border: 1px solid gray; padding: 4px 6px 4px 6px; border-radius: 9px; margin-left: 14px;">Monthly Order Report</span>
							</div>
							<div style="">
								
							</div>
						</div>
						<div style="overflow: hidden;">
							<div style="float: left;width: 48%;margin-right:5px">
								<label>Order Summary</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th>Sl</th>
											<th style="width:40%;">Date</th>
											<th style="width:40%;text-align:right">No. of Order</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$order_tk=0;
											if(mysqli_num_rows($order)>0){
												while($row=mysqli_fetch_array($order)){
													$order_tk+=$row['ord_num'];
													$ol=$sl++;
													?>
													<tr>
													<td><?php echo $ol; ?></td>
													<td><a href="javascript:void(0)" id="dvdate<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['dates']; ?>','<?php echo $ol; ?>','1');"><?php echo $row['dates']; ?></a></td>
													<td style="width:40%;text-align:right"><a href="javascript:void(0)" id="dvcount<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['dates']; ?>','<?php echo $ol; ?>','1');"><?php echo $row['ord_num']; ?></a></td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tr>
										<th colspan="2"  style="text-align:right">Total Order</th>
										<th style="width:40%;text-align:right"><?php echo $order_tk; ?></th>
									</tr>
								</table>
								
							</div>
							<input type="hidden" id="dvid" value="0"/>
							<div style="float: left;width: 49%;" id="ord_list">
								
							</div>
							
						</div>
						
					</div>
					
				</div>
			<?php 
		}else if($print_type==6){
			/* $date=date("F-Y", strtotime("-1 months")); 
			$mnt=date("m", strtotime("-1 months")); 
			$ex=explode("-",$date); */
			$month=$_REQUEST['month'];
			$year=$_REQUEST['year'];
			$order=$conn->query("select count(phy_ord_num) ord_num,phy_dv_date dates from dsms where is_active=1 and com_id=$com_id and phy_dv_date is not null and month(phy_dv_date)=$month and year(phy_dv_date)=$year group by phy_dv_date order by phy_dv_date asc");
			
			?>
			<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<div style="overflow: hidden;">
							<div style="float: left;width: 37%;">
								<p style="">Search Date: <b><?php echo date("d/m/Y"); ?></b></p>
								<p style="line-height: 0px;">Month: <b><?php echo getMonth($month); ?></b></p>
							</div>
							<div style="float: left;margin-top: 11px;margin-bottom: 6px;">
								<p style="text-align: center;line-height: 1px;"><b><?php echo $_SESSION['COM']; ?></b></p>
								<p style="text-align: center;line-height: 11px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
								<p style="text-align: center;line-height: 0px;margin-bottom: 16px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
								<span style="font-weight: bold;text-align: center;border: 1px solid gray; padding: 4px 6px 4px 6px; border-radius: 9px; margin-left: 14px;">Monthly Delivery Report</span>
							</div>
							<div style="">
								
							</div>
						</div>
						<div style="overflow: hidden;">
							<div style="float: left;width: 48%;margin-right:5px">
								<label>Order Summary</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th>Sl</th>
											<th style="width:40%;">Date</th>
											<th style="width:40%;text-align:right">No. of Order</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$order_tk=0;
											if(mysqli_num_rows($order)>0){
												while($row=mysqli_fetch_array($order)){
													$order_tk+=$row['ord_num'];
													$ol=$sl++;
													?>
													<tr>
													<td><?php echo $ol; ?></td>
													<td><a href="javascript:void(0)" id="dvdate<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['dates']; ?>','<?php echo $ol; ?>','2');"><?php echo $row['dates']; ?></a></td>
													<td style="width:40%;text-align:right"><a href="javascript:void(0)" id="dvcount<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['dates']; ?>','<?php echo $ol; ?>','2');"><?php echo $row['ord_num']; ?></a></td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tr>
										<th colspan="2"  style="text-align:right">Total Order</th>
										<th style="width:40%;text-align:right"><?php echo $order_tk; ?></th>
									</tr>
								</table>
								
							</div>
							<input type="hidden" id="dvid" value="0"/>
							<div style="float: left;width: 49%;" id="ord_list">
								
							</div>
							
						</div>
						
					</div>
					
				</div>
			<?php
		}else if($print_type==7){
			$month=$_REQUEST['month'];
			$year=$_REQUEST['year'];
			$order=$conn->query("SELECT es.master_id empid,(select concat(user_name,'(','Master',')') from user where id=es.master_id) name,(select emp_type from user where id=es.master_id) emp_type,sum(p.master_price*es.item_qty) tk FROM `order_record` es,product p WHERE es.item_id=p.id and es.is_active=1 and es.com_id=$com_id and month(es.insert_date)=$month and year(es.insert_date)=$year and es.master_id!=0 GROUP by es.master_id union (SELECT es.karigor_id empid,(select concat(user_name,'(','Karigor',')') from user where id=es.karigor_id) name,(select emp_type from user where id=es.karigor_id) emp_type,sum(p.artisan_price*es.item_qty) tk FROM `order_record` es,product p WHERE es.item_id=p.id and es.is_active=1 and es.com_id=$com_id and month(es.insert_date)=$month and year(es.insert_date)=$year and es.karigor_id!=0 GROUP by es.karigor_id)");
			
			?>
			<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<div style="overflow: hidden;">
							<div style="float: left;width: 37%;">
								<p style="">Search Date: <b><?php echo date("d/m/Y"); ?></b></p>
								<p style="line-height: 0px;">Month: <b><?php echo getMonth($month); ?></b></p>
							</div>
							<div style="float: left;margin-top: 11px;margin-bottom: 6px;">
								<p style="text-align: center;line-height: 1px;"><b><?php echo $_SESSION['COM']; ?></b></p>
								<p style="text-align: center;line-height: 11px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
								<p style="text-align: center;line-height: 0px;margin-bottom: 16px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
								<span style="font-weight: bold;text-align: center;border: 1px solid gray; padding: 4px 6px 4px 6px; border-radius: 9px; margin-left: 14px;">Monthly Employee Salary Report</span>
							</div>
							<div style="">
								
							</div>
						</div>
						<div style="overflow: hidden;">
							<div style="float: left;width: 48%;margin-right:5px">
								<label>Employee Monthly Salary</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th>Sl</th>
											<th style="width:40%;">Name</th>
											<th style="width:40%;text-align:right">Taka</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_tk=0;
											if(mysqli_num_rows($order)>0){
												while($row=mysqli_fetch_array($order)){
													$tot_tk+=$row['tk'];
													$ol=$sl++;
													?>
													<input type="hidden" value="<?php echo $row['emp_type']; ?>" id="emp_type<?php echo $ol; ?>"/>
													<input type="hidden" value="<?php echo $month."#sep#".$year; ?>" id="month_year<?php echo $ol; ?>"/>
													<tr>
													<td><?php echo $ol; ?></td>
													<td><a href="javascript:void(0)" id="dvdate<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['empid']; ?>','<?php echo $ol; ?>','3');"><?php echo $row['name']; ?></a></td>
													<td style="width:40%;text-align:right"><a href="javascript:void(0)" id="dvcount<?php echo $ol; ?>" onclick="getOrdList('<?php echo $row['empid']; ?>','<?php echo $ol; ?>','3');"><?php echo $row['tk']; ?></a></td>
													</tr>
													<?php 
												}
											}
										?>
									</tbody>
									<tr>
										<th colspan="2"  style="text-align:right">Total Taka</th>
										<th style="width:40%;text-align:right"><?php echo $tot_tk; ?></th>
									</tr>
								</table>
								
							</div>
							<input type="hidden" id="dvid" value="0"/>
							<div style="float: left;width: 49%;" id="ord_list">
								
							</div>
							
						</div>
						
					</div>
					
				</div>
			<?php
		}else if($print_type==8){
			date_default_timezone_set("Asia/Dhaka");
			$date1=$_REQUEST['date1'];
			$date2=$_REQUEST['date2'];
			$exdate=explode("/",$date1);
				$sdate = $exdate[2]."-".$exdate[1]."-".$exdate[0];
			$exdate2=explode("/",$date2);
				$tdate = $exdate2[2]."-".$exdate2[1]."-".$exdate2[0];
			if($date1!=""){
				$order_listsql="SELECT ds.id,ds.phy_ord_num,(select sum(amount) from accounting where dsms_id=ds.id and date(insert_date)=date(ds.insert_date) and is_active=1 and pay_status in(1)) taka FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date is null and date(ds.insert_date) between '$sdate' and '$tdate'";
				$order_list=$conn->query($order_listsql);
				$order_delsql="SELECT ds.id,ds.phy_ord_num,(select sum(amount) from accounting where dsms_id=ds.id and date(insert_date)=date(ds.phy_dv_date) and is_active=1 and delivery_status in(1)) taka FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and date(phy_dv_date) between '$sdate' and '$tdate'";
				$order_del=$conn->query($order_delsql);
				
				
			  $receivable_listsql="SELECT `amount` receive_tk,remarks FROM `transaction` WHERE `com_id`=$com_id and is_active=1 and date(insert_date) between '$sdate' and '$tdate' and `status`=1 and transaction_type in(1,2)";
					
				
				$receivable_list=$conn->query($receivable_listsql);
				$direct_salesql="SELECT ds.total_receive,ds.cus_mobile,(select cus_name from customer where cus_mobile=ds.cus_mobile and is_active=1 limit 0,1) cus_name,ds.id FROM direct_sale_head ds WHERE ds.is_active=1 and ds.is_order=0 and ds.in_out_status=0 and ds.com_id=$com_id and date(ds.insert_date) between '$sdate' and '$tdate'";
				$direct_sale=$conn->query($direct_salesql);
				$expensesql="SELECT ex.expense,ex.remarks,(select expense from expense_type where id=ex.expense_type) ex_type FROM expenses ex WHERE ex.is_active=1 and com_id=$com_id and date(ex.insert_date) between '$sdate' and '$tdate'";
				$expense=$conn->query($expensesql);
				$wasessql="SELECT ex.taka expense,(select user_name from user where id=ex.emp_id) emp_name FROM wages_details ex WHERE ex.is_active=1 and ex.com_id=$com_id and ex.status=1 and date(ex.insert_date) between '$sdate' and '$tdate'";
				$wases=$conn->query($wasessql);
				$dis=0;
				
				$only_fab_sql="select (pay_tbl.pay_only_fab+dsale_tbl.only_fab+dsale_tbl_ord.ord_tk) fab_total_taka from (SELECT CASE WHEN sum(`taka`)>0 THEN sum(`taka`) ELSE 0 END  pay_only_fab FROM `only_febrics_tk` WHERE `is_active`=1 and date(`insert_date`) BETWEEN '$sdate' and '$tdate') pay_tbl,
					(SELECT CASE WHEN sum(`total_receive`)>0 THEN sum(`total_receive`) ELSE 0 END only_fab FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=0 and date(`insert_date`) BETWEEN '$sdate' and '$tdate') dsale_tbl,
					(SELECT CASE WHEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END)>0 THEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END) ELSE 0 END ord_tk FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=1 and date(`insert_date`) BETWEEN '$sdate' and '$tdate') dsale_tbl_ord";
				$only_fab_row=$conn->query($only_fab_sql);
				
				//$exdate=explode("-",$date1);
				//$paymentDate = $exdate[0]."/".$exdate[1]."/".$exdate[2];
				//$day = date('l', strtotime($paymentDate));
				?>
				<input type="hidden" id="order_sql" value="<?php echo $order_listsql; ?>"/>
				<input type="hidden" id="order_del" value="<?php echo $order_delsql; ?>"/>
				<input type="hidden" id="receivable_list" value="<?php echo $receivable_listsql; ?>"/>
				<input type="hidden" id="direct_sale" value="<?php echo $direct_salesql; ?>"/>
				<input type="hidden" id="expense" value="<?php echo $expensesql; ?>"/>
				<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<div style="overflow: hidden;">
							<div style="float: left;width: 37%;padding-top: 4px;">
								<p style="">Date: <b><?php echo $date1." to ".$date2; //Converter::en2bn(date($exdate[2]."/".$exdate[1]."/".$exdate[0])); ?></b></p>
							</div>
							<div style="float: left;margin-top: 11px;margin-bottom: 6px;">
								<p style="text-align: center;line-height: 1px;margin-left: 37px;"><b><?php echo $_SESSION['COM']; ?></b></p>
								<p style="text-align: center;line-height: 11px;margin-left: 37px;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
								<p style="text-align: center;line-height: 0px;margin-bottom: 16px;margin-left: 37px;"><?php echo $_SESSION['COM_MOBILE']; ?></p>
								<span style="font-weight: bold;text-align: center;border: 1px solid gray; padding: 4px 6px 4px 6px; border-radius: 9px; margin-left: 75px;">Report</span>
							</div>
							<div style="">
								
							</div>
						</div>
						<div style="overflow: hidden;">
							
										<?php 
											$sl=1;$order_tk=0;
											if(mysqli_num_rows($order_list)>0){
												while($row=mysqli_fetch_array($order_list)){
													$order_tk+=$row['taka'];
												}
											}
										?>

								
										<?php 
											$sl=1;$receivable_tk=0;
											if(mysqli_num_rows($receivable_list)>0){
												while($row=mysqli_fetch_array($receivable_list)){
												$receivable_tk+=$row['receive_tk'];
													
												}
											}
										?>
									
							
										<?php 
											$sl2=1;$order_tk2=0;
											if(mysqli_num_rows($order_del)>0){
												while($row=mysqli_fetch_array($order_del)){
													$order_tk2+=$row['taka'];
													
												}
											}
										?>
									
										<?php 
											$sl3=1;$order_tk3=0;$qty=0;
											if(mysqli_num_rows($direct_sale)>0){
												while($row=mysqli_fetch_array($direct_sale)){
													$order_tk3+=($row['total_receive']);
													
												}
											}
										?>
							
										<?php 
											$sl3=1;$order_tk4=0;;
											if(mysqli_num_rows($expense)>0){
												while($row=mysqli_fetch_array($expense)){
													$order_tk4+=$row['expense'];
													
												}
											}
										?>
									
										<?php 
											$order_tk5=0;
											if(mysqli_num_rows($wases)>0){
												while($row=mysqli_fetch_array($wases)){
													$order_tk5+=$row['expense'];
													
												}
											}
										?>
										
										<?php 
											$order_tk6=0;
											if(mysqli_num_rows($only_fab_row)>0){
												while($row=mysqli_fetch_array($only_fab_row)){
													$order_tk6+=$row['fab_total_taka'];
													
												}
											}
										?>
									
							
							<div style="width: 100%;background:#eaeef1;">
								<label style="padding-left:10px;padding-top: 5px; padding-bottom: 5px;">Summary Report</label>
								<table border="1" style="width:100%">
										<thead>
											<tr>
												<th style="text-align:right">---</th>
												<th style="text-align:right;padding-right:5px;">টাকা</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">অর্ডার(টেইলারিং): </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">ডেলিভারি(টেইলারিং): </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk2); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">ফ্যাব্রিক্স: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk3); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">বাকি গ্রহণ: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($receivable_tk); ?>/=</th>
											</tr>
											<tr style="background:#F5F5F5;color: #b93333;">
												<th style="text-align:right;padding-right:5px;">মোট: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn(($order_tk+$order_tk2+$order_tk3+$receivable_tk)); ?>/=</th>
											</tr>
											<tr>
												<th style="text-align:right;padding-right:5px;">খরচ(ব্যয়)(-): </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn($order_tk4+$order_tk5); ?>/=</th>
											</tr>
											<tr style="background:#F5F5F5;color: #b61ed2;">
												<th style="text-align:right;padding-right:5px;">সর্ব মোট: </th>
												<th style="text-align:right;padding-right:5px;"><?php echo Converter::en2bn(($order_tk+$order_tk2+$order_tk3+$receivable_tk)-$order_tk4-$order_tk5); ?>/=</th>
											</tr>
										</thead>
										
									</table>
									<table border="1" style="width:100%">
										<thead>
											<tr>
												<th data-toggle="modal" data-target="#myModal" onclick="showOnlyFabricsPriceTotal('<?php echo $sdate; ?>','<?php echo $tdate; ?>','<?php echo $order_tk6; ?>')" style="text-align:right;padding-right:5px;cursor:pointer">ফ্যাব্রিক্স এর টাকা (Order+Pay+Delivery+Only Fabrics): </th>
												<th data-toggle="modal" data-target="#myModal" onclick="showOnlyFabricsPriceTotal('<?php echo $sdate; ?>','<?php echo $tdate; ?>','<?php echo $order_tk6; ?>')" style="text-align:right;padding-right:5px;cursor:pointer"><?php echo Converter::en2bn($order_tk6); ?>/=</th>
											</tr>
										</thead>
										
									</table>
							</div>
						</div>
					</div>
					
				</div>
				<?php 
			}else{
				echo "";// plz date select
			}
		}else if($print_type==10){
			$order_number=trim($_REQUEST['order_number']); // fabrics ord no 
			$idetails="";$dis="";$ship="";
			$sales_by=$_SESSION['USER'];
			$monthly_report_sql=$conn->query("select insert_date pdate,courier,payment_type,shipping_tk,id,f_total,discount,discount_tk,cus_mobile,(select cus_address from customer where cus_mobile=direct_sale_head.cus_mobile and is_active=1 limit 0,1) customer_address,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile and is_active=1 limit 0,1) customer_name,others_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 update_due.last_due from update_due where update_due.cus_id=(select customer.id from customer where customer.cus_mobile=direct_sale_head.cus_mobile limit 0,1) and update_due.is_active=1 order by update_due.id desc limit 0,1) total_due FROM `direct_sale_head` WHERE `com_id`=$com_id and is_active=1 and is_order=0 and id='$order_number'");
			if(mysqli_num_rows($monthly_report_sql)>0){
				$rows=mysqli_fetch_array($monthly_report_sql);
				$customer_name=$rows['customer_name'];
				$customer_address=$rows['customer_address'];
				$payment_type=$rows['payment_type'];
				$cus_mobile=$rows['cus_mobile'];
				$fab_total=$rows['f_total'];
				$discount=$rows['discount'];
				$discount_tk=$rows['discount_tk'];
				$others_tk=$rows['others_tk'];
				$total_receive=$rows['total_receive'];
				$dates=$rows['pdate'];
				$courier=$rows['courier'];
				$shipping_tk=$rows['shipping_tk'];
				$total_due=$rows['total_due'];
				
				if($discount>0){
					$dis="<div style='overflow:hidden;font-size: 14px;
							font-weight:bold;text-align:center;
							padding-top: 3px;
							padding-bottom: 3px;
							'>	
							<div style='float: left;text-align: right;width: 250px;'>	
								Discount($discount%): 
							</div>
							<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
								$discount_tk
							</div>
							
						</div>";
				}
				
			if($shipping_tk>0){
				$ship="<div style='overflow:hidden;font-size: 14px;
					font-weight: bold;text-align:center;
					padding-top: 3px;
					padding-bottom: 3px;
					'>	
					<div style='float: left;text-align: right;width: 250px;'>	
						Shipping Charge: 
					</div>
					<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
						$shipping_tk
					</div>
				
				</div>";
			}
				
				
				$fabrics_sql=$conn->query("select item_id,item_qty,price,item_unit,(select product_name from product where id=direct_sale.item_id) item_name FROM `direct_sale` WHERE is_active=1 and dstid='$order_number'");
				$sl=0;$c=1;
			if($_SESSION['MEASURE_TYPE']==0){ //0=standerd,1=Local,2=Normal
				while($rows=mysqli_fetch_array($fabrics_sql)){
					$sl=$c++;
					$item_name=$rows['item_name'];
					$item_qty=$rows['item_qty'];
					$item_price=$rows['price'];
					$item_unit=$rows['item_unit'];
					if($discount_tk>0){
						$item_price=(($item_price*100)/(100-$discount));
					}
					$tprice=($item_qty*$item_price);
					
					$idetails.="<div style='float:left;width: 7%;'>	
						$sl.
					</div>
					<div style='float:left;width: 53%;text-align:left'>	
						$item_name <span style='font-size:10px'>S: $item_unit</span>
					</div>
					<div style='float:left;width: 10%;'>	
						$item_qty
					</div>
					<div style='float:left;width: 15%;text-align: right;'>	
						$item_price
					</div>
					<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
						$tprice
					</div>";
				}
				$sl=$sl+1;
				if($others_tk>0){
					$otaka=$others_tk;
					$fab_total+=$otaka;
					$otaka_title="Others ";
					$idetails.="<div style='float:left;width: 7%;'>	
						$sl.
					</div>
					<div style='float:left;width: 53%;text-align:left'>	
						Others
					</div>
					<div style='float:left;width: 10%;'>	
						---
					</div>
					<div style='float:left;width: 15%;text-align: right;'>	
						$otaka
					</div>
					<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
						$otaka
					</div>";
				}
				
				if($discount_tk>0){
					$fab_totald=($fab_total-$discount_tk);
					$remaining=($fab_totald-$total_receive+$shipping_tk);
				}else{
					$remaining=($fab_total-$total_receive+$shipping_tk);
				}
				
			?>
			
<div id='print_area' style='overflow:hidden;margin-top:5px;margin-bottom: 6px; width:336px;max-width:336px;display: block; page-break-before: always;'>
	<div style='overflow:hidden;padding-top:25px;'>	
		<div style='line-height: 5px;padding-top:15px;text-align:center;'>	
			<p style='font-size: 17px;font-weight: bold;padding-top:0px;'><?php echo $_SESSION['COM']; ?></p>
			<p style='font-size: 16px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_ADDRESS']; ?></p>
			<p style='font-size: 15px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['EMAIL']; ?></p>
			<p style='font-size: 15px; font-weight: bold;padding-top: 0px;'><?php echo $_SESSION['COM_MOBILE']; ?></p>
			<p style='font-size: 16px; font-weight: bold;padding-top: 10px;'>Invoice</p>
		</div>
		
	</div>
	
	<div style='overflow:hidden;margin-top: 20px;'>	
		<div style='float:left; padding-left: 6px;'>	
			<p style='font-size: 14px;'><b>Order No: <?php echo $order_number; ?></b></span>
		</div>
		<div style='float:right; padding-right: 6px;font-weight:bold'>	
			<p style='font-size: 4;'><?php echo $dates; ?></p>
		</div>
	</div>
	<div style='overflow:hidden;margin-top: 0px;'>	
		<div style='float:left; padding-left: 6px;width: 50%;'>	
			<p style='font-size: 12px;'><b>Customer: <?php echo $customer_name; ?></b></span>
		</div>
		<div style='float:left; padding-right: 6px;width:50%;text-align:right;font-weight:bold'>	
			<p style='font-size: 14px;'><?php echo $cus_mobile; ?></p>
		</div>
	</div>
	<div style='overflow:hidden;margin-top: 0px;'>	
		<div style='float:left; padding-left: 6px;width: 100%;'>	
			<p style='font-size: 12px;'><b>Address: <?php echo $customer_address; ?></b></span>
		</div>
		
	</div>
	<div style='overflow:hidden;margin-top: 0px;'>	
		<div style='float:left; padding-left: 6px;width: 100%;'>	
			<p style='font-size: 12px;'><b>Method: <?php echo $payment_type; ?></b></span>
		</div>
		
	</div>
	<div style='overflow:hidden;margin-top: 0px;'>	
		<div style='float:left; padding-left: 6px;width: 100%;'>	
			<p style='font-size: 12px;'><b>Sales By: <?php echo $sales_by; ?></b></span>
		</div>
		
	</div>
	<div style='overflow:hidden;margin-top: -3px;margin-left: 6px;
			margin-right: 6px;'>	
	<div style='width: 100%;margin-bottom: -6px;'>	
			---------------------------------------------------------------------
	</div>
		<div style='overflow:hidden;font-size: 15px;
			font-weight: bold;text-align:center;margin-bottom: -7px;'>	
			<div style='float:left;width: 7%;'>	
				Sl
			</div>
			<div style='float:left;width: 53%;text-align:left'>	
				Description
			</div>
			<div style='float:left;width: 10%;'>	
				Qty
			</div>
			<div style='float:left;width: 15%;text-align: right;'>	
				Rate
			</div>
			<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
				Taka
			</div>
		</div>
	<div style='width: 100%;margin-bottom: -6px;'>	
			---------------------------------------------------------------------
	</div>
	<div style=''>
		<div style='overflow:hidden;font-size: 14px;
			font-weight:bold;text-align:center;
			padding-bottom: 15px;'>	
			<?php echo $idetails; ?>
		</div>
	</div>
	<div style='width: 100%;margin-bottom: -6px;'>	
			---------------------------------------------------------------------
	</div>
		<div style='overflow:hidden;font-size: 14px;
			font-weight: bold;text-align:center;
			
			padding-bottom: 3px;
			'>	
			<div style='float: left;text-align: right;width: 250px;'>	
				Total: 
			</div>
			<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $fab_total; ?>
			</div>
			
		</div>
		<?php echo $dis; ?>
		<?php echo $ship; ?>
		<div style='overflow:hidden;font-size: 14px;
			font-weight:bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;'>	
			<div style='float: left;text-align: right;width: 250px;'>	
				Receive: 
			</div>
			<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $total_receive; ?>
			</div>
			
		</div>
		<div style='overflow:hidden;font-size: 14px;
			font-weight: bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;'>	
			<div style='float: left;text-align: right;width: 250px;'>	
				 Due: 
			</div>
			<div style='float:left;font-size:14px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $remaining; ?>
			</div>
			
		</div>
		
	<div style='width: 100%;margin-bottom: -6px;'>	
			---------------------------------------------------------------------
	</div>
	
	</div>
	
	<div style='width: 100%;text-align: center;padding-top: 65px;padding-bottom: 50px;font-size:16px;font-weight:bold'>	
			*** Thanks for your purchase ***
	</div>
	
</div>
		
			<?php
			}else{
				while($rows=mysqli_fetch_array($fabrics_sql)){
					$sl=$c++;
					$item_name=$rows['item_name'];
					$item_qty=$rows['item_qty'];
					$item_price=$rows['price'];
					if($discount_tk>0){
						$item_price=(($item_price*100)/(100-$discount));
					}
					$tprice=($item_qty*$item_price);
					
					$idetails.="<div style='float:left;width: 5%;'>	
						$sl.
					</div>
					<div style='float:left;width: 55%;'>	
						$item_name
					</div>
					<div style='float:left;width: 10%;'>	
						$item_qty
					</div>
					<div style='float:left;width: 15%;text-align: right;'>	
						$item_price
					</div>
					<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
						$tprice
					</div>";
				}
				$sl=$sl+1;
				if($others_tk>0){
					$otaka=$others_tk;
					$fab_total+=$otaka;
					$otaka_title="অন্যান্য ";
					$idetails.="<div style='float:left;width: 5%;'>	
						$sl.
					</div>
					<div style='float:left;width: 55%;'>	
						অন্যান্য
					</div>
					<div style='float:left;width: 10%;'>	
						---
					</div>
					<div style='float:left;width: 15%;text-align: right;'>	
						$otaka
					</div>
					<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
						$otaka
					</div>";
				}
				
				if($discount_tk>0){
					$fab_totald=($fab_total-$discount_tk);
					$remaining=($fab_totald-$total_receive);
				}else{
					$remaining=($fab_total-$total_receive);
				}
				
			?>
			
		<div id='print_area' style='overflow:hidden;margin-top:5px;margin-bottom: 6px;border: 1px solid gray; width:580px;height:600px;display: block; page-break-before: always;'>
	<div style='overflow:hidden;padding-top: 10px;'>	
		<div style='float:left; line-height: 3px;padding-left: 228px;'>	
			<p style='font-size: 10px;'>বিসমিল্লাহির রাহমানির রাহিম</p>
			<p style='font-size: 12px;font-weight: bold;padding-left: 28px;padding-top:0px;'>ক্যাশ মেমো</p>
			<p style='font-size: 14px; font-weight: bold;padding-left:6px;padding-top: 0px;'>MM Company Ltd.</p>
		</div>
		<div style='float:right;text-align: right;padding-right: 6px;line-height: 3px;'>	
			<p style='font-size: 10px;'>মুজিবর রহমান</p>
			<p style='font-size: 10px;'>প্রোপ্রাইটর</p>
			<p style='font-size: 10px;'>মোবা: ০১৭১৮৬৩৫৫৩৬</p>
		</div>
	</div>
	<div style='overflow:hidden; margin-top: -4px;'>	
		<div style='text-align:center'>	
			<p style='font-size: 10px;'>শিববাড়ি, জয়দেবপুর,গাজীপুর</span>
		</div>
	</div>
	<div style='overflow:hidden;margin-top: -3px;'>	
		<div style='float:left; padding-left: 6px;'>	
			<p style='font-size: 10px;'>ক্রমিক নং: <?php echo $order_number; ?></span>
		</div>
		<div style='float:right; padding-right: 6px;'>	
			<p style='font-size: 10px;'>তারিখ: <?php echo $dates; ?></p>
		</div>
	</div>
	<div style='overflow:hidden;margin-top: -7px;'>	
		<div style='float:left; padding-left: 6px;width: 30%;'>	
			<p style='font-size: 10px;'>নাম: <?php echo $customer_name; ?></span>
		</div>
		<div style='float:left; padding-right: 6px;width: 40%;'>	
			<p style='font-size: 10px;'>ঠিকানা:............................</p>
		</div>
		<div style='float:left; padding-right: 6px;width: 30%;'>	
			<p style='font-size: 10px;'>মোবা:  <?php echo $cus_mobile; ?></p>
		</div>
	</div>
	<div style='overflow:hidden;margin-top: -3px;margin-left: 6px;
			margin-right: 6px;border: 1px solid gray;'>	
	
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;background: lightgray;
			padding-top: 3px;
			padding-bottom: 3px;
			'>	
			<div style='float:left;width: 5%;'>	
				নং
			</div>
			<div style='float:left;width: 55%;'>	
				বিবরণ
			</div>
			<div style='float:left;width: 10%;'>	
				পরিমান
			</div>
			<div style='float:left;width: 15%;text-align: right;'>	
				দর
			</div>
			<div style='float:left;width: 15%;text-align: right;padding-right: 5px;'>	
				টাকা
			</div>
		</div>
	<div style='height:327px'>
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;'>	
			<?php echo $idetails; ?>
		</div>
	
		
	</div>
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;
			
			padding-bottom: 3px;
			'>	
			<div style='float: left;width: 490px;text-align: right;'>	
				মোট: 
			</div>
			<div style='float:left;font-size:11px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $fab_total; ?>
			</div>
			
		</div>
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;
			'>	
			<div style='float: left;width: 490px;text-align: right;'>	
				ছাড় ($discount%): 
			</div>
			<div style='float:left;font-size:11px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $discount_tk; ?>
			</div>
			
		</div>
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;
			'>	
			<div style='float: left;width: 490px;text-align: right;'>	
				জমা: 
			</div>
			<div style='float:left;font-size:11px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $total_receive; ?>
			</div>
			
		</div>
		<div style='overflow:hidden;font-size: 10px;
			font-weight: bold;text-align:center;
			padding-top: 3px;
			padding-bottom: 3px;
			'>	
			<div style='float: left;width: 490px;text-align: right;'>	
				বকেয়া: 
			</div>
			<div style='float:left;font-size:11px;width: 74px;text-align: right;padding-right: 5px;'>	
				<?php echo $remaining; ?>
			</div>
			
		</div>
	
	</div>
	
	<div style='overflow:hidden;margin-top: 32px;'>	
	<div style='float:left; padding-left: 16px;font-size: 11px;'>	
		সাক্ষর
	</div>
	<div style='float: right;padding-right: 6px;font-size: 9px; padding-top: 14px;'>	
		EasyTech24
	</div>

	</div>
</div>
	<?php 
			}
			}else{
				echo "<span style='color:red'>Invalid Order/Serial No.</span>";
			}
		}else if($print_type==27){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$total=0;
			$c=0;$sl=0;
			$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			$monthly_report_sql=$conn->query("select item_id,date(insert_date) rdate,item_qty qty,(purchase_price*item_qty) sprice,(select product_name from product where id=direct_sale.item_id) item_name,(select uom from product where id=direct_sale.item_id) uom from direct_sale where `com_id`=$com_id and in_out_status=1 and is_active=1 and date(insert_date) between '$d1' and '$d2'");
			$monthly_report_sql2=$conn->query("select item_id,date(insert_date) rdate,item_qty qty,(price*item_qty) sprice,(select product_name from product where id=direct_sale.item_id) item_name,(select uom from product where id=direct_sale.item_id) uom from direct_sale where `com_id`=$com_id and in_out_status=0 and is_active=1 and date(insert_date) between '$d1' and '$d2'");
			//$monthly_report_sql2=$conn->query("select tfabrics_tk,date(insert_date) idate,cus_name,cus_mobile,phy_ord_num from dsms where `com_id`=$com_id and is_active=1 and date(insert_date) between '$d1' and '$d2' and tfabrics_tk!='0'");
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<?php 
							$tprofit=0;$tsprice=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Item Receive List</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Date</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
											<th style="width:10%;text-align:right">Price</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$tot_qty+=$rows['qty'];
													$tsprice+=$rows['sprice'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td><?php echo $rows['rdate']; ?></td>
													<td><?php echo $rows['item_name']; ?></td>
													<td style="text-align: center;"><?php echo round($rows['qty'],2); ?> <?php echo $rows['uom']; ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']),2); ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									<tr>
										<th colspan="3"  style="text-align:right">Total Qty/Total</th>
										<th style="width:40%;text-align:center"><?php echo round($tot_qty,2); ?></th>
										<th style="width:10%;text-align:right"><?php echo round($tsprice,2); ?></th>
									</tr>
								</table>
								<?php 
							}
							?>	

						<?php 
						$tprofit2=0;$tsale=0;
							if(mysqli_num_rows($monthly_report_sql2)>0){
								?>
								<label>Sales Total (Item)</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Date</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
											<th style="width:10%;text-align:right">Price</th>
											</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;$tsale=0;
											while($rows=mysqli_fetch_array($monthly_report_sql2)){
													$tot_qty+=$rows['qty'];
													$tsale+=$rows['sprice'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td><?php echo $rows['rdate']; ?></td>
													<td><?php echo $rows['item_name']; ?></td>
													<td style="text-align: center;"><?php echo round($rows['qty'],2); ?> <?php echo $rows['uom']; ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']),2); ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									<tr>
										<th colspan="4"  style="text-align:right">Total</th>
										<th style="width:10%;text-align:right"><?php echo round($tsale,2); ?></th>
											
									</tr>
								</table>
								<?php 
							}
							?>
								
							</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==30){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$total=0;
			$c=0;$sl=0;
			$d1=$date1[0]."-".$date1[1]."-".$date1[2];
			$d2=$date2[0]."-".$date2[1]."-".$date2[2];
			$monthly_report_sql2=$conn->query("select id,shipping_tk,date(insert_date) order_date,tracking_code,book_date from direct_sale_head where in_out_status=0 and is_order=0 and courier_book=1 and is_active=1 and book_date between '$d1' and '$d2' and book_date!=''");
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						<?php 
							$tprofit=0;$tsprice=0;
							if(mysqli_num_rows($monthly_report_sql2)>0){
								?>
								<label>Courier Payment Report</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:20%;text-align: center;">Order Number</th>
											<th style="width:35%;text-align: center;">Tracking Number</th>
											<th style="width:20%;text-align:center">Booking Date</th>
											<th style="width:20%;text-align:right">Taka</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql2)){
													$tot_qty+=$rows['shipping_tk'];
													
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td style="text-align: center;"><?php echo $rows['id']; ?></td>
													<td style="text-align: center;"><?php echo $rows['tracking_code']; ?></td>
													<td style="text-align: center;"><?php echo $rows['book_date']; ?></td>
													<td style="text-align: right;"><?php echo round(($rows['shipping_tk']),2); ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									<tr>
										<th colspan="4"  style="text-align:right">Total Taka</th>
										<th style="text-align:right"><?php echo round($tot_qty,2); ?></th>
									</tr>
								</table>
								<?php 
							}
							?>	
	
						</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==11){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$total=0;
			$c=0;$sl=0;
			$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			$monthly_report_sql=$conn->query("select item_id,sum(item_qty) qty,sum(price*item_qty) sprice,sum(purchase_price*item_qty) avg_price,(select product_name from product where id=direct_sale.item_id) item_name,(select uom from product where id=direct_sale.item_id) uom from direct_sale where `com_id`=$com_id and in_out_status=0 and is_active=1 and date(insert_date) between '$d1' and '$d2' and order_number is null group by item_id order by qty desc");
			$monthly_report_sql2=$conn->query("select item_id,sum(item_qty) qty,sum(price*item_qty) sprice,sum(purchase_price*item_qty) avg_price,(select product_name from product where id=direct_sale.item_id) item_name,(select uom from product where id=direct_sale.item_id) uom from direct_sale where `com_id`=$com_id and in_out_status=0 and is_active=1 and date(insert_date) between '$d1' and '$d2' and order_number is not null group by item_id order by qty desc");
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;$tsprice=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Item Sales List</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
											<th style="width:10%;text-align:right">Sale Price</th>
											<th style="width:15%;text-align:right">Purchase Price</th>
											<th style="width:10%;text-align:right">Profit(Tk.)</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$tot_qty+=$rows['qty'];
													//$tprofit+=($rows['sprice']-($rows['avg_price']*$rows['qty']));
													$tprofit+=($rows['sprice']-$rows['avg_price']);
													$tsprice+=$rows['sprice'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td><?php echo $rows['item_name']; ?></td>
													<td style="text-align: center;"><?php echo round($rows['qty'],2); ?> <?php echo $rows['uom']; ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']),2); ?></td>
													<td style="text-align: right;"><?php echo round($rows['avg_price'],2); ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']-$rows['avg_price']),2); ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									<tr>
										<th colspan="2"  style="text-align:right">Total Item</th>
										<th style="width:40%;text-align:center"><?php echo round($tot_qty,2); ?></th>
										<th style="width:10%;text-align:right"><?php echo round($tsprice,2); ?></th>
										<th colspan="1"  style="text-align:right">Profit</th>
										<th style="width:10%;text-align:right"><?php echo round($tprofit,2); ?></th>
										
									</tr>
								</table>
								<?php 
							}
							?>	

						<?php 
						$tprofit2=0;$tsale=0;
							if(mysqli_num_rows($monthly_report_sql2)>0){
								?>
								<label>Item Sales List</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
											<th style="width:10%;text-align:right">Sale Price</th>
											<th style="width:15%;text-align:right">Purchase Price</th>
											<th style="width:10%;text-align:right">Profit(Tk.)</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql2)){
													$tot_qty+=$rows['qty'];
													//$tprofit2+=(($rows['sprice'])-($rows['avg_price']*$rows['qty']));
													$tprofit2+=($rows['sprice']-$rows['avg_price']);
													$tsale+=$rows['sprice'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td><?php echo $rows['item_name']; ?></td>
													<td style="text-align: center;"><?php echo round($rows['qty'],2); ?> <?php echo $rows['uom']; ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']),2); ?></td>
													<td style="text-align: right;"><?php echo round($rows['avg_price'],2); ?></td>
													<td style="text-align: right;"><?php echo round(($rows['sprice']-$rows['avg_price']),2); ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									<tr>
										<th colspan="2"  style="text-align:right">Total Item</th>
										<th style="width:40%;text-align:center"><?php echo $tot_qty; ?></th>
										<th style="width:10%;text-align:right"><?php echo round($tsale,2); ?></th>
										<th colspan="1"  style="text-align:right">Profit</th>
										<th style="width:10%;text-align:right"><?php echo round($tprofit2,2); ?></th>
										
									</tr>
								</table>
								<?php 
							}
							?>
							<h2> Total Sales: <b><?php echo round(($tsprice+$tsale),2); ?></b> Taka <h2>
							<h2> Total Profit: <b><?php echo round(($tprofit2+$tprofit),2); ?></b> Taka <h2>
								
							</div>
							
					</div>
				
					<?php 
				
			
			}
			else if($print_type==12 || $print_type==17){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$extra_item=$_REQUEST['extra_item'];
			if($extra_item=='all'){
				$con="";
			}else{
				$con="`item_id` =$extra_item and";
			}
			$total=0;
			$c=0;$sl=0;
			$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if($print_type==12){
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name, sum(`item_qty`) item_qty,sum(`receive_qty`) receive_qty FROM `order_record` WHERE $con `is_active`=1 and `com_id`=$com_id and date(insert_date) between '$d1' and '$d2' group by item_id");
			}else if($print_type==17){
				$d1=$date1[0].'/'.$date1[1].'/'.$date1[2];
				$d2=$date2[0].'/'.$date2[1].'/'.$date2[2];
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name, sum(`item_qty`) item_qty,sum(`delivery_qty`) receive_qty FROM `order_record` WHERE $con `receive_qty`>0 and `item_qty`!=`delivery_qty` and `is_active`=1 and `com_id`=$com_id and assign_date between '$d1' and '$d2' group by item_id");
			}
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Item Not Making (Still Stay <?php echo ($print_type==12)? 'in Showroom' : 'in Factory'; ?>)</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$tpending=($rows['item_qty']-$rows['receive_qty']);
													$item_id=$rows['item_id'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td>
														<?php 
														if($print_type==17){
														?>
														<a href="javascript:void(0)" onclick="showOrderNumberItemWise('<?php echo $item_id; ?>','<?php echo $d1; ?>','<?php echo $d2; ?>')"><?php echo $rows['product_name']; ?></a> <span id="show_ord_num<?php echo $item_id; ?>"></span>
														<?php }else{ ?>
														<?php echo $rows['product_name']; } ?>
													</td>
													<td style="text-align: center;"><?php echo @$tpending; ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									
								</table>
								<?php 
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==14){
			
			$extra_items=explode("#sep#",$_REQUEST['karigor_list']);
			$extra_item=$extra_items[0];
			$monthly_report_sql=$conn->query("SELECT `item_id`,order_number,(select product_name from product where id=order_record.item_id) product_name, receive_qty,assign_date FROM `order_record` WHERE `maker` =$extra_item and `is_active`=1 and receive_qty!=delivery_qty and `com_id`=$com_id");
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Karigor Name wise Pending Status</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Order Number</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Assign Qty</th>
											<th style="width:10%;text-align:center">Assign Date</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td><?php echo $rows['order_number']; ?></td>
													<td><?php echo $rows['product_name']; ?></td>
													<td style="text-align: center;"><?php echo @$rows['receive_qty']; ?></td>
													<td style="text-align: center;"><?php echo @$rows['assign_date']; ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									
								</table>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==23){
			
			$extra_items=explode("#sep#",$_REQUEST['karigor_list']);
			$user_id=$extra_items[0];
			$user_type=$extra_items[1];
			if($user_type==1){ // master id=1
			$item_sql=$conn->query("SELECT sum(item_qty) tot_iqty,sum(master_cutting_qty) tot_cqty from order_record where is_active=1 and master_id=$user_id");
			}else{ //karigor id=2
				$item_sql=$conn->query("SELECT sum(item_qty) tot_iqty,sum(receive_qty) tot_cqty  from order_record where is_active=1 and karigor_id=$user_id");
			}
			
				?>
				<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
						<?php 
						if(mysqli_num_rows($item_sql)>0){
							$row=mysqli_fetch_array($item_sql);
							?>
							<div style="cursor: pointer;font-size: 18px;" onclick="getDetailsPending('<?php echo $user_type; ?>','<?php echo $user_id; ?>')">
								<b>Total Pending:<?php echo ($row['tot_iqty']-$row['tot_cqty']); ?> </b>
							</div>
							<?php 
						}else{
							?>
							<div>
								<b>Total Pending:</b><?php echo '0'; ?> 
							</div>
							<?php 
						}
						?>
					</div>
					<div class="col-xs-12 col-sm-12" id="get_details_pending">
					</div>				
				</div>
				
					<?php 
				
			
			}else if($print_type==24){
			@$pdate =date('d/m/Y');
			$order_type=$_REQUEST['order_type'];
			$com_id=$_SESSION['COM_ID'];
			$list="";
			if($order_type=="urgent"){ // master id=1
			$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,(select cus_name from customer where cus_mobile=ds.cus_mobile) cus_name,ds.cus_mobile umobile,ds.phy_ord_num,ds.amount,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.phy_dv_date IS NULL and ds.occasion=0 and ds.order_type=1 and ds.factory_status not in(1,2) and ds.com_id='$com_id' order by ds.id asc");
			$list="আর্জেন্ট অর্ডার লিস্ট";
			}
			if($order_type=="todays"){ // master id=1
			@$dv_date =date('d/m/Y'); // and ds.sms_status=0
			$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_dv_date,ds.phy_ord_num,ds.amount,ds.cus_name,ds.discount,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.factory_status not in(1,2) and ds.occasion=0 and ds.com_id='$com_id' and ds.fddate='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc");
			$list="আজকের অর্ডার লিস্ট";
			}
			if($order_type=="tomorrow"){
			@$dv_date =date('d/m/Y', strtotime(date('Y-m-d'). ' + 1 days'));
			$list="আগামী কালকের অর্ডার লিস্ট";
			$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.factory_status not in(1,2) and ds.com_id='$com_id' and ds.fddate='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc");
			}
			
			if($order_type=="twodays"){
				$list="২ দিন পরের অর্ডার লিস্ট";
				@$dv_date =date('d/m/Y', strtotime(date('Y-m-d'). ' + 2 days'));
				$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.factory_receive_date,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.com_id='$com_id' and ds.factory_status not in(1,2) and ds.fddate='$dv_date' and ds.phy_dv_date IS NULL order by ds.id asc");
			}
			
			if($order_type=="expireddelivery"){
				$list="Expired ডেলিভারি অর্ডার লিস্ট";
				@$dv_date =date('d/m/Y');
				$psmsquery=$conn->query("select ds.id,ds.sms_status,ds.dv_date,ds.txt_sms,date(ds.insert_date) indate,ds.tagnum,ds.order_type,ds.cus_mobile umobile,ds.phy_ord_num,ds.cus_name,ds.factory_status,ds.fddate from dsms ds where ds.is_active=1 and ds.occasion=0 and ds.com_id='$com_id' and str_to_date(ds.fddate,'%d/%m/%Y') <= str_to_date('$dv_date','%d/%m/%Y') and ds.factory_status not in(1,2) and ds.phy_dv_date IS NULL order by ds.id asc");
			}
				?>
				<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12" style="text-align: center;">
						<span for="" style="font-size: 14px;font-weight: bold;"><?php echo $list; ?></span><br/>
						<span for="">As Said Panjabi Tailors & Fabrics</span><br/>
						
						<span for="">Printing Date: <?php echo $pdate; ?></span>
				<table id="example" border="1" style="border-collapse: collapse;width: 100%;">
				
					<thead>
						<tr>
							<th style="padding-left:5px">অর্ডার নম্বর</th>
							<th style="padding-left:5px">কাস্টমার</th>
							<th style="padding-left:5px">ডেলিভারি</th>
							<th style="padding-left:5px">আইটেম</th>
						</tr>
					</thead>
					<tbody>		
						<?php 
					while($row=mysqli_fetch_array($psmsquery)){
					
					$sms_id=$row['id'];
					$cus_name=$row['cus_name'];
					$dv_date=explode("-",$row['dv_date']);
					$dv_date=$dv_date[2]."/".$dv_date[1]."/".$dv_date[0];
					$dv_date=$row['fddate'];
					@$tagnum=$row['tagnum'];
					
					@$phy_ord_num=$row['phy_ord_num'];
					?>
					<tr>
						<td style="padding-left:5px">
							<span style='cursor: pointer;color:blue;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$row['phy_ord_num']; ?>')">
								<?php echo $phy_ord_num; ?>
							</span>
						</td>
						<td style="padding-left:5px">
							<?php echo $cus_name; ?>
						</td>
						<td style="padding-left:5px">
							<?php echo $dv_date; ?>
						
						</td>
						<td>
						<table id="example" class="">
				
					<tbody>
					<?php 
					
					$chk_com_p=$conn->query("SELECT (select product_name from product where id=sd.item_id) pname,sd.item_qty pqty,sd.order_number,sd.id ord_id,sd.receive_qty,(select user_name from user where id=sd.master_id) masters,(select user_name from user where id=sd.karigor_id) karigor,(select item_qty from wages_details where emp_type=2 and ord_record_tblid=sd.id) making_qty FROM `order_record` sd WHERE sd.com_id=$com_id and sd.is_active=1 and sd.dsms_id=$sms_id");
					while($rrows=mysqli_fetch_array($chk_com_p)){
						$pname=$rrows['pname'];
						$pqty=$rrows['pqty'];
						$order_number=$rrows['order_number'];
						$receive_qty=$rrows['receive_qty'];
						$ord_id=$rrows['ord_id'];
						@$masters=$rrows['masters'];
						@$karigor=$rrows['karigor'];
						@$making_qty=($rrows['making_qty']=="")? 0 : $rrows['making_qty'];
						@$making_qty="<span style='color:blue'>".$making_qty."</span>";
							?>
							<tr>
							<td style="padding-left:5px">
								<?php echo $pname; ?>(<?php echo $making_qty.'/'.$pqty; ?>)(<?php echo $ord_id; ?>)(<?php echo $masters; ?>)(<?php echo $karigor; ?>)
							</td>
						</tr>
							<?php 
					}
					
						?>
						</tbody>
					</table>
						</td>
					</tr>
			<?php } ?>
					</tbody>
				</table>
					</div>
					<div class="col-xs-12 col-sm-12" id="get_details_pending">
					</div>				
				</div>
				
					<?php 
				
			
			}else if($print_type==15){
			
		$order_type=$_REQUEST['order_type'];
			if($order_type=="pending"){
				$monthly_report_sql=$conn->query("SELECT DISTINCT(`order_number`) ord_number,(select user_name from user where id=order_record.maker) karigor,assign_date,date(insert_date) order_date FROM `order_record` WHERE `receive_qty`=0 and is_active=1 and `com_id`=$com_id limit 0,500");
			}else if($order_type=="inprogress"){
				$monthly_report_sql=$conn->query("SELECT DISTINCT(`order_number`) ord_number,(select user_name from user where id=order_record.maker) karigor,assign_date,date(insert_date) order_date FROM `order_record` WHERE `receive_qty`!=`delivery_qty` and is_active=1 and `com_id`=$com_id limit 0,500");
			}else{
				$monthly_report_sql=$conn->query("SELECT DISTINCT(order_record.`order_number`) ord_number,(select user_name from user where id=order_record.maker) karigor,order_record.assign_date,date(order_record.insert_date) order_date,order_record.delivery_date FROM `order_record`,dsms ds WHERE order_record.dsms_id=ds.id and ds.phy_dv_date is null and order_record.`receive_qty`>0 and order_record.`receive_qty`=`delivery_qty` and order_record.is_active=1 and order_record.`com_id`=$com_id");
			}
			
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Karigor Name wise Pending Status</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Order Number</th>
											<th style="width:30%;">Order Date</th>
											<th style="width:10%;text-align:center">Assign By</th>
											<th style="width:10%;text-align:center">Assign Date</th>
											<th style="width:10%;text-align:center;color:green">Delivery Date</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td>
													<span style='color:#ec68d0;cursor: pointer;' data-toggle="modal" data-target="#myModal" onclick="showMeasurement('1','<?php echo @$rows['ord_number']; ?>')"><b><?php echo @$rows['ord_number']; ?></b></span>
													</td>
													<td><?php echo $rows['order_date']; ?></td>
													<td style="text-align: center;"><?php echo @$rows['karigor']; ?></td>
													<td style="text-align: center;"><?php echo @$rows['assign_date']; ?></td>
													<td style="text-align: center;color:green"><?php echo @$rows['delivery_date']; ?></td>
													</tr>
													<?php 
												}
										?>
									</tbody>
									
								</table>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			
		}else if($print_type==9){
			$com_id=($_SESSION['COM_ID']);
			$product=$conn->query("select * from product where is_active=2 and com_id=$com_id and ptype in(1,2) order by id asc limit 2500");
			$product2=$conn->query("select * from product where is_active=2 and com_id=$com_id and ptype in(1,2) order by id asc limit 2500");
			?>
			<div class="row">
				<div class="col-xs-12 col-sm-4" style="">
					<label for="comment" class="txt_color">Item Name</label>
					<select id="item_name" class="form-control select2">
						<option value="">Select One</option>
						<?php 
						if(mysqli_num_rows($product2)>0){
						
							while($rows2=mysqli_fetch_array($product2)){
								?>
								<option value="<?php echo $rows2['item_code']; ?>"><?php echo $rows2['product_name']; ?></option>
								<?php 
							}
						}
								?>
					</select>
				</div>	
				<div class="col-xs-12 col-sm-4" style="">
					<label for="comment" class="txt_color">Item Code</label>
					<input type="text" class="form-control" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: center;" autocomplete="off" name="tftotal_tk" id="item_code" required/>
				</div>	
				<button onclick="searchStockItem();" style="margin-top: 25px;;margin-right:5px" name="btn" value="sub" id="save_expense" class="btn btn-success">Search</button>
				<span id="expense_sms"></span>
			</div>
			<table style="width:100%" border="1">
				<tr>
					<th style="text-align:center">Sl</th>
					<th style="padding-left:4px">Item Name</th>
					<th style="text-align:center">Item Code</th>
					<th style="text-align:center">Present Stock</th>
					<th style="text-align:right;padding-right:4px">Purchase Price</th>
					<th style="text-align:right;padding-right:4px">Selling Price</th>
				</tr>
				<tbody id="stock_item">
			<?php 
			if(mysqli_num_rows($product)>0){
						$i=1;$tqty=0;$ttaka=0;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
								$tqty+=$rows['stock_qty'];
								$ttaka+=round(($rows['stock_qty']*$rows['purchase_price']),2);
						?>
							<tr>
								<td style="text-align:center">
									<?php 
										echo $j;
									?>
								</td>
								<td style="padding-left:4px">
								<?php echo $rows['product_name']; ?>
								</td>
								
								<td style="text-align:center">
								<?php echo $rows['item_code']; ?>
								</td>
								<td style="text-align:center">
								<?php echo ($rows['stock_qty']<$_SESSION['SAFETY_STOCK'])? "<span style='color:red'>".$rows['stock_qty']."</sapn>" : $rows['stock_qty']; ?><p style="font-size:8px;color:blue"><?php echo $rows['uom']; ?></p>
								</td>
								<td style="text-align:right;padding-right:4px"><?php echo $rows['purchase_price']; ?></td>
								<td style="text-align:right;padding-right:4px">
								 <span style="<?php echo ($rows['purchase_price']>=$rows['selling_price'])? 'color:red': ''; ?>"><?php echo $rows['selling_price']; ?></span>
								</td>
								
							</tr>
						<?php 
							}
							?>
							<tr>
								<td colspan="3" style="text-align: right;font-weight: bold;">
									Total Stock Qty & Price: 
								</td>
								<td style="text-align: center;font-weight: bold;">
									<?php echo $tqty; ?>
								</td>
								<td style="text-align: right;font-weight: bold;">
									<?php echo $ttaka; ?>
								</td>
							</tr>
						</tbody>
						</table>
							<?php 
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
			
			}else if($print_type==25){
			$com_id=($_SESSION['COM_ID']);
			$date1=date('Y-m-d');
				$order_listsql="SELECT count(ds.id) tot_order FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date is null and date(ds.insert_date)='$date1'";
				$order_list=$conn->query($order_listsql);
				$order_rows=mysqli_fetch_array($order_list);
				
				$deli_listsql="SELECT count(ds.id) tot_order FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date='$date1'";
				$deli_list=$conn->query($deli_listsql);
				$deli_rows=mysqli_fetch_array($deli_list);
				
				 $order_delsql="SELECT ds.id,ds.phy_ord_num,(select sum(amount) from accounting where dsms_id=ds.id and date(insert_date)=date(ds.phy_dv_date) and is_active=1 and delivery_status in(1)) taka,(select payment_type from accounting where dsms_id=ds.id and date(insert_date)=date(ds.phy_dv_date) and is_active=1 and delivery_status in(1) limit 0,1) payment_type FROM dsms ds WHERE ds.is_active=1 and com_id=$com_id and ds.phy_dv_date='$date1'";
				$order_del=$conn->query($order_delsql);
				
					
			  $method_listsql="SELECT sum(`amount`) method_tk,method_name FROM `transaction` WHERE `com_id`=$com_id and is_active=1 and date(insert_date)='$date1' and `status`=1 group by method_name";
			  $method_list=$conn->query($method_listsql);
			  $receivable_listsql="SELECT `amount` receive_tk,remarks FROM `transaction` WHERE `com_id`=$com_id and is_active=1 and date(insert_date)='$date1' and `status`=1 and transaction_type in(1,2)";
					
				
				
				$receivable_list=$conn->query($receivable_listsql);
				$direct_salesql="SELECT ds.total_receive,ds.cus_mobile,ds.payment_type,(select cus_name from customer where cus_mobile=ds.cus_mobile and is_active=1 limit 0,1) cus_name,ds.id FROM direct_sale_head ds WHERE ds.is_active=1 and ds.is_order=0 and ds.in_out_status=0 and ds.com_id=$com_id and date(ds.insert_date)='$date1'";
				$direct_sale=$conn->query($direct_salesql);
				$expensesql="SELECT ex.expense,ex.expense_type,ex.remarks,method,(select expense from expense_type where id=ex.expense_type) ex_type FROM expenses ex WHERE ex.is_active=1 and com_id=$com_id and date(insert_date)='$date1'";
				$expense=$conn->query($expensesql);
				$wasessql="SELECT ex.taka expense,(select user_name from user where id=ex.emp_id) emp_name FROM wages_details ex WHERE ex.is_active=1 and ex.com_id=$com_id and ex.status=1 and date(ex.insert_date)='$date1'";
				$wases=$conn->query($wasessql);
				
				$only_fab_sql="select (pay_tbl.pay_only_fab+dsale_tbl.only_fab+dsale_tbl_ord.ord_tk) fab_total_taka from (SELECT CASE WHEN sum(`taka`)>0 THEN sum(`taka`) ELSE 0 END  pay_only_fab FROM `only_febrics_tk` WHERE `is_active`=1 and date(`insert_date`)='$date1') pay_tbl,
					(SELECT CASE WHEN sum(`total_receive`)>0 THEN sum(`total_receive`) ELSE 0 END only_fab FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=0 and date(`insert_date`)='$date1') dsale_tbl,
					(SELECT CASE WHEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END)>0 THEN sum(CASE WHEN `total_receive`<=`f_total` THEN total_receive ELSE f_total END) ELSE 0 END ord_tk FROM `direct_sale_head` WHERE `is_active`=1 and `is_order`=1 and date(`insert_date`)='$date1') dsale_tbl_ord";
				$only_fab_row=$conn->query($only_fab_sql);
				
			?>
			<div style='overflow: hidden;float: left;margin-top: 15px;'>
				<span style='font-weight: bold;font-size: 18px;color:#7a14c8;'>Total Order: <?php echo $order_rows['tot_order']; ?></span><br/>
				<span style='font-weight: bold;font-size: 18px;color:#7a14c8;'>Total Delivery: <?php echo $deli_rows['tot_order']; ?></span><br/>
				<span style='font-weight: bold;font-size: 18px;color:#a01f1f;'>Todays Sales: 5000</span><br/>
				<span style='font-weight: bold;font-size: 18px;'>Total Expense: 34</span><br/>
				<span style='font-weight: bold;font-size: 18px;color: blue;'>Cash in Box: 34</span><br/>
			</div>
			<?php
			
		}else if($print_type==18){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$extra_item=$_REQUEST['extra_item'];
			
			$total=0;
			$c=0;$sl=0;
			$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if($extra_item=='order'){
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name, sum(`item_qty`) item_qty,sum(`receive_qty`) receive_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and date(insert_date) between '$d1' and '$d2' group by item_id");
			}else if($extra_item=="receive"){
				$d1=$date1[0].'/'.$date1[1].'/'.$date1[2];
				$d2=$date2[0].'/'.$date2[1].'/'.$date2[2];
				//echo "SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name, sum(`receive_qty`) item_qty FROM `order_record` WHERE `receive_qty`>0 and `is_active`=1 and `com_id`=$com_id and assign_date between '$d1' and '$d2' group by item_id";
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name, sum(`receive_qty`) item_qty FROM `order_record` WHERE `receive_qty`>0 and `is_active`=1 and `com_id`=$com_id and assign_date between '$d1' and '$d2' group by item_id");
			}else if($extra_item=="delivery"){
				
				//echo "SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name,sum(`item_qty`) item_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and dsms_id in (select id from dsms where is_active=1 and phy_ord_num between '$d1' and '$d2') group by item_id";
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name,sum(`item_qty`) item_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and dsms_id in (select id from dsms where is_active=1 and phy_dv_date between '$d1' and '$d2') group by item_id");
			}else if($extra_item=="only_delivery"){
				
				//echo "SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name,sum(`item_qty`) item_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and dsms_id in (select id from dsms where is_active=1 and phy_ord_num between '$d1' and '$d2') group by item_id";
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name,sum(`item_qty`) item_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and dsms_id in (select id from dsms where is_active=1 and dv_date between '$d1' and '$d2' and phy_dv_date is null) group by item_id");
			}else if($extra_item=="factory_delivery"){
				$d1=$date1[0].'/'.$date1[1].'/'.$date1[2];
				$d2=$date2[0].'/'.$date2[1].'/'.$date2[2];
				$monthly_report_sql=$conn->query("SELECT `item_id`,(select product_name from product where id=order_record.item_id) product_name,sum(`item_qty`) item_qty FROM `order_record` WHERE `is_active`=1 and `com_id`=$com_id and delivery_date between '$d1' and '$d2' group by item_id");
			}
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Item Status</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Item Name</th>
											<th style="width:10%;text-align:center">Qty</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													//$tpending=($rows['item_qty']-$rows['receive_qty']);
													$item_id=$rows['item_id'];
													$tot_qty+=$rows['item_qty'];
													$c=$sl++;
													?>
													<tr>
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td>
														
														<a href="javascript:void(0)" onclick="showOrderNumberItemWise('<?php echo $item_id; ?>','<?php echo $d1; ?>','<?php echo $d2; ?>','<?php echo $extra_item; ?>')"><?php echo $rows['product_name']; ?></a> <span id="show_ord_num<?php echo $item_id; ?>"></span>
														
													</td>
													<td style="text-align: center;"><?php echo @$rows['item_qty']; ?></td>
													</tr>
													<?php 
												}
										?>
										<tr>
											<td colspan="2" style="text-align: right;font-weight:bold">Total</td>
											
											<td style="text-align: center;font-weight:bold"><?php echo @$tot_qty; ?></td>
										</tr>
									</tbody>
									
								</table>
								<?php 
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==19){
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			$status=$_REQUEST['extra_item'];
			$emp_list=$_REQUEST['karigor_list'];
			$con="";$con2="";$con3="";
			if($emp_list!=""){
				$con.=" and emp_id=$emp_list ";
				$con3.=" and emp_id=$emp_list ";
			}
			$total=0;
			$c=0;$sl=0;
			//$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d1="";
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if(@$_REQUEST['date1']!=""){
				$d1=$date1[2]."-".$date1[1]."-".$date1[0];
				$con.=" and date(insert_date) between '$d1' and '$d2'";
				$con3.=" and date(insert_date)<='$d2'";
				$con2.=" and date(insert_date) between '$d1' and '$d2'";
			}else{
				$con3.=" and date(insert_date)<='$d2'";
				$con.=" and date(insert_date)<='$d2'";
			}
			if($status=='earning'){
				$statuss=0;
				$monthly_report_sql=$conn->query("SELECT emp_id,(select user_name from user where user.id=wages_details.emp_id) emp_name,
					(select emp_type from user where user.id=wages_details.emp_id) emp_type,
					(select mobile from user where user.id=wages_details.emp_id) emp_mobile,

					(select sum(taka) from wages_details ws where ws.emp_id=wages_details.emp_id and `is_active`=1 and `com_id`=$com_id and status=0 $con3) earning,

					(select sum(taka) from wages_details ws where ws.emp_id=wages_details.emp_id and `is_active`=1 and `com_id`=$com_id and status=1 $con3) payment

					FROM `wages_details` WHERE `is_active`=1 and emp_id in(select id from user where is_active=1 and emp_type in(1,2) and salary_type=1) and `com_id`=$com_id $con3 group by emp_id order by earning desc");
			}else if($status=="payable"){
				$statuss=1;
				$monthly_report_sql=$conn->query("SELECT (select user_name from user where user.id=wages_details.emp_id) emp_name,(select emp_type from user where user.id=wages_details.emp_id) emp_type,(select mobile from user where user.id=wages_details.emp_id) emp_mobile, sum(`taka`) emp_tk,emp_id FROM `wages_details` WHERE `is_active`=1 and `com_id`=$com_id and status=$statuss $con group by emp_id order by emp_tk desc");
			}
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($monthly_report_sql)>0){
								?>
								<label>Employee Earning/Payable Report </label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:30%;">Employee Name</th>
											<th style="width:30%;text-align:center">Employee Type</th>
											<th style="width:10%;text-align:right">মজুরি/জমা(Tk.)</th>
											<th style="width:10%;text-align:right">মজুরি প্রদান(Tk.)</th>
											<th style="width:10%;text-align:right">বকেয়া(Tk.)</th>
											
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;$tot_paymet=0;
											while($rows=mysqli_fetch_array($monthly_report_sql)){
													$emp_ids=$rows['emp_id'];
													$tot_qty+=$rows['earning'];
													$tot_paymet+=$rows['payment'];
													$c=$sl++;
													?>
													<tr style="color: <?php 
														if($rows['emp_type']==1){
															echo "blue";
														}else if($rows['emp_type']==3){
															echo "#b60bc1;";
														}
														?>">
														<td style="text-align: center;"><?php echo $c; ?></td>
														<td>
															<span style='cursor: pointer;' data-toggle="modal" data-target="#myModal" onclick="showEmployeesDetails('<?php echo $d1; ?>','<?php echo $d2; ?>','earning','<?php echo $emp_ids; ?>','<?php echo $rows['emp_name'].'('.$rows['emp_mobile'].')'; ?>')">
																<?php echo $rows['emp_name'].'('.$rows['emp_mobile'].')'; ?>
															</span>
														</td>
														<td style="text-align: center;">
															<?php if($rows['emp_type']==1){ echo "Master"; }else if($rows['emp_type']==2){ echo "Karigor"; }else{ echo "Staff";} ?>
														</td>
														<td style="text-align: right;">
															<span style='cursor: pointer;' data-toggle="modal" data-target="#myModal" onclick="showEmployeesDetails('<?php echo $d1; ?>','<?php echo $d2; ?>','earning','<?php echo $emp_ids; ?>','<?php echo $rows['emp_name'].'('.$rows['emp_mobile'].')'; ?>')">
																<?php echo @$rows['earning']; ?>/=
															</span>
														</td>
														<td style="text-align: right;">
															<span style='cursor: pointer;' data-toggle="modal" data-target="#myModal" onclick="showEmployeesDetails('<?php echo $d1; ?>','<?php echo $d2; ?>','payable','<?php echo $emp_ids; ?>','<?php echo $rows['emp_name'].'('.$rows['emp_mobile'].')'; ?>')">
																<?php echo @$rows['payment']; ?>/=
															</span>
														</td>
														<td style="text-align: right;"><?php echo (@$rows['earning']-@$rows['payment']); ?>/=</td>
													</tr>
													<?php 
												}
										?>
										<tr>
										<td colspan="3" style="text-align: right;font-weight:bold">
											মোট মজুরি | প্রদান | বকেয়া: 
										</td>
										<td style="text-align: right;font-weight:bold"><?php echo @$tot_qty; ?>/=</td>
										<td style="text-align: right;font-weight:bold"><?php echo @$tot_paymet; ?>/=</td>
										<td style="text-align: right;font-weight:bold"><?php echo ($tot_qty-$tot_paymet); ?>/=</td>
										</tr>
									</tbody>
									
								</table>
								<?php 
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==26){
				$com_id=($_SESSION['COM_ID']);
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			//$status=$_REQUEST['extra_item'];
			$emp_list=$_REQUEST['karigor_list'];
			$ord_number=$_REQUEST['extra_item'];
			$con=""; $con2="";
			if($emp_list!=""){
				$con.=" and emp_id='$emp_list' ";
			}
			if($ord_number!=""){
				$con.=" and order_num='$ord_number' ";
				$con2=" and order_num='$ord_number' ";
			}
			$total=0;
			$c=0;$sl=0;
			//$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d1="";
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if(@$_REQUEST['date1']!=""){
				$d1=$date1[2]."-".$date1[1]."-".$date1[0];
				$con.=" and date(insert_date) between '$d1' and '$d2'";
			}else{
				$con.=" and date(insert_date)<='$d2'";
			}
			
				$assign_sql=$conn->query("SELECT emp_id,emp_type,(select user_name from user where user.id=wages_details.emp_id) emp_name
			 FROM `wages_details` WHERE `is_active`=1 and `com_id`=$com_id
			and status=0 $con GROUP by `emp_id`,emp_type");
			
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								
								<label>Employee Earning/Payable Report </label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:10%;text-align:center">Date</th>
											<th style="width:20%;">Employee Name</th>
											<th style="width:6%;text-align:center">Type</th>
											<th style="width:15%;">Item Name</th>
											<th style="width:22%;">Order No</th>
											<th style="width:6%;text-align:center">Item Qty</th>
											<th style="width:8%;text-align:right">Rate</th>
											<th style="width:8%;text-align:right">Total(Tk.)</th>
										</tr>
									</thead>
									<tbody>
										<?php 
									$tprofit=0;
									$sl=1;$tot_qty=0;
									if(mysqli_num_rows($assign_sql)>0){
										
											while($rows=mysqli_fetch_array($assign_sql)){
													
													$emp_name=$rows['emp_name'];
													$emp_id=$rows['emp_id'];
													$emp_type=($rows['emp_type']==1)? 'Master' : 'Karigor';
													
															
													$assign_qty_sql=$conn->query("SELECT sum(item_qty) iqty,date(insert_date) assign_date,
													(select product_name from product where id=wages_details.item_ids) item_name, 
													(select price from employees_price_setup where emp_id=wages_details.emp_id and item_id=wages_details.item_ids and is_active=1 order by id desc limit 0,1) irate,
													sum(`taka`) wages,Group_concat( distinct `order_num`) memo_no
													FROM `wages_details` WHERE `is_active`=1 and `com_id`=$com_id and emp_id=$emp_id $con2 and status=0 and date(insert_date) between '$d1' and '$d2' GROUP by item_ids,assign_date order by assign_date asc");
													if(mysqli_num_rows($assign_qty_sql)>0){
														while($assign_row=mysqli_fetch_array($assign_qty_sql)){
															$c=$sl++;
															$memo_no=$assign_row['memo_no'];
															$iqty=$assign_row['iqty'];
															$tot_qty+=$assign_row['iqty'];
															$item_name=$assign_row['item_name'];
															$irate=$assign_row['irate'];
															$wages=$assign_row['wages'];
															$tprofit+=$assign_row['wages'];
															$assign_date=$assign_row['assign_date'];
													?>
													<tr style="color:<?php echo ($emp_type=='Master')? 'blue' : '';?>">
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td style="text-align: center;"><?php echo $assign_date; ?></td>
													<td style=""><?php echo $emp_name; ?></td>
													<td style="text-align: center;"><?php echo $emp_type; ?></td>
													<td style=""><?php echo $item_name; ?></td>
													<td style=""><?php echo $memo_no; ?></td>
													<td style="text-align: center;"><?php echo $iqty; ?></td>
													<td style="text-align: right;"><?php echo $irate; ?></td>
													<td style="text-align: right;"><?php echo $wages; ?></td>
													</tr>
													<?php 
														}
													}
												}
											}
										?>
										
									</tbody>
										<tr>
										<td colspan="6" style="text-align: right;font-weight:bold">
											Total Qty|Taka: 
										</td>
										<td style="text-align: center;font-weight:bold"><?php echo @$tot_qty; ?></td>
										<td colspan="1" style="text-align: right;font-weight:bold">
											
										</td>
										<td style="text-align: right;font-weight:bold"><?php echo @$tprofit; ?></td>
										</tr>
								</table>
							
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==28){
				$com_id=($_SESSION['COM_ID']);
				$date1=explode("/",$_REQUEST['date1']);
				$date2=explode("/",$_REQUEST['date2']);
				//$status=$_REQUEST['extra_item'];
				$emp_list=$_REQUEST['karigor_list'];
				$ord_number=$_REQUEST['extra_item'];
				$con=""; $con2="";
			if($emp_list!=""){
				$con.=" and emp_id='$emp_list' ";
			}
			if($ord_number!=""){
				$con.=" and item_ids='$ord_number' ";
				$con2=" and item_ids='$ord_number' ";
			}
			
			$total=0;
			$c=0;$sl=0;
			//$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d1="";
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if(@$_REQUEST['date1']!=""){
				$d1=$date1[2]."-".$date1[1]."-".$date1[0];
				$con.=" and date(insert_date) between '$d1' and '$d2'";
			}else{
				$con.=" and date(insert_date)<='$d2'";
			}
			
				$assign_sql=$conn->query("SELECT emp_id,emp_type,(select user_name from user where user.id=wages_details.emp_id) emp_name
			 FROM `wages_details` WHERE `is_active`=1 and `com_id`=$com_id
			and status=0 $con GROUP by `emp_id`,emp_type");
			
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								
								<label>Employee Earning/Payable Report </label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:10%;text-align:center">Date</th>
											<th style="width:20%;">Employee Name</th>
											<th style="width:6%;text-align:center">Type</th>
											<th style="width:15%;">Item Name</th>
											<th style="width:22%;">Order No</th>
											<th style="width:6%;text-align:center">Item Qty</th>
											<th style="width:8%;text-align:right">Rate</th>
											<th style="width:8%;text-align:right">Total(Tk.)</th>
										</tr>
									</thead>
									<tbody>
										<?php 
									$tprofit=0;
									$sl=1;$tot_qty=0;
									if(mysqli_num_rows($assign_sql)>0){
										
											while($rows=mysqli_fetch_array($assign_sql)){
													
													$emp_name=$rows['emp_name'];
													$emp_id=$rows['emp_id'];
													$emp_type=($rows['emp_type']==1)? 'Master' : 'Karigor';
													
															
													$assign_qty_sql=$conn->query("SELECT sum(item_qty) iqty,date(insert_date) assign_date,
													(select product_name from product where id=wages_details.item_ids) item_name, 
													(select price from employees_price_setup where emp_id=wages_details.emp_id and item_id=wages_details.item_ids and is_active=1 order by id desc limit 0,1) irate,
													sum(`taka`) wages,Group_concat( distinct `order_num`) memo_no
													FROM `wages_details` WHERE `is_active`=1 and `com_id`=$com_id and emp_id=$emp_id $con2 and status=0 and date(insert_date) between '$d1' and '$d2' GROUP by item_ids,assign_date order by assign_date asc");
													if(mysqli_num_rows($assign_qty_sql)>0){
														while($assign_row=mysqli_fetch_array($assign_qty_sql)){
															$c=$sl++;
															$memo_no=$assign_row['memo_no'];
															$iqty=$assign_row['iqty'];
															$tot_qty+=$assign_row['iqty'];
															$item_name=$assign_row['item_name'];
															$irate=$assign_row['irate'];
															$wages=$assign_row['wages'];
															$tprofit+=$assign_row['wages'];
															$assign_date=$assign_row['assign_date'];
													?>
													<tr style="color:<?php echo ($emp_type=='Master')? 'blue' : '';?>">
													<td style="text-align: center;"><?php echo $c; ?></td>
													<td style="text-align: center;"><?php echo $assign_date; ?></td>
													<td style=""><?php echo $emp_name; ?></td>
													<td style="text-align: center;"><?php echo $emp_type; ?></td>
													<td style=""><?php echo $item_name; ?></td>
													<td style=""><?php echo $memo_no; ?></td>
													<td style="text-align: center;"><?php echo $iqty; ?></td>
													<td style="text-align: right;"><?php echo $irate; ?></td>
													<td style="text-align: right;"><?php echo $wages; ?></td>
													</tr>
													<?php 
														}
													}
												}
											}
										?>
										
									</tbody>
										<tr>
										<td colspan="6" style="text-align: right;font-weight:bold">
											Total Qty|Taka: 
										</td>
										<td style="text-align: center;font-weight:bold"><?php echo @$tot_qty; ?></td>
										<td colspan="1" style="text-align: right;font-weight:bold">
											
										</td>
										<td style="text-align: right;font-weight:bold"><?php echo @$tprofit; ?></td>
										</tr>
								</table>
							
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==29){
				$com_id=($_SESSION['COM_ID']);
				
				
				$order_number=$_REQUEST['order_number'];
				$con=""; $con2="";
			if($order_number!=""){
				$con.=" and order_number='$order_number' ";
			}
			
			
			$total=0;
			$c=0;$sl=0;
			//$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d1="";
			
			if(@$_REQUEST['date1']!="" && $_REQUEST['date2']!=""){
				$date1=explode("/",$_REQUEST['date1']);
				$date2=explode("/",$_REQUEST['date2']);
				$d1=$date1[2]."-".$date1[1]."-".$date1[0];
				$d2=$date2[2]."-".$date2[1]."-".$date2[0];
				$con.=" and date(insert_date) between '$d1' and '$d2'";
			}
			
				$assign_sql=$conn->query("SELECT id,`order_number`,item_qty,(select product_name from product where id=order_record.item_id) item_name FROM `order_record` WHERE `is_active`=1 $con");
			
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
						
						<?php 
					$tprofit=0;
					$sl=1;$tot_qty=0;
					if(mysqli_num_rows($assign_sql)>0){
						
							while($rows=mysqli_fetch_array($assign_sql)){
									
									$ord_tbl_id=$rows['id'];
									$order_number=$rows['order_number'];
									$item_name=$rows['item_name'];
									$item_qty=$rows['item_qty'];
								
									?>
								<div style="text-align: center;font-weight: bold;display: block; page-break-before: always;">
									<p><?php echo $order_number; ?></p>
									<img src='barcode.php?codetype=Code128&size=30&text=<?php echo $ord_tbl_id.'#sep#'.$order_number.'#sep#123456789123456789';?>' width='180px;' height='30px' style="margin-top: -10px;">
										 <p style="margin-top: 5px;"><?php echo $item_name.'('.$item_qty.')'; ?></p>
								</div>
									<?php 
								
								}
							}
						?>
								
					</div>
							
					</div>
				
					<?php 
				
			
			}else if($print_type==16){
			
			echo $expense_type=$_REQUEST['expense_type'];
			$date1=explode("/",$_REQUEST['date1']);
			$date2=explode("/",$_REQUEST['date2']);
			
			$d1=$date1[2]."-".$date1[1]."-".$date1[0];
			$d2=$date2[2]."-".$date2[1]."-".$date2[0];
			if($expense_type==""){
				$expense_type_sql=$conn->query("SELECT sum(`expense`) extk,expense_type,(select et.expense from expense_type et where et.id=expenses.expense_type) expense_title FROM `expenses` WHERE `is_active`=1 and date(`insert_date`) BETWEEN '$d1' and '$d2' GROUP by `expense_type`");
			}else{
				$expense_type_sql=$conn->query("SELECT sum(`expense`) extk,expense_type,(select et.expense from expense_type et where et.id=expenses.expense_type) expense_title FROM `expenses` WHERE `is_active`=1 and `expense_type`=$expense_type and date(`insert_date`) BETWEEN '$d1' and '$d2'");
			}
			
			
				?>
					<div class="row" style="background:white">
					<div class="col-xs-12 col-sm-12">
								
								<?php 
							$tprofit=0;
							if(mysqli_num_rows($expense_type_sql)>0){
								?>
								<label>Expense Report</label>
								<table id="dynamic-table" class="table table-striped table-bordered table-hover">
									<thead>
										<tr>
											<th style="width:5%;text-align: center;">Sl</th>
											<th style="width:75%;">Expense Type</th>
											<th style="width:20%;text-align:right">Taka/=</th>
										</tr>
									</thead>
									<tbody>
										<?php 
											$sl=1;$tot_qty=0;
											while($rows=mysqli_fetch_array($expense_type_sql)){
													$c=$sl++;
													$tot_qty+=$rows['extk'];
													?>
													<tr>
														<td style="text-align: center;"><?php echo $c; ?></td>
														<td style='cursor: pointer;font-weight:bold' data-toggle="modal" data-target="#myModal" onclick="showExpenseBreakdown('<?php echo $rows['expense_title']; ?>','<?php echo @$rows['expense_type']; ?>','<?php echo @$d1; ?>','<?php echo @$d2; ?>')">
															<?php echo $rows['expense_title']; ?>
														</td>
														<td style="text-align: right;"><?php echo $rows['extk']; ?>/=</td>
													</tr>
													<?php 
												}
										?>
										<tr>
											<td colspan="2" style="text-align: right;font-weight:bold">Total</td>
											<td style="text-align: right;font-weight:bold"><?php echo $tot_qty; ?>/=</td>
										</tr>
									</tbody>
									
								</table>
								<?php 
							}else{
								echo "No Item Found!";
							}
							?>	
	
					</div>
							
					</div>
				
					<?php 
				
			
			}else{
				echo "<span style='color:red'>Invalid Order/Serial No.</span>";
			}
		
	}
	
	if(isset($_REQUEST['typwWiseUser'])){
		$user_type=$_REQUEST['user_type'];
		$com_id=($_SESSION['COM_ID']);
		$product=$conn->query("select * from user where is_active=1 and com_id=$com_id and user_type=$user_type and emp_type is null order by id asc");
			if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
						?>
							<tr>
								<td><button onclick='delEmployee(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button></td>
								<td>
								<input readonly type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','5');" value="<?php echo $rows['user_name']; ?>" id="user_name<?php echo $j; ?>"/>
								</td>
								<td><input readonly type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','1');" value="<?php echo $rows['mobile']; ?>" id="mobile<?php echo $j; ?>"/></td>
								<td><input readonly type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','2');" value="<?php echo $rows['log_user']; ?>" id="log_user<?php echo $j; ?>"/></td>
								<td><input readonly type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','3');" value="<?php echo $rows['pass']; ?>" id="pass<?php echo $j; ?>"/></td>
								<td><?php echo Converter::en2bn(getUserWiseSale($rows['id'],0))."/="; ?><br/><b><?php echo Converter::en2bn(getUserWiseSale($rows['id'],1))."/="; ?></b></td>
								
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
	}
	
	if(isset($_REQUEST['cuttingDone'])){
		date_default_timezone_set("Asia/Dhaka");
		$cdate=date('d/m/Y');
		@$cutting_barcode=explode('#sep#',trim($_REQUEST['cutting_barcode']));
		$ord_tbl_code=$cutting_barcode[0];
		
		 $cutting_item=$conn->query("select id,item_qty,item_id,order_number,(select product_name from product where id=order_record.item_id) item_name from order_record where is_active=1 and `master_cutting_qty`<item_qty and id='$ord_tbl_code'");
		if(mysqli_num_rows($cutting_item)>0){ 
			$rows=mysqli_fetch_array($cutting_item);
			$ord_tbl_id=$rows['id'];
			$item_qty=$rows['item_qty'];
			$item_id=$rows['item_id'];
			$item_name=$rows['item_name'];
			$order_number=$rows['order_number'];
			echo $ord_tbl_id.'#sep#'.$item_qty.'#sep#'.$item_id.'#sep#'.$item_name.'#sep#'.$order_number;
			
				mysqli_close($conn);
			}else{
				echo 2;
			} 
			
	}
	
	if(isset($_REQUEST['makingDone'])){
		date_default_timezone_set("Asia/Dhaka");
		$cdate=date('d/m/Y');
		@$making_barcode=explode('#sep#',trim($_REQUEST['making_barcode']));
		$ord_tbl_code=$making_barcode[0];
		
		
		 $cutting_item=$conn->query("select id,item_qty,item_id,order_number,(select product_name from product where id=order_record.item_id) item_name from order_record where is_active=1 and `receive_qty`<master_cutting_qty and id='$ord_tbl_code'");
		if(mysqli_num_rows($cutting_item)>0){ 
			$rows=mysqli_fetch_array($cutting_item);
			$ord_tbl_id=$rows['id'];
			$item_qty=$rows['item_qty'];
			$item_id=$rows['item_id'];
			$item_name=$rows['item_name'];
			$order_number=$rows['order_number'];
			echo $ord_tbl_id.'#sep#'.$item_qty.'#sep#'.$item_id.'#sep#'.$item_name.'#sep#'.$order_number;
			
				mysqli_close($conn);
			}else{
				echo 2;
			} 
			
	}
	
	if(isset($_REQUEST['receiveDone'])){
		date_default_timezone_set("Asia/Dhaka");
		$cdate=date('d/m/Y');
		@$receive_barcode=explode('#sep#',trim($_REQUEST['receive_barcode']));
		$ord_tbl_code=$receive_barcode[0];
		
		$cutting_item=$conn->query("select id,item_qty,item_id,order_number,(select product_name from product where id=order_record.item_id) item_name,(select cus_name from dsms where id=order_record.dsms_id limit 0,1) cus_name,(select cus_mobile from dsms where id=order_record.dsms_id limit 0,1) cus_mobile from order_record where is_active=1 and `delivery_qty`<receive_qty and id='$ord_tbl_code'");
		if(mysqli_num_rows($cutting_item)>0){ 
			$rows=mysqli_fetch_array($cutting_item);
			$ord_tbl_id=$rows['id'];
			$item_qty=$rows['item_qty'];
			$item_id=$rows['item_id'];
			$item_name=$rows['item_name'];
			$order_number=$rows['order_number'];
			$cus_name=$rows['cus_name'];
			$cus_mobile=$rows['cus_mobile'];
			echo $ord_tbl_id.'#sep#'.$item_qty.'#sep#'.$item_id.'#sep#'.$item_name.'#sep#'.$order_number.'#sep#'.$cus_name.'#sep#'.$cus_mobile;
			
				mysqli_close($conn);
			}else{
				echo 2;
			} 
			
	}
	
	if(isset($_REQUEST['addEmpPrice'])){
		$user_id=$_SESSION['USER_ID'];
		$com_id=($_SESSION['COM_ID']);
		$item_id=$_REQUEST['item_id'];
		$emp_id=$_REQUEST['emp_id'];
		$emp_type=$_REQUEST['emp_type'];
		$emp_price=($_REQUEST['emp_price']=="")? '0' : trim($_REQUEST['emp_price']);
		$user_price=$conn->query("SELECT * FROM `employees_price_setup` WHERE item_id=$item_id and emp_id='$emp_id' and is_active=1 order by id desc limit 0,1");
		if(mysqli_num_rows($user_price)>0){
			$rows=mysqli_fetch_array($user_price);
			$old_price=$rows['price'];
			if($emp_price!=$old_price){
				$order_details=$conn->query("insert into employees_price_setup(item_id,emp_id,emp_type,price,insert_by) values('$item_id','$emp_id','$emp_type','$emp_price','$user_id')");
			}else{
				$order_details=1;
			}
		}else{
			$order_details=$conn->query("insert into employees_price_setup(item_id,emp_id,emp_type,price,insert_by) values('$item_id','$emp_id','$emp_type','$emp_price','$user_id')");
		}
		if($order_details){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['employeePriceSetup'])){
		$com_id=($_SESSION['COM_ID']);
		$item_id=$_REQUEST['item_id'];
		$item_name=$_REQUEST['item_name'];
		$order_details=$conn->query("SELECT user.*,(select price from employees_price_setup where emp_id=user.id and is_active=1 and item_id='$item_id' order by id desc limit 0,1) emp_price FROM `user` WHERE com_id=$com_id and is_active=1 and emp_type in(1,2) and salary_type=1 order by emp_type desc");
		
		?>
		<label>Item: <?php echo $item_name.'['.$item_id.']'; ?></label>
		<table id="dynamic-table" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th style="width:5%;text-align: center;">Sl</th>
					<th style="width:25%;">Employee</th>
					<th style="width:10%;text-align:center">Type</th>
					<th style="width:20%;"><span style="float: left;color: blue;text-decoration: underline;font-size: 12px;cursor:pointer" onclick="fillOutAll();"><i>same</i></span><span style="float: right;">Wages (Tk.)</span></th>
					<th style="width:10%;text-align:center"><button onclick="addEmpPrice('<?php echo $item_id; ?>');" name="btn" id="asrcbtn" value="sub" class="btn btn-success">Save</button></th>
				</tr>
			</thead>
			<tbody>
				<?php 
					$sl=1;$tot_qty=0;
				if(mysqli_num_rows($order_details)>0){
					while($rows=mysqli_fetch_array($order_details)){
							$c=$sl++;
						?>
							<tr style="<?php echo ($rows['emp_type']==1)? 'color:blue' : ''; ?>">
								<td style="text-align: center;"><?php echo $c; ?></td>
								<td>
									<?php echo $rows['user_name']; ?>
								</td>
								<td style="text-align:center">
									<?php echo ($rows['emp_type']==1)? '<span style="color:blue">Master</span>' : 'Karigor'; ?>
								</td>
								<td>
									<input style="text-align:right;font-weight:bold;" class="form-control" type="text" value="<?php echo $rows['emp_price'] ?>" id="emp_price<?php echo $c; ?>"/>
								</td>
								<td style="text-align: center;">
									<input type="hidden" value="<?php echo $rows['id']; ?>" id="emp_id<?php echo $c; ?>"/>
									<input type="hidden" value="<?php echo $rows['emp_type']; ?>" id="emp_type<?php echo $c; ?>"/>
								</td>
							</tr>
							<?php 
						}
					}
				?>
					<input type="hidden" value="<?php echo $c; ?>" id="total_emp"/>
								
			</tbody>
			
		</table>
		<?php 
		
	}
	
	
	if(isset($_REQUEST['typwWiseItem'])){
		$item_type=$_REQUEST['item_type'];
		$ptype=$_REQUEST['ptype'];
		$com_id=($_SESSION['COM_ID']);
	
		if($ptype==1){
		   
			$product=$conn->query("select * from product where is_active=1 and com_id=$com_id and ptype=$item_type order by steps asc limit 0,2500");
			if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
						?>
							<tr>
								<td><button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button></td>
								<td>
								<input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','5');" value="<?php echo $rows['product_name']; ?>" id="product_name<?php echo $j; ?>"/>
								</td>
								<td><input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','1');" value="<?php echo $rows['cus_price']; ?>" id="cus_price<?php echo $j; ?>"/></td>
								<td style="text-align:center;color:blue;cursor:pointer"><span data-toggle="modal" data-target="#myModal" onclick="employeePriceSetup('<?php echo @$rows['id']; ?>','<?php echo @$rows['product_name']; ?>')"><i>View</i></span></td>
								<td><input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','4');" value="<?php echo $rows['steps']; ?>" id="order<?php echo $j; ?>"/></td>
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
		}else{
		  
			$product=$conn->query("select * from product where is_active=2 and com_id=$com_id and ptype=$item_type order by id ASC limit 0,150");
			if(mysqli_num_rows($product)>0){
						$i=1;$tqty=0;$ttaka=0;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
								$tqty+=$rows['stock_qty'];
								$ttaka+=round(($rows['stock_qty']*$rows['avg_price']),2);
							
						?>
							<tr>
								<td style="text-align: center;">
									<?php 
									if($rows['stock_qty']>0){
										echo $j;
									}else{
										if($_SESSION['LOG_USER']=="admin"){
										?>
										<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
										<?php 
										}else{
											echo $j;
										}
									}
									?>
								</td>
								<td>
									<?php 
									if($_SESSION['LOG_USER']=="admin"){
									?>
									<input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','5');" value="<?php echo $rows['product_name']; ?>" id="product_name<?php echo $j; ?>"/>
									<?php }else{
										echo $rows['product_name'];
									} ?>
								</td>
								<?php 
								if($_SESSION['IS_STOCK']==1){ // 1=means maintain stock
								?>
								<td style="text-align:center">
								 	<?php 
									if($_SESSION['LOG_USER']=="admin"){
									?>
									<input type="text" style="text-align:center" class="form-control" onblur="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','6')" value="<?php echo $rows['item_code']; ?>" id="product_code<?php echo $j; ?>"/>
									<?php }else{
										echo $rows['item_code'];
									} ?>
								</td>
								<td style="text-align:center;font-weight: bold;">
								<?php echo ($rows['stock_qty']<$_SESSION['SAFETY_STOCK'])? "<span style='color:red'>".$rows['stock_qty']."</sapn>" : $rows['stock_qty']; ?><p style="font-size:8px;color:blue"><?php echo $rows['uom']; ?></p>
								</td>
								<td style="text-align:right">
								<?php 
									if($_SESSION['LOG_USER']=="admin"){
									?>
									<input type="text" style="text-align:right;font-weight: bold;" class="form-control" onclick="clickToSelect('purchase_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','8')" value="<?php echo $rows['purchase_price']; ?>" id="purchase_price<?php echo $j; ?>"/>
									<?php }else{
										echo $rows['purchase_price'];
									} ?>
								
								</td>
								<td style="text-align:right;font-weight: bold;">
									<?php 
									if($_SESSION['LOG_USER']=="admin"){
									?>
									<input type="text" style="text-align:right;font-weight: bold;<?php echo ($rows['avg_price']>=$rows['selling_price'])? 'color:red': ''; ?>" class="form-control" onclick="clickToSelect('selling_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','7')" value="<?php echo $rows['selling_price']; ?>" id="selling_price<?php echo $j; ?>"/>
									<?php }else{
										echo $rows['selling_price'];
									} ?>
								 
								</td>
								
								<?php } ?>
							</tr>
						<?php 
						
							}
							?>
							<tr>
								<td colspan="3" style="text-align: right;font-weight: bold;">
									Total Stock Qty & Price: 
								</td>
								<td style="text-align: center;font-weight: bold;">
									<?php echo $tqty; ?>
								</td>
								<td style="text-align: right;font-weight: bold;">
									<?php echo $ttaka; ?>
								</td>
							</tr>
							<?php 
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
		}
		
	}
	
	if(isset($_REQUEST['authCustomer'])){
		@$mobile=$_REQUEST['mobile'];
		$com_id=($_SESSION['COM_ID']);
		$mobile_sql=$conn->query("select c.id,c.cus_name,c.cus_address,(select sum(point) from point_tbl where cus_id=c.id and is_active=1) getpoint from customer c where c.is_active=1 and c.com_id=$com_id and c.cus_mobile='$mobile'");
			if(mysqli_num_rows($mobile_sql)>0){
				$rows=mysqli_fetch_array($mobile_sql);
				echo trim($rows['cus_name']."#sep#".$rows['id']."#sep#".$rows['getpoint']."#sep#".$rows['cus_address']); // find selected user
			}else{
				echo 2; // not found user
			}
	}
	
	if(isset($_REQUEST['selectItemName'])){
		@$item_name=$_REQUEST['item_name'];
		@$search_type=$_REQUEST['search_type'];
		$com_id=($_SESSION['COM_ID']);
		$search_item=$conn->query("select pn.id,pn.product_name,pn.item_code,pn.avg_price,pn.selling_price,pn.uom,pn.stock_qty,pn.total_price from product pn where pn.com_id=$com_id and pn.product_name like '%$item_name%' or pn.item_code like '%$item_name%' and pn.is_active=2");
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($search_item)>0){
				
				while($rows=mysqli_fetch_array($search_item)){
					$sl=$i++;
					?>
					<a style="text-decoration:none" href="javascript:void(0)"><p onclick="setItemId('<?php echo $rows['id']; ?>','<?php echo $rows['product_name']; ?>','<?php echo $rows['item_code']; ?>','<?php echo $rows['uom']; ?>','<?php echo $rows['selling_price']; ?>','<?php echo $rows['stock_qty']; ?>','<?php echo $rows['total_price']; ?>','<?php echo $rows['avg_price']; ?>','<?php echo $search_type; ?>');" style="color: #347909fc;
					border: 1px solid #8e898942;
					background: white;
					padding-left: 10px;
					cursor: pointer;
					margin-bottom: 0px !important;
					font-style: italic;
					font-weight: bold;
					border-radius: 5px;
					padding: 5px 3px 6px 10px;
					line-height: 16px;"><?php echo $rows['product_name']." (".$rows['item_code'].") Price: ".$rows['avg_price']; ?></p></a>
					<?php 
				}
				
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['get_update_due'])){
		echo getUpdateDue($_REQUEST['cus_id']);  // find selected user
	}
	
	if(isset($_REQUEST['set_delivery_date'])){
		@$delivery_day=$_REQUEST['delivery_day'];
		@$date1=$_REQUEST['date1'];
		if($delivery_day=="" || $delivery_day==0){
			echo $date1;
		}else{
			$exday=explode("-",date('d-m-Y', strtotime(date('d-m-Y'). " +$delivery_day day")));
			echo $exday[0]."/".$exday[1]."/".$exday[2];
		}
	}
	
	if(isset($_REQUEST['typwWiseItem2'])){
		$item_type=$_REQUEST['item_type'];
		$ex=explode("#sep#",$_REQUEST['item_id']);
		$group_id=$ex[1];
		$com_id=($_SESSION['COM_ID']);
		$measurement_type=$_REQUEST['measurement_type'];
			$product=$conn->query("select * from measurement_head where is_active=1 and group_id=$group_id and mtype=$measurement_type and ptype=$item_type order by steps asc");
			if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
						?>
							<tr>
								<td><button onclick='delItemTwo(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtnTwo<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button></td>
								<td><input type="text" class="form-control" value="<?php echo $rows['title']; ?>" id="mheadordertitle<?php echo $j; ?>" onkeyup="setOrder('<?php echo $j; ?>','<?php echo $rows['id']; ?>','head','1')"/></td>
								<td><input type="number" <?php echo ($measurement_type==2 || $measurement_type==3)? "" : "readonly"  ?> class="form-control" value="<?php echo $rows['amount']; ?>" id="mheadamount<?php echo $j; ?>" onkeyup="setOrder('<?php echo $j; ?>','<?php echo $rows['id']; ?>','head','3')"/></td>
								<td><input type="text" class="form-control" value="<?php echo $rows['steps']; ?>" id="mheadorder<?php echo $j; ?>" onkeyup="setOrder('<?php echo $j; ?>','<?php echo $rows['id']; ?>','head','2')"/></td>
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
		}
		
		if(isset($_REQUEST['typwWiseItem3'])){
		$item_type=$_REQUEST['item_type'];
		$ex=explode("#sep#",$_REQUEST['item_id']);
		$group_id=$ex[1];
		$com_id=($_SESSION['COM_ID']);
		$measurement_type=$_REQUEST['measurement_type'];
			$product=$conn->query("select * from select_detail where is_active=1 and group_id=$group_id and select_type='$measurement_type' and ptype=$item_type order by steps asc");
			if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
						?>
							<tr>
								<td><button onclick='delItemThree(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtnThree<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button></td>
								<td><input type="text" class="form-control" value="<?php echo $rows['title']; ?>" id="mheadordertitle<?php echo $j; ?>" onkeyup="setOrder('<?php echo $j; ?>','<?php echo $rows['id']; ?>','detail','1')"/></td>
								<td><input type="text" class="form-control" value="<?php echo $rows['steps']; ?>" id="mheadorder<?php echo $j; ?>" onkeyup="setOrder('<?php echo $j; ?>','<?php echo $rows['id']; ?>','detail','2')"/></td>
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
			}else{
				echo "<input type='hidden' value='0' id='ilast_id'/>";
			}
		}
		
		
	if(isset($_REQUEST['getMeasurementType'])){
		$option='<option value="">Select One</option>
					<option value="1">Measurement(Text Field)</option>
					<option value="2">Propertice(Select Box)</option>
					<option value="3">Extra propertice(Check Box)</option>
					<option value="4">Remarks(Textarea)</option>';
					echo $option;
	}
	
	if(isset($_REQUEST['settingsData'])){
		$id=$_REQUEST['id'];
		$com_id=($_SESSION['COM_ID']);
		if($id==1){
		?>
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Item</h5>
				<label for="comment">Item Type<sup style="color:red">*</sup>:</label>
				<select id="item_type" onchange="typwWiseItem(1);" class="form-control">
					<option value="">Select One</option>
					<option value="1">Gents</option>
					<option value="2">Lady</option>
				</select>
				<label for="comment">Item Name<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="item_name" id="item_name" />
				<label for="comment">Group<sup style="color:red">*</sup>:</label>
				<select id="group_id" class="form-control">
					<option value="1">Shirt/Fatua/Safari (1)</option>
					<option value="2">Pant/Pajama/Kabli (2)</option>
					<option value="3">Coat/Mujib Coat/Prince Coat/Waistcoat/Sherwani (3)</option>
					<option value="4">Panjabi/Jubbah (4)</option>
					<option value="5">Ladies Group-1 (5)</option>
					<option value="6">Ladies Group-2 (6)</option>
					<option value="7">Ladies Group-3 (7)</option>
					<option value="8">Ladies Group-4 (8)</option>
					<option value="9">Ladies Group-5 (9)</option>
					<option value="11">Ladies Group-6 (11)</option>
					<option value="12">Group (12)</option>
					<option value="13">Group (13)</option>
					<option value="14">Group (14)</option>
					<option value="15">Group (15)</option>
					<option value="16">Group (16)</option>
					<option value="17">Group (17)</option>
					<option value="18">Group (18)</option>
					<option value="19">Group (19)</option>
					<option value="20">Group (20)</option>
					<option value="21">Group (21)</option>
					<option value="22">Group (22)</option>
					<option value="23">Group (23)</option>
					<option value="24">Group (24)</option>
					<option value="25">Group (25)</option>
					<option value="26">Group (26)</option>
					<option value="27">Group (27)</option>
					<option value="28">Group (28)</option>
					<option value="29">Group (29)</option>
					<option value="30">Group (30)</option>
					<option value="31">Group (31)</option>
					<option value="32">Group (32)</option>
				</select>
				<label for="comment">Customer's Price<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="cus_price" />
				<label for="comment">Master's Price<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="master_price" id="master_price" />
				<label for="comment">Karigor's Price<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="karigor_price" id="karigor_price" />
				<button onclick="saveItem();" style="margin-top: 12px;" name="btn" value="sub" id="saveItemBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Item</th>
							<th>Customer Price</th>
							<th>Employee Price</th>
							
							<th>Order</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
		<?php 
		}
		
		if($id==2){
		?>
		
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Propertice</h5>
				<label for="comment">Item Type<sup style="color:red">*</sup>:</label>
				<select id="item_type" onchange="changeType();" style="" class="form-control">
					<option value="">Select One</option>
					<option value="1">Gents</option>
					<option value="2">Lady</option>
				</select>
				<label for="comment">Item<sup style="color:red">*</sup>:</label>
				<select id="item_id" style="" class="form-control"  onchange="getMeasurementType();">
					
				</select>
				<label for="comment">Measurement Type<sup style="color:red">*</sup>:</label>
				<select id="measurement_type" onchange="getPropertice();" class="form-control">
					<option value="">Select One</option>
					<option value="1">Measurement(Text Field)</option>
					<option value="2">Propertice(Select Box)</option>
					<option value="3">Extra propertice(Check Box)</option>
					<option value="4">Remarks(Textarea)</option>
				</select>
				<label for="comment">Title<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="propertice_title" id="propertice_title" />
				<button onclick="savePropertices();" style="margin-top: 12px;" name="btn" value="sub" id="saveProperticesBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<!--<th>Item</th>-->
							<th>Propertice Head Title</th>
							<th>Amount</th>
							<th>Order</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
		<?php 
		}
		
		if($id==3){
		?>
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Propertice Details</h5>
				<label for="comment">Item Type<sup style="color:red">*</sup>:</label>
				<select id="item_type" onchange="changeType();" style="" class="form-control">
					<option value="">Select One</option>
					<option value="1">Gents</option>
					<option value="2">Lady</option>
				</select>
				<label for="comment">Item<sup style="color:red">*</sup>:</label>
				<select id="item_id" onchange="getSelectHead();" style="" class="form-control">
					
				</select>
				
				<label for="comment">Propertice(Select Box Details)<sup style="color:red">*</sup>:</label>
				<select id="measurement_type" onchange="getPropertice2();" class="form-control">
				</select>
				<label for="comment">Title<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="chk_title" id="chk_title" />
				<button onclick="saveProperticesExtra();" style="margin-top: 12px;" name="btn" value="sub" id="saveProperticesExtraBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Propertice Title</th>
							<th>Order</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
		<?php 
		}else if($id==4){
			$com_id=($_SESSION['COM_ID']);
			$date=date("Y-m-d");
			$dsms=$conn->query("select dv_date,cus_mobile from dsms where is_active=1 and dv_date>='$date' and online_status=0 and com_id=$com_id");
		
			$order=$conn->query("select id,factory_receive_date,dv_date,cus_mobile,online_status from dsms where is_active=1 and factory_status=1 and com_id=$com_id");
			?>
			<div class="col-xs-12 col-sm-3">
				<div class="alert alert-info">
				  <p><strong>Order History (<?php echo mysqli_num_rows($dsms); ?>)</strong></p>
				  <?php if(mysqli_num_rows($dsms)>0){ ?>
				  <span id="send_to_server_load"><button onclick="sendToServerOrder();" name="btn" id="send_to_server_order" value="sub" class="form-control btn btn-info">Send SMS</button></span>
				  <?php } ?>
				</div>
				
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Delivery Date</th>
							<th>Mobile</th>
						</tr>
					</thead>
					<tbody id="tbl_one">
						<?php 
						if(mysqli_num_rows($dsms)>0){
							$i=1;
							while($row=mysqli_fetch_array($dsms)){
								?>
									<tr>
										<td><?php echo $i++; ?></td>
										<th><?php echo $row['dv_date']; ?></th>
										<th><?php echo $row['cus_mobile']; ?></th>
									</tr>
								<?php 
							}
						}
						?>
						
					</tbody>
				</table>
			</div>
			<div class="col-xs-12 col-sm-3">
				<div class="alert alert-success">
				  <p><strong>Production Received Order (<?php echo mysqli_num_rows($order); ?>)</strong></p>
				</div>
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Delivery Date</th>
							<th>Mobile</th>
						</tr>
					</thead>
					<tbody id="tbl_two2">
						<?php 
						if(mysqli_num_rows($order)>0){
							$i=0;$k=0;
							while($row=mysqli_fetch_array($order)){
								if($row['online_status']==1){
									$k=++$i;
								?>
									<tr>
										<td><?php echo $k; ?></td>
										<th><?php echo $row['dv_date']; ?></th>
										<input type="hidden" value="<?php echo $row['id']."#sep#".$row['cus_mobile']."#sep#".$row['dv_date']."#sep#".$row['factory_receive_date']; ?>" id="factory_mobile<?php echo $k; ?>"/>
										<th><span id="send_to_server_load2<?php echo $k; ?>"><button onclick="sendToServerReceivedOrder(<?php echo $k; ?>);" name="btn" id="received_order" value="sub" class="form-control btn btn-success"><?php echo $row['cus_mobile']; ?></button></span></th>
									</tr>
								<?php
								}								
							}
						}
						?>
						
					</tbody>
				</table>
			</div>
			
			<?php 
		}else if($id==5){
			date_default_timezone_set("Asia/Dhaka");
			$mnt="0"; 
			$year="0";
			
			$bill_sql=$conn->query("select bill,sec_id,billing_month,billing_year,is_active,bill_pay_date from billing where com_id=$com_id order by id desc limit 1,1");
			if(mysqli_num_rows($bill_sql)>0){
				$bill_array=mysqli_fetch_array($bill_sql);
				$bmonth=date("F", mktime(0, 0, 0, $bill_array['billing_month'], 10)).'-'.$bill_array['billing_year'];
				if($bill_array['bill']!=0 && $bill_array['is_active']==1){
					$sataus='<span style="color:green">Paid</span>';
					$chk_sataus=1;
				}else{
					$sataus='<span style="color:red">Unpaid</span>';
					$chk_sataus=0;
				}
			}else{
				$bmonth="";
				$sataus='<span style="color:red">---</span>';
				$chk_sataus=0;
			}
			$order=$conn->query("select count(ds.id) tot from dsms ds where ds.is_active=1 and ds.com_id=$com_id and month(ds.insert_date)=$mnt and year(ds.insert_date)=$year");
			
			if(mysqli_num_rows($order)>0){
				$ord=mysqli_fetch_array($order);
				$order_num=$ord['tot'];
			}else{
				$order_num=0;
			}
			if($_SESSION['SOFT_CHARGE']>0 && $_SESSION['SMS_SERVICE']!=1){ // per order bill but not get sms service
				//only soft
				$soft=$_SESSION['SOFT_CHARGE'];
				$total=round(floatval($order_num)*$soft);
				$security=getSecurity($total);
				$tbl="<table id='example' class='table table-striped table-bordered'>
					<thead>
						<tr>
							<th>Total Order(qty)</th>
							<th>Per Order(tk)</th>
							<th>Total(round tk)</th>
							<th>Security Code</th>
							<th>Status</th>
						</tr>
					</thead>
					<tbody id='tbl_three'>
						<tr>
							<td>$order_num</td>
							<th>$soft</th>
							<th style='background:#73CEFB;color:white'>$total</th>
							<th>$security</th>
							<th>$sataus</th>
						</tr>
					</tbody>
				</table>";
			}
			if($_SESSION['SOFT_CHARGE']>0 && $_SESSION['SMS_SERVICE']==1){ // per order charge and per sms bill
				// soft and sms
				$soft=$_SESSION['SOFT_CHARGE'];
			
				$total=round(floatval($order_num)*($soft));
				$security=getSecurity($total);
				$tbl="<table id='example' class='table table-striped table-bordered'>
					<thead>
						<tr>
							<th>Total Order(qty)</th>
							<th>Per Order(tk)</th>
							<th>Total(round tk)</th>
							<th>Security Code</th>
							<th>Status</th>
						</tr>
					</thead>
					<tbody id='tbl_three'>
						<tr>
							<th>$order_num</th>
							<th>$soft</th>
							<th style='background:#73CEFB;color:white'>$total</th>
							<th>$security</th>
							<th>$sataus</th>
						</tr>
					</tbody>
				</table>";
			}
			
			if($_SESSION['SOFT_CHARGE']==0){ //monthly bill
				// monthly bill
				$total="700";
				$security=getSecurity($total);
				$tbl="<table id='example' class='table table-striped table-bordered'>
					<thead>
						<tr>
							<th>Total Order(qty)</th>
							<th>Per Month(tk)</th>
							<th>Total(tk)</th>
							<th>Security Code</th>
							<th>Status</th>
						</tr>
					</thead>
					<tbody id='tbl_three'>
						<tr>
							<th>$order_num</th>
							<th>$total</th>
							<th style='background:#73CEFB;color:white'>$total</th>
							<th>$security</th>
							<th>$sataus</th>
						</tr>
					</tbody>
				</table>";
			}
			
			?>
				<div class="col-xs-12 col-sm-10">
				
				<div class="panel panel-success">
				  <div class="panel-heading" style="text-align:center">Bill(<?php echo @$bmonth; ?>)</div>
				  <div class="panel-body">
					<div>
						<h4 style="text-align: center;line-height: 0px;"><?php echo $_SESSION['COM']; ?></h4>
						<p style="text-align: center;"><?php echo $_SESSION['COM_ADDRESS']; ?></p>
						<?php echo $tbl; ?>
					</div>
				  </div>
				</div>
							
				</div>
			<?php 
			if($chk_sataus==0){
				if($_SESSION['MBILL']!=2){
			?>
			<div class="col-xs-12 col-sm-3">
					<div class="panel panel-success">
					  <div class="panel-heading" style="text-align:center">Step-1</div>
					  <div class="panel-body">
						<p style="font-size:11px;color:red;text-align:justify">1. Software এর  Monthly Bill আগে  <b>01719027713</b> এই নম্বর এ Bkash করুন.</p>
						<p style="font-size:11px;color:red;text-align:justify">2. Step-2 তে আপনি যে মোবাইল নম্বর থেকে Bkash করেছেন সেই নম্বর টি Sender Bkash Number হিসেবে বসিয়ে Send এ ক্লিক করুন.</p>
						<p style="font-size:11px;color:red;text-align:justify">2. Step-3 তে আপনার মোবাইল নম্বর এ দুইটি PIN Number SMS করা হবে তা PIN-1এবং PIN-2 তে বসিয়ে Verify এ ক্লিক করুন.</p>
					 </div>
					</div>
							
				</div>
				<div class="col-xs-12 col-sm-4">
					<div class="panel panel-info">
					  <div class="panel-heading" style="text-align:center">Step-2</div>
					  <div class="panel-body">
						<label for="comment">Total Bill(Tk)</label>
						<input type="text" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;background:#73CEFB;color:white" value="<?php echo $total; ?>" autocomplete="off" name="bill_tk" id="bill_tk" required/>
						<label for="comment">Security Code</label>
						<input type="text" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" autocomplete="off" value="<?php echo $security; ?>" name="security_code" id="security_code" required/>
						<label for="comment">Sender Bkash Number</label>
						<input type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" maxlength="11" autocomplete="off" name="sender_number" id="sender_numbers" required/>
					    <button onclick="sendMonthlyBill();" style="margin-top:15px" name="btn" value="sub" id="bill_btn" class="btn btn-info">Send</button>
						<span id="bsms"></span>
					 </div>
					</div>
							
				</div>
				<div class="col-xs-12 col-sm-3">
				
				<div class="panel panel-warning">
				  <div class="panel-heading" style="text-align:center">Verification(Step-3)</div>
				  <div class="panel-body">
					<label for="comment">PIN-1</label>
					<input type="text" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color:red" maxlength="5" autocomplete="off" name="pin1" id="pina" required/>
					<label for="comment">PIN-2</label>
					<input type="text" class="form-control" style="font-weight: bold;font-size:18px;font-style: italic;color:red" maxlength="5" autocomplete="off" name="pin2" id="pinb" required/>
					<input type="hidden" id="bill_save" value="<?php echo $total; ?>"/>
					<input type="hidden" id="security_save" value="<?php echo $security; ?>"/>
					<input type="hidden" id="month_year" value="<?php echo @$bill_array['billing_month']."_".@$bill_array['billing_year']; ?>"/>
				  <button onclick="verificationChk();" style="margin-top:15px" name="btn" value="sub" id="verify_btn" class="btn btn-warning">Verify</button>
				  <span id="vsms"></span>
				  </div>
				</div>
							
				</div>
			<?php 
				}
		}
		}else if($id==6){
			$com_id=($_SESSION['COM_ID']);
			?>
			<div class="row" style="margin-top: 6px;">
				<div class="col-xs-12 col-sm-2">
					<div class="alert alert-warning">
					  <strong><?php
					   if(check_internet_connection()==1){
						$response = file_get_contents($_SESSION['API']."api/data.php?com_id=$com_id&chk=2"); //chk=2 means check sms
						$json = json_decode($response, true);
						echo "Balance: ".$json['sms']." SMS";
						}else{
							echo '<span style="color:red">No Internet Connection</span>';
						}
					  ?></strong>
					</div>
					
				</div>
				<div class="col-xs-12 col-sm-3">
					<div class="alert alert-success">
					  <strong>Details(Last 15 Result)</strong>
					  <button onclick="getSmsDetails();" name="btn" id="sms_details" value="sub" class="form-control btn btn-success">Purchase Details(SMS)</button>
					</div>
					<table id="example" class="table table-striped table-bordered">
						<thead>
							<tr>
								<th>SL</th>
								<th>Purchase Date</th>
								<th>SMS Qty</th>
							</tr>
						</thead>
						<tbody id="sms_tbl">
							
						</tbody>
					</table>
				</div>
				<div class="col-xs-12 col-sm-4">
					<p style="font-size: 24px;">SMS ক্রয় এর জন্য  <i><b>01311240085</b></i>  এই নম্বর এ কল করুন !!!</p>
				</div>
			</div>
			<?php 
		}else if($id==7){
			
			exec($_SESSION['BACKUP']);
			
			?>
			<div class="col-xs-12 col-sm-2">
				<div class="alert alert-info">
				  <strong>Database Backup Success!</strong>
				</div>
			</div>
			<?php 
		}else if($id==8){
			$com_id=($_SESSION['COM_ID']);
			$order=$conn->query("select * from company where is_active=1 and id=$com_id");
			$taxes=$conn->query("select * from vat_tax where is_active=1 and com_id=$com_id");
			$rows=mysqli_fetch_array($order);
			?>
			<div class="col-xs-12 col-sm-3">
				<label>Order No. Set</label>
				<select class="form-control" id="order_change_option" onchange="orderChangeOption(1);">
					<option <?php if($rows['sversion']==0) echo "selected"; ?> value="0">Computer Generated Order No.</option>
					<option <?php if($rows['sversion']==1) echo "selected"; ?> value="1">Physical Books Order No.</option>
					<option <?php if($rows['sversion']==2) echo "selected"; ?> value="2">Merge Order No.</option>
				</select>
				<label>Production Copy Set</label>
				<select class="form-control" id="order_change_option2" onchange="orderChangeOption(2);">
					<option <?php if($rows['measure_type']==0) echo "selected"; ?> value="0">Standard Production Copy</option>
					<option <?php if($rows['measure_type']==2) echo "selected"; ?> value="2">Normal Production Copy</option>
					<option <?php if($rows['measure_type']==1) echo "selected"; ?> value="1">Local Production Copy</option>
				</select>
				<label>Design Set</label>
				<select class="form-control" id="order_change_option9" onchange="orderChangeOption(9);">
					<option <?php if($rows['design_set']==1) echo "selected"; ?> value="1">Show Desing</option>
					<option <?php if($rows['design_set']==0) echo "selected"; ?> value="0">Not</option>
				</select>
				<label>Order Report Set</label>
				<select class="form-control" id="order_change_option6" onchange="orderChangeOption(6);">
					<option <?php if($rows['ord_settings']==1) echo "selected"; ?> value="1">Active</option>
					<option <?php if($rows['ord_settings']==0) echo "selected"; ?> value="0">Inactive</option>
				</select>
				<label>Customer Delivery Day Set</label>
				<select class="form-control" id="order_change_option4" onchange="orderChangeOption(4);">
					<option <?php if($rows['customer_delivery']==7) echo "selected"; ?> value="7">7 Days later</option>
					<option <?php if($rows['customer_delivery']==8) echo "selected"; ?> value="8">8 Days later</option>
					<option <?php if($rows['customer_delivery']==9) echo "selected"; ?> value="9">9 Days later</option>
					<option <?php if($rows['customer_delivery']==10) echo "selected"; ?> value="10">10 Days later</option>
					<option <?php if($rows['customer_delivery']==11) echo "selected"; ?> value="11">11 Days later</option>
					<option <?php if($rows['customer_delivery']==12) echo "selected"; ?> value="12">12 Days later</option>
					<option <?php if($rows['customer_delivery']==14) echo "selected"; ?> value="14">14 Days later</option>
					<option <?php if($rows['customer_delivery']==16) echo "selected"; ?> value="16">16 Days later</option>
					<option <?php if($rows['customer_delivery']==18) echo "selected"; ?> value="18">18 Days later</option>
					<option <?php if($rows['customer_delivery']==20) echo "selected"; ?> value="20">20 Days later</option>
					<option <?php if($rows['customer_delivery']==22) echo "selected"; ?> value="22">22 Days later</option>
					<option <?php if($rows['customer_delivery']==24) echo "selected"; ?> value="24">24 Days later</option>
					<option <?php if($rows['customer_delivery']==26) echo "selected"; ?> value="26">26 Days later</option>
					<option <?php if($rows['customer_delivery']==28) echo "selected"; ?> value="28">28 Days later</option>
					<option <?php if($rows['customer_delivery']==30) echo "selected"; ?> value="30">30 Days later</option>
				</select>
				<label>Factory Delivery Day Set</label>
				<select class="form-control" id="order_change_option3" onchange="orderChangeOption(3);">
					<option <?php if($rows['factory_delivery']==1) echo "selected"; ?> value="1">1 Day Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==2) echo "selected"; ?> value="2">2 Days Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==3) echo "selected"; ?> value="3">3 Days Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==4) echo "selected"; ?> value="4">4 Days Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==5) echo "selected"; ?> value="5">5 Days Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==7) echo "selected"; ?> value="7">7 Days Ago Delivery</option>
					<option <?php if($rows['factory_delivery']==10) echo "selected"; ?> value="10">10 Days Ago Delivery</option>
				</select>
				<label>Order SMS</label>
				<select class="form-control" id="order_change_option13" onchange="orderChangeOption(13);">
					<option <?php if($rows['order_sms']==0) echo "selected"; ?> value="0">Not Active</option>
					<option <?php if($rows['order_sms']==1) echo "selected"; ?> value="1">Active</option>
				</select>
				<label>Item Receive SMS</label>
				<select class="form-control" id="order_change_option14" onchange="orderChangeOption(14);">
					<option <?php if($rows['item_receive_sms']==0) echo "selected"; ?> value="0">Not Active</option>
					<option <?php if($rows['item_receive_sms']==1) echo "selected"; ?> value="1">Active</option>
				</select>
				<label>Employee Payment SMS</label>
				<select class="form-control" id="order_change_option15" onchange="orderChangeOption(15);">
					<option <?php if($rows['emp_payment_sms']==0) echo "selected"; ?> value="0">Not Active</option>
					<option <?php if($rows['emp_payment_sms']==1) echo "selected"; ?> value="1">Active</option>
				</select>
				<?php 
				if($_SESSION['IS_STOCK']==1){ // 1=means maintain stock
				?>
				<label>Is Active Selling Price?</label>
				<select class="form-control" id="order_change_option11" onchange="orderChangeOption(11);">
					<option <?php if($rows['apply_selling_price']==1) echo "selected"; ?> value="1">Yes</option>
					<option <?php if($rows['apply_selling_price']==0) echo "selected"; ?> value="0">No</option>
				</select>
				<label>Set Safety Stock</label>
				<select class="form-control" id="order_change_option12" onchange="orderChangeOption(12);">
					<option <?php if($rows['sefty_stock']==10) echo "selected"; ?> value="10">10</option>
					<option <?php if($rows['sefty_stock']==20) echo "selected"; ?> value="20">20</option>
					<option <?php if($rows['sefty_stock']==30) echo "selected"; ?> value="30">30</option>
					<option <?php if($rows['sefty_stock']==40) echo "selected"; ?> value="40">40</option>
					<option <?php if($rows['sefty_stock']==50) echo "selected"; ?> value="50">50</option>
					<option <?php if($rows['sefty_stock']==60) echo "selected"; ?> value="60">60</option>
					<option <?php if($rows['sefty_stock']==70) echo "selected"; ?> value="70">70</option>
					<option <?php if($rows['sefty_stock']==80) echo "selected"; ?> value="80">80</option>
					<option <?php if($rows['sefty_stock']==90) echo "selected"; ?> value="90">90</option>
					<option <?php if($rows['sefty_stock']==100) echo "selected"; ?> value="100">100</option>
				</select>
				<?php } ?>
				<label>Active Reference?</label>
				<select class="form-control" id="order_change_option10" onchange="orderChangeOption(10);">
					<option <?php if($rows['active_reference']==0) echo "selected"; ?> value="0">No</option>
					<option <?php if($rows['active_reference']==1) echo "selected"; ?> value="1">Yes</option>
				</select>
				<?php 
				if($rows['active_reference']==1){
				?>
				<label id="ref_amount_title">Reference Point</label>
				<input type="text" onkeyup="updateReferenceAmount();" value="<?php echo @$_SESSION['REFERENCE_AMOUNT']; ?>" maxlength="4" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" name="reference_amount" autocomplete="off" placeholder="Enter Amount(Tk)" id="reference_amount" class="form-control">
				<?php } ?>
				<span id="show_amount">
				</span>
				
				<?php 
				if($_SESSION['MEASURE_TYPE']==0){
				?>
				<label>Heading Image</label>
				<input type="file" style="width: 260px;" name="submitfile" id="submitfile" onchange="readURL(this);" />
				<img id="blah" src="" style="width: 184px;height:50px" alt="your image" />
				<button style="margin-top: 6px;" class="btn btn-success">Upload</button>
				<style>
				input[type=file]{
				padding:10px;
				background:#2d2d2d;}
				</style>
				<?php } ?>
				
				
				<span id="show_ord"></span>
				<span id="load_order_change"></span>
			</div>
			<div class="col-xs-12 col-sm-3">
				
			</div>
			<?php 
		}else if($id==9){
			$com_id=($_SESSION['COM_ID']);
			$emp_info=$conn->query("SELECT mh.user_name,mh.id,mh.mobile,mh.emp_type,mh.emp_address,mh.salary_type,mh.salary,(select taka from wages_head where emp_id=mh.id and com_id=mh.com_id) wages FROM `user` mh WHERE mh.com_id=$com_id and mh.is_active=1 and mh.emp_type in(1,2,3) order by mh.emp_type asc");
			mysqli_close($conn);
			?>
			<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center"><b>Master/Karigor/Staff Information</b></h5>
				<label for="comment">Employee Type<sup style="color:red">*</sup>:</label>
				<select id="emp_type" style="" class="form-control">
					<option value="">Select One</option>
					<option value="1">Master</option>
					<option value="2">Karigor</option>
					<option value="3">Staff</option>
				</select>
				
				<label for="comment">Name<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_name" id="emp_name" />
				
				<label for="comment">Mobile<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" maxlength="11" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_mobile" id="emp_mobile" />
				<label for="comment">Address:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_name" id="emp_address" />
				<label for="comment">Salary Type<sup style="color:red">*</sup>:</label>
				<select id="salary_type" onchange="changeSalaryType();" class="form-control">
					<option value="">Select One</option>
					<option value="1">Item Wise</option>
					<option value="2">Daily Basis</option>
					<option value="3">Monthly Basis</option>
				</select>
				<label for="comment"><span id="stitle">Salary</span><sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" name="emp_name" id="emp_salary" />
				
				<button onclick="saveMasterKarigor();" style="margin-top: 12px;" name="btn" value="sub" id="saveMasKaeBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7">
				<table id="example" style="margin-top: 5px;" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Name</th>
							<th>Mobile</th>
							<th>Type</th>
							<th>Salary Type</th>
							<th style="text-align:right">Balance</th>
						</tr>
					</thead>
					<tbody id="emp_tbl">
						<?php 
						$i=1;
						if(mysqli_num_rows($emp_info)>0){
							$tot_wages=0;
							while($rows=mysqli_fetch_array($emp_info)){
								$tbl_id=$rows['id'];
								$tot_wages+=$rows['wages'];
								$sl=$i++;
								?>
								<tr style="color:<?php 
								if($rows['emp_type']==1){
									echo "blue";
								}else if($rows['emp_type']==3){
									echo "#b60bc1;";
								}
								?>">
									<td><button onclick="delEmployee('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>"><?php echo $sl; ?></button></td>
									<td>
									<input type="text" class="form-control" autocomplete="off" id="user_name<?php echo $tbl_id; ?>" onkeyup="editEmployee('<?php echo $tbl_id; ?>','1');" value="<?php echo @$rows['user_name']; ?>" />
									</td>
									<td>
									<input type="text" class="form-control" autocomplete="off" id="user_mobile<?php echo $tbl_id; ?>" value="<?php echo @$rows['mobile']; ?>" />
									<button onclick="editEmployee('<?php echo $tbl_id; ?>','2');">Ok</button>
									</td>
									<td><?php if($rows['emp_type']==1){ echo "Master"; }else if($rows['emp_type']==2){ echo "Karigor"; }else{ echo "Staff";} ?></td>
									<td><?php if($rows['salary_type']==1){ echo "Item Wise"; }else if($rows['salary_type']==2){ echo "Daily Basis (".$rows['salary']."/=)"; }else{ echo "Monthly Basis (".$rows['salary']."/=)";} ?></td>
									<td style="text-align:right;font-weight:bold"><?php echo ($rows['wages']=="")? 0 : $rows['wages']; ?>/=</td>
								</tr>
								<?php 
							}
							echo "<input type='hidden' id='tbl_last_id' value='$sl'/>";
						}else{
							echo "<input type='hidden' id='tbl_last_id' value='0'/>";
						}
						?>
						<tr>
							<td style="text-align:right;font-weight:bold" colspan="5">Total Wages</td>
							<td style="text-align:right;font-weight:bold"><?php echo $tot_wages; ?>/=</td>
						</tr>
					</tbody>
				</table>
			</div>
			<?php 
		}else if($id==19){
			$com_id=($_SESSION['COM_ID']);
			@$emp_info=$conn->query("SELECT * FROM `supplier_info` mh WHERE mh.is_active=1");
			mysqli_close($conn);
			?>
			<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center"><b>Supplier Information</b></h5>
				
				<label for="comment">Supplier Name<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_name" id="emp_name" />
				
				<label for="comment">Mobile<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" maxlength="11" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_mobile" id="emp_mobile" />
				<label for="comment">Address:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_name" id="emp_address" />
			
				<button onclick="saveSupplier();" style="margin-top: 12px;" name="btn" value="sub" id="saveMasKaeBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7">
				<table id="example" style="margin-top: 5px;" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Supplier Name</th>
							<th>Mobile</th>
							<th>Address</th>
							<th style="text-align:right">Balance</th>
						</tr>
					</thead>
					<tbody id="emp_tbl">
						<?php 
						$i=1;$tot_wages=0;
						if(mysqli_num_rows($emp_info)>0){
							
							while($rows=mysqli_fetch_array($emp_info)){
								$tbl_id=$rows['id'];
								$tot_wages+=$rows['supplier_due'];
								$sl=$i++;
								?>
								<tr>
									<td><button onclick="delSupplier('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>"><?php echo $sl; ?></button></td>
									<td><?php echo $rows['supplier_name']; ?></td>
									<td><?php echo $rows['supplier_mobile']; ?></td>
									<td><?php echo $rows['supplier_address']; ?></td>
									<td style="text-align:right;font-weight:bold"><?php echo ($rows['supplier_due']=="")? 0 : $rows['supplier_due']; ?>/=</td>
								</tr>
								<?php 
							}
							echo "<input type='hidden' id='tbl_last_id' value='$sl'/>";
						}else{
							echo "<input type='hidden' id='tbl_last_id' value='0'/>";
						}
						?>
						<tr>
							<td style="text-align:right;font-weight:bold" colspan="4">Total</td>
							<td style="text-align:right;font-weight:bold"><?php echo $tot_wages; ?>/=</td>
						</tr>
					</tbody>
				</table>
			</div>
			<?php 
		}else if($id==18){ //expense type setup
			$com_id=($_SESSION['COM_ID']);
			$emp_info=$conn->query("SELECT * FROM `expense_type` mh WHERE mh.is_active=1 order by mh.id desc");
			mysqli_close($conn);
			?>
			<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center"><b>Expense Type Setup</b></h5>
				
				<label for="comment">Expense Type Name<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="emp_name" id="expense_type_name" />
				
				<button onclick="saveExpenseType();" style="margin-top: 12px;" name="btn" value="sub" id="saveMasKaeBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				<p></p>
			</div>
			
			<div class="col-xs-12 col-sm-7">
				<table id="example" style="margin-top: 5px;" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th style="text-align:center">SL</th>
							<th>Expense Type</th>
							<th>Insert Date</th>
						</tr>
					</thead>
					<tbody id="emp_tbl">
						<?php 
						$i=1;
						if(mysqli_num_rows($emp_info)>0){
							$tot_wages=0;
							while($rows=mysqli_fetch_array($emp_info)){
								$tbl_id=$rows['id'];
								$sl=$i++;
								?>
								<tr>
									<td style="text-align:center"><button onclick="delExpenseType('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>"><?php echo $sl; ?></button></td>
									<td><?php echo $rows['expense']; ?></td>
									<td><?php echo $rows['insert_date']; ?></td>
									</tr>
								<?php 
							}
							echo "<input type='hidden' id='tbl_last_id' value='$sl'/>";
						}
						?>
						
					</tbody>
				</table>
			</div>
			<?php 
		}else if($id==10){
			$com_id=($_SESSION['COM_ID']);
			$emp_info=$conn->query("SELECT c.id,c.cus_name,c.cus_mobile,c.cus_address,(select last_due from update_due where cus_id=c.id and is_active=1 order by id desc limit 0,1) due_amount FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 limit 0,500");
			$total_due=$conn->query("select sum(dd.last_dues) total_due from (SELECT `cus_id`,(select ud.`last_due` from update_due ud where ud.`cus_id`=update_due.cus_id and ud.is_active=1 order by ud.id desc limit 0,1) last_dues FROM `update_due` WHERE `is_active`=1 GROUP by `cus_id`) dd");
			$trows=mysqli_fetch_array($total_due);
			$total_due=round($trows['total_due'],2);
			mysqli_close($conn);
			$tot_emp=mysqli_num_rows($emp_info);
			?>
			<div class="col-xs-12 col-sm-3">
				<label for="comment">Customer Mobile/Name:</label>
					<input type="text" maxlength="11" placeholder="Enter Mobile Number/Name" class="form-control" onkeyup="searhMobileNumber();" style="font-weight: bold;font-size:18px;font-style: italic;" autocomplete="off" name="" id="src_cus_mobile" required/>
				
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 25px;">
				
				<button onclick="addNewCustomer();" name="btn" id="curtomerBtn" value="sub" class="btn btn-success">+New Customer</button>
			</div>
			
			<div class="col-xs-12 col-sm-10" id="customer_form">
					
			</div>
			<div class="col-xs-12 col-sm-10" id="customer_scroll" style="height: 560px;">
				<table id="example" style="margin-top: 5px;" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Customer Name</th>
							<th>Mobile</th>
							<th>Address</th>
							<th style="text-align: right;">বাকি(টাকা)</th>
						</tr>
					</thead>
					<tbody id="search_mobile">
						<?php 
						$i=1;$total_tk=0;
						if($tot_emp>0){
							while($rows=mysqli_fetch_array($emp_info)){
								$tbl_id=$rows['id'];
								$sl=$i++;
								$total_tk+=$rows['due_amount'];
								?>
								<tr>
									<td>
									<?php 
									if(@$rows['due_amount']=="" || $rows['due_amount']==0){
									?>
									<button onclick="delCustomer('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>"><?php echo $sl; ?></button>
									<?php }else{
										echo $sl;
									} ?>
									</td>
									<td><input type="text" class="form-control" autocomplete="off" id="cus_name<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','1');" value="<?php echo @$rows['cus_name']; ?>" /></td>
									<td><?php echo $rows['cus_mobile']; ?></td>
									<td><input type="text" class="form-control" autocomplete="off" id="cus_address<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','2');" value="<?php echo @$rows['cus_address']; ?>" /></td>
									<td style="text-align: right;font-weight:bold"><?php echo englishToBangla($rows['due_amount'])."/="; ?></td>
								</tr>
								
								<?php 
							}
						}else{
							echo "";
						}
						?>
					</tbody>
				</table>
				<?php 
					if($tot_emp>=500){
				 ?>
				 <div class="form-group" style="margin-top:15px">
				  <button onclick="seaMoreCustomer();" name="btn" id="morebtns" class="btn btn-success">More+</button><span id="load_imgs"></span>
				  </div>
				<?php } ?>
				<input type="hidden" id="last_id" value="500"/>	
			</div>
			<div class="col-xs-12 col-sm-12">
				<span id="total_dues" style="float: right;margin-right: 20px;font-weight: bold;font-size: 16px;margin-bottom: 15px;">সর্বমোট বাকি: <?php echo Converter::en2bn($total_due)."/="; ?></span>
			</div>
			<?php 
		}else if($id==11){
			
			?>
			<div class="col-xs-12 col-sm-2">
				<label for="comment" class="txt_color">Customer Name/Mobile:</label>
				<input type="text" placeholder="Customer Name/Mobile" onkeyup="chkCustomer();" class="form-control" maxlength="11" autocomplete="off" style="font-weight: bold;font-size:16px;font-style: italic;background: #ffeb3b;" name="mobile" id="cus_mobile" />
				<span id="cus_info" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 240px;"></span>
				
			</div>
			<input type="hidden" id="hide_cus_id"/>
			<div class="col-xs-12 col-sm-2">
				<label for="comment" class="txt_color">ধরণ:</label>
				<select class="form-control" style="font-weight: bold;font-size:16px;font-style: italic;" id="tk_type">
					<option value="">Select One</option>
					<option value="0">বাকি প্রদান(+)</option>
					<option value="1">বাকি গ্রহণ(-)</option>
					
				</select>
				
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment" class="txt_color">টাকা:</label>
				<input type="text" value="0" onclick="clickToSelect('adjust_tk')" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" class="form-control" maxlength="7" autocomplete="off" style="font-weight: bold;font-size:16px;font-style: italic;text-align:right" name="mobile" id="adjust_tk" />
			</div>
			<div class="col-xs-12 col-sm-2">
				<label for="comment" class="txt_color">পেমেন্ট:</label>
				<select id="payment_type" class="form-control">
					<option value="Cash">Cash</option>
					<option value="Bkash">Bkash</option>
					<option value="Rocket">Rocket</option>
					<option value="Nagad">Nagad</option>
					<option value="Upay">Upay</option>
					<option value="Sure Cash">Sure Cash</option>
					<option value="Tap">Tap</option>
					<option value="POS Machine">POS Machine</option>
					<option value="Bank">Bank</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2">
				<label for="comment" class="txt_color">মন্তব্য:</label>
				<input type="text" placeholder="Enter Remarks"  class="form-control" autocomplete="off" style="font-weight: bold;font-size:16px;font-style: italic;" name="mobile" id="tk_remarks" />
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment" class="txt_color">#</label>
				<span id="adjust_sms"><button onclick="dueAdjustment();" style="" name="btn" value="sub" id="save_order" class="btn btn-success">Save</button></span>
			</div>
			<div class="col-xs-12 col-sm-10" style="margin-top: 5px;">
				<div class="row" id="tk_form">
					<div class="col-xs-12 col-sm-3">
						<label for="comment" class="txt_color">কাস্টমার:</label>
						<p id="scus_name"></p>
						<input type="hidden" id="hscus_name"/>
					</div>
					<div class="col-xs-12 col-sm-2">
						<label for="comment" class="txt_color">মোবাইল:</label>
						<p id="scus_mobile"></p>
					</div>
					<div class="col-xs-12 col-sm-5">
						<label for="comment" class="txt_color">ঠিকানা:</label>
						<p id="scus_address"></p>
					</div>
				</div>
			</div>
			
			<div class="col-xs-12 col-sm-10" id="">
				<h3>Last <select style="border: 1px solid red;" onchange="lastDaysResult();" id="last_days"><option value="">##</option><option value="1">1</option><option value="3">3</option>
				<option value="5">5</option>
				<option value="10">10</option>
				<option value="15">15</option>
				<option value="20">20</option>
				<option value="25">25</option>
				<option value="30">30</option>
				</select> days result.</h3>
				<table id="example" style="margin-top: 5px;" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Date</th>
							<th style="text-align: right;">Amount</th>
							<th>Remarks</th>
							<th>Transaction By</th>
						</tr>
					</thead>
					<tbody id="result_tbl">
						
					</tbody>
				</table>
			</div>
			<?php 
		} else if($id==12){
			if($_SESSION['IS_STOCK']==0){
		?>
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Fabrics</h5>
		<input type="hidden" id="check_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
		<input type="hidden" id="purchase_price" value="0"/>
		<input type="hidden" id="selling_price" value="0"/>
				<label for="comment">Item Type<sup style="color:red">*</sup>:</label>
				<select id="item_type" onchange="typwWiseItem(2);" class="form-control">
					<option value="1">Gents</option>
					<option value="2">Lady</option>
				</select>
				<label for="comment">Fabrics Item Name<sup style="color:red">*</sup>:</label>
				<input type="text" <?php if($_SESSION['IS_STOCK']==1){ ?> onkeyup="selectItemName(1);" <?php } ?> class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="item_name" id="item_name" />
				<?php if($_SESSION['IS_STOCK']==1){ ?>
				 <span id="auto_item" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 263px;"></span>
				<input type="hidden" id="chkAutItem" value=""/>
				
				<label for="comment">Unit:</label>
				<select id="item_unit" class="form-control">
					<option value="পিছ">Piece(পিছ)</option>
					<option value="গজ">Yard(গজ)</option>
					<option value="মিটার">Meter(মিটার)</option>
				</select>
				<label for="comment">Item Code:</label>
				<input type="text" onblur="checkItemCode();" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_code" />
				<?php } ?>
				<button onclick="saveFabrics();" style="margin-top: 12px;" name="btn" value="sub" id="saveFabricsBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				
				<p></p>
			</div>
			<div class="col-xs-12 col-sm-3" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(1);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Item Name/Code" id="search_item_name" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(1);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Stock Qty" id="search_item_stock_qty" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<select id="search_sort_type" onchange="searchStockItem(1);" class="form-control">
					<option value="">Sorting Type</option>
					<option value="asc">SL. ASC</option>
					<option value="desc">SL. DESC</option>
					<?php if($_SESSION['IS_STOCK']==1){ ?>
					<option value="qty_asc">Stock ASC</option>
					<option value="qty_desc">Stock DESC</option>
					<?php } ?>
				</select>
			</div>
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
			
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th style="text-align:center">SL</th>
							<th>Item Name</th>
							<?php if($_SESSION['IS_STOCK']==1){ ?>
							<th style="text-align:center;width: 16%;">Item Code</th>
							<th style="text-align:center">Stock</th>
							<th style="text-align:right">Avg Price</th>
							<?php } ?>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
		<?php 
		}else{
			?>
		<div id="stock_area">
			
			<div class="col-xs-12 col-sm-3">
				<label for="comment">Item Name<sup style="color:red">*</sup>: <span style='color:red;cursor:pointer;text-decoration:underline' onclick="clrAllItem();">Clr</span></label>
				<input type="text" <?php if($_SESSION['IS_STOCK']==1){ ?> onkeyup="selectItemName(1);" <?php } ?>  onkeydown="enterEventSelection('item_name','item_unit')" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" value="<?php if(isset($_SESSION['sitem_name'])) echo $_SESSION['sitem_name']; ?>" name="item_name" id="item_name" />
				
				 <span id="auto_item" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 263px;"></span>
				<input type="hidden" id="chkAutItem" value=""/>
			</div>
			<div class="col-xs-12 col-sm-1">
				<label for="comment">Unit:</label>
				<select id="item_unit" class="form-control">
					<option value="পিছ">পিছ(Piece)</option>
					<option value="গজ">গজ(Yard)</option>
					<option value="মিটার">মিটার(Meter)</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-2" style="text-align: right;">
			
				<input type="hidden" id="check_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				<input type="hidden" id="item_type" value="1"/>
				<label for="comment">Purchase Price<sup style="color:red">*</sup>:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" name="cus_price" onkeydown="enterEventSelection('purchase_price','selling_price')" value="<?php if(isset($_SESSION['spurchase_price'])) echo $_SESSION['spurchase_price']; ?>" id="purchase_price" />
			</div>
			<div class="col-xs-12 col-sm-2" style="text-align: right;">
				<label for="comment">Selling Price:</label>
				<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" name="cus_price" onkeydown="enterEventSelection('selling_price','item_code')" value="<?php if(isset($_SESSION['sselling_price'])) echo $_SESSION['sselling_price']; ?>" id="selling_price" />
			</div>
			<div class="col-xs-12 col-sm-2">
				<label for="comment">Item Code: <span id="duplicte_code" style="color:red"></span></label>
				<input type="text" onblur="checkItemCode();" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_code" />
			</div>	
			<div class="col-xs-12 col-sm-10">
				<span id="save_load">
					<button onclick="saveFabrics();" style="margin-top: 25px;" name="btn" value="sub" id="saveFabricsBtn" class="btn btn-success form-control">Save</button>
				</span>
				
			</div>
		</div>
			<div class="col-xs-12 col-sm-6" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(1);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Item Name/Code" id="search_item_name" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(1);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Stock Qty" id="search_item_stock_qty" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<select id="search_sort_type" onchange="searchStockItem(1);" class="form-control">
					<option value="">Sorting Type</option>
					<option value="asc">SL. ASC</option>
					<option value="desc">SL. DESC</option>
					<?php if($_SESSION['IS_STOCK']==1){ ?>
					<option value="qty_asc">Stock ASC</option>
					<option value="qty_desc">Stock DESC</option>
					<?php } ?>
				</select>
			</div>
		
			<div class="col-xs-12 col-sm-12" style="margin-top: 5px;">
			
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th style="text-align:center">SL</th>
							<th>Item Name</th>
							<?php if($_SESSION['IS_STOCK']==1){ ?>
							<th style="text-align:center;width: 13%;">Item Code</th>
							<th style="text-align:center">Stock</th>
							<th style="text-align:right;width: 12%;">Purchase Price</th>
							<th style="text-align:right;width: 12%;">Selling Price</th>
						
							<?php } ?>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
			<?php 
		}
		} else if($id==13){
		?>
		<div class="col-xs-12 col-sm-2">
		<h5 style="text-align:center">User Form</h5>
				<label for="comment">User Type<sup style="color:red">*</sup>:</label>
				<select id="user_type" onchange="typwWiseUser();" class="form-control">
					<option value="">Select One</option>
					<option value="0">Entry user</option>
					<option value="2">Admin</option>
				</select>
				<label for="comment">User Name<sup style="color:red">*</sup>:</label>
				<input type="text" maxlength="50" name="user" autocomplete="off" class="form-control" placeholder="User Name" id="user_name">
				
				<label for="comment">User Mobile<sup style="color:red">*</sup>:</label>
				<input type="text" maxlength="11" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" name="mobile" autocomplete="off" maxlength="11" class="form-control" placeholder="User Mobile" id="user_mobile">
				<label for="comment">Login user<sup style="color:red">*</sup>:</label>
				<input type="text" maxlength="11" name="user" autocomplete="off" class="form-control" placeholder="Login User" id="login_user">
				<label for="comment">Login Password<sup style="color:red">*</sup>:</label>
				<input type="text" maxlength="11" name="user" autocomplete="off" class="form-control" placeholder="Login Password" id="login_password">
				
				<button onclick="saveUserInfo();" style="margin-top: 12px;" name="btn" value="sub" id="saveUserBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				
				<p></p>
			</div>
			<div class="col-xs-12 col-sm-8" style="margin-top: 5px;">
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>User Name</th>
							<th>Mobile</th>
							<th>Login User</th>
							<th>Login Password</th>
							<th>আজকের বিক্রি(Tk)<br/>ক্যাশ গ্রহণ(Tk)</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						
					</tbody>
				</table>
			</div>
		<?php 
		} else if($id==14){
			$com_id=($_SESSION['COM_ID']);
			$emp_info=$conn->query("select t2.cus_name,t2.cus_mobile,t1.cus_id,t1.earn_point from (SELECT sum(c.point) earn_point,c.cus_id FROM point_tbl c WHERE c.com_id=$com_id and c.is_active=1 group by c.cus_id) t1,customer t2 where t1.cus_id=t2.id");
			mysqli_close($conn);
		?>
		<div class="col-xs-10 col-sm-10" style="margin-top: 5px;">
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Customer Name</th>
							<th>Mobile</th>
							<th style="width: 20%;">Withdraw</th>
							<th style="width: 15%;text-align:right">Earning Point</th>
						</tr>
					</thead>
					<tbody id="">
					<?php 
					if(mysqli_num_rows($emp_info)>0){
						$count=1;
					while($row=mysqli_fetch_array($emp_info)){
						@$j=$count++;
						if($row['earn_point']>0){
					?>
						<tr style="cursor:pointer" onclick="showPoint('<?php echo $row['cus_id']; ?>','<?php echo $row['cus_mobile']; ?>','<?php echo $j; ?>')" id="point_detail<?php echo $j; ?>">
							<td><?php echo $j; ?></td>
							<td><?php echo $row['cus_name']; ?></td>
							<td><?php echo $row['cus_mobile']; ?></td>
							<td>
							<input type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold; font-size: 18px;font-style: italic;text-align: right;width: 68%;float: left;margin-right: 8px; border: 1px solid green;" autocomplete="off" name="tdue" id="width_draw<?php echo $j; ?>" value="<?php echo $row['earn_point']; ?>"/>
							<button onclick="widthDrawBtn('<?php echo $j; ?>',<?php echo $row['cus_id']; ?>);" name="btn" id="widthdarawBtn<?php echo $j; ?>" value="sub" class="btn btn-success">Ok</button>
							</td>
							<td style="text-align:right"><b><span id="last_point<?php echo $j; ?>"><?php echo $row['earn_point']; ?></span></b></td>
						</tr>
					<?php } } } ?>
					</tbody>
				</table>
			</div>
			<span id="sms_point"></span>
		<?php 
		}else if($id==15){
			$com_id=($_SESSION['COM_ID']);
			$supplier=$conn->query("select * from supplier_info ss where ss.is_active=1");
			$product=$conn->query("select ss.id,ss.item_id,ss.dstid direct_salse_head_id,(select cus_mobile from direct_sale_head where id=ss.dstid) supplier_mobile,(select item_code from product where id=ss.item_id) item_code,(select uom from product where id=ss.item_id) item_unit,(select product_name from product where id=ss.item_id) item_name,ss.item_qty,ss.price,ss.insert_date from direct_sale ss where ss.is_active=1 and ss.com_id=$com_id and ss.in_out_status=1 order by ss.id desc limit 0,1000");
			mysqli_close($conn);
		?>
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Stock In</h5>
		<input type="hidden" id="check_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				
				<label for="comment">Item Name<sup style="color:red">*</sup>: <span id="stk_in"></span></label>
				<input type="text" <?php if($_SESSION['is_barcode']==1){ ?> onkeydown="barcodeScan(event);" <?php }else{?>onkeyup="selectItemName(2);"<?php } ?> class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="item_name" id="item_name" />
				
				 <span id="auto_item" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 263px;"></span>
				<input type="hidden" id="chkAutItem" value=""/>
				<input type="hidden" id="previous_stock_qty" value="0"/>
				<input type="hidden" id="previous_total_price" value="0"/>
				<input type="hidden" id="previous_avg_price" value="0"/>
				
				<label for="comment">Unit:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_unit" />
				<label for="comment">Item Code:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_code" />
				<label for="comment">Purchase Per Price:</label>
				<input type="text" class="form-control" onkeyup="CalculatePerPrice();" onkeydown="enterEvent('purchase_price','saveFabricsBtn')" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="purchase_price" />
				<label for="comment">Purchase Qty:</label>
				<input type="text" class="form-control" onkeyup="CalculatePerPrice();" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="purchase_qty" />
				
				<label for="comment">Total Price:</label>
				<input type="text" readonly class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="total_price" />
				<label for="comment">Supplier Info:</label>
				<select class="form-control select2" style="font-weight: bold;font-size:18px;font-style: italic;background:#f9d9a8" id="supplier_mobile">
					<option value="">Select One</option>
					<?php 
					while($rows=mysqli_fetch_array($supplier)){
						?>
						<option value="<?php echo $rows['supplier_mobile']; ?>"><?php echo $rows['supplier_name']; ?></option>
						<?php
						}
						?>
					
				</select>
				
				<button onclick="saveFabricsInStock();" style="margin-top: 12px;" name="btn" value="sub" id="saveFabricsBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				
				<p></p>
			</div>
			<div class="col-xs-12 col-sm-3" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(2);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Item Name/Code" id="search_item_name" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<input type="date" onchange="searchStockItem(2);" autocomplete="off" name="date3" id="date3" class="form-control" data-select="date">
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<select id="search_sort_type" onchange="searchStockItem(2);" class="form-control">
					<option value="">Sorting Type</option>
					<option value="asc">SL. ASC</option>
					<option value="desc">SL. DESC</option>
					<option value="qty_asc">Qty ASC</option>
					<option value="qty_desc">Qty DESC</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
			
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th style="text-align:center">SL</th>
							<th>Item Name</th>
							<th style="text-align:center;width: 12%;text-align:center">In Qty</th>
							<th style="text-align:right">Price</th>
							<th style="text-align:right">Total</th>
							<th style="text-align:center">Supplier Mobile</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						<?php 
						$tqty=0;$ttaka=0;$tprice_row=0;
						if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
								$tqty+=$rows['item_qty'];
								$ttaka+=round(($rows['item_qty']*$rows['price']),2);
								$tprice_row=round(($rows['item_qty']*$rows['price']),2);
								
								$tbl_id=$rows['direct_salse_head_id']; // direct sales head tbl id 
								$item_qty=$rows['item_qty'];
								$item_id=$rows['item_id'];
						?>
							<tr>
								<td style="text-align:center">
								 <?php 
									if($_SESSION['USER_TYPE']==2){
								?>
								<button onclick="delInStockItem('<?php echo $tbl_id; ?>','<?php echo $j; ?>','<?php echo $item_qty; ?>','<?php echo $tprice_row; ?>','<?php echo $item_id; ?>');" name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
									<?php }else{
									echo $j;
								} ?>
								</td>
								<td>
									<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
								</td>
								<td style='text-align:center'><?php echo $rows['item_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
								<td style='text-align:right'><?php echo $rows['price']; ?></td>
								<td style='text-align:right'><?php echo round(($rows['item_qty']*$rows['price']),2); ?></td>
								<td style='text-align:center'><?php echo @$rows['supplier_mobile']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
					}else{
						echo "<input type='hidden' value='0' id='ilast_id'/>";
					}
					?>
					<tr>
						<td colspan="2" style="text-align: right;font-weight: bold;">
							Total Qty: 
						</td>
						<td style="text-align: center;font-weight: bold;">
							<?php echo $tqty; ?>
						</td>
						<td style="text-align: right;font-weight: bold;">
							Total: 
						</td>
						<td style="text-align: right;font-weight: bold;">
							<?php echo $ttaka; ?>
						</td>
					</tr>
					</tbody>
				</table>
			</div>
		<?php 
		}else if($id==40){
			$com_id=($_SESSION['COM_ID']);
			$supplier=$conn->query("select * from supplier_info ss where ss.is_active=1");
			$product=$conn->query("select * from product where is_active=2 order by id desc limit 0,1");
			$txtrow=mysqli_fetch_array($product);
			$item_code=$txtrow['item_code'];
			$purchase_price=$txtrow['purchase_price'];
			$selling_price=$txtrow['selling_price'];
			//mysqli_close($conn);
		?>
		<div class="col-xs-12 col-sm-10">
		   <div class="row" style="margin-bottom: 25px;">
		<h5 style="text-align:center;font-size: 18px;font-weight: bold;text-decoration: underline;color: blue;">Stock In</h5>
		<input type="hidden" id="check_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				<div class="col-xs-12 col-sm-3">	
				<label for="comment">Item Name<sup style="color:red">*</sup>: <span id="stk_in"></span></label>
				<input type="text" <?php if($_SESSION['is_barcode']==1){ ?> onclick="barcodeScanClick();" <?php }else{?> onkeyup="selectItemName(2);"<?php } ?> class="form-control" value="<?php echo $item_code; ?>" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="item_name" id="item_name" />
				
				 <span id="auto_item" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 263px;"></span>
				<input type="hidden" id="chkAutItem" value=""/>
				<input type="hidden" id="previous_stock_qty" value="0"/>
				<input type="hidden" id="previous_total_price" value="0"/>
				<input type="hidden" id="previous_avg_price" value="0"/>
				<input type="hidden" id="selling_price" value="<?php echo $selling_price; ?>"/>
				</div>
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Unit:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_unit" />
				</div>
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Item Code:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_code" />
				</div>
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Purchase Per Price:</label>
				<input type="text" class="form-control" onkeyup="CalculatePerPrice();" value="<?php echo $purchase_price; ?>" onkeydown="enterEvent('purchase_price','saveFabricsBtn')" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="purchase_price" />
				</div>
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Purchase Qty:</label>
				<input type="text" class="form-control" onkeyup="CalculatePerPrice();" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="purchase_qty" />
				</div>
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Total Price:</label>
				<input type="text" readonly class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="total_price" />
				</div>
				
					<div class="col-xs-12 col-sm-3">
				<label for="comment">Supplier Info:</label>
				<select class="form-control select2" style="font-weight: bold;font-size:18px;font-style: italic;background:#f9d9a8" id="supplier_mobile">
					<option value="">Select One</option>
					<?php 
					while($rows=mysqli_fetch_array($supplier)){
						?>
						<option value="<?php echo $rows['supplier_mobile']; ?>"><?php echo $rows['supplier_name']; ?></option>
						<?php
						}
						?>
					
				</select>
				</div>
					<div class="col-xs-12 col-sm-3">
				<button onclick="saveFabricsInStockClick();" style="margin-top: 24px;" name="btn" value="sub" id="saveFabricsBtn" class="btn btn-success form-control">Save</button>
				</div>
				<span id="save_load">
				
				</span>
				
				<p></p>
				</div>
			</div>
		
			
		<?php 
		}else if($id==16){
			$com_id=($_SESSION['COM_ID']);
			$product=$conn->query("select ss.id,ss.item_id,(select item_code from product where id=ss.item_id) item_code,(select uom from product where id=ss.item_id) item_unit,(select product_name from product where id=ss.item_id) item_name,ss.adjustment_qty,ss.remarks,ss.insert_date,(select user_name from user where id=ss.insert_by) adjust_by from stock_adjustment ss where ss.is_active=1 order by ss.id desc limit 0,100");
			mysqli_close($conn);
		?>
		<div class="col-xs-12 col-sm-3">
		<h5 style="text-align:center">Stock Adjustment</h5>
				
				<label for="comment">Item Name<sup style="color:red">*</sup>:</label>
				<input type="text" onkeyup="selectItemName(3);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="item_name" id="item_name" />
				
				 <span id="auto_item" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 263px;"></span>
				<input type="hidden" id="chkAutItem" value=""/>
				<input type="hidden" id="previous_total_price" value="0"/>
				
				<label for="comment">Unit:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_unit" />
				<label for="comment">Item Code:</label>
				<input type="text" readonly class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="item_code" />
				<label for="comment">Present Stock Qty:</label>
				<input type="text" readonly class="form-control" autocomplete="off"  style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="previous_stock_qty" />
				<label for="comment">Adjustment Qty:</label>
				<input type="number" class="form-control" onkeyup="CalculateAdjustmentQty();" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="adjustment_qty" />
				<label for="comment">Final Qty:</label>
				<input type="text" readonly class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="final_qty" />
				<label for="comment">Average Price:</label>
				<input type="text" onkeyup="CalculateAdjustmentQty();" class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="previous_avg_price" />
				<label for="comment">Total Price:</label>
				<input type="text" readonly class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="total_price" />
				
				<button onclick="saveStockAdjustment();" style="margin-top: 12px;" name="btn" value="sub" id="saveFabricsBtn" class="btn btn-success form-control">Save</button>
				<span id="save_load">
				
				</span>
				
				<p></p>
			</div>
			<div class="col-xs-12 col-sm-3" style="margin-top: 5px;">
				<input type="text" onkeyup="searchStockItem(3);" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" placeholder="Item Name/Code" id="search_item_name" />
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<input type="date" onchange="searchStockItem(3);" autocomplete="off" name="date3" id="date3" class="form-control" data-select="date">
			</div>
			<div class="col-xs-12 col-sm-2" style="margin-top: 5px;">
				<select id="search_sort_type" onchange="searchStockItem(3);" class="form-control">
					<option value="">Sorting Type</option>
					<option value="asc">SL. ASC</option>
					<option value="desc">SL. DESC</option>
					<option value="qty_asc">Qty ASC</option>
					<option value="qty_desc">Qty DESC</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-7" style="margin-top: 5px;">
			
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th style='text-align:center'>SL</th>
							<th>Item Name</th>
							<th style="text-align:center;width: 14%;">Adjus. Qty</th>
							<th style="text-align:center">Remarks</th>
							<th style="text-align:center">Insert By</th>
						</tr>
					</thead>
					<tbody id="item_tbl">
						<?php 
						$tqty=0;$ttaka=0;
						if(mysqli_num_rows($product)>0){
						$i=1;
							while($rows=mysqli_fetch_array($product)){
								$j=$i++;
								$tqty+=$rows['adjustment_qty'];
						?>
							<tr>
								<td style='text-align:center'>
									<?php echo $j; ?></td>
								<td>
									<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
								</td>
								<td style='text-align:center'><?php echo $rows['adjustment_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
								<td style='text-align:center'><?php echo $rows['remarks']; ?></td>
								<td style='text-align:center'><?php echo @$rows['adjust_by']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
							</tr>
						<?php 
							}
							echo "<input type='hidden' value='$j' id='ilast_id'/>";
			
					}else{
						echo "<input type='hidden' value='0' id='ilast_id'/>";
					}
					?>
				
					</tbody>
				</table>
			</div>
		<?php 
		} else if($id==17){
			$com_id=($_SESSION['COM_ID']);
			$product=$conn->query("select ss.id,ss.item_id,(select item_code from product where id=ss.item_id) item_code,(select uom from product where id=ss.item_id) item_unit,(select product_name from product where id=ss.item_id) item_name,ss.adjustment_qty,ss.remarks,ss.insert_date,(select user_name from user where id=ss.insert_by) adjust_by from stock_adjustment ss where ss.is_active=1 order by ss.id desc limit 0,100");
			mysqli_close($conn);
		?>
		<div class="col-xs-12 col-sm-3">
			<h5 style="text-align:center">Job Manage</h5>
				
				<label for="comment">Job Type<sup style="color:red">*</sup>:</label>
				<select id="job_type" onchange="showJobType();" class="form-control">
					<option value="">Select One</option>
					<option value="0">Job Receive</option>
					<option value="1">Payment (Tk)</option>
				</select>
				<div id="show_job_form">
				</div>
				<p></p>
		</div>
			
			<div class="col-xs-12 col-sm-7" id="right_result" style="margin-top: 5px;">
				
			</div>
		<?php 
		}
	}
	
	if(isset($_REQUEST['showJobType'])){
		$job_type=($_REQUEST['job_type']);
		if($job_type==0){ // job assign
			?>
			<label for="comment">Employee Type:</label>
			<select id="get_emp_type" onchange="getEmp();" style="" class="form-control">
					<option value="">Select One</option>
					<option value="1">Master</option>
					<option value="2">Karigor</option>
			</select>
			<label for="comment">Employee Name:</label>
			<select id="emp_name_details" onchange="getDueDetails('0');" style="" class="form-control">
					<option value="">Select One</option>
			</select>
			<label for="comment">Order No:</label>
			<input type="text" class="form-control"  style="font-weight: bold;font-size:18px;font-style: italic;text-transform:uppercase" autocomplete="off" name="edit_ord_number" onkeyup="getSrcableOrder()" id="src_ord_number" required/>
			<span id="srcable_auto_mobile" style="z-index: 99999999999999;overflow: hidden;position: fixed;width: 240px;">
			</span>
			<div id="show_order_info">
			</div>
			<label for="comment">Taka:</label>
			<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="emp_wages" />
			<label for="comment">Remarks:</label>
			<input type="text" class="form-control" autocomplete="off"  style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="remarks" />
			
			<span id="save_load"></span>
			<?php 
		}
		if($job_type==1){ // payment
			?>
			<label for="comment">Employee Type:</label>
			<select id="get_emp_type" style="" onchange="getEmp();" class="form-control">
					<option value="">Select One</option>
					<option value="1">Master</option>
					<option value="2">Karigor</option>
					
			</select>
			<label for="comment">Employee Name:</label>
			<select id="emp_name_details" style="" onchange="getDueDetails('1');" class="form-control">
					<option value="">Select One</option>
					
			</select>
			<label for="comment">Taka:</label>
			<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="emp_wages" />
			<label for="comment">Remarks:</label>
			<input type="text" class="form-control" autocomplete="off"  style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_price" id="remarks" />
			
			<button onclick="savePaymet('1');" style="margin-top: 12px;" name="btn" value="sub" id="jobAssignBtn" class="btn btn-success form-control">Save</button>
			<span id="save_load"></span>
			<?php 
		}
	}
	
	if(isset($_REQUEST['getDueDetails'])){
		date_default_timezone_set("Asia/Dhaka");
		$date=date("Y-m-d");
		$param=($_REQUEST['param']);
		$emp_id=($_REQUEST['emp_id']);
		$job_type=$_REQUEST['job_type']; //assign, payment
		
		$summery=$conn->query("SELECT `taka` FROM `wages_head` WHERE emp_id=$emp_id");
		if(mysqli_num_rows($summery)>0){
			$row=mysqli_fetch_array($summery);
			$balance=$row['taka'];
			$emp_info=$conn->query("SELECT id,emp_id,status,`order_num`,`item_name`,`item_qty`,`taka`,`remarks`,`insert_date`,date(`insert_date`) indate,ord_record_tblid FROM `wages_details` WHERE emp_id=$emp_id and is_active=1 and `status`=$job_type order by id desc limit 0,200");
		?>
		<h3 id="tot_balance">Present Balance: <?php echo @$balance; ?>/=</h3>
		<table id="example" class="table table-striped table-bordered">
			<thead>
				<tr>
					<th style='text-align:center'>SL</th>
					<th>Order No.</th>
					<th style="text-align:center;width: 14%;">Item Name</th>
					<th style="text-align:center">Item Qty</th>
					<th style="text-align:center">Remarks</th>
					<th style="text-align:right">Taka</th>
					<th style="text-align:center">Insert Date</th>
				</tr>
			</thead>
					<tbody id="item_tbl">
						<?php 
						$i=1;
						while($row=mysqli_fetch_array($emp_info)){
							$c=$i++;
							?>
						<tr>
							<td style='text-align:center'>
							<?php 
							if($job_type==0){
							?>
								<button onclick="delItemPayment('<?php echo $row['id']; ?>','<?php echo $c; ?>','<?php echo $row['taka']; ?>','<?php echo $row['emp_id']; ?>','<?php echo $row['status']; ?>','<?php echo $row['ord_record_tblid']; ?>');" name='btn' id='delbtns<?php echo $c; ?>' class="btn btn-danger form-control"><?php echo $c; ?></button>
							<?php
							}else 
							if($date==$row['indate'] && $job_type==1){
							?>
							<button onclick="delItemPayment('<?php echo $row['id']; ?>','<?php echo $c; ?>','<?php echo $row['taka']; ?>','<?php echo $row['emp_id']; ?>','<?php echo $row['status']; ?>','<?php echo $row['ord_record_tblid']; ?>');" name='btn' id='delbtns<?php echo $c; ?>' class="btn btn-danger form-control"><?php echo $c; ?></button>
							<?php }else{
								 echo $c; 
							} ?>
							</td>
							<td><?php echo $row['order_num']; ?></td>
							<td><?php echo $row['item_name']; ?></td>
							<td><?php echo $row['item_qty']; ?></td>
							<td><?php echo $row['remarks']; ?></td>
							<td style="text-align:right"><?php echo $row['taka']; ?></td>
							<td><?php echo $row['insert_date']; ?></td>
						<tr>	
							<?php 
						}
						?>
					</tbody>
					<input type="hidden" value="<?php echo @$c; ?>" id="right_tbl_id"/>
				</table>
		<?php 
		}else{
			?>
			<input type="hidden" value="0" id="right_tbl_id"/>
			<?php 
		}
		
		
		
	}
	
	if(isset($_REQUEST['srchForOrdDetails'])){
		$ord_number=trim($_REQUEST['ord_number']);
		$get_emp_type=($_REQUEST['get_emp_type']);
		$com_id=$_SESSION['COM_ID'];
		if($get_emp_type==1){
			$item_sql=$conn->query("SELECT ord.id,ord.receive_qty,ord.master_cutting_qty,ord.item_qty,ord.item_id,ord.dsms_id,(select product_name from product where id=ord.item_id) item_name,(SELECT master_price from product where id=ord.item_id) wages,(select user_name from user where id=ord.master_emp_id) karigor_name FROM `order_record` ord WHERE ord.is_active=1 and com_id=$com_id and ord.`order_number`='$ord_number'");
		}
		if($get_emp_type==2){
			$item_sql=$conn->query("SELECT ord.id,ord.receive_qty,ord.item_qty,ord.item_id,ord.dsms_id,(select product_name from product where id=ord.item_id) item_name,(SELECT artisan_price from product where id=ord.item_id) wages,(select user_name from user where id=ord.maker) karigor_name FROM `order_record` ord WHERE ord.is_active=1 and com_id=$com_id and ord.`order_number`='$ord_number'");
		}
		if(mysqli_num_rows($item_sql)>0){
			echo "<br/><ol style='margin-left: -24px;'>";
			$c=1;
			while($row=mysqli_fetch_array($item_sql)){
				$name=$row['karigor_name'];
				$receive_qty=($get_emp_type==1)? $row['master_cutting_qty'] : $row['receive_qty'];
				
				$j=$c++;
				?>
				<li>
					<span style="cursor:pointer;font-size:12px;font-weight:bold" title="<?php echo @$name; ?>"><?php echo $row['item_name'];?>(<?php echo $row['id'];?>)<input type='hidden' value='<?php echo $row['item_name'];?>' id='src_item_name<?php echo $j; ?>'/><input type='hidden' value='<?php echo $row['item_id'];?>' id='src_item_id<?php echo $j; ?>'/><input type='hidden' value='<?php echo $row['id'];?>' id='src_ord_tbl_id<?php echo $j; ?>'/></span> |<span style="font-size:12px;font-weight:bold"> Qty: <input style="width: 15%;text-align:center" <?php echo ($row['item_qty']==$receive_qty)? "readonly" : ""; ?> id="srcitem_qty<?php echo $j; ?>" onkeyup="setItemPrice('1');" type="text" value="<?php echo ($row['item_qty']==$receive_qty)? "" : ($row['item_qty']-$receive_qty); ?>"/> | Rate: <input type="hidden" id="rate<?php echo $j; ?>" value="<?php echo $row['wages'];?>"/><?php echo $row['wages'];?>/=</span>
				
				</li>
				<?php 
			}
			echo "</ol>";
			echo "<input type='hidden' id='tot_rate' value='$j'/>";
		}else{
			echo 2;
		}
		
	}
	
	if(isset($_REQUEST['getEmp'])){
		$get_emp_type=($_REQUEST['get_emp_type']);
		$com_id=$_SESSION['COM_ID'];
		$emp_info=$conn->query("SELECT ord.id,ord.user_name,ord.mobile FROM `user` ord WHERE ord.is_active=1 and salary_type=1 and emp_type=$get_emp_type");
		if(mysqli_num_rows($emp_info)>0){
			$c=1;
			echo '<option value="">Select One</option>';
			while($row=mysqli_fetch_array($emp_info)){
				?>
				<option value="<?php echo $row['id'];?>"><?php echo $row['user_name']."(".$row['mobile'].")"; ?></option>
				<?php 
			}
			
		}else{
			echo 2;
		}
		
	}
	
	if(isset($_REQUEST['updateAnyColumn'])){
		$mobile=$_REQUEST['mobile'];
		$cus_id=$_REQUEST['cus_id'];
		$id=$_REQUEST['id'];
		?>
		<input style="text-align: center;width: 100%;" onkeyup="updateFabMobile('<?php echo $id; ?>','<?php echo $cus_id; ?>');" type="text" value="<?php echo $mobile; ?>" id="cus_mobile_edit_field<?php echo $id; ?>" class="form-control"/>
		<?php 
	}
	
	if(isset($_REQUEST['updateFabMobile'])){
		$mobile=trim($_REQUEST['mobile']);
		$id=$_REQUEST['id'];
		$cus_id=$_REQUEST['cus_id'];
		$conn->query("update customer set cus_mobile='$mobile' where id=$cus_id");
		$last_insert_head=$conn->query("update direct_sale_head set cus_mobile='$mobile' where id=$id");
		if($last_insert_head){
			echo 1;
		}
	}
	
	if(isset($_REQUEST['saveJobAssign'])){
		date_default_timezone_set("Asia/Dhaka");
		$assign_date=date("d/m/Y");
		$com_id=($_SESSION['COM_ID']);
		$user_id=($_SESSION['USER_ID']);
		$emp_id=($_REQUEST['emp_id']);
		@$order_num=($_REQUEST['order_num']);
		$taka=($_REQUEST['taka']);
		$remarks=($_REQUEST['remarks']);
		@$item_name=($_REQUEST['item_name']);
		@$item_idss=($_REQUEST['item_id']);
		$get_emp_type=($_REQUEST['get_emp_type']);
		$item_id=explode(",",$_REQUEST['item_id']);
		$ex_item_name=explode(",",$item_name);
		$ord_tbl_id=explode(",",$_REQUEST['ord_tbl_id']);
		@$item_qty=($_REQUEST['item_qty']);
		$status=($_REQUEST['param']);
		$right_tbl_id=($_REQUEST['right_tbl_id']);
		$emp_info=$conn->query("SELECT id,taka from wages_head where emp_id=$emp_id and com_id=$com_id");
		if(mysqli_num_rows($emp_info)>0){
			$row=mysqli_fetch_array($emp_info);
			$id=$row['id'];
			$utaka=($row['taka']+$taka);
			$last_insert_head=$conn->query("update wages_head set taka='$utaka' where id=$id");
		}else{
			$last_insert_head=$conn->query("insert into wages_head(com_id,emp_id,taka) values ($com_id,$emp_id,'$taka')");
			
		}
		
		if($order_num!=""){
				$update_qty_a=explode(",",$item_qty);
				for($i=0; $i<count($item_id); $i++){
					$update_qty=$update_qty_a[$i];
					$item_ids=$item_id[$i];
					$tbl_id=$ord_tbl_id[$i];
					$item_name=$ex_item_name[$i];
					$work_tk_sql=$conn->query("SELECT * from product where id=$item_ids");
					$row_work_tk=mysqli_fetch_array($work_tk_sql);
					if($get_emp_type==2){ //karigor 
						$rec_qty=$conn->query("SELECT * from order_record where id=$tbl_id and is_active=1");
						$row=mysqli_fetch_array($rec_qty);
						$receive_qty=$row['receive_qty'];
						$work_tk=($row_work_tk['artisan_price']*$update_qty);
						$conn->query("update order_record set assign_date='$assign_date',receive_qty=($update_qty+$receive_qty),maker=$emp_id,emp_type=$get_emp_type where id=$tbl_id");
					}else{ // master=1
						$rec_qty=$conn->query("SELECT * from order_record where id=$tbl_id and is_active=1");
						$row=mysqli_fetch_array($rec_qty);
						$receive_qty=$row['master_cutting_qty'];
						$work_tk=($row_work_tk['master_price']*$update_qty);
						$conn->query("update order_record set master_assign_date='$assign_date',master_cutting_qty=($update_qty+$receive_qty),master_emp_id=$emp_id where id=$tbl_id");
					}
					
					$last_insert=$conn->query("insert into wages_details(com_id,
								emp_id,
								order_num,
								taka,
								remarks,
								item_name,
								item_qty,
								status,
								item_ids,
								emp_type,
								ord_record_tblid,
								insert_by
								) values($com_id,
								$emp_id,
								'$order_num',
								'$work_tk',
								'$remarks',
								'$item_name',
								'$update_qty',
								'$status',
								'$item_ids',
								'$get_emp_type',
								'$tbl_id',
								$user_id)");
				}
			
		}else{
			$last_insert=$conn->query("insert into wages_details(com_id,
						emp_id,
						order_num,
						taka,
						remarks,
						item_name,
						item_qty,
						status,
						item_ids,
						emp_type,
						insert_by
						) values($com_id,
						$emp_id,
						'$order_num',
						'$taka',
						'$remarks',
						'$item_name',
						'$item_qty',
						'$status',
						'$item_idss',
						'$get_emp_type',
						$user_id)");
		}
		
		
			
			if($order_num!=""){
					$ord_tbl_select=$conn->query("select itbl.iitem_qty,rtbl.rreceive_qty from (SELECT sum(item_qty) iitem_qty FROM `order_record` WHERE `com_id`=$com_id and is_active=1 and order_number='$order_num') itbl, (SELECT sum(receive_qty) rreceive_qty FROM `order_record` WHERE `com_id`=$com_id and is_active=1 and order_number='$order_num' and `emp_type`=2) rtbl");
				$ord_tbl_selecta=mysqli_fetch_array($ord_tbl_select);
				//if($ord_tbl_selecta['receive_test']==1){
				if($ord_tbl_selecta['iitem_qty']==$ord_tbl_selecta['rreceive_qty']){
					$date=date("Y-m-d");
					$chk_com=$conn->query("update dsms set factory_status=1,factory_receive_date='$date' where tagnum='$order_num' and com_id=$com_id");
						if($from_factory_recive_live_sms==1){ // 1=means active order live smsm 
							if($get_emp_type==2){ //karigor 
								if(check_internet_connection()==1){
									$cus_mobiles=$conn->query("SELECT cus_mobile FROM `dsms` WHERE `com_id`=$com_id and is_active=1 and tagnum='$order_num'");
									$cus_mobilea=mysqli_fetch_array($cus_mobiles);
									$mobile=$cus_mobilea['cus_mobile'];
									$response = file_get_contents($_SESSION['API']."api/data.php?com_id=$com_id&cus_mobile=$mobile&order_no=$order_num&chk=11"); //chk=2 means check sms
									$json = json_decode($response, true);
								}
							}
						}
					
				}
			}
		
		if($last_insert){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['savePaymet'])){
		$due_tk="";
		$com_id=($_SESSION['COM_ID']);
		$user_id=($_SESSION['USER_ID']);
		$emp_id=($_REQUEST['emp_id']);
		$taka=($_REQUEST['taka']);
		$remarks=($_REQUEST['remarks']);
		$status=($_REQUEST['param']);
		$right_tbl_id=($_REQUEST['right_tbl_id']);
		$emp_info=$conn->query("SELECT id,taka from wages_head where emp_id=$emp_id and com_id=$com_id");
		$emp_info_mobile=$conn->query("SELECT mobile from user where id=$emp_id");
		$row_mobile=mysqli_fetch_array($emp_info_mobile);
		$cus_mobile=$row_mobile['mobile'];
		if(mysqli_num_rows($emp_info)>0){
			$row=mysqli_fetch_array($emp_info);
			$id=$row['id'];
			$utaka=($row['taka']-$taka);
			$due_tk=$utaka;
			$last_insert_head=$conn->query("update wages_head set taka='$utaka' where id=$id");
		}else{
			if($status==1){ // at first advance payment 
				$last_insert_head=$conn->query("insert into wages_head(com_id,emp_id,taka) values ($com_id,$emp_id,'-$taka')");
				$due_tk=-$taka;
			}else{
				$last_insert_head=$conn->query("insert into wages_head(com_id,emp_id,taka) values ($com_id,$emp_id,'$taka')");
				$due_tk=$taka;
			}
		}
		$last_insert=$conn->query("insert into wages_details(com_id,
			emp_id,
			taka,
			remarks,
			status,
			insert_by
			) values($com_id,
			$emp_id,
			'$taka',
			'$remarks',
			'$status',
			$user_id)");
			
			 if($wages_sms==1){ // 1=means active order live smsm 
				if(check_internet_connection()==1){
					
					$response = file_get_contents($_SESSION['API']."api/data.php?com_id=$com_id&cus_mobile=$cus_mobile&taka=$taka&remarks=1&balance=$due_tk&chk=12"); //chk=2 means check sms
					$json = json_decode($response, true);
				}
			} 
		
		if($last_insert){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['widthDrawBtn'])){
		$com_id=($_SESSION['COM_ID']);
		$cus_id=($_REQUEST['cus_id']);
		$width_draw=($_REQUEST['width_draw']);
		$paidpoint=$conn->query("insert into point_tbl(cus_id,point,com_id) values($cus_id,'-$width_draw',$com_id)");
		if($paidpoint){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['show_point_details'])){
		$com_id=($_SESSION['COM_ID']);
		$cus_id=($_REQUEST['cus_id']);
		$mobile=($_REQUEST['mobile']);
			$emp_info=$conn->query("SELECT c.point earn_point,c.cus_id,c.insert_date FROM point_tbl c WHERE c.com_id=$com_id and c.cus_id=$cus_id and c.is_active=1");
			mysqli_close($conn);
		?>
		<div class="col-xs-10 col-sm-10" style="margin-top: 5px;">
			<h3>Mobile: <?php echo $mobile; ?></h3>
				<table id="example" class="table table-striped table-bordered">
					<thead>
						<tr>
							<th>SL</th>
							<th>Earning Date</th>
							<th style="width: 15%;text-align:right">Earning Point</th>
						</tr>
					</thead>
					<tbody id="">
					<?php 
					if(mysqli_num_rows($emp_info)>0){
						$count=1;$total=0;
					while($row=mysqli_fetch_array($emp_info)){
						@$j=$count++;
						$total+=$row['earn_point'];
					?>
						<tr>
							<td><?php echo $j; ?></td>
							<td><?php echo $row['insert_date']; ?></td>
							<td style="text-align:right"><b><?php echo $row['earn_point']; ?></b></td>
						</tr>
						
					<?php } } ?>
					<tr>
						<td colspan="2" style="text-align:right">Total Point</td>
						<td style="text-align:right"><b><?php echo $total; ?></b></td>
					</tr>
					</tbody>
				</table>
			</div>
		<?php 
		
	}
	
	if(isset($_REQUEST['customerForm'])){
		?>
		<div class="col-xs-12 col-sm-6">
			<div class="row">
				<div class="col-xs-12 col-sm-12">
					<label for="comment">Customer Name:</label>
					<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="smobile" id="customer_name" />
				</div>
				<div class="col-xs-12 col-sm-12">
					<label for="comment">Customer Mobile Number:<sup style="color:red">*</sup></label>
					<input type="text" maxlength="11" class="form-control" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="smobile" id="customer_mobile" />
				</div>
				<div class="col-xs-12 col-sm-12">
					<label for="comment">Customer Address:</label>
					<input type="text" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="smobile" id="customer_address" />
				</div>
				<div class="col-xs-12 col-sm-12" style="margin-top: 15px;">
					<button onclick="saveCustomer();" name="btn" id="saveBtns" value="sub" class="btn btn-info">Save</button>
					<button onclick="canceForm();" name="btn" id="cancelBtns" value="sub" class="btn btn-danger">Cancel</button>
					<span id="save_sms"></span>
				</div>
			</div>
		</div>
		<?php 
	}
	

	
	if(isset($_REQUEST['dueAdjustment'])){
		$cus_id=$_REQUEST['cus_id'];
		$cus_mobile=$_REQUEST['cus_mobile'];
		$tk_type=$_REQUEST['tk_type'];
		$adjust_tk=$_REQUEST['adjust_tk'];
		$tk_remarks=$_REQUEST['tk_remarks'];
		$payment_type=$_REQUEST['payment_type'];
		$hscus_name=$_REQUEST['hscus_name'];
		$previous_due=$_REQUEST['cus_last_due'];
		$user_id=$_SESSION['USER_ID'];
		$com_id=($_SESSION['COM_ID']);
		
		
		
		if($tk_type==0){
			//if($tk_remarks==""){
				$tk_remarks.="[ বাকি প্রদান অথবা Adjustment(+) ]-$payment_type";
			//}
			//echo dueTblUpdate($cus_id,$adjust_tk,0,$tk_remarks,'0');
			$conn->query("insert into transaction(cus_id,com_id,amount,status,remarks,insert_by,transaction_type,method_name) values($cus_id,$com_id,'$adjust_tk',$tk_type,'$tk_remarks',$user_id,'0','$payment_type')");
			echo $conn->query("insert into update_due(cus_id,com_id,last_due) values($cus_id,$com_id,(select ud.last_due+$adjust_tk from update_due ud where ud.com_id=$com_id and ud.cus_id=$cus_id and ud.is_active=1 order by ud.id desc limit 0,1))");
		}else{
			if(payToSms()==1){ //for offline
				
				if(check_internet_connection()==1){
					$mobiles=$cus_mobile;
					$response = file_get_contents($_SESSION['API']."api/data.php?com_id=$com_id&previous_due=$previous_due&paytxt=$adjust_tk&mobiles=$mobiles&chk=13"); //chk=5 means dv date update sms
					$json = json_decode($response, true);
					
				}
			}
			
				$tk_remarks.="[ $hscus_name এর বাকি গ্রহণ  অথবা Adjustment(=) ]-$payment_type";
			
			echo dueTblUpdate($cus_id,$adjust_tk,1,$tk_remarks,1); // 1= due receive from cus from due adjustment panel 
		}	
	}
	
	if(isset($_REQUEST['getLastResult'])){
		$cus_id=$_REQUEST['cus_id'];
		@$days=$_REQUEST['days'];
		if($days==""){
			$days=24;
		}
		$com_id=($_SESSION['COM_ID']);
		$last_closing=$conn->query("SELECT tt.`last_due`,date(tt.insert_date) closing_date FROM `update_due` tt WHERE date(tt.`insert_date`)=(select date(`insert_date`) FROM `transaction` WHERE `is_active`=1 and `cus_id`=$cus_id and `com_id`=$com_id order by id desc limit $days,1) and tt.cus_id=$cus_id and tt.com_id=$com_id order by tt.id desc limit 0,1");
		$last_details=$conn->query("SELECT id,amount,date(insert_date) dates,remarks,status,(select user_name from user where id=transaction.insert_by) insert_by FROM `transaction` WHERE `is_active`=1 and `cus_id`=$cus_id and `com_id`=$com_id and date(`insert_date`)>(SELECT date(tt.`insert_date`) FROM `transaction` tt WHERE tt.`is_active`=1 and tt.`cus_id`=$cus_id and tt.`com_id`=$com_id order by tt.id desc limit $days,1)");
		
		$i=1;
		$close_due=0;
		if(mysqli_num_rows($last_closing)>0){
		$close=mysqli_fetch_array($last_closing);
		?>
		<tr style="background: #f5d433;">
			<td style="text-align:center">***</td>
			<td><?php echo Converter::en2bn($close['closing_date']); ?></td>
			<td style="text-align: right;font-weight:bold"><?php echo Converter::en2bn($close_due=$close['last_due']); ?></td>
			<td style="font-weight:bold">Total Due of last closing</td>
			<td></td>
		</tr>
		<?php 
		}else{
			$last_details=$conn->query("SELECT id,amount,date(insert_date) dates,remarks,status,(select user_name from user where id=transaction.insert_by) insert_by FROM `transaction` WHERE `is_active` in(0,1) and `cus_id`=$cus_id and `com_id`=$com_id");	
		}
		mysqli_close($conn);
		$sl=1;$status="";
		date_default_timezone_set("Asia/Dhaka");
		$date=date("Y-m-d");
		if(mysqli_num_rows($last_details)>0){
			while($rows=mysqli_fetch_array($last_details)){
				$sl=$i++;
				if($rows['status']==0){
					$status="+";
					$close_due+=$rows['amount'];
				}else{
					$status="-";
					$close_due-=$rows['amount'];
				}
				?>
				<tr id="delete_row<?php echo $sl; ?>">
					<td style="text-align:center">
					<?php 
					if($date==$rows['dates']){
					?>
					<button onclick="delCustomerDue('<?php echo $rows['amount']; ?>','<?php echo $rows['id']; ?>','<?php echo $sl; ?>','<?php echo $rows['status']; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>">
					<?php echo $sl; ?>
					</button>
					<?php }else{
						echo $sl;
					} ?>
					</td>
					<td><?php echo Converter::en2bn($rows['dates']); ?></td>
					<td style="text-align: right;font-weight:bold"><?php echo Converter::en2bn($status.$rows['amount']); ?></td>
					<td><?php echo $rows['remarks']; ?></td>
					<td><?php echo $rows['insert_by']; ?></td>
				</tr>
				<?php 
			}
			?>
			<tr>
				<input type="hidden" value="<?php echo (@$close_due=="")? 0 : @$close_due; ?>" id="cus_last_due"/>
				<td colspan="2" style="text-align:right;font-weight: bold;">সর্বমোট বাকি :</td>
				<td style="text-align: right;font-weight: bold;">=<?php echo Converter::en2bn($close_due); ?></td>
			</tr>
			<?php 
		}else{
			echo "";
		}
					
	}
	
	if(isset($_REQUEST['searhMobileNumber'])){
		$src_cus_mobile=$_REQUEST['src_cus_mobile'];
		$com_id=($_SESSION['COM_ID']);
		if($src_cus_mobile!=""){
			$emp_info=$conn->query("SELECT c.id,c.cus_name,c.cus_mobile,c.cus_address,(select last_due from update_due where cus_id=c.id and is_active=1 order by id desc limit 0,1) due_amount FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 and (c.cus_mobile like '%$src_cus_mobile%' or c.cus_name like '%$src_cus_mobile%')");
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					?>
					<tr>
						<td><?php echo $sl; ?></td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_name<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','1');" value="<?php echo @$rows['cus_name']; ?>" /></td>
						<td><?php echo $rows['cus_mobile']; ?></td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_address<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','2');" value="<?php echo @$rows['cus_address']; ?>" /></td>
						<td style="text-align: right;font-weight:bold"><?php echo englishToBangla($rows['due_amount']); ?>/=</td>
					</tr>
					<?php 
				}
			}else{
				echo "";
			}
		}else{
			$emp_info=$conn->query("SELECT c.id,c.cus_name,c.cus_mobile,c.cus_address,(select last_due from update_due where cus_id=c.id and is_active=1 order by id desc limit 0,1) due_amount FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 limit 0,100");
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					?>
					<tr>
						<td><?php echo $sl; ?></td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_name<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','1');" value="<?php echo @$rows['cus_name']; ?>" /></td>
						<td><?php echo $rows['cus_mobile']; ?></td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_address<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','2');" value="<?php echo @$rows['cus_address']; ?>" /></td>
						<td style="text-align: right;font-weight:bold"><?php echo englishToBangla($rows['due_amount']); ?>/=</td>
					</tr>
					<?php 
				}
			}else{
				echo "";
			}
			
		}
		
	}
	
	if(isset($_REQUEST['searchStockItem'])){
			$search_item_name=$_REQUEST['search_item_name'];
			@$search_item_stock_qty=$_REQUEST['search_item_stock_qty'];
			$search_sort_type=$_REQUEST['search_sort_type'];
			$search_page_type=$_REQUEST['search_page_type'];
			
			$item_type=$_REQUEST['item_type'];
			$com_id=($_SESSION['COM_ID']);
		if($search_page_type==1){ // stock page area 
		$con="";
			$sort=" order by pp.id asc limit 0,2500";
			if($search_sort_type=="asc" || $search_sort_type=="desc"){
				$sort=" order by pp.id $search_sort_type limit 0,2500";
			}else if($search_sort_type=="qty_asc" || $search_sort_type=="qty_desc"){
				$stype=explode("_",$search_sort_type);
				$search_sort_type=$stype[1];
				$sort=" order by cast(pp.stock_qty as decimal(20,2)) $search_sort_type limit 0,2500";
			}
			if($search_item_stock_qty!=""){
				$con=" and pp.stock_qty='$search_item_stock_qty' ";
			}
			if($search_item_name!=""){
				$product=$conn->query("select * from product pp where pp.is_active=2 and pp.com_id=$com_id and pp.ptype=$item_type and (pp.product_name like '%$search_item_name%' or pp.item_code like '%$search_item_name%') $con $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
							?>
								<tr>
									<td style="text-align:center">
										<?php 
										if($rows['stock_qty']>0){
											echo $j;
										}else{
											
											if($_SESSION['LOG_USER']=='admin'){
											?>
											<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
											<?php }else{
												echo $j;
											} 
										}
										?>
									</td>
									<td>
										<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','5');" value="<?php echo $rows['product_name']; ?>" id="product_name<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['product_name'];
										} ?>
									</td>
									<?php 
									if($_SESSION['IS_STOCK']==1){ // 1=means maintain stock
									?>
									<td style="text-align:center">
									 	<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:center" class="form-control" onblur="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','6')" value="<?php echo $rows['item_code']; ?>" id="product_code<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['item_code'];
										} ?>
									</td>
									<td style="text-align:center;font-weight:bold">
									<?php echo ($rows['stock_qty']<$_SESSION['SAFETY_STOCK'])? "<span style='color:red'>".$rows['stock_qty']."</sapn>" : $rows['stock_qty']; ?><p style="font-size:8px;color:blue"><?php echo $rows['uom']; ?></p>
									</td>
									<td style="text-align:right">
										<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:right;" class="form-control" onclick="clickToSelect('purchase_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','8')" value="<?php echo $rows['purchase_price']; ?>" id="purchase_price<?php echo $j; ?>"/>
										<?php }else{
										echo $rows['purchase_price']; 
										} ?>
									</td>
									<td style="text-align:right;font-weight:bold;">
									 	<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:right;<?php echo ($rows['avg_price']>=$rows['selling_price'])? 'color:red': ''; ?>" class="form-control" onclick="clickToSelect('selling_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','7')" value="<?php echo $rows['selling_price']; ?>" id="selling_price<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['selling_price'];
										} ?>
									</td>
									
									<?php } ?>
								</tr>
							<?php 
								}
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}else{
				$product=$conn->query("select * from product pp where pp.is_active=2 and pp.com_id=$com_id and pp.ptype=$item_type $con $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
							?>
								<tr>
									<td style="text-align:center">
										<?php 
										if($rows['stock_qty']>0){
											echo $j;
										}else{
											if($_SESSION['LOG_USER']=='admin'){
											?>
											<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
											<?php }else{
												echo $j;
											} 
										}
										?>
									</td>
									<td>
										<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" class="form-control" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','5');" value="<?php echo $rows['product_name']; ?>" id="product_name<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['product_name'];
										} ?>
									</td>
									<?php 
									if($_SESSION['IS_STOCK']==1){ // 1=means maintain stock
									?>
									<td style="text-align:center">
									 	<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:center" class="form-control" onblur="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','6')" value="<?php echo $rows['item_code']; ?>" id="product_code<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['item_code'];
										} ?>
									</td>
									<td style="text-align:center;font-weight:bold">
									<?php echo ($rows['stock_qty']<$_SESSION['SAFETY_STOCK'])? "<span style='color:red'>".$rows['stock_qty']."</sapn>" : $rows['stock_qty']; ?><p style="font-size:8px;color:blue"><?php echo $rows['uom']; ?></p>
									</td>
									<td style="text-align:right">
									<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:right;font-weight:bold;" class="form-control" onclick="clickToSelect('purchase_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','8')" value="<?php echo $rows['purchase_price']; ?>" id="selling_price<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['purchase_price'];
										} ?>
									</td>
									<td style="text-align:right;font-weight:bold;">
									 	<?php 
										if($_SESSION['LOG_USER']=='admin'){
										?>
										<input type="text" style="text-align:right;font-weight:bold;<?php echo ($rows['avg_price']>=$rows['selling_price'])? 'color:red': ''; ?>" class="form-control" onclick="clickToSelect('selling_price<?php echo $j; ?>')" onkeyup="setCusPrice('<?php echo $j; ?>','<?php echo $rows['id']; ?>','7')" value="<?php echo $rows['selling_price']; ?>" id="selling_price<?php echo $j; ?>"/>
										<?php }else{
											echo $rows['selling_price'];
										} ?>
									</td>
									
									<?php } ?>
								</tr>
							<?php 
								}
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}
			
		}else if($search_page_type==2){ //in stock area
			$tqty=0;$ttaka=0;
			$condition="";
			$sort=" order by ds.id desc limit 0,1000";
			if($search_sort_type=="asc" || $search_sort_type=="desc"){
				$sort=" order by ds.id $search_sort_type limit 0,1000";
			}else if($search_sort_type=="qty_asc" || $search_sort_type=="qty_desc"){
				$stype=explode("_",$search_sort_type);
				$search_sort_type=$stype[1];
				$sort=" order by cast(ds.item_qty as decimal(20,2)) $search_sort_type limit 0,1000";
			}
			@$date3=$_REQUEST['date3'];
			if($date3!=""){
				$condition=" and date(ds.insert_date)='$date3'";
			}
			if($search_item_name!=""){
				$product=$conn->query("select pp.id,
				pp.product_name item_name,
				pp.item_code,
				pp.uom item_unit,
				ds.dstid direct_salse_head_id,
				ds.item_id,
				ds.item_qty,
				ds.price,
				(select cus_mobile from direct_sale_head where id=ds.dstid) supplier_mobile,
				ds.insert_date
				from product pp,direct_sale ds where ds.item_id=pp.id and ds.in_out_status=1 and ds.com_id=$com_id and pp.is_active=2 and (pp.product_name like '%$search_item_name%' or pp.item_code like '%$search_item_name%') $condition $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
									$tqty+=$rows['item_qty'];
									$ttaka+=round(($rows['item_qty']*$rows['price']),2);
									$tprice_row=round(($rows['item_qty']*$rows['price']),2);
									
								$tprice_row=round(($rows['item_qty']*$rows['price']),2);
								$tbl_id=$rows['direct_salse_head_id']; // direct sales head tbl id 
								$item_qty=$rows['item_qty'];
								$item_id=$rows['item_id'];
							?>
								<tr>
									<td style="text-align:center">
										<?php 
										if($_SESSION['USER_TYPE']==2){
										?>
										<button onclick="delInStockItem('<?php echo $tbl_id; ?>','<?php echo $j; ?>','<?php echo $item_qty; ?>','<?php echo $tprice_row; ?>','<?php echo $item_id; ?>');" name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
										  <?php }else{
											echo $j;
										} ?>
									</td>
									<td>
										<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
									</td>
									<td style='text-align:center'><?php echo $rows['item_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
									<td style='text-align:right'><?php echo $rows['price']; ?></td>
									<td style='text-align:right'><?php echo round(($rows['item_qty']*$rows['price']),2); ?></td>
									<td style='text-align:center'><?php echo @$rows['supplier_mobile']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
								</tr>
							<?php 
								}
								?>
								<tr>
									<td colspan="2" style="text-align: right;font-weight: bold;">
										Total Qty: 
									</td>
									<td style="text-align: center;font-weight: bold;">
										<?php echo $tqty; ?>
									</td>
									<td style="text-align: right;font-weight: bold;">
										Total: 
									</td>
									<td style="text-align: right;font-weight: bold;">
										<?php echo $ttaka; ?>
									</td>
								</tr>
								<?php 
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}else{
				$product=$conn->query("select pp.id,pp.product_name item_name,pp.item_code,pp.uom item_unit,ds.item_qty,ds.price,(select cus_mobile from direct_sale_head where id=ds.dstid) supplier_mobile,ds.insert_date from product pp,direct_sale ds where ds.item_id=pp.id and ds.in_out_status=1 and ds.com_id=$com_id and pp.is_active=2 and (pp.product_name like '%$search_item_name%' or pp.item_code like '%$search_item_name%') $condition $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
									$tqty+=$rows['item_qty'];
									$ttaka+=round(($rows['item_qty']*$rows['price']),2);
							?>
								<tr>
									<td style="text-align:center">
									<?php 
										if($_SESSION['USER_TYPE']==2){
										?>
										<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>
										<?php }else{
											echo $j;
										} ?>
									</td>
									<td>
										<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
									</td>
									<td style='text-align:center'><?php echo $rows['item_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
									<td style='text-align:right'><?php echo $rows['price']; ?></td>
									<td style='text-align:right'><?php echo round(($rows['item_qty']*$rows['price']),2); ?></td>
									<td style='text-align:center'><?php echo @$rows['supplier_mobile']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
								</tr>
							<?php 
								}
								?>
								<tr>
									<td colspan="2" style="text-align: right;font-weight: bold;">
										Total Qty: 
									</td>
									<td style="text-align: center;font-weight: bold;">
										<?php echo $tqty; ?>
									</td>
									<td style="text-align: right;font-weight: bold;">
										Total: 
									</td>
									<td style="text-align: right;font-weight: bold;">
										<?php echo $ttaka; ?>
									</td>
								</tr>
								<?php 
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}
		}else if($search_page_type==3){ //in stock Adjustment area 
			$tqty=0;$ttaka=0;
			$condition="";
			$sort=" order by ds.id desc limit 0,100";
			if($search_sort_type=="asc" || $search_sort_type=="desc"){
				$sort=" order by ds.id $search_sort_type limit 0,100";
			}else if($search_sort_type=="qty_asc" || $search_sort_type=="qty_desc"){
				$stype=explode("_",$search_sort_type);
				$search_sort_type=$stype[1];
				$sort=" order by cast(ds.adjustment_qty as decimal(20,2)) $search_sort_type limit 0,100";
			}
			@$date3=$_REQUEST['date3'];
			if($date3!=""){
				$condition=" and date(ds.insert_date)='$date3'";
			}
			if($search_item_name!=""){
				
				$product=$conn->query("select pp.id,pp.product_name item_name,pp.item_code,pp.uom item_unit,ds.remarks,ds.adjustment_qty,ds.insert_date,(select user_name from user where id=ds.insert_by) adjust_by from product pp,stock_adjustment ds where ds.item_id=pp.id and ds.is_active=1 and pp.is_active=2 and (pp.product_name like '%$search_item_name%' or pp.item_code like '%$search_item_name%') $condition $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
							?>
							<tr>
								<td style='text-align:center'>
									<?php echo $j; ?><!--<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>--></td>
								<td>
									<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
								</td>
								<td style='text-align:center'><?php echo $rows['adjustment_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
								<td style='text-align:center'><?php echo $rows['remarks']; ?></td>
								<td style='text-align:center'><?php echo @$rows['adjust_by']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
							</tr>
							<?php 
								}
								
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}else{
				$product=$conn->query("select pp.id,pp.product_name item_name,pp.item_code,pp.uom item_unit,ds.remarks,ds.adjustment_qty,ds.insert_date,(select user_name from user where id=ds.insert_by) adjust_by from product pp,stock_adjustment ds where ds.item_id=pp.id and ds.is_active=1 and pp.is_active=2 and (pp.product_name like '%$search_item_name%' or pp.item_code like '%$search_item_name%') $condition $sort");
				
				if(mysqli_num_rows($product)>0){
							$i=1;
								while($rows=mysqli_fetch_array($product)){
									$j=$i++;
							?>
							<tr>
								<td style='text-align:center'>
									<?php echo $j; ?><!--<button onclick='delItem(<?php echo $rows['id']; ?>,<?php echo $j; ?>);' name='btn' id='delbtn<?php echo $j; ?>' class="btn btn-danger form-control"><?php echo $j; ?></button>--></td>
								<td>
									<?php echo $rows['item_name']; ?><p style='font-size:9px;color:blue'><?php echo @$rows['item_code']; ?></p>
								</td>
								<td style='text-align:center'><?php echo $rows['adjustment_qty']; ?> <p style='font-size:8px;color:blue'><?php echo @$rows['item_unit']; ?></p></td>
								<td style='text-align:center'><?php echo $rows['remarks']; ?></td>
								<td style='text-align:center'><?php echo @$rows['adjust_by']; ?> <p style='font-size:9px;color:green'><?php echo @$rows['insert_date']; ?></p></td>
							</tr>
							<?php 
								}
								
								echo "<input type='hidden' value='$j' id='ilast_id'/>";
				
				}else{
					echo "<input type='hidden' value='0' id='ilast_id'/>";
				}
			}
		}
		
	}
	
	if(isset($_REQUEST['autoCompleteMobile'])){
		$src_cus_mobile=$_REQUEST['mobile'];
		$com_id=($_SESSION['COM_ID']);
		$emp_info=$conn->query("SELECT c.id ids,c.cus_mobile,c.cus_address,c.cus_name,(select sum(point) from point_tbl where is_active=1 and cus_id=c.id) getpoint FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 and c.cus_mobile like '%$src_cus_mobile%' limit 0,12");
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['ids'];
					$sl=$i++;
					?>
					<a style="text-decoration:none" href="javascript:void(0)"><p onclick="setMobileNumber('<?php echo $rows['cus_mobile']; ?>','<?php echo $rows['cus_name']; ?>','<?php echo $tbl_id; ?>','<?php echo $rows['cus_address']; ?>');" style="    color: #347909fc;
    border: 1px solid #8e898942;
    background: white;
    padding-left: 10px;
    cursor: pointer;
    margin-bottom: 0px !important;
    font-style: italic;
    font-weight: bold;
    border-radius: 5px;
    padding: 5px 3px 6px 10px;
    line-height: 16px;"><?php echo $rows['cus_mobile']; ?><br/><?php echo $rows['cus_name']; ?></p></a>
					<?php 
				}
				
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['autoCompleteMobileSearchable'])){ // editable searching 
		$src_cus_mobile=$_REQUEST['mobile'];
		$com_id=($_SESSION['COM_ID']);
		if($_REQUEST['chk_searchable_number']==1){ // order number 
			$src_cus_mobile=strtoupper($src_cus_mobile);
			$emp_info=$conn->query("SELECT c.id,dss.phy_ord_num as cus_mobile,c.cus_name FROM `customer` c,dsms dss WHERE c.cus_mobile=dss.cus_mobile and c.com_id=$com_id and c.is_active=1 and dss.phy_ord_num like '%$src_cus_mobile%' limit 0,12");
		}
		if($_REQUEST['chk_searchable_number']==2){ // mobile number 
			$emp_info=$conn->query("SELECT distinct(c.cus_mobile) cus_mobile,c.id,c.cus_name FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 and c.cus_mobile like '%$src_cus_mobile%' limit 0,12");
		}
		
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					?>
					<a style="text-decoration:none" href="javascript:void(0)"><p onclick="srchByMobileNum('<?php echo $rows['cus_mobile']; ?>');" style="color: #347909fc;
						border: 1px solid #8e898942;
						background: white;
						padding-left: 10px;
						cursor: pointer;
						margin-bottom: 0px !important;
						font-style: italic;
						font-weight: bold;
						border-radius: 5px;
						padding: 5px 3px 6px 10px;
						line-height: 16px;"><?php echo $rows['cus_mobile']; ?><br/><?php echo $rows['cus_name']; ?></p></a>
					<?php 
				}
				
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['autoCompleteMobileSearchableForJob'])){ // editable searching 
		$src_cus_mobile=$_REQUEST['mobile'];
		$com_id=($_SESSION['COM_ID']);
		if($_REQUEST['chk_searchable_number']==1){ // order number 
			$src_cus_mobile=strtoupper($src_cus_mobile);
			$emp_info=$conn->query("SELECT c.id,dss.phy_ord_num as cus_mobile,c.cus_name FROM `customer` c,dsms dss WHERE c.cus_mobile=dss.cus_mobile and c.com_id=$com_id and c.is_active=1 and dss.phy_ord_num like '%$src_cus_mobile%' limit 0,12");
		}
		if($_REQUEST['chk_searchable_number']==2){ // mobile number 
			$emp_info=$conn->query("SELECT distinct(c.cus_mobile) cus_mobile,c.id,c.cus_name FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 and c.cus_mobile like '%$src_cus_mobile%' limit 0,12");
		}
		
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					?>
					<a style="text-decoration:none" href="javascript:void(0)"><p onclick="srchForOrdDetails('<?php echo $rows['cus_mobile']; ?>');" style="color: #347909fc;
						border: 1px solid #8e898942;
						background: white;
						padding-left: 10px;
						cursor: pointer;
						margin-bottom: 0px !important;
						font-style: italic;
						font-weight: bold;
						border-radius: 5px;
						padding: 5px 3px 6px 10px;
						line-height: 16px;"><?php echo $rows['cus_mobile']; ?><br/><?php echo $rows['cus_name']; ?></p></a>
					<?php 
				}
				
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['seaMoreCustomer'])){
		$last_id=trim($_REQUEST['last_id']);
		$com_id=$_SESSION['COM_ID'];
		$i=$last_id+1;
		$emp_info=$conn->query("SELECT c.id,c.cus_name,c.cus_mobile,c.cus_address,(select last_due from update_due where cus_id=c.id and is_active=1 order by id desc limit 0,1) due_amount FROM `customer` c WHERE c.com_id=$com_id and c.is_active=1 limit  $last_id,100");
			mysqli_close($conn);
			$tot_emp=mysqli_num_rows($emp_info);
			
			$total_tk=0;
			if($tot_emp>0){
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					$total_tk+=$rows['due_amount'];
					?>
					<tr>
						<td>
						<?php 
						if(@$rows['due_amount']=="" || $rows['due_amount']==0){
						?>
						<button onclick="delCustomer('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delbtn<?php echo $sl; ?>"><?php echo $sl; ?></button>
						<?php }else{
							echo $sl;
						} ?>
						</td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_name<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','1');" value="<?php echo @$rows['cus_name']; ?>" /></td>
						<td><?php echo $rows['cus_mobile']; ?></td>
						<td><input type="text" class="form-control" autocomplete="off" id="cus_address<?php echo $tbl_id; ?>" onkeyup="setAddress('<?php echo $tbl_id; ?>','2');" value="<?php echo @$rows['cus_address']; ?>" /></td>
						<td style="text-align: right;font-weight:bold"><?php echo englishToBangla($rows['due_amount'])."/="; ?></td>
					</tr>
					
					<?php 
				}
			}else{
				echo 2;
			}
					
	}
	
	if(isset($_REQUEST['onlyBoxUpdateBtn'])){
		$box_number=trim($_REQUEST['box_number']);
		$order_number=trim($_REQUEST['order_number']);
		$com_id=($_SESSION['COM_ID']);
		$update_box_num=$conn->query("update dsms set box_number='$box_number' WHERE phy_ord_num='$order_number'");
			mysqli_close($conn);
			$i=1;
			if($update_box_num){
				echo 2;
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['autoCompleteMobile2'])){
		$src_cus_mobile=$_REQUEST['mobile'];
		$com_id=($_SESSION['COM_ID']);
		$emp_info=$conn->query("SELECT * FROM `customer` WHERE com_id=$com_id and is_active=1 and (cus_mobile like '%$src_cus_mobile%' or cus_name like '%$src_cus_mobile%') limit 0,12");
			mysqli_close($conn);
			$i=1;
			if(mysqli_num_rows($emp_info)>0){
				
				while($rows=mysqli_fetch_array($emp_info)){
					$tbl_id=$rows['id'];
					$sl=$i++;
					?>
					<a style="text-decoration:none" href="javascript:void(0)"><p onclick="setMobileNumber('<?php echo $rows['cus_mobile']; ?>','<?php echo $rows['cus_name']; ?>','<?php echo $tbl_id; ?>');" style="    color: #347909fc;
    border: 1px solid #8e898942;
    background: white;
    padding-left: 10px;
    cursor: pointer;
    margin-bottom: 0px !important;
    font-style: italic;
    font-weight: bold;
    border-radius: 5px;
    padding: 5px 3px 6px 10px;
    line-height: 16px;"><?php echo $rows['cus_mobile']; ?><br/><?php echo $rows['cus_name']; ?></p></a>
					<?php 
				}
				
			}else{
				echo "";
			}
	}
	
	if(isset($_REQUEST['previousDuePayable'])){
		$remarks="পূর্বের বাকি পরিশোধ";
		echo dueTblUpdate(getCustomerId($_REQUEST['mobile']),$_REQUEST['previous_due_payable'],1,$remarks,'3'); // 3= from order form due receive 
	}
	
	if(isset($_REQUEST['searchYearlyOrder'])){
		$com_id=($_SESSION['COM_ID']);
		$year=$_REQUEST['year'];
		$order_details=$conn->query("SELECT * FROM `feg_order` WHERE com_id=$com_id and year='$year' order by id desc limit 0,1");
		$rows=mysqli_fetch_array($order_details);
		echo $rows['order_qty'];
	}
	
	if(isset($_REQUEST['showDetailYearlyOrder'])){
		
		$com_id=($_SESSION['COM_ID']);
		$horder=$_REQUEST['horder'];
		$year=$_REQUEST['year'];
		$order_details=$conn->query("SELECT * FROM `dsms` WHERE is_active=1 and com_id=$com_id and year(insert_date)='$year' order by id desc limit 0,$horder");
		?>
		<p>Order Details</p>
		<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>SL</th>
						<th>Order Number</th>
					</tr>
				</thead>
		<tbody id="">
		<?php 
			$i=0;
			while($row=mysqli_fetch_array($order_details)){
				?>
					<tr>
						<td>
							<?php echo ++$i; ?>
						</td>
						<th><?php echo $row['phy_ord_num']; ?></th>
					</tr>
				<?php 
			}
		
		?>
					
		</tbody>
		</table>
		<?php 
	}
	
	
	if(isset($_REQUEST['getSelectHead'])){
		$com_id=($_SESSION['COM_ID']);
		$item_type=$_REQUEST['item_type'];
		$ex=explode("#sep#",$_REQUEST['item_id']);
		$group_id=$ex[1];
		$order_details=$conn->query("SELECT * FROM `measurement_head` WHERE group_id=$group_id and ptype=$item_type and mtype=2 and is_active=1");
		if(mysqli_num_rows($order_details)>0){
			echo '<option value="">Select One</option>';
			while($rows=mysqli_fetch_array($order_details)){
				?>
				<option value='<?php echo $rows['title']; ?>'><?php echo $rows['title']; ?></option>
				<?php 
			}
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['setEmployee'])){
		$com_id=($_SESSION['COM_ID']);
		$userid=$_REQUEST['userid'];
		$user_type=$_REQUEST['user_type'];
		$sl=$_REQUEST['sl'];
		$order_num_id=$_REQUEST['order_num_id'];
		$order_details=$conn->query("SELECT * FROM `user` WHERE com_id=$com_id and emp_type=$user_type and is_active=1");
		if(mysqli_num_rows($order_details)>0){
			if($user_type==2){ //for karigor
			?>
			<select id="get_select_karigor<?php echo $sl; ?>" onchange="changeUser(<?php echo $sl; ?>,'<?php echo $order_num_id; ?>',<?php echo $userid; ?>);" style="" class="form-control">
			<option value="">Select One</option>
			<?php 
			while($rows=mysqli_fetch_array($order_details)){
				if($rows['id']==$userid){
					$slect="selected";
				}else{
					$slect="";
				}
				?>
				<option <?php echo $slect; ?> value='<?php echo $rows['id']."#sep#".$rows['user_name']; ?>'><?php echo $rows['user_name']; ?></option>
				<?php 
			}
			?>
			</select>
			<?php 
			}
		
		
		if($user_type==1){ //for master
			?>
			<select id="get_select_master<?php echo $sl; ?>" onchange="changeUser2(<?php echo $sl; ?>,'<?php echo $order_num_id; ?>',<?php echo $userid; ?>);" style="" class="form-control">
			<option value="">Select One</option>
			<?php 
			while($rows=mysqli_fetch_array($order_details)){
				if($rows['id']==$userid){
					$slect="selected";
				}else{
					$slect="";
				}
				?>
				<option <?php echo $slect; ?> value='<?php echo $rows['id']."#sep#".$rows['user_name']; ?>'><?php echo $rows['user_name']; ?></option>
				<?php 
			}
			?>
			</select>
			<?php 
			}
		
		}
	}
	
	if(isset($_REQUEST['searchExpense'])){
		date_default_timezone_set("Asia/Dhaka");
		@$srcdate=$_REQUEST['srcdate'];
		$com_id=($_SESSION['COM_ID']);
		$date=date("Y-m-d");
		if($srcdate!=""){
			$ex=explode("/",$srcdate);
			if(count($ex)==3){
			$srcdate=$ex[2]."-".$ex[1]."-".$ex[0];
			}else{
				$srcdate="";
			}
			$expense_detail=$conn->query("SELECT  ex.id,ex.expense_type,date(ex.insert_date) indate,ex.expense,ex.remarks,(select expense from expense_type where id=ex.expense_type) ex_title  FROM `expenses` ex WHERE ex.com_id=$com_id and date(ex.insert_date)='$srcdate' and ex.is_active=1 order by ex.id desc");
		}else{
			$expense_detail=$conn->query("SELECT  ex.id,ex.expense_type,ex.expense,ex.remarks,(select expense from expense_type where id=ex.expense_type) ex_title  from expenses ex where ex.com_id=$com_id and date(ex.insert_date)='$date' and ex.is_active=1 order by ex.id desc");
		}
		if(mysqli_num_rows($expense_detail)>0){
		?>
		<?php 
			$sl=0;$i=1;
			if(mysqli_num_rows($expense_detail)>0){
				while($row=mysqli_fetch_array($expense_detail)){
					$sl=$i++;
					$tbl_id=$row['id'];
					?>
					<tr id="delrow<?php echo $tbl_id; ?>">
					<td style="text-align:center">
					<?php 
						if($date==$row['indate']){
					?>
					<button onclick="delExpense('<?php echo $tbl_id; ?>','<?php echo $sl; ?>')" class="btn btn-danger form-control" id="delExbtn<?php echo $sl; ?>"><?php echo $sl; ?></button>
					<?php }else{
						echo $sl;
					} ?>
					</td>
					<td><?php echo $row['ex_title']; ?></td>
					<td><?php echo $row['remarks']; ?></td>
					<td style="text-align:right"><?php echo $row['expense'] ?></td>
					</tr>
					<?php 
				}
			}
		?>
					
		<?php 
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['salesReturnOption'])){
		date_default_timezone_set("Asia/Dhaka");
		@$srcdate=$_REQUEST['srcdate'];
		$com_id=($_SESSION['COM_ID']);
		$date=date("Y-m-d");
		if($srcdate!=""){
			$ex=explode("/",$srcdate);
			if(count($ex)==3){
			$srcdate=$ex[2]."-".$ex[1]."-".$ex[0];
			}else{
				$srcdate="";
			}
			$sales_details=$conn->query("SELECT id,cus_mobile,insert_date,f_total,others_tk,discount_tk,(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)='$srcdate' and is_active!=0 and in_out_status=0 order by id desc");
		}else{
			$sales_details=$conn->query("SELECT id,cus_mobile,insert_date,f_total,others_tk,discount_tk,(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 order by id desc");
		}
		if(mysqli_num_rows($sales_details)>0){
		?>
			<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th>SL</th>
						<th>Order No</th>
						<th>Mobile</th>
						<th>Sales Date</th>
						<th style="text-align:right">Net Total</th>
						<th style="text-align:right">Others(Tk)</th>
						<th style="text-align:right">discount(Tk)</th>
						<th style="text-align:right">Total(Tk)</th>
						<th style="text-align:center">Print</th>
					</tr>
				</thead>
				<tbody id="tbl_two2">
					<?php 
						$i=1;$ttk=0;$others=0;$total=0;$gtotal=0;
						while($row=mysqli_fetch_array($sales_details)){
							$ttk=$row['f_total'];
							$others=$row['others_tk'];
							$discount=$row['discount_tk'];
							$total=($ttk+$others)-$discount;
							$gtotal+=$total;
							?>
								<tr>
									<td>
										<button onclick="showDetailSales('<?php echo $row['id']; ?>');" name="btn" value="sub" class="btn btn-success form-control"><?php echo $row['id'];//$i++; ?></button>
									</td>
									<th><?php echo $row['ord_num']; ?></th>
									<th><?php echo $row['cus_mobile']; ?></th>
									<th><?php echo $row['insert_date']; ?></th>
									<th style="text-align:right"><?php echo $ttk; ?></th>
									<th style="text-align:right"><?php echo $others; ?></th>
									<th style="text-align:right"><?php echo $discount; ?></th>
									<th style="text-align:right"><?php echo $total; ?></th>
									<th style="text-align:center;color:blue;"><?php 
										if($row['ord_num']==""){
											?>
											<span style="cursor: pointer;" onclick="dateWisePrint('<?php echo $row['id']; ?>','10');"><i>Print</i></span>
											<?php 
										}
										?>
									</th>
								</tr>
							<?php 
						}
					
					?>
					<tr>
						<th colspan="7" style="text-align:right">Total: </th>
						<th style="text-align:right"><?php echo $gtotal; ?></th>
					</tr>
					
				</tbody>
			</table>
		<?php 
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['showDetailSales'])){
		@$dstblid=$_REQUEST['dstblid'];
		$com_id=($_SESSION['COM_ID']);
		$sales_details=$conn->query("SELECT ds.id,ds.dstid,(select id from customer where cus_mobile=(select direct_sale_head.cus_mobile from direct_sale_head where direct_sale_head.id=ds.dstid) limit 0,1) customer_id,(select cus_mobile from direct_sale_head where direct_sale_head.id=ds.dstid) cus_mobile,(select uom from product where id=ds.item_id) item_unit,(select product_name from product where id=ds.item_id) item_name,ds.item_qty,ds.price,ds.order_number,ds.item_id FROM `direct_sale` ds WHERE ds.com_id=$com_id and ds.is_active!=0 and ds.dstid=$dstblid order by ds.id asc");
		if(mysqli_num_rows($sales_details)>0){
		?>
			<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th style="text-align:center;width: 13%;">SL</th>
						<th>Item</th>
						<th style="text-align:center;width:15%">Qty</th>
						<th style="text-align:right">Price</th>
					</tr>
				</thead>
				<tbody id="tbl_two2">
					<?php 
						$i=1;$ttk=0;
						while($row=mysqli_fetch_array($sales_details)){
							?>
								<tr>
									<td style="text-align:center">
										<button onclick="delDetailSales('<?php echo $row['id']; ?>','<?php echo ($row['price']*$row['item_qty']); ?>','<?php echo $dstblid; ?>','<?php echo $row['order_number']; ?>','<?php echo $row['item_id']; ?>','<?php echo $row['item_qty']; ?>','<?php echo $row['cus_mobile']; ?>');" id="delid<?php echo $row['id']; ?>" name="btn" value="sub" class="btn btn-danger form-control"><?php echo $i++; ?></button>
									</td>
									<th><?php echo $row['item_name']; ?></th>
									<th style="text-align:center"><button style="width: 22%;" id="update_btn<?php echo $row['id']; ?>" onclick="updateFabQty('<?php echo $row['item_id']; ?>','<?php echo $row['item_qty']; ?>','<?php echo $row['price']; ?>','<?php echo $row['id']; ?>','<?php echo $row['dstid']; ?>','<?php echo $row['customer_id']; ?>','<?php echo $row['order_number']; ?>')">ok</button><input type="text" style="text-align: center;width: 40%;" id="edit_fab_qty<?php echo $row['id']; ?>" onkeyup="liveCheckStockQty('<?php echo $row['id']; ?>','<?php echo $row['item_id']; ?>','<?php echo $row['item_qty']; ?>');" value="<?php echo $row['item_qty']; ?>"/> <?php echo $row['item_unit']; ?></th>
									<th style="text-align:right"><?php echo ($row['price']*$row['item_qty']); ?></th>
								</tr>
							<?php 
						}
					
					?>
					
				</tbody>
			</table>
		<?php 
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['payTk'])){
		$com_id=($_SESSION['COM_ID']);
		$user_id=$_SESSION['USER_ID'];
		@$fab_head_tbl_id=$_REQUEST['fab_head_tbl_id'];
		@$hide_due=$_REQUEST['hide_due'];
		@$exdiscount=trim($_REQUEST['exdiscount']);
		@$paytxt=trim($_REQUEST['paytxt']);
		@$payment_type=$_REQUEST['payment_type'];
		$com_id=($_SESSION['COM_ID']);
		if($exdiscount!=""){
			$conn->query("update `direct_sale_head` set discount_tk=(discount_tk+$exdiscount) WHERE id='$fab_head_tbl_id'");
		}
		$sales_head=$conn->query("insert into accounting_fabrics(dsms_id,com_id,amount,insert_by,pay_status,payment_type) values('$fab_head_tbl_id','$com_id','$paytxt','$user_id','0','$payment_type')");
				
		if($sales_head){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['delPay'])){
		@$accounting_tbl_id=$_REQUEST['accounting_tbl_id'];
		$com_id=($_SESSION['COM_ID']);
		$sales_head=$conn->query("update `accounting_fabrics` set is_active=0 WHERE id='$accounting_tbl_id'");
		if($sales_head){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['payDetailSales'])){
		@$dstblid=$_REQUEST['dstblid'];
		@$param=$_REQUEST['param'];
		$com_id=($_SESSION['COM_ID']);
		$sales_head=$conn->query("SELECT direct_sale_head.*,(select id from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_id,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_name  FROM `direct_sale_head` WHERE id='$dstblid'");
	
	$t_row=mysqli_fetch_array($sales_head);
	$total_tk=$t_row['f_total'];
	$discount=$t_row['discount_tk'];
	$shipping_tk=$t_row['shipping_tk'];
	$due=$t_row['f_total']-$t_row['discount_tk']-$t_row['total_receive']+$shipping_tk;
	$payment_detail=$conn->query("SELECT accounting_fabrics.*,date(accounting_fabrics.insert_date) indate FROM `accounting_fabrics` WHERE `com_id`=$com_id and is_active=1 and `dsms_id`=$dstblid");
		
	?>
	<div class="panel-body">
		<div id="show_btn"></div>
		<div class="row" id="calculator" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-left: 0px;margin-right: 0px;">
			<div class="col-xs-12 col-sm-4" style="float: right;margin-right: 35px;">
				<span style="font-size: 16px;font-weight: bold;color: blue;">Order: <?php echo $dstblid; ?></span>
				<table id="example" class="table table-striped table-bordered">
				<thead>
					<tr>
						<th style="width: 68%;">Description</th>
						<th style="text-align:right;width: 32%;">Taka</th>
					</tr>
				</thead>
				<tbody id="payable">
					<tr>
						<td>
							<b>Total</b>
						</td>
						<td style='text-align:right;'><b>
							<input style='text-align:right;border: 1px solid #F9F9F9;background: #F9F9F9;' type='text' readonly value='<?php echo $total_tk; ?>'/>
						</b>
						</td>
						</tr><tr><td>
							<b>Discount</b>
						</td><td style='text-align:right'><?php echo $discount; ?></td></tr>
						<tr><td>
							<b>Shipping</b>
						</td><td style='text-align:right'><?php echo $shipping_tk; ?></td></tr>
						<?php 
				$paytbl2="";	
				$i=1;$sum=0;
				date_default_timezone_set("Asia/Dhaka");
				$date=date("Y-m-d");$del_info="";
				while($payrows=mysqli_fetch_array($payment_detail)){
					$due_tk=$payrows['amount'];
					$accounting_tbl_id=$payrows['id'];
					$payment_type=$payrows['payment_type'];
					$sum+=intval($due_tk);
					$del_info=($date==$payrows['indate'])? "(<a href='javascript:void(0)' onclick='delPay($accounting_tbl_id,$dstblid,$param);'>Del</a>)" : '';
					if($payrows['pay_status']==1){
						$paytbl2.="<tr>
						<td>
							Advance($payment_type) $del_info
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
					}else{
						$paytbl2.="<tr>
						<td>
							Pay($payment_type) $del_info
						</td>
						<td style='text-align:right'>
							$due_tk
						</td>
						</tr>";
						$due-=$due_tk;
					}
				
				}
				$due_div="<tr>
						<td>
							<b>Due</b>
						</td>
						<td style='text-align:right'><b>
							$due
						</b>
						</td>
						</tr>";
				
				if($due!=0){
				@$paytblpay.="<tr>
						<td style='color:red'>
							Discount <span style='color:black;cursor:pointer' onclick='setDiscountTk($dstblid)' id='discount_tks$dstblid'></span>
						</td>
						<td>
						<input style='text-align: right;width: 100%;background: #61c5cf87;' type='text' id='exdiscount$dstblid'/>
						</td>
						</tr>
						<tr>
						<td>
							<button onclick='payTk($dstblid,$param);' name='btn' id='paybtns$dstblid' value='sub' class='btn btn-success'>Pay</button>
							<select style='height: 30px;' id='payment_type$dstblid'>
								<option value='Cash'>Cash</option>
								<option value='বেলাল ভাই'>বেলাল ভাই</option>
							</select>
						</td>
						<td>
						<input style='text-align:right;width:100%' onkeyup='showLiveDiscount($dstblid)' onclick='clickToSelect(paytxt$dstblid,$param)' type='text' id='paytxt$dstblid'/>
						
						<span id='stksms$dstblid'></span>
						</td>
						</tr>";
				}else{
					$paytblpay="";
				}
				
				echo $paytbl2.$due_div.$paytblpay;
				?>
				
				<input type='hidden' id='fpay_total_tue_tk' value='<?php echo @$due; ?>' />
				<input type='hidden' id='discount_tot' value='0'/></tbody>
				<input type='hidden' id='fab_head_tbl_id' value='<?php echo $dstblid; ?>'/></tbody>
				</table>
				<span style="color: blue;font-size: 16px;" id="pay_sms"></span>
			</div>
		</div>
	</div>
	<?php 
	}
	
		if(isset($_REQUEST['only_fab_edit_area'])){
		@$dstblid=$_REQUEST['dstblid'];
		@$param=$_REQUEST['param'];
		$com_id=($_SESSION['COM_ID']);
		$sales_head=$conn->query("SELECT direct_sale_head.*,(select id from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_id,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_name,(select cus_address from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_address  FROM `direct_sale_head` WHERE id='$dstblid'");
		$direct_sale=$conn->query("SELECT direct_sale.*,(select product_name from product where id=direct_sale.item_id) item_name  FROM `direct_sale` WHERE is_active=1 and dstid='$dstblid'");
		$product_fabrics=$conn->query("select * from product where is_active=2 order by id asc");
		if(mysqli_num_rows($sales_head)>0){
			$sales_head_row=mysqli_fetch_array($sales_head);
			$cus_mobile=$sales_head_row['cus_mobile'];
			$cus_name=$sales_head_row['cus_name'];
			$cus_id=$sales_head_row['cus_id'];
			$cus_address=$sales_head_row['cus_address'];
			$shipping_tk=$sales_head_row['shipping_tk'];
			$courier=$sales_head_row['courier'];
			
		?>
<div class="panel-group">
   <div class="panel panel-info">
      <div class="panel-heading" style="overflow:hidden;">
	  <span style="float: left;width: 200px;font-weight: bold;font-size: 16px;">Item Order No.- <?php echo $dstblid; ?></span><b><span id="head_ord_num">
		<input type="hidden" value="<?php echo $dstblid; ?>" id="fab_sl_no"/>
	  </span>
	  </b>
	  <?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><span style="margin-left: 175px;">Total Point <b><span style="color:#e842d4;" id="tot_remaining_point"></span></b></span><?php }else{ echo "<input type='hidden' id='tot_remaining_point'/>"; } ?>
	   </div>
      <div class="panel-body">
		<div id="show_btn"></div>
		<div class="row" id="calculator" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-left: 0px;margin-right: 0px;">
		
		<div class="col-xs-12 col-sm-3">
			
		<label for="comment" class="txt_color">Customer Mobile Number<sup style="color:red">*</sup>:<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><input style="margin-left: 15px;" type="checkbox" class="chkbox" name="normal" id="ref_chk" value="0"/><?php }else{ echo "<span id='ref_chk'></span>"; } ?></label>
				<input type="text" onkeyup="editCustomerInformation('<?php echo $dstblid; ?>','<?php echo $sales_head_row['cus_id']; ?>','mobile','direct_sale_head','customer');" value="<?php echo $sales_head_row['cus_mobile']; ?>" onkeydown="enterEventSelection('mobile','cus_name')" class="form-control" maxlength="11" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="mobile" id="mobile" />
				<span id="auto_mobile" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 240px;"></span>
				<input type="hidden" id="chkAuthUser" value="<?php echo $sales_head_row['cus_id']; ?>" />
				<input type="hidden" id="ref_user_id"/>
				<input type="hidden" id="backup_advance"/>
				<input type="hidden" value="0" id="ref_point_check"/>
				<input type="hidden" id="hidden_item_qty"/>
				<input type="hidden" id="hidden_item_name" />
				<input type="hidden" id="hidden_group_name" />
				<input type="hidden" id="increment_number" value="0"/>
				<input type="hidden" id="previous_delivery_date" value="<?php //echo $dday; ?>"/>
				<input type="hidden" id="tblid" value="0"/>
				<input type="hidden" id="max_item_hidden" value="20"/>
				<input type="hidden" id="max_fabrics_hidden" value="20"/>
				<input type="hidden" id="apply_selling_price" value="<?php echo $_SESSION['APPLY_SELLING_PRICE']; ?>"/>
				<input type="hidden" id="is_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				<input type="hidden" id="merge_order_chk" value=""/>
				<input type="hidden" id="hidden_ord_number" value=""/>
				<input type="hidden" id="hidden_selected_item" value=""/>
				
				<label for="comment" class="txt_color">Customer Name:</label>
				<input type="text" class="form-control" onkeyup="editCustomerInformation('<?php echo $dstblid; ?>','<?php echo $sales_head_row['cus_id']; ?>','cus_name','direct_sale_head','customer');" value="<?php echo @$cus_name; ?>" onkeydown="enterEventSelection('cus_name','cus_address')" autocomplete="off" maxlength="30" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_name" id="cus_name" />
				<input type="hidden" name="hidden_cus_name" id="hidden_cus_name" />
				<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?>
				<label for="comment" class="txt_color">Reference Mobile No.<sup style="color:red"></sup>:<span style="cursor: pointer;color: blue;font-size: 11px;margin-left: 10px;" onclick="copyReferenceNumber();">Copy</span> | <span style="cursor: pointer;color: red;font-size: 11px;" onclick="clearReferenceNumber();">Clear</span></label>
				<input readonly type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" maxlength="11" autocomplete="off" name="total_tk" id="ref_mobile_number"/>
				<?php } ?>
				<label for="comment" class="txt_color">Address:</label>
				<textarea rows="5" onkeydown="enterEventSelection('cus_address','date1')" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_name" id="cus_address"><?php echo $cus_address; ?></textarea>
				
				<input type="hidden" style="background: #8bc34a;font-weight:bold" onkeyup="return setDeliveryDate();" autocomplete="off" name="delivery_day" id="delivery_day" value="<?php //echo $delivery_day; ?>" class="form-control">
				<input type="hidden" autocomplete="off" name="date1" onkeydown="enterEventSelection('date1','ds_item_id')" id="date1" value="<?php //echo $dday; ?>" class="form-control">
				
				
			<div class="row">
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="design_charge" id="design_charge" required/>
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_item_qty" id="total_item_qty" required/>
				</div>	
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_tk" id="total_tk" required/>
				</div>
			</div>
			
				<input type="hidden" onkeyup="getAdvance();" maxlength="3" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="discount" id="discount" value="0" required/>
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="tdue" id="tdue" value="0" required/>
				<div style="margin: 10px;display:none">
					<input type="hidden" class="form-control" name="txt_sms" id="txt_sms" />
					<input type="checkbox" class="chkbox" checked name="normal" id="normal" value="0"/> <span class="checkboxtext" id="nor">Normal</span>
					<input type="checkbox" class="chkbox" name="emergency" id="emergency" value="1"/> <span class="checkboxtext" id="emg">Urgent</span>
				</div>
			<div class="" id="urdate_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" placeholder="Factory Delivery" name="date1" value="" id="urdate" class="form-control" data-select="date">
			</div>
			<div class="" id="urtime_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" name="date1" value="<?php //echo $cdate; ?>" id="urtime" class="form-control">
			</div>
			<div class="row">
				<input type="hidden" value="" id="master_id"/>
				<input type="hidden" value="" id="karigor_id"/>
			
			</div>
		</div>	
		
		<div class="col-xs-12 col-sm-6">
			<label for="comment" class="txt_color">Item Name<span> (Maximum <b><span style="color:red" id="max_fabrics">20</span></b> Fabrics)</span></label>
			<div style="margin-bottom: 5px;" id="reload_item_list">
				<select class="form-control select2" onchange="getNewItem('<?php echo $dstblid; ?>','<?php echo $cus_id; ?>');" style="font-weight: bold;font-size:18px;font-style: italic;background:#f9d9a8" id="ds_item_id">
					<option value="">Select One</option>
					<?php 
					while($rows=mysqli_fetch_array($product_fabrics)){
						@$item_code=($rows['item_code']=="")? '' : ' ['.$rows['item_code'].']';
						@$unit=($rows['uom']=="")? '' : '-('.$rows['uom'].')';
						@$avg_price="";//($rows['avg_price']=="")? '0' : '-'.$rows['avg_price'].'/=';
						@$selling_price=($rows['selling_price']=="")? '0' : '-Rate: '.$rows['selling_price'].'/=';
						@$stock_qty=($rows['stock_qty']=="")? '0' : ' Stock: '.$rows['stock_qty'];
						if($_SESSION['IS_STOCK']==0){
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name']; ?></option>
						<?php
						}
						if($_SESSION['IS_STOCK']==1){ // maintain stock
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name'].$item_code.$unit; ?></option>
						<?php
						}
					} 
					?>
					
				</select>
			</div>
			<div style="">
				<table id="dynamic-table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr style="background:#D3DCE3;">
							<th>Sl</th>
							<th style="width: 58%;">Item</th>
							<th style="width:10%;text-align:right">Qty(Pic)</th>
							<th style="width: 15%;text-align:right">Price</th>
							<th style="width: 20%;text-align:right">Sub Total</th>
						</tr>
					</thead>
					<tbody id="item_details">
					<?php 
					$tot=0;$sl=0;
					$discount=$sales_head_row['discount'];
					$discount_tk=$sales_head_row['discount_tk'];
					$fab_total=$sales_head_row['f_total'];
					$total_receive=$sales_head_row['total_receive'];
					if($discount>0){
						$remaining=($fab_total-$discount_tk-$total_receive+$shipping_tk);
					}else{
						$remaining=($fab_total-$total_receive+$shipping_tk);
					}
					
					if(mysqli_num_rows($direct_sale)>0){
						$sl=0;$c=0;
						while($direct_sale_row=mysqli_fetch_array($direct_sale)){
							$item_price=$direct_sale_row['price'];
							$item_unit=$direct_sale_row['item_unit'];
							if($discount_tk>0){
								$item_price=(($item_price*100)/(100-$discount));
							}
							$tot+=round(($direct_sale_row['item_qty']*$item_price),2);
							$sl=++$c;
						?>
							<tr id="fab_edit_row<?php echo $sl; ?>">
								<td id='thd'>
									<span>
										<a href='javascript:void(0)' style="color:red" onclick="delDetailSales('<?php echo $direct_sale_row['id']; ?>','<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['order_number']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $cus_mobile; ?>','<?php echo $param; ?>');" id="delid<?php echo $direct_sale_row['id']; ?>">del</a>
									</span>
								</td>
								<td>
									<input type='hidden' id='hidden_item_id<?php echo $direct_sale_row['id']; ?>' value='<?php echo $direct_sale_row['item_id']; ?>'/>
									<?php echo $direct_sale_row['item_name']; ?>
									<br/>
									<select onchange="changeItemUnit(<?php echo $direct_sale_row['id']; ?>)" id='item_sizec<?php echo $direct_sale_row['id']; ?>' style='background: yellow;'>
									<option value=''>Size</option>
									<option <?php echo ($item_unit=='M')? 'selected' : ''; ?> value='M'>M</option>
									<option <?php echo ($item_unit=='L')? 'selected' : ''; ?> value='L'>L</option>
									</select>
								</td>
								<td style='width: 10%;' class='text-align-right'>
									<input type='hidden' value='<?php echo $direct_sale_row['id']; ?>' id="hidden_fs_tbl_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_qty']; ?>' id="hidden_edit_fab_qty<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_id']; ?>' id="hidden_edit_item_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['purchase_price']; ?>' id="hidden_purchase_price<?php echo $sl; ?>"/>
									<input type='text' maxlength='7' style='text-align:right;color:black;font-size:18px;font-style: italic;font-weight: bold;width: 100%;' autocomplete='off' class='qtycls qtywidth' value='<?php echo $direct_sale_row['item_qty']; ?>' placeholder='1' id="edit_fab_qty<?php echo $sl; ?>" onclick="clickToSelect('edit_fab_qty<?php echo $sl; ?>')" onkeyup="liveCheckStockQty('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['purchase_price']; ?>','<?php echo $cus_id; ?>'); "/>
								</td>
								<td style='width: 10%;' id='thd'>
									<input type='text' style='text-align:right;font-size:18px;font-style: italic;color:black;font-weight: bold;width: 100%;' maxlength='7' autocomplete='off' placeholder='0' value='<?php echo $item_price; ?>' class='price text-align-right' id='live_item_pricec<?php echo $sl; ?>' onclick="clickToSelect('live_item_pricec<?php echo $sl; ?>')" onkeyup="pricef('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>');"/>
								</td>
								<td id='thd' class='text-align-right'>
									<span class='totalcls' style='float:right;color:black;font-weight: bold;font-size:18px;font-style: italic;' disabled='disabled' id="sub_total<?php echo $sl; ?>">
									<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?></span>
								</td>
							</tr>
						<?php
						}
					} 
					?>
					
					</tbody>
					<input type="hidden" value="<?php echo @$sl; ?>" id="fab_hidden_id"/>
				</table>
				<span style="color: blue;font-size: 26px;" id="usuccess"></span>
				
				
				<!--<label for="comment" class="txt_color">Discount(%) </label>-->
				<input type="hidden" onkeyup="febDiscount();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="febdis" id="febdis" value="0" required/>
				
				
				<input type="hidden" value="0" id="sub_tot_f_val"/>
				<input type="hidden" value="0" id="fab_total"/>
				<span id="item_detail_copy">
				</span>
				<!--<input type="hidden" id="total_h"/>-->
			</div>
			
		</div>
		<div class="col-xs-12 col-sm-3">
			<div class="row">
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: red;text-align: right;" autocomplete="off" value="0.0" name="previous_due" id="previous_due" required/>
					
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Sub Total(Tk)<sup style="color:red">*</sup>:</label>
					<input type="text" readonly value="<?php echo @$tot; ?>" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: #a726bd;text-align: right;" autocomplete="off" value="0.0" name="tftotal_tk" id="total_h" required/>
				</div>
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Discount(Tk):</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo ($sales_head_row['discount_tk']); ?>" onclick="clickToSelect('discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #a726bd;text-align: right;padding-right: 12px;background: bisque;" autocomplete="off" value="0" name="tftotal_tk" id="discount_tk" required/>
				</div>
			</div>
			<div class="row">
					
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Courier<sup style="color:red">*</sup>:</label>
				<select id="courier" onkeydown="enterEventSelection('courier','advance_tk')" class="form-control">
					<option <?php echo ($courier=="")? 'selected': ''; ?> value="">Select One</option>
					<option <?php echo ($courier=="SteadFast")? 'selected': ''; ?> value="SteadFast">SteadFast</option>
				</select>
				</div>
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Shipping<sup style="color:red">*</sup>:</label>
					
				<input type="text" onkeyup="getTotal();" onclick="clickToSelect('shipping_tk')" onkeydown="enterEventSelection('shipping_tk','advance_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #a726bd;text-align: right;padding-right: 12px;background: #0df4e2;" autocomplete="off" value="<?php echo $shipping_tk; ?>" name="tftotal_tk" id="shipping_tk" required/>
			</div>
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onkeydown="enterEventSelection('chain_tk','bottam_tk')" onclick="clickToSelect('chain_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="chain_tk" required/>
				</div>	
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onclick="clickToSelect('bottam_tk')" onkeydown="enterEventSelection('bottam_tk','others_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="bottam_tk" required/>
				</div>	
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onclick="clickToSelect('others_tk')" onkeydown="enterEventSelection('others_tk','discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="others_tk" required/>
					<input type="hidden" onkeyup="discountPercentage();" onclick="clickToSelect('discount_percentage')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ab556;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="discount_percentage" required/>
				</div>	
				
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Total(Tk): </label>
				<input type="text" readonly maxlength="6" value="<?php echo ($tot-$discount_tk+$shipping_tk); ?>" onkeyup="getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;" autocomplete="off" value="0.0" name="grant_total" id="grant_total" required/>
			</div>	
			<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Advance(Tk): </label>
				<input type="text" maxlength="6" onkeyup="getTotal();" value="<?php echo ($sales_head_row['total_receive']); ?>" onclick="clickToSelect('advance_tk')" onkeydown="enterEventSelection('advance_tk','payment_type')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;color: white;background: #2d38ea;" autocomplete="off" name="advance_tk" id="advance_tk" required/>
			</div>
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color">Payment Type </label>
				<select id="payment_type" class="form-control">
					<option <?php echo ($sales_head_row['payment_type']=='Cash')? 'selected' : ''; ?> value="Cash">Cash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Bkash')? 'selected' : ''; ?> value="Bkash">Bkash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Rocket')? 'selected' : ''; ?> value="Rocket">Rocket</option>
					<option <?php echo ($sales_head_row['payment_type']=='Nagad')? 'selected' : ''; ?> value="Nagad">Nagad</option>
					<option <?php echo ($sales_head_row['payment_type']=='Upay')? 'selected' : ''; ?> value="Upay">Upay</option>
					<option <?php echo ($sales_head_row['payment_type']=='Sure Cash')? 'selected' : ''; ?> value="Sure Cash">Sure Cash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Tap')? 'selected' : ''; ?> value="Tap">Tap</option>
					<option <?php echo ($sales_head_row['payment_type']=='POS Machine')? 'selected' : ''; ?> value="POS Machine">POS Machine</option>
					<option <?php echo ($sales_head_row['payment_type']=='Bank')? 'selected' : ''; ?> value="Bank">Bank</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color" style="text-align: right;">Present Due</label>
				<input type="text" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: blue;text-align: right;" autocomplete="off" value="<?php echo $remaining; ?>" name="due_tk" id="due_tk" required/>
				<!--<label for="comment" class="txt_color">Total Due</label>-->
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;text-align: right;" autocomplete="off" value="0.0" name="total_due" id="total_due" required/>
			</div>
			</div>
				
			
			<button onclick="updateAllInfo('<?php echo $dstblid; ?>','<?php echo $cus_id; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="update_order" class="btn btn-success">Update</button>
			<?php 
				if($_SESSION['USER_TYPE']==2){
			?>
				<button onclick="deleteFabricsOrder('<?php echo $dstblid; ?>','<?php echo $cus_id; ?>','<?php echo $cus_mobile; ?>','<?php echo $param; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="delete_order" class="btn btn-danger">Delete</button>
			<?php } ?>
				<button onclick="closeArea('<?php echo $param; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="delete_order" class="btn btn-warning">Close</button>
			<span id="sms"></span>
		</div>

		
		</div>	
			
			<!--------------------------------Item name list start-------------------------------------->
			<?php 
				if($_SESSION['SVERSION']==0){ //0= correcnt, 1=old order
			?>
				<input type="hidden" id="phy_ord_num" value="0"/>
				<input type="hidden" id="tbl_ord_num" value="0"/>
				<?php 
				}else if($_SESSION['SVERSION']==1){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php 
			}else if($_SESSION['SVERSION']==2){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php } ?> 
			<div id="home" class="tab-pane fade in active">
				<br/>
				<div id="item_head" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;display:none">
				<select id="item_type" onchange="changeType();" style="width:8%;margin-right:5px;float:left" class="form-control">
						<option value="1">Gents</option>
						<option value="2">Lady</option>
					
				</select>
				<span id="show_item_btn">
				
				</span>
					<input type="hidden" value="0" id="selectid"/>
				
				
				</div>
				<div id="page_loading"></div>
				<div id="head_measurement_details" style="color: green;padding: 15px;margin-top: 10px;border:2px solid green;font-weight:bold;text-align:center;display: none;">
				
				</div>
				<div id="measurement_details" style="">
				
				</div> 
				
			</div>
			<div id="getOrderDetails"> 
			</div>
			<!--------------------------------Item name list end-------------------------------------->
			
	  </div>
    </div>

  </div>
		<?php 
		}else{
			echo 2;
		}
	}
	
	if(isset($_REQUEST['only_fab_edit_area_courier'])){
		@$dstblid=$_REQUEST['dstblid'];
		@$param=$_REQUEST['param'];
		$com_id=($_SESSION['COM_ID']);
		$sales_head=$conn->query("SELECT direct_sale_head.*,(select id from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_id,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_name,(select cus_address from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_address  FROM `direct_sale_head` WHERE id='$dstblid'");
		$direct_sale=$conn->query("SELECT direct_sale.*,(select product_name from product where id=direct_sale.item_id) item_name  FROM `direct_sale` WHERE is_active=1 and dstid='$dstblid'");
		$product_fabrics=$conn->query("select * from product where is_active=2 order by id asc");
		if(mysqli_num_rows($sales_head)>0){
			$sales_head_row=mysqli_fetch_array($sales_head);
			$cus_mobile=$sales_head_row['cus_mobile'];
			$cus_name=$sales_head_row['cus_name'];
			$cus_id=$sales_head_row['cus_id'];
			$cus_address=$sales_head_row['cus_address'];
			$shipping_tk=$sales_head_row['shipping_tk'];
			$courier=$sales_head_row['courier'];
			
		?>
<div class="panel-group">
   <div class="panel panel-info">
      <div class="panel-heading" style="overflow:hidden;">
	  <span style="float: left;width: 200px;font-weight: bold;font-size: 16px;">Item Order No.- <?php echo $dstblid; ?></span><b><span id="head_ord_num">
		<input type="hidden" value="<?php echo $dstblid; ?>" id="fab_sl_no"/>
	  </span>
	  </b>
	  <?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><span style="margin-left: 175px;">Total Point <b><span style="color:#e842d4;" id="tot_remaining_point"></span></b></span><?php }else{ echo "<input type='hidden' id='tot_remaining_point'/>"; } ?>
	   </div>
      <div class="panel-body">
		<div id="show_btn"></div>
		<div class="row" id="calculator" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-left: 0px;margin-right: 0px;">
		
		<div class="col-xs-12 col-sm-3">
			
		<label for="comment" class="txt_color">Customer Mobile Number<sup style="color:red">*</sup>:<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><input style="margin-left: 15px;" type="checkbox" class="chkbox" name="normal" id="ref_chk" value="0"/><?php }else{ echo "<span id='ref_chk'></span>"; } ?></label>
				<input type="text" onkeyup="editCustomerInformation('<?php echo $dstblid; ?>','<?php echo $sales_head_row['cus_id']; ?>','mobile','direct_sale_head','customer');" value="<?php echo $sales_head_row['cus_mobile']; ?>" onkeydown="enterEventSelection('mobile','cus_name')" class="form-control" maxlength="11" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="mobile" id="mobile" />
				<span id="auto_mobile" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 240px;"></span>
				<input type="hidden" id="chkAuthUser" value="<?php echo $sales_head_row['cus_id']; ?>" />
				<input type="hidden" id="ref_user_id"/>
				<input type="hidden" id="backup_advance"/>
				<input type="hidden" value="0" id="ref_point_check"/>
				<input type="hidden" id="hidden_item_qty"/>
				<input type="hidden" id="hidden_item_name" />
				<input type="hidden" id="hidden_group_name" />
				<input type="hidden" id="increment_number" value="0"/>
				<input type="hidden" id="previous_delivery_date" value="<?php //echo $dday; ?>"/>
				<input type="hidden" id="tblid" value="0"/>
				<input type="hidden" id="max_item_hidden" value="20"/>
				<input type="hidden" id="max_fabrics_hidden" value="20"/>
				<input type="hidden" id="apply_selling_price" value="<?php echo $_SESSION['APPLY_SELLING_PRICE']; ?>"/>
				<input type="hidden" id="is_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				<input type="hidden" id="merge_order_chk" value=""/>
				<input type="hidden" id="hidden_ord_number" value=""/>
				<input type="hidden" id="hidden_selected_item" value=""/>
				
				<label for="comment" class="txt_color">Customer Name:</label>
				<input type="text" class="form-control" onkeyup="editCustomerInformation('<?php echo $dstblid; ?>','<?php echo $sales_head_row['cus_id']; ?>','cus_name','direct_sale_head','customer');" value="<?php echo @$cus_name; ?>" onkeydown="enterEventSelection('cus_name','cus_address')" autocomplete="off" maxlength="30" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_name" id="cus_name" />
				<input type="hidden" name="hidden_cus_name" id="hidden_cus_name" />
				<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?>
				<label for="comment" class="txt_color">Reference Mobile No.<sup style="color:red"></sup>:<span style="cursor: pointer;color: blue;font-size: 11px;margin-left: 10px;" onclick="copyReferenceNumber();">Copy</span> | <span style="cursor: pointer;color: red;font-size: 11px;" onclick="clearReferenceNumber();">Clear</span></label>
				<input readonly type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" maxlength="11" autocomplete="off" name="total_tk" id="ref_mobile_number"/>
				<?php } ?>
				<label for="comment" class="txt_color">Address:</label>
				<textarea rows="5" onkeydown="enterEventSelection('cus_address','date1')" class="form-control" autocomplete="off" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_name" id="cus_address"><?php echo $cus_address; ?></textarea>
				
				<input type="hidden" style="background: #8bc34a;font-weight:bold" onkeyup="return setDeliveryDate();" autocomplete="off" name="delivery_day" id="delivery_day" value="<?php //echo $delivery_day; ?>" class="form-control">
				<input type="hidden" autocomplete="off" name="date1" onkeydown="enterEventSelection('date1','ds_item_id')" id="date1" value="<?php //echo $dday; ?>" class="form-control">
				
				
			<div class="row">
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="design_charge" id="design_charge" required/>
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_item_qty" id="total_item_qty" required/>
				</div>	
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_tk" id="total_tk" required/>
				</div>
			</div>
			
				<input type="hidden" onkeyup="getAdvance();" maxlength="3" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="discount" id="discount" value="0" required/>
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="tdue" id="tdue" value="0" required/>
				<div style="margin: 10px;display:none">
					<input type="hidden" class="form-control" name="txt_sms" id="txt_sms" />
					<input type="checkbox" class="chkbox" checked name="normal" id="normal" value="0"/> <span class="checkboxtext" id="nor">Normal</span>
					<input type="checkbox" class="chkbox" name="emergency" id="emergency" value="1"/> <span class="checkboxtext" id="emg">Urgent</span>
				</div>
			<div class="" id="urdate_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" placeholder="Factory Delivery" name="date1" value="" id="urdate" class="form-control" data-select="date">
			</div>
			<div class="" id="urtime_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" name="date1" value="<?php //echo $cdate; ?>" id="urtime" class="form-control">
			</div>
			<div class="row">
				<input type="hidden" value="" id="master_id"/>
				<input type="hidden" value="" id="karigor_id"/>
			
			</div>
		</div>	
		
		<div class="col-xs-12 col-sm-6">
			<label for="comment" class="txt_color">Item Name<span> (Maximum <b><span style="color:red" id="max_fabrics">20</span></b> Fabrics)</span></label>
			<div style="margin-bottom: 5px;" id="reload_item_list">
				<select class="form-control select2" onchange="getNewItem('<?php echo $dstblid; ?>','<?php echo $cus_id; ?>');" style="font-weight: bold;font-size:18px;font-style: italic;background:#f9d9a8" id="ds_item_id">
					<option value="">Select One</option>
					<!--<?php 
					while($rows=mysqli_fetch_array($product_fabrics)){
						@$item_code=($rows['item_code']=="")? '' : ' ['.$rows['item_code'].']';
						@$unit=($rows['uom']=="")? '' : '-('.$rows['uom'].')';
						@$avg_price="";//($rows['avg_price']=="")? '0' : '-'.$rows['avg_price'].'/=';
						@$selling_price=($rows['selling_price']=="")? '0' : '-Rate: '.$rows['selling_price'].'/=';
						@$stock_qty=($rows['stock_qty']=="")? '0' : ' Stock: '.$rows['stock_qty'];
						if($_SESSION['IS_STOCK']==0){
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name']; ?></option>
						<?php
						}
						if($_SESSION['IS_STOCK']==1){ // maintain stock
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name'].$item_code.$unit; ?></option>
						<?php
						}
					} 
					?>-->
					
				</select>
			</div>
			<div style="">
				<table id="dynamic-table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr style="background:#D3DCE3;">
							<th>Sl</th>
							<th style="width: 58%;">Item</th>
							<th style="width:10%;text-align:right">Qty(Pic)</th>
							<th style="width: 15%;text-align:right">Price</th>
							<th style="width: 20%;text-align:right">Sub Total</th>
						</tr>
					</thead>
					<tbody id="item_details">
					<?php 
					$tot=0;$sl=0;
					$discount=$sales_head_row['discount'];
					$discount_tk=$sales_head_row['discount_tk'];
					$fab_total=$sales_head_row['f_total'];
					$total_receive=$sales_head_row['total_receive'];
					if($discount>0){
						$remaining=($fab_total-$discount_tk-$total_receive+$shipping_tk);
					}else{
						$remaining=($fab_total-$total_receive+$shipping_tk);
					}
					
					if(mysqli_num_rows($direct_sale)>0){
						$sl=0;$c=0;
						while($direct_sale_row=mysqli_fetch_array($direct_sale)){
							$item_price=$direct_sale_row['price'];
							if($discount_tk>0){
								$item_price=(($item_price*100)/(100-$discount));
							}
							$tot+=round(($direct_sale_row['item_qty']*$item_price),2);
							$sl=++$c;
						?>
							<tr id="fab_edit_row<?php echo $sl; ?>">
								<td id='thd'>
									<span>
										<a href='javascript:void(0)' style="color:red" onclick="delDetailSalesCourier('<?php echo $direct_sale_row['id']; ?>','<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['order_number']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $cus_mobile; ?>','<?php echo $param; ?>');" id="delid<?php echo $direct_sale_row['id']; ?>">Return</a>
									</span>
								</td>
								<td>
									<input type='hidden' id='hidden_item_id<?php echo $direct_sale_row['id']; ?>' value='<?php echo $direct_sale_row['item_id']; ?>'/>
									<?php echo $direct_sale_row['item_name']; ?>
								</td>
								<td style='width: 10%;' class='text-align-right'>
									<input type='hidden' value='<?php echo $direct_sale_row['id']; ?>' id="hidden_fs_tbl_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_qty']; ?>' id="hidden_edit_fab_qty<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_id']; ?>' id="hidden_edit_item_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['purchase_price']; ?>' id="hidden_purchase_price<?php echo $sl; ?>"/>
									<input readonly type='text' maxlength='7' style='text-align:right;color:black;font-size:18px;font-style: italic;font-weight: bold;width: 100%;' autocomplete='off' class='qtycls qtywidth' value='<?php echo $direct_sale_row['item_qty']; ?>' placeholder='1' id="edit_fab_qty<?php echo $sl; ?>" onclick="clickToSelect('edit_fab_qty<?php echo $sl; ?>')" onkeyup="liveCheckStockQty('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['purchase_price']; ?>','<?php echo $cus_id; ?>'); "/>
								</td>
								<td style='width: 10%;' id='thd'>
									<input readonly type='text' style='text-align:right;font-size:18px;font-style: italic;color:black;font-weight: bold;width: 100%;' maxlength='7' autocomplete='off' placeholder='0' value='<?php echo $item_price; ?>' class='price text-align-right' id='live_item_pricec<?php echo $sl; ?>' onclick="clickToSelect('live_item_pricec<?php echo $sl; ?>')" onkeyup="pricef('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>');"/>
								</td>
								<td id='thd' class='text-align-right'>
									<span class='totalcls' style='float:right;color:black;font-weight: bold;font-size:18px;font-style: italic;' disabled='disabled' id="sub_total<?php echo $sl; ?>">
									<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?></span>
								</td>
							</tr>
						<?php
						}
					} 
					?>
					
					</tbody>
					<input type="hidden" value="<?php echo @$sl; ?>" id="fab_hidden_id"/>
				</table>
				<span style="color: blue;font-size: 26px;" id="usuccess"></span>
				
				
				<!--<label for="comment" class="txt_color">Discount(%) </label>-->
				<input type="hidden" onkeyup="febDiscount();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="febdis" id="febdis" value="0" required/>
				
				
				<input type="hidden" value="0" id="sub_tot_f_val"/>
				<input type="hidden" value="0" id="fab_total"/>
				<span id="item_detail_copy">
				</span>
				<!--<input type="hidden" id="total_h"/>-->
			</div>
			
		</div>
		<div class="col-xs-12 col-sm-3">
			<div class="row">
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: red;text-align: right;" autocomplete="off" value="0.0" name="previous_due" id="previous_due" required/>
					
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Sub Total(Tk)<sup style="color:red">*</sup>:</label>
					<input type="text" readonly value="<?php echo @$tot; ?>" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: #a726bd;text-align: right;" autocomplete="off" value="0.0" name="tftotal_tk" id="total_h" required/>
				</div>
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Discount(Tk):</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo ($sales_head_row['discount_tk']); ?>" onclick="clickToSelect('discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #a726bd;text-align: right;padding-right: 12px;background: bisque;" autocomplete="off" value="0" name="tftotal_tk" id="discount_tk" required/>
				</div>
			</div>
			<div class="row">
					
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Courier<sup style="color:red">*</sup>:</label>
				<select id="courier" onkeydown="enterEventSelection('courier','advance_tk')" class="form-control">
					<option <?php echo ($courier=="")? 'selected': ''; ?> value="">Select One</option>
					<option <?php echo ($courier=="SteadFast")? 'selected': ''; ?> value="SteadFast">SteadFast</option>
				</select>
				</div>
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Shipping<sup style="color:red">*</sup>:</label>
					
				<input type="text" onkeyup="getTotal();" onclick="clickToSelect('shipping_tk')" onkeydown="enterEventSelection('shipping_tk','advance_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #a726bd;text-align: right;padding-right: 12px;background: #0df4e2;" autocomplete="off" value="<?php echo $shipping_tk; ?>" name="tftotal_tk" id="shipping_tk" required/>
			</div>
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onkeydown="enterEventSelection('chain_tk','bottam_tk')" onclick="clickToSelect('chain_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="chain_tk" required/>
				</div>	
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onclick="clickToSelect('bottam_tk')" onkeydown="enterEventSelection('bottam_tk','others_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="bottam_tk" required/>
				</div>	
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<input type="hidden" onkeyup="getAdvance();" onclick="clickToSelect('others_tk')" onkeydown="enterEventSelection('others_tk','discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="others_tk" required/>
					<input type="hidden" onkeyup="discountPercentage();" onclick="clickToSelect('discount_percentage')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ab556;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="discount_percentage" required/>
				</div>	
				
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Total(Tk): </label>
				<input type="text" readonly maxlength="6" value="<?php echo ($tot-$discount_tk+$shipping_tk); ?>" onkeyup="getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;" autocomplete="off" value="0.0" name="grant_total" id="grant_total" required/>
			</div>	
			<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Advance(Tk): </label>
				<input type="text" maxlength="6" onkeyup="getTotal();" value="<?php echo ($sales_head_row['total_receive']); ?>" onclick="clickToSelect('advance_tk')" onkeydown="enterEventSelection('advance_tk','payment_type')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;color: white;background: #2d38ea;" autocomplete="off" name="advance_tk" id="advance_tk" required/>
			</div>
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color">Payment Type </label>
				<select id="payment_type" class="form-control">
					<option <?php echo ($sales_head_row['payment_type']=='Cash')? 'selected' : ''; ?> value="Cash">Cash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Bkash')? 'selected' : ''; ?> value="Bkash">Bkash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Rocket')? 'selected' : ''; ?> value="Rocket">Rocket</option>
					<option <?php echo ($sales_head_row['payment_type']=='Nagad')? 'selected' : ''; ?> value="Nagad">Nagad</option>
					<option <?php echo ($sales_head_row['payment_type']=='Upay')? 'selected' : ''; ?> value="Upay">Upay</option>
					<option <?php echo ($sales_head_row['payment_type']=='Sure Cash')? 'selected' : ''; ?> value="Sure Cash">Sure Cash</option>
					<option <?php echo ($sales_head_row['payment_type']=='Tap')? 'selected' : ''; ?> value="Tap">Tap</option>
					<option <?php echo ($sales_head_row['payment_type']=='POS Machine')? 'selected' : ''; ?> value="POS Machine">POS Machine</option>
					<option <?php echo ($sales_head_row['payment_type']=='Bank')? 'selected' : ''; ?> value="Bank">Bank</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color" style="text-align: right;">Present Due</label>
				<input type="text" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: blue;text-align: right;" autocomplete="off" value="<?php echo $remaining; ?>" name="due_tk" id="due_tk" required/>
				<!--<label for="comment" class="txt_color">Total Due</label>-->
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;text-align: right;" autocomplete="off" value="0.0" name="total_due" id="total_due" required/>
			</div>
			</div>
				
			
			<button onclick="updateAllInfoCourier('<?php echo $dstblid; ?>','<?php echo $cus_id; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="update_order" class="btn btn-success">Done</button>
			<?php 
				if($_SESSION['USER_TYPE']==2){
			?>
			<?php } ?>
				<button onclick="closeArea('<?php echo $param; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="delete_order" class="btn btn-warning">Close</button>
			<span id="sms"></span>
		</div>

		
		</div>	
			
			<!--------------------------------Item name list start-------------------------------------->
			<?php 
				if($_SESSION['SVERSION']==0){ //0= correcnt, 1=old order
			?>
				<input type="hidden" id="phy_ord_num" value="0"/>
				<input type="hidden" id="tbl_ord_num" value="0"/>
				<?php 
				}else if($_SESSION['SVERSION']==1){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php 
			}else if($_SESSION['SVERSION']==2){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php } ?> 
			<div id="home" class="tab-pane fade in active">
				<br/>
				<div id="item_head" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;display:none">
				<select id="item_type" onchange="changeType();" style="width:8%;margin-right:5px;float:left" class="form-control">
						<option value="1">Gents</option>
						<option value="2">Lady</option>
					
				</select>
				<span id="show_item_btn">
				
				</span>
					<input type="hidden" value="0" id="selectid"/>
				
				
				</div>
				<div id="page_loading"></div>
				<div id="head_measurement_details" style="color: green;padding: 15px;margin-top: 10px;border:2px solid green;font-weight:bold;text-align:center;display: none;">
				
				</div>
				<div id="measurement_details" style="">
				
				</div> 
				
			</div>
			<div id="getOrderDetails"> 
			</div>
			<!--------------------------------Item name list end-------------------------------------->
			
	  </div>
    </div>

  </div>
		<?php 
		}else{
			echo 2;
		}
	}
	
if(isset($_REQUEST['updateOnlyOrder'])){
	@$ord_num=$_REQUEST['ord_num'];
	@$dsms_id=$_REQUEST['dsms_id'];
	@$update_fab_sl_no=trim($_REQUEST['update_fab_sl_no']);
	$chk_duplicate=$conn->query("select * from dsms where is_active=1 and phy_ord_num='$update_fab_sl_no'");
	if(mysqli_num_rows($chk_duplicate)<=0){
		$sales_head=$conn->query("update dsms set phy_ord_num='$update_fab_sl_no',tagnum='$update_fab_sl_no' where id='$dsms_id'");
		$conn->query("update order_record set order_number='$update_fab_sl_no' where order_number='$ord_num'");
		$conn->query("update direct_sale set order_number='$update_fab_sl_no' where order_number='$ord_num'");
		$conn->query("update wages_details set order_num='$update_fab_sl_no' where order_num='$ord_num'");
		if($sales_head){
		?>
			<span onclick="viewAllEditArea('<?php echo $update_fab_sl_no; ?>');"><i>Edit</i></span> | 
			<span onclick="getOrderDetails('<?php echo $update_fab_sl_no; ?>');">Deliv.</span> | 
			<span style="color: blue;" onclick="moneyReceitPrint('<?php echo $update_fab_sl_no; ?>');"><i>Print</i></span>
		<?php 
		}
	}else{
		echo 2;
	}
		
}
	

if(isset($_REQUEST['viewAllEditArea'])){
		@$ord_num=$_REQUEST['ord_num'];
		
		$com_id=($_SESSION['COM_ID']);
		$sales_head=$conn->query("SELECT direct_sale_head.*,(select id from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_id,(select cus_name from customer where cus_mobile=direct_sale_head.cus_mobile limit 0,1) cus_name  FROM `direct_sale_head` WHERE id=(SELECT direct_sale.dstid  FROM `direct_sale` WHERE is_active=1 and order_number='$ord_num' limit 0,1)");
		$direct_sale=$conn->query("SELECT direct_sale.*,(select product_name from product where id=direct_sale.item_id) item_name  FROM `direct_sale` WHERE is_active=1 and order_number='$ord_num'");
		
		$order_head=$conn->query("select dsms.*,(select amount from accounting where dsms_id=dsms.id and pay_status=1 and is_active=1 order by id asc limit 0,1) advance_tk,(select id from customer where cus_mobile=dsms.cus_mobile limit 0,1) cus_id from dsms where is_active=1 and phy_ord_num='$ord_num'");
		
		$product_fabrics=$conn->query("select * from product where is_active=2 order by id asc");
		$product=$conn->query("select * from product where is_active=1 and ptype=1 order by steps asc");
		$making_product=$conn->query("select order_record.*,(select img_loc from attachment_tbl where order_num=order_record.id order by id desc limit 0,1) img_loc,(select product_name from product where id=order_record.item_id limit 0,1) item_name,(select cus_price from product where id=order_record.item_id limit 0,1) cus_price from order_record where is_active=1 and order_number='$ord_num'");
		if(mysqli_num_rows($order_head)>0){
			$order_head_row=mysqli_fetch_array($order_head);
			$dv_date=date_format(date_create($order_head_row['dv_date']),"d/m/Y");
			$ord_date=date_format(date_create($order_head_row['insert_date']),"d/m/Y");
			$dsms_id=$order_head_row['id'];
			$paymentType=$order_head_row['paymentType'];
			$cus_id=$order_head_row['cus_id'];
			$cus_mobile=$order_head_row['cus_mobile'];
			$cus_name=$order_head_row['cus_name'];
			
			@$head_discount_tk=$order_head_row['discount'];
			@$design_tk=$order_head_row['others_tk'];
			@$chain_tk=$order_head_row['chain_tk'];
			@$bottam_tk=$order_head_row['bottam_tk'];
			@$tfabrics_tk=$order_head_row['tfabrics_tk'];
			$advance_tk=($order_head_row['advance_tk']=="")? 0 : $order_head_row['advance_tk'];
			$total_amount=(($order_head_row['amount']+$head_discount_tk)-$design_tk-$bottam_tk-$chain_tk-$tfabrics_tk);
			
			$grant_total=($total_amount+$design_tk+$bottam_tk+$chain_tk+$tfabrics_tk-$head_discount_tk);
			$grant_due=$grant_total-$advance_tk;
			$dstblid="";
			if(mysqli_num_rows($sales_head)>0){
				$sales_head_row=mysqli_fetch_array($sales_head);
				@$dstblid=$sales_head_row['id'];
				
			}
			
			
		?>
<div class="panel-group">
   <div class="panel panel-info">
      <div class="panel-heading" style="overflow:hidden;">
	  <span style="float: left;width: 90px;font-weight: bold;font-size: 16px;">Order No.- </span><input style="font-weight: bold;font-size: 15px;color: black;font-style: italic;margin-right: 5px;width: 8%;" type="text" value="<?php echo $ord_num; ?>" id="update_fab_sl_no"/><span style="font-style: italic;color: red;cursor: pointer;text-decoration: underline;" onclick="updateOnlyOrder('<?php echo $ord_num; ?>','<?php echo $dsms_id; ?>');">Update</span> <span style="margin-left: 10px;" id="update_order_sms"></span><b><span id="head_ord_num">
		<input type="hidden" value="<?php echo $ord_num; ?>" id="fab_sl_no"/>
	  </span>
	  </b>
	  <?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><span style="margin-left: 175px;">Total Point <b><span style="color:#e842d4;" id="tot_remaining_point"></span></b></span><?php }else{ echo "<input type='hidden' id='tot_remaining_point'/>"; } ?>
	   </div>
      <div class="panel-body">
		<div id="show_btn"></div>
		<div class="row" id="calculator" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;margin-left: 0px;margin-right: 0px;">
		
		<div class="col-xs-12 col-sm-3">
					
		<label for="comment" class="txt_color">Customer Mobile Number<sup style="color:red">*</sup>:<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?><input style="margin-left: 15px;" type="checkbox" class="chkbox" name="normal" id="ref_chk" value="0"/><?php }else{ echo "<span id='ref_chk'></span>"; } ?></label>
				<input type="text" onkeyup="editCustomerInformation('<?php echo $ord_num; ?>','<?php echo $order_head_row['cus_id']; ?>','mobile','dsms','customer');" value="<?php echo $order_head_row['cus_mobile']; ?>" onkeydown="enterEventSelection('mobile','cus_name')" class="form-control" maxlength="11" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" name="mobile" id="mobile" />
				<span id="auto_mobile" style="z-index: 99999999999999;
					overflow: hidden;
					position: fixed;
					width: 240px;"></span>
				<input type="hidden" id="chkAuthUser" value="<?php echo $cus_id; ?>" />
				<input type="hidden" id="ref_user_id"/>
				<input type="hidden" id="backup_advance"/>
				<input type="hidden" value="0" id="ref_point_check"/>
				<input type="hidden" id="hidden_item_qty"/>
				<input type="hidden" id="hidden_item_name" />
				<input type="hidden" id="hidden_group_name" />
				<input type="hidden" id="increment_number" value="0"/>
				<input type="hidden" id="previous_delivery_date" value="<?php //echo $dday; ?>"/>
				<input type="hidden" id="tblid" value="0"/>
				<input type="hidden" id="max_item_hidden" value="20"/>
				<input type="hidden" id="max_fabrics_hidden" value="20"/>
				<input type="hidden" id="apply_selling_price" value="<?php echo $_SESSION['APPLY_SELLING_PRICE']; ?>"/>
				<input type="hidden" id="is_stock" value="<?php echo $_SESSION['IS_STOCK']; ?>"/>
				<input type="hidden" id="merge_order_chk" value=""/>
				<input type="hidden" id="hidden_ord_number" value=""/>
				<input type="hidden" id="hidden_selected_item" value=""/>
				
				<label for="comment" class="txt_color">Customer Name:</label>
				<input type="text" class="form-control" onkeyup="editCustomerInformation('<?php echo $ord_num; ?>','<?php echo $cus_id; ?>','cus_name','dsms','customer');" value="<?php echo $order_head_row['cus_name']; ?>" onkeydown="enterEventSelection('cus_name','date1')" autocomplete="off" maxlength="30" style="font-weight: bold;font-size:18px;font-style: italic;" name="cus_name" id="cus_name" />
				<input type="hidden" name="hidden_cus_name" id="hidden_cus_name" />
				<?php if($_SESSION['ACTIVE_REFERENCE']==1){ ?>
				<label for="comment" class="txt_color">Reference Mobile No.<sup style="color:red"></sup>:<span style="cursor: pointer;color: blue;font-size: 11px;margin-left: 10px;" onclick="copyReferenceNumber();">Copy</span> | <span style="cursor: pointer;color: red;font-size: 11px;" onclick="clearReferenceNumber();">Clear</span></label>
				<input readonly type="text" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;" maxlength="11" autocomplete="off" name="total_tk" id="ref_mobile_number"/>
				<?php } ?>
				<label for="comment" class="txt_color">Order Date<sup style="color:red">*</sup>:</label>
				<input type="text" autocomplete="off" name="date2" onkeydown="enterEventSelection('date2','ds_item_id')" onkeyup="editCustomerInformation('<?php echo $ord_num; ?>','<?php echo $cus_id; ?>','date2','dsms','customer');" id="date2" value="<?php echo $ord_date; ?>" class="form-control"><!-- data-select="date"--->
				
				<label for="comment" class="txt_color">Delivery Date<sup style="color:red">*</sup>:</label>
				<input type="hidden" style="background: #8bc34a;font-weight:bold" onkeyup="return setDeliveryDate();" autocomplete="off" name="delivery_day" id="delivery_day" value="<?php //echo $delivery_day; ?>" class="form-control">
				<input type="text" autocomplete="off" name="date1" onkeydown="enterEventSelection('date1','ds_item_id')" onkeyup="editCustomerInformation('<?php echo $ord_num; ?>','<?php echo $cus_id; ?>','date1','dsms','customer');" id="date1" value="<?php echo $dv_date; ?>" class="form-control"><!-- data-select="date"--->
				
				
			<div class="row">
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="design_charge" id="design_charge" required/>
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_item_qty" id="total_item_qty" required/>
				</div>	
				<div class="col-xs-12 col-sm-6">
					<input type="hidden" readonly onkeyup="return getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" value="0" name="total_tk" id="total_tk" required/>
				</div>
			</div>
			
				<input type="hidden" onkeyup="getAdvance();" maxlength="3" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="discount" id="discount" value="0" required/>
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="tdue" id="tdue" value="0" required/>
				<div style="margin: 10px;display:none">
					<input type="hidden" class="form-control" name="txt_sms" id="txt_sms" />
					<input type="checkbox" class="chkbox" checked name="normal" id="normal" value="0"/> <span class="checkboxtext" id="nor">Normal</span>
					<input type="checkbox" class="chkbox" name="emergency" id="emergency" value="1"/> <span class="checkboxtext" id="emg">Urgent</span>
				</div>
			<div class="" id="urdate_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" placeholder="Factory Delivery" name="date1" value="" id="urdate" class="form-control" data-select="date">
			</div>
			<div class="" id="urtime_option">
				<input type="hidden" style="font-weight: bold;font-size:18px;font-style: italic;margin-top: 12px;" autocomplete="off" name="date1" value="<?php //echo $cdate; ?>" id="urtime" class="form-control">
			</div>
			<div class="row">
				<input type="hidden" value="" id="master_id"/>
				<input type="hidden" value="" id="karigor_id"/>
			
			</div>
		</div>	
		
		<div class="col-xs-12 col-sm-6">
			<label for="comment" class="txt_color">Fabrics Name<span> (Maximum <b><span style="color:red" id="max_fabrics">20</span></b> Fabrics)</span></label>
			<div style="margin-bottom: 5px;" id="reload_item_list">
				<select class="form-control select2" onchange="getNewItem('<?php echo $dstblid; ?>','<?php echo $ord_num; ?>','<?php echo $cus_id; ?>','<?php echo $cus_mobile; ?>');" style="font-weight: bold;font-size:18px;font-style: italic;background:#f9d9a8" id="ds_item_id">
					<option value="">Select One</option>
					<?php 
					while($rows=mysqli_fetch_array($product_fabrics)){
						@$item_code=($rows['item_code']=="")? '' : ' ['.$rows['item_code'].']';
						@$unit=($rows['uom']=="")? '' : '-('.$rows['uom'].')';
						@$avg_price="";//($rows['avg_price']=="")? '0' : '-'.$rows['avg_price'].'/=';
						@$selling_price=($rows['selling_price']=="")? '0' : '-Rate: '.$rows['selling_price'].'/=';
						@$stock_qty=($rows['stock_qty']=="")? '0' : ' Stock: '.$rows['stock_qty'];
						if($_SESSION['IS_STOCK']==0){
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name']; ?></option>
						<?php
						}
						if($_SESSION['IS_STOCK']==1){ // maintain stock
						?>
						<option value="<?php echo $rows['id']."#sep#".$rows['product_name']."#sep#".$rows['uom']."#sep#".$rows['selling_price']."#sep#".$rows['stock_qty']."#sep#".$rows['purchase_price']."#sep#".$rows['item_code']; ?>"><?php echo $rows['product_name'].$item_code.$unit; ?></option>
						<?php
						}
					} 
					?>
					
				</select>
			</div>
			<div style="">
				<table id="dynamic-table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr style="background:#D3DCE3;">
							<th>Sl</th>
							<th style="width: 58%;">Item</th>
							<th style="width:10%;text-align:right">Qty(Pic)</th>
							<th style="width: 15%;text-align:right">Price</th>
							<th style="width: 20%;text-align:right">Sub Total</th>
						</tr>
					</thead>
					<tbody id="item_details">
					<?php 
					
					$sl=0;
					if(mysqli_num_rows($direct_sale)>0){
						$tot=0;
						$discount=$sales_head_row['discount'];
						$discount_tk=$sales_head_row['discount_tk'];
						$fab_total=$sales_head_row['f_total'];
						$total_receive=$sales_head_row['total_receive'];
						if($discount>0){
							$remaining=($fab_total-$discount_tk-$total_receive);
						}else{
							$remaining=($fab_total-$total_receive);
						}
						$c=0;
						while($direct_sale_row=mysqli_fetch_array($direct_sale)){
							$item_price=$direct_sale_row['price'];
							if($discount_tk>0){
								$item_price=(($item_price*100)/(100-$discount));
							}
							$tot+=round(($direct_sale_row['item_qty']*$item_price),2);
							$sl=++$c;
						?>
							<tr id="fab_edit_row<?php echo $sl; ?>">
								<td id='thd'>
									<span>
										<a href='javascript:void(0)' style="color:red" onclick="delDetailSales('<?php echo $direct_sale_row['id']; ?>','<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['order_number']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $cus_mobile; ?>');" id="delid<?php echo $direct_sale_row['id']; ?>">del</a>
									</span>
								</td>
								<td>
									<input type='hidden' id='hidden_item_id<?php echo $direct_sale_row['id']; ?>' value='<?php echo $direct_sale_row['item_id']; ?>'/>
									<?php echo $direct_sale_row['item_name']; ?>
								</td>
								<td style='width: 10%;' class='text-align-right'>
									<input type='hidden' value='<?php echo $direct_sale_row['id']; ?>' id="hidden_fs_tbl_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_qty']; ?>' id="hidden_edit_fab_qty<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['item_id']; ?>' id="hidden_edit_item_id<?php echo $sl; ?>"/>
									<input type='hidden' value='<?php echo $direct_sale_row['purchase_price']; ?>' id="hidden_purchase_price<?php echo $sl; ?>"/>
									<input type='text' maxlength='7' style='text-align:right;color:black;font-size:18px;font-style: italic;font-weight: bold;width: 100%;' autocomplete='off' class='qtycls qtywidth' value='<?php echo $direct_sale_row['item_qty']; ?>' placeholder='1' id="edit_fab_qty<?php echo $sl; ?>" onclick="clickToSelect('edit_fab_qty<?php echo $sl; ?>')" onkeyup="liveCheckStockQty('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>','<?php echo $direct_sale_row['item_id']; ?>','<?php echo $direct_sale_row['item_qty']; ?>','<?php echo $dstblid; ?>','<?php echo $direct_sale_row['purchase_price']; ?>','<?php echo $cus_id; ?>'); "/>
								</td>
								<td style='width: 10%;' id='thd'>
									<input type='text' style='text-align:right;font-size:18px;font-style: italic;color:black;font-weight: bold;width: 100%;' maxlength='7' autocomplete='off' placeholder='0' value='<?php echo $item_price; ?>' class='price text-align-right' id='live_item_pricec<?php echo $sl; ?>' onclick="clickToSelect('live_item_pricec<?php echo $sl; ?>')" onkeyup="pricef('<?php echo $sl; ?>','<?php echo $direct_sale_row['id']; ?>');"/>
								</td>
								<td id='thd' class='text-align-right'>
									<span class='totalcls' style='float:right;color:black;font-weight: bold;font-size:18px;font-style: italic;' disabled='disabled' id="sub_total<?php echo $sl; ?>">
									<?php echo round(($direct_sale_row['item_qty']*$item_price),2); ?></span>
								</td>
							</tr>
						<?php
						}
					} 
					?>
					
					</tbody>
					<input type="hidden" value="<?php echo @$sl; ?>" id="fab_hidden_id"/>
				</table>
				<span style="color: blue;font-size: 26px;" id="usuccess"></span>
				
				
				<!--<label for="comment" class="txt_color">Discount(%) </label>-->
				<input type="hidden" onkeyup="febDiscount();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align:right" autocomplete="off" name="febdis" id="febdis" value="0" required/>
				
				
				<input type="hidden" value="0" id="sub_tot_f_val"/>
				<input type="hidden" value="0" id="fab_total"/>
				<span id="item_detail_copy">
				</span>
				<!--<input type="hidden" id="total_h"/>-->
			</div>
			
		</div>
		<div class="col-xs-12 col-sm-3">
			<div class="row">
					<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: red;text-align: right;" autocomplete="off" value="0.0" name="previous_due" id="previous_due" required/>
					
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Sub Total(Tk)<sup style="color:red">*</sup>:</label>
					<input type="text" readonly value="<?php echo @$total_amount; ?>" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:#E5E5E5;color: #a726bd;text-align: right;" autocomplete="off" name="tftotal_tk" id="total_h" required/>
				</div>
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Fabrics(Tk)<sup style="color:red">*</sup>:</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo @$tfabrics_tk; ?>" onkeydown="enterEventSelection('tfabrics_tk','chain_tk')" onclick="clickToSelect('tfabrics_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;background:green;color: white;text-align: right;" autocomplete="off" name="tftotal_tk" id="tfabrics_tk" required/>
				</div>
				
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Others</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo @$chain_tk; ?>" onkeydown="enterEventSelection('chain_tk','bottam_tk')" onclick="clickToSelect('chain_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" name="tftotal_tk" id="chain_tk" required/>
				</div>	
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
				<label for="comment" class="txt_color">Bottam(Tk):</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo @$bottam_tk; ?>" onclick="clickToSelect('bottam_tk')" onkeydown="enterEventSelection('bottam_tk','others_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" name="tftotal_tk" id="bottam_tk" required/>
				</div>	
			</div>
			<div class="row">
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Design(Tk):</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo @$design_tk; ?>" onclick="clickToSelect('others_tk')" onkeydown="enterEventSelection('others_tk','discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ba6a6;text-align: right;" autocomplete="off" name="tftotal_tk" id="others_tk" required/>
					<input type="hidden" onkeyup="discountPercentage();" onclick="clickToSelect('discount_percentage')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #4ab556;text-align: right;" autocomplete="off" value="0" name="tftotal_tk" id="discount_percentage" required/>
				</div>	
				<div class="col-xs-12 col-sm-6" style="text-align: right;">
					<label for="comment" class="txt_color">Discount(Tk):</label>
					<input type="text" onkeyup="getTotal();" value="<?php echo @$head_discount_tk; ?>" onclick="clickToSelect('discount_tk')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:25px;font-style: italic;color: #a726bd;text-align: right;padding-right: 12px;background: bisque;" autocomplete="off" name="tftotal_tk" id="discount_tk" required/>
				</div>
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color" style="text-align: right;">Total(Tk): </label>
				<input type="text" readonly maxlength="6" value="<?php echo @$grant_total; ?>" onkeyup="getAdvance();" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;" autocomplete="off" value="0.0" name="grant_total" id="grant_total" required/>
			</div>	
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color" style="text-align: right;">Advance(Tk): </label>
				<input type="text" maxlength="6" onkeyup="getTotal();" value="<?php echo @$advance_tk; ?>" onclick="clickToSelect('advance_tk')" onkeydown="enterEventSelection('advance_tk','payment_type')" class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;text-align: right;color: white;background: #2d38ea;" autocomplete="off" name="advance_tk" id="advance_tk" required/>
			</div>
			</div>
			<div class="row">
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color">Payment Type </label>
				<select id="payment_type" class="form-control">
					<option <?php echo ($paymentType=='Cash')? 'selected' : ''; ?> value="Cash">Cash</option>
					<option <?php echo ($paymentType=='আল আব্বাস')? 'selected' : ''; ?> value="আল আব্বাস">আল আব্বাস</option>
				</select>
			</div>
			<div class="col-xs-12 col-sm-6">
				<label for="comment" class="txt_color" style="text-align: right;">Present Due</label>
				<input type="text" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: blue;text-align: right;" autocomplete="off" value="<?php echo $grant_due; ?>" name="due_tk" id="due_tk" required/>
				<!--<label for="comment" class="txt_color">Total Due</label>-->
				<input type="hidden" readonly class="form-control" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="font-weight: bold;font-size:18px;font-style: italic;color: #5e5ea2;text-align: right;" autocomplete="off" value="0.0" name="total_due" id="total_due" required/>
			</div>
			</div>
				
			
			<button onclick="updateAllInfo('<?php echo $ord_num; ?>','<?php echo $dsms_id; ?>','<?php echo @$dstblid; ?>','<?php echo @$cus_id; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="update_order" class="btn btn-success">Update</button>
			<button onclick="moneyReceitPrint('<?php echo $ord_num; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="print_order" class="btn btn-info">Print</button>
			<?php 
				if($_SESSION['USER_TYPE']==2){
			?>
				<button onclick="deleteFabricsOrder('<?php echo $ord_num; ?>','<?php echo $dsms_id; ?>','<?php echo $dstblid; ?>','<?php echo @$cus_id; ?>','<?php echo @$cus_mobile; ?>');" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="delete_order" class="btn btn-danger">Delete</button>
			<?php } ?>
			<button onclick="closeArea();" style="margin-top: 12px;margin-right:5px" name="btn" value="sub" id="delete_order" class="btn btn-warning">Close</button>
			<span id="sms"></span>
		</div>

		
		</div>	
			
			<!--------------------------------Item name list start-------------------------------------->
			<?php 
				if($_SESSION['SVERSION']==0){ //0= correcnt, 1=old order
			?>
				<input type="hidden" id="phy_ord_num" value="0"/>
				<input type="hidden" id="tbl_ord_num" value="0"/>
				<?php 
				}else if($_SESSION['SVERSION']==1){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php 
			}else if($_SESSION['SVERSION']==2){
				?>
				<input type="hidden" id="tbl_ord_num" value=""/>
				
			<?php } ?> 
			<div id="home" class="tab-pane fade in active">
				<br/>
				<div id="item_head" style="color: black;box-shadow: inset 0 0 1em gray;padding: 15px;">
				<select id="item_type" onchange="changeType();" style="width:8%;margin-right:5px;float:left" class="form-control">
						<option value="1">Gents</option>
						<option value="2">Lady</option>
					
				</select>
				<span id="show_item_btn">
				<?php 
					$ic=1;
					while($rows=mysqli_fetch_array($product)){
						$jj=$ic++;
					?>
					<button  onclick="itemIdWiseDetails('<?php echo $rows['id']."#sep#".$ord_num."#sep#".$dsms_id."#sep#".$rows['group_id']."#sep#".$rows['cus_price']."#sep#".$rows['product_name']; ?>');" name="btn" value="sub" id="item_btn<?php echo $jj; ?>" class="btn btn-primary"><?php echo $rows['product_name']; ?></button>
					<?php 
					}
					?>
				</span>
					<input type="hidden" value="0" id="selectid"/>
				
				
				</div>
				<div id="page_loading"></div>
				<div id="head_measurement_details" style="color: green;padding: 15px;margin-top: 10px;border:2px solid green;font-weight:bold;text-align:center;">
					<?php 
					$ssl=0;$m=0;
					if(mysqli_num_rows($making_product)>0){
						while($mrow=mysqli_fetch_array($making_product)){
							$ssl=++$m;
							$order_record_id=$mrow['id'];
							$item_id=$mrow['item_id'];
							$item_qty=$mrow['item_qty'];
							$master_cutting_qty=$mrow['master_cutting_qty'];
							$design_cost=$mrow['design_cost'];
							$amount_cost=$mrow['amount_cost'];
							$item_name=$mrow['item_name'];
							$item_rate=$mrow['cus_price'];
							$group_name=$mrow['group_name'];
							@$img_loc=$mrow['img_loc'];
							?>
								<div class="row" id="making_row<?php echo $ssl; ?>">
									<div class="col-xs-12 col-sm-1">
										<label for="comment">Qty:</label>
										<input class="form-control" onkeyup="itemAmountChangeEdit('<?php echo $ssl; ?>');" style="background: #ffc107;font-weight:bold;text-align: center;" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="" type="text" value="<?php echo $item_qty; ?>" id="item_qtye<?php echo $ssl; ?>"/>
										<input type="hidden" value="<?php echo $order_record_id; ?>" id="order_record_id<?php echo $ssl; ?>"/>
									</div>
									<div class="col-xs-12 col-sm-1">
										<label for="comment">Rate:</label>
										<input class="form-control" onkeyup="itemAmountChangeEdit('<?php echo $ssl; ?>');" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;" type="text" value="<?php echo $item_rate; ?>" id="item_ratee<?php echo $ssl; ?>"/>
									</div>
									
									
									<div class="col-xs-12 col-sm-1">
										<label for="comment">Amount:</label>
										<input class="form-control" readonly autocomplete="off" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" style="text-align: right;color: blue;font-weight: bold;" type="text" value="<?php echo @$amount_cost; ?>" id="item_amounte<?php echo $ssl; ?>"/>
									</div>
									
									<div class="col-xs-12 col-sm-2">
										<label for="comment">Item:</label>
										
										<input class="form-control" readonly type="text" id="item_namee<?php echo $item_id; ?>" value="<?php echo $item_name; ?>"/>
											
										
									</div>
									<div class="col-xs-12 col-sm-3" style="overflow:hidden">
										<div style="width: 60%;float: left;">
											<label for="comment" class="txt_color">ফটো আপলোড</label>
											<input style="color: black;" type="file" id="file<?php echo $ssl; ?>" name="file" />
										</div>
										<div style="margin-top: 21px;">
											<button onclick="photoUpload('<?php echo $order_record_id; ?>','<?php echo $ssl; ?>');" name="btn" style="" value="sub" id="upload_btn<?php echo $ssl; ?>" class="btn btn-info">Upload</button>
										</div>
									</div>
									<div class="col-xs-12 col-sm-1" style="padding-top: 29px;">
										<span style='color:#180cac;cursor: pointer;margin-top: 15px;' data-toggle="modal" data-target="#myModal" onclick="showMeasurementImage('<?php echo $order_record_id; ?>','<?php echo $ssl; ?>')"><b>ফটো</b></span>
										<input type="hidden" id="hidden_img_link<?php echo $ssl; ?>" value="<?php echo @$img_loc; ?>" />
									</div>
									<?php 
									if($master_cutting_qty==0){
									?>
									<div class="col-xs-12 col-sm-1" style="margin-top: 23px;">
										<button onclick="deleteMeasurement('<?php echo $order_record_id; ?>','<?php echo $ord_num; ?>','<?php echo $item_id; ?>','<?php echo $item_qty; ?>','<?php echo $ssl; ?>','<?php echo @$amount_cost; ?>');" name="btn" style="" value="sub" id="" class="btn btn-danger">Remove</button>
									</div>
									<div class="col-xs-12 col-sm-2" style="padding-top: 29px;">
										<span style="color: blue;font-size: 20px;" id="upload_sms<?php echo $ssl; ?>"></span>
									</div>
									<?php } ?>
									
								</div>
							<?php 
						}
					}
					?>
					<input type="hidden" value="<?php echo @$ssl; ?>" id="making_hidden_id"/>
				</div>
				<div id="measurement_details" style="">
				
				</div> 
				
			</div>
			<div id="getOrderDetails"> 
			</div>
			<!--------------------------------Item name list end-------------------------------------->
			
	  </div>
    </div>

  </div>
		<?php 
		}else{
			echo 2;
		}
	}
}


?>


 
 