Current File : /home/obabain/public_html/abc/d_bom.jsp
<%@include file="master.jsp" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
     <%@page import="java.sql.*,java.util.*"%>
    
  <%
   Statement st=con1.createStatement();
  %>  
  
 <%!
    int id=0;String porder, porder1, porder2, porder3,porder4,date;int d_id=0;int f_id=0; String bomno=null;
    String did="";
 %>
 
      <%!
         String p_itemcode[]=null,quantity[]=null,required_quantity[]=null,unit[]=null,price[]=null;
      %>
 
<%
  ResultSet r1=null;
  did=request.getParameter("did");
%>
<style type="text/css">
.highlight-error {
  border-color: red;
}
</style>

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/jquery-2.1.0.min.js"></script>
<script src="js/tableEdit-0.1.js"></script>


<body>
<script type="text/javascript">
function getqc(targetField,targetField1)
{
	var w3=window.open('Productselect.jsp','_blank','top=80,left=70,width=1400,height=650,scrollbars=1')
	w3.targetField=targetField;
	w3.targetField1=targetField1;
	
	w3.focus();
	}
</script>
<script>
function setSearchRslt2(targetField,targetField1,returnvalue,returnvalue1)
{
	targetField.value = returnvalue;
	targetField1.value = returnvalue1;
    window.focus();
}
</script>

<script type="text/javascript">
function getqc1(targetField,targetField1,targetField2)
{
	var w3=window.open('Productselect1.jsp','_blank','top=80,left=70,width=1400,height=650,scrollbars=1')
	w3.targetField=targetField;
	w3.targetField1=targetField1;
	w3.targetField2=targetField2;
	//w3.targetField3=targetField3;
	w3.focus();
	}
</script>
<script type="text/javascript">
function setSearchRslt4(targetField,targetField1,targetField2,returnvalue,returnvalue1,returnvalue2)
{
	targetField.value = returnvalue;
	targetField1.value = returnvalue1;
	targetField2.value = returnvalue2;
	//targetField3.value = returnvalue3;
    window.focus();
}
</script>

<script type="text/javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='editbom.jsp?id='+id;
    f.submit();
}
</script>

<%
ResultSet rs123=st.executeQuery("select max(B_id) as B_id  from bom_rawmaterial where type='F'");
while(rs123.next()){
	id=rs123.getInt("B_id");
}
%>

<%
ResultSet rs11=st.executeQuery("select * from bom_rawmaterial where fg_id='"+did+"'");
while(rs11.next()){
	d_id=rs11.getInt("B_id");
	f_id=rs11.getInt("fg_id");
	bomno=rs11.getString("bom_no");
porder=rs11.getString("hsn");
porder1=rs11.getString("product");
porder2=rs11.getString("quantity");
porder3=rs11.getString("unit");
porder4=rs11.getString("type");
date=rs11.getString("date");
}
%>

<div class="row">
<form action="" method="post" id="contact" name="form1">
<section id="main">
<div class="container">
 <div class="row" style="width:110%">
    <div class="col-md-10" >
       <div class="panel panel-default" >
       <div class="panel-heading main-color-bg">
        <h3 class="panel-title">Indent</h3>
        
    </div>
     <div class="panel-body">
    
       <div class="row" >
        <!--  <b style="margin-left:10px;">Indent:</b> -->
         <div align="right"><a href="ViewBillofMaterial_3.jsp">
<input type="button" value="View Details" style="background:#204b58;margin-right:50px" class="btn btn-info"/></a>
 </div>
 
    <div class="form-group col-xs-2">
             
            <div class="onerow">
                    
               <p> <label for="firstname" style="margin-left:20px;">Indent Id</label></p>
              <input  id="displayText"  type="text" name="did" value="<%=bomno%>" name="hsn" class="form-control input-group-lg reg_name" readonly="readonly">
            </div>
            </div>
 
              
            <div class="form-group col-xs-4">
               <p> <label for="lastname" style="margin-left:30px;"> Product </label></p>
                          <input    type="text" name="itemcode1"  value="<%=porder1%>" class="form-control input-group-lg reg_name">
            </div>
            
        <div class="form-group col-xs-2">     
            <div class="onerow">      
               <p> <label for="firstname" style="margin-left:40px;">Qty</label></p>
                <input id="firstname" class="form-control input-group-lg reg_name"  value="<%=porder2%>" style="width:150px;margin-left:40px;"  type="text" 
                       title="Enter first name" 
                   name="name"  placeholder=""/>
            </div>
        </div>
        
              &nbsp;&nbsp;&nbsp;
              
         <div class="form-group col-xs-2">     
            <div class="onerow">      
               <p> <label for="firstname" style="margin-left:50px;">Date</label></p>
                <input id="firstname" class="form-control input-group-lg reg_name"  value="<%=date%>" style="width:150px;margin-left:40px;"  type="text" 
                       title="Enter first name" 
                   name="name"  placeholder=""/>
            </div>
        </div>      
              
              
        <%-- <div class="form-group col-xs-2">
               <p> <label for="lastname" style="margin-left:50px;">Unit</label></p>
                <input type="hidden" value="<%=porder3%>" id="u">
          <select name="unit" id="unit"  style="margin-left:40px;"  class="form-control input-group-lg reg_name">
          <%
            ResultSet rs1=st.executeQuery("select * from ip_units");
            while(rs1.next())
            {
          %>
            <option value=" <%=rs1.getString("unit_id") %>"><%=rs1.getString("unit_name") %></option>
          <%} %>
         </select>
       </div> --%>
                                
             
     </div>
               
    </div>
            <hr>
          <!-- new extra code -->   
           <div class="panel-body">
            <b>Components Details:</b>
            <%    int j=0;
              r1=st.executeQuery("select tb.*,(select product_name from ip_products where product_id=tb.product)prod,(select unit_name_plrl from ip_units where unit_id=tb.unit)runit,(select workcentername from workcenter where w_id=tb.workcenter)wc from bom_rawmaterial tb where type='R' and d1_id="+f_id+"");
            %> 
    
    
             
            
<table id="myTable" class="table table-bordered">
<tr>
<th>Components</th>
<th>Required&nbsp;Qty</th>
<th>Qty</th>
<th>Unit</th>
<!-- <th>Price</th> -->
<!-- <th>Edit</th>
<th>Delete</th> -->
</tr>
<tbody>
<tr>
 <%
 while(r1.next()){ 
 %>
 <td style="display:none;"> <input  id="id"  type="hidden" name="p_itemcode[]" value="<%=r1.getString("product")%>" class="form-control">  </td>
<td><input type="text" name="p_itemcode1[]" value="<%=r1.getString("prod")%>"> </td> 
<td> <input type="text" name="quantity[]" value="<%=r1.getString("quantity")%>"> </td>
<td> <input type="text" name="required_quantity[]"> </td>

<td> <input type="text" name="unit[]" value="<%=r1.getString("runit")%>"> </td>
<%-- <td>  <input type="text" name="price" value="<%=r1.getString("p_price")%>"> </td> --%>

<%-- <td> <a class="glyphicon glyphicon-pencil" href="editbom.jsp?id=<%=r1.getString("B_id")%>"></a> </td>
<td> <a href="deleteRowBOM.jsp?Id=<%=r1.getString("B_id")%>" onclick = "if (! confirm('Continue?')) { return false; }"><i class='glyphicon glyphicon-trash'></i></a> </td> --%>
     
</tr>
<%  j=j+1; } %>

</tbody>
</table>
</div>    
             

<div class="panel-body">
   <div class="col-md-12">

		<!-- 	<input type="submit" value="Save" style="background:#204b58" class="pull-right btn btn-info" onclick="validate()"> -->
   
<!--  <input type="submit" value="save" name="save" id="save"/>  -->
   <div id="output"> </div>
</div>
          <%        
          try
          {        	 
          String hsn = request.getParameter("hsn1");
          System.out.print(id);       
          
            String[] a=null;
        	String[] b=null;
        	String[] c=null;
        	String[] d=null;
            
        	a=request.getParameterValues("p_itemcode[]");
      	    b=request.getParameterValues("quantity[]");
      	    c=request.getParameterValues("required_quantity[]");
      	  d=request.getParameterValues("unit[]");
          
          
         /*  String p_itemcode= request.getParameter("p_itemcode");
          String quantity= request.getParameter("quantity");
          String required_quantity= request.getParameter("required_quantity");
          String unit = request.getParameter("unit");  */
          
          String workc = request.getParameter("workc"); 
          String price = request.getParameter("price");    
          String d_id=request.getParameter("did");

          String Ref_no=request.getParameter("rawm_id");
          System.out.print(workc);  
         
            /* if(p_itemcode!=null || p_itemcode.length()!=0 || p_itemcode!="")     */
             for(int x=0;x<=j;x++) 
              {   
              /* int l=  */st.executeUpdate("insert into bom_rawmaterial1(product,quantity,unit,type,workcenter,p_price,d1_id,fg_id,date,required_quantity)values('"+a[x]+"','"+c[x]+"','"+d[x]+"','R','"+workc+"','"+price+"','"+d_id+"','"+Ref_no+"','"+(new java.util.Date()).toLocaleString()+"','"+b[x]+"')");
              }
         }
         catch(Exception el){}     
          %>       
           </div>    
      <%--     <hr>  
       <div class="panel-body">
            <b>Components Details:</b>
            <%
             String p_HSN=null;
             String p_NMAE=null;String p_quentity=null;
             String p_UNIT=null;
             String p_WORKC=null;
             r1=st.executeQuery("select tb.*,(select unit_name_plrl from ip_units where unit_id=tb.unit)runit,(select workcentername from workcenter where w_id=tb.workcenter)wc from bom_rawmaterial1 tb where type='R' and d1_id="+f_id+"");
            %> 
         
          
<table id="myTable" class="table table-bordered">
<tr> 
 <th>Components</th>
 <th>Required Quantity</th>
 <th>Quantity</th>
 <th>Unit</th>
 <th>Price</th>   
 <th>Edit</th>
 <th>Delete</th>
</tr>                                                                
<tbody> 
<tr>
 <%
   while(r1.next()){
 %>

<td> <%=r1.getString("product")%> </td>
<td> <%=r1.getString("quantity")%> </td>
<td> <%=r1.getString("required_quantity")%> </td>

<td> <%=r1.getString("runit")%> </td>


<td><%= r1.getString("p_price")%> </td>
<td> <a class="glyphicon glyphicon-pencil" href="editbom_1.jsp?id=<%=r1.getString("B_id")%>"></a> </td>


<td> <a href="deleteRowBOM_1.jsp?Id=<%=r1.getString("B_id")%>" onclick = "if (! confirm('Continue?')) { return false; }"><i class='glyphicon glyphicon-trash'></i></a> </td>

</tr>
<% } %> 
   
</tbody>
</table>
</div>  --%>
        
       
     <div class="modal-footer" id="contact_submit">
        <input type="button" value="Back" style="background:#204b58;" class="btn btn-info pull-left"  onclick="goBack()"/>
        <input type="submit" value="Save" style="background:#204b58" class="pull-right btn btn-info" onclick="validate()">
			<!--<a class="btn btn-default" href="SalesInvoiceMain.jsp">Reset</a>
			<a style="background:#204b58" class="btn btn-info" onclick="validate();">Submit</a>-->
	 </div>     
       
  <!--       <div class="row" >
        <input type="button" value="Back" style="background:#204b58;margin-right:700px" class="btn btn-info" />&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<a class="btn btn-default" href="#"  style="margin-right:80px">Reset</a>
         <button type="submit" style="background:" class="" ></button>
       <a href="addbom.jsp"><input type="submit" value="submit"></a> 
      </div> -->
      </div>
 </div>                        
    </div>
  </div>
</div>       

</section>
</div>
<%@include file="footer.jsp" %>
</form>
<script>
$( document ).ready(function() {
	var s=0;
	s=$("#u").val();
	$("#unit").val(s);
});
</script>
<script type="text/javascript">
function goBack() {
    window.history.back();

};
</script>
</body>
</html>