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

  if ($_GET['periode'] == 'y') {
    $tanggal1 = $_POST['tanggal1'];
    $tanggal2 = $_POST['tanggal2'];
    $tgl1 = date('Y-m-d', strtotime($tanggal1));
    $tgl2 = date('Y-m-d', strtotime($tanggal2));
    $query_saldo = mysqli_query($conn, "SELECT SUM(jumlah) AS total_transaksi FROM transaksi_uangawal WHERE tanggal BETWEEN '$tgl1' AND '$tgl2'");
  } else {
    $hariini = date('Y-m-d');
    $query_saldo = mysqli_query($conn, "SELECT SUM(jumlah) as total_transaksi FROM transaksi_uangawal 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="clearfix"></div>

      <div class="row">
        <div class="col-md-8 col-sm-12 col-xs-12">
          <div class="x_panel">
            <div class="x_title" style="text-transform: capitalize; margin:0;">
              <h2>Data Uang Awal</h2>

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


             


                <div class="well" style="overflow: auto">
                <form action="?module=lap-uangawal&periode=y" enctype="multipart/form-data" method="POST">
                  <div class="col-md-12 col-sm-12 col-xs-12" style="padding: 4px;">
                    <label for="nama">Pilih Periode :</label>
                  </div>

                  <div class="col-md-6 col-sm-12 col-xs-12" style="padding: 4px;">

                    <div class="input-group">
                      <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                      <input type="text" autocomplete="off" class="form-control " id="tanggal" required value="<?php if ($_GET['periode'] == 'y') {
                                                                                                                  echo $tanggal1;
                                                                                                                } else {
                                                                                                                  echo "";
                                                                                                                } ?>" name="tanggal1">
                      <div class="input-group-addon" style="background:white;"><small>Sampai</small></i></div>
                      <div class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></div>
                      <input type="text" autocomplete="off" class="form-control " required value="<?php if ($_GET['periode'] == 'y') {
                                                                                                    echo $tanggal2;
                                                                                                  } else {
                                                                                                    echo "";
                                                                                                  } ?>" id="tanggal2" name="tanggal2">
                    </div>
                  </div>

                  <div class="col-md-6 col-sm-12 col-xs-12" style="padding: 4px;">
                    <button type="submit" class="btn btn-primary btn-sm">Pilih</button>



              </form>


            </div>
            <div class="col-md-9 col-sm-12 col-xs-12">
                
                
           
            </div>


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

              <h4>
                <table>
                  <tr>
                    <td id="hit"><small><b>TOTAL </b></small></td>
                    <td align="right">&nbsp; Rp. <?php echo rupiah($row_saldo['total_transaksi']); ?></td>
                  </tr>
                </table>
              </h4>
            </div>



            <div class="x_content">

              <table id="datatable" class="table table-striped table-bordered">
                <thead>
                  <tr>
                    <th>Id</th>
                    <th>Tanggal</th>
                    <th>
                      Jenis Kas
                    </th>
                    <th>Jumlah</th>
                    <th>Keterangan</th>
                    <th>User</th>
                    <th>aksi</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $no = 0;
                  if ($_GET['periode'] == 'y') {
                    $query = mysqli_query($conn, "SELECT * FROM transaksi_uangawal WHERE tanggal BETWEEN '$tgl1' AND '$tgl2' order by tanggal ASC ");
                  } else {
                    $hariini = date('Y-m-d');
                    $query = mysqli_query($conn, "SELECT * FROM transaksi_uangawal WHERE tanggal='$hariini' order by tanggal ASC ");
                  }

                  $count = 2;



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

                    <tr style="background: <?php if ($row['kredit'] == 0) { ?>
                          #defff1;
                          <?php } else { ?>
                            #feeeea;
                            <?php } ?>">
                      <td><?php echo $row['id_transaksi']; ?></td>
                      <td><?php echo $row['tanggal']; ?></td>
                      <td><?php echo namajeniskas($row['jenis_kas']); ?></td>
                      <td><?php echo rupiah($row['jumlah']); ?></td>
                      <td><?php echo $row['keterangan']; ?></td>
                      <td><?php echo namapegawai($row['id_pegawai']); ?></td>
                      
                           <td>
                          <?php
                          if ($_SESSION['leveluser'] == 'admin' AND $_SESSION['id'] == 'P0001') {
                          ?>
                            <a class='open_modal btn  btn-default btn-xs' href="?module=<?php echo $_GET['module']; ?>&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=<?php echo $_GET['module']; ?>&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-8 col-sm-12 col-xs-12">
            <div class="x_title" style="text-transform: capitalize; margin:0;">
              <h2>Edit Data Uang Awal</h2>

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

            <form action="?module=<?php echo $_GET['module']; ?>&aksi=simpan_edit" enctype="multipart/form-data" method="POST">
              <?php


              $query = "SELECT * FROM transaksi_uangawal WHERE id_transaksi='$_GET[id_tran]' ";
              $hasil = mysqli_query($conn, $query);
              $data = mysqli_fetch_array($hasil);

              ?>

            <label for="id">ID transaksi * :</label>
              <input type="text" class="form-control" disabled value="<?php echo $data['id_transaksi']; ?>" >
              <input type="hidden" class="form-control" name="id_transaksi" value="<?php echo $data['id_transaksi']; ?>" >
              
             <label for="id">Nama User * :</label>
              <input type="text" class="form-control" disabled value="<?php echo namapegawai($data['id_pegawai']); ?>" >
              
              <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 " autocomplete="off" value="<?php echo date('d-m-Y', strtotime($data['tanggal'])); ?>" id="tanggal4" name="tanggal" required>
              </div>

              <label>Jumlah Uang Awal *:</label>
              <input type="number" class="form-control" autocomplete="off" name="jumlah" value="<?php echo $data['jumlah']; ?>" 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=transaksi&type=$_POST[jenis_transaksi]';</script>";
  if (!$save) {
    echo "<script>nSimpan('?module=transaksi&type=$_POST[jenis_transaksi]');</script>";
  } else {
    historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
    echo "<script>ySimpan('?module=transaksi&type=$_POST[jenis_transaksi]');</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=transaksi&type=$_POST[jenis_transaksi]';</script>";
  if (!$save) {
    echo "<script>nSimpan('?module=transaksi&type=$_POST[jenis_transaksi]');</script>";
  } else {
    historysimpan($_POST['id'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
    echo "<script>ySimpan('?module=transaksi&type=$_POST[jenis_transaksi]');</script>";
  }
} elseif ($_GET['aksi'] == 'simpan_edit') {

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

    $save = mysqli_query($conn, "UPDATE transaksi_uangawal SET tanggal = '$tgl1',
                                    jumlah = '$_POST[jumlah]',
                                    keterangan = '$_POST[keterangan]',
                                    jenis_kas='$_POST[jenis_kas]'
                                    WHERE id_transaksi = '$_POST[id_transaksi]'") or die("GAGAL");
 

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

  $query = mysqli_query($conn, "DELETE FROM transaksi_uangawal 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=$module');</script>";
  } else {
    historyhapus($_GET['id_tran'], $_SESSION['id'], $_SESSION['mac'], $_POST['jenis_transaksi']);
    echo "<script>ySimpan('?module=$module');</script>";
  }
} ?>

<!-- Modal -->
<div class="modal fade" id="modalAdd" 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">Setoran duit</h4>
      </div>
      <div class="modal-body">

        <form action="?module=transaksi&aksi=setoran_tunai" class="form-horizontal form-label-left" method="POST">

          <div class="form-group">
            <div class="col-sm-12 col-sm-12 col-xs-12 ">
              <div class="input-group">
                <input type="text" class="typeahead form-control" placeholder="Tulis Nomor Rekening" required name="no_rekening" autofocus=”autofocus” autocomplete="off">
                <span class="input-group-btn">
                  <button type="submit" class="btn btn-success"><i class="fa fa-search"></i> Cari</button>
                </span>

              </div>

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

      </div>

      <!-- end form for validations -->
    </div>
  </div>
</div>
<!-- /modal -->


<!-- Modal -->
<div class="modal fade" id="tarikAdd" 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">Penarikan Tunai</h4>
      </div>
      <div class="modal-body">

        <form action="?module=transaksi&aksi=penarikan_tunai" class="form-horizontal form-label-left" method="POST">

          <div class="form-group">
            <div class="col-sm-12 col-sm-12 col-xs-12 ">
              <div class="input-group">
                <input type="text" class="typeahead form-control" placeholder="Tulis Nomor Rekening" required name="no_rekening" autofocus=”autofocus” autocomplete="off">
                <span class="input-group-btn">
                  <button type="submit" class="btn btn-danger"><i class="fa fa-search"></i> Cari</button>
                </span>

              </div>

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

      </div>

      <!-- end form for validations -->
    </div>
  </div>
</div>
<!-- /modal -->

<!--  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=transaksi&aksi=pemasukan" enctype="multipart/form-data" method="POST">
          <?php
          $query = "SELECT max(id_transaksi) as maxID FROM transaksi_uangawal ";
          $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>Jumlah (Rp) *:</label>
          <input type="hidden" class="form-control" name="kredit" />
          <input 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>
          <input type="hidden" class="form-control" name="jenis_transaksi" value="<?php echo $jenis; ?>">

          <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)) {
              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>

<!--  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=transaksi&aksi=pengeluaran" enctype="multipart/form-data" method="POST">
          <?php
          $query = "SELECT max(id_transaksi) as maxID FROM transaksi_uangawal ";
          $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>Jumlah (Rp) *:</label>

          <input type="hidden" class="form-control" name="debit" />
          <input type="number" id="t4" class="form-control" name="kredit" autofocus=”autofocus” autocomplete="off">
          <input type="hidden" class="form-control" name="jenis_transaksi" value="<?php echo $jenis; ?>">
          <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 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>


<!--  data item -->
<div class="modal fade" id="data_item" 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">Data item</h4>
      </div>
      <div class="modal-body">
        <form action="?module=transaksi&aksi=pengeluaran" enctype="multipart/form-data" method="POST">
          <?php
          $query = "SELECT max(id_transaksi) as maxID FROM transaksi_uangawal ";
          $hasil = mysqli_query($conn, $query);
          $data = @mysqli_fetch_array($hasil);
          $idMax = $data['maxID'];

          $noUrut = (int) substr($idMax, 1, 9);
          $noUrut++;
          $char = "T";
          $newID = $char . sprintf("%04s", $noUrut);
          ?>
          <label for="id">ID transaksi * :</label>
          <input type="text" class="form-control" disabled value="<?php echo $newID; ?>" />
          <input type="hidden" class="form-control" name="id" value="<?php echo $newID; ?>" />


          <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 id="tanggal2" name="tanggal" autocomplete="off">
          </div>

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

          <label>Jumlah (Rp) *:</label>
          <input type="hidden" class="form-control" name="debit" />
          <input type="text" class="form-control" name="kredit" autofocus=”autofocus” autocomplete="off" />
          <input type="hidden" class="form-control" name="jenis_transaksi" value="<?php echo $jenis; ?>">
      </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 menghapus 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">Hapus</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 untuk merevisi</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;

  }

  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>