<?php 
include 'aksi/functions.php';

$id = base64_decode($_GET["id"]);

$penjualan = mysqli_query($conn, "select * from penjualan where hilangbarang_id = $id");
$jmlPenjualan = mysqli_num_rows($penjualan);

if ( $jmlPenjualan < 1 ) {
	if( hapushilangbarang($id) > 0) {
		echo "
			<script>
				document.location.href = 'hilangbarang';
			</script>
		";
	} else {
		echo "
			<script>
				alert('Data gagal dihapus');
				document.location.href = 'hilangbarang';
			</script>
		";
	}
} else {
	echo "
		<script>
			alert('Data tidak bisa dihapus karena masih ada di data Invoice Penjualan');
			document.location.href = 'hilangbarang';
		</script>
	";
}

?>