<!DOCTYPE html>
<?php
require_once('../Db/dbconfig.php');
@$name=$_GET['username'];
@$userid=$_GET['userid'];
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.4/css/jquery.dataTables.min.css">
<script src="https://kit.fontawesome.com/c17eae44a3.js" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.24/api/sum().js"></script>
<style type="text/css">
select.rou{
 border: 1px solid #ccc;
  -moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;

-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
font-size: 18px;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none;
}
#round{
 border: 1px solid #ccc;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
 border-radius: 10px;
	
 -moz-box-shadow: 2px 2px 3px #666;
 -webkit-box-shadow: 2px 2px 3px #666;
 box-shadow: 2px 2px 3px #666;
 font-size: 15px;
 padding: 4px 7px;
 outline: 0;
 -webkit-appearance: none;
}

@media only screen and (max-height: 700px) {
	.child{
	  width:1000px;
	  float:left;
	  font-size:15px;
	  font-family:arial;
	  padding:10px;
	  cursor: pointer;
	}
}
</style>
</head>
<body>
<div class="card">
	<div class="page-header">
      <h3 class="page-title">
        <span class="page-title-icon bg-gradient-primary text-white mr-2">
        <i class="fas fa-cubes fa-xs" style="color: black"></i>
        </span><b>Packaging</b></h3>
        <input type="hidden" id="username" value="<?php echo @$name;?>">
    </div>
    <div class=" card-header d-flex flex-row-reverse">
		<a href="../view/multiple_package_send.php?userid=<?php echo @$userid; ?>&multipleraw=0"><button type="button" class="btn btn-primary sendbtn"><i class="ace-icon fa fa-share bigger-130"></i></button></a>
        <label class="p-2" style="width:200px;" for="dat"><b>Multiple Product Send :</b></label>
	</div>
	<div class="card-body child" style="overflow: auto;">
		<table id="datatableid1" class="table table-striped table-bordered table-hover">
		<thead class="thead-dark">
			<tr style="background-color:#f54281">
				<th class="center">
					
				</th>
				<th>Sr. No</th>
				<th>Lot Number</th>
				<th>Raw Material</th>
				<th>Sent From</th>
				<th>Final Product</th>
				<th>Quantity</th>	
				<th>Type</th>
				<th>Sent DateTime</th>
				<th>Water Weight</th>
				<th style="display: none;"></th>
				<th style="display: none;"></th>
				<th style="display: none;"></th>
				<!-- <th style="width: 13%;">Final Product Details</th> -->
				<th>Send To</th>
				<th>Delete</th>
				<th>Edit</th>
			</tr>
		</thead>
		<tbody>
		<?php 
		$sql2 = "SELECT '1' AS is_single, ad.id as ids,frmd.depart AS frmdpt,p.item AS finalProdname,p.id AS finalprodID, sendqt.q_name,sendqt.id AS qttypeId, ad.lotnumber, ad.productItem_id, ad.send_to_quantity AS send_to_quantity,
				ad.created_at AS senddttime, ad.water_wt AS water_wt, ad.final_product
				FROM admin_dpts ad ,department frmd,final_product p ,quantity_type sendqt
				WHERE ad.send_from = frmd.id AND ad.final_product = p.id AND ad.send_to_qtny_type = sendqt.id AND ad.send_to = 2 AND ad.send_to_quantity > 0 group by ad.lotnumber 
				UNION
				SELECT '0' AS is_single, ad.id as ids,frmd.depart AS frmdpt,p.item AS finalProdname,p.id AS finalprodID, sendqt.q_name,sendqt.id AS qttypeId, ad.lotnumber, GROUP_CONCAT(distinct(admrc.productItem_id) SEPARATOR ',') as productItem_id, ad.send_to_quantity AS send_to_quantity,
				ad.created_at AS senddttime, admrc.water_wt AS water_wt, ad.final_product
				FROM admin_dpts_mul_raw ad ,department frmd,final_product p ,quantity_type sendqt,admin_dpts_mul_raw_child admrc 
				WHERE ad.send_from = frmd.id AND ad.final_product = p.id AND ad.send_to_qtny_type = sendqt.id and ad.lotnumber = admrc.lotnumber AND ad.send_to = 2 AND ad.send_to_quantity > 0 group by p.id,ad.lotnumber ";
		   $result2 = $con->query($sql2);
		   if ($result2->num_rows > 0){
		   while($row2 = $result2->fetch_assoc()){
			   
		   ?>
		<tr style="background-color:#AFF3CA">
			<td class="center">
				
				<p style="display: none"><?php echo $row2['ids']?></p>
			</td>
			<td>
				<p><?php 
					if($row2['is_single'] == '1'){
						echo $row2['ids']."-S";
					}else{
						echo $row2['ids']."-M";
					}
					?></p>
			</td>
			<td>
				<p><?php echo $row2['lotnumber']?></p>
			</td>
			<td>
				<p><?php 
						$sql3 ="select GROUP_CONCAT(p.description SEPARATOR ',') as raw_material from productitem p where p.id in (".$row2['productItem_id'].")";
						$result3 = $con->query($sql3);
						if ($result3->num_rows > 0){
							while($row = $result3->fetch_assoc()){
								echo $row['raw_material'];
							}
						}
					?></p>
			</td>
			<td>
				<p>
					<?php 
						echo $row2['frmdpt']
					?>
				</p>
			</td>
			<td>
				<p><?php echo $row2['finalProdname']?></p>
			</td>
			<td>
				<p><?php 
                if($row2['qttypeId'] == '1' or $row2['qttypeId'] == '3'){
					if($row2['send_to_quantity'] != 0){
						echo ($row2['send_to_quantity']/1000);
					}else{
						echo $row2['send_to_quantity'];
					}
				}else{
					echo $row2['send_to_quantity'];
				}
				?>
				</p>
			</td>
			<td>
				<p><?php echo $row2['q_name']?></p>
			</td>
			<td>
				<p><?php 
					$date = new DateTime($row2['senddttime'], new DateTimeZone('MST'));
					$date->setTimezone(new DateTimeZone('Asia/Kolkata'));
					echo $date->format('Y-m-d H:i:s');
					?></p>
			</td>
			<td>
				<p>
				<?php 
					if($row2['water_wt'] != 0){
						echo ($row2['water_wt']/1000);
					}else{
						echo $row2['water_wt'];
					}
				
				?>
				</p>
			</td>
			<td style="display: none;"><?php echo $row2['finalprodID']?></td>
			<td style="display: none;"><?php echo $row2['qttypeId']?></td>
			<td style="display: none;"><?php echo $row2['is_single']?></td>
			<!-- <td>
				<button type="button" class="btn btn-primary viewbtn"><i class="ace-icon fa fa-search-plus bigger-130"></i></button>
			</td> -->
			<td>
				<button type="button" class="btn btn-primary sendbtn"><i class="ace-icon fa fa-plus bigger-130"></i></button>
			</td>
			<td>
				<button type="button" class="btn btn-primary deletebtn"><i class="ace-icon fa fa-trash-o"></i></button>
			</td>
			<td>
				<button type="button" name="edit" class="btn btn-primary editbtn" title="Edit"><i class="ace-icon fa fa-edit"></i></button>
			</td>
		</tr>
		<?php
				}
			}
			
		?>
		
		</tbody>
	</table>
		
	</div>
</div>

<!--Send Modal-->
<div id="single_send" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true"> 
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
	  <h4 class="modal-title">Send</h4>
        <button type="button" class="close" data-dismiss="modal" onclick="clearForm('adminForm')">&times;</button>
        
      </div>
      <div class="modal-body">
       
		<form id="adminForm">
		<input type="hidden" class="form-control" id="adminId" name="adminId">
		<input type="hidden" id="issendfromsingle" readonly>
		<div class="form-group">
			<?php 
	       $productnmlbl='Final Product Name';
	       
	    ?>
		    <label for="item"><?php echo $productnmlbl;?> : </label>
		    <input type="text" class="form-control" id="item" name="item" readonly>
		</div>	
		
		<div class="form-group" style="width: 220px">
		    <label style="width:150px;" for="quan">Total Quantity : </label>
			<input style="width:100px;" type="text" id="quan" name="quan" class="rounded" disabled>
			<input type="text" class="rounded" style="width:100px;"  id="qty_typ" name="qty_typ" disabled>
			<input type="hidden" class="rounded" id="qty_typId" name="qty_typId">
		</div>	
		
		<div class="form-group">
		    <div class="form-group" id="qty21" >
			<label style="width:150px;" for="qty">Input Quantity :</label>
		    <input type="text" style="width:120px;" maxlength="6" class="rounded" id="iko" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Kilo</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="igr" pattern="^(0|[1-9][0-9]*)$" value ="0"><label>gram</label>
			
		</div>
		<div class="form-group" id="qty22" style="display:none">
			<label style="width:150px;" for="qty">Input Quantity :</label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="ipiec" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Pieces</label>
		</div>
		<div class="form-group" id="qty23" style="display:none">
			<label style="width:150px;" for="qty">Input Quantity :</label>
			<input type="text" style="width:120px;" maxlength="6" class="rounded" id="ilitr" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Litre</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="imltr" pattern="^(0|[1-9][0-9]*)$" value ="0">ml
		</div>
		<div class="form-group" id="qty24" style="display:none">
			<label style="width:150px;" for="qty">Input Quantity :</label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="imtr" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Meter</label>
		</div>
		<div class="form-group" id="qty25" style="display:none">
			<label style="width:150px;" for="qty">Input Quantity :</label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="ift" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Feet</label>
		</div>
			<input type="hidden" id="initialqty" name="initialqty" class="rounded">
		</div>	
		<div class="dropdown-divider"></div>
		<div class="form-group">
	      <label style="width:150px;" for="no">Send To Department:</label>
	      <select style="width:170px;" id="dpt" name="dpt" onchange="departmentCheck()" class="rou" disabled>
	        <?php 
	        
	        $sql1="select * from department where id = 3";
	       
					$res=mysqli_query($con,$sql1);
				while($row1 = mysqli_fetch_array($res))
				{
		        	
			?>
			<option value="<?php echo $row1['id']; ?>"><?php echo $row1['depart']; ?></option> 
			<?php
	      }
	      $sendQtyLbl = 'Per Box Quantity';
			?>
	        </select>
			        
		</div>	
		
		<div class="form-group">
		    <input style="width:150px;" type="hidden" id="send_to_quantity" name="send_to_quantity">
		<div class="form-group" id="qty11" >
			<label style="width:150px;" for="qty"><b><?php echo $sendQtyLbl;?> :</b></label>
		    <input type="text" style="width:120px;" maxlength="6" class="rounded" id="ko" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Kilo</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="gr" pattern="^(0|[1-9][0-9]*)$" value ="0"><label>gram</label>
			
		</div>
		<div class="form-group" id="qty12" style="display:none">
			<label style="width:150px;" for="qty"><b><?php echo $sendQtyLbl;?> :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="piec" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Pieces</label>
		</div>
		<div class="form-group" id="qty13" style="display:none">
			<label style="width:150px;" for="qty"><b><?php echo $sendQtyLbl;?> :</b></label>
			<input type="text" style="width:120px;" maxlength="6" class="rounded" id="litr" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Litre</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="mltr" pattern="^(0|[1-9][0-9]*)$" value ="0">ml
		</div>
		<div class="form-group" id="qty14" style="display:none">
			<label style="width:150px;" for="qty"><b><?php echo $sendQtyLbl;?> :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="mtr" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Meter</label>
		</div>
		<div class="form-group" id="qty15" style="display:none">
			<label style="width:150px;" for="qty"><b><?php echo $sendQtyLbl;?> :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="ft" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Feet</label>
		</div>
		</div>
		
		 <div class="form-group">
			 <label style="width:150px;" for="no"><b>Waste Type :</b></label>
       <select style="width:150px;" id="wtype" name="wtype" class="rou" disabled>
        <?php 
         	$sql1="select * from waster_type where id = 4";
	       				
			    $res=mysqli_query($con,$sql1);
				while($row1 = mysqli_fetch_array($res))
				{
				?>
				<option value="<?php echo $row1['id']; ?>"><?php echo $row1['name']; ?></option> 
			    <?php
				}
				?>
			</select>	
		  </div>

		   <div class="form-group">
		   	<input type="hidden" id="waste_qty" name="waste_qty" class="rounded">
		    <div class="form-group" id="qty16" >
			<label style="width:150px;" for="waste_qty"><b>Waste Quantity :</b></label>
            <input type="text" style="width:120px;" maxlength="6" class="rounded" id="wko" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Kilo</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="wgr" pattern="^(0|[1-9][0-9]*)$" value ="0"><label>gram</label>
			
			</div>
			<div class="form-group" id="qty17" style="display:none">
			<label style="width:150px;" for="waste_qty"><b>Waste Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="wpiec" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Pieces</label>
			</div>
			<div class="form-group" id="qty18" style="display:none">
			<label style="width:150px;" for="waste_qty"><b>Waste Quantity :</b></label>
			<input type="text" style="width:120px;" maxlength="6" class="rounded" id="wlitr" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Litre</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="wmltr" pattern="^(0|[1-9][0-9]*)$" value ="0">ml
			</div>
			 <div class="form-group" id="qty19" style="display:none">
			<label style="width:150px;" for="waste_qty"><b>Waste Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="wmtr" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Meter</label>
			</div>
			<div class="form-group" id="qty20" style="display:none">
			<label style="width:150px;" for="waste_qty"><b>Waste Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="wft" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Feet</label>
			</div>
		  </div>

      <div class="form-group" id="packing_type_div">
            <label id="packaging_label" style="width:150px;" for="packaging_qt"><b>No. of Boxes</b></label>
            <input type="text" style="width:100px;" maxlength="6" class="rounded" id="packaging_qt" name="packaging_qt" pattern="^(0|[1-9][0-9]*)$" value ="0">
       </div>
       
      <div class="form-group">
	      <label style="width:150px;"><b>Send Rejection To Department:</b></label>
	      <select style="width:170px;" id="wastedpt" name="wastedpt" class="rou" required>
	      	 <option value="0" disabled selected>Please select....</option>
	        <?php 
	        	$sql1="select * from department where id not in (2,3,5)";
					
						$res=mysqli_query($con,$sql1);
						while($row1 = mysqli_fetch_array($res))
						{
				        	
					?>
					<option value="<?php echo $row1['id']; ?>"><?php echo $row1['depart']; ?></option> 
					<?php
			        	
						}
					?>
	        </select>
		        
		</div>	
	
	  <button type="submit" name="adminSend" id="adminSend" class="p-1 mb-1 bg-primary text-white rounded">Submit</button>
	  <button type="button" class="p-1 mb-2 bg-danger text-white rounded" data-dismiss="modal" onclick="clearForm('adminForm')">Close</button>
	</form> 

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

  </div>
</div>

<!--Edit Modal-->
<div id="editModal" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true"> 
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
	  <h4 class="modal-title">Edit Product</h4>
        <button type="button" class="close" data-dismiss="modal" onclick="clearForm('editForm')">&times;</button>
        
      </div>
      <div class="modal-body">
       
	<form id="editForm">
	<input type="hidden" class="form-control" id="editadminId" name="editadminId">
	<input type="hidden" id="editissendfromsingle" readonly>
		<div class="form-group" >
            <label  style="width:150px;"for="no"><b>Final Product :</b></label>
            <select name="editfin_product" id="editfin_product" class="rou" disabled>
			<?php 
			 $sql1="select * from final_product";
			   $res=mysqli_query($con,$sql1);
				while($row1 = mysqli_fetch_array($res))
				{
				?>

				<option value="<?php echo $row1['id']; ?>"><?php echo $row1['item']; ?></option> 

				<?php
				}
			?>
			</select>
			
		</div>	
		<div class="form-group">
		<label style="width:150px;" for="qty"><b>Old Send Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="oldqty" disabled><label id="oldqtytype"></label>
		</div>
	  <div class="form-group">
		    <label style="width:150px;"><b>Quantity Type</b></label>
		    <select style="width:150px;" class="rou" id="editsendqty_typ" name="editsendqty_typ" onchange="changefuncEdit()" required>
			  <?php 
				$sql1="select * from quantity_type";
			    $res=mysqli_query($con,$sql1);
				while($row1 = mysqli_fetch_array($res))
				{
				?>
				<option value="<?php echo $row1['id']; ?>"><?php echo $row1['q_name']; ?></option> 
			    <?php
				}
				?>
		    </select>
		</div>
		<div class="form-group">
		    <input style="width:150px;" type="hidden" id="editsend_to_quantity" name="editsend_to_quantity">
		<div class="form-group" id="qty31" >
			<label style="width:150px;" for="qty"><b>Send Quantity :</b></label>
		    <input type="text" style="width:120px;" maxlength="6" class="rounded" id="eko" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Kilo</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="egr" pattern="^(0|[1-9][0-9]*)$" value ="0"><label>gram</label>
			
		</div>
		<div class="form-group" id="qty32" style="display:none">
			<label style="width:150px;" for="qty"><b>Send Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="epiec" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Pieces</label>
		</div>
		<div class="form-group" id="qty33" style="display:none">
			<label style="width:150px;" for="qty"><b>Send Quantity :</b></label>
			<input type="text" style="width:120px;" maxlength="6" class="rounded" id="elitr" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Litre</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="emltr" pattern="^(0|[1-9][0-9]*)$" value ="0">ml
		</div>
		<div class="form-group" id="qty34" style="display:none">
			<label style="width:150px;" for="qty"><b>Send Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="emtr" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Meter</label>
		</div>
		<div class="form-group" id="qty35" style="display:none">
			<label style="width:150px;" for="qty"><b>Send Quantity :</b></label>
			<input type="text" style="width:150px;" maxlength="6" class="rounded" id="eft" pattern="^[0-9]+(\.[0-9]{1,4})?$" title="Enter a Valid Input" value="0"><label>Feet</label>
		</div>
		</div>

    <div class="form-group" id="editwateractivityDiv" style="display: none;">
    <div class="form-group">
		<label style="width:150px;" for="qty"><b>Old Extra Weight Added by Water :</b></label>
		<input type="text" style="width:150px;" maxlength="6" class="rounded" id="oldextrawaterwt" disabled><label>Kilogram</label>
		</div>
      	<input type="hidden" class="rounded" style="width:100px;"  id="editextrawaterwt" name="editextrawaterwt" readonly>
        <label style="width:150px;" for="extrawaterwt"><b>Extra Weight Added by Water : </b></label>
        <input type="text" style="width:120px;" maxlength="6" class="rounded" id="editextrawaterwtko" pattern="^(0|[1-9][0-9]*)$" title="Enter a Valid Input" value="0"><label>Kilo</label>
			<input type="text" style="width:100px;" maxlength="3" class="rounded" id="editextrawaterwtgr" pattern="^(0|[1-9][0-9]*)$" value ="0"><label>gram</label>
      	</div>

      <button type="submit" id = "updateProds" name="updateProds" class="btn btn-gradient-primary mr-2">Update</button>
		  <button type="button" class="btn btn-default" data-dismiss="modal" onclick="clearForm('editForm')">Close</button>
	</form> 

      </div>
     
    </div>

  </div>
</div>

<!-- Add Table Modal -->
<div id="tableModal" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true" style="overflow: auto;text-align: center;"> 
  <div class="modal-dialog" style="text-align: left; max-width: 100%;width: auto !important; display: inline-block;">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
         <h4 class="modal-title">Final Product Details</h4>
		 <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body">
       	<table id="datatableid" class="table table-striped table-bordered table-hover">
			<thead class="thead-dark">
				<tr style="background-color:#048065">
					<th>Sr. No</th>
					<th>Sent From</th>
					<th>Final Product</th>
					<th>Quantity</th>	
					<th>Quantity Type</th>
					<th>Sent DateTime</th>
					<th>Water Weight</th>
					<th style="display: none;"></th>
					<th style="display: none;"></th>
					<th style="display: none;"></th>
					<?php
						if(@$name == 'superadmin'){
					?>
					<th>Delete</th>
					<th>Edit</th>
					<?php
						}
					?>
					
				</tr>
			</thead>
			<tbody>
			
			</tbody>
		</table>
	  </div>
      <div class="modal-footer">
       
      </div>
    </div>

  </div>
</div>

<!-- Add Table Modal -->
<div id="tableModalMl" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true" style="overflow: auto;text-align: center;"> 
  <div class="modal-dialog" style="text-align: left; max-width: 100%;width: auto !important; display: inline-block;">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
         <h4 class="modal-title">Final Product Details</h4>
		 <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body">
       	<table id="datatableid3" class="table table-striped table-bordered table-hover">
			<thead class="thead-dark">
				<tr style="background-color:#048065">
					<th>Sr. No</th>
					<th>Sent From</th>
					<th>Final Product</th>
					<th>Quantity</th>	
					<th>Quantity Type</th>
					<th>Sent DateTime</th>
					<th>Water Weight</th>
					<th style="display: none;"></th>
					<th style="display: none;"></th>
					<th style="display: none;"></th>
					<?php
						if(@$name == 'superadmin'){
					?>
					<th>Delete</th>
					<th>Edit</th>
					<?php
						}
					?> 
					
				</tr>
			</thead>
			<tbody>
			
			</tbody>
		</table>
	  </div>
      <div class="modal-footer">
       
      </div>
    </div>

  </div>
</div>

<!-- Add Final Product Modal -->
<div id="ad_product" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true"> 
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Add Final Product</h4>
		<button type="button" onclick="clearForm('user_form')" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      <div class="modal-body">
       
		<form method="POST" id="user_form">
		
		<div class="form-group">
            <label>Product Name</label>
            <input type="text" class="form-control" id="pname" name="pname" required>
        </div>
        <b id="mesg"></b>
		<input type="button" name="add_product" id="add_product" style="background-color:#FF6666" class="btn btn-default" value="Submit"/>
		<button type="button" style="background:radial-gradient(#FFF176, #ff3300)" class="btn btn-default" data-dismiss="modal" onclick="clearForm('user_form')">Close</button>
		</form> 

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

  </div>
</div>

</body>
<script type="text/javascript">
$(document).ready(function(){
	
	var userid = '<?php echo @$userid; ?>';
	var t = $('#datatableid1').DataTable( {
	rowReorder: true,
	"order": [[ 8, "desc" ]],
	columnDefs: [
	    { orderable: true, targets: '_all' }
	    
	]
	} );

	var t1 = $('#datatableid').DataTable( {
				rowReorder: true,
				"order": [[ 7, "desc" ]],
				columnDefs: [
				    { orderable: true, targets: '_all' }
				    
				]
	} );

	var t3 = $('#datatableid3').DataTable( {
				rowReorder: true,
				"order": [[ 7, "desc" ]],
				columnDefs: [
				    { orderable: true, targets: '_all' }
				    
				]
	} );

	$('.finalproductBtn').on('click',function() {
		$('#ad_product').modal('show');
	});

	$('#add_product').click(function(){
		var data=$('#user_form').serialize()+'&type=add_final_product';
		var productnm = $('#pname').val();
		$.ajax({
			url:'../controller/purchase_controller.php',
			type:'POST',
			data:data,
			success:function(response){
				console.log('Result',response);
				if(response.status == true){
					alert(response.msg);
					
					$('#editfin_product').append($('<option>', {
					    value: response.rowId,
					    text: productnm
					}));

										
					$('#ad_product').modal('hide');
					clearForm('user_form');
					
					$('#single_send').modal('show');
					
				}else{
					alert(response.msg);
				}
			}
		});
	});

	$('#datatableid1').on('click','.viewbtn',function() {
		
		$tr = $(this).closest('tr');

		var data = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		var adminIds = data[0].trim();

		var isSingle = data[10].trim();

		var url = '../controller/admin_controller.php';

		var tableEle = t1;

		if(isSingle == '0'){
			url = '../controller/multiple_raw_material_controller.php';
			tableEle = t3;
		}
		
		$.ajax( {
			url:url,
			type: 'POST',
			data: 'id='+adminIds+'&type=viewPackage',
           
			success: function(data){
				
				if(data.status == true){
					var rows = tableEle
					.rows()
					.remove()
					.draw();
					
					$.each(data.data,function(i,item){

						var finalqty = 0;
						if(item.qttypeId == '1' || item.qttypeId == '3'){
							finalqty = item.send_to_quantity/1000;
						}else{
							finalqty = item.send_to_quantity;
						}

						if(item.water_wt != '0'){
							finalwaterwt = item.water_wt/1000;
						}else{
								finalwaterwt = item.water_wt;
						}
						
						var rowNode = tableEle
						.row.add( [item.id, item.frmdpt,item.finalProdname,finalqty,item.q_name,item.senddttime,finalwaterwt,item.finalprodID,item.qttypeId,isSingle,'<button type="button" class="btn btn-primary deletebtn" title="Delete"><i class="ace-icon fa fa-trash-o"></i></button>','<button type="button" name="edit" class="btn btn-primary editbtn" title="Edit"><i class="ace-icon fa fa-edit"></i></button>'])
						.draw()
						.node();
					
					});

					tableEle.columns([7,8,9]).visible(false);

					if(isSingle == '0'){
						$('#tableModalMl').modal('show');
					}else{
						$('#tableModal').modal('show');
					}

				}
			
			},
			error: function(r) {
			console.log(r);
			var rows = tableEle
					.rows()
					.remove()
					.draw();
			}
		});	
		
	});

	$('#datatableid1').on('click','.sendbtn',function() {
		
		$('#single_send').modal('show');

		$tr = $(this).closest('tr');

		var data = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		$('#adminId').val(data[0].trim());
		$('#quan').val(data[6].trim());
		$('#qty_typ').val(data[7].trim());
		$('#item').val(data[5].trim());
		var isSingle = data[12].trim();
		console.log('isSingle',isSingle);
		$('#issendfromsingle').val(isSingle);
		
		$('#qty_typId').val(data[11].trim());
		changefunc($('#qty_typId').val());
		changeWasteQtyType($('#qty_typId').val());
		changeInitialQtyType($('#qty_typId').val());
	});

	$('#datatableid').on('click','.editbtn',function() {
		$('#tableModal').modal('hide');
		$('#editModal').modal('show');

		$tr = $(this).closest('tr');

		var data = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		$('#editadminId').val(data[0].trim());
		$('#oldqty').val(data[3].trim());
		$('#oldqtytype').html(data[4].trim());
		$('#oldextrawaterwt').val(data[6].trim());

		var rowIndex = $(this).closest("tr").index();

		var editsendqty_typ = t1.column(8).data()[rowIndex];
		var editfinalProductId = t1.column(7).data()[rowIndex];
		
		$('#editsendqty_typ').val(editsendqty_typ);
		$('#editfin_product').val(editfinalProductId);
		var isSingle = t1.column(9).data()[rowIndex];
		$('#editissendfromsingle').val(isSingle);
						
		if($('#oldextrawaterwt').val() != '0'){
			document.getElementById("editwateractivityDiv").style.display = "block";
		}else{
			document.getElementById("editwateractivityDiv").style.display = "none";
		}

		changefuncEdit();
		
	});

	$('#datatableid').on('click','.deletebtn',function() {
		$tr = $(this).closest('tr');

		var datatb = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		var adminId = datatb[0].trim();

		var lotnumber = datatb[2].trim();

		var rowIndex = $(this).closest("tr").index();
		var isSingle = t1.column(12).data()[rowIndex];
		if (confirm("Are You Sure?")) {
		$.ajax( {
	        url: '../controller/admin_controller.php',
	        method: 'POST',
	        data:'type=validateProductIsSentToStock&adminId='+adminId+'&is_single='+isSingle,
	        
	        success: function(data1){
	          console.log('Msg',data1);
	          if(data1.status == true){
		        alert('This Product has been processed furthur, first please delete from processed departments to delete this!.'); 
		      }else{

		      	$.ajax( {
			        url: '../controller/admin_controller.php',
			        method: 'POST',
			        data:'type=adminDelete&adminId='+adminId+'&userId='+userid,
			        
			        success: function(data2){
			          console.log('Msg',data2);
			          if(data2.status == true){
			          	alert('Product deleted and Quantity reverted to '+data2.revertDpt); 
			          	window.location.reload();
			      	  }else{
			      	  	alert('Failed To Delete Product'); 
			      	  }
			        },
			        error: function(r) {
			          alert('Unable To Delete Product'); 
			        }
			      } );
	      	  	
	      	  }
	        },
	        error: function(r) {
	          alert('Unable To Edit Product'); 
	        }
	      } );
		}
	});

	$('#datatableid1').on('click','.editbtn',function() {
		$tr = $(this).closest('tr');

		var data = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		var isSingle = data[12].trim();
		/*
		if(isSingle == 0){
			var lotnumber = data[2].trim();
			window.open("../view/multiple_raw_material_send_edit.php?userid=<?php echo @$userid; ?>&dptId=<?php echo @$dptId; ?>&lotnumber="+lotnumber,"_self");
		}else{
			*/
			$('#editModal').modal('show');

			$('#editadminId').val(data[0].trim());
			$('#oldqty').val(data[6].trim());
			$('#oldqtytype').html(data[7].trim());
			$('#oldextrawaterwt').val(data[9].trim());

			var editsendqty_typ = data[11].trim();
			var editfinalProductId = data[10].trim();

			$('#editsendqty_typ').val(editsendqty_typ);
			$('#editfin_product').val(editfinalProductId);

			$('#editissendfromsingle').val(isSingle);
							
			if($('#oldextrawaterwt').val() != '0'){
				document.getElementById("editwateractivityDiv").style.display = "block";
			}else{
				document.getElementById("editwateractivityDiv").style.display = "none";
			}

			changefuncEdit();
		
		
	});

	$('#datatableid1').on('click','.deletebtn',function() {
		$tr = $(this).closest('tr');

		var datatb = $tr.children('td').map(function(){
			return $(this).text();
		}).get();

		//var rowIndex = $(this).closest("tr").index();
		var isSingle =datatb[12].trim();
		var adminId = datatb[0].trim();

		var lotnumber = datatb[2].trim();

		if (confirm("All products with this lot number will be deleted. Are You Sure you want to continue?")) {
		$.ajax( {
	        url: '../controller/admin_controller.php',
	        method: 'POST',
	        data:'type=validateProductIsSentToStock&adminId='+adminId+'&is_single='+isSingle,
	        
	        success: function(data1){
	          console.log('Msg',data1);
	          if(data1.status == true){
		        alert('This Product has been processed furthur, first please delete from processed departments to delete this!.'); 
		      }else{
				var url ='';
				if(isSingle == 0){
					url = 'multiple_raw_material_controller.php';
				}else{
					url = 'admin_controller.php';
				}

		      	$.ajax( {
			        url: '../controller/'+url,
			        method: 'POST',
			        data:'type=deletePackageByLotNumber&lotnumber='+lotnumber+'&userId='+userid,
			        
			        success: function(data2){
			          console.log('Msg',data2);
			          if(data2.status == true){
			          	alert('Product deleted and Quantity reverted to respective departments'); 
			          	window.location.reload();
			      	  }else{
			      	  	alert('Failed To Delete Product'); 
			      	  }
			        },
			        error: function(r) {
			          alert('Unable To Delete Product'); 
			        }
			      } );
	      	  	
	      	  }
	        },
	        error: function(r) {
	          alert('Unable To Edit Product'); 
	        }
	      } );
		}
	});

	$("#adminForm").submit(function(e) {
    document.getElementById("adminSend").disabled=true;
    //prevent Default functionality
    e.preventDefault();
    //do your own request an handle the results
   	
   	var selectedValue = $('#qty_typId').val();
   	console.log('Slected data',selectedValue);
   if(selectedValue == "1")
	{
		var kilogrm = (parseInt($('#ko').val()) * 1000)+parseInt($('#gr').val());
		$('#send_to_quantity').val(kilogrm);
	}else if(selectedValue == "3")
	{
		var milliltr = (parseInt($('#litr').val()) * 1000)+parseInt($('#mltr').val());
		$('#send_to_quantity').val(milliltr);
	}else if(selectedValue == "2")
	{
		$('#send_to_quantity').val($('#piec').val());
	}else if(selectedValue == "4")
	{
		$('#send_to_quantity').val($('#mtr').val());
		
	}else if(selectedValue == "5")
	{
		$('#send_to_quantity').val($('#ft').val());
	}

	var selectedValue2 = selectedValue;
   	//console.log('Slected data',selectedValue);
   	if(selectedValue2 == "1")
	{
		var kilogrm = (parseInt($('#wko').val()) * 1000)+parseInt($('#wgr').val());
		$('#waste_qty').val(kilogrm);
	}else if(selectedValue2 == "3")
	{	var milliltr = (parseInt($('#wlitr').val()) * 1000)+parseInt($('#wmltr').val());
		$('#waste_qty').val(milliltr);
	}else if(selectedValue2 == "2")
	{
		$('#waste_qty').val($('#wpiec').val());
	}else if(selectedValue2 == "4")
	{
		$('#waste_qty').val($('#wmtr').val());
		
	}else if(selectedValue2 == "5")
	{
		$('#waste_qty').val($('#wft').val());
	}

	var totalqt = parseFloat($('#quan').val());
	var selectedValue3 = selectedValue;
	if(selectedValue3 == "1")
	{
		var kilogrm = (parseInt($('#iko').val()) * 1000)+parseInt($('#igr').val());
		$('#initialqty').val(kilogrm);
		totalqt = totalqt * 1000;
	}else if(selectedValue3 == "3")
	{	var milliltr = (parseInt($('#ilitr').val()) * 1000)+parseInt($('#imltr').val());
		$('#initialqty').val(milliltr);
		totalqt = totalqt * 1000;
	}else if(selectedValue3 == "2")
	{
		$('#initialqty').val($('#ipiec').val());
	}else if(selectedValue3 == "4")
	{
		$('#initialqty').val($('#imtr').val());
		
	}else if(selectedValue3 == "5")
	{
		$('#initialqty').val($('#ift').val());
	}
	
	var formData = new FormData(this);

	formData.append('type','adminPackageSendToStock');
	formData.append('userId',userid);

	var sendqty = parseFloat($('#initialqty').val());
	console.log('#wastedpt',$('#wastedpt').val());

	if(isNaN($('#send_to_quantity').val()) || $('#send_to_quantity').val() == ''){
		alert('Invalid or Empty Value in Sending Quantity');
    document.getElementById("adminSend").disabled=false;
	}else if(isNaN($('#initialqty').val()) || $('#initialqty').val() == ''){
		alert('Invalid or Empty Value in Input Quantity');
    document.getElementById("adminSend").disabled=false;
	}else if(isNaN($('#waste_qty').val()) || $('#waste_qty').val() == ''){
		alert('Invalid or Empty Value in Waste Quantity');
    document.getElementById("adminSend").disabled=false;
	}else if(sendqty > totalqt){
    	alert('Input Quantity cannot exceed Total Quantity');
    	document.getElementById("adminSend").disabled=false;
   }else if(sendqty == 0){
		alert('Input Quantity cannot be 0');
		document.getElementById("adminSend").disabled=false;
   }else if(parseFloat($('#send_to_quantity').val()) == 0){
		alert('Send Quantity cannot be 0');
		document.getElementById("adminSend").disabled=false;
   }else if(parseFloat($('#packaging_qt').val()) == 0){
		alert('Boxes cannot be 0');
		document.getElementById("adminSend").disabled=false;
   }else if(parseFloat($('#waste_qty').val()) != 0 && $('#wastedpt').val() == null){
		alert('Please Select a department to send rejected quantity');
		document.getElementById("adminSend").disabled=false;
   }else if((parseFloat($('#send_to_quantity').val()) * parseFloat($('#packaging_qt').val())) > sendqty){
		alert('Total Quantity in boxes cannot exceed input quantity');
		document.getElementById("adminSend").disabled=false;
   }else if(((parseFloat($('#send_to_quantity').val()) * parseFloat($('#packaging_qt').val()))+ parseFloat($('#waste_qty').val())) > sendqty){
		alert('Overall Quantity cannot exceed input quantity');
		document.getElementById("adminSend").disabled=false;
   }else{
   		var url = '';
   		if($('#issendfromsingle').val() == '1'){
   			url = '../controller/admin_controller.php';
   		}else{
   			url = '../controller/multiple_raw_material_controller.php';
   		}
	     $.ajax( {
        url: url,
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false,

        success: function(data){
          console.log('Msg',data);
          if(data.status == true){
          	if(parseFloat($('#waste_qty').val()) != 0){
          		alert('Product sent to Stock and rejected product(s) sent to '+$( "#wastedpt option:selected" ).text()); 
          	}else{
          		alert('Product sent to Stock'); 		
          	}
	        
	        window.location.reload();
      	  }else{
      	  	alert('Failed To Send Product'); 
      	  	document.getElementById("adminSend").disabled=false;
      	  }
        },
        error: function(r) {
          alert('Unable To Send Product'); 
          document.getElementById("adminSend").disabled=false;
        }
      } );
	}
	
});

	$("#editForm").submit(function(e) {
    document.getElementById("updateProds").disabled=true;
    //prevent Default functionality
    e.preventDefault();
    //do your own request an handle the results
   	
   	var selectedValue = $('#editsendqty_typ').val();
   	console.log('Slected data',selectedValue);
   if(selectedValue == "1")
	{
		var kilogrm = (parseInt($('#eko').val()) * 1000)+parseInt($('#egr').val());
		$('#editsend_to_quantity').val(kilogrm);
	}else if(selectedValue == "3")
	{
		var milliltr = (parseInt($('#elitr').val()) * 1000)+parseInt($('#emltr').val());
		$('#editsend_to_quantity').val(milliltr);
	}else if(selectedValue == "2")
	{
		$('#editsend_to_quantity').val($('#epiec').val());
	}else if(selectedValue == "4")
	{
		$('#editsend_to_quantity').val($('#emtr').val());
		
	}else if(selectedValue == "5")
	{
		$('#editsend_to_quantity').val($('#eft').val());
	}
	
	var formData = new FormData(this);
	if($('#oldextrawaterwt').val() != '0'){
		var kilogrm = (parseInt($('#editextrawaterwtko').val()) * 1000)+parseInt($('#editextrawaterwtgr').val());
		formData.set('editextrawaterwt',kilogrm);
	} 

	
	formData.append('userId',userid);

	var url = '';
	if($('#editissendfromsingle').val() == '1'){
		url = '../controller/admin_controller.php';
		formData.append('type','adminEdit');
	}else{
		url = '../controller/multiple_raw_material_controller.php';
		formData.append('type','packageEdit');
	}
		
	$.ajax( {
		url: '../controller/admin_controller.php',
		method: 'POST',
		data:'type=validateProductIsSentToStock&adminId='+$('#editadminId').val()+'&is_single='+$('#editissendfromsingle').val(),
		
		success: function(data1){
			console.log('Msg',data1);
			if(data1.status == true){
				alert('This Product has been processed furthur, first please delete from processed departments to Edit this!.'); 
				document.getElementById("updateProds").disabled=false;
			}else{

				$.ajax( {
					url: url,
					type: 'POST',
					data: formData,
					processData: false,
					contentType: false,

					success: function(data){
					console.log('Msg',data);
					if(data.status == true){
						alert('Product Updated!'); 
						window.location.reload();
					}else{
						alert(data.msg); 
						document.getElementById("updateProds").disabled=false;
					}
					},
					error: function(r) {
					alert('Unable To Update Product'); 
					document.getElementById("updateProds").disabled=false;
					}
				} );
			
			}
		},
		error: function(r) {
			alert('Unable To Edit Product'); 
		}
		} );
    
  });

});

function changefunc(selectedValue) {
	
	if(selectedValue == "1")
	{
		$('#qty11').show();
		$('#qty12').hide();
		$('#qty13').hide();
		$('#qty14').hide();
		$('#qty15').hide();
		
	}else if(selectedValue == "2")
	{
		$('#qty12').show();
		$('#qty11').hide();
		$('#qty13').hide();
		$('#qty14').hide();
		$('#qty15').hide();
		
	}else if(selectedValue == "4")
	{
		$('#qty12').hide();
		$('#qty11').hide();
		$('#qty13').hide();
		$('#qty14').show();
		$('#qty15').hide();
		
	}else if(selectedValue == "5")
	{
		$('#qty12').hide();
		$('#qty11').hide();
		$('#qty13').hide();
		$('#qty14').hide();
		$('#qty15').show();
		
	}else
	{
		$('#qty13').show();
		$('#qty11').hide();
		$('#qty12').hide();
		$('#qty14').hide();
		$('#qty15').hide();
		
	}
}

function changeWasteQtyType(selectedValue){
	
	if(selectedValue == "1")
	{
		$('#qty16').show();
		$('#qty17').hide();
		$('#qty18').hide();
		$('#qty19').hide();
		$('#qty20').hide();
		
	}else if(selectedValue == "2")
	{
		$('#qty17').show();
		$('#qty16').hide();
		$('#qty18').hide();
		$('#qty19').hide();
		$('#qty20').hide();
		
	}else if(selectedValue == "4")
	{
		$('#qty16').hide();
		$('#qty17').hide();
		$('#qty18').hide();
		$('#qty19').show();
		$('#qty20').hide();
		
	}else if(selectedValue == "5")
	{
		$('#qty16').hide();
		$('#qty17').hide();
		$('#qty18').hide();
		$('#qty20').show();
		$('#qty19').hide();
	}else
	{
		$('#qty16').hide();
		$('#qty17').hide();
		$('#qty19').hide();
		$('#qty18').show();
		$('#qty20').hide();
		
	}
}

function changeInitialQtyType(selectedValue) {
	
	if(selectedValue == "1")
	{
		$('#qty21').show();
		$('#qty22').hide();
		$('#qty23').hide();
		$('#qty24').hide();
		$('#qty25').hide();
		
	}else if(selectedValue == "2")
	{
		$('#qty22').show();
		$('#qty21').hide();
		$('#qty23').hide();
		$('#qty24').hide();
		$('#qty25').hide();
		
	}else if(selectedValue == "4")
	{
		$('#qty22').hide();
		$('#qty21').hide();
		$('#qty23').hide();
		$('#qty24').show();
		$('#qty25').hide();
		
	}else if(selectedValue == "5")
	{
		$('#qty22').hide();
		$('#qty21').hide();
		$('#qty23').hide();
		$('#qty24').hide();
		$('#qty25').show();
		
	}else
	{
		$('#qty23').show();
		$('#qty21').hide();
		$('#qty22').hide();
		$('#qty24').hide();
		$('#qty25').hide();
		
	}
}


function clearForm(formname){
	$("#"+formname).trigger("reset");
	
	if(formname == 'user_form'){
		$('#mesg').text('');
		$('#add_product').show();
	}
}

function changefuncEdit(){
	var selectedValue = $('#editsendqty_typ').val();
	
	if(selectedValue == "1")
	{
		$('#qty31').show();
		$('#qty32').hide();
		$('#qty33').hide();
		$('#qty34').hide();
		$('#qty35').hide();
		
	}else if(selectedValue == "2")
	{
		$('#qty32').show();
		$('#qty31').hide();
		$('#qty33').hide();
		$('#qty34').hide();
		$('#qty35').hide();
		
	}else if(selectedValue == "4")
	{
		$('#qty32').hide();
		$('#qty31').hide();
		$('#qty33').hide();
		$('#qty34').show();
		$('#qty35').hide();
		
	}else if(selectedValue == "5")
	{
		$('#qty32').hide();
		$('#qty31').hide();
		$('#qty33').hide();
		$('#qty34').hide();
		$('#qty35').show();
		
	}else
	{
		$('#qty33').show();
		$('#qty31').hide();
		$('#qty32').hide();
		$('#qty34').hide();
		$('#qty35').hide();
		
	}
}

</script>
</html>