<?php 
  include '_header.php';
  include '_nav.php';
  include '_sidebar.php'; 
?>
<?php  
  if ( $levelLogin === "kurir") {
    echo "
      <script>
        document.location.href = 'bo';
      </script>
    ";
  }
    
?>
<?php  

// cek apakah tombol submit sudah ditekan atau belum
if( isset($_POST["submit"]) ){
  // var_dump($_POST);

  // cek apakah data berhasil di tambahkan atau tidak
  if( tambahcashdrawer($_POST) > 0 ) {
    echo "
      <script>
        document.location.href = 'laba-bersih-cashdrawer';
      </script>
    ";
  } else {
    echo "
      <script>
        alert('data gagal ditambahkan');
      </script>
    ";
  }
  
}
?>


  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Tambah Data Cashdrawer</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="bo">Home</a></li>
              <li class="breadcrumb-item active">Data Cashdrawer</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <!-- left column -->
          <div class="col-md-12">
            <!-- general form elements -->
            <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Cashdrawer</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form role="form" action="" method="post">
                <div class="card-body">
                  <div class="row">
                    <div class="col-md-6 col-lg-6">
                        <input type="hidden" name="cashdrawer_cabang" value="<?= $sessionCabang; ?>">
                        <input type="hidden" name="cashdrawer_create" value="<?= $_SESSION['user_id']; ?>">
                        <div class="form-group">
                          <label for="cashdrawer_date">Tanggal Transaksi</label>
                          <input type="date" name="cashdrawer_date" class="form-control" id="cashdrawer_date" value="<?= date("Y-m-d"); ?>" required>
                        </div>
                        <div class="form-group">
                          <label for="cashdrawer_name">Cashdrawer</label>
                          <input type="teks" name="cashdrawer_name" class="form-control" id="cashdrawer_name" value="Pendapatan Cashdrawer Tanggal <?= date("Y-m-d"); ?>" required>
                        </div>
                        <div class="form-group">
                          <label for="cashdrawer_penerima">Penerima</label>
                          <input type="text" name="cashdrawer_penerima" class="form-control" id="cashdrawer_penerima" value="EYD COMPUTER" readonly>
                        </div>
                        <div class="form-group">
                          <label for="cashdrawer_desc">Keterangan</label>
                          <textarea name="cashdrawer_desc" id="cashdrawer_desc" class="form-control" rows="3" required="required"></textarea>
                        </div>
                    </div>

                    <div class="col-md-6 col-lg-6">
                        
                        <div class="form-group">
                          <label for="cashdrawer_total_dibayar">Total Dibayar</label>
                          <input type="number" name="cashdrawer_total_dibayar" class="form-control" id="cashdrawer_total_dibayar" placeholder="Contoh: 200000" required>
                        </div>

                    </div>
                  </div>
                </div>
                <!-- /.card-body -->

                <div class="card-footer text-right">
                  <button type="submit" name="submit" class="btn btn-primary">Submit</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </section>


  </div>


<?php include '_footer.php'; ?>