 <?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>";
        $man_msg ="";
        
        include_once("/includes/errorcheck.php");


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

            if(!preg_match($string_exp2,$_POST['man_name']) || strlen($_POST['man_name'])<3)  
                $man_msg .= 'Το Ονοματεπώνυμο δεν είναι έγκυρο ή ειναι κάτω των τριών χαρακτήρων.<br/>';

            if(!preg_match($strin_num_exp,$_POST['man_adr']) || strlen($_POST['man_adr'])<2)
                $man_msg .= 'Η Διεύθυνση δεν είναι έγκυρη ή ειναι κάτω των δύο χαρακτήρων.<br/>';

            if(strlen($_POST['man_phon']) < 4)
                $man_msg .= 'Το Τηλέφωνο που πληκτρολογήσατε δεν είναι έγκυρο.<br/>';

            if(strlen($_POST['man_sal']) < 2)
                $man_msg .= 'Ο Μισθός που πληκτρολογήσατε δεν είναι έγκυρος.<br/>';

            if(!preg_match($strin_num_exp,$_POST['man_ident']) || strlen($_POST['man_ident'])<4)
                $man_msg .= 'Ο Αριθμός ταυτότητας δεν είναι έγκυρος ή ειναι κάτω των τεσσάρων χαρακτήρων.<br/>';

            if(!preg_match($string_exp2,$_POST['man_semin']) || strlen($_POST['man_semin'])<3)  
                $man_msg .= 'Ο Τίτλος σεμιναρίου δεν είναι έγκυρος ή ειναι κάτω των τριών χαρακτήρων.<br/>';

            if (!strlen($man_msg) and isset($_SESSION['type']) and ($_SESSION['type']=='managers_up')){

                $result = $con->query("UPDATE managers SET full_name='".$_POST['man_name']."',address='".$_POST['man_adr']."',phone='".$_POST['man_phon']."',salary='".$_POST['man_sal']."',ident_card='".$_POST['man_ident']."',seminar='".$_POST['man_semin']."' WHERE id=".$_SESSION['id'].";");
                $man_msg .= 'Η Εγγραφή ενημερώθηκε επιτυχώς στην βάση.<br/>';
                if(isset($_SESSION))
                session_destroy();
                header("Refresh:1;url=http://127.0.0.1/museam/dioikitikoi.php");
            }

             if (!strlen($man_msg) and !isset($_SESSION['type'])){
            $query = "INSERT INTO managers (full_name,address,phone,salary,ident_card,seminar) VALUES ('".$_POST['man_name']."','".$_POST['man_adr']."','".$_POST['man_phon']."','".($_POST['man_sal'])."','".$_POST['man_ident']."','".$_POST['man_semin']."')";
                $result=mysqli_query($con,$query);
                $man_msg .= 'Η Εγγραφή προστέθηκε επιτυχώς στην βάση.<br/>';
                  header("Refresh:1;url=http://127.0.0.1/museam/dioikitikoi.php#dioikitikous");
            }
         header("Refresh:4;url=http://127.0.0.1/museam/dioikitikoi.php#dioikitikous");
    }

    ?>

<!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/ipaliloi.png">
                        </li>
                    </li>
                    <li class="page-scroll">
                       <a href="arxaiologoi.php"> <i class="fa fa-star-half"> </i></i>ΑΡΧΑΙΟΛΟΓΟΙ</a>
                    </li>
                    <li class="page-scroll">
                         <a href="dioikitikoi.php"><i class="fa fa-star-half"> </i>ΔΙΟΙΚΗΤΙΚΟΙ</a>
                    </li>
                    <li class="page-scroll">
                        <a href="texnikoi.php"><i class="fa fa-star-half"> </i>ΤΕΧΝΙΚΟΙ|ΕΠΙΣΚΕΥΑΣΤΕΣ</a>
                    </li>
                    <li class="page-scroll">
                        <a href="syntirites.php"><i class="fa fa-star-half"> </i>ΣΥΝΤΗΡΗΤΕΣ</a>
                    </li>
                    <li class="page-scroll">
                        <a href="fylakes.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="dioikitikous">
        <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"> <?=$man_msg?> </p>
                </div>
            </div>
                
            <div class="row">       
                <div class="box">
                    <div class="col-md-6">  

                        <table class="main_table">
                            <tr>

                            <td>
                            <figure class="cap-left">
                                        <img class="img_inside_box" src="images/images_inside_box/ypalliloi/dioikitikoi/dioikitikoi.jpg" alt="">
                                        <figcaption>Αγγελή Αννα | Διοικητικός.</figcaption>
                                    </figure>
                            </td>
                            <td rowspan="2">

                            <form method="post"  action="">
                                    <div class="main_div1">

                                       <label>Ονοματεπώνυμο:</label>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"> <i class="fa fa-user"> </i> </span>
                                            <input  name="man_name" value="<?=((isset($_SESSION['full_name']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['full_name'] : '')?>" type="text" class="form-control" placeholder="Δώστε ένα ονοματεπώνυμο.">
                                        </div>

                                         <label>Διεύθυνση:</label>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"> <i class="fa fa-location-arrow"> </i> </span>
                                            <input name="man_adr" value="<?=((isset($_SESSION['address']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['address'] : '')?>" type="text" class="form-control" placeholder="Δώστε μία διεύθυνση.">
                                        </div>

                                         <label>Τηλέφωνο:</label>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"><i class="fa fa-phone"> </i></span>
                                            <input name="man_phon" value="<?=((isset($_SESSION['phone']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['phone'] : '')?>" type="text" class="form-control" placeholder="Δώστε ένα τηλέφωνο.">
                                        </div>

                                         <label>Μισθός:</label>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"><i class="fa fa-euro"> </i></span>
                                            <input name="man_sal" value="<?=((isset($_SESSION['salary']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['salary'] : '')?>"  type="text" class="form-control" placeholder="Δώστε ένα μισθό.">
                                        </div>

                                        <label>Αριθμό Ταυτότητας:</label>
                                        <div class="form-group input-group">
                                            <span class="input-group-addon"> <i class="fa fa-newspaper-o"> </i> </span>
                                            <input name="man_ident" value="<?=((isset($_SESSION['ident_card']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['ident_card'] : '')?>"  type="text" class="form-control" placeholder="Δώστε ένα αριθμό ταυτότητας.">
                                        </div>

                                    </div>
                            </td>
                            <td rowspan="2">
                               <div class="main_div1">

                                    <label>Σεμινάρια Διοίκησης:</label>
                                    <div class="form-group input-group">
                                        <span class="input-group-addon"><i class="fa fa-file-pdf-o"> </i></span>
                                        <input name="man_semin" value="<?=((isset($_SESSION['seminar']) and ($_SESSION['type']=='managers_up')) ? $_SESSION['seminar'] : '')?>"  type="text" class="form-control" placeholder="Δώστε ένα σεμινάριο διοίκησης.">
                                    </div>

                                    <label>Για καταχώρηση πατήστε εδώ:</label>
                                    <div class="form-group input-group">
                                        <input type="hidden" name="save" value="man">
                                        <input type="submit" class="btn btn-success" onclick="this.form.submit();"></submit>
                                    </div>
                                     <div class="form-group input-group">
                                        <?=('<a href="" class="btn btn-warning" onclick="close_data(\'null\', \''.'0'.'\')">'.'<i class="fa fa-eraser">'.'</i>'.'</a>') ?>             
                                    </div>
                                </div>
                            </td>
                            </form>

                            </tr>
                            <tr>
                                <td>
                                    <div id="info_box">           
                                        <p id="info_p"> <strong> <i class="fa fa-user"> </i> Ονοματεπώνυμο: </strong> Αγγελή Αννα</p>
                                        <p id="info_p"> <strong> <i class="fa fa-location-arrow"> </i> Διεύθυνση: </strong> Καποδιστρίου 16 </p>
                                        <p id="info_p"> <strong> <i class="fa fa-phone"> </i> Τηλέφωνο: </strong> 2810876404 </p>
                                    </div> 
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <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="box"> 
                    <div id="wrapper">
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>Όνομα</th>
                                            <th>Διεύθυνση</th>
                                            <th>Τηλέφωνο</th>
                                            <th>Μισθός</th>
                                            <th>Ταυτότητα</th>
                                            <th>Σεμινάριο</th>
                                            <th>Del/Edit</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $query = "SELECT * FROM managers WHERE 1;";
                                        $result=mysqli_query($con, $query);  
                                        if($result)
                                        while(($row=$result->fetch_assoc())!= null){  
                                        ?>
                                        <tr class="">
                                        <td><?=$row['full_name']?></td>
                                        <td><?=$row['address']?></td>
                                        <td><?=$row['phone']?></td>
                                        <td><?=$row['salary']?></td>
                                        <td><?=$row['ident_card']?></td>
                                        <td><?=$row['seminar']?></td>
                                        <td>
                                        <?=('<button class="btn btn-danger btn-xs" onclick="delete_from(\'managers\', \''.$row['id'].'\')">'.'<i class="fa fa-trash-o">'.'</i>'.'</button>') ?>
                                        <?=('<a href="#dioikitikous" class="btn btn-primary btn-xs" onclick="bring_data(\'managers\', \''.$row['id'].'\')">'.'<i class="fa fa-pencil">'.'</i>'.'</button>') ?>             
                                        </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-example').DataTable({
                responsive: true
        });
    });
    </script>

</body>

</html>
