Current File : //home/obabain/khb_obaba_in/CheckAvailability.jsp
<%@include file="master.jsp"%>
<%Statement st=con1.createStatement(); %>
<%!	int q1,q2;int str;int i2; String ty=null; String mid=null;	int i1;int id1;int sub; int id;String p_id,type,mocus_id, Scheduledate, Product, BillofMaterial, ProductQty, ResponsiblePerson, RawMaterialLocation, Locations,qun ,p2, p1;%>
<%
ResultSet rs=st.executeQuery("select * from manufacture_order where mo_id=(select max(mo_id) as mo_id from manufacture_order)");
while(rs.next()){
	mocus_id=rs.getString("mocus_id");

	Scheduledate=rs.getString("Scheduledate");
	Product=rs.getString("Product");
	BillofMaterial=rs.getString("BillofMaterial");
	ProductQty=rs.getString("ProductQty");
	i1=Integer.parseInt(ProductQty);
	ResponsiblePerson=rs.getString("ResponsiblePerson");
	RawMaterialLocation=rs.getString("RawMaterialLocation");
	Locations=rs.getString("Location");
	 p_id=rs.getString("p_id");
	 type=rs.getString("type");
	 mid=rs.getString("mo_id");
	 }
%>


<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>


<form 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">Manufacturing Order Form</h3>
								</div>
								<div class="onerow">
								<div class="btn">
					<!-- id="chkbutn" -->	
								<a  class="btn btn-danger " onclick = "abc()" id="showit" >Check Availability</a> <!--   -->
									
										<!-- <button  class="btn btn-danger " onclick=" abc()">Check Availability</button> -->
										
										<!--<button type="button" class="btn btn-primary">Cancel
											Production</button>
<a href="M_orderForm.jsp"><button type="button" class="btn btn-primary" style="margin-left: 297px;">NEW</button></a>
			<button type="button" class="btn btn-primary"style="margin-left: px;">Awaiting raw Material</button>							
    <button type="button" class="btn btn-primary">Production Start</button>
    <button type="button" class="btn btn-primary">Done</button>-->
								</div>
								</div>
								<div class="panel-body">

									<div class="row">
								<label for="lastname" style="margin-left: 11px;">manufacturing Order:</label> 
<input id="lastname" class="input-group-lg reg_name" value="<%=mocus_id %>" style="width: 170px;" type="text"name="address" placeholder="" />
&nbsp;&nbsp;&nbsp;&nbsp;
								
								&nbsp; 
	<label for="lastname" style="margin-left: 40px;">Schedule date:</label> 
	<input id="lastname" class=""  value="<%=Scheduledate %>" style="width: 170px; margin: px;" type="date" name="pincode" placeholder="" />
								
								<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: 90px;">Product:</label>			
	<input id="lastname"  value="<%=Product %>" style="width: 170px; margin: 5px;"	type="text" placeholder="" /> &nbsp; &nbsp; 
	
	
	<label for="lastname"	style="margin-left: 35px;">Bill of Material:</label> 
	<input	class=""  value="<%=BillofMaterial %>" style="width: 170px; margin: 5px;" name="contactperson" placeholder="" />




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



<label for="lastname" style="margin-left: 240px;">Product Qty</label> 
<input id="p" class="input-group-lg reg_name"  name="in" value="<%=ProductQty %>"  style="width: 170px; margin: 5px;" type="text" placeholder="" /> &nbsp;
										
										
<label for="firstname" style="margin: 5px;">Responsible Person</label> 
<input id="firstname" class=" " value="<%=ResponsiblePerson %>"  style="width: 170px; margin: 5px;" type="text"placeholder="" />


</div>
<div class="row">

	<label for="lastname" style="margin-left: 175px;">RawMaterial Location</label> <input id="qwe"
											class=" input-group-lg reg_name"
									 value="<%=RawMaterialLocation %>"		style="width: 170px; margin: 5px;" type="text"
											 name="cp" placeholder="" />

				&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 <label for="lastname" style="margin: 5px;">Location:</label>
 <input id="lastname" class=" input-group-lg reg_name"	value="<%=Locations %>" style="width: 170px; margin: 5px;" type="text" name="cl" placeholder="" />
									</div>
								
								<hr>
								<br>
								<div>
								<table class="table table-bordered" id="loader"> <!-- style="display:none;" -->
								<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*"+ProductQty+")qty,(case when ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))>((quantity*"+ProductQty+")) then 'black' else 'red' end) stat,(case when ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))>((quantity*"+ProductQty+")) 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 s=null;
								ResultSet rb1=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*"+ProductQty+")");
								if(rb1.next()){
									 s="Insufficient Stock";
								}
									else
									{
										 s="Stock is Available";
								}
									
								%>
								<input type="hidden" id="stock" name="stock" value="<%=s%>">
								</div>
								</div>
								<div class="inlineTable">
								<%-- <%
								ResultSet rb=st.executeQuery("select tb.hsn,tb.product,tb.fg_id from bom_rawmaterial tb where d1_id="+p_id+" and ((select product_qua from ip_products where product_id=tb.fg_id)+(select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))<(quantity*"+ProductQty+")");
								if(rb.next()){
									
								%>
          <a href="Produce.jsp" id="btnred"> <button type="button" class="btn btn-danger"style="margin-left:830px;">Ready to produce</button></a>  
          <%}
								else{
									%> --%>
									<a href="Produce.jsp" > <button type="button" id="btnblue" class="btn btn-primary"style="margin-left:830px;">Ready to produce</button></a> 
								
								<%-- <% }%> --%>
							                  
    </div>	
								</div>
								</div>
							
								
								</div>
								</div>
								</div>
								
								</section>
								</form>
								<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";
		}
	
		 
}
</script>

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

</script>



</body>