Example #1
0
                </div>
                <div class="box">
                    <?php 
            if (isset($_SESSION['gaji']['gagal'])) {
                echo "<div class='error'>" . $_SESSION['gaji']['gagal'] . "</div>\n";
                unset($_SESSION['gaji']['gagal']);
            }
            ?>
                    <form action="" method="post" autocomplete="off" class="form" name="transfer">
                        <input type="text" name="jam_lembur" placeholder="Isi Total Jam Lembur..." onkeyup="hitung_gaji()" onkeydown="hitung_gaji()" onchange="hitung_gaji()"/>&nbsp;
                        <input type="text" name="gaji_pokok" value="<?php 
            echo $transfer['gapok'];
            ?>
" style="display: none;"/>
                        <input type="text" name="kode_gaji" value="<?php 
            echo atur_kode("tbl_gaji", "kode_gaji", "GJ");
            ?>
" style="display: none;"/>
                        <input type="text" name="uang_lembur" placeholder="Uang Lembur..."/><br>
                        <input type="submit" name="act" value="Transfer Gaji"/>
                    </form>
                </div>
                <?php 
        }
    } elseif ($page == 'data-transfer-gaji') {
        if ($id_karyawan) {
            $transfer_gaji = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM tbl_karyawan k,tbl_gaji g WHERE k.id_karyawan=g.id_karyawan AND k.id_karyawan='" . $id_karyawan . "'"));
            ?>
                <div class="box">
                    <h1>Data Transfer Gaji</h1>
                    <p>Berikut ini adalah detail proses transfer gaji bulanan untuk karyawan:</p>
    }
    if (count($errormsg)) {
        $_SESSION['edit-karyawan']['gagal'] = implode('<br>', $errormsg);
    }
    if (count($errormsg)) {
        header("Location: index.php?page=edit-karyawan&id_karyawan={$id_karyawan}");
    } else {
        header("Location: index.php?page=daftar-karyawan");
    }
    exit;
} elseif ($act == 'Transfer Gaji') {
    // Proses penerimaan gaji
    $id_karyawan = isset($_GET['id_karyawan']) ? $_GET['id_karyawan'] : '';
    $jam_lembur = isset($_POST['jam_lembur']) ? $_POST['jam_lembur'] : '';
    $uang_lembur = isset($_POST['uang_lembur']) ? $_POST['uang_lembur'] : '';
    $kode = atur_kode("tbl_gaji", "kode_gaji", "GJ");
    // kode urut gaji
    $bln_transfer = date("F Y");
    $tgl_transfer = date("d/m/Y");
    $jam_transfer = date("H:i:s");
    $errormsg = array();
    // Ambil data karyawan
    $karyawan = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM tbl_karyawan WHERE id_karyawan='" . $id_karyawan . "'"));
    $total_gaji = $uang_lembur + $karyawan['gapok'];
    if (empty($jam_lembur)) {
        $errormsg[] = 'Harap mengisi total jam lembur karyawan.';
    }
    if (!count($errormsg)) {
        mysqli_query($con, "INSERT INTO tbl_gaji VALUES('','" . $id_karyawan . "','" . $kode . "','" . $jam_lembur . "','" . $uang_lembur . "','" . $total_gaji . "','" . $bln_transfer . "','" . $tgl_transfer . "','" . $jam_transfer . "')");
    }
    if (count($errormsg)) {