<?php
include '../../config/conn.php';
if ($_GET['aksi'] == '') {
    $jenis = $_GET['type'];


    $hariini = date('Y-m-d');
    $query_saldo = mysqli_query($conn, "SELECT SUM(debit) as jumlah_debit, SUM(kredit) as jumlah_kredit FROM transaksi WHERE  tanggal='$hariini'");

    $row_saldo = mysqli_fetch_array($query_saldo);
    $saldo_keseluruhan = $row_saldo['jumlah_debit'] - $row_saldo['jumlah_kredit'];


?>

    <!-- page content -->
    <div class="col" role="main">
        <div class="">


            <div class="row">
                <div class="col-md-10 col-sm-12 col-xs-12 margin-center">
                    <div class="x_panel">
                        <div class="x_title" style="text-transform: capitalize; margin:0;">
                            <h2 >Data TRANSAKSI HARIAN <?php echo $hariini; ?></h2>

                            <div class="clearfix"></div>




                        </div><br>
                        <div class="col-md-9 col-sm-12 col-xs-12">
                            <?php if ($_GET['type'] == '5' or $_GET['type'] == '10' or $_GET['type'] == '11' or $_GET['type'] == '12' or $_GET['type'] == '13' or $_GET['type'] == '14') {
                            } else { ?>

                                <a class="btn btn-success btn-sm" data-toggle="modal" data-target="#pemasukan"><i class="glyphicon glyphicon-save-file"></i> Pemasukan</a>
                                <a class="btn btn-danger btn-sm" data-toggle="modal" data-target="#pengeluaran"><i class="glyphicon glyphicon-open-file"></i> Pengeluaran</a>
                                <a class="btn btn-warning btn-sm" data-toggle="modal" data-target="#mutasi"><i class="glyphicon glyphicon-open-file"></i> Pindah dana</a>

                            <?php }
                            //khusu donatur

                            if ($_GET['type'] == '10') {
                                echo " <a class='btn btn-danger btn-sm' data-toggle='modal' data-target='#pengeluaran'><i class='glyphicon glyphicon-open-file'></i> Pengeluaran</a>";
                            }

                            ?>

                        </div>



                        <a class="btn btn-primary btn-sm" href="component/com_transaksi/export_harian.php?type=<?php echo $jenis; ?>&<?php if ($_GET['periode'] == 'y') {
                                                                                                                                            echo "periode=y&tanggal1=$tgl1&tanggal2=$tgl2";
                                                                                                                                        } else {
                                                                                                                                            echo "periode=";
                                                                                                                                        } ?>"><i class="fa fa-print"></i> Cetak Laporan</a>
                                                                                                                                        
                        <a class="btn btn-success btn-sm" href="?module=lap-transaksiharian"><i class="fa fa-eye"></i> Lihat Laporan</a>
                        <a class="btn btn-warning btn-sm" data-toggle="modal" data-target="#uangawal""><i class="fa fa-money"></i> Tambah Uang Awal</a>

                    </div>
                </div>

            </div>
        </div>
    </div>
    <!-- /page content --><br>


    <!-- edit data transaksi -->
<?php } elseif ($_GET['aksi'] == 'form_edit') {  ?>
    <div class="col" role="main">
        <div class="">
            <div class="clearfix"></div>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">

                        <form action="?module=transaksiharian&aksi=simpan_edit" enctype="multipart/form-data" method="POST">
                            <?php


                            $query = "SELECT * FROM transaksi WHERE id_transaksi='$_GET[id_tran]' ";
                            $hasil = mysqli_query($conn, $query);
                            $data = mysqli_fetch_array($hasil);
                            if ($data['kredit'] == 0) {
                                $jenis = "1";
                            } else {
                                $jenis = "0";
                            }

                            ?>
                            <label for="id">ID Transaksi * :</label>
                            <input type="text" class="form-control" disabled value="<?php echo $_GET['id_tran'];
                                                                                    ?>" />
                            <input type="hidden" class="form-control" name="id" value="<?php echo $_GET['id_tran']; ?>" />
                            <input type="hidden" class="form-control" name="type" value="<?php echo $_GET['type']; ?>" />

                            <label for="id">Jenis * :</label>
                            <input type="text" class="form-control" disabled value="<?php if ($jenis == "1") {
                                                                                        echo "pemasukan";
                                                                                    } else {
                                                                                        echo "pengeluaran";
                                                                                    }
                                                                                    ?>">
                            <input type="hidden" class="form-control" name="jenis" value="<?php echo $jenis; ?>" />


                            <label f>Tanggal pembayaran * :</label>
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                                <input type="text" class="form-control " autocomplete="off" value="<?php echo date('d-m-Y', strtotime($data['tanggal'])); ?>" id="tanggal4" name="tanggal" required>
                            </div>
                            <label f>Jenis Transaksi * :</label>
                            <select id="heard" class="form-control" required name="jenis_transaksi">

                                <option value="" selected>- Pilih Jenis -</option>
                                <?php

                                $query2  = "SELECT * FROM jenis_transaksi ORDER BY nama_jenis ASC";
                                $tampil2 = mysqli_query($conn, $query2);
                                while ($w = mysqli_fetch_array($tampil2)) { ?>
                                    <option value="<?php echo $w['id_jenis']; ?>" <?php if ($data['id_jenis'] == $w['id_jenis']) {
                                                                                        echo "selected";
                                                                                    } ?>><?php echo $w['nama_jenis']; ?></option>";
                                <?php }
                                ?>
                            </select>

                            <label>Jumlah pembayaran *:</label>
                            <input style="font-weight: bold;color:black;font-size:large" type="number" class="form-control" autocomplete="off" name="jumlah_bayar" value="<?php if ($data['debit'] == "0") {
                                                                                                                                                                                echo $data['kredit'];
                                                                                                                                                                            } else {
                                                                                                                                                                                echo $data['debit'];
                                                                                                                                                                            } ?>" required />

                            <label f>Jenis Pembayaran * :</label>
                            <select id="heard" class="form-control" required name="jenis_kas">

                                <option value="" selected>- Pilih Jenis -</option>
                                <?php

                                $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                                $tampil2 = mysqli_query($conn, $query2);
                                while ($w = mysqli_fetch_array($tampil2)) {
                                ?>
                                    <option value="<?php echo $w['id']; ?>" <?php if ($data['jenis_kas'] == $w['id']) {
                                                                                echo "selected";
                                                                            } ?>><?php echo $w['nama']; ?></option>";
                                <?php
                                }
                                ?>
                            </select>

                            <label for="alamat">Keterangan :</label>
                            <textarea class="form-control" name="keterangan"><?php echo $data['keterangan']; ?></textarea>


                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default btn-sm" onclick=self.history.back()>Batal</button>
                        <button type="submit" class="btn btn-success btn-sm">Simpan</button>
                    </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
    </div>






<?php } elseif ($_GET['aksi'] == 'pemasukan') {

    $tgl = date('Y-m-d', strtotime($_POST['tanggal']));
    $save = mysqli_query($conn, "INSERT INTO transaksi(id_transaksi,
                                  tanggal,
                                  debit,
                                  kredit,
                                  keterangan,id_jenis,id_pegawai,jenis_kas) VALUES('$_POST[id]',
                                                 '$tgl',
                                                 '$_POST[debit]',
                                                 '0',
                                                 '$_POST[keterangan]','$_POST[jenis_transaksi]','$_SESSION[id]','$_POST[jenis_kas]')");
    // echo "<script language='javascript'>document.location='?module=transaksiharian';</script>";
    if (!$save) {
        echo "<script>nSimpan('?module=transaksiharianinput');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    }

    // $query_saldo=mysqli_query($conn,"SELECT SUM(debit) as jumlah_debit, SUM(kredit) as jumlah_kredit FROM transaksi WHERE id_nasabah ='$_POST[id_nasabah]'");
    // $saldo = mysqli_fetch_array($query_saldo);
    // $saldoo= $saldo['jumlah_debit'] - $saldo['jumlah_kredit'];
    // mysqli_query($conn,"UPDATE nasabah SET saldo = '$saldoo'
    //                                 WHERE id_nasabah = '$_POST[id_nasabah]'");




    //echo "<script language='javascript'>document.location='?module=transaksi&hehe=';</script>";


?>


<?php


} elseif ($_GET['aksi'] == 'pengeluaran') {
    $tgl = date('Y-m-d', strtotime($_POST['tanggal']));
    $save = mysqli_query($conn, "INSERT INTO transaksi(id_transaksi,
                                  tanggal,
                                  debit,
                                  kredit,
                                  keterangan,id_jenis,id_pegawai,jenis_kas) VALUES('$_POST[id]',
                                                 '$tgl',
                                                 '0',
                                                 '$_POST[kredit]',
                                                 '$_POST[keterangan]','$_POST[jenis_transaksi]','$_SESSION[id]','$_POST[jenis_kas]')");

    // echo "<script language='javascript'>document.location='?module=transaksiharian';</script>";
    if (!$save) {
        echo "<script>nSimpan('?module=transaksiharianinput');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    }
}elseif ($_GET['aksi'] == 'uangawal') {
    $tgl = date('Y-m-d', strtotime($_POST['tanggal']));
    $save = mysqli_query($conn, "INSERT INTO transaksi_uangawal(
                                  tanggal,
                                  jumlah,
                                  keterangan,
                                  jenis_kas,id_pegawai) VALUES(
                                                 '$tgl',
                                                 '$_POST[jumlah]',
                                                 '$_POST[keterangan]','$_POST[jenis_kas]','$_SESSION[id]')");

    // echo "<script language='javascript'>document.location='?module=transaksiharian';</script>";
    if (!$save) {
        echo "<script>nSimpan('?module=transaksiharianinput');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'],"uang awal");
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    }
} elseif ($_GET['aksi'] == 'simpan_edit') {

    $module = $_GET['module'];
    $tgl1 = date('Y-m-d', strtotime($_POST['tanggal']));

    //log edit 
    $query = "SELECT * FROM transaksi WHERE id_transaksi='$_POST[id]' ";
    $hasil = mysqli_query($conn, $query);
    $data = mysqli_fetch_array($hasil);


    $logedit = $data['log_edit'] . "[" . $_SESSION['id'] . "~" . date('Y-m-d H:i:s') . "]";


    if ($_POST['jenis'] == "1") {

        $save = mysqli_query($conn, "UPDATE transaksi SET tanggal = '$tgl1',
                                    debit = '$_POST[jumlah_bayar]',
                                    keterangan = '$_POST[keterangan]',
                                    jenis_kas='$_POST[jenis_kas]',id_jenis='$_POST[jenis_transaksi]',
                                    log_edit='$logedit'
                                    WHERE id_transaksi = '$_POST[id]'");
    } else {
        $save = mysqli_query($conn, "UPDATE transaksi SET tanggal = '$tgl1',
    kredit = '$_POST[jumlah_bayar]',
    keterangan = '$_POST[keterangan]',
    jenis_kas='$_POST[jenis_kas]',id_jenis='$_POST[jenis_transaksi]',
    log_edit='$logedit'
    WHERE id_transaksi = '$_POST[id]'");
    }

    // echo "<script language='javascript'>document.location='?module=transaksiharian';</script>";
    if (!$save) {
        echo mysqli_error($conn);
        echo "gagal";
        echo "<script>nSimpan('?module=transaksiharianinput');</script>";
    } else {
        historyedit($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    }
} elseif ($_GET['aksi'] == 'hapus') {

    $query = mysqli_query($conn, "DELETE FROM transaksi WHERE id_transaksi='$_GET[id_tran]'") or die("GAGAL");
    // echo "<script language='javascript'>document.location='?module=transaksi&type=$_GET[type]';</script>";
    if (!$query) {
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    } else {
        historyhapus($_GET['id_tran'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharianinput');</script>";
    }
} elseif ($_GET['aksi'] == 'mutasi') {
//untuk mutasi


 $ket_mutasi = "$_POST[dari_kas] to -> $_POST[ke_kas] | ";
 $module = $_GET['module'];
        $tgl = date('Y-m-d', strtotime($_POST['tanggal']));
            $jen = '2';
            $save = mysqli_query($conn, "INSERT INTO transaksi(
                                          tanggal,
                                          debit, 
                                          kredit,
                                          keterangan,id_jenis,id_pegawai,jenis_kas) VALUES(
                                                         '$tgl',
                                                         '0',
                                                         '$_POST[jumlah_mutasi]',
                                                         '$ket_mutasi- $_POST[keterangan]','22','$_SESSION[id]','$_POST[dari_kas]')");
        // echo "<script language='javascript'>document.location='?module=pembayaran-dam&aksi=tambah_dam&id=$id_san';</script>";
        if (!$save) {
            echo "gagal";
            echo "<script>nSimpan('?module=proses-transaksi&id=$rek');</script>";
        } else {
            historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $jen);
            $save1 = mysqli_query($conn, "INSERT INTO transaksi(
                                          tanggal,
                                          debit,
                                          kredit,
                                          keterangan,id_jenis,id_pegawai,jenis_kas) VALUES(
                                                         '$tgl',
                                                         '$_POST[jumlah_mutasi]',
                                                         '0',
                                                         '$ket_mutasi- $_POST[keterangan]','22','$_SESSION[id]','$_POST[ke_kas]')");


            if (!$save1) {
                echo "gagal masuk pembukuan utama";
                echo "<script>nSimpan('?module=transaksiharianinput');</script>";
            } else {
                echo "<script>ySimpan('?module=transaksiharianinput');</script>";
                echo "sukses";
            }
        }
    }
 ?>



<!--  pemasukan -->
<div class="modal fade" id="pemasukan" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Tambah Data pemasukan</h4>
            </div>
            <div class="modal-body">
                <form action="?module=transaksiharian&aksi=pemasukan" enctype="multipart/form-data" method="POST">
                    <?php
                    $query = "SELECT max(id_transaksi) as maxID FROM transaksi ";
                    $hasil = mysqli_query($conn, $query);
                    $data = @mysqli_fetch_array($hasil);
                    $rand = rand(100, 999);
                    include 'id_transaksi.php';
                    ?>
                    <label for="id">ID transaksi * :</label>
                    <input type="text" class="form-control" disabled value="<?php echo id_transaksi(); ?>" />
                    <input type="hidden" class="form-control" name="id" value="<?php echo id_transaksi(); ?>" />


                    <label f>Tanggal * :</label>
                    <div class="input-group">
                        <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                        <input type="text" class="form-control" required value="<?php echo date('d-m-Y'); ?>" id="tanggal4" autocomplete="off">
                        <input type="hidden" value="<?php echo date('d-m-Y'); ?>" name="tanggal">
                    </div>
                    <label f>Jenis Transaksi * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_transaksi">

                        <option value="" selected>- Pilih Jenis -</option>
                        
                      
                        <?php
                        if ($_SESSION['leveluser'] == 'admin') {
                        $query2  = "SELECT * FROM jenis_transaksi ORDER BY nama_jenis";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</option>";
                        }
                        }else{ 
                            $query2  = "SELECT * FROM jenis_transaksi  WHERE jenis='1' OR jenis='3' OR id_jenis='7' ORDER BY nama_jenis";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</option>";
                        }
                        }
                        ?>
                    </select>
                      
                    <label>Jumlah (Rp) *:</label>
                    <input type="hidden" class="form-control" name="kredit" />
                    <input style="font-weight: bold;color:black;font-size:large" type="number" class="form-control" id="t3" name="debit" autofocus=”autofocus” autocomplete="off" />
                    <div class="input-group">

                        <button type="button" class="btn btn-danger" onclick="resetcash();"><i class="fa fa-refresh" aria-hidden="true"></i></button>
                        <button type="button" class="btn btn-info" onclick="cashsepuluh();">+ 10.000</button>
                        <button type="button" class="btn btn-info" onclick="cashlima();">+ 5.000</button>
                        <button type="button" class="btn btn-info" onclick="cashdua();">+ 2.000</button>
                        <button type="button" class="btn btn-info" onclick="cashsatu();">+ 1.000</button>
                    </div>
                    <div class="input-group">

                        <!-- <button type="button" class="btn btn-danger" onclick="resetcash();"><i class="fa fa-refresh" aria-hidden="true"></i></button> -->
                        <button type="button" class="btn btn-info" onclick="cashlimaratus();">+ 500.000</button>
                        <button type="button" class="btn btn-info" onclick="cashseratus();">+ 100.000</button>
                        <button type="button" class="btn btn-info" onclick="cashlimapuluh();">+ 50.000</button>
                    </div>

                    <label f>Jenis Pembayaran * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_kas">

                        <option value="" selected>- Pilih Jenis -</option>
                        <?php

                        $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id]\">$w[nama]</option>";
                        }
                        ?>
                    </select>


                    <label>Keterangan *:</label>

                    <script type="text/javascript">
                        function changetextbox() {
                            if (document.getElementById("barang").value != 0) {
                                document.getElementById("keterangan").disabled = true;
                                document.getElementById("keterangan").value = '';
                            } else {
                                document.getElementById("keterangan").disabled = false;
                            }
                        }
                    </script>
                    <?php if ($_GET['type'] == 100) { ?>
                        <select onchange="changetextbox();" id="barang" class="form-control" name="level">
                            <option value=0>Lainnya</option>
                            <option value=2>yes</option>
                            <option value=3>semen</option>
                            <option value=4>semongko</option>
                            <option value=5>setia</option>
                            <option value=6>senama</option>

                        </select>
                    <?php } ?>
                    <!--<a data-dismiss="modal"  data-toggle="modal" data-target="#data_item"><i class="glyphicon glyphicon-open-file"></i> Data item</a>-->
                    <textarea class="form-control" name="keterangan" id="keterangan"></textarea>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Batal</button>
                <button type="submit" class="btn btn-success btn-sm">Simpan</button>
            </div>
            </form>
        </div>
    </div>
</div>

 <!-- untuk MUTASI -->
            <div class="modal fade" id="mutasi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header" style="background-color:seagreen; color:white">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h3 class="modal-title" id="myModalLabel">Setor Dana</h3>
                        </div>
                        <div class="modal-body">
                            <form action="?module=transaksiharian&aksi=mutasi" enctype="multipart/form-data" method="POST">
                                <?php
                                $query = "SELECT max(id_transaksi) as maxID FROM transaksi ";
                                $hasil = mysqli_query($conn, $query);
                                $data = @mysqli_fetch_array($hasil);
                                $rand = rand(100, 999);
                                $urut = date('ymdHi');

                                $char = $urut . $rand;
                                $newID = $char;
                                ?>

                                <label f>Tanggal * :</label>
                                <div class="input-group">
                                    <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                                    <input type="text" class="form-control " disabled autocomplete="off" value="<?php echo date('d-m-Y'); ?>" id="tanggal4" required>
                                    <input type="hidden" value="<?php echo date('d-m-Y'); ?>" name="tanggal">

                                </div>

                                <label>Jumlah Mutasi *:</label>
                                <input type="text" style="font-size: x-large; color:black;font-weight:bold" onkeyup="currency('rupiah1','rupiahesc1');" id="rupiah1" name="jumlah_mutasi" class="form-control" autocomplete="off" required>


                                <label f>Mutasi Dari * :</label>
                                <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="dari_kas">

                                    <option value="" selected>- Pilih Jenis -</option>
                                    <?php

                                    $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                                    $tampil2 = mysqli_query($conn, $query2);
                                    while ($w = mysqli_fetch_array($tampil2)) {
                                        echo "<option value=\"$w[id]\">$w[nama]</option>";
                                    }
                                    ?>
                                </select>
                                
                                <label f>Mutasi Ke * :</label>
                                <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="ke_kas">

                                    <option value="" selected>- Pilih Jenis -</option>
                                    <?php

                                    $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                                    $tampil2 = mysqli_query($conn, $query2);
                                    while ($w = mysqli_fetch_array($tampil2)) {
                                        echo "<option value=\"$w[id]\">$w[nama]</option>";
                                    }
                                    ?>
                                </select>

                                <label for="alamat">Keterangan :</label>
                                <textarea class="form-control" name="keterangan"></textarea>


                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Batal</button>
                            <button type="submit" class="btn btn-success btn-sm">Simpan</button>
                        </div>
                        </form>
                    </div>
                </div>
            </div>

<!--  input pengeluaran -->
<div class="modal fade" id="pengeluaran" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Tambah Data pengeluaran</h4>
            </div>
            <div class="modal-body">
                <form action="?module=transaksiharian&aksi=pengeluaran" enctype="multipart/form-data" method="POST">
                    <?php
                    $query = "SELECT max(id_transaksi) as maxID FROM transaksi ";
                    $hasil = mysqli_query($conn, $query);
                    $data = @mysqli_fetch_array($hasil);
                    $idMax = $data['maxID'];
                    $rand = rand(100, 999);

                    ?>
                    <label for="id">ID transaksi * :</label>
                    <input type="text" class="form-control" disabled value="<?php echo id_transaksi(); ?>" />
                    <input type="hidden" class="form-control" name="id" value="<?php echo id_transaksi(); ?>" />


                    <label f>Tanggal * :</label>
                    <div class="input-group">
                        <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                        <input type="text" class="form-control" value="<?php echo date('d-m-Y'); ?>" required id="tanggal3" autocomplete="off">
                        <input type="hidden" value="<?php echo date('d-m-Y'); ?>" name="tanggal">
                    </div>
                    <label f>Jenis Transaksi * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_transaksi">

                        <option value="" selected>- Pilih Jenis -</option>
                        
                      
                        <?php
                        if ($_SESSION['leveluser'] == 'admin') {
                        $query2  = "SELECT * FROM jenis_transaksi ORDER BY nama_jenis";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</option>";
                        }
                        }else{ 
                            $query2  = "SELECT * FROM jenis_transaksi  WHERE jenis='2' OR jenis='3' OR id_jenis='7' ORDER BY nama_jenis";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</option>";
                        }
                        }
                        ?>
                    </select>


                    <label>Jumlah (Rp) *:</label>

                    <input type="hidden" class="form-control" name="debit" />
                    <input style="font-weight: bold;color:black;font-size:large" type="number" id="t4" class="form-control" name="kredit" autofocus=”autofocus” autocomplete="off">
                    <div class="input-group">

                        <button type="button" class="btn btn-danger" onclick="resetcash();"><i class="fa fa-refresh" aria-hidden="true"></i></button>
                        <button type="button" class="btn btn-info" onclick="cashsepuluh();">+ 10.000</button>
                        <button type="button" class="btn btn-info" onclick="cashlima();">+ 5.000</button>
                        <button type="button" class="btn btn-info" onclick="cashdua();">+ 2.000</button>
                        <button type="button" class="btn btn-info" onclick="cashsatu();">+ 1.000</button>
                    </div>

                    <label f>Jenis Pembayaran * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_kas">

                        <option value="" selected>- Pilih Jenis -</option>
                        <?php

                        $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id]\">$w[nama]</option>";
                        }
                        ?>
                    </select>


                    <label>Keterangan *:</label>
                    <textarea class="form-control" name="keterangan" required></textarea>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Batal</button>
                <button type="submit" class="btn btn-success btn-sm">Simpan</button>
            </div>
            </form>
        </div>
    </div>
</div>

<!--uang awal-->
<div class="modal fade" id="uangawal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Tambah Uang Awal</h4>
            </div>
            <div class="modal-body">
                <form action="?module=transaksiharian&aksi=uangawal" enctype="multipart/form-data" method="POST">
                    <?php
                    $query = "SELECT max(id_transaksi) as maxID FROM transaksi ";
                    $hasil = mysqli_query($conn, $query);
                    $data = @mysqli_fetch_array($hasil);
                    $idMax = $data['maxID'];
                    $rand = rand(100, 999);

                    ?>
                    <label f>Tanggal * :</label>
                    <div class="input-group">
                        <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                        <input type="text" class="form-control" value="<?php echo date('d-m-Y'); ?>" required id="tanggal3" autocomplete="off">
                        <input type="hidden" value="<?php echo date('d-m-Y'); ?>" name="tanggal">
                    </div>

                    <label>Jumlah Tambah Uang (Rp) *:</label>

                    <input style="font-weight: bold;color:black;font-size:large" type="number" id="t4" class="form-control" name="jumlah" autofocus=”autofocus” autocomplete="off">

                    <label f>Jenis Kas * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_kas">

                        <option value="" selected>- Pilih Jenis -</option>
                        <?php

                        $query2  = "SELECT * FROM jenis_kas ORDER BY id";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            echo "<option value=\"$w[id]\">$w[nama]</option>";
                        }
                        ?>
                    </select>


                    <label>Keterangan *:</label>
                    <textarea class="form-control" name="keterangan" required></textarea>


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Batal</button>
                <button type="submit" class="btn btn-success btn-sm">Simpan</button>
            </div>
            </form>
        </div>
    </div>
</div>



<script>
    //fungsi hitung tambah uang saku
    function sum() {
        var txtFirstNumberValue = document.getElementById('txt1').value;
        var txtSecondNumberValue = document.getElementById('txt3').value;
        var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue);
        if (!isNaN(result)) {
            document.getElementById('txt2').value = result;
            document.getElementById('txt4').value = result;
        } else {
            document.getElementById('txt2').value = txtFirstNumberValue;
        }

    }


    function cashsatu() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 1000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashdua() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 2000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashlima() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 5000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashsepuluh() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 10000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashlimapuluh() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 50000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashseratus() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 100000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function cashlimaratus() {
        var txttambah = document.getElementById('t3').value;

        if (txttambah === "") {
            txttambah = 0;
        }
        var txttambah = parseInt(txttambah) + 500000;
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;

    }

    function resetcash() {

        var txttambah = "";
        document.getElementById('t3').value = txttambah;
        document.getElementById('t4').value = txttambah;


    }

    function isNumberKey(evt) {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))

            return false;
        return true;
    }
</script>