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

   if (isset($_POST['submit'])) {
      $query = "UPDATE deliverytbl SET
                          DateKirim = '$_POST[date_kirim]',
                          NoDN = '$_POST[no_dn]',
                          Arrival_Time = '$_POST[arr_time]',
                          Expedisi = '$_POST[item_desc1]',
                          Cont = '$_POST[item_desc2]',
                          Seal = '$_POST[item_desc3]'
                          WHERE Del_ID = '$_POST[del_id]'
                          ";

      mysqli_query($koneksi, $query)
      or die ("Gagal Perintah SQL".mysql_error());
  }

?>
<style type="text/css">
</style>
<div class="row">
  <div class="col-md-3"></div>
  <div class="col-md-6">
  <div class="row">
    <div class="col-md-11">
    <div class="pagetitle">
  	<h3>DELIVERY NUMBER</h3>
    </div>
    </div><div class="col-md-1">
    <a onclick="myFunction()" style="color: #00008B; font-size: 25px;" ><i class="bi bi-printer-fill"></i></a>
    </div></div>
  <?php 
        $data = mysqli_query ($koneksi, " select 
                              deliverytbl.Del_ID,
                              deliverytbl.DateKirim,
                              deliverytbl.DetailPO_ID,
                              deliverytbl.Arrival_Time,
                              deliverytbl.Expedisi,
                              deliverytbl.Cont,
                              deliverytbl.Seal,
                              detail_po.PO_ID,
                              po_tbl.No_PO,
                              po_tbl.CustomerID,
                              customer.CustomerName,
                              detail_po.ProductID,
                              product.Material,
                              product.ItemDescription,
                              product.SLoc,
                              product.QtyUnit,
                              deliverytbl.DetailEkspedisi_ID,
                              detailekspedisi.EkspedisiID,
                              ekspedisi.Ekspedisi,
                              detailekspedisi.Sopir,
                              detailekspedisi.NoPolisi,
                              detailekspedisi.NoHP,
                              deliverytbl.NoDN,   
                              deliverytbl.QtyKirim    
                      from 
                      deliverytbl
                      INNER JOIN detail_po
                      ON deliverytbl.DetailPO_ID=detail_po.DetailPO_ID
                      INNER JOIN po_tbl
                      ON detail_po.PO_ID=po_tbl.PO_ID
                      INNER JOIN customer
                      ON po_tbl.CustomerID=customer.CustomerID
                      INNER JOIN product
                      ON detail_po.ProductID=product.ProductID
                      INNER JOIN detailekspedisi
                      ON deliverytbl.DetailEkspedisi_ID=detailekspedisi.DetailEkspedisi_ID
                      INNER JOIN ekspedisi
                      ON detailekspedisi.EkspedisiID=ekspedisi.EkspedisiID
                      WHERE Del_ID ='$_GET[id]'");
        
        while($row = mysqli_fetch_array ($data)):
      ?>
   <table class="table">
    <tr style="font-weight: bold" >
   		<td>Delivery Memo  :</td>
   		<td><?php echo $row['CustomerName']; ?></td>
   	</tr>
    <form action="" method="POST" autocomplete="off">
    <input type="hidden" name="del_id" id="del_id" value="<?php echo $row['Del_ID']; ?>">
    <tr>
   		<td>Tanggal Kirim  :</td>
   		<td><input type="text" class="input-tanggal form-control" id="date_kirim" name="date_kirim" data-date-format="d-M-Y" value="<?php echo $row['DateKirim']; ?>" ></td>
   	</tr>
    <tr>
      <td>Nomor DN  :</td>
      <td><input class="form-control" aria-label="Small" id="no_dn" name="no_dn" value="<?php echo $row['NoDN']; ?>"></td>
    </tr>
    <tr>
      <td>Product Name  :</td>
      <td style="font-weight: bold"><?php echo $row['Material']; ?> - <?php echo $row['ItemDescription']; ?></td>
    </tr>
    <tr>
      <td>Nomor PO  :</td>
      <td style="font-weight: bold"><?php echo $row['No_PO']; ?></td>
    </tr>
    <tr>
      <td>Arrival Time  :</td>
      <td><input class="form-control" aria-label="Small" id="arr_time" name="arr_time" value="<?php echo $row['Arrival_Time']; ?>"></td>
    </tr>
    <tr>
      <td>Description 1  :</td>
      <td><input class="form-control" aria-label="Small" id="item_desc1" name="item_desc1" value="<?php echo $row['Expedisi']; ?>" ></td>
    </tr>
    <tr>
      <td>Description 2  :</td>
      <td><input class="form-control" aria-label="Small" id="item_desc2" name="item_desc2" value="<?php echo $row['Cont']; ?>"></td>
    </tr>
    <tr>
      <td>Description 3  :</td>
      <td><input class="form-control" aria-label="Small" id="item_desc3" name="item_desc3" value="<?php echo $row['Seal']; ?>" ></td>
    </tr>  
    </table>
   	<?php endwhile; ?>
   <input style="margin-top: 10px;" class="btn btn-success btn-block" type="submit" name="submit" value="Simpan"></input>
  </form>
  </div>
  <div class="col-md-3"></div>

  <link rel="stylesheet" type="text/css" href="../style/jquery-ui.css">
<script type="text/javascript" src="../style/jquery-ui.js"></script>
<script>
	function GetURLParameter(sParam)
		{
			var sPageURL = window.location.search.substring(1);
			var sURLVariables = sPageURL.split('&');
			for (var i = 0; i < sURLVariables.length; i++) 
			{
				var sParameterName = sURLVariables[i].split('=');
				if (sParameterName[0] == sParam) 
				{
					return sParameterName[1];
				}
			}
		}
		var id = GetURLParameter('id');
    
    function myFunction() {
      window.open("del_numb_sample.php?id="+id);
    }

    $(document).ready(function(){
		$('.input-tanggal').datepicker({
			dateFormat: 'yy-mm-dd'
		});		
	});	
      
  </script>
  </div>
</div>



  </div>
  </div>

</div>