Untitled

mail@pastecode.io avatar
unknown
php
24 days ago
14 kB
2
Indexable
Never
<?php
  mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  error_reporting(1);
  $id=  base64_decode(@$_GET['id']);
  $code = base64_decode(@$_GET['cd']);

  $query = '';

  if (isset($_POST['searchs'])) 
  {
    $awal = @$_POST['tglAwal'];
    $akhir = @$_POST['tglAkhir'];
  
    $cbo_dana    = $_POST['cboDana'];
    $cbo_kondisi = $_POST['cboKondisi'];
    $cbo_unit = $_POST['cboUnit'];
    
    $sql_cond_add = [
      'tb_inventaris.tgl_inven BETWEEN "'.$awal.'" AND "'.$akhir.'"'
    ];

    if(!empty($cbo_unit)) {
      $sql_cond_add[] = 'tb_inventaris.unit = "'.$cbo_unit.'"';
    }

    if (!empty($cbo_dana)) 
    {
      $sql_cond_add[] = 'tb_inventaris.sumber_dana LIKE "%'.$cbo_dana.'%"';
    }

    if (!empty($cbo_kondisi)) 
    {
      $sql_cond_add[] = 'tb_inventaris.kondisi LIKE "%'.$cbo_kondisi.'%"';
    }

    $sql_cond_add = implode(' AND ', $sql_cond_add);

    // $sd = $_POST['sumber_dana'] != null ? 'AND tb_inventaris.sumber_dana = $_POST['sumber_dana']';
    $query = mysqli_query($koneksi, "SELECT * FROM tb_inventaris 
    INNER JOIN tb_barang on tb_barang.id_barang = tb_inventaris.id_barang
    INNER JOIN tb_subkelompok_barang on tb_subkelompok_barang.id_subkelompok = tb_barang.id_subkelompok
    INNER JOIN tb_kelompok_barang on tb_kelompok_barang.id_kelompok = tb_subkelompok_barang.id_kelompok
    INNER JOIN tb_bidang_barang on tb_bidang_barang.id_bidang = tb_kelompok_barang.id_bidang
    INNER JOIN tb_unit on tb_unit.id_unit = tb_inventaris.unit
    WHERE ".$sql_cond_add.$sql_unit); 
  }

  $listUnit = mysqli_query($koneksi, 'SELECT `id_unit`, `nama_unit` FROM `tb_unit`');

  $kondisis = mysqli_query($koneksi, 'SELECT DISTINCT `kondisi` FROM `tb_inventaris`');
  $r_kondisi= mysqli_fetch_all($kondisis);

  $list_kondisi = [];
  foreach ($r_kondisi as $r)
  {
    $list_kondisi[] = array_shift($r);
  }

  $sumberdanas = mysqli_query($koneksi, 'SELECT DISTINCT `sumber_dana` FROM `tb_inventaris`');
  $r_sumb_dana = mysqli_fetch_all($sumberdanas);

  $list_sumberdana = [];
  foreach ($r_sumb_dana as $r)
  {
    if (!empty($r))
    {
      $list_sumberdana[] = array_shift($r);
    }
  }

?>

<style type="text/css">
  .table tbody {
    font-size: 0.775rem;
  }
</style>

<div class="br-pageheader pd-y-15 pd-l-20">
  <nav class="breadcrumb pd-0 mg-0 tx-12">
    <a class="breadcrumb-item" href="?p=beranda">Beranda</a>
    <!-- <a class="breadcrumb-item" href="#">Tables</a> -->
    <span class="breadcrumb-item active">Laporan Aset</span>
  </nav>
</div><!-- br-pageheader -->

<div class="pd-x-20 pd-sm-x-30 pd-t-20 pd-sm-t-30" style="padding-top: 10px;">
  <h4 class="tx-gray-800 mg-b-5">Laporan Aset
    <!-- <input type="button" style="float:right" name="printqr" id="printqr" class="btn btn-danger" value="Print Qr"> -->
    <!-- <input type="button" onclick="window.print()" style="float:right" name="cetak_laporan" id="cetak_laporan" class="btn btn-primary" value="Cetak Laporan"> -->
  </h4>
    <a style="float:right;" href="./cetak_laporan/cetak_laporan.php?tgawal=<?php echo base64_encode($awal) ?>&tgakhir=<?php echo base64_encode($akhir) ?>&kondisi=<?php echo base64_encode($cbo_kondisi) ?>&dana=<?php echo base64_encode($cbo_dana) ?>&unit=<?php echo base64_encode($cbo_unit) ?>" target="_blank" class="btn btn-info">Cetak Laporan</a>
    <a style="float:right;" href="./laporan/grafik_laporan_aset.php?tgawal=<?php echo base64_encode($awal) ?>&tgakhir=<?php echo base64_encode($akhir) ?>&kondisi=<?php echo base64_encode($cbo_kondisi) ?>&dana=<?php echo base64_encode($cbo_dana) ?>&unit=<?php echo base64_encode($cbo_unit) ?>" target="_blank" class="btn btn-warning mx-1"> Cetak Grafik </a>
    <a style="float:right;" href="./laporan/excel_laporan_aset.php?tgawal=<?php echo base64_encode($awal) ?>&tgakhir=<?php echo base64_encode($akhir) ?>&kondisi=<?php echo base64_encode($cbo_kondisi) ?>&dana=<?php echo base64_encode($cbo_dana) ?>&unit=<?php echo base64_encode($cbo_unit) ?>" target="_blank" class="btn btn-primary ml-1"> Export Excel ALL</a>
    <a style="float:right;" href="./export_excel_inven.php?tgawal=<?php echo base64_encode($awal) ?>&tgakhir=<?php echo base64_encode($akhir) ?>&kondisi=<?php echo base64_encode($cbo_kondisi) ?>&dana=<?php echo base64_encode($cbo_dana) ?>&unit=<?php echo base64_encode($cbo_unit) ?>" target="_blank" class="btn btn-success"> Export Excel By Date</a>
    <a href="" class="btn btn-primary btn-with-icon" data-toggle="modal" data-target="#modaldemo6">
    </a>

</div>

<div class="br-pagebody">
  <div class="br-section-wrapper" style="padding: 30px 60px 60px 60px;">
    <div class="card">
      <div class="card-header" role="tab" id="headingOne">
        <h6 class="mg-b-0">
          <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true"
            aria-controls="collapseOne" class="tx-gray-800 transition">
            Pencarian Lanjut <span style="color: white; font-size: 11px; background-color: grey; padding: 4px;">Klik
              untuk Minimize</span>
          </a>
        </h6>
      </div><!-- card-header -->
      <div id="collapseOne" class="collapse show" role="tabpanel" aria-labelledby="headingOne">
        <div class="card-block pd-20" style="padding: 20px 20px 0px 20px;">
          <div class="form-layout">
            <form method="post" enctype="multipart/form-data">
              <div class="row mg-t-20">
                <label class="col-sm-2 form-control-label">
                  <span class="tx-danger">*</span> Tanggal Awal
                </label>
                <div class="col-sm-3 mg-t-10 mg-sm-t-0">
                  <input type="date" class="form-control" value="<?php echo $_POST['tglAwal'] ?>" name="tglAwal" required>
                </div>
              </div><!-- row -->
              <div class="row mg-t-20">
                <label class="col-sm-2 form-control-label">
                  <span class="tx-danger">*</span> Tanggal Akhir
                </label>
                <div class="col-sm-3 mg-t-10 mg-sm-t-0">
                  <input type="date" class="form-control" value="<?php echo $_POST['tglAkhir'] ?>" name="tglAkhir" required>
                </div>
              </div>
              <div class="row mg-t-20">
                <label class="col-sm-2 form-control-label">
                  Unit
                </label>
                <div class="col-sm-4 mg-t-10 mg-sm-t-0">
                <select class="form-control" name="cboUnit">
                  <option value="" <?php echo (@$_POST['cboUnit']=='') ? "SELECTED" : ''; ?>>- Pilih -</option>
                  <?php
                    foreach (mysqli_fetch_all($listUnit) as $key => $units) 
                    {
                      ?>
                        <option value="<?php echo $units[0]; ?>" <?php if(@$_POST['cboUnit']==$units[0]){ echo "SELECTED";} ?>><?php echo $units[1]; ?></option>
                      <?php
                    }
                  ?>
                  </select>
                </div>
              </div>
              <?php
                // $sumberdana = mysqli_query($koneksi, "SELECT  FROM tb_inventaris")
              ?>
              <div class="row mg-t-20">
                <label class="col-sm-2 form-control-label">
                  Sumber Dana
                </label>
                <div class="col-sm-6 mg-t-10 mg-sm-t-0">
                <select class="form-control select2-show-search" name="cboDana">
                  <option value="" <?php echo (@$_POST['cboDana']=='') ? "SELECTED" : ''; ?>>- Pilih -</option>
                  <?php
                    foreach ($list_sumberdana as $key => $sumb_dana) 
                    {
                      if (!empty($sumb_dana)) 
                      {
                        ?>
                        <option value="<?php echo $sumb_dana; ?>" <?php if(@$_POST['cboDana']==$sumb_dana){ echo "SELECTED";} ?>><?php echo $sumb_dana; ?></option>
                        <?php
                      }
                    }
                  ?>
                  </select>
                </div>
              </div>
              <div class="row mg-t-20">
                <label class="col-sm-2 form-control-label">
                  Kondisi Aset
                </label>
                <div class="col-sm-6 mg-t-10 mg-sm-t-0">
                  <select class="form-control select2-show-search" name="cboKondisi">
                  <option value="" <?php if(@$_POST['cboKondisi']==''){ echo "SELECTED";} ?>>- Pilih -</option>
                  <?php
                    foreach ($list_kondisi as $key => $kondisi) 
                    {
                      ?>
                      <option value="<?php echo $kondisi; ?>" <?php if(@$_POST['cboKondisi']==$kondisi){ echo "SELECTED";} ?>><?php echo $kondisi; ?></option>
                      <?php  
                    }
                  ?>
                  </select>
                </div>
              </div>
              <div class="row mg-t-30 mg-b-20">
                <div class="col-sm-10 mg-l-auto">
                  <div class="form-layout-footer">
                    <button class="btn btn-info" name="searchs" type="submit">Cari</button>
                    <!-- <a href="?p=inventarisasi" class="btn btn-secondary">Kembali</a> -->
                  </div><!-- form-layout-footer -->
                </div><!-- col-8 -->
              </div>
            </form>
          </div><!-- form-layout -->
        </div>
      </div>
    </div>
  </div>
  <!-- Tabel Cari kel -->
  <div class="br-section-wrapper" style="padding: 30px 60px 60px 60px; margin-bottom: 30px;">
    <div class="table-responsive">
      <table id="datatable1" class="table display responsive">
        <thead>
          <tr>
            <th width="10">No.</th>
            <th>No. Inventarisasi</th>
            <th>Nama Barang</th>
            <th>Tanggal Inven</th>
            <th>Sumber Dana</th>
            <th>Unit Pemilik</th>
            <th>Kondisi</th>
            <th>Status</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
        <?php
          $n = 1;
          while ($data = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
          ?>
              <tr>
                  <td><?php echo $n++; ?></td>
                  <td>
                      <?php echo $data['golongan'] . '.' .
                              $data['kode_bidang'] . '.' .
                              $data['kode_kelompok'] . '.' .
                              $data['kode_subkelompok'] . '.' .
                              $data['kode_barang'] . '.' .
                              $data['kode_inven']; ?>
                  </td>
                  <td><?php echo $data['nama_barang']; ?></td>
                  <td><?php echo date('d-m-Y', strtotime($data['tgl_inven'])); ?></td>
                  <td><?php echo $data['sumber_dana'] == '' ? '-' : $data['sumber_dana']; ?></td>
                  <td><?php echo $data['kd_unit']; ?></td>
                  <td><?php echo $data['kondisi']; ?></td>
                  <td><?php echo $data['status_aset']; ?></td>
              </tr>
          <?php
          }
          ?>
        </tbody>
      </table>
    </div>
  </div><!-- br-section-wrapper -->
</div><!-- br-pagebody -->

<script src="../../assets/lib/jquery/jquery.js"></script>
<script type="text/javascript">
  let table;
  $(document).ready(function() {
    table = $('#datatable1s').DataTable({
      "processing": true,
      // "serverSide": true,
      "pageLength": 10,
      "ajax": {
        "url": "inventarisasi_ajax.php",
        "dataType": "json",
        "type": "POST",
      },
      error: function() {
        $('#datatable1s').append('<tbody class="dataku-error"><tr><th colspan="3">Tidak ada data untuk ditampilkan</th></tr></tbody>');
      }
    });

    var ele = document.getElementsByClassName('checklist');
    console.log(ele);
    for (var i = 0; i < ele.length; i++) {
      // if (ele[i].type == 'checkbox') ele[i].checked = choose;
    }
  });
  
  function gets() {
    var ele = document.getElementsByClassName('checklist');
    let x = [];
    for (var i = 0; i < ele.length; i++) {
      ele[i].checked == true ? x.push(ele[i]) : null;
    }
    x.length > 0 ? $('#printqr').removeAttr("type").attr("type", "submit") : $('#printqr').removeAttr("type").attr("type", "button");
  }

  function getAll(params) {
    // Dibawah adalah print satu pages full
    var ele = document.getElementsByClassName('checklist');
    let choose;
    let x = [];
    $(params).not(':checked').length ? choose = false : choose = true;
    for (var i = 0; i < ele.length; i++) {
      if (ele[i].type == 'checkbox') ele[i].checked = choose;
      ele[i].checked == true ? x.push(ele[i]) : null;
    }
    x.length > 0 ? $('#printqr').removeAttr("type").attr("type", "submit") : $('#printqr').removeAttr("type").attr("type", "button");
  }

  // $(document).ready(function () {

  // });

  // function gets()
  // {
  //   x.length > 0 ? $('#cetak_laporan').removeAttr("type").attr("type", "submit") : $('#cetak_laporan').removeAttr("type").attr("type", "button");
  // }
</script>
Leave a Comment