<?php 
$niz_novina = Aplikacija::novine_za_auto();
foreach ($niz_novina as $nov) {
    $id_novina = $nov["id_novina"];
    $novina = new Novina($id_novina);
    $rez = $novina->prikazi_vesti_neobjavljene(1);
    foreach ($rez as $r) {
        $id_vesti = $r["id_vesti"];
        $v = new Vest($id_vesti);
        ?>
            <!-- pocetak clanak -->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2 class="panel-title" style="display:inline;">
                        <a href="<?php 
        echo $v->link();
        ?>
"><?php 
        echo $v->naslov();
        ?>
</a>
                    </h2>

                    <div class="pull-right">
                        <div class="btn-group">
                            <div class="btn btn-default" triger="odobri_vest" role="stara" id="<?php 
        echo $v->id_vesti;
        ?>
">
                                Odobri vest
                            </div>
echo $nov->naziv();
?>
</span></a>
        <p class="date" id="nove-vesti"></p>
    <?php 
$res = $nov->prikazi_vesti_neobjavljene(0);
foreach ($res as $r) {
    $id = $r["id_vesti"];
    $n_vest = new Vest($id);
    ?>
        <!-- pocetak clanak -->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2 class="panel-title" style="display:inline;">
                   <a href="<?php 
    echo $n_vest->link();
    ?>
"> <?php 
    echo $n_vest->naslov();
    ?>
</a>
                </h2>

                <div class="pull-right">
                    <div class="btn-group">
                        <div class="btn btn-default" triger="dodaj_vest" role="nova" id="<?php 
    echo $n_vest->id_vesti;
    ?>
">
                            Dodaj vest
                        </div>
<marquee scrollamount="5">
    <?php 
$db = new DB();
$db->get("SELECT id_vesti FROM vesti WHERE obrisano=0 AND datum_publikovanja IS NOT NULL AND obrisano=0 AND vreme >= DATE(NOW() - INTERVAL 1 DAY) ORDER BY datum_publikovanja DESC ");
//$db->get("SELECT id_vesti FROM vesti WHERE datum_publikovanja IS NOT NULL AND obrisano=0");
$rez = $db->res;
foreach ($rez as $r) {
    $id_v = $r["id_vesti"];
    $v = new Vest($id_v);
    echo '<span class="mali-logo"></span><a class="fancy" href="' . $v->link() . '"><span style="color: #D54401">' . $v->kategorija() . ' </span> ' . $v->naslov() . '</a>';
}
?>
</marquee>
 * Date: 12.6.2015
 * Time: 13:20
 */
$vreme = '1';
$kat = '0';
if (isset($_POST["filter"]) && $_POST["filter"] != "") {
    $filter = json_decode($_POST["filter"], true);
    $vreme = $filter['vreme'];
    $kat = $filter['kategorije'];
}
if ($kat == '0') {
    $katsql = "";
} else {
    $katsql = "AND kategorija='{$kat}'";
}
$db = new DB();
$sql = "SELECT id_vesti FROM vesti WHERE obrisano=0 AND datum_publikovanja IS NOT NULL AND DATE(`vreme`) >= DATE(NOW() - INTERVAL '{$vreme}' DAY)" . $katsql;
$db->get($sql);
$data = array();
$i = 0;
$rez = $db->res;
foreach ($rez as $r) {
    $vest = new Vest($r['id_vesti']);
    $data[$i]['tittle'] = $vest->naslov();
    $data[$i]['link'] = $vest->link();
    $data[$i]['lat'] = $vest->lat();
    $data[$i]['lng'] = $vest->lng();
    $data[$i]['time'] = $vest->vreme();
    $i++;
}
echo json_encode($data, JSON_PRETTY_PRINT);