
<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>
<?php error_reporting(0);
date_default_timezone_set('Asia/Kolkata');
/***************************** PREVIOUS NEXT CODING ****************************************/
 include("../../include/db.php");
ob_start();
session_start();
$user_id11 = $_SESSION['login_user_id'];
 function get_shift_name($shift_time)
 {
	$sql_user="select * from  shift_creation where id='$shift_time'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$shift_name=$rsdata_user->shift_name;
	}
	return $shift_name;

 }  function get_operator_name($operator_name)
 {
	$sql_user="select * from  operator_creation where id='$operator_name'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$operator_name=$rsdata_user->operator_name;
	}
	return $operator_name;

 }

  function get_machine_name($machine_no)
 {
	$sql_user="select * from  machine_creation where id='$machine_no'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$machine_no=$rsdata_user->machine_no;
	}
	return $machine_no;
 }
  $edit_ids=$_POST['edit_id']; 
  
  $ink_entry_no=$_POST['ink_entry_no'];
  // echo $ink_entry_no;
   $sql="select * from ink_sublist where ink_sub_id='$_POST[edit_id]' ";
  $rs=mysql_query($sql);
  while($rsdata=mysql_fetch_array($rs))
  {
				   $sno=$sno+1;
				   $id=$rsdata['ink_sub_id'];
				   $ink_entry_no2=$rsdata['ink_entry_no'];
				$ink_date2=$rsdata['ink_date'];
				$production_time2=$rsdata['production_time'];
				$shift_time4=$rsdata['shift_time'];
   				$machine_no2=$rsdata['machine_no'];
				 $operator_name2=$rsdata['operator_name'];
				 	 $prod_size2=$rsdata['prod_size'];
					 	 $batch_no2=$rsdata['batch_no'];
					 	 $total_req2=$rsdata['total_req'];
				
}
  $edit_ids=$_POST['edit_id']; 

  $media_part=mysql_fetch_array(mysql_query("select *,SUM(qty) as tot_qty, SUM(total_meter)as total_meter from ink_pur_batch_tot_value where particulars='$prod_size2' and `batch_no`='$batch_no2' group by batch_no "));
 			
 
  $media_part_tot=mysql_fetch_array(mysql_query("select *, SUM(total_meter)as total_meter from ink_pur_batch_tot_value where particulars='$prod_size2' and `batch_no`='$batch_no2' group by batch_no "));
 //  $media_qty=$media_part['tot_qty'];			
  $total_meter=$media_part_tot['total_meter'];

?>

<div style="height:300px; 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="52" height="30" class="text style5 style1 style21"><strong>&nbsp;Date&nbsp;</strong></td>
    <td width="66" class="text style1 style5 style21"><strong>&nbsp;Shift</strong><span style="color:#FF0000">*</span><div id="shift_validation_div" style="color:#F00"></div></td>
    <td width="88" class="text style1 style5 style21" align="left"><strong>&nbsp;Machine No</strong><span style="color:#FF0000">*</span><div id="machine_validation_div" style="color:#F00"></div></td>
    <td width="141" class="text style1 style5 style21" align="left"><strong>&nbsp;Operator</strong><span style="color:#FF0000">*</span><div id="operator_validation_div" style="color:#F00"></div></td>
    <td width="138" class="text style1 style5 style21" align="left"><strong>&nbsp;Particulars</strong><span style="color:#FF0000">*</span><div id="size_validation_div" style="color:#F00"></div></td>
    <td width="84" class="text style1 style5 style21" align="left"><strong>Batch No&nbsp;</strong></td>
    <td width="252" class="text style1 style5 style21" align="left"><strong>Total Req&nbsp;</strong></td>
   
    
   
    <td width="100" height="30" class="text style5 style1 style21" align="center"><strong>&nbsp;Action&nbsp;</strong></td>
 </tr>
   <?php
   	    $sql_user2="select * from  ink_sublist where (ink_entry_no='$_POST[ink_entry_no]' or ink_entry_no='$_GET[ink_entry_no]') order by ink_sub_id asc";
		$rs_user2=mysql_query($sql_user2);
			while($rsdata_user2=mysql_fetch_object($rs_user2))
			{ 
			$ink_sub_id=$rsdata_user2->ink_sub_id;
			$ink_date=$rsdata_user2->ink_date;
			$shift_time=$rsdata_user2->shift_time;
			$shift_dis_name=get_shift_name($shift_time);
			$machine_no=$rsdata_user2->machine_no;
			$machine_name=get_machine_name($machine_no);
			$operator_name=$rsdata_user2->operator_name;
			$operator_dis_name=get_operator_name($operator_name);
			$prod_size=$rsdata_user2->prod_size;
			$width=$rsdata_user2->width;
			$height=$rsdata_user2->height;
			$batch_no=$rsdata_user2->batch_no;
			$total_req=$rsdata_user2->total_req;
			$prod_qty=$rsdata_user2->prod_qty;
			$ink_entry_no=$rsdata_user2->ink_entry_no;
			 
  ?>
  <tr height="25px">
    <td height="29" class="text style4  style5">&nbsp;<?php echo date("d-m-Y H:i",strtotime($ink_date));?></td>
    <td class="text style4  style5">&nbsp;<?php echo $shift_dis_name;?></td>
    <td class="text style4  style5">&nbsp;<?php echo $machine_name;?></td>
    <td class="text style4  style5">&nbsp;<?php echo $operator_dis_name;?></td>
    <td class="text style4  style5">&nbsp;<?php echo $prod_size;?></td>
    <td class="text style4  style5">&nbsp;<?php echo $batch_no;?></td>
    <td class="text style4  style5">&nbsp;<?php echo $total_req;?></td>
   
     <?php if(($user_id11=='1')||($user_id11=='3'))
	 { ?>
       <td class="text style4  style5" align="center"><img src="img/edit.png" onClick="inkent_sublist_edit('<?php echo $ink_sub_id;?>','<?php  echo $ink_entry_no;?>')" width="18px" height="18px">&nbsp;&nbsp;<img src="img/cross-small.png"  title="Delete" onClick="del_ink_sub('<?php echo $ink_sub_id;?>','<?php echo $ink_entry_no;?>')" width="20px" height="20px"></td><?php }?>
  </tr>
  <?php 
  $tot_total_qty+=$total_req;
  $tot_prod_qty+=$prod_qty;
  }?>
  <tr height="20px">
    <td  class="text  style5"><input type="datetime-local" name="production_time"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>  id="production_time" tabindex="3" value="<?php if($_POST['edit_id']!='') { echo $ink_date2; } else { echo date('Y-m-d').'T'.date('H:i'); }?>" class="types_class" style="width:100%; height:28px; font-size:14px" onkeyup="enterevent(event,'machine_no','shift_time')"/></td>
    <td class="text style5"><select name="shift_time" id="shift_time" tabindex="4" onchange="ink_entry_clear_sub_validation(this.value)" class="types_class" style="width:100%; height:29px; font-size:14px"  >
    <option value="">--Select--</option>
    <?php
	$sql_user="select * from  shift_creation order by shift_name asc";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$shift_name=$rsdata_user->shift_name;
			$shiftid=$rsdata_user->id;

	?>
    <option value="<?php echo $shiftid;?>"  <?php if($shiftid==$shift_time4){?> selected="selected" <?php }?>><?php echo $shift_name;?></option>
    <?php } ?>
    </select></td>
    <td class="style5">
    <select name="machine_no" id="machine_no" class="types_class" onchange="ink_entry_clear_sub_validation(this.value)" tabindex="5" style="width:100%; height:29px; font-size:14px"  >
    <option value="">--Select--</option>
    <?php
	$sql_user="select * from  machine_creation where mach_type='printer' order by machine_no asc";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$machine_no=$rsdata_user->machine_no;
			$machine_id=$rsdata_user->id;

	?>
    <option value="<?php echo $machine_id;?>"  <?php if($machine_id==$machine_no2){?> selected="selected" <?php }?>><?php echo $machine_no;?></option>
    <?php } ?>
    </select></td>
    <td class="style5"><select name="operator_name" id="operator_name" onchange="ink_entry_clear_sub_validation(this.value)" tabindex="6" class="types_class" style="width:100%; height:29px; font-size:14px" >
    <option value="">--Select--</option>
    <?php
	$sql_user1="select * from  operator_creation where operator_type='Printing Operator' order by operator_name asc";
		$rs_user1=mysql_query($sql_user1);
			while($rsdata_user1=mysql_fetch_object($rs_user1))
			{ 
			$operator_name=$rsdata_user1->operator_name;
			$operatorid=$rsdata_user1->id;

	?>
    <option value="<?php echo $operatorid;?>" <?php if($operatorid==$operator_name2){?> selected="selected" <?php }?>><?php echo $operator_name;?></option>
    
    <?php } ?></select></td>
    <td class="style5"><select name="prod_size" id="prod_size" onchange="ink_entry_clear_sub_validation(this.value),get_tot_qty(this.value),get_batchno(this.value)" class="types_class" tabindex="7" style="width:100%; height:29px; font-size:14px"  >
    <option value="">--Select--</option>
    <?php
	$sql_user="select * from  consumable_creation where item='Ink' and status_type='Active' order by id asc";
		$rs_user=mysql_query($sql_user);
			while($rsdata_user=mysql_fetch_object($rs_user))
			{ 
			$particulars=$rsdata_user->particulars;
			
	?>
    <option value="<?php echo $particulars;?>" <?php if($particulars==$prod_size2){?> selected="selected" <?php }?>><?php echo $particulars;?></option>
    <?php } ?>
    </select></td>
    <td class="style5">
  <div id="ink_entry_batchno_div">
    <select class="types_class" name="batch_no" onchange="get_batchno_detail(this.value)" tabindex="8" id="batch_no" style="width:100%; height:26px; font-size:14px;">
      <option value="">--Select--</option>
      <?php
      if($_POST['edit_id']!='') {
        $batch_sql="select distinct batch_no from ink_pur_batch_tot_value where particulars='$prod_size2'";
        $batch_rs=mysql_query($batch_sql);
        while($batch_data=mysql_fetch_object($batch_rs)){
          $batch=$batch_data->batch_no;
      ?>
      <option value="<?php echo $batch;?>" <?php if($batch==$batch_no2){?> selected <?php }?>><?php echo $batch;?></option>
      <?php }} ?>
    </select>
  </div>
</td>

    <td class="style5"><div id="ink_entry_qty_div1"><input type="text" class="types_class1" name="total_req" tabindex="9" onKeyUp="ink_entry_clear_sub_validation(this.value),get_total_ink_roll(prod_size.value); updateQty();" id="total_req" style="width:100%; height:26px; font-size:14px;" value="<?php if($_POST['edit_id']!='') { echo $total_req2; } ?>"/></div>
      <input type="hidden" name="tot_qty_hid_ink" id="tot_qty_hid_ink" value="<?php   if($edit_ids!=''){ echo $media_qty;} else {  } ?>">
      <input type="hidden" name="tot_qty_hid_ink1" id="tot_qty_hid_ink1" value="<?php   if($edit_ids!=''){ echo $total_meter;} else {  } ?>">

</td>


 
   
    <td class="style5"><input type="button" name="add" id="add" value="<?php if($_POST['edit_id']!='') {echo  "EDIT"; } else { echo "ADD"; } ?>" tabindex="10" style="width:100%; height:120%;" onClick="ink_entry_sublist(ink_no.value,ink_date.value,shift_time.value,machine_no.value,operator_name.value,prod_size.value,batch_no.value,total_req.value,tot_qty_hid_ink.value,tot_qty_hid_ink1.value,'<?php echo $_POST['edit_id']; ?>',this.value)"></td>
  </tr>
     <tr height="105px">
    <td width="11%" class="text  style1 "></td>
    <td width="9%" class="text  style1 "><div id="shift_time_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    <td width="12%" class="text  style1 "><div id="machine_no_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    <td width="12%" class="text  style1 "><div id="operator_name_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    <td width="24%" class="text  style1 "><div id="prod_size_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    <td width="10%" class="text  style1 "><div id="batch_no_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    <td width="8%" class="text  style1 "><div id="total_req_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
    
    <td width="8%" class="text  style1 "><div id="tota_validation_inkent_div" style="color:#FF0000;"></div>&nbsp;</td>
  </tr>
   <tr height="200px">
 
   </tr>
   
</table>
<input type="hidden" name="tot_prod" id="tot_prod" value="<?php echo number_format($tot_total_qty,3); ?>"/>
<input type="hidden" name="tot_bal" id="tot_bal" value="<?php echo number_format($tot_balance_qty,3); ?>"/>
</div>



<?php 
  $edit_ids=$_POST['edit_id']; 

?>
 <table width="98%">
  <tr>
  <td width="6"></td>
  <td width="6"></td>
  <td width="6"></td>
  <td width="6"></td>
  <td width="199" class="text" align="right"><strong>Total</strong></td>
 
  <td width="137" align="right" class="text"><strong><?php echo number_format($tot_total_qty,2); ?></strong></td>
  <td width="49" align="right"></td>
  </tr></table>
  <script>
      function updateQty() {
    var total_reqValue = parseFloat(document.getElementById('total_req').value);
    // var nosValue = parseFloat(document.getElementById('nos').value);
    // var qtyField = document.getElementById('total_qty');
    // if (!isNaN(total_reqValue) && !isNaN(nosValue)) {
    //     var product = total_reqValue * nosValue;
    //     qtyField.value = product;
    // } else {
    //     qtyField.value = '';
    // }
}
  </script>