<?php
include "../koneksi.php";

$data = mysqli_query ($koneksi, " SELECT 
										stpj.STPJ_ID
                    FROM stpj 
                    INNER JOIN plan
                    ON stpj.PlanID=plan.PlanID
                    INNER JOIN product
                    ON plan.ProductID=product.ProductID
                    INNER JOIN material
                    ON plan.MaterialID=material.MaterialID
	  where stpj.Del_ID IS NULL AND plan.ProductID='$_GET[prod_id]' AND plan.MaterialID='$_GET[mat_id]' AND DATE_FORMAT(plan.DatePlan, '%y%m')='$_GET[date_plan]'
                    Order BY product.ProductID ,plan.DatePlan, material.MaterialID ASC");


$hitung = mysqli_num_rows($data);

	for( $i=0; $i < $hitung; $i++ )
{
	$row = mysqli_fetch_assoc($data);
	$id = $row['STPJ_ID'];
	echo $id;
	$query = "UPDATE stpj SET `Lock`='0' WHERE stpj.STPJ_ID='$id'";
			mysqli_query($koneksi, $query)
			or die ("Gagal Perintah SQL".mysql_error());
}

header('Location:../index.php?switch=stok');

?>

