<?php 
  include '_header.php';
  include '_nav.php';
  include '_sidebar.php'; 
?>
<?php  
  if ( $levelLogin !== "super admin") {
    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( editLabaBersih($_POST) > 0 ) {
    echo "
      <script>
        alert('Data Berhasil diupdate');
        document.location.href = 'laba-bersih-data';
      </script>
    ";
  } elseif( editLabaBersih($_POST) == null ) {
    echo "
      <script>
        alert('Anda Belum Melakukan Perubahan Data');
      </script>
    ";
  } else {
    echo "
      <script>
        alert('data gagal ditambahkan');
      </script>
    ";
  }
  
}
?>

<?php  
  $labaBersih = query("SELECT * FROM laba_bersih WHERE lb_cabang = $sessionCabang")[0];
?>

  <!-- 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-9">
            <h1>Data Operasional Toko dari Pendapatan & Pengeluaran</h1>
          </div>
          <div class="col-sm-3">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="bo">Home</a></li>
              <li class="breadcrumb-item active">Data Operasional</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <section class="content">
      <div class="container-fluid">
        <form role="form" action="" method="post">
          <div class="row">
            <div class="col-md-12">
              <!-- general form elements -->
              <div class="card card-primary">
                <div class="card-header">
                  <h3 class="card-title">Pendapatan</h3>
                </div>
                <!-- /.card-header -->
                <!-- form start -->
                  <div class="card-body">
                    <div class="row">
                      <div class="col-md-6 col-lg-6">
                          <div class="form-group">
                            <input type="hidden" name="lb_id" value="<?= $labaBersih['lb_id']; ?>">
                            <input type="hidden" name="lb_cabang" value="<?= $sessionCabang; ?>">
                            <label for="satuan_nama">Pendapatan Lain</label>
                            <input type="number" name="lb_pendapatan_lain" class="form-control" id="satuan_nama" value="<?= $labaBersih['lb_pendapatan_lain']; ?>" required>
                          </div>
                      </div>
                    </div>
                  </div>
                  <!-- /.card-body -->
              </div>
            </div>

            <div class="col-md-12">
              <!-- general form elements -->
              <div class="card card-primary">
                <div class="card-header">
                  <h3 class="card-title">Pengeluaran</h3>
                </div>
                <!-- /.card-header -->
                <!-- form start -->
                  <div class="card-body">
                    <div class="row">
                      <div class="col-md-6 col-lg-6">
                          <div class="form-group">
                            <label for="lb_pengeluaran_gaji">Biaya Gaji Karyawan</label>
                            <input type="number" name="lb_pengeluaran_gaji" class="form-control" id="lb_pengeluaran_gaji" value="<?= $labaBersih['lb_pengeluaran_gaji']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_insentif_karyawan">Biaya Insentif Karyawan</label>
                            <input type="number" name="lb_insentif_karyawan" class="form-control" id="lb_insentif_karyawan" value="<?= $labaBersih['lb_insentif_karyawan']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_tunjangan_karyawan">Biaya Tunjangan Karyawan</label>
                            <input type="number" name="lb_tunjangan_karyawan" class="form-control" id="lb_tunjangan_karyawan" value="<?= $labaBersih['lb_tunjangan_karyawan']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_listrik">Biaya Listrik</label>
                            <input type="number" name="lb_pengeluaran_listrik" class="form-control" id="lb_pengeluaran_listrik" value="<?= $labaBersih['lb_pengeluaran_listrik']; ?>" required>
                          </div>
                          <div class="form-group">
                            <label for="lb_pulsa_kuota">Biaya Pulsa & Kuota</label>
                            <input type="number" name="lb_pulsa_kuota" class="form-control" id="lb_pulsa_kuota" value="<?= $labaBersih['lb_pulsa_kuota']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_tlpn_internet">Biaya Telpon & Internet</label>
                            <input type="number" name="lb_pengeluaran_tlpn_internet" class="form-control" id="lb_pengeluaran_tlpn_internet" value="<?= $labaBersih['lb_pengeluaran_tlpn_internet']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_bahan_baku">Biaya Bahan Baku</label>
                            <input type="number" name="lb_bahan_baku" class="form-control" id="lb_bahan_baku" value="<?= $labaBersih['lb_bahan_baku']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_biaya_penyusutan">Biaya Bahan Baku Rusak</label>
                            <input type="number" name="lb_pengeluaran_biaya_penyusutan" class="form-control" id="lb_pengeluaran_biaya_penyusutan" value="<?= $labaBersih['lb_pengeluaran_biaya_penyusutan']; ?>" required>
                          </div>
                      </div>
                      <div class="col-md-6 col-lg-6">
                          <div class="form-group">
                            <label for="lb_habis_pakai">Biaya Habis Pakai</label>
                            <input type="number" name="lb_habis_pakai" class="form-control" id="lb_habis_pakai" value="<?= $labaBersih['lb_habis_pakai']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_perlengkapan_toko">Biaya Perlengkapan Toko</label>
                            <input type="number" name="lb_pengeluaran_perlengkapan_toko" class="form-control" id="lb_pengeluaran_perlengkapan_toko" value="<?= $labaBersih['lb_pengeluaran_perlengkapan_toko']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_sewa_bangunan">Biaya Sewa Bangunan</label>
                            <input type="number" name="lb_sewa_bangunan" class="form-control" id="lb_sewa_bangunan" value="<?= $labaBersih['lb_sewa_bangunan']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_bensin">Biaya Transport & Bensin</label>
                            <input type="number" name="lb_pengeluaran_bensin" class="form-control" id="lb_pengeluaran_bensin" value="<?= $labaBersih['lb_pengeluaran_bensin']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_promosi">Biaya Promosi</label>
                            <input type="number" name="lb_promosi" class="form-control" id="lb_promosi" value="<?= $labaBersih['lb_promosi']; ?>" required>
                          </div>

                          <div class="form-group">
                            <label for="lb_pengeluaran_tak_terduga">Biaya Tak Terduga</label>
                            <input type="number" name="lb_pengeluaran_tak_terduga" class="form-control" id="lb_pengeluaran_tak_terduga" value="<?= $labaBersih['lb_pengeluaran_tak_terduga']; ?>" required>
                          </div>
                          <div class="form-group">
                            <label for="lb_pengeluaran_lain">Biaya Lain-lain</label>
                            <input type="number" name="lb_pengeluaran_lain" class="form-control" id="lb_pengeluaran_lain" value="<?= $labaBersih['lb_pengeluaran_lain']; ?>" required>
                          </div>
                      </div>
                    </div>
                  </div>
                  <div class="card-footer text-right">
                    <button type="submit" name="submit" class="btn btn-primary">Submit</button>
                  </div>
                  <!-- /.card-body -->
              </div>
            </div>
          </div>
        </form>
      </div>
    </section>

  </div>


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