Current File : /home/obabain/anms_obaba_in/ViewProduce.jsp
<%@page import="java.sql.Statement"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ include file="Connection.jsp" %>


<%@include file="master.jsp"%>

 <%
String count=null;String id=null;String sys_id=null;int i; String s=null;

Statement st1=con.createStatement();
ResultSet rs = null;
rs = st1.executeQuery("select tb.*,(select concat(Prefix,MO_Id))codes from system_generated_id tb");
while(rs.next()){
count=rs.getString("codes");
id=rs.getString("MO_Id");
i=Integer.parseInt(id)+1;
 s=String.valueOf(i);
 if(s.length()==1)
 {
	 sys_id="00"+s;
 }
 else{
	 sys_id="0"+s;
 }
 
	 System.out.println(count);
}

//st.executeUpdate("INSERT INTO manufacture_order(mocus_id)VALUES('"+count+"');");

 
%>


<% 
/* 
String sh_date=request.getParameter("sh_date");
String product=request.getParameter("product");
System.out.print(product);
String bom=request.getParameter("bom");
String proqty=request.getParameter("pro_qty");
String res=request.getParameter("resperson");
String raw=request.getParameter("loc");
String raw1=request.getParameter("loc1");
String p_id=request.getParameter("p_id");

String machinname=request.getParameter("machinname");
String machin_capacity=request.getParameter("machin_capacity");
String type=request.getParameter("type"); */
/* String uname=request.getParameter("inputname"); 
 */
/*  String name=(String)session.getAttribute("sessname"); 
 */
 
 
 String sh_date=(String)session.getAttribute("sh_date"); 
 String product=(String)session.getAttribute("product"); 
 String bom=(String)session.getAttribute("bom"); 
 String proqty=(String)session.getAttribute("pro_qty"); 
 String res=(String)session.getAttribute("res"); 
 String raw=(String)session.getAttribute("raw"); 
 String raw1=(String)session.getAttribute("raw1"); 
 String p_id=(String)session.getAttribute("p_id"); 
 String machinname=(String)session.getAttribute("machinname"); 
 String machin_capacity=(String)session.getAttribute("machin_capacity"); 
 String type=(String)session.getAttribute("type"); 
 
 
 
 
 
 %>


<style type="text/css">
.highlight-error {
	border-color: red;
}
table, th, td {
    border: 1px solid black;
   
}

.inlineTable {
            display: inline-block;
        }

.panel-default>.panel-heading-custom {
	background: #ff0000;
	color: #fff;
}
</style>
<!-- <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">-->
<script
	src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<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>

<body onload="abc()">
<%Statement st=con1.createStatement(); %>
<%-- <%!	int i2;	int i1;int id1;int sub; int id;String mocus_id, Scheduledate, Product, BillofMaterial, ProductQty, ResponsiblePerson, RawMaterialLocation, Locations; %>
<%
ResultSet rs123=st.executeQuery("select max(mo_id) as mo_id from manufacture_order");
while(rs123.next()){
	id=rs123.getInt("mo_id");
}
%>
<%
ResultSet rs=st.executeQuery("select * from manufacture_order where mo_id='"+id+"'");
while(rs.next()){

	Product=rs.getString("Product");
	ProductQty=rs.getString("ProductQty");
	i1=Integer.parseInt(ProductQty);
}
%>
 --%>
<!-- Start -->


<%-- <%!	int q1,q2;int str; String ty=null; String mid=null;String p_id,type,qun ,p2, p1;%>
<%
ResultSet rs1=st.executeQuery("select * from manufacture_order where mo_id=(select max(mo_id) as mo_id from manufacture_order)");
while(rs1.next()){
	mocus_id=rs1.getString("mocus_id");
	Scheduledate=rs1.getString("Scheduledate");
	Product=rs1.getString("Product");
	BillofMaterial=rs1.getString("BillofMaterial");
	ProductQty=rs1.getString("ProductQty");
	i1=Integer.parseInt(ProductQty);
	ResponsiblePerson=rs1.getString("ResponsiblePerson");
	RawMaterialLocation=rs1.getString("RawMaterialLocation");
	Locations=rs1.getString("Location");
	 p_id=rs1.getString("p_id");
	 type=rs1.getString("type");
	 mid=rs1.getString("mo_id");
	 }
%>
 --%>
<!--  End-->

	<div class="row">
		<form  action="addproduce.jsp"  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">Produce</h3>
								</div>




				
								
								

								<div class="panel-body">
                      	
								
									<div class="row">

										
                   
	<label for="lastname" style="margin-left: 5px;">Produce&nbsp;Product:</label>
	<input id="lastname" class=""  style="width:170px;margin:5px; type="text" value="<%=product%>"
                       title="Enter last name"  name="contactperson"  placeholder=""/> &nbsp; &nbsp; 
                       






										


										<div class="form-group col-xs-2">
											<p>
												<label for="lastname" style="margin: 5px;"> </label>
											</p>	</div>	</div>


									



									<div class="row">


							<label for="lastname" style="margin-left: 11px;">Product Quantity:</label> 
<input id="lastname" class=""  style="width:170px;margin:5px; type="text" value="<%=proqty%>"
                       title="Enter last name"  name="contactperson"  placeholder=""/> &nbsp; &nbsp; 




										<div class="form-group col-xs-2">
											<p>
												<label for="firstname" style="margin: 5px;"></label>
											</p>
										</div>	</div>


									


									
                                  
   
  
                                   
                                   
                                  		<div>
						
					<br><br>
								<table class="table table-bordered" > 
								<thead>
								<tr>
								<th>HSN</th>
								<th>Product</th>
								<th>Required Qty</th>
								<th>Available Qty</th>
								<th>Stock Status</th>
								</tr>
								</thead>
								<tbody>
								<%
								ResultSet rq=st.executeQuery("select tb.hsn,tb.product,tb.fg_id, (quantity*"+proqty+")qty,(case when ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))>((quantity*"+proqty+")) then 'black' else 'red' end) stat,(case when ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))>((quantity*"+proqty+")) then 'Stock is available' else 'Insufficient Stock' end)stock,((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))avl from bom_rawmaterial tb where d1_id="+p_id+"");
								while(rq.next())
								{
								%>
								<tr>
								<td><%=rq.getString("hsn") %></td>
								<td><%=rq.getString("product") %></td>
								<td><%=rq.getString("qty") %></td> 
								<td><span style="color:<%=rq.getString("stat")%>;"><%=rq.getString("avl") %></span></td>
								<td><span style="color:<%=rq.getString("stat")%>;"><%=rq.getString("stock") %></span></td>
								</tr>
								<%} %>
								</tbody>
								</table>
								<div>
								<%
								String s1=null;
								ResultSet rb12=st.executeQuery("select tb.hsn,tb.product,tb.fg_id from bom_rawmaterial tb where d1_id="+p_id+" and ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))<(quantity*"+proqty+")");
								if(rb12.next()){
									 s1="Insufficient Stock";
								}
									else
									{
										 s1="Stock is Available";
								}
									
								%>
								<input type="hidden" id="stock" name="stock" value="<%=s1%>">
								</div>
											
								
								
								
								
								
								</div>  
								
		<%--  <%  
		
		  try{
		 if(proqty.length()!=0)
	      {
			
	st.executeUpdate("insert into manufacture_order(mocus_id,Scheduledate,Product,BillofMaterial,ProductQty,ResponsiblePerson,RawMaterialLocation,Location,p_id,machinname,machin_capacity,type)values('"+count+"','"+sh_date+"','"+product+"','"+bom+"','"+proqty+"','"+res+"','"+raw+"','"+raw1+"','"+p_id+"','"+machinname+"','"+machin_capacity+"','"+type+"')");
	    
	      st.executeUpdate("update system_generated_id set MO_Id='"+sys_id+"'"); 
	
	      }
	      
	      }catch(Exception el){out.println(el);}
	      %> 
	
	
	
<%  	%>						
				 	 --%>			
								
								                    
                                
              <div class="inlineTable" >
 
 
 <input type="hidden" class="btn btn-danger" onclick = "abc()" id="showit" >
  
 <a href="ProductionOrder.jsp" > <button type="submit" id="btnblue" class="btn btn-primary"style="margin-left:350px;">Confirm</button></a> 
 
 
 
 &nbsp;&nbsp; &nbsp;<button type="button" class="btn btn-primary"style="margin-left:px;">cancel</button>                   
          </div>                  
                                           
        						
						</div>
					</div>
				</div>
	</div>
	
	</section>

	<script src="http://cdn.ckeditor.com/4.6.1/standard/ckeditor.js"></script>
	<script src="http://cdn.ckeditor.com/4.6.1/standard/ckeditor.js"></script>

	<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
	<script
		src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
	<script
		src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
	<script
		src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
		
		
		
		
			<script type="text/javascript">

								function abc() {
	
	
									var n1=document.getElementById("stock").value;
	
									var n2=document.getElementById("btnblue");
	
									var n3=document.getElementById("showit");

									alert(n1);
/* 	if (n3.style.display === "none") {
		n3.style.display = "block";
    } else {
    	n3.style.display = "none";
    }
	 */
	
	
	
	 if(n1=='Insufficient Stock')
		{
		
		 n2.style.backgroundColor = "#d43f3a";
	n2.style.borderColor="#d43f3a";
	 n3.style.backgroundColor ="#2e6da4";
	n3.style.borderColor="#2e6da4"; 
	 n2.disabled = true;
		}
	  else
		{
		n2.style.backgroundColor = "#2e6da4";
		n2.style.borderColor="#2e6da4";
		n3.style.backgroundColor ="#d43f3a";
		n3.style.borderColor="#d43f3a";
		n3.disabled=true;
				}
	
 	 
}
</script>

<script type="text/javascript">
$(function(){
    $("#loader").css("display","none");
    
    $("#showit").click(function(e){
      $("#loader").css("display","inline-block");
    })
})

</script>
		

	</form>
	</div>
</body>
</html>