<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>
<?php 
error_reporting(0);
date_default_timezone_set('Asia/Kolkata');
include("../../include/db.php");
ob_start();
session_start();
$user_id = $_SESSION['login_user_id'];
function get_roll_id_edit($roll_name_edit)
{
  $Isql=mysql_query("select * from consumable_creation where particulars='$roll_name_edit'");
  //echo "select * from consumable_creation where particulars='$roll_name_edit'";
    $rscount=mysql_num_rows($Isql);
  while($rsdata_user=mysql_fetch_object($Isql))
      { 
       $id11=$rsdata_user->id;
      }
      return $id11;
}
  $edit_ids=$_POST['edit_id']; 
  $media_pur_no=$_POST['media_pur_no'];
  $sql="select * from media_pur_sublist where id='$_POST[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'];
        $roll_name_edit=$rsdata['particulars'];
        $roll_id_edit=get_roll_id_edit($roll_name_edit);
				 $qty1=$rsdata['qty'];
				 $mtr_roll1=$rsdata['mtr_roll'];
				$tot_mtr1=$rsdata['tot_mtr'];
				$batch_no1=$rsdata['batch_no'];
}
?>

<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="290" class="text style1 style5 style21"><strong>&nbsp;&nbsp;Batch No</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
    $media_pur_no=$_GET['media_pur_no'];
    $media_pur_no=$_POST['media_pur_no'];
    $sql="select * from  media_pur_sublist where (media_pur_no='$_GET[media_pur_no]' or media_pur_no='$_POST[media_pur_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'];
   			$particularss=$rsdata['particulars'];
   			$batch_no=$rsdata['batch_no'];
				$qty=$rsdata['qty'];
				$mtr_roll=$rsdata['mtr_roll'];
				$tot_mtr=$rsdata['tot_mtr'];
				
				
				$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 $particularss;?></td>
            <td align="left" class="text style5 style4" style="padding-left:2px;">&nbsp;<?php echo $batch_no;?></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/cross-small.png"  title="Delete" onClick="delete_sublist_media_pur('<?php echo $id;?>','<?php echo $media_pur_no; ?>','<?php echo $particularss; ?>','<?php echo $batch_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" ><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')" /></td>
     <td align="left" class="text style4 style5" ><input name="invoice_no"  id="invoice_no"   tabindex="4" onKeyUp="media_pur_clear_validation(this.value)" value="<?php if($edit_ids!='') { echo $invoice_no; }  ?>" style="width:100%;  height:28px;"   class="types_class1" /></td>
    <td align="left" class="text style4 style5" ><select name="sup_name"   id="sup_name" onChange="media_pur_clear_validation(this.value)" class="types_class1"  tabindex="4" style="width:100%;  height:28px;" >
     <option value="">Select</option><?php error_reporting(0);
 include("../../include/db.php");
	$sql_user="select * from  party_creation where party_type='Supplier' ";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$id=$rsdata_user->party_id;
			$party_name=$rsdata_user->party_name;
			?>
<option value="<?php  echo $party_name; ?>"  <?php if($party_name==$supplier_name1){?> selected="selected" <?php }?>><?php echo $party_name;?></option><?php } ?></select></td>

 
    <td align="left" class="text style4 style5"><select name="particulars" onChange="media_pur_clear_validation(this.value)"  class="types_class1" id="particulars"  tabindex="4" style="width:100%;  height:28px;" >
     <option value="">Select</option><?php error_reporting(0);
 include("../../include/db.php");
  $sql_user="select * from  consumable_creation where item='Media' and status_type='Active' order by particulars asc";
    $rs_user=mysql_query($sql_user);
      while($rsdata_user=mysql_fetch_object($rs_user))
      { 
      $id=$rsdata_user->id;
      $particulars=$rsdata_user->particulars;
      ?>
      
      
<option value="<?php  echo $id; ?>" <?php if($id==$roll_id_edit){?> selected="selected" <?php }?>><?php echo $particulars;?></option><?php } ?></select></td>

<td align="left" class="text style4 style5" ><input name="batch_no"  id="batch_no" tabindex="4" value="<?php if($edit_ids!='') { echo $batch_no1; }  ?>" style="width:100%;  height:28px;"  onKeyUp="media_pur_clear_validation(this.value)" class="types_class1"/></td>

        <td  class="text style4 style5"><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="media_pur_clear_validation(this.value),get_tot_mtr(this.value,mtr_roll.value)"    value="<?php if($edit_ids!=''){ echo $qty1; } else {  }?>" /><input type="hidden" name="width_hid" id="width_hid" value="<?php echo $width_hid; ?>"></td>

    <td  class="text style4 style5"><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="media_pur_clear_validation(this.value),get_tot_mtr(qty.value,this.value)"  value="<?php if($edit_ids!=''){ echo $mtr_roll1; } else {  }?>" /><input type="hidden" name="height_hid" id="height_hid" value="<?php echo $mtr_roll1; ?>"></td>

    <td  class="text style4 style5"><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 {  }?>" /></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_sub(media_pur_no.value,media_date.value,entrydates.value,invoice_no.value,sup_name.value,particulars.value,batch_no.value,qty.value,mtr_roll.value,tot_mtr.value,'<?php echo $edit_ids;?> ',this.value)"></td>
  </tr>
  <tr>
  <td></td> 
  <td ></td> 
  <td><div id="invoice_no_media_valid_div" style="color:#F00;"></div></td>
  <td><div id="supp_name_media_valid_div" style="color:#F00;"></div></td>
  <td><div id="particulars_media_valid_div" style="color:#F00;"></div></td>
  <td><div id="qty_media_valid_div" style="color:#F00;"></div></td>
  <td><div id="mtr_roll_media_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 $total_mtrs; ?>"/>
</div><table width="100%">
  <tr >

  <td colspan="5" align="right" 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>