 <?php

        $con = new mysqli("localhost","root","toor","museam_db");
        mysqli_set_charset($con, 'utf8');

        // Check connection
        if (mysqli_connect_errno())
          {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }

            if(!isset($_SESSION))
            session_start();
  //      foreach ($_SESSION as $key=>$val)
  //      echo $key. ": ".$val. "<br>";

        $anaf2_msg ="";
        
        include_once("/includes/errorcheck.php");


        if (isset($_POST['save']) and $_POST['save']=="anaf2"){


        }    
    ?>


<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>About - Business Casual - Start Bootstrap Theme</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/business-casual.css" rel="stylesheet">
    <link href="css/flow.css" rel="stylesheet">
    <script type='text/javascript' src='js/function/common.js'></script>


    <!-- Fonts -->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" rel="stylesheet" type="text/css">

    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
    <script type='text/javascript' src='js/flow.js'></script>

    <!-- Custom CSS -->
    <link href="css/freelancer.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">

    <!-- MetisMenu CSS -->
    <link href="css/metisMenu.min.css" rel="stylesheet">

    <!-- DataTables CSS -->
    <link href="css/dataTables.bootstrap.css" rel="stylesheet">

</head>

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

 <!-- Navigation -->
    <nav class="navbar_fixed_top">
        <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" href="#page-top">Start Bootstrap</a>
            </div>

             <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-left">
                 <li class="page-scroll">
                        <img class="main_image_bar" id="proswpa"src="images/icons_black/report.png">
                        </li>
                    <li class="page-scroll">
                        <a href="anafores.php"> <i class="fa fa-star-half"> </i>ΕΠΙΣΚΕΥΕΣ</a>
                    </li>
                    <li class="page-scroll">
                        <a href="anafores2.php"> <i class="fa fa-star-half"> </i>ΣΥΝΤΗΡΗΣΕΙΣ</a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>

 <!--create-flow-menu-->
 <?php
  include_once("/includes/flowmenu.php");
 ?>
 <!-- /.create-flow-menu -->     


      <section class="top_pad" id="edit">
        <div class="container"> 

            <div class="row">
                <div class="col-lg-12 text-center">
                    <hr class="star-primary">
                    <h2 class="intro-text text-center">ΑΝΑΦΟΡΑ
                            <strong>ΣΥΝΤΗΡΗΣΕΩΝ</strong>
                    </h2>
                    <hr class="star-primary2">
                </div>
            </div>

              <div class="row">
                <div class="col-lg-12 text-center">
                    <p class="main_img_text2"> 
                    </p>
                </div>
            </div>

            

             <div class="row">       
                <div class="box"> 

                <div class="row">       
                    <div class="col-md-6">
                         <table class="main_table3">
                         <form method="post" action="">
                            <tr>
                            <td >
                                <label id="pad-left">Ημερομηνία Έναρξης Αναζήτησης:</label>
                                <div class="form-group input-group">
                                    <span class="input-group-addon"> <i class="fa fa-calendar"> </i> </span>
                                    <input name="anaf2_start_date" value="<?=((isset($_POST['anaf2_start_date'])) ? $_POST['anaf2_start_date'] : date('Y-m-d'))?>" type="date" class="form-control">
                                </div>
                            </td>
                            <td >
                                <label id="pad-left">Ημερομηνία Λήξης Αναζήτησης:</label>
                                <div class="form-group input-group">
                                    <span class="input-group-addon"> <i class="fa fa-calendar"> </i> </span>
                                    <input name="anaf2_end_date" value="<?=((isset($_POST['anaf2_end_date'])) ? $_POST['anaf2_end_date'] : date('Y-m-d'))?>" type="date" class="form-control">
                                </div>
                            </td>
                            <td>
                                <label id="pad-left">OK εδώ:</label>
                                <div class="form-group input-group">
                                        <input type="hidden" name="save" value="anaf2">
                                        <input type="submit"  onclick="this.form.submit();" class="btn btn-success"></submit>
                                </div>
                            </td>
                            </tr>
                            <tr>
                            </tr>
                            </form>
                        </table>          
                    </div>
            </div>
                    <div id="wrapper">
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example23">
                                    <thead>
                                        <tr>
                                            <th>Κωδικός</th>
                                            <th>Προϋπ.</th>
                                            <th>Ημερ.Έναρξης:</th>
                                            <th>Ημερ.Λήξης:</th>
                                            <th>Συντηρητής</th>
                                            <th>Υπεύθ.Προϋπ.</th>
                                            <th>Υπεύθ.Επίβλ.</th>
                                            <th>Αίθουσα</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php

                                        if (isset($_POST['save']) and $_POST['save']=="anaf2"){

                                        $query = "SELECT syntiriseis.id, syntiriseis.kwdikos, syntiriseis.budget, syntiriseis.start_date, syntiriseis.end_date, syntiriseis.museam_id, syntiriseis.room_id, (SELECT full_name FROM preservatives WHERE preservatives.id=syntiriseis.syntiritis_id) AS presername,  (SELECT full_name FROM managers WHERE managers.id=syntiriseis.manager_id) AS managername,  (SELECT full_name FROM archaeologist WHERE archaeologist.id=syntiriseis.archaeologist_id) AS archaeologistname FROM syntiriseis WHERE start_date>='".$_POST['anaf2_start_date']."' AND end_date<='".$_POST['anaf2_end_date']."'; ";
                                        $result=mysqli_query($con, $query);  
                                        if($result)
                                        while(($row=$result->fetch_assoc())!= null){


                                          if (isset($row['room_id'])){
                                            $query2 = "SELECT full_name as roomname FROM room WHERE museam_id=".$row['museam_id']." AND id=".$row['room_id']." ;";
                                            $result2=mysqli_query($con, $query2);
                                            $row2=$result2->fetch_assoc();
                                            }  
                                                  
                                        ?>
                                        <tr class="">
                                        <td><?=$row['kwdikos']?></td>
                                        <td><?=$row['budget']?></td>
                                        <td><?=$row['start_date']?></td>
                                        <td><?=$row['end_date']?></td>
                                        <td><?=$row['presername']?></td>
                                        <td><?=$row['managername']?></td>
                                        <td><?=$row['archaeologistname']?></td>
                                        <td><?=$row2['roomname']?></td>
                                        </tr>       
                                        <?php
                                        }
                                        }
                                        ?>
                                        <div id="result"></div>
                                    </tbody>
                                </table>
                            </div>  
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

     <section>
        <div class="container">
            <div class="row">
                <div class="col-lg-12 text-center">
                    <p class="footer">Copyright &copy; Dream Designs 2015</p>
                </div>
            </div>
        </div>
    </section>

    </div>
    <!-- /.container -->
    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Plugin JavaScript -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    <script src="js/classie.js"></script>
    <script src="js/cbpAnimatedHeader.js"></script>

    <!-- Contact Form JavaScript -->
    <script src="js/jqBootstrapValidation.js"></script>
    <script src="js/contact_me.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="js/freelancer.js"></script>

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>


     <!-- jQuery -->
    <script src="js/jquery.min.js"></script>


    <!-- Metis Menu Plugin JavaScript -->
    <script src="js/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
   <script src="js/jquery.dataTables.min.js"></script>
   <script src="js/dataTables.bootstrap.min.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
        $('#dataTables-example23').DataTable({
                responsive: true
        });
    });
    </script>

</body>

</html>
