
<?php
	include "../koneksi.php";
	
	$data = mysqli_query ($koneksi, " select	plan.PlanID,
												plan.DatePlan,
												plan.MesinID,
												mesin.Mesin,
												plan.ProductID,
												product.ItemDescription,
												product.SLoc,
												product.QtyUnit,
												plan.QtyPlan,
												plan.MaterialID,
												plan.Prioritas,
												material.RawMat,
												plan.POOR
										  from 
										  plan
										  INNER JOIN mesin
										  ON plan.MesinID=mesin.MesinID
										  INNER JOIN product
										  ON plan.ProductID=product.ProductID
										  INNER JOIN material
										  ON plan.MaterialID=material.MaterialID
									  	  where PlanID = $_POST[id]");
	$row = mysqli_fetch_array ($data);
	
?>
<form role="form" id="form-edit" method="post" action="update.php">
<table style="width: 100%; background-color: white;">
	<tr>
		<th width="20%">DATE PLAN
		<input type="hidden" name="plan_id" value="<?php echo $row['PlanID'] ; ?>">
		</th>
		<td><input type="text" class="input-tanggal" id="date_plan" name="date_plan" data-date-format="dd-mm-yy" value="<?php echo $row['DatePlan'] ; ?>">
			<p style="color:red" id="error_edit_date_plan"></p></td>
	</tr>
	<tr>
	<th>MESIN</th>
	<td><select id="mesin" name="mesin">
			<option value="<?php echo $row['MesinID'] ; ?>" selected><?php echo $row['Mesin'] ; ?></option>
			<?php 
			$data1 = mysqli_query ($koneksi, " select 
									MesinID,
									Mesin
								from 
								mesin 
								order by MesinID DESC");
			while ($row1 = mysqli_fetch_array ($data1))
			{
			?>
			<option value="<?php echo  $row1['MesinID']; ?>"><?php echo $row1['Mesin']; ?></option>
			<?php } ?>
		</select>
		<p style="color:red" id="error_edit_mesin"></p></td>
	</tr>
	<tr>
		<th>PRODUCT</th>
		<td><select id="product" name="product">
				<option value="<?php echo $row['ProductID'] ; ?>" selected><?php echo $row['ItemDescription']; ?> | <?php echo $row['SLoc']; ?> @ <?php echo $row['QtyUnit']; ?> pcs</option>
				<?php 
				$data2 = mysqli_query ($koneksi, " select 
										ProductID,
										ItemDescription,
										SLoc,
										QtyUnit
									from 
									product 
									order by ProductID DESC");
				while ($row2 = mysqli_fetch_array ($data2))
				{
				?>
				<option value="<?php echo  $row2['ProductID']; ?>"><?php echo $row2['ItemDescription']; ?> | <?php echo $row2['SLoc']; ?> @ <?php echo $row2['QtyUnit']; ?> pcs</option>
				<?php } ?>
			</select>
			<p style="color:red" id="error_edit_product"></p></td>
	</tr>
	<tr>
		<th>MATERIAL</th>
		<td>
		<select id="material" name="material">
				<option value="<?php echo $row['MaterialID'] ; ?>" selected><?php echo $row['RawMat']; ?></option>
				<?php 
				$data3 = mysqli_query ($koneksi, " select 
										MaterialID,
										RawMat
									from 
									material 
									order by MaterialID DESC");
				while ($row3 = mysqli_fetch_array ($data3))
				{
				?>
				<option value="<?php echo  $row3['MaterialID']; ?>"><?php echo $row3['RawMat']; ?></option>
				<?php } ?>
			</select>
			<p style="color:red" id="error_edit_material"></p>
		</td>
	</tr>
	<tr>
		<th>QUANTITY</th>
		<td>
			<input id="qty" name="qty" value="<?php echo $row['QtyPlan'] ; ?>">
			<p style="color:red" id="error_edit_qty"></p>
		</td>
	</tr>
	<tr>
		<th>PRIORITAS</th>
		<td>
			<input id="prioritas" name="prioritas" value="<?php echo $row['Prioritas'] ; ?>">
			<p style="color:red" id="error_edit_prioritas"></p>
		</td>
	</tr>
	<tr>
		<th>POOR</th>
		<td>
			<input id="poor" name="poor" value="<?php echo $row['POOR'] ; ?>">
			<p style="color:red" id="error_prioritas"></p>
		</td>
	</tr>
</table>
			
</form>
