<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; }
.types_class1 { 
    height: 25px; 
    width: 250px; 
    background-color: transparent;  
    border-style: solid;  
    border-width: 0px 0px 1px 0px;  
    border-color:#CCC; 
    outline:0;
	font-size:13px;
	font-family:Verdana;
	
  }
</style>

<?php 
 include("../../include/db.php");
 date_default_timezone_set('Asia/Kolkata');
$user_id = $_SESSION['login_user_id'];

$edit_ids=$_POST['edit_id'];
 $sql="select * from   return_sublist where sub_id='$edit_ids'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$id1=$rsdata['sub_id'];
				$jobcard_no1=$rsdata['jobcard_no'];
				$return_date=$rsdata['return_date'];
   				$particulars1=$rsdata['particulars'];
				$roll_width1=$rsdata['rollno_width'];
				$kg_height1=$rsdata['kg_meter_height'];
				$deliv_qty1=$rsdata['qty'];
				$deliv_qty2+=$rsdata['qty'];
				}
?>
<div style="height:210px; width:98%; padding-left:0px;  overflow-x:hidden; overflow-y:scroll; white-space:nowrap;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" >
  <tr  bgcolor="#F2F2F2">
    <td width="4%"  height="25" class="text style5 style1 style21"><strong>&nbsp;S.No&nbsp;</strong></td>
    <td width="12%"  class="text style5 style1 style21"> <strong>&nbsp;&nbsp;Date</strong></td>
    <td width="34%"  class="text style1 style5 style21"><strong>&nbsp;&nbsp;Particulars</strong><span style="color:#FF0000"> *</span></td>
    <td width="16%" align="right"  class="text style1 style5 style21"><strong>Width<span style="color:#FF0000"> *</span></strong>&nbsp;</td>
    <td width="16%" align="right"  class="text style1 style5 style21"><strong>Height<span style="color:#FF0000"> *</span>&nbsp;&nbsp;</strong>
    </td>
    <td width="12%" align="right"  class="text style1 style5 style21"><strong>Qty<span style="color:#FF0000"> *</span>&nbsp;&nbsp;</strong></td>
    <td width="6%"  align="center" class="text style1 style5 style21" ><strong>Action</strong></td>
    </tr>
   <?php
    $job_no=$_GET['job_no'];
    $job_no1=$_POST['job_no'];
     $sql="select * from  return_sublist where job_no='$job_no' or job_no='$job_no1'";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$id=$rsdata['sub_id'];
				$jobcard_no=$rsdata['job_no'];
				$return_date=$rsdata['return_date'];
   				$particulars=$rsdata['particulars'];
				$roll_width=$rsdata['rollno_width'];
				$kg_height=$rsdata['kg_meter_height'];
				$deliv_qty=$rsdata['qty'];
				$date_time=$rsdata['date_time'];
				$row=$row+1;
								  $row1=$row%2;
								  if($row1==0)
								  {
								  $class='style="background-color:#f6faff;border-bottom:solid 1px;border-color:#E2E2E2"';
								  }
								  else
								  {
								  $class='style="background-color:#f3f3ff;border-bottom:solid 1px;border-color:#E2E2E2"';
								  }

								  
  ?>
   <tr>
      <td  height="27"  align="center" class="text style4  style5"><?php echo $sno; ?></td>
      <td  height="27"  align="left" class="text style4  style5">&nbsp;<?php  echo date('d-m-Y H:i',strtotime($date_time));?></td>
      <td  align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;&nbsp;<?php echo $particulars;?></td>
      <td  align="right" class="text style5 style4"><?php echo $roll_width;?>&nbsp;&nbsp;</td>
      <td  align="right" class="text style5 style4"><?php echo $kg_height;?>&nbsp;&nbsp;</td>
      <td  align="right" class="text style5 style4"><?php echo $deliv_qty;?>&nbsp;&nbsp;</td>
      <?php if(($user_id=='1')||($user_id=='3'))
	 { 
	 ?> <td  align="center" class="text style5 style4"><img src="img/edit-icon.png" onClick="edit_sublist_return('<?php echo $id;?>',
      '<?php echo $jobcard_no; ?>','<?php echo $particulars; ?>')" width="18px" height="18px">&nbsp;&nbsp;&nbsp;<img src="img/cross-small.png"  title="Delete" onClick="delete_sublist_return('<?php echo $id;?>','<?php echo $jobcard_no; ?>')" width="20px" height="20px"></td><?php } ?>
   </tr>
    <?php 
	$inward_qty1+=$deliv_qty;
	} ?>
 <tr>
 <td height="32" align="center" class="text style4  style5"><?php echo $sno+1; ?></td>
<td class="text style4  style5"><input type="datetime-local" name="return_dates" id="return_dates" tabindex="2"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>  value="<?php if($edit_ids!='') { echo $return_date; } else{ echo date('Y-m-d').'T'.date('H:i');  }  ?>" style="height:31px; width:200px;"class="types_class1" onKeyUp="enterevent(event,'ret_particular','delivery_dates')" /></td>
   <td class="text style4  style5"><div id="ret_particulars_div">
   <select name="ret_particular" id="ret_particular" class="types_class1" tabindex="3" onchange="enterevent(event,'inward_qty','ret_particular')"  style="width:100%; height:32px; font-family:Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; font-size:14px">
  
    <option value="<?php if($edit_ids!='') { echo $particulars1; }?>"  ><?php if($edit_ids!='') { echo $particulars1; }?></option>
    </option>
    </select></div></td>
    <td class="text style4  style5"><div id="return_roll_width_div"><input type="text" readonly class="types_class1" name="roll_width" id="roll_width"   onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false"  style="width:100%; height:29px; text-align:right;" value="<?php if($edit_ids!=''){ echo $roll_width1; } else {  }?>" /></div>
  </td>
    <td class="text style4  style5"><div id="return_kg_height_div"><input type="text" readonly name="kg_height" id="kg_height"  class="types_class1"     onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false" style="width:100%; height:29px; text-align:right;" value="<?php if($edit_ids!=''){ echo $kg_height1; } else {  }?>" /></div></td>
    <td class="text style4  style5"><div id="return_qty_div"><input type="text" name="inward_qty" id="inward_qty"    class="types_class1"   tabindex="4"  style="width:100%; height:29px; text-align:right;" value="<?php if($edit_ids!=''){ echo $deliv_qty1; } else {  }?>" onKeyUp="enterevent(event,'add','inward_qty')" />
    <input type="hidden" name="tot_qty" id="tot_qty"    class="types_class1"  style="width:100%; height:29px; text-align:right;" /></div></td>
    <td class="text style4  style5"><input type="button" name="add" id="add" tabindex="5" value="<?php if($edit_ids!='') { echo "EDIT"; } else { echo "ADD"; } ?>" style="width:100%; height:120%;" onClick="enterevent(event,'remarks','add'),return_sublist_add(return_no.value,date_time.value,job_no.value,customer_name.value,job_type.value,fabric_type.value,return_dates.value,ret_particular.value,roll_width.value,kg_height.value,inward_qty.value,tot_qty.value,overal_qty.value,'<?php echo $_POST['edit_id'];?>',this.value);"></td>
    </tr>
 <tr height="145px">
   <td height="12" colspan="9"  align="center" class="style4 style3 style5" >
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
   </table></td>
   </tr>
    </table>
 </div>
<table width="100%">
  <tr >
  <?php 
if($_POST['edit_id']!='') 
{
   $sql="select sum(qty) as qty from  return_sublist where job_no='$job_no' or job_no='$job_no1' and sub_id!='$edit_ids'";
}
else
{
	   $sql="select sum(qty) as qty from  return_sublist where job_no='$job_no' or job_no='$job_no1' ";
}
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$over_allqty=$rsdata['qty'];
			}
			
			if($edit_ids!='')
			{
			     $sql_user="select sum(prod_qty) as prod_qty  from  fusing_production_sublist where  job_card_no='$job_no' or job_card_no='$job_no1' and prod_size='$_POST[particulars]'";
		 $rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			 $prod_qtysss=$rsdata_user->prod_qty;
			}
			}
			
			
  ?>
  
    <td width="79%"  align="center" ></td>
    <td width="11%"><span class="text" style="font-size: 14px;"><strong><strong>Total</strong></strong></span></td>
    <td width="10%">&nbsp;<input type="hidden" name="overal_qty" id="overal_qty" value="<?php echo $over_allqty; ?>" >
    <input type="hidden" name="overal_qty11" id="overal_qty11" value="<?php echo $inward_qty1; ?>" >
	<span style="font-size:18px; font-weight:bold"><?php   echo number_format($inward_qty1,2);  ?></span>
  <input type="hidden" name="tot_qty44" id="tot_qty44" class="types_class1"   style="width:100%; height:29px;" value="<?php echo $prod_qtysss; ?>" />
    </td>
  </tr>
</table>
