<?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-12 col-sm-12 col-xs-12 margin-center">
                    <div class="x_panel">
                        <div class="x_title" style="text-transform: capitalize; margin:0;">
                            <h2 style="align: center;">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>
                                <a class="btn btn-primary btn-sm" data-toggle="modal" data-target="#pindahbuku"><i class="glyphicon glyphicon-open-file"></i> Bawa Uang</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>


                        <div class="col-md-3 col-sm-12 col-xs-12" style="margin-left: 0px;">

                            <h4>
                                <table>
                                    <tr style="color:green">
                                        <td><small><b>TOTAL DEBIT </b></small></td>
                                        <td align="right">&nbsp; Rp. <?php echo rupiah($row_saldo['jumlah_debit']); ?></td>
                                    </tr>
                                    <tr style="color:red">
                                        <td id="hit"><small><b>TOTAL KREDIT </b></small></td>
                                        <td align="right">&nbsp; Rp. <?php echo rupiah($row_saldo['jumlah_kredit']); ?></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" height="2px" bgcolor="black"></td>
                                    </tr>
                                    <tr>
                                        <td id="hit"><small><b>TOTAL </b></small></td>
                                        <td align="right">&nbsp; Rp. <?php echo rupiah($saldo_keseluruhan); ?></td>
                                    </tr>
                                </table>
                            </h4>
                        </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 class="x_content" id="timestamp">

                            <table style="font-size:18px;color:black" id="datatable1" class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>NO.</th>
                                        <th>Jenis Kas</th>
                                        <th>Pemasukan</th>
                                        <th>Pengeluaran</th>
                                        <th>
                                            Total
                                        </th>
                                        <th>+ Uang Awal</th>
                                        <th>- Bawa Uang</th>
                                        <th>+ Kembalikan Bawa Uang</th>
                                        <th>Total Akhir</th>

                                        
                                    </tr>
                                </thead>
                                <tbody >
                                    <?php
                                    $no = 0;

                                    $hariini = date('Y-m-d');
                                    $query = mysqli_query($conn, "SELECT 
    j.id, 
    j.nama, 
    SUM(t.debit) AS jumlah_debit, 
    SUM(t.kredit) AS jumlah_kredit,
    COALESCE(u.jumlah_uangawal, 0) AS jumlah_uangawal,
    COALESCE(b1.total_bawa_tgl_totalan, 0) AS jumlah_bawa_tgl_totalan,
    COALESCE(b2.total_bawa_tgl_bawa, 0) AS jumlah_bawa_tgl_bawa
FROM jenis_kas j
LEFT JOIN (
    SELECT jenis_kas, SUM(debit) AS debit, SUM(kredit) AS kredit
    FROM transaksi
    WHERE tanggal = '$hariini'
    GROUP BY jenis_kas
) t ON j.id = t.jenis_kas
LEFT JOIN (
    SELECT jenis_kas, SUM(jumlah) AS jumlah_uangawal
    FROM transaksi_uangawal
    WHERE tanggal = '$hariini'
    GROUP BY jenis_kas
) u ON j.id = u.jenis_kas
LEFT JOIN (
    SELECT jenis_kas, SUM(jumlah_bawa) AS total_bawa_tgl_totalan
    FROM transaksi_bawauang
    WHERE tgl_totalan = '$hariini' AND valid ='1'
    GROUP BY jenis_kas
) b1 ON j.id = b1.jenis_kas
LEFT JOIN (
    SELECT jenis_kas, SUM(jumlah_bawa) AS total_bawa_tgl_bawa
    FROM transaksi_bawauang
    WHERE tgl_bawa = '$hariini'
    GROUP BY jenis_kas
) b2 ON j.id = b2.jenis_kas
GROUP BY j.id, j.nama;
");
                                    
                                    


                                    $count = 2;



                                    while ($row = mysqli_fetch_array($query)) {
                                        $no++;
                                    ?>

                                        <tr style="background: <?php if ($no % 2 == 0) { ?>
                          #defff1;
                          <?php } else { ?>
                            #f2f2f2;
                            <?php } ?>;text-align: right;">
                                            <td><?php echo $no; ?></td>
                                            <td><?php echo $row['nama']; ?></td>
                                            <td><?php echo rupiah($row['jumlah_debit']); ?></td>
                                            <td><?php echo rupiah($row['jumlah_kredit']); ?></td>
                                            <td><?php echo rupiah($row['jumlah_debit']-$row['jumlah_kredit']); ?></td>
                                            <td><?php echo rupiah($row['jumlah_uangawal']); ?></td>
                                            <td><?php echo rupiah($row['jumlah_bawa_tgl_bawa']); ?></td>
                                            <td><?php echo rupiah($row['jumlah_bawa_tgl_totalan']); ?></td>
                                            <td style="font-weight: bold;"><?php echo rupiah($row['jumlah_debit']-$row['jumlah_kredit']+$row['jumlah_uangawal']-$row['jumlah_bawa_tgl_bawa']+$row['jumlah_bawa_tgl_totalan']); ?></td>
  

                                        </tr>

                                <?php
                                              
                                            } ?>




                                </tbody>
                            </table>

                            <div class="x_title" style="text-transform: capitalize; margin:0;">
                            <h2 style="text-align: center;color:black">Data Bawa Uang (Total : <?php echo rupiah(totalbawauang()); ?>)</h2>

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




                        </div><br>
                            <table style="font-size:18px;color:black" id="datatable" class="table table-striped table-bordered">
                <thead>
                  <tr>
                  <th>No.</th>
                    <th>Id Bawa Uang</th>
                    <th>Print</th>
                    <th>Nama</th>
                    <th>Tgl Bawa</th>
                    <th>Waktu Input</th>
                    <th>Jenis Kas</th>
                    <th>Jumlah Bawa</th>
                    <th>Keterangan Bawa</th>
                    <th>Pemberi</th>
                    <th>Status</th>
                    <th>Tgl Totalan</th>
                    <th>Penerima Totalan</th>

                    <th>aksi</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $no = 0;
                  if ($_GET['periode'] == 'y') {
                    $query = mysqli_query($conn, "SELECT * FROM transaksi_bawauang WHERE tgl_bawa BETWEEN '$tgl1' AND '$tgl2' order by tgl_bawa ASC ");
                  } else {
                    $hariini = date('Y-m-d');
                    $query = mysqli_query($conn, "SELECT * FROM transaksi_bawauang WHERE valid != '1' OR tgl_totalan = '$hariini' order by valid DESC, id_transaksi DESC ");
                  }

                  $count = 2;



                  while ($row = mysqli_fetch_array($query)) {
                    $no++;
                  ?>

                    <tr style="background: <?php if ($row['valid'] == "1") { ?>
                          #defff1;
                          <?php } else { ?>
                            #feeeea;
                            <?php } ?>">
                      <td><?php echo $no; ?></td>
                      <td><?php echo $row['id_transaksi']; ?></td>
                      <td>
                      <a class="btn btn-primary btn-xs" onclick="window.open('component/com_transaksi/cetak_bawauang.php?id_tran=<?php echo $row['id_transaksi']; ?>','nama window','width=1000,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=no,resizable=yes,copyhistory=no')"><i class="glyphicon glyphicon-print"></i></a>
                    </td>
                      <td><?php echo namapekerja($row['id_pekerja']); ?></td>
                      <td><?php echo $row['tgl_bawa']; ?></td>
                      <td><?php echo $row['waktu_real']; ?></td>
                      <td><?php echo namajeniskas($row['jenis_kas']); ?></td>
                      <td><?php echo rupiah($row['jumlah_bawa']); ?></td>
                      <td><?php echo $row['keterangan']; ?></td>
                      <td><?php echo namapegawai($row['id_pegawai_pemberi']); ?></td>
                      <td><?php 
                      
                      if ($_SESSION['leveluser'] == "admin" ) {
                        if ($row['valid']=="1") {
                          if ($_SESSION['id'] == "P0001" ) {
                            echo "<a class=\"btn  btn-success btn-xs\"  onclick=\"confirm_modal('?module=$_GET[module]&aksi=ubahstatus&valid=0&id_transaksi=$row[id_transaksi]');\">Sudah</a>";
                          }else{
                            echo "<div style='color:green;font-size:14px'>Sudah</div>";
                          }
                        } else {
                          echo "<a class=\"btn  btn-warning btn-xs\"  onclick=\"confirm_modal('?module=$_GET[module]&aksi=ubahstatus&valid=1&id_transaksi=$row[id_transaksi]');\">Belum</a>";
                        }
                      }else{
                        if ($row['valid']=="1") {
                          echo "<div style='color:green;font-size:14px'>Sudah</div>";
                        } elseif ($row['valid']=="0" OR $row['valid']==""){
                          echo "<a class=\"btn  btn-warning btn-xs\">Belum</a>";
                        }
                      }
                      
                      ?></td>
                      <td><?php echo $row['tgl_totalan']; ?></td>
                      <td><?php echo namapegawai($row['id_pegawai_penerima']); ?></td>
                      
                           <td>
                          <?php
                          if ($_SESSION['leveluser'] == 'admin' AND $_SESSION['id'] == 'P0001') {
                          ?>
                            <a class='open_modal btn  btn-default btn-xs' href="?module=lap-bawauang&aksi=form_edit&id_tran=<?php echo $row['id_transaksi']; ?>"><i class="glyphicon glyphicon-edit"></i> Edit</a>
                            <a class="btn  btn-danger btn-xs" onclick="confirm_modal('?module=lap-bawauang&aksi=hapus&type=<?php echo $_GET['type']; ?>&id_tran=<?php echo $row['id_transaksi']; ?>');"><i class="glyphicon glyphicon-trash"></i> Hapus</a>

                          <?php

                          } else {
                            echo "<a data-toggle='modal' data-target='#akses_edit'><i>Akses dibatasi</i></a>";
                          }

                          ?>

                        </td>
                          
                          
                          
                          <?php
                      
                    } ?>




                </tbody>
              </table>
                        </div>
                    </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(
                                  tanggal,
                                  debit,
                                  kredit,
                                  keterangan,id_jenis,id_pegawai,jenis_kas) VALUES(
                                                 '$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=transaksiharian');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharian');</script>";
    }


?>


<?php


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

    // echo "<script language='javascript'>document.location='?module=transaksiharian';</script>";
    if (!$save) {
        echo "<script>nSimpan('?module=transaksiharian');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharian');</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=transaksiharian');</script>";
    } else {
        historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'],"uang awal");
        echo "<script>ySimpan('?module=transaksiharian');</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',id_tag_hut='$_POST[id_tag_hut]'
    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=transaksiharian');</script>";
    } else {
        historyedit($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharian');</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=transaksiharian');</script>";
    } else {
        historyhapus($_GET['id_tran'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
        echo "<script>ySimpan('?module=transaksiharian');</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=transaksiharian');</script>";
            } else {
                echo "<script>ySimpan('?module=transaksiharian');</script>";
                echo "sukses";
            }
        }
    }elseif ($_GET['aksi'] == 'pindahbuku') {
//untuk pindah pembukuan


 $ket_mutasi = "Pindah Buku $_POST[dari_kas] to -> $_POST[ke_kas] | ";
 $module = $_GET['module'];
        $tgl = date('Y-m-d', strtotime($_POST['tanggal']));
            $jen = '2';
            $tanggal        = $tgl;
            $kredit         = $_POST['jumlah_mutasi'];
            $keterangan     = $ket_mutasi . ' - ' . $_POST['keterangan'];
            $id_sumber      = $_POST['dari_kas'];
            $id_jenis       = 44;
            $id_pegawai     = $_SESSION['id'];
            $jenis_kas      = 6;
            
            $sql = "INSERT INTO transaksi(
                tanggal,
                debit, 
                kredit,
                keterangan,
                id_jenis_sumber, 
                id_jenis,
                id_pegawai,
                jenis_kas
            ) VALUES (
                '$tanggal',
                '0',
                '$kredit',
                '$keterangan',
                '$id_sumber',
                '$id_jenis',
                '$id_pegawai',
                '$jenis_kas'
            )";
            
            $save = mysqli_query($conn, $sql) or die("Query Error: " . mysqli_error($conn));
            
            if (!$save) {
                echo "Gagal menyimpan data";
                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]','$_POST[ke_kas]','$_SESSION[id]','6')");


            if (!$save1) {
                echo "gagal masuk pembukuan utama";
                echo "<script>nSimpan('?module=transaksiharian');</script>";
            } else {
                echo "<script>ySimpan('?module=transaksiharian');</script>";
                echo "sukses";
            }
        }
    }elseif ($_GET['aksi'] == 'ubahstatus') {
        $module = $_GET['module'];
          if ($_GET['valid']=="1"){
            $tgl1 = date('Y-m-d');
          $query=mysqli_query($conn, "UPDATE transaksi_bawauang SET valid = '$_GET[valid]',
                                              id_pegawai_penerima = '$_SESSION[id]',
                                              tgl_totalan = '$tgl1'
                                             WHERE id_transaksi = '$_GET[id_transaksi]'");
          }else{
            $query=mysqli_query($conn, "UPDATE transaksi_bawauang SET valid = '$_GET[valid]',
                                              id_pegawai_penerima = '', tgl_totalan = '0000-00-00'
                                             WHERE id_transaksi = '$_GET[id_transaksi]'");
          }
        
        if (!$query) {
          echo mysqli_error($conn);
          echo "gagal";
      } else {
          echo "<script>ySimpan('?module=" . $module . "');</script>";
      }
      }
 ?>



<!--  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' OR 'user1') {
                        $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">Pindah Kas</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>
            
<!-- untuk MUTASI -->
            <div class="modal fade" id="pindahbuku" 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">Pindah Pembukuan</h3>
                        </div>
                        <div class="modal-body">
                            <form action="?module=transaksiharian&aksi=pindahbuku" 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>Pindah 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_transaksi ORDER BY nama_jenis ASC";
                                    $tampil2 = mysqli_query($conn, $query2);
                                    while ($w = mysqli_fetch_array($tampil2)) {
                                        echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</option>";
                                    }
                                    ?>
                                </select>
                                
                                <label f>Pindah 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_transaksi ORDER BY nama_jenis ASC";
                                    $tampil2 = mysqli_query($conn, $query2);
                                    while ($w = mysqli_fetch_array($tampil2)) {
                                        echo "<option value=\"$w[id_jenis]\">$w[nama_jenis]</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>Sumber Kas Transaksi * :</label>
                    <select style="font-weight: bold;color:black;font-size:large" id="heard" class="form-control" required name="jenis_transaksi_sumber">

                        <option value="" selected>- Pilih Jenis -</option>
                        
                      
                        <?php
                        if ($_SESSION['leveluser'] == 'admin' OR 'user1') {
                        $query2  = "SELECT * FROM jenis_transaksi WHERE jenis='0' 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 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' OR 'user1') {
                        $query2  = "SELECT * FROM jenis_transaksi WHERE jenis!='0' 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 class="col-md-12" for="nama">Tautkan Tagihan/Hutang (Opsional) : <button class="class=form-control btn-warning btn-flat" id="onoff" type=button onClick="taghut()"><i class="glyphicon glyphicon-share"></i></button></label>
                    
                    <select style="font-weight: bold;color:black;font-size:large" id="inputtaghut" class="form-control" name="id_tag_hut">

                        <option value="" selected>- Pilih Tagihan/Hutang -</option>
                        
                      
                        <?php
                        
                            $query2  = "SELECT * FROM tagihan_hutang WHERE status!='1' ORDER BY id_divisi ASC, nama_tag_hut ASC";
                        $tampil2 = mysqli_query($conn, $query2);
                        while ($w = mysqli_fetch_array($tampil2)) {
                            $namadivisi=namadivisi($w['id_divisi']);
                            echo "<option value='$w[id_tag_hut]'>[$namadivisi]- $w[nama_tag_hut]</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-->
<!--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>
<!--  Tambah Bawa Uang -->
<div style="color:black;" class="modal fade" id="bawauang" 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 Bawa Uang</h4>
      </div>
      <div class="modal-body">
        <form action="?module=lap-bawauang&aksi=bawauang" enctype="multipart/form-data" method="POST">
         <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>Nama Pembawa Uang * (dari data pekerja) :</label>
          <select id="heard" class="form-control" required name="id_pekerja">

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

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

          <label>Jumlah Bawa Uang (Rp) *:</label>
          <input type="hidden" class="form-control" name="" />
          <input type="number" class="form-control" id="t5" name="jumlah_bawa_uang" 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>
          <input type="hidden" class="form-control" name="jenis_transaksi" value="<?php echo $jenis; ?>">

          <label>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)) {
              echo "<option value=\"$w[id]\">$w[nama]</option>";
            }
            ?>
          </select>


          <label>Keterangan Bawa Uang *:</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>


<!-- modal delete-->
<div class="modal fade" id="modal_delete">
  <div class="modal-dialog">
    <div class="modal-content" style="margin-top:100px;">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" style="text-align:center;">Apakah anda yakin mengubah data ini ?</h4>
      </div>
      <div class="modal-footer" style="margin:0px; border-top:0px; text-align:center;">
        <a href="#" class="btn btn-danger btn-sm" id="delete_link">Ubah</a>
        <button type="button" class="btn btn-success btn-sm" data-dismiss="modal">Batal</button>
      </div>
    </div>
  </div>
</div>

<!-- modal akses edit-->
<div class="modal fade" id="akses_edit">
  <div class="modal-dialog">
    <div class="modal-content" style="margin-top:100px;">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" style="text-align:center;">Hubungi Administrator Utama untuk merevisi atau menghapus</h4>
      </div>
      <div class="modal-footer" style="margin:0px; border-top:0px; text-align:center;">
        <button type="button" class="btn btn-success btn-sm" data-dismiss="modal">OK</button>
      </div>
    </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;
        document.getElementById('t5').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;
        document.getElementById('t5').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;
        document.getElementById('t5').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;
        document.getElementById('t5').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;
        document.getElementById('t5').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;
        document.getElementById('t5').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;
        document.getElementById('t5').value = txttambah;

    }

    function resetcash() {

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


    }

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

            return false;
        return true;
    }

    //untuk pada tambah data transaksi pengeluaran (tagihan hutan)
  document.getElementById("inputtaghut").style.display = "none";

function taghut() {
  //aktif/nonaktif taghut
  var x = document.getElementById("inputtaghut");
  if (x.style.display === "none") {
    x.style.display = "block";
    document.getElementById("onoff").innnerHTML =
      "ON";
      } else {
    x.style.display = "none";
    Webcam.reset();
  }
}
</script>