<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: 12px;}

#tot_amt::-webkit-input-placeholder { color:#666; }
</style>
<div id="return_id">

<?php 

error_reporting(0);
date_default_timezone_set('Asia/Kolkata');
include("../../include/db.php");
ob_start();
session_start();

if($_GET['job_card_nos']!='')
{
	
 $fun_job=$_GET['job_card_nos'];	
}
elseif($_POST['job_card_nos']!='')
{
	
 $fun_job=$_POST['job_card_nos'];	
}
  $user_id = $_SESSION['login_user_id'];
  $job_card_nos=$_POST['job_card_nos']; 
  $edit_ids=$_GET['edit_id'];
  $media_pur_no=$_GET['purchase_no'];
  $media_pur_no=$_POST['media_pur_no'];
  $sql_return="select * from return_media_pur_sublist where media_pur_no='$_GET[job_card_nos]' ";
  $res_sql=mysql_query($sql_return);
  while($rs_datass=mysql_fetch_array($res_sql))
  {
				$sno=$sno+1;
				$id=$rs_datass['id'];
				$media_pur_no22=$rs_datass['media_pur_no'];
				$entrydates22=$rs_datass['entrydates'];
				$invoice_no22=$rs_datass['invoice_no'];
				$supplier_name22=$rs_datass['supplier_name'];
   				$particulars22=$rs_datass['particulars_id'];
				$qty1=$rs_datass['qty'];
				$qty_hid=$rs_datass['qty_hid'];
				$mtr_ro22=$rs_datass['mtr_roll'];
				$tot_mtr22=$rs_datass['tot_mtr'];
}

  $sql="select * from return_media_pur_sublist where id='$_GET[edit_id]' ";
  $rs=mysql_query($sql);
  while($rsdata=mysql_fetch_array($rs))
  {
				    $sno=$sno+1;
				    $id=$rsdata['id'];
				    $media_pur_no1=$rsdata['media_pur_no'];
					$entrydates1=$rsdata['entrydates'];
					 $invoice_no1=$rsdata['invoice_no'];
					$supplier_name1=$rsdata['supplier_name'];
   					$particulars1_edit=$rsdata['particulars'];
				 	$qty1=$rsdata['qty'];
				 	$mtr_roll1=$rsdata['mtr_roll'];
					$tot_mtr1=$rsdata['tot_mtr'];
					$qty_hid1=$rsdata['qty_hid'];
}

	 	
			?>



<div style="height:200px; width:98%; padding-left:0px;  overflow-x:hidden; overflow-y:scroll; white-space:nowrap;" align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" >
    <tr bgcolor="#F2F2F2">
    <td width="40" height="35"  class="text style5 style1 style21"><strong>&nbsp;S.No&nbsp;</strong></td>
    <td width="145" class="text style1 style5 style21"><strong>&nbsp;&nbsp;Date</strong></td>
    <td width="145" class="text style1 style5 style21"><strong>Invoice No</strong></td>
     <td width="215" class="text style1 style5 style21"><strong>Supplier Name</strong></td>
    <td width="222" class="text style1 style5 style21"><strong>&nbsp;&nbsp;Particulars</strong></td>
     <td width="117" class="text style1 style5 style21"><strong>&nbsp;&nbsp;Qty</strong></td>
      <td width="145" class="text style1 style5 style21"><strong>&nbsp;&nbsp;Mtr/Qty</strong></td>
    <td width="145" align="right" class="text style1 style5 style21"><strong>Total Mtr</strong>&nbsp;</td>
     
    <td width="101" align="center" class="text style1 style5 style3 style21"><strong>Action</strong></td>
   
 </tr>
   <?php
   
	       $sql="select * from  return_media_pur_sublist WHERE (`return_no`='$_POST[return_no]' or  `return_no`='$_GET[return_no]' )";
    $rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{ 
   				$sno=$sno+1;
   				$id=$rsdata['id'];
				$media_pur_no=$rsdata['media_pur_no'];
				$entrydates=$rsdata['entrydates'];
				$invoice_no=$rsdata['invoice_no'];
				$supplier_name=$rsdata['supplier_name'];
   				$particulars=$rsdata['particulars'];
				$qty=$rsdata['qty'];
				$mtr_roll=$rsdata['mtr_roll'];
				$tot_mtr=$rsdata['tot_mtr'];
				$return_no=$rsdata['return_no'];
				$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 align="center" class="text style4  style5"><?php echo $sno; ?></td>
      <td align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;&nbsp;<?php echo date('d-m-Y H:i',strtotime($entrydates));?></td>
      <td align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;<?php echo $invoice_no;?></td>
      <td align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;&nbsp;<?php echo $supplier_name;?></td>
            <td align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;<?php echo $particulars;?></td>
 <td align="right" class="text style5 style4" style="padding-left:2px;">&nbsp;<?php echo $qty;?></td>
  <td align="right" class="text style5 style4" style="padding-left:2px;">&nbsp;<?php echo $mtr_roll;?></td>
      <td align="right" class="text style5 style4"><?php echo $tot_mtr;?>&nbsp;&nbsp;</td>
    
        <?php if(($user_id=='1')||($user_id=='3'))
	 { ?>
   
      
    
	  <td align="center" class="style5 style3 style4" ><img src="img/edit.png" onClick="mediapurchase_sublist_edit_con_ret('<?php echo $id;?>','<?php  echo $media_pur_no;?>','<?php  echo $return_no;?>')" width="18px" height="18px">&nbsp;&nbsp;<img src="img/cross-small.png"  title="Delete" onClick="delete_sublist_media_pur_con_ret('<?php echo $id;?>','<?php echo $return_no; ?>')" width="20px" height="20px"></td><?php } ?>
</tr>
<?php 
$total_mtrs+=$tot_mtr;
$mtr_roll3+=$mtr_roll;

$qty2+=$qty;

} 
?>
<tr>
    <td class="text style4 style5"><?php echo $sno+1; ?></td>
    <td  align="left" class="text style4 style5" ><div id="date_div"><input type="datetime-local" name="entrydates" id="entrydates"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>   tabindex="3" style="width:100%; height:28px;" value="<?php if($edit_ids!='') { echo $entrydates; } else{ echo date('Y-m-d').'T'.date('H:i'); } ?>" class="types_class1" onkeypress="enterevent(event,'media_particular','entrydates')" /></div></td>
     <td align="left" class="text style4 style5" ><div id="voice_div">
     
     <select name="invoice_no"   id="invoice_no" onChange="cons_ret_media_clear_valid_sub(this.value),get_con_ret_sup_part_name_media(return_no.value,job_card_nos.value,invoice_no.value)" class="types_class1"  tabindex="4" style="width:100%;  height:28px;" >
         <?php if($_GET['edit_id']=='') { ?><option value="">Select</option><?php } ?>

    <?php 
	 	$sql_user="select DISTINCT invoice_no  from  media_pur_sublist WHERE (`media_pur_no`='$_POST[job_card_nos]' or  `media_pur_no`='$_GET[job_card_nos]' or  `media_pur_no`='$_GET[media_pur_no1]')";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$id=$rsdata_user->id;
			$invoice_no=$rsdata_user->invoice_no;
			?>
	<option value="<?php  echo $invoice_no; ?>" <?php if($invoice_no1==$invoice_no){?> selected="selected" <?php }?>><?php echo $invoice_no;?></option><?php } ?>
	 <?php error_reporting(0);
 include("../../include/db.php");
	?></select>
     
     </div></td>
    <td align="left" class="text style4 style5" ><div id="sup_div"><select name="sup_name"   id="sup_name" onChange="cons_ret_media_clear_valid_sub(this.value)" class="types_class1"  tabindex="4" style="width:100%;  height:28px;" >
    <?php if($_GET['edit_id']=='') { ?><option value="">Select</option><?php } ?>
	 <?php 
	 	$sql_user="select DISTINCT supplier_name  from  media_pur_sublist WHERE (`media_pur_no`='$_POST[job_card_nos]' or  `media_pur_no`='$_GET[job_card_nos]' or  `media_pur_no`='$_GET[purchase_no]') and invoice_no='$invoice_no1'";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$id=$rsdata_user->id;
			$supplier_name133=$rsdata_user->supplier_name;
			?>
<option value="<?php  echo $supplier_name133; ?>" <?php if($supplier_name133==$supplier_name1){?> selected="selected" <?php }?>><?php echo $supplier_name133;?></option><?php } ?>
	 </select></div></td>
 
    <td align="left" class="text style4 style5"><div id="ret_particulars_div"><select name="particulars" onchange="get_qty_fun(this.value,'<?php echo $fun_job;?>',return_no.value),cons_ret_media_clear_valid_sub(this.value)"  class="types_class1" id="particulars"  tabindex="4" style="width:100%;  height:28px;" >
    <?php if($_GET['edit_id']=='') { ?><option value="">Select</option><?php } ?>
	
	<?php 
	$sql_user="select * from  media_pur_sublist where (`media_pur_no`='$media_pur_no' or  `media_pur_no`='$_GET[job_card_nos]' or  `media_pur_no`='$_GET[purchase_no]') and invoice_no='$invoice_no1'";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			 $id=$rsdata_user->particulars_id;
			$res_part11=$rsdata_user->particulars;
			
			?>
<option value="<?php  echo $id; ?>" <?php if($particulars1_edit==$rsdata_user->particulars){?> selected="selected" <?php }?>><?php echo $res_part11;?></option><?php } ?></select></div></td>
        <td  class="text style4 style5"><div id="qty_div_media_con"><input type="text" class="types_class1" name="qty" id="qty" style="width:100%;  height:28px;"  onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false" onKeyUp="get_tot_mtr_consumable(this.value,mtr_roll.value),cons_ret_media_clear_valid_sub(this.value)"    value="<?php if($edit_ids!=''){ echo $qty1; } else {  }?>" /><input type="hidden" class="types_class1" name="qty_hide_med" id="qty_hide_med" style="width:100%;  height:28px;"  value="<?php if($edit_ids!=''){  echo $qty_hid1;} else {  }  ?>" /></div></td>

    <td  class="text style4 style5"><div id="res_mtrsss"><input type="text" class="types_class1" name="mtr_roll"  id="mtr_roll" style="width:100%;  height:28px;"  onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false" onKeyUp="cons_ret_media_clear_valid_sub(this.value),get_tot_mtr(qty.value,this.value)" readonly  value="<?php if($edit_ids!=''){ echo $mtr_roll1; } else {  }?>" /></div></td>

    <td  class="text style4 style5"><div id="res_tot_mtr"><input type="text" class="types_class1" name="tot_mtr"  readonly id="tot_mtr" style="width:100%;  height:28px;"  onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false"  value="<?php if($edit_ids!=''){ echo $tot_mtr1; } else {  }?>" /></div></td>
  
  
<td class="text style4 style5"><input type="button" name="add" style="width:100%;  height:28px;" id="add" tabindex="6" value="<?php if($edit_ids!='') { echo "EDIT"; } else { echo "ADD"; } ?>"   onClick="media_pur_sublist_sublist_con_ret(job_card_nos.value,entrydates.value,invoice_no.value,sup_name.value,particulars.value,qty.value,mtr_roll.value,tot_mtr.value,'<?php echo $_GET['edit_id'];?> ',this.value,return_no.value,qty_hide_med.value)"></td>
  </tr>
  <tr>
  <td></td> 
  <td ></td> 
  <td><div id="invoice_no_media_con_ret_valid_div" style="color:#F00;"></div></td>
  <td><div id="supp_name_media_con_ret_valid_div" style="color:#F00;"></div></td>
  <td><div id="particulars_media_con_ret_valid_div" style="color:#F00;"></div></td>
  <td><div id="qty_media_con_ret_valid_div" style="color:#F00;"></div></td>
  <td><div id="mtr_roll_media_con_ret_valid_div" style="color:#F00;"></div></td>
  <td></td>
  <td width="1"></td>
  <td width="1"></td>
  <td width="1"></td>
  <td width="6"></td>
  </tr>
  <tr height="100px">
  <td></td> 
  <td></td> 
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
<td></td>

 </tr>
</table>

<input type="hidden" name="total" id="total" value="<?php echo $qty2; ?>"/>
</div><table width="100%">
  <tr >

  <td  align="center"  style="padding-left:55%;" class="text"><strong>Total</strong></td>
  <td width="15%" align="right" class="text"><strong><?php echo number_format($qty2,2) ?></strong></td>
  <td width="9%" align="right" class="text"><strong><?php echo number_format($mtr_roll3,2) ?></strong></td>
<td width="12%" align="right" class="text"><strong><?php echo number_format($total_mtrs,2) ?></strong></td>
<td width="10%"></td>
 </tr></table></div>
 
