[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
silppm
/
[
Home
]
File: files.inc.php
<?php $id = ""; $judul = ""; $hp = ""; $keterangan = ""; $buton = "Simpan"; $url = "-"; $tgl = "-"; $hp = "-"; $ktp = "-"; $kota_asal = "-"; $alamat = "-"; $keterangan = "-"; $judul = "-"; if(isset($_SESSION["user-profile"]) && strlen($_SESSION["user-profile"]) > 0) { $profile = $_SESSION["user-profile"]; $nm = $_SESSION["user_fullname"]; $ids = $_SESSION["user-id"]; } if(isset($_GET["deleteID"])) { $sql = "delete from files where id = ".$_GET["deleteID"]; if (mysqli_query($conn, $sql)) { echo "<script>window.alert('Data Sudah Terhapus');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_GET["editID"])) { $sql = "SELECT * FROM files where id = ".$_GET["editID"]." order by id desc"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $id = $row['id']; $judul = $row['judul']; $keterangan = $row['keterangan']; $tgl = $row['tgl']; $url = $row['url']; $buton = "Koreksi"; } } } if(isset($_GET["setaktif"])) { $setz = mysqli_query($conn, "update files set aktif = 0"); $sql = "update files set aktif = 1 where id = ".$_GET["setaktif"]; if (mysqli_query($conn, $sql)) { echo "<script>window.alert('Set Aktif');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_POST["Simpan"]) || isset($_POST["Koreksi"])) { if(isset($_POST["keterangan"])) $keterangan = $_POST["keterangan"]; if(isset($_POST["judul"])) $judul = $_POST["judul"]; if(isset($_POST["id"])) $id = $_POST["id"]; if(isset($_POST["tgl"])) $tgl = $_POST["tgl"]; if(isset($_POST["url"])) $url = $_POST["url"]; if(isset($_POST["jenis"])) $jenis = $_POST["jenis"]; $image_id = time(); $images = $_FILES["fileInput"]["name"]; if($images) { $rename = explode(".",$images); if(count($rename) > 1) { $images = "dok".$image_id.".".$rename[1]; $url = $images; move_uploaded_file($_FILES["fileInput"]["tmp_name"],"files/" . $images); } } $tbField[0] = "judul"; $tbField[1] = "keterangan"; $tbField[2] = "tgl"; $tbField[3] = "url"; $tbField[4] = "id_user"; $tbField[5] = "jenis"; $tbIsi[0] = "'".$judul."'"; $tbIsi[1] = "'".$keterangan."'"; $tbIsi[2] = "'".$tgl."'"; $tbIsi[3] = "'".$url."'"; $tbIsi[4] = "'".$_SESSION["user-id"]."'"; $tbIsi[5] = "'".$jenis."'"; if(isset($_POST["Simpan"])) { $nmField = compile_array($tbField); $isiField = compile_array($tbIsi); $sql = "insert into files (".$nmField.") values (".$isiField.")"; $notif = $ssm; } if(isset($_POST["Koreksi"])) { $compileSet = compile_array2($tbField,$tbIsi); $sql = "update files set ".$compileSet." where id = ".$id; $notif = $sum; } if (mysqli_query($conn, $sql)) { echo "<script>window.alert('".$notif."');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } ?> <div class="container-fluid"> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">Entry Dokumen </h6> </div> <div class="card-body"> <form class="user" action="dashboard.php?files" enctype="multipart/form-data" accept-charset="utf-8" method="post"> <div class="col m6"> <div class="row"> <div class="input-field col m6 s12"> <table border="0" width="100%" cellspacing="1" cellpadding="1"> <tr> <td width="30%">Judul</td> <td width="70%"> <input value="<?php echo $id;?>" name="id" type="hidden"> <input value="<?php echo $judul;?>" name="judul" type="text" class="form-control" id="exampleFirstName" placeholder="Judul"> </td> </tr> <tr> <td>Keterangan</td> <td> <input value="<?php echo $keterangan;?>" name="keterangan" type="text" class="form-control" id="var" placeholder="Keterangan"> </td> </tr> <tr> <td>Tanggal</td> <td> <input value="<?php echo $tgl;?>" name="tgl" type="date" class="form-control" id="tgl" placeholder="Tanggal"> </td> </tr> <tr> <td>Jenis</td> <td> <select name="jenis" class="form-control" id="jenis"> <option value="">- Pilih -</option> <option value="Buku">Buku</option> <option value="Artikel">Artikel</option> <option value="Jurnal">Jurnal</option> <option value="HKI">HKI</option> <option value="Lainnya">Lainnya</option> </select> </td> </tr> <tr> <td>Upload</td> <td> <input name="fileInput" type="file" class="form-control" id="url" placeholder=""> </td> </tr> <tr> <td> </td> <td> <div class="form-group row"> <div class="col-sm-3 mb-3 mb-sm-0"> <button name="<?php echo $buton;?>" type="submit" class="btn btn-primary btn-block"><?php echo $buton;?></button> </div> <div class="col-sm-3"> <button name="Cancel" type="submit" class="btn btn-primary btn-block">Cancel</button> </div> </div> </td> </tr> </table> </div> </div> </div> </div> </div> </div> </form> <div class="container-fluid"> <!-- Page Heading --> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">DataTables</h6> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>Hapus</th> <th>Edit</th> <th>Unduh</th> <th>Judul</th> <th>Jenis</th> <th>Tanggal</th> <th>Pemilik</th> </tr> </thead> <tfoot> <tr> <th>Hapus</th> <th>Edit</th> <th>Unduh</th> <th>Judul</th> <th>Jenis</th> <th>Tanggal</th> <th>Pemilik</th> </tr> </tfoot> <tbody> <?php if($profile == "ADMIN") { $sql = "SELECT * FROM files a left join user_login b on a.id_user = b.user_id order by a.id desc"; }else{ $nidn2 = substr($nidn,1,20); $sql = "SELECT * FROM files a left join user_login b on a.id_user = b.user_id where b.user_name like '%".$nidn."%' or b.user_name like '%".$nidn2."%' order by a.id desc"; } $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { ?> <tr> <td> <a class="btn btn-primary btn-danger" href="dashboard.php?files&deleteID=<?php echo $row['id'];?>"><i class="fas fa-trash"></i></a> </td> <td> <a class="btn btn-primary btn-warning" href="dashboard.php?files&editID=<?php echo $row['id'];?>"><i class="fas fa-edit"></i></a> </td> <td> <a class="btn btn-primary btn-warning" href="files/<?php echo $row['url'];?>" target="_blank"><i class="fas fa-envelope fa-fw"></i></a> </td> <td><?php echo $row['judul'];?></td> <td><?php echo $row['jenis'];?></td> <td><?php echo $row['tgl'];?></td> <td><?php echo $row['user_fullname'];?></td> </tr> <?php } } ?> </tbody> </table> </div> </div> </div> </div>