<style>
.style1 {border-top: solid 1px;border-top-color: #CCCCCC;}
.style21 {border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.style5 {border-left: solid 1px;border-left-color: #CCCCCC;}
.style3{ border-right: solid 1px;border-right-color: #CCCCCC; }
.style4 {border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.text{ font-family: Verdana; font-size:13px;}
#tot_amt::-webkit-input-placeholder { color:#666; }
</style>
<select name="batch_no" id="batch_no"  tabindex="8"  onchange="get_batchno_detail(this.value)" style=" height:30px; width:100%;"  >
<option value="">Select</option><?php error_reporting(0);
/***************************** PREVIOUS NEXT CODING ****************************************/
 include("../../include/db.php");
 $particular=$_POST['particular'];
// echo $particular;	

 $sql_user = "SELECT *, SUM(qty) AS tot_req FROM ink_pur_batch_tot_value WHERE particulars = '$particular' AND batch_no != '' AND qty != total_meter GROUP BY batch_no ORDER BY batch_no DESC";
 $rs_user = mysql_query($sql_user);
 
 while ($rsdata_user = mysql_fetch_object($rs_user)) {
	 $batch_no = $rsdata_user->batch_no;
	 $tot_req = $rsdata_user->tot_req;  // Corrected: Added semicolon
 
	 // Query for ink_sublist
	 $ink_part = mysql_fetch_array(mysql_query("SELECT *, SUM(total_req) AS tot_req FROM ink_sublist WHERE prod_size = '$particular' AND batch_no = '$batch_no' GROUP BY batch_no"));
 
	 // Handle the case where ink_part might return NULL or no rows
	 $media_qty = isset($ink_part['tot_req']) ? $ink_part['tot_req'] : 0;
 
	 // Calculate remaining quantity
	 $tot_qty = $tot_req - $media_qty;
 
	 // Only show batch_no if tot_qty is greater than 0
	 if ($tot_qty > 0) {
		 ?>
		 <option value="<?php echo $batch_no; ?>">
			 <?php echo $batch_no . ' (' . $tot_qty . ')'; ?>
		 </option>
		 <?php
	 }
 }
 ?>
 