Select menggunakan form edit modal tidak bisa POST

om tante mohon bantuan untuk newbie terkait select menggunakan form edit modal yang ga bisa kirim data. Tetapi jika untuk tambah data tidak ada masalah. Input lainnya terkirim, hanya select pada saat edit saja yg kosong.

Berikut script nya

Script Tabel dan Form

<?php
if ($_SESSION['LEVEL'] != '1') {
    session_destroy();
    echo "<script>alert('Anda Tidak Mempunyai Hak Mengakses Halaman Ini!');document.location='../login.php'</script>";
}
$page       = base64_encode('triwulan');
$page_save  = base64_encode('simpan_triwulan');
$triwulan   = getTriwulan();
?>

<!-- header dan breadcumb -->
<section class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h2>Triwulan</h2>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><?= $_SESSION['LOGIN_AS']; ?></a></li>
                    <li class="breadcrumb-item">Master</li>
                    <li class="breadcrumb-item active">Triwulan</li>
                </ol>
            </div>
        </div>
    </div>
</section>
<!-- End header dan breadcumb -->
<?= flashdata(base64_decode($_REQUEST['message'])); ?>
<!-- Start Content -->
<div class="card">
    <div class="card-header card-header-primary card-header-icon">
        <div class="card-icon">
            <i class="material-icons">account_circle</i>
        </div>
        <h4 class="card-title">Triwulan</h4>
    </div>
    <div class="card-body">
        <a href="#" class="btn btn-primary btn-round" data-toggle="modal" data-target="#TambahTriwulan"><i class="fa fa-plus"></i> Tambah</a>
        <!-- <a href="?ret=<?= $page; ?>&pModule=<?= $page_form; ?>&pAct=<?= base64_encode('Tambah'); ?>"
            class="btn btn-primary btn-round"><i class="fa fa-plus"></i> Tambah</a> -->
        <!-- Start table-responsive -->
        <div class="material-datatables">
            <table id="datatables" class="table table-striped table-no-bordered table-hover" cellspacing="0" width="100%" style="width:100%">
                <thead>
                    <th bgcolor="#48C9B0" width="5%">
                        <center><b>No.</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="5%">
                        <center><b>Triwulan</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="5%">
                        <center><b>Tahun</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="10%">
                        <center><b>Status</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="10%">
                        <center><b>Created Date</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="10%">
                        <center><b>Modified Date</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="10%">
                        <center><b>User Log</b></center>
                    </th>
                    <th bgcolor="#48C9B0" width="10%">
                        <center><b>Aksi</b></center>
                    </th>
                </thead>
                <?php
                foreach ($triwulan as $data) :
                    $no++;
                    $id_triwulan    = $data['id_triwulan'];
                    $triwulan       = $data['triwulan'];
                    $tahun          = $data['tahun'];
                    if ($data['active_is'] == '1') {
                        $status = "<span class='badge badge-success'>Aktif</span>";
                    } else {
                        $status = "<span class='badge badge-danger'>Tidak Aktif</span>";
                    }
                    $user_log       = $data['user_log'];
                ?>
                    <tr>
                        <td align="center"><?= $no; ?></td>
                        <td align="center"><?= $triwulan; ?></td>
                        <td align="center"><?= $tahun; ?></td>
                        <td align="center"><?= $status; ?></td>
                        <td align="center"><?php if ($data['created_date'] == '0000-00-00 00:00:00') {
                                                echo '';
                                            } else {
                                                echo date('d-m-Y H:i:s', strtotime($data['created_date']));
                                            } ?></td>
                        <td align="center"><?php if ($data['modified_date'] == '0000-00-00 00:00:00') {
                                                echo '';
                                            } else {
                                                echo date('d-m-Y H:i:s', strtotime($data['modified_date']));
                                            } ?></td>
                        <td align="center"><?= $user_log; ?></td>
                        <td align="center">
                            <span class="d-inline-block" tabindex="1" data-toggle="tooltip" title="Ubah Triwulan">
                                <a href="#" id="ubah" class="btn btn-primary btn-round btn-fab btn-sm" data-toggle="modal" data-target="#edit-data<?= $id_triwulan; ?>"><i class=" fa fa-pencil"></i> </a>
                            </span>
                            <span class="d-inline-block" tabindex="1" data-toggle="tooltip" title="Aktivasi Triwulan">
                                <a href="?pModule=<?= $page; ?>&pSub=<?= $page_save; ?>&pAct=<?= base64_encode('Aktivasi'); ?>&triwulan=<?= base64_encode($id_triwulan); ?>&token=<?= $_SESSION['csrf_token']; ?>" class="btn btn-success btn-sm btn-round btn-fab"><i class="fa fa-key"></i> </a>
                            </span>
                            <span class="d-inline-block" tabindex="1" data-toggle="tooltip" title=" Hapus Triwulan">
                                <a class="btn btn-danger btn-round btn-sm btn-fab tip-bottom" data-placement="right" class="btn btn-danger" data-toggle="modal" href="#KonfirmasiHapus" onclick="set_url('?pSub=<?= $page; ?>&pModule=<?= $page_save; ?>&pAct=<?= base64_encode('Hapus'); ?>&user=<?= base64_encode($id_user); ?>&token=<?= $_SESSION['csrf_token']; ?>');"><i class="fa fa-trash"></i></a>
                            </span>
                        </td>
                    </tr>
                    <!-- ### UBAH MODAL TRIWULAN ### -->
                    <div class="modal fade bd-example-modal-lg" id="edit-data<?= $id_triwulan; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header btn-info">
                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                    <h3 class="modal-title">Ubah Triwulan</h3>
                                </div>
                                <div class="modal-body">
                                    <form method="POST" enctype="multipart/form-data" action="?pModule=<?= $page; ?>&pSub=<?= $page_save; ?>&pAct=<?= base64_encode('Ubah'); ?>&token=<?= $_SESSION['csrf_token']; ?>&triwulan=<?= base64_encode($id_triwulan); ?>">
                                        <div class="row">
                                            <label class="col-sm-2 col-form-label">Triwulan</label>
                                            <div class="col-sm-10">
                                                <div class="form-group">
                                                    <select name="tri" class="form-control selectpicker" data-style="select-with-transition" title="Pilih Triwulan" id="tri" required autofocus>
                                                        <option value="I" <? if($triwulan=="I" ){ echo "selected" ;}?>>I</option>
                                                        <option value="II" <? if($triwulan=="II" ){ echo "selected" ;}?>>II</option>
                                                        <option value="III" <? if($triwulan=="III" ){ echo "selected" ;}?>>III</option>
                                                        <option value="IV" <? if($triwulan=="IV" ){ echo "selected" ;}?>>IV</option>
                                                    </select>
                                                    <!-- <input type="text" name="tri" value="<?= $triwulan; ?>" class="form-control" maxlength="4" id="tri"> -->
                                                </div>
                                            </div>
                                            <label class="col-sm-2 col-form-label">Tahun</label>
                                            <div class="col-sm-10">
                                                <div class="form-group">
                                                    <input type="text" name="tahun" id="tahun" value="<?= $tahun; ?>" class="form-control" maxlength="4" minlength="4" value="<?= $thn; ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="modal-footer">
                                            <button type="submit" class="btn btn-primary btn-round"><i class="fa fa-save"></i> Ubah</button>&nbsp;
                                            <button type="button" class="btn btn-danger btn-round" data-dismiss="modal"><i class="fa fa-close"></i>
                                                Tutup</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <!-- ### UBAH MODAL TRIWULAN ### -->
                    <?php endforeach; ?>
            </table>
        </div>
    </div>
</div>

<!-- ### MODAL TAMBAH TRIWULAN #### -->
<div class="modal fade bd-example-modal-lg" id="TambahTriwulan" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header btn-info">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">Tambah Triwulan</h3>
            </div>
            <div class="modal-body">
                <form method="POST" enctype="multipart/form-data" action="?pModule=<?= $page; ?>&pSub=<?= $page_save; ?>&pAct=<?= base64_encode('Tambah'); ?>&token=<?= $_SESSION['csrf_token']; ?>">
                    <div class="row">
                        <label class="col-sm-2 col-form-label">Triwulan</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                <select name="tri" class="form-control selectpicker" data-style="select-with-transition" title="Pilih Triwulan" id="triwulan" required autofocus>
                                    <option value="I">I</option>
                                    <option value="II">II</option>
                                    <option value="III">III</option>
                                    <option value="IV">IV</option>
                                </select>
                            </div>
                        </div>
                        <label class="col-sm-2 col-form-label">Tahun</label>
                        <div class="col-sm-10">
                            <div class="form-group">
                                <input type="text" name="tahun" class="form-control" maxlength="4" minlength="4" id="tahun">
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary btn-round"><i class="fa fa-save"></i> Simpan</button>&nbsp;
                        <button type="button" class="btn btn-danger btn-round" data-dismiss="modal"><i class="fa fa-close"></i>
                            Tutup</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- ### END MODAL TAMBAH TRIWULAN ### -->

<!-- ### HAPUS TRIWULAN ### -->
<div class="modal fade" id="KonfirmasiHapus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">Konfirmasi</h3>
            </div>
            <div class="modal-body btn-info">
                <h4>Apakah anda yakin data ini akan <b>dihapus</b>?</h4>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info btn-round" data-dismiss="modal"><i class="fa fa-close"></i>
                    Tidak</button>
                <a class="btn btn-danger btn-round" id="btn-yes"><i class="fa fa-trash"></i> Ya</a>
            </div>
        </div>
    </div>
</div>
<script>
    function set_url(url) {
        $('#btn-yes').attr('href', url);
    }
</script>
<!-- ### END HAPUS TRIWULAN ### -->

Scrip Simpan

<?php
if ($_SESSION['LEVEL'] != '1') {
    session_destroy();
    echo "<script>alert('Anda Tidak Mempunyai Hak Mengakses Halaman Ini!');document.location='login.php'</script>";
    exit();
} else {
    $page               = $_REQUEST['pModule'];
    $pAct               = base64_decode($_REQUEST['pAct']);
    $triwulan           = mysqli_real_escape_string($mysql->connect(), $_POST['tri']);
    $tahun              = mysqli_real_escape_string($mysql->connect(), $_POST['tahun']);
    $id_triwulan        = mysqli_real_escape_string($mysql->connect(), base64_decode($_REQUEST['triwulan']));
    $user_log           = mysqli_real_escape_string($mysql->connect(), $_SESSION['NAMA'] . " (" . $_SESSION['USERNAME'] . ")");
    $csrf_token         = $_REQUEST['token'];
    //untuk redirect
    $user = base64_encode($id_user);
    if ($csrf_token != $_SESSION['csrf_token']) {
        $message = base64_encode(4);
    } else {
        switch ($pAct) {
            case "Tambah":
                $sql    = "INSERT INTO triwulan
                            (id_triwulan,
                            triwulan,
                            tahun,
                            active_is,
                            created_date,
                            modified_date,
                            user_log)
                            VALUES(NULL,
                            '$triwulan',
                            '$tahun',
                            '0',
                            now(),
                            now(),
                            '$user_log') ";
                $mysql->insert($sql);
                $message    = base64_encode(1);
                $tindakan   = "Menambah Data Triwulan";
                break;

            case "Ubah":
                $sql    = "UPDATE triwulan SET
                            triwulan = '$triwulan',
                            tahun = '$tahun',
                            active_is = '0',
                            modified_date = now(),
                            user_log = '$user_log'
                            WHERE id_triwulan = '$id_triwulan'";
                $mysql->update($sql);
                $message    = base64_encode(2);
                $tindakan   = "Mengubah Data Triwulan";
                break;

            case "Hapus":
                $sql    = "DELETE FROM triwulan WHERE id_triwulan = '$id_triwulan'";
                $mysql->delete($sql);
                $message    = base64_encode(3);
                $tindakan   = "Menghapus Data Triwulan";
                break;

            case "Aktivasi":
                $sql    = "UPDATE triwulan SET active_is='0'";
                $mysql->update($sql);
                $sql2   = "UPDATE triwulan SET active_is='1' WHERE id_triwulan = '$id_triwulan'";
                $mysql->update($sql2);
                $message    = base64_encode(7);
                $tindakan   = "Melakukan Aktivasi Triwulan";
                break;
        }
    }
    $aksi = "Unit Kerja-> " . $_SESSION['NAMA'] . ":" . $tindakan;
    insertLog($aksi);
    $mysql->disconnect();
    echo "<script>document.location='?pModule=$page&message=$message' </script> ";
}

avatar hendrahe2885
@hendrahe2885

36 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban