<?php
if(isset($_POST['Save']))
{
 $insert="insert into machine_production_capacity set branch_code='".$_REQUEST['site']."',group_code='".$_REQUEST['group']."',manufacturing_process='".$_REQUEST['manufac']."',interval_time='".$_REQUEST['interval']."',part_name='".$_REQUEST['partname']."',
machine_work_center='".$_REQUEST['machin_work']."',1st_rdg='".$_REQUEST['1st_rdg']."',2nd_rdg='".$_REQUEST['2nd_rdg']."',3rd_rdg='".$_REQUEST['3rd_rdg']."',4th_rdg='".$_REQUEST['4th_rdg']."',5nd_rdg='".$_REQUEST['5th_rdg']."',100_eff_qty='".$_REQUEST['100per_eff_qty']."',eff_per='".$_REQUEST['Eff_per']."'";	
$query=DB_query($insert,$db);
if($query)
{
$message="Records Save Sucessfully";	
}
}
?>
<h2 align="center"><strong>Machine Production Capacity </strong></h2>
<form method="post" action="">
<table width="50%" border="0" cellspacing="1" cellpadding="2" align="center" >
      <tr>
        <th><strong>Branch</strong></th>
        <td><select name="site" id="site" style="width:107px">
          <option value="">Select Site</option>
            <?php 
		$site_sql = "SELECT prefix,loccode, locationname from locations";
		$site_result = DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))
		{
		?>
         <option value="<?php echo $site_row['loccode']; ?>" ><?php echo $site_row['locationname']; ?></option>
            <?php } ?></select></td>    
           <th><strong>Manufacturing Process</strong></th>
        <td><select name="manufac" id="manufac" style="width:107px">
            <option value="0">Select Site</option>
            <?php 			
		$site_sql1 ="SELECT *  from production_process_master";
		$query11=DB_query($site_sql1,$db);
		while($site_row1 = DB_fetch_array($query11))
		{
		
		?>
            <option value="<?php echo $site_row1['id']; ?>" ><?php echo $site_row1['manuf_process_name']; ?></option>
            <?php } ?>
          </select></td>              
      </tr>
      <tr>
         <th><strong>Machine Work Center</strong></th>
        <td><select name="machin_work" id="machin_work" style="width:107px">
            <option value="0">Select Site</option>
            <?php 
			if($_SESSION['AssignedSites']!='0'){ 
		$site_sql = "SELECT prefix,loccode, locationname from locations where loccode in (".$_SESSION['AssignedSites'].")";}
		else
		{$site_sql = "SELECT prefix,loccode, locationname from locations";}
		$site_result = DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))
		{
		?>
            <option value="<?php echo $site_row['prefix']; ?>" <?php echo ($_REQUEST['site']==$site_row['prefix']?'selected':'')?>><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
          </select>        </td>
            <th><strong>Interval Time</strong></th>
        <td><input type="text" name="interval" id="interval"/></td>             
      </tr>
      <tr>
       <th><strong>1St Rdg</strong></th>
        <td><input type="text" name="1st_rdg" id="1st_rdg"/></td>
            <th><strong>2nd Rdg</strong></th>
        <td><input type="text" name="2nd_rdg" id="2nd_rdg" />      </td>               
      </tr>
      <tr>
       <th><strong>3Rd Rdg</strong></th>
        <td><input type="text" name="3rd_rdg" id="3rd_rdg"/></td>
            <th><strong>4th Rdg</strong></th>
        <td><input type="text" name="4th_rdg" id="4th_rdg"/>      </td>               
      </tr>
      <tr>
       <th><strong>5th Rdg</strong></th>
        <td><input type="text" name="5th_rdg" id="5th_rdg"/></td>
          <th><strong>100% Eff. Qty</strong></th>
        <td><input type="text" name="100per_eff_qty" id="100per_eff_qty"/></td>
       <tr>
        <th><strong>Eff.%</strong></th>
        <td><input type="text" name="Eff_per" id="Eff_per" />      </td>
        <th><strong>Choose</strong></th>
        <td>Group Wise<input type="radio" name="group" value="group"  />Item Wise<input type="radio" name="group" value="item" />      </td>               
      </tr>
      <tr>
       <th><strong>Part Name</strong></th>
        <td colspan="2"><select name="part_name" style="width:107px">
        	<option selected="0">---Select----</option>	
     <?php 
	$item_sql=DB_query("select StockID,item_name from item_master where CategoryID='FG'",$db);
	while($row3=DB_fetch_array($item_sql))
	{
   ?> 
    <option value="<?php echo $row3['StockID']; ?>"><?php echo $row3['item_name']; ?></option>    	
    <?php } ?>
    </select>    	             
      </tr>      
      
    </table>
    <p align="center"><input type="submit" name="Save" value="Save" onclick="return valid();" /></p>
    </form>
<div>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
    	        <tr>
	  <th scope="col">Branch Name </th>
	  <th scope="col">Manufacturing Process Name</th>
	  <th scope="col">Machine Work Center/th>
	  <th scope="col">Interval Time</th>
	  <th scope="col">1ST RDG</th>
	  <th scope="col">2ED RDG<br /></th>
	  <th scope="col">3RD RDG </th>
	  <th scope="col">4Th RDG</th>
	  <th scope="col">5ND RDG</th>
	  <th scope="col">100 Per Eff Qty</th>
	  <th scope="col">Eff Percentage</th>
	        </tr>	
	        <?php
	         $manu="select * from machine_production_capacity";
	        $manu_query=DB_query($manu,$db);
			while($row1=DB_fetch_array($manu_query))
			{				        
	        ?>
	          <tr>
	  <td scope="col">
	  	<?php 
	  	    $site_sql1=DB_query("Select loccode,locationname from locations where loccode='".$row1['branch_code']."'",$db);
			$row11=DB_fetch_array($site_sql1);
	  	echo $row11['locationname']; ?> </td>
	  <td scope="col">
	  	<?php 	  	 $sql5=DB_query("select * from production_process_master where id='".$row1['manufacturing_process']."'",$db);
	  $row12=DB_fetch_array($sql5);
	  	echo $row12['manuf_process_name']; ?></td>
	  <td scope="col">Machine Work Center</th>
	  <td scope="col"><?php echo $row1['interval_time']; ?></td>
	  <td scope="col"><?php echo $row1['1st_rdg']; ?></td>
	  <td scope="col"><?php echo $row1['2nd_rdg']; ?></td>
	  <td scope="col"><?php echo $row1['3rd_rdg']; ?></td>
	  <td scope="col"><?php echo $row1['4th_rdg']; ?></td>
	  <td scope="col"><?php echo $row1['5nd_rdg']; ?></td>
	  <td scope="col"><?php echo $row1['100_eff_qty']; ?></td>
	  <td scope="col"><?php echo $row1['eff_per']; ?></td>
	        </tr>	
	        <?php } ?>     
	        </table>
	
</div>	
	
<script language="JavaScript">
function valid()
{
if(document.getElementById("site").value==0)
{
alert("Must Select Site Name");
document.getElementById("site").focus();
return false;	
}
if(document.getElementById("manufac").value==0)
{
alert("Must Select Manufacturing Process");
document.getElementById("manufac").focus();
return false;	
}
if(document.getElementById("machin_work").value==0)
{
alert("Must Select Machine Work Center");
document.getElementById("machin_work").focus();
return false;	
}
if(document.getElementById("interval").value=='')
{
alert("Must Enter interval");
document.getElementById("interval").focus();
return false;	
}
if(document.getElementById("1st_rdg").value=='')
{
alert("Must Enter 1st_rdg");
document.getElementById("1st_rdg").focus();
return false;	
}
if(document.getElementById("2nd_rdg").value=='')
{
alert("Must Enter 2nd_rdg");
document.getElementById("2nd_rdg").focus();
return false;	
}
if(document.getElementById("3rd_rdg").value=='')
{
alert("Must Enter 3rd_rdg");
document.getElementById("3rd_rdg").focus();
return false;	
}
if(document.getElementById("4th_rdg").value=='')
{
alert("Must Enter 4th_rdg");
document.getElementById("4th_rdg").focus();
return false;	
}
if(document.getElementById("5th_rdg").value=='')
{
alert("Must Enter 5th_rdg");
document.getElementById("5th_rdg").focus();
return false;	
}
if(document.getElementById("Eff_per").value=='')
{
alert("Must Enter Eff_per");
document.getElementById("Eff_per").focus();
return false;	
}
if(document.getElementById("100per_eff_qt").value=='')
{
alert("Must Enter 100per_eff_qt");
document.getElementById("100per_eff_qt").focus();
return false;	
}
return true;	
}	
	
	
	
</script>



