Files
manjapro_v6/pages/master_inventaris.php

214 lines
12 KiB
PHP

<!-- Main content -->
<section class="content" style="zoom: 90%;">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-sm-6">
<h3 class="card-title">Data Aset</h3>
</div>
<div class="col-sm-6">
<ol class="float-sm-right mb-0">
<a type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#staticBackdrop">Tambah Aset</a>
</ol>
</div>
<!-- Modal Tambah -->
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<form method="post" enctype="multipart/form-data">
<div class="modal-header bg-danger">
<h5 class="modal-title" id="staticBackdropLabel">Tambah Aset</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="card-body pb-0">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Nama Server</label>
<select class="form-control" name="ids" required="required">
<option value="">Pilih</option>
<?php
$List = new Listdata();
$List->set_list("data_server", $SqlDataWH);
foreach ($List->get_list() as $key => $value): ?>
<option value="<?php echo $value['id']; ?>"><?php echo $value['nama_server']; ?></option>
<?php endforeach ?>
</select>
</div>
<div class="form-group">
<label>Nama Barang</label>
<input type="text" class="form-control" name="nama" required="required">
</div>
<div class="row">
<div class="col-6">
<div class="form-group">
<label>Harga Barang</label>
<input type="text" class="form-control rupiah" id="rupiah0" name="harga" required="required">
</div>
<div class="form-group">
<label>Kategori</label>
<select class="form-control" name="kategori" required="required">
<option value="">Pilih</option>
<option value="Lainnya">Lainnya</option>
<option value="Tanah">Tanah</option>
<option value="Kendaraan">Kendaraan</option>
</select>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label>Penyusutan</label>
<div class="input-group">
<input type="number" class="form-control" name="penyusutan" required="required">
<div class="input-group-append">
<span class="input-group-text">Tahun</span>
</div>
</div>
</div>
<div class="form-group">
<label>Jenis Kas</label>
<select class="form-control" name="metode" required="required">
<option value="">Pilih</option>
<option value="Bank">Bank</option>
<option value="Tunai">Tunai</option>
<option value="Hutang Jangka Pendek">Hutang Jangka Pendek</option>
<option value="Hutang Jangka Panjang">Hutang Jangka Panjang</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Tanggal Pembelian</label>
<input type="date" class="form-control" name="pembelian" required="required">
</div>
<div class="form-group">
<label>Keterangan</label>
<textarea class="form-control" name="keterangan" required="required" rows="5"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input type="submit" name="tambah" class="btn btn-primary" value="Tambah">
</div>
</form>
<?php
if (isset($_POST['tambah'])) {
$sql = "INSERT INTO aset
(id_data_server, id_user_akses, nama, harga, kategori, penyusutan, metode_pembayaran, start_time, keterangan, status)
VALUES (:ids, :userId, :nama, :harga, :kategori, :penyusutan, :metode, :waktu, :keterangan, '1')";
try {
// Prepare the statement
$stmt = $pdo->prepare($sql);
$harga = preg_replace("/[^0-9]/","",$_POST['harga']);
// Bind the parameters
$stmt->bindParam(':ids', $_POST['ids']);
$stmt->bindParam(':userId', $UserId);
$stmt->bindParam(':nama', $_POST['nama']);
$stmt->bindParam(':harga', $harga);
$stmt->bindParam(':kategori', $_POST['kategori']);
$stmt->bindParam(':penyusutan', $_POST['penyusutan']);
$stmt->bindParam(':metode', $_POST['metode']);
$stmt->bindParam(':waktu', $_POST['pembelian']);
$stmt->bindParam(':keterangan', $_POST['keterangan']);
// Execute the statement
$stmt->execute();
// Success message
sweetAlert("Data Aset telah di tambah", "success");
} catch (PDOException $e) {
// Handle error
echo 'Error: ' . $e->getMessage();
}
}
?>
</div>
</div>
</div>
<!-- END Modal Tambah -->
</div>
</div>
<!-- /.card-header -->
<?php
$aset1 = mysqli_query($con,"SELECT SUM(harga) AS total_harga, SUM(nilai_Penyusutan) AS total_nilai_Penyusutan, SUM(jumlah_nilai_Penyusutan) AS total_jumlah_nilai_Penyusutan, SUM(nilai_saat_ini) AS total_nilai_saat_ini FROM v_akumulasi_inventaris_total $SqlDataWHId");
$aset = mysqli_fetch_assoc($aset1);
?>
<div class="card-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th style="vertical-align: top;">No</th>
<th style="vertical-align: top;">Nama Barang</th>
<th style="vertical-align: top;">Jenis</th>
<th style="vertical-align: top;">Tanggal Pembelian</th>
<th>Harga Barang<br>Rp. <?php echo number_format($aset['total_harga']); ?></th>
<th style="vertical-align: top;">Penyusutan</th>
<th>Penyusutan per Bulan<br>Rp. <?php echo number_format($aset['total_nilai_Penyusutan']); ?></th>
<th style="vertical-align: top;">Bulan ke</th>
<th>Total Penyusutan per Bulan<br>Rp. <?php echo number_format($aset['total_jumlah_nilai_Penyusutan']); ?></th>
<th>Nilai Saat Ini<br>Rp. <?php echo number_format($aset['total_nilai_saat_ini']); ?></th>
<th style="vertical-align: top;">Action</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
$aserver = mysqli_query($con,"SELECT * FROM v_akumulasi_inventaris $SqlDataWHId");
while ($server = mysqli_fetch_assoc($aserver))
{
?>
<tr>
<td style="max-width: 30px;"><?php echo $no; ?></td>
<td style="max-width: 200px;"><?php echo $server['nama']; ?></td>
<td style="max-width: 200px;"><?php echo $server['kategori']; ?></td>
<td style="max-width: 30px;"><?php echo $server['start_time']; ?></td>
<td style="max-width: 200px;">Rp. <?php echo number_format($server['harga']); ?></td>
<td style="max-width: 200px;"><?php echo $server['penyusutan']; ?> Tahun</td>
<td style="max-width: 30px;">Rp. <?php echo number_format($server['nilai_penyusutan']); ?></td>
<td style="max-width: 30px;"><?php echo $server['bulan_ke']; ?></td>
<td style="max-width: 30px;">Rp. <?php echo number_format($server['jumlah_nilai_penyusutan']); ?></td>
<td style="max-width: 30px;">Rp. <?php echo number_format($server['nilai_saat_ini']); ?></td>
<td>
<form method="post">
<a href="?<?php echo encrypt_url('barang_aset_detail|'.$server['id']); ?>" class="btn btn-info btn-sm">Detail / Edit</a>
<input type="submit" class="btn btn-danger btn-sm m-1" name="hapus<?php echo $server['id']; ?>" value="Hapus">
</form>
</td>
</tr>
<?php
if (isset($_POST['hapus'.$server['id']])) {
$iddata = $server['id'];
deleteAlert("aset",$iddata );
}
$no ++; } ?>
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>