<?php
if ($_GET['module']=='home'){
  $sql=mysql_query("SELECT * FROM tb_halaman WHERE halaman='home'");
  $r=mysql_fetch_array($sql);
    echo "<h2>$r[judul]</h2>
          <p align='center'>$r[detail]</p>";

    $sql=mysql_query("select * from tb_berita order by rand() LIMIT 3");
    while($r=mysql_fetch_array($sql)){
        //$tgl = tgl_indo($r['tanggal']);
        $judul = nl2br($r['judul']);
        $isijudul = substr($judul,0, 36);

        $isi_berita = nl2br($r['isi_berita']);
        $isi = substr($isi_berita,0, 260);
        $isi = substr($isi_berita,0,strrpos($isi," "));
        echo "
			<h2><a href=news-$r[id_berita].adm>$isijudul</a></h2>
				$isi <a href=news-$r[id_berita].adm>[selengkapnya..]</a>
	";
    }
}

elseif ($_GET['module']=='form_login'){
	echo "
	<h2>Silahkan Login !!</h2>
		<form method=POST name='formku' onSubmit='return valid()' action='cek_login.php' id='registerHere'>
		<table class='data'>
			<tr class='data'>
				<td class='data' width='150'>Username</td>
				<td class='data' width='5'> :</td>
				<td class='data'><input type=text name='id_user' class='panjang'></td>
			</tr>
			<tr class='data'>
				<td class='data'>Password</td>
				<td class='data'> :</td>
				<td class='data'><input type=password name='password' class='panjang'></td>
			</tr>
			<tr class='data'>
				<td class='data' colspan='3' align='center'>
					<button type='submit' class='button'>Login</button>
				</td>
			</tr>
		</table>";
}

elseif ($_GET['module']=='profil'){
  include "kinerja/profil.php";
}

elseif ($_GET['module']=='nilaiatribut'){
  include "kinerja/nilaiatribut.php";
}

elseif ($_GET['module']=='dataset'){
  include "kinerja/dataset.php";
}

elseif ($_GET['module']=='atribut'){
  include "kinerja/atribut.php";
}

elseif ($_GET['module']=='proses_excel'){
  include "config/proses_excel.php";
}

elseif ($_GET['module']=='proses_excel1'){
    include "config/proses_excel1.php";
}

elseif ($_GET['module']=='datalatih'){
  include "kinerja/datalatih.php";
}

elseif ($_GET['module']=='periode'){
  include "kinerja/periode.php";
}

elseif ($_GET['module']=='proses'){
    include "kinerja/proses.php";
}

elseif ($_GET['module']=='hubungikami'){
  echo "<h2>Hubungi kami</h2>
		<form action=hubungi-aksi.adm name='formku' onSubmit='return valid()' method=POST id='registerHere'>
			<table class='data'>
				<tr class='data'>
					<td class='data' width='150'>Nama Lengkap</td>
					<td class='data' width='5'>:</td>
					<td class='data'>
					<input id='nama_lengkap' name='nama_lengkap' type='text' class='panjang'/></td>
				</tr>
				<tr class='data'>
					<td class='data'>Alamat E-mail</td>
					<td class='data'>:</td>
					<td class='data'>
					<input name='email' type='text' class='panjang' id='email'/></td>
				</tr>
				<input name='subjek' type='hidden' value='From_Guest'/>
				<tr class='data'>
					<td class='data'>Message</td>
					<td class='data'>:</td>
					<td class='data'><textarea style='width:93%; height:120px;' name='pesan' class='required'></textarea></td>
				</tr>
				<tr class='data'>
					<td class='data' align='center' colspan='3'>
						<button type='submit' class='button'>Submit</button></td>
				</tr>
			</table>
			</fieldset>
		</form>";
}

elseif ($_GET['module']=='hubungiaksi'){
$nama_lengkap = trim(htmlentities($_POST[nama_lengkap]));
$email = trim(htmlentities($_POST[email]));
$subjek = trim(htmlentities($_POST[subjek]));
$pesan = trim(htmlentities($_POST[pesan]));
  mysql_query("INSERT INTO tb_hubungi(nama,
                                   email,
                                   subjek,
                                   pesan,
                                   tanggal)
                        VALUES('$nama_lengkap',
                               '$email',
                               '$subjek',
                               '$pesan',
                               '$tgl_sekarang')");

  echo "<div style='margin-top:5%; text-align:center;' class='alert alert-success'>
			<button type='button' class='close' data-dismiss='alert'>&times;</button>
			Sukses Mengirim Pesan ke Admin! <br>Terimakasih telah menghubungi kami. Kami akan segera meresponnya
		</div>";
}

elseif ($_GET['module']=='detailberita'){
	  $sql=mysql_query("select * from tb_berita where id_berita=$_GET[id]");
	  while($r=mysql_fetch_array($sql)){
		  $tgl = tgl_indo($r['tanggal']);
		  $isi_berita = nl2br($r['isi_berita']);

			echo "<table><tr>
						<h2><a href=news-$r[id_berita].adm>$r[judul]</a></h2>
						 <div class='date'>Diposting pada : $r[hari], $tgl - $r[jam] WIB  </div><hr>";
			echo "<p>$isi_berita</p>";
		 }
			echo "</table><br/>";
}

elseif ($_GET['module']=='contact'){
	  echo "<h2>Data Contact.</h2>";

  $prosedur=mysql_query("SELECT * FROM tb_hubungi ORDER BY id_hubungi DESC");
  $no=1;
  echo "<table class='data'>
		<tr class='data'>
			<th class='data'>No</th>
			<th class='data'>Nama</th>
			<th class='data'>Subjek</th>
			<th class='data'>Tanggal</th>
			<th width='80' class='data'>Action</th>
		</tr>";
  $no=1;

  while($r=mysql_fetch_array($prosedur)){
  $tanggal = tgl_indo($r['tanggal']);
  if(($no % 2)==0){ $warna="#fff"; } else{ $warna="#f4f4f4"; }
	echo "<tr bgcolor='$warna'><td>$no</td>
				 <td class='data'>$r[nama]</td>
				 <td class='data'>$r[subjek]</td>
				 <td class='data'>$tanggal</td>
				 <td class='data'>
				 	<a class='btn btn-success' href='media.php?module=contact&aksi=detail&id=$r[id_hubungi]'><img src='images/view.png'></a>
					<a class='btn btn-danger' href='media.php?module=contact&aksi=hapus&id=$r[id_hubungi]'><img src='images/cancel.gif'></a>
				 </td>
			 </tr>";
	$no++;
  }
  echo "</table>";

	if (@$_GET['aksi']=='detail'){
		$edit = mysql_query("SELECT * FROM tb_hubungi WHERE id_hubungi='$_GET[id]'");
    	$r    = mysql_fetch_array($edit);
  		?>
        <br />
        <hr />
        <br />
        <form class="form-horizontal" action='media.php?module=kriteria&aksi=update' method='POST'>
        <h2>Detail Data Contact</h2>
        <table class='data'>
        	<tr class='data'>
            	<td width="150" class='data'>ID Contact</td>
                <td width="5" class='data'>:</td>
                <td class='data'><?php echo $r['id_hubungi'];?></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Nama</td>
                <td width="5" class='data'>:</td>
                <td class='data'><?php echo $r['nama'];?></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>E-Mail</td>
                <td width="5" class='data'>:</td>
                <td class='data'><?php echo $r['email'];?></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Subjek</td>
                <td width="5" class='data'>:</td>
                <td class='data'><?php echo $r['subjek'];?></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Pesan</td>
                <td width="5" class='data'>:</td>
                <td class='data'><p align="justify"><?php echo $r['pesan'];?></p></td>
            </tr>
            <tr class='data'>
            	<td colspan="3" align="center" class='data'>
                	<center>
                    <a class='btn btn-primary' href='contact.adm'>&lArr; Kembali</a>
                    <a class='btn btn-danger' href='<?php echo "media.php?module=contact&aksi=hapus&id=$r[id_hubungi]";?>'>&times;</a>
                    </td>
            </tr>
        </table>
        </form>
        <?php
  	}

	if (@$_GET['aksi']=='hapus'){
  		mysql_query("DELETE FROM tb_hubungi where id_hubungi='$_GET[id]'");

  		echo "<script>window.alert('Sukses Hapus Contact Us Terpilih.');
				window.location='contact.adm'</script>";
  }
}

elseif ($_GET['module']=='hal_web'){
	echo "<h2>Halaman WEB.</h2>";

  $prosedur=mysql_query("SELECT * FROM tb_halaman ORDER BY id_halaman DESC");
  $no=1;
  echo "
  <table class='data'>
		<tr class='data'>
			<th class='data' align='center'>No</th>
			<th class='data' align='center'>Halaman</th>
			<th class='data' align='center'>Judul</th>
			<th width='80' class='data' align='center'>Action</th>
		</tr>";
  $no=1;

  while($r=mysql_fetch_array($prosedur)){
  if(($no % 2)==0){ $warna="#fff"; } else{ $warna="#f4f4f4"; }
	echo "<tr bgcolor='$warna'>
				<td class='data'>$no</td>
				 <td class='data'>$r[halaman]</td>
				 <td class='data'>$r[judul]</td>
				 <td class='data' align='center'>
				 	<a class='btn btn-success' href='media.php?module=hal_web&aksi=detail&id=$r[id_halaman]'>
					<img src='images/view.png'></a>
					<a class='btn btn-danger' href='media.php?module=hal_web&aksi=hapus&id=$r[id_halaman]'>
					<img src='images/cancel.gif'></a>
				 </td>
			 </tr>";
	$no++;
  }
  echo "</table>";

  if (@$_GET['aksi']=='detail'){
		$edit = mysql_query("SELECT * FROM tb_halaman WHERE id_halaman='$_GET[id]'");
    	$r    = mysql_fetch_array($edit);
  		?>
        <br />
        <hr />
        <br />
        <form class="form-horizontal" action='media.php?module=hal_web&aksi=update' method='POST'>
        <h2>Detail Data Halaman WEB</h2>
        <table class='data'>
        	<tr class='data'>
            	<td width="150" class='data'>ID Halaman</td>
                <td width="5" class='data'>:</td>
                <td class='data'><input type="text" class='span3' name='id_halaman' id="id_halaman"
                  value="<?php echo $r['id_halaman'];?>" readonly></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Halaman</td>
                <td width="5" class='data'>:</td>
                <td class='data'><input type="text" class='span9' name='halaman' id="halaman" value="<?php echo $r['halaman'];?>"></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Judul</td>
                <td width="5" class='data'>:</td>
                <td class='data'>
                <textarea name='judul' rows='7' cols="60" id='judul'><?php echo $r['judul'];?></textarea>
                </td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Detail Halaman</td>
                <td width="5" class='data'>:</td>
                <td class='data'><textarea name='detail' rows='10' cols="60" id='detail'><?php echo $r['detail'];?></textarea> </td>
            </tr>
            <tr class='data'>
            	<td colspan="3" align="center" class='data'>
                	<center>
                    <a class='btn btn-primary' href='media.php?module=hal_web'>&lArr; Kembali</a>
                    <button type='submit' name='u' class="button">Ubah &rArr;</button>
                    </td>
            </tr>
        </table>
        </form>
        <?php
  	}

	if (@$_GET['aksi']=='update'){
  		$query=mysql_query("
							UPDATE tb_halaman SET
							judul = '$_POST[judul]',
							detail = '$_POST[detail]'
							WHERE id_halaman = '$_POST[id_halaman]'");

  		echo "<script>window.alert('Sukses Ubah Halaman WEB Terpilih.');
				window.location='media.php?module=hal_web'</script>";
  }

  if (@$_GET['aksi']=='hapus'){
  		mysql_query("DELETE FROM tb_halaman where id_halaman='$_GET[id]'");

  		echo "<script>window.alert('Sukses Hapus Halaman WEB Terpilih.');
				window.location='media.php?module=hal_web'</script>";
  }

}
elseif ($_GET['module']=='berita'){
	echo "<h2>Data Berita</h2>";

  $prosedur=mysql_query("SELECT * FROM tb_berita ORDER BY id_berita DESC");
  $no=1;
  echo "
  <table class='data'>
		<tr class='data'>
			<th class='data' align='center'>No</th>
			<th class='data' align='center'>Tanggal</th>
			<th class='data' align='center'>judul</th>
			<th width='80' class='data' align='center'>Action</th>
		</tr>";
  $no=1;

  while($r=mysql_fetch_array($prosedur)){
	  $tanggal = tgl_indo($r['tanggal']);
  if(($no % 2)==0){ $warna="#fff"; } else{ $warna="#f4f4f4"; }
	echo "<tr bgcolor='$warna'>
				<td class='data'>$no</td>
				 <td class='data'>$tanggal</td>
				 <td class='data'>$r[judul]</td>
				 <td class='data' align='center'>
				 	<a class='btn btn-success' href='media.php?module=berita&aksi=detail&id=$r[id_berita]'><img src='images/view.png'></a>
					<a class='btn btn-danger' href='media.php?module=berita&aksi=hapus&id=$r[id_berita]'><img src='images/cancel.gif'></a>
				 </td>
			 </tr>";
	$no++;
  }
  echo "</table>";

  if (@$_GET['aksi']=='detail'){
		$edit = mysql_query("SELECT * FROM tb_berita WHERE id_berita='$_GET[id]'");
    	$r    = mysql_fetch_array($edit);
		$tanggal = tgl_indo($r['tanggal']);
  		?>
        <br />
        <hr />
        <br />
        <form class="form-horizontal" action='media.php?module=berita&aksi=update' method='POST'>
        <h2>Detail Data Berita</h2>
        <table style='border:1px solid #c1c1c1;' class='table table-bordered'>
        	<tr class='data'>
            	<td width="150" class='data'>ID Berita</td>
                <td width="5" class='data'>:</td>
                <td class='data'><input type="text" class='span3' name='id_berita' id="id_berita"
                  value="<?php echo $r['id_berita'];?>" readonly></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Waktu Terbit Berita</td>
                <td width="5" class='data'>:</td>
                <td class='data'><input type="text" class='panjang' name='waktu' id="waktu"
                  value="<?php echo $r['hari']." | ".$tanggal." | ".$r['jam'];?>" readonly></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Judul</td>
                <td width="5" class='data'>:</td>
                <td class='data'><input type="text" class='panjang' name='judul' id="judul" value="<?php echo $r['judul'];?>"></td>
            </tr>
            <tr class='data'>
            	<td width="150" class='data'>Isi Berita</td>
                <td width="5" class='data'>:</td>
                <td class='data'>
                <textarea name='isi_berita' rows='12' cols="60" id='isi_berita'><?php echo $r['isi_berita'];?></textarea>
                </td>
            </tr>
            <tr class='data'>
            	<td colspan="3" align="center" class='data'>
                	<center>
                    <a class='btn btn-primary' href='media.php?module=hal_web'>&lArr; Kembali</a>
                    <button type='submit' name='u' class="button">Ubah &rArr;</button>
                    </td>
            </tr>
        </table>
        </form>
        <?php
  	}

	if (@$_GET['aksi']=='update'){
  		$query=mysql_query("
							UPDATE tb_berita SET
							judul = '$_POST[judul]',
							isi_berita = '$_POST[isi_berita]'
							WHERE id_berita = '$_POST[id_berita]'");

  		echo "<script>window.alert('Sukses Ubah Berita Terpilih.');
				window.location='media.php?module=berita'</script>";
  }

  if (@$_GET['aksi']=='hapus'){
  		mysql_query("DELETE FROM tb_berita where id_berita='$_GET[id]'");

  		echo "<script>window.alert('Sukses Hapus Berita Terpilih.');
				window.location='media.php?module=berita'</script>";
  }
}
?>