<div class="wawan-panel grid_7">
<div class="wawan-panel-header">
<span class="wawan-i-24 i-list">Form Upload File Informasi Berkala</span>
</div>
<div class="wawan-panel-body">
<?php
if (isset($_POST['informasi']))
{
$kategori = "Berkala";
$unit = "sdm";
$tanggal;
$informasi=ucwords($_POST['informasi']);
$nama_file=$_FILES['file_berkala']['name'];
$ukuran=$_FILES['file_berkala']['size'];
if (trim($informasi)=="") {
echo "<script>alert('Nama Informasi masih kosong, ulangi kembali.');</script>";
}
elseif (trim($nama_file)=="") {
echo "<script>alert('File masih kosong, ulangi kembali.');</script>";
}else{
$uploaddir='./files/';
$alamatfile=$uploaddir.$nama_file;
if (move_uploaded_file($_FILES['file_berkala']['tmp_name'],$alamatfile))
{
echo "<script>alert('Data Anda berhasil diupload.');</script>";
$upload=mysql_db_query($dbs,"INSERT INTO file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file','$ukuran','$alamatfile','$tanggal','$informasi','$kategori','$unit')");
}else{
echo "<script>alert('Proses upload gagal, kode error = {$_FILES['location']['error']}');</script>";
}
}
}
else
{
unset($_POST['informasi']);
}
?>
<form class="wawan-form" enctype="multipart/form-data" action="" method="post" >
<div class="wawan-form-inline">
<div class="wawan-form-row">
<label>Nama Informasi</label>
<div class="wawan-form-item large">
<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" placeholder="Nama informasi"/>
</div>
</div>
<div class="wawan-form-row">
<label>File Upload</label>
<div class="wawan-form-item large">
<input type="file" name="file_berkala" class="required" />
</div>
</div>
</div>
<div class="wawan-button-row">
<input type="submit" name="btntambah" value="Submit" class="wawan-button red" />
<input type="reset" value="Reset" class="wawan-button gray" />
</div>
</form>
</div>
</div>
<div class="wawan-panel grid_7">
<div class="wawan-panel-header">
<span class="wawan-i-24 i-table-1">Daftar File Informasi Berkala</span>
</div>
<div class="wawan-panel-body">
<table class="wawan-datatable-fn wawan-table">
<thead>
<tr>
<th>No.</th>
<th>Nama Informasi</th>
<th>Nama File</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM file_upload where kategori='Berkala' ORDER BY tgl_upload";
$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
while ($data=mysql_fetch_array($qry)) {
$no++;
?>
<tr class="gradeX">
<td><?php echo $no ?></td>
<td><?php echo $data['informasi']; ?></td>
<td><?php echo $data['nama_file']; ?></td>
<td class="center">
<a id="wawan-form-dialog-mdl-btn" href="<?=$_SERVER["PHP_SELF"];?>?page=berkala&Action=Edit&Id=<?php echo $data['Id']; ?>&info=<?php echo $data['informasi']; ?>">Edit</a> - <a href="">Hapus</a>
<!--// setelah Edit di klik maka akan menampilkan form ini, mengunakan js //-->
<?php
if($data["informasi"] == $_GET["info"] and $_GET["Action"] == "Edit")
{
?>
<div id="wawan-form-dialog">
<form id="wawan-validate" class="wawan-form" action="">
<div id="wawan-validate-error" class="wawan-form-message error" style="display:none;"></div>
<div class="wawan-form-inline">
<div class="wawan-form-row">
<label>Nama Informasi</label>
<div class="wawan-form-item large">
<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" placeholder="Nama informasi" value="<?php echo $data['informasi']; ?>"/>
</div>
</div>
<div class="wawan-form-row">
<label>File Upload</label>
<div class="wawan-form-item large">
<input type="file" name="file_berkala" class="required" value="<?php echo $data['nama_file']; ?>" />
</div>
</div>
</div>
</form>
</div>
<?php
}
?>
<!--// batas form update //-->
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<div class="wawan-panel grid_7">
<div class="wawan-panel-header">
<span class="wawan-i-24 i-list">Form Upload File Informasi Berkala</span>
</div>
<div class="wawan-panel-body">
<?php
/*if (isset($_POST['frminput']))
if (isset($_POST['frminput']) && $_POST['btnTambah'] == "Submit")*/
if($_POST["statpos"] == "frminput")
{
$kategori = "Berkala";
$unit = "sdm";
$tanggal;
$informasi=ucwords($_POST['informasi']);
$nama_file=$_FILES['file_berkala']['name'];
$ukuran=$_FILES['file_berkala']['size'];
if (trim($informasi)=="") {
echo "<script>alert('Nama Informasi masih kosong, ulangi kembali.');</script>";
}
elseif (trim($nama_file)=="") {
echo "<script>alert('File masih kosong, ulangi kembali.');</script>";
}else{
$uploaddir='./files/';
$alamatfile=$uploaddir.$nama_file;
if (move_uploaded_file($_FILES['file_berkala']['tmp_name'],$alamatfile))
{
echo "<script>alert('Data Anda berhasil diupload.');</script>";
$upload=mysql_db_query($dbs,"INSERT INTO file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file','$ukuran','$alamatfile','$tanggal','$informasi','$kategori','$unit')");
}else{
echo "<script>alert('Proses upload gagal, kode error = {$_FILES['location']['error']}');</script>";
}
}
}
else
{
unset($_POST['frminput']);
}
//*** Delete ***//
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM file_upload WHERE Id = '".$_GET["Id"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}
//*** Update ***//
?>
<form class="wawan-form" enctype="multipart/form-data" action="dashboard.php?page=berkala" method="post" >
<div class="wawan-form-inline">
<input class="wawan-textinput" style="width:80%;" name="statpos" type="hidden" value="frminput"/>
<div class="wawan-form-row">
<label>Nama Informasi</label>
<div class="wawan-form-item large">
<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" placeholder="Nama informasi"/>
</div>
</div>
<div class="wawan-form-row">
<label>File Upload</label>
<div class="wawan-form-item large">
<input type="file" name="file_berkala" class="required" />
</div>
</div>
</div>
<div class="wawan-button-row">
<input type="submit" name="btntambah" value="Submit" class="wawan-button red" />
<input type="reset" value="Reset" class="wawan-button gray" />
</div>
</form>
</div>
</div>
<div class="wawan-panel grid_7">
<div class="wawan-panel-header">
<span class="wawan-i-24 i-table-1">Daftar File Informasi Berkala</span>
</div>
<div class="wawan-panel-body">
<table class="wawan-datatable-fn wawan-table">
<thead>
<tr>
<th>No.</th>
<th>Nama Informasi</th>
<th>Nama File</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$no=1;
$sql = "SELECT * FROM file_upload where kategori='Berkala' ORDER BY tgl_upload";
$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
while ($data=mysql_fetch_array($qry)) {
?>
<tr class="gradeX">
<td><?php echo $no ?></td>
<td><?php echo $data['informasi']; ?></td>
<td><?php echo $data['nama_file']; ?></td>
<td class="center">
<a id="wawan-form-dialog-mdl-btn-<?php echo $no ?>" href="<?=$_SERVER["PHP_SELF"];?>?page=berkala&Action=Edit&Id=<?php echo $data['Id']; ?>&info=<?php echo $data['informasi']; ?>" >Edit</a> - <a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?page=berkala&Action=Del&Id=<?php echo $data['Id'];?>';}">Hapus</a>
<!--?php
$sql = "SELECT * FROM file_upload";
$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
while($data = mysql_fetch_array($qry))
{
?-->
</td>
</tr>
<?php
$no++;
}
?>
</tbody>
</table>
<?php
if ($_GET['Action'] == "Edit") {
$informasi = $_GET['info'];
$Id = $_GET['Id'];
$sqlupdate="select * from file_upload where id ='$Id'";
$qryupdate=mysql_query($sqlupdate,$koneksi) or die ("Gagal query".mysql_error());
$data=mysql_fetch_array($qryupdate);
/*if(isset($_GET["Edit"]) and $_GET["Edit"] == $no)
{*/
?>
<?php
if($_POST["statpos"] == "frmupdate")
/*if (isset($_POST['frmupdate']))
if (isset($_POST['frmupdate']) && $_POST['statpos'] == "frmupdate")*/
{
$Id = $_POST['Id'];
$kategori_update = "Berkala";
$unit_update = "sdm";
$tanggal;
$informasi_update = ucwords($_POST['informasi']);
$nama_file_update = $_FILES['file_berkala_update']['name'];
$ukuran_update = $_FILES['file_berkala_update']['size'];
if (trim($informasi_update)=="") {
echo "<script>alert('Nama Informasi masih kosong, ulangi kembali.');</script>";
}
elseif (trim($nama_file_update)=="") {
echo "<script>alert('File Upload belum dipilih, ulangi kembali.');</script>";
}
else {
$uploaddir_update='./files/';
$alamatfile_update=$uploaddir_update.$nama_file_update;
if (move_uploaded_file($_FILES['file_berkala_update']['tmp_name'],$alamatfile_update))
{
echo "<script>alert('Update data Anda berhasil diupload.');</script>";
$update=mysql_db_query($dbs,"UPDATE file_upload(nama_file,ukuran,url,tgl_upload,informasi,kategori,unit) VALUES('$nama_file_update','$ukuran_update','$alamatfile_update','$tanggal','$informasi_update','$kategori_update','$unit_update')");
}else{
echo "<script>alert('Proses update gagal, kode error = {$_FILES['location']['error']}');</script>";
}
}
}
else
{
unset($_POST['frmupdate']);
}
?>
<div id="wawan-form-dialog">
<form class="wawan-form" action="dashboard.php?page=berkala" method="post">
<input class="wawan-textinput" style="width:80%;" name="statpos" type="hidden" value="frmupdate"/>
<div class="wawan-form-inline">
<div class="wawan-form-row">
<label>Nama Informasi</label>
<div class="wawan-form-item large">
<input class="wawan-textinput" style="width:80%;" name="informasi" type="text" value="<?php echo $data['informasi']; ?>"/>
</div>
</div>
<div class="wawan-form-row">
<label>File Upload</label>
<div class="wawan-form-item large">
<input type="file" name="file_berkala_update" class="required" />
</div>
</div>
</div>
<div class="wawan-button-row">
<input type="submit" name="Submit" value="Update" class="wawan-button green" />
</div>
</form>
</div>
<?php
}
?>
</div>
</div>