
<?php
	include "../koneksi.php";
	$no = 1;
	$data = mysqli_query ($koneksi, "SELECT ReturnID,
												Date_Return,
												ekspedisi.Ekspedisi,
												detailekspedisi.DetailEkspedisi_ID,
												detailekspedisi.Sopir,
												`return`.CustomerID,
												customer.CustomerName,
												SJ_Return,
												Packaging,
												Qty,
												Qty2,
												Deskripsi
									FROM `return`
									INNER JOIN detailekspedisi
									ON detailekspedisi.DetailEkspedisi_ID=`return`.DetailEkspedisi_ID
									INNER JOIN ekspedisi
									ON ekspedisi.EkspedisiID=detailekspedisi.EkspedisiID
									INNER JOIN customer
									ON `return`.CustomerID=customer.CustomerID
									where `return`.ReturnID = $_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 Return</th>
						<input type="hidden" type="id" name="id" value="<?php echo $row['ReturnID']; ?>">
						<td><input type="text" class="input-tanggal" id="date_return" name="date_return" data-date-format="dd-mm-yy" value="<?php echo $row['Date_Return']; ?>">
						<p style="color:red" id="error_edit_date_return"></p></td>
					</tr>
					<tr>
						<th>Customer</th>
						<td>
						<select name="customer" id="customer">
								<option value="<?php echo $row['CustomerID']; ?>" selected><?php echo $row['CustomerName']; ?></option>
								<?php 
								include"../koneksi.php";
								$data1 = mysqli_query ($koneksi, " select 
														CustomerID,
														CustomerName
												  from 
												  customer 
												  order by CustomerID DESC");
								while ($row1 = mysqli_fetch_array ($data1))
								{
								?>
								<option value="<?php echo  $row1['CustomerID']; ?>" ><?php echo $row1['CustomerName']; ?></option>
								<?php } ?>
							</select>
							<p style="color:red" id="error_edit_customer"></p>
						</td>
					</tr>
					<tr>
						<th style="margin-top: 15px;">Ekspedisi</th>
						<td style="margin-top: 15px;">
						<select name="ekspedisi" id="ekspedisi">
								<option value="<?php echo $row['DetailEkspedisi_ID']; ?>" selected><?php echo $row['Ekspedisi']; ?> | <?php echo $row['Sopir']; ?></option>
								<?php 
								$data3 = mysqli_query ($koneksi, " select 
																			detailekspedisi.DetailEkspedisi_ID,
																			ekspedisi.EkspedisiID,
																			ekspedisi.Ekspedisi,
																			detailekspedisi.Sopir,
																			detailekspedisi.NoPolisi,
																			detailekspedisi.NoHP
																	from 
																	detailekspedisi
																	INNER JOIN ekspedisi
																	ON detailekspedisi.EkspedisiID=ekspedisi.EkspedisiID
																	where detailekspedisi.Sopir!=''
																	order by DetailEkspedisi_ID DESC");
								while ($row3 = mysqli_fetch_array ($data3))
								{
								?>
								<option value="<?php echo  $row3['DetailEkspedisi_ID']; ?>"><?php echo $row3['Ekspedisi']; ?> | <?php echo $row3['Sopir']; ?></option>
								<?php } ?>
							</select>
							<p style="color:red" id="error_edit_ekspedisi"></p>
						</td>
					</tr>
					<tr>
						<th>NO SJ</th>
						<td>
							<input style="width: 70%; margin-bottom: 10px;" id="sj" name="sj" value="<?php echo $row['SJ_Return'] ?>">
						</td>
					</tr>
					<tr>
						<th style="margin-top: 15px;">Packaging</th>
						<td style="margin-top: 15px;">
						<span><?php echo $row['Packaging'] ?></span>
						</td>
					</tr>
					<?php if($row['Packaging']=='NICKTAINER') { ?>
					<th>NICKTAINER</th>
					<td>
						<input id="qty" name="qty" value="<?php echo $row['Qty']; ?>">
						<input hidden id="qty2" name="qty2" value="">
					</td>
					<?php } else { ?>
					<th>PALET & TOP</th>
					<td>
						<input id="qty" name="qty" placeholder="Jml Palet" value="<?php echo $row['Qty']; ?>">
						<input id="qty2" name="qty2" placeholder="Jml Top Palet" value="<?php echo $row['Qty2']; ?>">
					</td>
					<?php } ?>
					<tr>
						<th>Deskripsi</th>
						<td>
							<input style='width: 100%; margin-top: 10px;' name="deskripsi" id="deskripsi" value="<?php echo $row['Deskripsi']; ?>">
						</td>
					</tr>
					
					</table>			
	
</form>