<?php
error_reporting(0);
require("koneksi/koneksi.php");
include 'layouts/header.php';
include 'fungsi_paging.php';
// include 'layouts/menu_awal.php';
?>

    <body id="page-top" class="index">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" style="padding-bottom:12px">
            <div class="container">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header page-scroll">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand page-scroll" href="index.php">
                        <?php
    $query=mysql_query("SELECT * FROM setting WHERE id=8") or die (mysql_error());
    $data=mysql_fetch_array($query);
    if ($data['value'] == NULL) 
    {
      $logo = "";
  }else{
      $logo = $data['value'];
  }
    ?>
                            <img alt="Brand" width="70px" src="asset/img/<?php echo $logo;?>">
                    </a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->

                <!-- /.navbar-collapse -->
            </div>
            <!-- /.container-fluid -->
        </nav>


        <section id="portfolio" class="bg-light-gray">
            <div class="container">
                <div class="row">
                    <div class="col-lg-12 text-center">
                        <h2 class="section-heading">Berita Terkini</h2>
                    </div>
                </div>
                <div class="row">
                    <?php
            
                $p = new Paging();
                $batas = 9;
                $posisi = $p->cariPosisi($batas);

                $anggota = mysql_query("Select * from berita where status='1' order by id_berita DESC limit $posisi, $batas");
                $anggota1 = mysql_query("select * from berita");
                if(mysql_num_rows($anggota1)){
                   
                    $no = 1+$posisi;
                    while($s=mysql_fetch_array($anggota)){
                        ?>
                        <div class="col-md-4 col-sm-6 portfolio-item">
                            <a href="#portfolioModal<?php echo $s['id_berita']; ?>" class="portfolio-link" data-toggle="modal">
                                <div class="portfolio-hover">
                                    <div class="portfolio-hover-content">
                                        <i class="fa fa-check fa-3x"></i>
                                    </div>
                                </div>
                                <img src="asset/img/berita/<?php echo $s['gambar'];?>" class="" alt="" height="200px" width="360px">
                            </a>
                            <div class="portfolio-caption">
                                <h4><?php echo $s['judul'];?></h4>
                                <p class="text-muted">
                                    <?php echo $s['kategori'];?>
                                </p>
                            </div>
                        </div>
                        <?php
                        $no++;
                    }

                    $jumlahData = mysql_num_rows($anggota1);
                    $jml_halaman = $p->jmlHalaman($jumlahData,$batas);
                    $link = $p->linkHal(@$_GET['halaman'],$jml_halaman);

                    

                    }

              ?>

                </div>
                <center>
                    <?php
            echo"<br \> $link";
            ?>
                </center>

            </div>
        </section>

        <?php
include 'layouts/footer.php';
?>

            <?php
            $rw=mysql_query("Select * from berita where status='1'");
            while($s=mysql_fetch_array($rw))
            {
            ?>
                <div class="portfolio-modal modal fade" id="portfolioModal<?php echo $s['id_berita'];?>" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-content">
                        <div class="close-modal" data-dismiss="modal">
                            <div class="lr">
                                <div class="rl">
                                </div>
                            </div>
                        </div>
                        <div class="container">
                            <div class="row">
                                <div class="col-lg-8 col-lg-offset-2">
                                    <div class="modal-body">
                                        <!-- Project Details Go Here -->
                                        <h2><?php echo $s['judul'];?></h2>
                                        <p class="item-intro text-muted">
                                            <?php echo $s['kategori'];?>
                                        </p>
                                        <img class="img-responsive img-centered" src="asset/img/berita/<?php echo $s['gambar'];?>" alt="">
                                        <p>
                                            <?php echo $s['isi'];?>
                                        </p>
                                        <button type="button" class="btn btn-primary" onclick="alert('Silahkan Login Terlebih dahulu. Jika tidak punya akun, silahkan untuk medaftar.')">Join</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php
}
?>