        <!-- ============================================================== -->
        <!-- wrapper  -->
        <!-- ============================================================== -->
        <div class="dashboard-wrapper">
            <div class="container-fluid  dashboard-content">
                <!-- ============================================================== -->
                <!-- pageheader -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="page-header">
                            <h2 class="pageheader-title">Edit LPBJ Item</h2>
                            <div class="page-breadcrumb">
                                <nav aria-label="breadcrumb">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="?menu=tambah-lpbj&lpbj=<?php echo $_GET['lpbj']; ?>" class="breadcrumb-link"><?php echo namahari_ID(date('Y-m-d')) . ", " . date('d-m-Y'); ?>Tambah LPBJ</a></li>
                                        <li class="breadcrumb-item"></li>
                                        <li class="breadcrumb-item active" aria-current="page"><a href="?menu=edit-lpbj-item" class="breadcrumb-link">Item LPBJ</a></li>
                                    </ol>
                                </nav>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- end pageheader -->
                <!-- ============================================================== -->

                <div class="row">
                    <?php
                    $d_lpbj_ID = "";
                    $strKdItem = "";
                    $strDeskripsi = "";
                    $strUnit = "";
                    $iJumlah = "";
                    $iJumlahStok = "";
                    $strKeterangan = "";
                    $dtDibutuhkan = "";
                    $dept_ID = "";
                    $strNmDept = "";
                    $MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);

                    $query = "SELECT ITEM.strKdItem, 
                            ITEM.strDeskripsi, 
                            DET.ID AS d_lpbj_ID, 
                            DET.item_strUnit, 
                            DET.strNmFile, 
                            DET.iJumlah, 
                            DET.iJumlahStok, 
                            DET.strKeteranganREQ, 
                            DET.dtDibutuhkan, 
                            DEPT.ID, 
                            DEPT.strNmDept 
                    FROM tpc_h_lpbj AS HEAD 
                    LEFT JOIN tpc_d_lpbj AS DET 
                        ON HEAD.ID=DET.h_lpbj_ID 
                    LEFT JOIN item AS ITEM 
                        ON DET.item_ID=ITEM.ID 
                    LEFT JOIN tpc_dept AS DEPT 
                        ON DET.dept_ID=DEPT.ID 
                    WHERE DET.ID='" . $_GET['id'] . "' AND 
                            (DET.stsAktif=1 OR DET.stsAktif=2) AND 
                            (HEAD.stsAktif=1 OR HEAD.stsAktif=2) 
                    "; //die($query);
                    $result = $MySQLi->query($query);
                    if ($result->num_rows == 1) {
                        $row = $result->fetch_array();
                        $d_lpbj_ID = $row['d_lpbj_ID'];
                        $strKdItem = $row['strKdItem'];
                        $strDeskripsi = $row['strDeskripsi'];
                        $strUnit = $row['item_strUnit'];
                        $iJumlah = $row['iJumlah'];
                        $iJumlahStok = $row['iJumlahStok'];
                        $strKeterangan = substr($row['strKeteranganREQ'], 5);
                        $dtDibutuhkan = $row['dtDibutuhkan'];
                        $dept_ID = $row['ID'];
                        $strNmDept = $row['strNmDept'];
                        $strNmFile = $row['strNmFile'];
                    }
                    ?>
                    <!-- ============================================================== -->
                    <!-- basic form -->
                    <!-- ============================================================== -->
                    <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-12">
                        <div class="card">
                            <h5 class="card-header">Edit LPBJ Item</h5>
                            <div class="card-body">
                                <form id="basicform" data-parsley-validate="" action="transaksi/persediaan/pemesanan/simpan.edit.lpbj.item.php" method="post" enctype="multipart/form-data">
                                    <input type="hidden" name="ID" value="<?php echo $d_lpbj_ID; ?>">
                                    <input type="hidden" name="strKdLPBJ" value="<?php echo $_GET['lpbj']; ?>">
                                    <div class="form-group">
                                        <label for="list_item">Deskripsi</label>
                                        <input type="text" id="list_item" name="strDeskripsi" data-parsley-trigger="change" required="" placeholder="Masukan deskripsi barang" autocomplete="off" value="<?php echo $strDeskripsi; ?>" class="form-control" list="list_deskripsi">
                                        <datalist id="list_deskripsi">
                                            <?php
                                            $query = "SELECT ID, 
                                                                strDeskripsi 
                                                        FROM item 
                                                        ";
                                            $result = $MySQLi->query($query);
                                            while ($row = $result->fetch_array())
                                                echo "<option value='" . $row['strDeskripsi'] . "'  data-realvalue='" . $row['ID'] . "_" . $row['strDeskripsi'] . "'>";
                                            ?>
                                        </datalist>
                                    </div>
                                    <div class="form-group">
                                        <label for="inputJumlah">Jumlah</label>
                                        <input id="inputJumlah" type="text" name="iJumlah" data-parsley-trigger="change" required="" placeholder="Masukan Jumlah" autocomplete="off" class="form-control" value="<?php echo $iJumlah; ?>">
                                    </div>
                                    <div class="form-group">
                                        <label for="inputUnit">Unit</label>
                                        <input id="inputUnit" type="text" name="strUnit" data-parsley-trigger="change" class="form-control" list="datalist_unit" autocomplete='off' value="<?php echo $strUnit; ?>">
                                        <datalist id="datalist_unit"></datalist>
                                    </div>
                                    <div class="form-group">
                                        <label for="iJumlahStok">Jumlah Stok</label>
                                        <input id="iJumlahStok" type="text" name="iJumlahStok" data-parsley-trigger="change" required="" placeholder="Masukan Jumlah Stok" autocomplete="off" class="form-control" value="<?php echo $iJumlahStok; ?>">
                                    </div>
                                    <div class="form-group">
                                        <label for="inputKeterangan">Keterangan</label>
                                        <textarea class="form-control" id="inputKeterangan" name="strKeterangan" rows="3"><?php echo $strKeterangan; ?></textarea>
                                    </div>
                                    <div class="form-group">
                                        <label for="inputDepartement">Departement</label>
                                        <select class="form-control" id="inputDepartement" name="dept_ID">
                                            <?php
                                            $query = "SELECT ID, 
                                                        strNmDept 
                                                    FROM tpc_dept
                                                    WHERE stsAktif=1 AND 
                                                            strKdLokasi='" . $_SESSION['strKdLokasi'] . "'
                                                    ";
                                            $result = $MySQLi->query($query);
                                            while ($row = $result->fetch_array()) {
                                                if ($row['ID'] == $dept_ID)
                                                    $select = "selected";
                                                else
                                                    $select = "";
                                                echo "<option value='" . $row['ID'] . "' " . $select . ">" . $row['strNmDept'] . "</option>";
                                            }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label for="inputdtDibutuhkan">Tanggal Dibutuhkan</label>
                                        <input id="inputdtDibutuhkan" type="date" min="<?php echo date('Y-m-d'); ?>" name="dtDibutuhkan" value="<?php echo $dtDibutuhkan; ?>" required>
                                    </div>
                                    <div class="form-group">
                                        <label for="fileUpload">Upload Image</label>
                                        <input type="file" id="fileUpload" name="strNmFile" accept=".jpg,.jpeg,.png,.bmp" data-parsley-trigger="change" autocomplete="off" value="<?php echo $strNmFile; ?>" class="form-control">
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6 pl-0">
                                            <p class="text-right">
                                                <button type="submit" name="simpan" class="btn btn-space btn-primary">Simpan</button>
                                                <a href="?menu=tambah-lpbj&lpbj=<?php echo $_GET['lpbj']; ?>" class="btn btn-space btn-secondary">Cancel</a>
                                            </p>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end basic form -->
                    <!-- ============================================================== -->
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <div class="footer">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
                            Copyright © 2024 TPC-PACK, Developed By <a href="mailto: jockie@netportal.my.id">JC Comp</a>.
                        </div>
                        <!--<div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-12">
                            <div class="text-md-right footer-links d-none d-sm-block">
                                <a href="javascript: void(0);">About</a>
                                <a href="javascript: void(0);">Support</a>
                                <a href="javascript: void(0);">Contact Us</a>
                            </div>
                        </div>-->
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- end footer -->
            <!-- ============================================================== -->
        </div>
        <script>
            function changeValue() {
                var input = document.getElementById("list_item");
                var selectedValue = input.value;
                var realValue = document.querySelector('option[value="' + selectedValue + '"]').getAttribute("data-realvalue");
                input.value = realValue;
            }
        </script>
        <script src="assets/libs/js/jquery-3.6.0.min.js"></script>
        <script>
            $(document).ready(function() {
                $('#list_item').on('input', function() {
                    var strDeskripsi = $(this).val();
                    $.ajax({
                        url: 'transaksi/persediaan/pemesanan/get_unit.php',
                        type: 'POST',
                        data: {
                            strDeskripsi: strDeskripsi
                        },
                        dataType: 'json',
                        success: function(response) {
                            $('#datalist_unit').empty(); // Kosongkan datalist sebelum mengisinya kembali
                            $.each(response, function(index, unit) {
                                $('#datalist_unit').append('<option value="' + unit + '">');
                            });
                        },
                        error: function(xhr, status, error) {
                            console.error(xhr.responseText);
                        }
                    });
                });
            });
        </script>