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

	if (isset($_GET['prod_id']) && isset($_GET['prod_mat'])) {
		$date = date('Y-m-d');
		$data1 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1)) {
			$row1 = mysqli_fetch_array($data1);
			$beginPlan = $row1['QtyPlan'];	
		} else {
		$beginPlan = 0;
		}
		

		$date2 = date('Y-m-d', strtotime("+1 day"));
		$data1day2 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date2' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1day2)>0) {
			$row1day2 = mysqli_fetch_array($data1day2);	
			$planDay2 = $row1day2['QtyPlan'];
		} else {
		$planDay2 = 0;
		}	

		$date3 = date('Y-m-d', strtotime("+2 day"));
		$data1day3 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date3' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1day3)>0) {
				$row1day3 = mysqli_fetch_array($data1day3);
				$planDay3 = $row1day3['QtyPlan'];
		} else {
			$planDay3 = 0;
		}
		

		$date4 = date('Y-m-d', strtotime("+3 day"));
		$data1day4 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date4' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");	
		if (mysqli_num_rows($data1day4)>0) {
			$row1day4 = mysqli_fetch_array($data1day4);
			$planDay4 = $row1day4['QtyPlan'];	
		} else {
		$planDay4 = 0;
		}

		$date5 = date('Y-m-d', strtotime("+4 day"));
		$data1day5 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date5' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1day5)>0) {
			$row1day5 = mysqli_fetch_array($data1day5);	
			$planDay5 = $row1day5['QtyPlan'];	
		} else {
		$planDay5 = 0;
		}

		$date6 = date('Y-m-d', strtotime("+5 day"));
		$data1day6 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date6' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1day6)>0) {
			$row1day6 = mysqli_fetch_array($data1day6);	
			$planDay6 = $row1day6['QtyPlan'];
		} else {
		$planDay6 = 0;
		}
		
		
		$date7 = date('Y-m-d', strtotime("+6 day"));
		$data1day7 = mysqli_query ($koneksi, " select sum(QtyPlan) as QtyPlan,
										  POOR
										  from 
										  plan
									  	  where DatePlan = '$date7' AND ProductID='$_GET[prod_id]' AND MaterialID='$_GET[prod_mat]'");
		if (mysqli_num_rows($data1day7)>0) {
			$row1day7 = mysqli_fetch_array($data1day7);	
			$planDay7 = $row1day7['QtyPlan'];	
		} else {
			$planDay7 = 0;
		} 

		} else {
			$beginPlan = 0;
			$planDay2 = 0;
			$planDay3 = 0;
			$planDay4 = 0;
			$planDay5 = 0;
			$planDay6 = 0;
			$planDay7 = 0;
		}

		if (isset($_GET['prod_id']) && isset($_GET['prod_mat'])) {
		$data2 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2)>0) {
			$row2 = mysqli_fetch_array ($data2);
			$beginDelivery = $row2['jmlKirim'];	
		} else {
			$beginDelivery = 0;
		}

		$data2day2 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date2' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day2)>0) {
			$row2day2 = mysqli_fetch_array ($data2day2);
			$DeliveryDay2 = $row2day2['jmlKirim'];	
		} else {
			$DeliveryDay2 = 0;
		}

		$data2day3 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date3' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day3)>0) {
			$row2day3 = mysqli_fetch_array ($data2day3);
			$DeliveryDay3 = $row2day3['jmlKirim'];	
		} else {
			$DeliveryDay3 = 0;
		}
		
		$data2day4 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date4' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day4)>0) {
			$row2day4 = mysqli_fetch_array ($data2day4);
			$DeliveryDay4 = $row2day4['jmlKirim'];	
		} else {
			$DeliveryDay4 = 0;
		}

		$data2day5 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date5' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day5)>0) {
			$row2day5 = mysqli_fetch_array ($data2day5);
			$DeliveryDay5 = $row2day5['jmlKirim'];	
		} else {
			$DeliveryDay5 = 0;
		}

		$data2day6 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date6' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day6)>0) {
			$row2day6 = mysqli_fetch_array ($data2day6);
			$DeliveryDay6 = $row2day6['jmlKirim'];	
		} else {
			$DeliveryDay6 = 0;
		}

		$data2day7 = mysqli_query ($koneksi, " SELECT deliverytbl.Del_ID,
												deliverytbl.DateKirim,
												deliverytbl.DetailPO_ID,
												detail_po.ProductID,
												sum(deliverytbl.QtyKirim) AS jmlKirim
										FROM deliverytbl
										INNER JOIN detail_po
 										on deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
									  	where DateKirim = '$date7' AND ProductID='$_GET[prod_id]'");
		if (mysqli_num_rows($data2day7)>0) {
			$row2day7 = mysqli_fetch_array ($data2day7);
			$DeliveryDay7 = $row2day7['jmlKirim'];	
		} else {
			$DeliveryDay7 = 0;
		}
		
		} else {
			$beginDelivery = 0;
			$DeliveryDay2 = 0;
			$DeliveryDay3 = 0;
			$DeliveryDay4 = 0;
			$DeliveryDay5 = 0;
			$DeliveryDay6 = 0;
			$DeliveryDay7 = 0;
		}

		if (isset($_GET['prod_id']) && isset($_GET['prod_mat'])) {
				$data = mysqli_query ($koneksi, " SELECT sum(stpj.Qty) as jml,
												product.ItemDescription,
												product.QtyUnit,
												product.Gram,
												material.RawMat
										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 product.ProductID='$_GET[prod_id]' AND material.MaterialID='$_GET[prod_mat]'
										GROUP BY material.MaterialID, plan.ProductID");
		

				$row = mysqli_fetch_array ($data); 
				$beginStock = $row['jml'];
				$mupDay1 = ($beginPlan*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay2 = ($planDay2*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay3 = ($planDay3*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay4 = ($planDay4*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay5 = ($planDay5*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay6 = ($planDay6*$row['QtyUnit']*$row['Gram'])/1000000;
				$mupDay7 = ($planDay7*$row['QtyUnit']*$row['Gram'])/1000000;
			} else {
				$beginStock = 0;
				$mupDay1 = 0;
				$mupDay2 = 0;
				$mupDay3 = 0;
				$mupDay4 = 0;
				$mupDay5 = 0;
				$mupDay6 = 0;
				$mupDay7 = 0;
			}

			$day1end = $beginStock + $beginPlan - $beginDelivery;
			$day2end = $day1end + $planDay2 - $DeliveryDay2;
			$day3end = $day2end + $planDay3 - $DeliveryDay3;
			$day4end = $day3end + $planDay4 - $DeliveryDay4;
			$day5end = $day4end + $planDay5 - $DeliveryDay5;
			$day6end = $day5end + $planDay6 - $DeliveryDay6;
			$day7end = $day6end + $planDay7 - $DeliveryDay7;

			

			if (isset($_GET['mat_id'])) {
				$data4 = mysqli_query ($koneksi, " SELECT
										incoming.MaterialID,
										material.RawMat,
										sum(material.Qty) AS Qty
										FROM pbb
										INNER JOIN incoming
										ON pbb.IncomingID=incoming.IncomingID
										INNER JOIN material
										ON incoming.MaterialID=material.MaterialID
										WHERE PlanID IS NULL AND material.MaterialID='$_GET[mat_id]'");
		

				$row4 = mysqli_fetch_array ($data4);
				$beginStockRM = $row4['Qty'];
				$RMDay1 = ($beginStockRM/1000) - $mupDay1;
				$RMDay2 = $RMDay1 - $mupDay2;
				$RMDay3 = $RMDay2 - $mupDay3;
				$RMDay4 = $RMDay3 - $mupDay4;
				$RMDay5 = $RMDay4 - $mupDay5;
				$RMDay6 = $RMDay5 - $mupDay6;
				$RMDay7 = $RMDay6 - $mupDay7;
			} else {
				$beginStockRM = 0;
				$RMDay1 = ($beginStockRM/1000) - $mupDay1;
				$RMDay2 = $RMDay1 - $mupDay2;
				$RMDay3 = $RMDay2 - $mupDay3;
				$RMDay4 = $RMDay3 - $mupDay4;
				$RMDay5 = $RMDay4 - $mupDay5;
				$RMDay6 = $RMDay5 - $mupDay6;
				$RMDay7 = $RMDay6 - $mupDay7;
			}

			
		
?>
<div class="row">
<div class="col-md-6">
<div class="form-group">
	<button type="button" class="btn btn-primary" id="simulasi"><i class="bi bi-plus-square"></i>&ensp;Setting Simulasi</button>
	
</div>

</div>
<div class="col-md-6">
	 <nav>
    <ol class="breadcrumb">
		<li class="breadcrumb-item">Dashbard</li>
        <li class="breadcrumb-item">Table Simulasi</li>
    </ol>
</nav>
</div>
</div>
<div style="width:100%;height100px;overflow:scroll;" >

<table class="table table-bordered">
        <thead>
		<tr>
			<?php if(isset($_GET['prod_id']) && isset($_GET['prod_mat'])) { ?>
			<th colspan=4><?php echo $row['ItemDescription']; ?></th>
			<th colspan=4><?php echo $row['RawMat']; ?></th>
			<?php } ?>
		</tr>
		<tr>
			<th>
				Date
			</th>
			<td>
				<?php date_default_timezone_set('Asia/Jakarta'); 
				 echo date('d.m.Y'); ?>
			</td>
			<td>
			    <?php echo date('d.m.Y', strtotime("+1 day")); ?>
			</td>
			<td>
				<?php echo date('d.m.Y', strtotime("+2 day")); ?>
			</td>
			<td>
				<?php echo date('d.m.Y', strtotime("+3 day")); ?>
			</td>
			<td>
				<?php echo date('d.m.Y', strtotime("+4 day")); ?>
			</td>
			<td>
				<?php echo date('d.m.Y', strtotime("+5 day")); ?>
			</td>
			<td>
				<?php echo date('d.m.Y', strtotime("+6 day")); ?>
			</td>
		</tr>
		<tr>
			<th>
				Hari
			</th>
			<td>
				<?php
				$tanggal = date('d.m.Y');
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+1 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+2 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+3 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+4 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+5 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
			<td>
			<?php
				$tanggal = date('d.m.Y', strtotime("+6 day"));
				$day = date('D', strtotime($tanggal));
				$dayList = array(
					'Sun' => 'Minggu',
					'Mon' => 'Senin',
					'Tue' => 'Selasa',
					'Wed' => 'Rabu',
					'Thu' => 'Kamis',
					'Fri' => 'Jumat',
					'Sat' => 'Sabtu'
				);
				echo $dayList[$day]; ?>
			</td>
		</tr>
		<tr>
			<th>
				Begin Stock
			</th>
			<td>
				<?php echo $beginStock;  ?>
			</td>
			<td>
				<?php echo $day1end; ?>
			</td>
			<td>
				<?php echo $day2end; ?>
			</td>
			<td>
				<?php echo $day3end; ?>
			</td>
			<td>
				<?php echo $day4end; ?>
			</td>
			<td>
				<?php echo $day5end; ?>
			</td>
			<td>
				<?php echo $day6end; ?>
			</td>
		</tr><?php
		
	    ?>
		<tr>
			<th>
				Plan
			</th>
			<td>
				<?php echo $beginPlan; ?>
			</td>
			<td>
				<?php echo $planDay2; ?>
			</td>
			<td>
				<?php echo $planDay3; ?>
			</td>
			<td>
				<?php echo $planDay4; ?>
			</td>
			<td>
				<?php echo $planDay5; ?>
			</td>
			<td>
				<?php echo $planDay6; ?>
			</td>
			<td>
				<?php echo $planDay7; ?>
			</td>
		</tr>
		<tr>
			<th>
				Delivery
			</th>
			<td>
				<?php echo $beginDelivery; ?>
			</td>
			<td>
				<?php echo $DeliveryDay2; ?>
			</td>
			<td>
				<?php echo $DeliveryDay3; ?>
			</td>
			<td>
				<?php echo $DeliveryDay4; ?>
			</td>
			<td>
				<?php echo $DeliveryDay5; ?>
			</td>
			<td>
				<?php echo $DeliveryDay6; ?>
			</td>
			<td>
				<?php echo $DeliveryDay7; ?>
			</td>
		</tr>
		<tr>
			<th>
				End Stock
			</th>
			<td>
				<?php echo $day1end; ?>
			</td>
			<td>
				<?php echo $day2end; ?>
			</td>
			<td>
				<?php echo $day3end; ?>
			</td>
			<td>
				<?php echo $day4end; ?>
			</td>
			<td>
				<?php echo $day5end; ?>
			</td>
			<td>
				<?php echo $day6end; ?>
			</td>
			<td>
				<?php echo $day7end; ?>
			</td>
		</tr>
		<tr>
			<th>
				POOR
			</th>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day2['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day3['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day4['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day5['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day6['POOR'];
				}
				?>
			</td>
			<td>
				<?php if (isset($_GET['prod_id'])) {
					echo $row1day7['POOR'];
				}
				?>
			</td>
		</tr>
		<tr>
			<?php if(isset($_GET['mat_id'])) { ?>
			<th colspan=8><?php echo $row['RawMat']; ?></th>
			<?php } ?>
		</tr>
		<tr>
			<th>
				M U P
			</th>
			<td>
				<?php echo $mupDay1; ?>
			</td>
			<td>
				<?php echo $mupDay2; ?>
			</td>
			<td>
				<?php echo $mupDay3; ?>
			</td>
			<td>
				<?php echo $mupDay4; ?>
			</td>
			<td>
				<?php echo $mupDay5; ?>
			</td>
			<td>
				<?php echo $mupDay6; ?>
			</td>
			<td>
				<?php echo $mupDay7; ?>
			</td>
		</tr>
		<tr>
			<th>
				End Stock RM
			</th>
			<td>
				<?php echo $RMDay1; ?>
			</td>
			<td>
				<?php echo $RMDay2; ?>
			</td>
			<td>
				<?php echo $RMDay3; ?>
			</td>
			<td>
				<?php echo $RMDay4; ?>
			</td>
			<td>
				<?php echo $RMDay5; ?>
			</td>
			<td>
				<?php echo $RMDay6; ?>
			</td>
			<td>
				<?php echo $RMDay7; ?>
			</td>
		</tr>
		
	</table>

</div>

<div id="modal-simulasi" class="modal fade" role="dialog">
		<div class="modal-dialog modal-md">
			<div class="modal-content">
				<form role="form" id="form-edit" method="post" action="link_simulasi.php" autocomplete="off">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">&times;</button>
					<h4 class="modal-title">Setting Simulasi</h4>
				</div>
					<div class="modal-body">
					<div class="form-group">
						<label>Pilih Product</label>
						<select class="form-control" id="prod_id" name="prod_id">
							<option selected></option>
							<?php 
							$data = mysqli_query ($koneksi, " SELECT * FROM product");
							while ($row = mysqli_fetch_array ($data))
							{
							?>
							<option value="<?php echo  $row['ProductID']; ?>"><?php echo $row['ItemDescription']; ?> | <?php echo $row['SLoc']; ?> @ <?php echo $row['QtyUnit']; ?> PCS</option>
							<?php } ?>
						</select>
					</div>
					<div id="container"></div>
					<div class="form-group">
						<label>Pilih Material</label>
						<select class="form-control" id="mat_id" name="mat_id">
							<option selected>Pilih Product</option>
							<?php 
							$data2 = mysqli_query ($koneksi, " SELECT * FROM material");
							while ($row2 = mysqli_fetch_array ($data2))
							{
							?>
							<option value="<?php echo  $row2['MaterialID']; ?>"><?php echo $row2['NoMat']; ?> | <?php echo $row2['RawMat']; ?></option>
							<?php } ?>
						</select>
					</div>
				</div>
					<div class="modal-footer">
          <button type="button" class="btn btn-info" data-dismiss="modal">Batal</button>
						<button type="submit" class="btn btn-primary" >Simpan</button>
					</div>
				</form>		
			</div>
		</div>
	</div>

<link rel="stylesheet" type="text/css" href="../style/jquery-ui.css">
<script type="text/javascript" src="../style/jquery-ui.js"></script>
	<script>
    $(document).ready(function(){
		$('.input-tanggal').datepicker({
			dateFormat: 'yy-mm-dd'
		});		
	});	

	$('#prod_id').on('change', function(){
		$.get('things.php?id=' + $('#prod_id').val(), function(data) {
				//fungsi eksekusi func. Ajax
				$('#container').html(data);
		});
	  });
	  
	 $(document).on('click','#simulasi',function(e){
		e.preventDefault();
		$("#modal-simulasi").modal('show');
	});
	
    </script>

