<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>iLink | Hyperviseur</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="<?php echo base_url('bower_components/bootstrap/dist/css/bootstrap.min.css') ?>">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo base_url('bower_components/font-awesome/css/font-awesome.min.css') ?>">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo base_url('bower_components/Ionicons/css/ionicons.min.css') ?>">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo base_url('dist/css/AdminLTE.css') ?>">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<?php echo base_url('dist/css/skins/_all-skins.min.css') ?>">
    <link rel="shortcut icon" href="<?php echo base_url('favicon.ico') ?>" type="image/x-icon">
    <link rel="icon" href="<?php echo base_url('favicon.ico') ?>" type="image/x-icon">



    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style media="screen">
        .img-dash {
            height: 50px !important;
            float: left !important;
            padding: 1% !important;
        }

        .table_modified {
            font-size: 11px !important;
        }

    </style>
</head>

<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <a href="#" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini"><b>iLink</b></span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg">
        <img class="img img-responsive img-dash" src="<?php echo base_url('images/logo.png') ?>">
        <b>iLink</b> World
      </span>

        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">

                    <!-- User Account: style can be found in dropdown.less -->
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <?php echo $this->lang->line('Bienvenue'); ?>  <span class="hidden-xs"><b><?php echo $firstname.' '.$lastname;?></b></span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- User image -->
                            <li class="user-header">

                                <p>
                                    <?php echo $network.' - '.$this->session->userdata('member_code');?>
                                    <small><?php echo $email;?></small>
                                </p>
                            </li>

                            <li class="user-body">
                                <div class="row">
                                    <div class="col-xs-6 text-center">
                                        <?php echo $this->session->userdata('current_pays');?>
                                    </div>
                                    <div class="col-xs-6 text-center">
                                        <?php echo $this->session->userdata('phone');?>
                                    </div>
                                </div>
                                <!-- /.row -->
                            </li>
                            <li class="user-footer">

                                <div class="pull-right">
                                    <a href="<?php echo base_url('index.php/Users/logout') ?>" class="btn btn-default btn-flat"><?php echo $this->lang->line('Déconnexion'); ?></a>
                                </div>
                            </li>
                        </ul>
                    </li>

                </ul>
            </div>
        </nav>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu" data-widget="tree">

                <li class="<?php if($active=="dash"){echo "active ";}  ?>">


                    <a href="<?php echo base_url('index.php/Hyperviseur_dash') ?>">
                        <i class="fa fa-dashboard"></i> <span><?php echo $this->lang->line('Tableau de bord'); ?></span>
                    </a>
                </li>

                <li class="<?php if($active=="geolocated"){echo "active ";}  ?>">
                    <a href="#" data-toggle="modal" data-target="#modal-default">
                        <i class="fa fa-users"></i> <span><?php echo $this->lang->line('Utilisateurs géolocalisés'); ?></span>
                    </a>

                </li>
                <li class="<?php if($active=="super"){echo "active ";}  ?>">
                    <a href="<?php echo base_url('index.php/Hyperviseur_dash/getAllSupervisor') ?>">
                        <i class="fa fa-users"></i> <span><?php echo $this->lang->line('Superviseur'); ?></span>
                    </a>

                </li>
                <li class="<?php if($active=="demandes"){echo "active ";}  ?>">
                    <a href="#" data-toggle="modal" data-target="#modal-default2">
                        <i class="fa fa-users"></i> <span><?php echo $this->lang->line('Demandes de crédits'); ?></span>
                    </a>

                </li>
                <li class="<?php  if($active=="demandesAd"){echo "active ";}  ?>">
                        <a href="<?php  echo base_url('index.php/Hyperviseur_dash/getDemandesAd') ?>">
                            <i class="fa fa-users"></i> <span><?php echo $this->lang->line('Demandes adhésion'); ?></span>
                        </a>
                </li>
                <?php if($hasWallet){
                    ?>
                    <li class="<?php if($active=="wallet"){echo "active";}  ?>">
                        <a href="<?php  echo base_url('index.php/Hyperviseur_dash/wallet') ?>">
                            <i class="glyphicon glyphicon-credit-card"></i> <span>Wallet<?php //echo $this->lang->line('Game'); ?></span>
                        </a>
                    </li>
					<li class="<?php if($active=="wallet_password"){echo "active";}  ?>">
						<a href="<?php echo base_url('index.php/Hyperviseur_dash/walletPassword') ?>">
							<i class="glyphicon glyphicon-lock"></i> <span><?php echo $this->lang->line('menu_wallet_password'); ?></span>
						</a>
					</li>
					<?php if($hasWallet->first_row()->type == 'ilink'){ ?>
						<li class="<?php if($active=="calculator"){echo "active";}  ?>">
							<a href="<?php echo base_url('index.php/Hyperviseur_dash/calculator') ?>">
								<i class="glyphicon glyphicon-adjust"></i> <span><?php echo $this->lang->line('calculator'); ?></span>
							</a>
						</li>
					<?php }?>
                <?php } ?>
            </ul>

        </section>
        <!-- /.sidebar -->
    </aside>

    <div class="modal fade" id="modal-default">
        <div class="modal-dialog">
            <div class="modal-content">
                <form action="<?php echo base_url('index.php/Hyperviseur_dash/getAllUser_g')?>" method="post">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title"><?php echo $this->lang->line('Sélectionnez la ville'); ?></h4>
                    </div>
                    <div class="modal-body">

                            <div class="form-group">

                                <?php
                                $result=$villes;

                                $numrows=$result->num_rows();

                                if ($numrows > 0) { ?>
                                    <select class="form-control input-lg" name="ville" required>
                                    <?php foreach($result->result() as $row) {

                                        echo "<option>".$row->ville."</option>";
                                    } ?>
                                    </select>
                                <?php }else{
                                    echo "Aucun utilisateur géolocalisé";
                                }
                                ?>

                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
                        <button type="submit" class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="modal fade" id="modal-default2">
        <div class="modal-dialog">
			<div class="modal-content">
				<form action="#" method="post" id="getDemandes">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title"><?php echo $this->lang->line('Utilisateurs_géolocalisés'); ?></h4>
					</div>
					<div class="modal-body">

						<div class="form-group">

							<?php
							$result=$superviseurs;;
							if($result){
								$numrows=$result->num_rows();

								if ($numrows > 0) { ?>
									<label for="selected-super"><?php echo $this->lang->line('Superviseur'); ?></label>
									<select class="form-control input-lg" name="geo_user" id="selected-super" required>
										<?php foreach($result->result() as $row) {

											echo "<option value='".$row->member_code."'>".$row->lastname." - ".$row->member_code."</option>";
										} ?>
									</select>
								<?php }else{
									echo $this->lang->line('no_supervisor');
								}
								?>
							<?php } else {
								echo $this->lang->line('no_supervisor');
							} ?>


						</div>
						<div class="info-box-content">
							<span class="info-box-text">Période </span>
							<span class="info-box-number">
                                <div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
                                    <i class="fa fa-calendar"></i>&nbsp;
                                    <span></span> <i class="fa fa-caret-down"></i>
                                </div>
                            </span>
						</div>

					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
						<?php if($result){ ?>
							<button type="button" id="send-getDemandes" class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
						<?php } ?>
					</div>
				</form>
			</div>
        </div>
    </div>
    <!-- /.modal -->

	<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
	<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
	<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
	<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />


	<script type="text/javascript">
		var startDate;
		var endDate;

		$(function() {

			var start = moment().subtract(29, 'days');
			var end = moment();

			startDate = start;
			endDate = end;

			function cb(start, end) {
				$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
				startDate = start;
				endDate = end;
			}

			$('#reportrange').daterangepicker({
				startDate: start,
				endDate: end,
				ranges: {
					'Today': [moment(), moment()],
					'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
					'Last 7 Days': [moment().subtract(6, 'days'), moment()],
					'Last 30 Days': [moment().subtract(29, 'days'), moment()],
					'This Month': [moment().startOf('month'), moment().endOf('month')],
					'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
				}
			}, cb);

			cb(start, end);

		});

		$('#send-getDemandes').click(function(){
			var debut = startDate.format('YYYY-MM-DD');
			var fin = endDate.format('YYYY-MM-DD');
			var user_geo = $('#selected-super').find(":selected").val();
			window.location.replace("<?php echo base_url('index.php/Hyperviseur_dash/getDemandes')?>"+"?d="+debut+"&f="+fin+"&u="+user_geo);
		});
	</script>
