<?php if(isset($_GET['project'])){ ?>
    <?php include_once 'header.php';
    $proje = $db->query("SELECT id FROM " . DBPREFIX . "projeler WHERE proje_code = '".$func->get('project')."'");
    //echo '<pre>';print_r($proje->row['id']);echo '</pre>'; die();
    if(!isset($proje->row['id'])){
        echo '<div class="text-center">Proje bulunamadı!</div>';die();
    }
    $db->query("INSERT INTO " . DBPREFIX . "events SET customer_id = '".$customer->getId()."',page='projeler=".$func->get('project')."',description= '".$func->get('project')." projesine bakıldı'");
    ?>
    <?php $tabs = $db->query("SELECT blok FROM " . DBPREFIX . "items WHERE proje_id = '".$proje->row['id']."' GROUP BY blok"); ?>

    <section id="main-page" class="content-section text-center">
        <div class="container">
            <!--
        <div class="row">
            <div class="col-sm-12">
                <div class="page-panel-header">
                    <div class="row">
                        <div class="col-sm-8">
                            <ul class="tab-list">
                                <?php foreach ($tabs->rows as $key=>$tab) { ?>
                                    <li class="tab-item <?php echo $key==0?'active':''; ?>" data-tab="tab_<?php echo $tab['blok']; ?>"><a data-tab="tab_<?php echo $tab['blok']; ?>" href="javascript:void();"><?php echo $tab['blok']; ?> Blok</a></li>
                                <?php } ?>
                            </ul>
                        </div>
                        <div class="col-sm-4">
                            <div class="pull-right">
                                <div class="dropdown">
                                    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <span class="text">Kat Planları</span>
                                        <img src="assets/img/arrow-down.svg" alt="" class="">
                                    </button>
                                    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                        <?php foreach ($tabs->rows as $key=>$tab) { ?>
                                            <a class="dropdown-item" href="#"><?php echo $tab['blok']; ?> Blok Kat Planı</a>
                                        <?php } ?>
                                    </div>
                                </div>
                                <div class="dropdown ml40">
                                    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <span class="text">Sırala</span>
                                        <img src="assets/img/sort.svg" alt="Sırala" class="">
                                    </button>
                                    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                        <a class="dropdown-item" href="#">Satılan</a>
                                        <a class="dropdown-item" href="#">Satılmayan</a>
                                        <a class="dropdown-item" href="#">Opsiyonlu</a>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

                </div>
            </div>
        </div>
        -->
            <div class="row">
                <div class="col-lg-12">
                    <?php foreach ($tabs->rows as $key=>$tab) { ?>
                        <!-- All Orders Block -->
                        <div id="tab_<?php echo $tab['blok']; ?>" class="block full tab-area-item <?php echo $key==0?'active':''; ?>">

                            <!-- All Orders Content -->
                            <table id="ecom-orders" class="table table-striped table-vcenter">
                                <thead>
                                <tr>

                                    <th class="text-center">No</th>
                                    <th class="text-center">Blok</th>
                                    <th class="text-center">Oda</th>
                                    <th class="text-center">Fiyat</th>
                                    <th>Durum</th>
                                    <th class="text-center">Brüt</th>
                                    <th class="text-center">Net</th>
                                    <th class="text-right">Kat</th>
                                    <th class="text-right">Cephe</th>
                                    <th class="text-right">Türü</th>
                                    <th class="text-right">Tipi</th>
                                    <th class="text-right">Model</th>

                                </tr>
                                </thead>
                                <tbody>
                                <?php

                                $labels['1']['class']   = "label-danger";
                                $labels['1']['text']    = "Satıldı";
                                $labels['0']['class']   = "label-info";
                                $labels['0']['text']    = "Satılık";
                                $labels['2']['class']   = "label-success";
                                $labels['2']['text']    = "Opsiyonlandı";

                                $items = $db->query("SELECT * FROM " . DBPREFIX . "items WHERE proje_id = '".$proje->row['id']."'");
                                ?>
                                <?php foreach($items->rows as $item) { ?>
                                    <tr id="order_id_<?php echo $item['id']; ?>" class="<?php echo $labels[$item['durum']]['class']; ?> ">

                                        <td data-order="<?php echo $item['id']; ?>" class="text-center"> <span class="<?php echo $item['is_arsa_sahibi']?'gray-label':''; ?>"></span><?php echo $item['daire_no']; ?></td>
                                        <td class="text-center"><?php echo $item['blok']; ?></td>
                                        <td class="text-center"><?php echo $item['oda']; ?></td>
                                        <td class="text-center"><?php echo $item['fiyat']; ?><?php echo $item['currency']; ?></td>
                                        <td>
                                            <span class=" "><?php echo $labels[$item['durum']]['text']; ?></span>
                                            <!--
                                    <select type="text" id="durum" name="durum" <?php echo isset($item['status']) && $item['status']>='1'?'disabled':''; ?> class="form-control">
                                        <option value="" >-- Eylem --</option>
                                        <option value="1" <?php echo isset($item['status']) && $item['status']=='1'?'selected="selected"':''; ?>>Satıldı</option>
                                        <option value="2" <?php echo isset($item['status']) && $item['status']=='2'?'selected="selected"':''; ?>>Opsiyonlandı</option>
                                    </select>
                                    --->
                                        </td>
                                        <td class="text-center"><?php echo $item['brut_metre']; ?></td>
                                        <td class="text-center"><?php echo $item['net_metre']; ?></td>
                                        <td class="text-right"><?php echo $item['kat']; ?></td>
                                        <td class="text-right"><?php echo $item['cephe']; ?></td>
                                        <td class="text-right"><?php echo $item['daire_turu']; ?></td>
                                        <td class="text-right"><?php echo $item['daire_tipi']; ?></td>
                                        <td class="text-right"><?php echo $item['diger_metre']; ?></td>

                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                            <!-- END All Orders Content -->
                        </div>
                        <!-- END All Orders Block -->
                    <?php } ?>
                </div>
            </div>
        </div>
    </section>

    <script src="<?php echo SITE_ADMIN; ?>js/vendor/jquery.min.js"></script>
    <script src="<?php echo SITE_ADMIN; ?>js/vendor/bootstrap.min.js"></script>
    <script src="<?php echo SITE_ADMIN; ?>js/plugins.js"></script>
    <script src="<?php echo SITE_ADMIN; ?>js/app.js"></script>
    <script src="<?php echo SITE_ADMIN; ?>js/pages/ecomOrders.js"></script>
    <script>$(function(){ EcomOrders.init(); });</script>
    <script>

        jQuery('#supports').on('change',function () {
            vals = jQuery(this).val();
            date = $('#filter-date').val();
            if(!date){
                alert("Rezervasyon tarihi seçiniz!");
                return false;
            }
            //vals = vals.join(',')
            console.log(vals)
            $.ajax({
                url: 'ajax.php?type=users',
                type: "POST",
                data: 'supports='+vals+'&date='+date,
                dataType: 'json',
                beforeSend: function () {
                    //$('#button-cart').button('loading');
                },
                complete: function () {
                    //$('#button-cart').button('reset');
                },
                success: function (json) {
                    if(json.success){
                        if(json.status>0) {
                            jQuery('#user_id').html(json.success);
                        }else{
                            alert('Malesef seçtiğiniz tarihlerde müsait personel bulunmamaktadır.')
                        }
                    }else{
                        aler('Silme işleminde bir hata ile karşılaşıldı!');
                    }
                }
            });
        });

    </script>
    <?php include_once 'footer.php'; ?>

<?php }else{ ?>
    <?php include 'loader.php'; ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Gökdemir Group - Proje Fiyat Listesi</title>
        <meta name="description" content="">
        <link href="<?php echo SITE; ?>assets/css/style.css" rel="stylesheet">
    </head>
    <body id="page-top">
    <?php
    /**
     * Created by DDAWEBDIZAYN.
     * User: HUS
     * Date: 17.04.2017
     * Time: 12:09
     */

    $projeler = $db->query("SELECT * FROM " . DBPREFIX . "projeler WHERE durum = '1'");
    $db->query("INSERT INTO " . DBPREFIX . "events SET customer_id = '".$customer->getId()."',page='login',description= 'Giriş yapıldı'");
    //print_r($_SERVER);die();
    if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST'){
        //echo "metodda";

        $login = $user->plogin($_POST['email'],$_POST['password']);
        //echo '<pre>';print_r($login);echo '</pre>'; die();
        if($user->isLogged('frontend')){
            //$func->prnt($_POST,1);
            $error->uset();
            $session->set('success',"Başarı ile giriş yaptınız.");
            $db->query("INSERT INTO " . DBPREFIX . "events SET customer_id = '".$user->getId()."',page='login',description= 'Giriş yapıldı'");
            $location->redirect('index');
        }else{
            $success->uset();
            $session->set('error',"Yanlış Kullanıcı Adı Veya Şifre!");
            //$location->redirect('login');
        }
    }else{
        $error->uset();
    }

    ?>

    <!-- Login Container -->
    <div id="login-container" class="container">

        <!-- Login Block -->
        <div class="login-block">
            <img src="assets/img/logo.svg" alt="Login Full Background" style="max-width: 300px" class="login-logo">
            <!-- Login Form -->
            <form action="index.php" method="get" id="form-login" class="form-horizontal form-bordered form-control-borderless">
                <div class="form-group">
                    <label>Proje Fiyat Listeleri</label>
                    <select name="project" class="form-control" style="line-height: 40px;height: 50px">
                        <option value="">-- Proje Seçiniz --</option>
                        <?php if($projeler->num_rows){ ?>
                            <?php foreach($projeler->rows as $row){ ?>
                                <option value="<?php echo $row['proje_code']; ?>"><?php echo $row['adi']; ?></option>
                            <?php } ?>
                        <?php } ?>
                    </select>
                </div>
                <div class="form-group form-actions">
                    <button type="submit" class="btn btn-sm btn-submit"><i class="fa fa-angle-right"></i> Projeye Git</button>
                </div>
            </form>
            <!-- END Login Form -->
        </div>


        <!-- END Login Block -->
    </div>
    <!-- END Login Container -->
    <link href="<?php echo SITE; ?>assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700&amp;subset=latin-ext" rel="stylesheet">
    <link href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet">
    <link href="<?php echo SITE; ?>assets/css/grayscale.min.css" rel="stylesheet">

    </body>
    </html>
<?php } ?>