<?php  
	include '_header-artibut.php';
    $id = $_POST['id'];
    
    $dataEditServis = query("SELECT * FROM data_servis WHERE ds_id = $id ")[0];
?>

				<div class="row">
                    <div class="col-md-6 col-lg-4">
                        <input type="hidden" name="ds_id" value="<?= $id; ?>">
                        <div class="form-group">
                            <label for="ds_customer_id">Customer <span class="red">*</span></label>
                            <select class="form-control select2bs4" required="" name="ds_customer_id" id="ds_customer_id">
                              <?php  
                                $customer_id = $dataEditServis['ds_customer_id'];
                                $customer_nama = mysqli_query($conn, "select customer_nama from customer where customer_id = ".$customer_id." ");
                                $customer_nama = mysqli_fetch_array($customer_nama);
                                $customer_nama = $customer_nama['customer_nama'];
                              ?>

                              <option selected="selected" value="<?= $customer_id; ?>"><?= $customer_nama; ?></option>
                              <?php  
                                $customer = query("SELECT * FROM customer WHERE customer_cabang = $sessionCabang && customer_status = 1 && customer_id != $customer_id ORDER BY customer_id DESC ");
                              ?>
                              <?php foreach ( $customer as $ctr ) : ?>
                                <?php if ( $ctr['customer_id'] > 1 ) { ?>
                                <option value="<?= $ctr['customer_id'] ?>"><?= $ctr['customer_nama'] ?></option>
                                <?php } ?>
                              <?php endforeach; ?>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_kategori_jenis_barang_servis_id">Kategori Servis <span class="red">*</span></label>
                            <select class="form-control select2bs4" required="" name="ds_kategori_jenis_barang_servis_id">
                              <?php  
                                $dkjbsi_id = $dataEditServis['ds_kategori_jenis_barang_servis_id'];
                                $dkjbsi = mysqli_query($conn, "select kategori_servis_nama from kategori_servis where kategori_servis_id = ".$dkjbsi_id." ");
                                $dkjbsi = mysqli_fetch_array($dkjbsi);
                                $dkjbsi = $dkjbsi['kategori_servis_nama'];
                              ?>
                              <option selected="selected" value="<?= $dkjbsi_id; ?>"><?= $dkjbsi; ?></option>
                              <?php  
                                $kategori_servis = query("SELECT * FROM kategori_servis WHERE kategori_servis_cabang = $sessionCabang && kategori_servis_status > 0 && kategori_servis_id != $dkjbsi_id ORDER BY kategori_servis_id DESC ");
                              ?>
                              <?php foreach ( $kategori_servis as $row ) : ?>
                                <option value="<?= $row['kategori_servis_id'] ?>"><?= $row['kategori_servis_nama'] ?></option>
                              <?php endforeach; ?>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_merk">Merek <span class="red">*</span></label>
                            <input type="text" name="ds_merk" class="form-control" id="ds_merk" placeholder="Contoh: Samsung" value="<?= $dataEditServis['ds_merk']; ?>" required>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_model_seri">Model/Seri <span class="red">*</span></label>
                            <input type="text" name="ds_model_seri" class="form-control" id="ds_model_seri" value="<?= $dataEditServis['ds_model_seri']; ?>" placeholder="Input Model/Seri Barang" required>
                        </div>
                    </div>

                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_sn">No. SN</label>
                            <input type="text" name="ds_sn" class="form-control" value="<?= $dataEditServis['ds_sn']; ?>" id="ds_sn" placeholder="Input Nomor Serial Number">
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_imei">Imei</label>
                            <input type="text" name="ds_imei" class="form-control" value="<?= $dataEditServis['ds_imei']; ?>" id="ds_imei" placeholder="Imei Barang">
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_warna">Warna Barang <span class="red">*</span></label>
                            <input type="text" name="ds_warna" class="form-control" id="ds_warna" placeholder="Input Warna Barang Barang" value="<?= $dataEditServis['ds_warna']; ?>" required>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_memory">Memory</label>
                            <input type="text" name="ds_memory" class="form-control" id="ds_memory" value="<?= $dataEditServis['ds_memory']; ?>" placeholder="Contoh 16 GB">
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_kelengkapan">Kelengkapan <span class="red">*</span></label>
                            <input type="text" name="ds_kelengkapan" class="form-control" id="ds_kelengkapan" value="<?= $dataEditServis['ds_kelengkapan']; ?>" placeholder="Kelengkapan Barang" required>
                        </div>
                    </div>

                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_kerusakan">Kerusakan <span class="red">*</span></label>
                            <input type="text" name="ds_kerusakan" class="form-control" id="ds_kerusakan" value="<?= $dataEditServis['ds_kerusakan']; ?>" placeholder="Input Kerusakan Barang" required>
                        </div>
                    </div>
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_keterangan">Keterangan/Keluhan</label>
                            <textarea name="ds_keterangan" id="textarea" class="form-control" rows="3" placeholder="Keterangan dari customer tentang keluhan barang"><?= $dataEditServis['ds_keterangan']; ?></textarea>
                        </div>
                    </div>
                    
                    <div class="col-md-6 col-lg-4">
                        <div class="form-group">
                            <label for="ds_password">Password</label>
                            <input type="text" name="ds_password" class="form-control" id="ds_password" value="<?= $dataEditServis['ds_password']; ?>" placeholder="Input Password Barang Jika Ada">
                        </div>
                    </div>
                    </div>
                </div>

<script>
	$(function () {

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  });
</script>