<?
//***************************************************
// http://www.niadesain.com
// Solusi Hemat Script Bisnis Online Anda
// Menerima Jasa Pembuatan Website & Template Website
//***************************************************
?>

<?
echo "<div class='media accordion-inner'>";
$batas   = 12;
//$halaman = $_GET['halaman'];
$halaman = isset($_GET['halaman']) ? $_GET['halaman'] : null;
if(empty($halaman)){
	$posisi  = 0;
	$halaman = 1;
}
else{
	$posisi = ($halaman-1) * $batas;
}

$db->select("id_berita, id_user, judul, isi_berita, gambar, tanggal, counter, published", "berita", "published=1", "id_berita desc LIMIT $posisi,$batas");

if($db->num_rows() > 0) {
	//echo $db->result(0, "maintext");
	while($row = $db->fetch_row()) {
	$adafoto = $row[4];
	    echo "<table width='100%'>";
	    echo "<tr><td>";

		echo "<div class='isi'>Post : $row[5] - dibaca : $row[6] kali</div>";
//		echo "<div class='isi'><font color='#282D3A'>Berita ini telah dibaca : $row[6] kali</font></div>";
		echo "<div class='isi'><font color='#282D3A'><h4><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><font color='#ff6700' class='judulberita'>$row[2]</font></a></h4></font></div>";

		if ($adafoto !=''){
                echo "<div class='pull-left'><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><img class='img-responsive' src='images/news/".$row[4]."' width=239 height=102 hspace=0 border=1 align=left title='$row[2]'></a><img class='img' src='images/news/awblank.png' width=15 height=97 align=left></div>";
		}
		else
		{
                echo "<div class='pull-left'><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><img class='img-responsive' src='images/news/noimage.jpg' width=239 height=102 hspace=0 border=1 align=left title='$row[2]'></a><img class='img' src='images/news/awblank.png' width=15 height=97 align=left></div>";
		}

		// Tampilkan hanya sebagian isi berita
  	  	//$isi_berita = nl2br($row[3]);
                $isi_berita = strip_tags(nl2br($row[3]));
        	$isi = substr($isi_berita,0,140);               // ambil sebanyak 140 karakter
                $isi = substr($isi_berita,0,strrpos($isi," ")); // spasi antar kalimat
		echo "<div class='media-body'><div align=left><font color='#282D3A'>$isi ...</font></div><a href=./?scrindo=detailberita&nid=$row[0]&id=$id><button type=\"submit\" name=\"submit\" class=\"btn btn-primary btn-lg\"> Baca Selengkapnya </button></a></div>";
		echo "</td></tr></table>";
		echo "<div><hr width=100% size=1 color=#CCCCCC></div>";
			}
} else {
	echo "<p>&nbsp;</p><p align=left class='isi'>Maaf belum ada berita untuk ditampilkan...</p><p>&nbsp;</p>";
}

$tampil2 = mysql_query("SELECT * FROM berita where published=1");
$jmldata = mysql_num_rows($tampil2);
$jmlhal  = ceil($jmldata/$batas);
echo "<div class=paging>";
echo "</div>";

if($halaman > 1){
	$prev=$halaman-1;
	echo "<span class=prevnext><a href=$_SERVER[PHP_SELF]?scrindo=berita&halaman=$prev&id=$id>Prev</a></span> ";
}
else{
	echo "<span class=disabled>Prev</span> ";
}

// Tampilkan link halaman 1,2,3 ...
for($i=1;$i<=$jmlhal;$i++)
if ($i != $halaman){
	echo " <a href=$_SERVER[PHP_SELF]?scrindo=berita&halaman=$i&id=$id>$i</a> ";
}
else{
	echo " <span class=current>$i</span> ";
}

// Link kehalaman berikutnya (Next)
if($halaman < $jmlhal){
	$next=$halaman+1;
	echo "<span class=prevnext><a href=$_SERVER[PHP_SELF]?scrindo=berita&halaman=$next&id=$id>Next</a></span>";
}
else{
	echo "<span class=disabled>Next</span>";
}
echo "</div>";
//echo "<br>";
echo "<div class='media accordion-inner'>";
echo "Total berita & informasi <strong><font color=#ff6700>". strtolower($set_bisnis) ."</font></strong> ada : <b>$jmldata</b> berita";
echo "<br><font color=#ffffff>design by $set_develop</font>";
echo "</div>";

echo "</div>";
?>