<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="fr">
<head>
    <title>iLinkWorld</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="<?php echo base_url('dist/images/logo.ico')?>"/>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link href="<?php echo base_url('dist/css/main_dash.css') ?>" rel="stylesheet" id="css">
    <link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
    <script src="<?php echo base_url('dist/js/paging.js') ?>"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url('dist/fonts/font-awesome-4.7.0/css/font-awesome.min.css')?>">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url('dist/css/util.css')?>">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url('dist/css/main.css')?>">
    <!------ Include the above in your HEAD tag ---------->
</head>
<body>
    <div class="container login-container">
        <div class="row">
            <div style="text-align: center" class="col-md-6 login-form-1">
                    <img width="300" height="85" class="col-xs-12"  src="<?php echo base_url('dist/images/logo_2.png')?>" alt="IMG">
                    <h3 style="height:100; text-align:center;" id="challenge">Challenge</h3>
                <p style=" text-align:center; color: white"><span style="font-size:40px;"><?php echo $this->session->userdata('user'); ?></span><span style="font-size:10px;"></span><?php echo ' /'.$this->session->userdata('pays'); ?></span></p>
                <p style="text-align:center; color: white"><span style="font-size:90px;"><?php echo $total ?></span><span style="font-size:10px;"></span>personne<?= $total > 1 ? 's' : ''?></span></p>
                <h3 id="add-code" style="text-align:center;">Ajouter un code</h3>
                <form class="validate-form"  action="<?php echo base_url('index.php/Users/add_member') ?>" method="post">
                    <div class="wrap-input100 validate-input" data-validate = "Votre code membre est requis">
                        <input type="text" name="code" class="input100" required placeholder="Code de validation" value="" />
						<span class="focus-input100"></span>
						<span class="symbol-input100">
							<i class="fa fa-user" aria-hidden="true"></i>
						</span>
                    </div>
                    <div class="container-login100-form-btn">
						<button class="login100-form-btn">Valider</button>
                    </div>
                </form>
            </div>
            <div class="col-md-6 login-form-2 parent">
                <div style="text-align: center;" class="center">
                    <?php
                        if($membres!=false){
                            ?>
                                <table style="background-color: white;" id="tab" class="table table-bordered table-sm" cellspacing="0" width="100%">
                                    <thead style="text-align:center;">
                                        <tr>
                                            <th class="th-sm">Nom</th>
                                            <th class="th-sm">Code</th>
                                        </tr>
                                    </thead>
                                    <tbody style="text-align:center;">
                                        <?php foreach($membres->result() as $row) {
                                            echo "<tr><td>".$row->lastname."</td>";
                                            echo "<td>".$row->validation_code."</td></tr>";
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            <?php
                        }else{ ?>
                             <h5 style="color: white">Aucun membre</h5>
                       <?php }
                    ?>
                        <button class="btnPage2 btnSubmit" style="font-family: Montserrat-Bold; text-transform: uppercase;width: 200px;height: 50px; border-radius: 25px;" onclick="location.href = '<?php echo base_url('index.php/Users/logout') ?>';">Déconnexion</button>
                </div>
            </div>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="info" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-show="true" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Information</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <div class="modal-body">
            <p id="message"><?php echo $message; ?></p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
        </div>
        </div>
    </div>
    </div>
</body>
<script>
    $(document).ready(function () {

		if(<?= isset($message) ?>){
			$('#info').modal('show');
			// alert($('#message').text());
		}

        $('#tab').paging(
            {
                limit: 5,
                rowDisplayStyle: 'block',
                activePage: 0,
                rows: []
            }
        );
});
</script>
</html>
