<?php
include "asset/session_check.php";

$nama_pegawai = $_SESSION['nama_pegawai'];
$akses = $_SESSION['akses'];
?>
<!doctype html>
<html lang="en">

<head>
    <?php
    include "asset/head.php";
    ?>
</head>

<body>
    <!-- NAVIGASI -->
    <?php
    include "asset/navigasi.php";
    ?>
    <div class="container">
        <div class="row">
            <div class="d-flex bd-highlight mb-3">
                <div class="me-auto p-2 bd-highlight">
                    <h1>Edit Data Telp Customers Bisman</h1>
                </div>
            </div>
        </div>
        <div class="row">
            <?php
            include "koneksi.php";

            $tgl = date("Y-m-d");
            $idtelp_custbisman = $_GET["idtelp_custbisman"];

            $cariidtelp = mysqli_query($konek, "SELECT t.idtelp_custbisman,t.keperluan,t.sumber,t.ket_sumber,c.bu,c.idcustomer,c.nama_customer,c.alamat,c.kota,c.email,c.telp,t.note_telp FROM telp_custbisman t INNER JOIN customeb c ON t.idcustomer=c.idcustomer WHERE t.idtelp_custbisman = '$idtelp_custbisman'");
            $data = mysqli_fetch_array($cariidtelp);
            $idcustomer = $data['idcustomer'] ?? '';
            $nama_customer = $data['nama_customer'] ?? '';
            $alamat = $data['alamat'] ?? '';
            $kota = $data['kota'] ?? '';
            $email = $data['email'] ?? '';
            $telp = $data['telp'] ?? '';
            $sumber = $data['sumber'] ?? '';
            $ketarangansumber = $data['ket_sumber'] ?? '';
            $keperluan = $data['keperluan'] ?? '';
            $note = $data['note'] ?? '';
            $note_telp = $data['note_telp'] ?? '';
            $bu = $data['bu'] ?? '';
            ?>
            <input type="text" class="form-control" name="idtelp_custbisman" value="<?= $idtelp_custbisman ?>" form="formSelesai" hidden>
            <div class="mb-3">
                <label class="form-label" hidden>Tanggal Telp Customers</label>
                <input type="date" class="form-control" name="tgl_customer" value="<?= $tgl ?>" form="formSelesai" hidden>
            </div>
            <div class="col">
                <div class="mb-3">
                    <label class="form-label">Customers</label>
                    <div class="input-group">
                        <select class="form-select" name="bu" id="bu" style="max-width: 95px;" form="formSelesai">
                            <option value="PT " <?= ($bu == 'PT ') ? 'selected' : '' ?>>PT</option>
                            <option value="CV " <?= ($bu == 'CV ') ? 'selected' : '' ?>>CV</option>
                            <option value="UD " <?= ($bu == 'UD ') ? 'selected' : '' ?>>UD</option>
                            <option value="Toko " <?= ($bu == 'Toko ') ? 'selected' : '' ?>>Toko</option>
                            <option value="Bapak " <?= ($bu == 'Bapak ') ? 'selected' : '' ?>>Bapak</option>
                            <option value="Ibu " <?= ($bu == 'Ibu ') ? 'selected' : '' ?>>Ibu</option>
                        </select>
                        <input type="text" class="form-control" autocomplete="off" name="nama_customer" id="nama_customer" value="<?= $nama_customer ?>" form="formSelesai" placeholder="Masukkan Nama Customer">
                    </div>
                    <div id="customerList"
                        class="list-group w-100"
                        style="z-index:1000; display:none;"></div>
                </div>
                <div class="mb-3">
                    <label class="form-label">Alamat</label>
                    <input type="text" id="alamat" name="alamat" class="form-control" value="<?= $alamat ?>" form="formSelesai" placeholder="Masukkan Alamat" readonly>
                    <div id="suggestion" class="list-group"></div>
                </div>
                <div class="mb-3">
                    <label class="form-label">KOTA</label>
                    <input type="text" id="kota" name="kota" class="form-control kota" value="<?= $kota ?>" form="formSelesai" placeholder="Ketik kota  /  / kabupaten" readonly>
                    <div id="suggestion" class="list-group suggestion"></div>
                </div>
                <!-- <div class="mb-3">
                        <label class="form-label">PIC</label>
                        <div class="input-group">
                            <select class="form-select" name="tt" id="tt" style="max-width: 95px;">
                                <option value="Bapak">Bapak</option>
                                <option value="Ibu">Ibu</option>
                            </select>
                            <input type="text" class="form-control" autocomplete="off" name="pic" id="pice" placeholder="Masukkan Nama PIC">
                        </div>
                    </div> -->
                <div class="mb-3">
                    <label class="form-label">Telp Perusahaan</label>
                    <input type="text" class="form-control" name="telp" id="telp" form="formSelesai" value="<?= $telp ?>" placeholder="Masukkan Nama Telp" maxlength="50" readonly>
                </div>
            </div>
            <div class="col">
                <div class="mb-3">
                    <label class="form-label">Email</label>
                    <input type="text" class="form-control" name="email" id="email" value="<?= $email ?>" placeholder="Masukkan Email" form="formSelesai">
                </div>
                <label class="form-label">Sumber</label>
                <div class="mb-3" id="selectSum">
                    <select class="form-select" id="sumber" name="sumber" form="formSelesai">
                        <option value="WA" <?= ($sumber == 'WA') ? 'selected' : '' ?>>WA</option>
                        <option value="Email" <?= ($sumber == 'Email') ? 'selected' : '' ?>>Email</option>
                        <option value="Brosur" <?= ($sumber == 'Brosur') ? 'selected' : '' ?>>Brosur</option>
                        <option value="Walk In" <?= ($sumber == 'Walk In') ? 'selected' : '' ?>>Walk In</option>
                        <option value="Telp" <?= ($sumber == 'Telp') ? 'selected' : '' ?>>Telp</option>
                        <option value="Iklan" <?= ($sumber == 'Iklan') ? 'selected' : '' ?>>Iklan</option>
                        <option value="Website" <?= ($sumber == 'Website') ? 'selected' : '' ?>>Website</option>
                        <option value="Tidak Tau" <?= ($sumber == 'Tidak tahu') ? 'selected' : '' ?>>Tidak tahu</option>
                    </select>
                    <select class="form-select" id="formWebsite" style="display:none;" name="keteranganSumberWeb" form="formSelesai">
                        <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="alatangkat.com / sales@alatangkat.com / 082338331857"
                                <?= ($ketarangansumber == 'alatangkat.com / sales@alatangkat.com / 082338331857') ? 'selected' : '' ?>>
                                alatangkat.com / sales@alatangkat.com / 082338331857
                            </option>

                            <option value="dunialifting.com / dunialifting@gmail.com / 081334095835"
                                <?= ($ketarangansumber == 'dunialifting.com / dunialifting@gmail.com / 081334095835') ? 'selected' : '' ?>>
                                dunialifting.com / dunialifting@gmail.com / 081334095835
                            </option>

                            <option value="forkliftnusantara.com / info@forkliftnusantara.com / 082122225308"
                                <?= ($ketarangansumber == 'forkliftnusantara.com / info@forkliftnusantara.com / 082122225308') ? 'selected' : '' ?>>
                                forkliftnusantara.com / info@forkliftnusantara.com / 082122225308
                            </option>

                            <option value="hand-lift.com / @ / @"
                                <?= ($ketarangansumber == 'hand-lift.com / @ / @') ? 'selected' : '' ?>>
                                hand-lift.com / - / -
                            </option>

                            <option value="handlift.id / info@handlift.id / 081336092292"
                                <?= ($ketarangansumber == 'handlift.id / info@handlift.id / 081336092292') ? 'selected' : '' ?>>
                                handlift.id / info@handlift.id / 081336092292
                            </option>

                            <option value="handliftnusantara.com / @ / 081330288034"
                                <?= ($ketarangansumber == 'handliftnusantara.com / @ / 081330288034') ? 'selected' : '' ?>>
                                handliftnusantara.com / - / 081330288034
                            </option>

                            <option value="handpalletlift.com / @ / @"
                                <?= ($ketarangansumber == 'handpalletlift.com / @ / @') ? 'selected' : '' ?>>
                                handpalletlift.com / - / -
                            </option>

                            <option value="saranalifting.com / @ / 081336402013"
                                <?= ($ketarangansumber == 'saranalifting.com / @ / 081336402013') ? 'selected' : '' ?>>
                                saranalifting.com / - / 081336402013
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081334108072"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081334108072') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081334108072
                            </option>

                            <option value="primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244"
                                <?= ($ketarangansumber == 'primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244') ? 'selected' : '' ?>>
                                primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244
                            </option>
                    </select>
                    <select class="form-select" id="formEmail" style="display:none;" name="keteranganSumberEmail" form="formSelesai">
                        <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / bismanbintangbuana@gmail.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / bismanbintangbuana@gmail.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / bismanbintangbuana@gmail.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / admin@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / admin@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / admin@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / dika@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / dika@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / dika@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / service@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / service@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / service@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / hrd@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / hrd@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / hrd@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / adminkubsd@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / adminkubsd@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / adminkubsd@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / purchasing@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / purchasing@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / purchasing@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="alatangkat.com / sales@alatangkat.com / 082338331857"
                                <?= ($ketarangansumber == 'alatangkat.com / sales@alatangkat.com / 082338331857') ? 'selected' : '' ?>>
                                alatangkat.com / sales@alatangkat.com / 082338331857
                            </option>

                            <option value="dunialifting.com / dunialifting@gmail.com / 081334095835"
                                <?= ($ketarangansumber == 'dunialifting.com / dunialifting@gmail.com / 081334095835') ? 'selected' : '' ?>>
                                dunialifting.com / dunialifting@gmail.com / 081334095835
                            </option>

                            <option value="forkliftnusantara.com / info@forkliftnusantara.com / 082122225308"
                                <?= ($ketarangansumber == 'forkliftnusantara.com / info@forkliftnusantara.com / 082122225308') ? 'selected' : '' ?>>
                                forkliftnusantara.com / info@forkliftnusantara.com / 082122225308
                            </option>

                            <option value="forkliftnusantara.com / forkliftnusantara99@gmail.com / 082122225308"
                                <?= ($ketarangansumber == 'forkliftnusantara.com / forkliftnusantara99@gmail.com / 082122225308') ? 'selected' : '' ?>>
                                forkliftnusantara.com / forkliftnusantara99@gmail.com / 082122225308
                            </option>

                            <option value="handlift.id / info@handlift.id / 081336092292"
                                <?= ($ketarangansumber == 'handlift.id / info@handlift.id / 081336092292') ? 'selected' : '' ?>>
                                handlift.id / info@handlift.id / 081336092292
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081334108072"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081334108072') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081334108072
                            </option>

                            <option value="primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244"
                                <?= ($ketarangansumber == 'primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244') ? 'selected' : '' ?>>
                                primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244
                            </option>
                    </select>
                    <select class="form-select" id="formTelp" style="display:none;" name="keteranganSumberTelp" form="formSelesai">
                        <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287
                            </option>

                            <option value="alatangkat.com / sales@alatangkat.com / 082338331857"
                                <?= ($ketarangansumber == 'alatangkat.com / sales@alatangkat.com / 082338331857') ? 'selected' : '' ?>>
                                alatangkat.com / sales@alatangkat.com / 082338331857
                            </option>

                            <option value="dunialifting.com / dunialifting@gmail.com / 081334095835"
                                <?= ($ketarangansumber == 'dunialifting.com / dunialifting@gmail.com / 081334095835') ? 'selected' : '' ?>>
                                dunialifting.com / dunialifting@gmail.com / 081334095835
                            </option>

                            <option value="forkliftnusantara.com / info@forkliftnusantara.com / 082122225308"
                                <?= ($ketarangansumber == 'forkliftnusantara.com / info@forkliftnusantara.com / 082122225308') ? 'selected' : '' ?>>
                                forkliftnusantara.com / info@forkliftnusantara.com / 082122225308
                            </option>

                            <option value="handlift.id / @ / 081336092292"
                                <?= ($ketarangansumber == 'handlift.id / @ / 081336092292') ? 'selected' : '' ?>>
                                handlift.id / - / 081336092292
                            </option>

                            <option value="handliftnusantara.com / @ / 081330288034"
                                <?= ($ketarangansumber == 'handliftnusantara.com / @ / 081330288034') ? 'selected' : '' ?>>
                                handliftnusantara.com / - / 081330288034
                            </option>

                            <option value="saranalifting.com / @ / 081336402013"
                                <?= ($ketarangansumber == 'saranalifting.com / @ / 081336402013') ? 'selected' : '' ?>>
                                saranalifting.com / - / 081336402013
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081334108072"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081334108072') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081334108072
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081231201845"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081231201845') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081231201845
                            </option>

                            <option value="primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244"
                                <?= ($ketarangansumber == 'primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244') ? 'selected' : '' ?>>
                                primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244
                            </option>
                    </select>
                    <select class="form-select" id="formWA" style="display:none;" name="keteranganSumberWA" form="formSelesai">
                        <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 081249883080
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 03199445298
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 03130000249
                            </option>

                            <option value="bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287"
                                <?= ($ketarangansumber == 'bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287') ? 'selected' : '' ?>>
                                bismanbintangbuana.com / sales@bismanbintangbuana.com / 0217237287
                            </option>

                            <option value="alatangkat.com / sales@alatangkat.com / 082338331857"
                                <?= ($ketarangansumber == 'alatangkat.com / sales@alatangkat.com / 082338331857') ? 'selected' : '' ?>>
                                alatangkat.com / sales@alatangkat.com / 082338331857
                            </option>

                            <option value="dunialifting.com / dunialifting@gmail.com / 081334095835"
                                <?= ($ketarangansumber == 'dunialifting.com / dunialifting@gmail.com / 081334095835') ? 'selected' : '' ?>>
                                dunialifting.com / dunialifting@gmail.com / 081334095835
                            </option>

                            <option value="forkliftnusantara.com / info@forkliftnusantara.com / 082122225308"
                                <?= ($ketarangansumber == 'forkliftnusantara.com / info@forkliftnusantara.com / 082122225308') ? 'selected' : '' ?>>
                                forkliftnusantara.com / info@forkliftnusantara.com / 082122225308
                            </option>

                            <option value="handlift.id / @ / 081336092292"
                                <?= ($ketarangansumber == 'handlift.id / @ / 081336092292') ? 'selected' : '' ?>>
                                handlift.id / - / 081336092292
                            </option>

                            <option value="handliftnusantara.com / @ / 081330288034"
                                <?= ($ketarangansumber == 'handliftnusantara.com / @ / 081330288034') ? 'selected' : '' ?>>
                                handliftnusantara.com / - / 081330288034
                            </option>

                            <option value="saranalifting.com / @ / 081336402013"
                                <?= ($ketarangansumber == 'saranalifting.com / @ / 081336402013') ? 'selected' : '' ?>>
                                saranalifting.com / - / 081336402013
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081259832813
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 03199843034
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081231201845
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420755
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02130420756
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 081249883080
                            </option>

                            <option value="sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916"
                                <?= ($ketarangansumber == 'sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916') ? 'selected' : '' ?>>
                                sumberterangdunia.com / sumberterangdunia@gmail.com / 02129082916
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081334108072"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081334108072') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081334108072
                            </option>

                            <option value="indoputrateknik.com / sales@indoputrateknik.com / 081231201845"
                                <?= ($ketarangansumber == 'indoputrateknik.com / sales@indoputrateknik.com / 081231201845') ? 'selected' : '' ?>>
                                indoputrateknik.com / sales@indoputrateknik.com / 081231201845
                            </option>

                            <option value="primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244"
                                <?= ($ketarangansumber == 'primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244') ? 'selected' : '' ?>>
                                primajayasukses.com / forkliftprimajaya@gmail.com / 087822631244
                            </option>
                    </select>
                </div>
                <div class="mb-3">
                    <label class="form-label">Keperluan</label>
                    <input type="text" id="keperluan" class="form-control" name="keperluane" value="<?= $keperluan ?>" form="formSelesai" placeholder="Masukkan Keperluan">
                    <div id="keperluanItem" class="list-group"></div>
                </div>
                <div class="mb-3">
                        <label class="form-label">Note Customer</label>
                        <textarea type="text" class="form-control" name="note_telp" id="note_telp" form="formSelesai"><?= $note_telp ?></textarea>
                    </div>
            </div>
        </div>
        <button
            class="btn btnfunc"
            data-bs-toggle="modal"
            data-bs-target="#ModalTmbTelp">
            Tambah PIC
        </button>
        <!-- <button type="submit" class="btn btnfunc" name="tambah">Tambah PIC</button> -->
        <hr>
        <div class="row">
            <table class="table table-hover">
                <thead>
                    <tr style="text-align: center;">
                        <th>No</th>
                        <th>PIC</th>
                        <th>Telp PIC</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $no = 1;
                    $query = mysqli_query($konek, "SELECT t.idtelp_custbisman,td.iddtelp_custbisman,c.nama_customer,c.bu,c.telp,c.kota,p.idpic,p.nama_pic,p.telp_pic,t.keperluan,t.sumber,t.ket_sumber FROM telp_custbisman_detail td INNER JOIN picb p ON td.idpic = p.idpic INNER JOIN telp_custbisman t ON td.idtelp_custbisman = t.idtelp_custbisman INNER JOIN customeb c ON t.idcustomer = c.idcustomer WHERE td.idtelp_custbisman = '$idtelp_custbisman'");
                    while ($row = mysqli_fetch_array($query)) {
                    ?>
                        <tr style="text-align: center;">
                            <td><?php echo $no ?></td>
                            <td><?php echo $row['nama_pic'] ?></td>
                            <td><?php echo $row['telp_pic'] ?></td>
                            <td>
                                <button
                                    class="btn btn-warning btn-sm"
                                    data-bs-toggle="modal"
                                    data-bs-target="#edit<?= $row['idpic']; ?>">
                                    <i class="bi bi-pencil-fill"></i>
                                </button>
                                <a href="function/function-telpbisman.php?uedit&hps&idtelp_custbisman=<?php echo $row['idtelp_custbisman'] ?>&iddtelp_custbisman=<?php echo $row['iddtelp_custbisman'] ?>" class="btn btn-sm btn-danger"><i class="bi bi-trash3"></i></a>
                            </td>
                            <div class="modal fade" id="edit<?= $row['idpic']; ?>" tabindex="-1">
                                <div class="modal-dialog modal-lg">
                                    <div class="modal-content">
                                        <form action="function/function-telp.php?idtelp_custbisman = <?= $idtelp_custbisman ?>" method="post">
                                            <div class="modal-header">
                                                <h5 class="modal-title">Edit Data Customer</h5>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                            </div>

                                            <div class="modal-body">
                                                <input type="text" name="idtelp_custbisman" value="<?= $idtelp_custbisman ?>" hidden>
                                                <input type="text" name="idpic" value="<?= $row['idpic']; ?>" hidden>

                                                <div class="mb-3">
                                                    <label class="form-label">PIC</label>
                                                    <?php
                                                    $pic = $row['nama_pic'];
                                                    $sapaan = 'Bapak'; // default

                                                    if (stripos($pic, 'Ibu') !== false) {
                                                        $sapaan = 'Ibu';
                                                    }

                                                    $pic = preg_replace('/\b(bapak|ibu)\b\s*/i', '', $pic);
                                                    $pic = trim($pic);
                                                    ?>
                                                    <div class="input-group">
                                                        <select class="form-select" name="tt" id="tt" style="max-width: 95px;">
                                                            <option value="Bapak" <?= $sapaan == 'Bapak' ? 'selected' : '' ?>>Bapak</option>
                                                            <option value="Ibu" <?= $sapaan == 'Ibu' ? 'selected' : '' ?>>Ibu</option>
                                                        </select>
                                                        <input type="text" class="form-control idcustomer" autocomplete="off" name="idcustomer" id="idcustomer" value="<?= $idcustomer ?>" hidden>
                                                        <input type="text" class="form-control pic" autocomplete="off" name="pic" id="pice" value="<?= $pic ?>">
                                                    </div>
                                                    <div id="picList"
                                                        class="list-group picList w-100"
                                                        style=" display:none;"></div>
                                                </div>
                                                <div class="mb-3">
                                                    <label>Telp</label>
                                                    <input type="text" name="telp" class="form-control" id="telep" value="<?= $row['telp_pic'] ?>" maxlength="50">
                                                </div>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="submit" name="editpic" class="btn tmbdata">Update</button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </tr>
                    <?php
                        $no++;
                    }
                    ?>
                </tbody>
            </table>
        </div>
        <div class="row">
            <form id="formSelesai" action="function/function-telpbisman.php?idtelp_custbisman=<?php echo $idtelp_custbisman ?>" method="post">
                <button type="submit" name="selesaiedit" class="btn btn-secondary btnfunct">Selesai</button>
            </form>
        </div>
    </div>
    <div class="modal fade" id="ModalTmbTelp" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Tambah Data PIC</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <form action="function/function-telpbisman.php?uedit&idtelp_custbisman=<?php echo $idtelp_custbisman ?>" method="post">
                    <div class="modal-body">
                        <div class="input-group">
                            <select class="form-select" name="tt" id="tt" style="max-width: 95px;">
                                <option value="Bapak">Bapak</option>
                                <option value="Ibu">Ibu</option>
                            </select>
                            <input type="text" class="form-control idcustomer" autocomplete="off" name="idcustomer" id="idcustomer" value="<?= $idcustomer ?>" hidden>
                            <input type="text" class="form-control pic" autocomplete="off" name="pic" id="pice" placeholder="Masukkan Nama PIC">
                        </div>
                        <div id="picList"
                            class="list-group picList w-100"
                            style=" display:none;"></div>
                        <br>
                        <div class="mb-3">
                            <label class="form-label">Telp PIC</label>
                            <input type="text" class="form-control telp_pic" id="telp_pic" autocomplete="off" name="telppic" maxlength="50" placeholder="Masukkan Telp PIC">
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Note</label>
                            <textarea class="form-control note" name="note" id="note" style="height: 100px"><?= $note ?></textarea>
                            <!-- <input type="text" class="form-control" name="note" value="<?= $note ?>" placeholder="Masukkan Note"> -->
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn" name="tmbpic" style="background-color: #1E93AB;color: white;">Simpan</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- customer -->
    <script src="asset/js/auto_custb.js"></script>
    <!-- pic -->
    <script src="asset/js/auto_picb.js"></script>
    <!-- wilayah -->
    <script src="asset/js/auto_wilayah.js"></script>
    <!-- keperluan -->
    <script src="asset/js/auto_keperluan.js"></script>

    <!-- <?php if ($modal === 'ModalTmbTelp'): ?>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                const modal = new bootstrap.Modal(
                    document.getElementById('ModalTmbTelp')
                );
                modal.show();
            });
        </script>
    <?php endif; ?> -->
    <script>
        function toggleChecker() {
            let nilai = document.getElementById('sumber').value;

            let formWebsite = document.getElementById('formWebsite');
            let formEmail = document.getElementById('formEmail');
            let formTelp = document.getElementById('formTelp');
            let formWA = document.getElementById('formWA');
            let selectSum = document.getElementById('selectSum');

            // sembunyikan semua dulu
            formWebsite.style.display = 'none';
            formEmail.style.display = 'none';
            formTelp.style.display = 'none';
            formWA.style.display = 'none';

            // tampilkan sesuai pilihan
            if (nilai == 'Website') {
                formWebsite.style.display = 'block';
                selectSum.style.display = 'flex';
            } else if (nilai == 'Email') {
                formEmail.style.display = 'block';
                selectSum.style.display = 'flex';
            } else if (nilai == 'Telp') {
                formTelp.style.display = 'block';
                selectSum.style.display = 'flex';
            } else if (nilai == 'WA') {
                formWA.style.display = 'block';
                selectSum.style.display = 'flex';
            }
        }

        document.getElementById('sumber').addEventListener('change', toggleChecker);
        document.addEventListener('DOMContentLoaded', toggleChecker);
    </script>
    <!-- INI FOOTER -->
    <?php
    include "asset/footer.php";
    ?>
</body>

</html>