<link rel="stylesheet"
	  href="<?= base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
<link rel="stylesheet"
	  href="<?= base_url('<link rel="stylesheet" 
	href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap.min.css">') ?>">
<link rel="stylesheet"
	  href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet"
	  href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
	<style>
		.name-link {
			color: white;
			text-decoration: none;
		}

		.form-style {
			display: block;
			width: 50%;
			height: 34px;
			padding: 6px 12px;
			font-size: 14px;
			line-height: 1.42857143;
			color: #555;
			background-color: #fff;
			background-image: none;
			border: 1px solid #ccc;
		}

		.form-group-style {
			margin-bottom: 15px;
			width: 50%;
		}

		.img-style {
			width: 20%;
			margin: 5%;
		}

		.conteneur-img {
			text-align: center;
		}

		.label-radio {
			font-style: bold;
			margin-right: 30px;
			color: #444;
			font-weight: 700;
		}
		img {
			max-width: 100%;
			max-height: 100%;
		}

		.portrait {
			height: 80px;
			width: 30px;
		}

		.landscape {
			height: 30px;
			width: 80px;
		}

		.square {
			height: 75px;
			width: 75px;
		}
	</style>
	<section class="content-header">

		<h1>
			<?= $this->lang->line('Rechercher un utilisateur'); ?>
		</h1>
		<?php
		$site_url = base_url();

		if ($alert == "ok") {

			if (!$success == "ok") {
				?>
				<div class='alert alert-danger alert-dismissible col-xs-6'>
					<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
					<h4><i class='icon fa fa-ban'></i> Erreur!</h4>
					<?= $message; ?>
				</div>

				<?php
			} else {
				?>
				<div class="alert alert-success alert-dismissible col-xs-6">
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<h4><i class="icon fa fa-check"></i> Success!</h4>
					<?= $message; ?>
				</div>

				<?php
			}
		}
		?>
	</section>

	<section class="content">
		<div class="box box-primary">
			<div class="box-header with-border">
			</div>
			<div class="box-body">
				<?php
					if(isset($category)){
						$url = $category == 'hyper' ? 'Hyperviseur_dash/get_user' : 'Superviseur_dash/get_user';
					}else{
						$url = 'Gestion/get_user';
					}
				?>
				<form name="form_login" action="<?= base_url($url) ?>" method="post">
					<div class="row">
						<div class="col-sm-3">
							<div class="form-group">
								<label><?= $this->lang->line('phone_number')?></label>
								<div class="input-group date">
									<div class="input-group-addon">
										<i class="glyphicon glyphicon-earphone"></i>
									</div>
									<input type="text" class="form-control pull-right" id="phone" name="phone"
										   value="<?= $default_phone ?>">
								</div>
							</div>
						</div>
						<div class='col-sm-3'>
							<div class="form-group">
								<label><?= $this->lang->line('Numéro de transaction') ?></label>
								<div class="input-group date">
									<div class="input-group-addon">
										<i class="glyphicon glyphicon-usd"></i>
									</div>
									<input type="text" class="form-control pull-right" id="transac" name="transac"
										   value="<?= $default_transac ?>">
								</div>
							</div>
						</div>
						<div class='col-sm-3'>
							<div class="form-group">
								<label><?= $this->lang->line('code membre') ?></label>
								<div class="input-group date">
									<div class="input-group-addon">
										<i class="glyphicon glyphicon-user"></i>
									</div>
									<input type="text" class="form-control pull-right" id="code" name="code"
										   value="<?= $default_code ?>">
								</div>
							</div>
						</div>
						<div class='col-sm-3'>
							<div class="form-group">
								<label><?= $this->lang->line('Nom') ?></label>
								<div class="input-group date">
									<div class="input-group-addon">
										<i class="glyphicon glyphicon-user"></i>
									</div>
									<input type="text" class="form-control pull-right" id="nom" name="nom"
										   value="<?= $default_nom ?>">
								</div>
							</div>
						</div>
						<div class="col-sm-4 col-sm-offset-4">
							<input class="btn btn-primary btn-block" id='search' disabled='disabled' name='b'
								   type='submit' value='<?= $this->lang->line('Rechercher'); ?>'/>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="box box-primary">
			<div class="box-header with-border">
				<?php if ($result_search == 1) { ?>

					<h3 class="box-title"><?= $num_res.' '.$this->lang->line($num_res == 1 ? 'utilisateur trouvé' : 'users_found')  ?></h3>
					<div class="box-body">
						<div class="row">
							<?php $users = $res_users;
							if ($users) {
								$numrows = $users->num_rows();
								$num = 0;
								if ($numrows > 0) {
									foreach ($users->result() as $row) {
										$num++;
										?>

										<div class="col-md-3">
											<!-- Profile Image -->
											<div class="box box-primary">
												<div class="box-body box-profile">
													<img class="profile-user-img img-responsive img-circle"
														 src="<?= base_url('dist/img/user-g.png')?>" alt="User profile picture">

													<h3 class="profile-username text-center"><?= $row->lastname ?></h3>

													<p class="text-muted text-center"><?= $row->category ?></p>

													<ul class="list-group list-group-unbordered">
														<li class="list-group-item">
															<b><?= $this->lang->line('Reseau'); ?></b> <a
																	class="pull-right"><?= $row->network_name ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('code membre'); ?></b> <a
																	class="pull-right"><?= $row->code ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Ville'); ?></b> <a
																	class="pull-right"><?= $row->town_name ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Contact'); ?></b> <a
																	class="pull-right"><?= $row->phone ?></a>
														</li>
													</ul>

													<?php if($row->qr_code) { ?>
														<a href="<?= $row->qr_code ?>" class='btn btn-success btn-block mb3' target='_blank'>
															<b><?= $this->lang->line('display_qr_code')?> </b>
														</a>
													<?php } else { ?>
														<button class='btn btn-primary btn-block generateQRCode mb-3' data-id="<?=$row->id?>" data-type="<?=$row->type?>">
															<b> <?= $this->lang->line('generate_qr_code') ?> </b>
														</button>
													<?php } ?>
													<a href="#" class="btn btn-primary btn-block" data-toggle="modal"
													   data-target="#infos<?= $num; ?>"><b><?= $this->lang->line('Voir plus...'); ?></b></a>
												</div>
												<!-- /.box-body -->
											</div>
											<!-- /.box -->
										</div>
										<div class="modal fade" id="infos<?= $num; ?>" tabindex="-1"
											 role="dialog" aria-labelledby="infosModalLabel" aria-hidden="true">
											<div class="modal-dialog" role="document">
												<div class="modal-content">
													<div class="modal-header">
														<h3 class="modal-title"><?= $this->lang->line('Informations de l utilisateur'); ?></h3>
													</div>
													<div class="modal-body">
														<form>
															<div class="form-group">
																<label for="nom"
																	   class="col-form-label"><?= $this->lang->line('Nom'); ?></label>
																<input type="text" class="form-control"
																	   id="nom-g<?= $num; ?>" name="nom"
																	   value="<?= $row->lastname ?>">
															</div>
															<div class="form-group">
																<label for="adresse"
																	   class="col-form-label"><?= $this->lang->line('Adresse'); ?></label>
																<input class="form-control"
																	   id="adresse-g<?= $num; ?>"
																	   name="adresse-g"
																	   value="<?= $row->adresse ?>">
															</div>
															<div class="form-group">
																<label for="email"
																	   class="col-form-label"><?= $this->lang->line('Email'); ?></label>
																<input class="form-control"
																	   id="email-g<?= $num; ?>" name="email-g"
																	   value="<?= $row->email ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="m-phone"
																	   class="col-form-label"><?= $this->lang->line('Contact'); ?></label>
																<input class="form-control"
																	   id="phone-g<?= $num; ?>" name="phone-g"
																	   value="<?= $row->phone ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="m-transac"
																	   class="col-form-label"><?= $this->lang->line('Numéro de transaction'); ?></label>
																<input class="form-control"
																	   id="transac-g<?= $num; ?>"
																	   name="transac-g"
																	   value="<?= $row->transac ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="code-m"
																	   class="col-form-label"><?= $this->lang->line('code membre'); ?></label>
																<input class="form-control" disabled id="code-m"
																	   name="code-m" value="<?= $row->code ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="code-p"
																	   class="col-form-label"><?= $this->lang->line('Code parrain'); ?></label>
																<input class="form-control" disabled id="code-p"
																	   name="code-p"
																	   value="<?= $row->parrain ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="category"
																	   class="col-form-label"><?= $this->lang->line('Catégorie'); ?></label>
																<input class="form-control" disabled id="category"
																	   name="category"
																	   value="<?= $row->category ?>">
															</div>
															<div class="form-group col-sm-6">
																<label for="date-ins"
																	   class="col-form-label"><?= $this->lang->line('Date inscription'); ?></label>
																<input class="form-control" disabled id="date-ins"
																	   name="date-ins"
																	   value="<?= $row->date_created ?>">
															</div>
														</form>
													</div>
													<div class="modal-footer">
														<button type="button" class="btn btn-secondary"
																data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
														<button type="button" class="btn btn-primary valid-infos-g"
																data-num="<?= $num; ?>"
																data-idnetworkAgent="<?= $row->networkAgent_id ?>"
																data-idUser="<?= $row->userID ?>"><?= $this->lang->line('Valider'); ?></button>
													</div>
												</div>
											</div>
										</div>
										<?php
									}
								}
							}
							?>
							<?php $simple_users = $res_simple_users;
							if ($simple_users != null) {
								$numrows = $simple_users->num_rows();
								$num = 0;
								if ($numrows > 0) {
									foreach ($simple_users->result() as $row) {
										$num++;
										?>

										<div class="col-md-3">
											<!-- Profile Image -->
											<div class="box box-success">
												<div class="box-body box-profile">
													<img class="profile-user-img img-responsive img-circle"
														 src="<?= base_url('dist/img/user-s.png')?>" alt="User profile picture">

													<h3 class="profile-username text-center"><?= $row->lastname ?></h3>

													<p class="text-muted text-center"><?= $this->lang->line('Utilisateur simple'); ?></p>

													<ul class="list-group list-group-unbordered">
														<li class="list-group-item">
															<b><?= $this->lang->line('Reseau'); ?></b> <a
																	class="pull-right"><?= $row->network ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Pays'); ?></b> <a
																	class="pull-right"><?= $row->country ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Contact'); ?></b> <a
																	class="pull-right"><?= $row->phone ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Date inscription'); ?></b>
															<a class="pull-right"><?= $row->date_created ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('identified'); ?></b> <a
																	class="pull-right"><?= $row->status ? $this->lang->line('Oui') : $this->lang->line('Non') ?></a>
														</li>
													</ul>

													<?php if($row->qr_code) { ?>
														<a href="<?= $row->qr_code ?>" class='btn btn-success btn-block mb3' target='_blank'>
															<b><?= $this->lang->line('display_qr_code')?> </b>
														</a>
													<?php } else { ?>
														<button class='btn btn-primary btn-block generateQRCode mb-3' data-id="<?=$row->id?>" data-type="<?=$row->type?>">
															<b> <?= $this->lang->line('generate_qr_code') ?> </b>
														</button>
													<?php } ?>

													<a href="#" class="btn btn-success btn-block" data-toggle="modal"
													   data-target="#infos-s"><b><?= $this->lang->line('Voir plus...'); ?></b></a>
												</div>
												<!-- /.box-body -->
											</div>
											<!-- /.box -->
										</div>
										<div class="modal fade" id="infos-s" data-id="<?= $row->id_user; ?>"
											 tabindex="-1" role="dialog" aria-labelledby="infos-s-ModalLabel"
											 aria-hidden="true">
											<div class="modal-dialog modal-lg" role="document">
												<div class="modal-content">
													<div class="modal-header">
														<h3 class="modal-title"><?= $this->lang->line('Informations de l utilisateur'); ?></h3>
													</div>
													<div class="modal-body">
														<form>
															<div class="form-group">
																<label for="nom"
																	   class="col-form-label"><?= $this->lang->line('Nom'); ?></label>
																<input type="text" class="form-control" id="nom-s"
																	   name="nom" value="<?= $row->lastname ?>">
															</div>
															<div class="form-group">
																<label for="adresse"
																	   class="col-form-label"><?= $this->lang->line('Adresse'); ?></label>
																<input class="form-control" id="adresse-s"
																	   name="adresse"
																	   value="<?= $row->adresse ?>">
															</div>
															<div class="form-group">
																<label for="email"
																	   class="col-form-label"><?= $this->lang->line('Email'); ?></label>
																<input class="form-control" id="email-s" name="email"
																	   value="<?= $row->email ?>">
															</div>
															<div class="form-group">
																<label for="m-phone"
																	   class="col-form-label"><?= $this->lang->line('Contact'); ?></label>
																<input class="form-control" id="phone-s" name="m-phone"
																	   value="<?= $row->phone ?>">
															</div>

															<?php if ($row->status) {
																$user_image = $row->user_image;
																$user_image_file =  empty($user_image) ? null : @fopen($user_image ,'r');

																$document_front = $row->document_image_front;
																$document_front_file = empty($document_front) ? null :  @fopen($document_front ,'r');

																$document_back =  $row->document_image_back;
																$document_back_file = empty($document_back) ? null :  @fopen($document_back ,'r');
																?>
																<label class="text-center text-muted" style="padding: 10px"> Identification </label>
																<div class="row">
																	<div class="form-group col-sm-5">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Nom'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_firstname ?>">
																	</div>
																	<div class="form-group col-sm-5">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Prénom'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_lastname ?>">
																	</div>
																	<div class="form-group col-sm-2">
																		<label
																				class="col-form-label"><?= $this->lang->line('gender'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->gender ?>">
																	</div>
																</div>
																<div class="row">
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('birth_date'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->birth_date ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Ville'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_town ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Pays'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_country?>">
																	</div>
																</div>
																<div class="row">
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('identity_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->identity_document ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('id_identity_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_identity_document ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('expiry_date_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->expiry_date_document ?>">
																	</div>
																</div>
																<div class="row text-center">
																	<div class="col-12">
																		<label><?= $this->lang->line('user_image') ?></label>
																		<div>
																			<img src="<?= $user_image_file ? $user_image : base_url('images/broken.png') ?>"
																				 alt="user_image"/>
																		</div>
																	</div>
																</div>

																<div class="row" style="margin-top: 10px">
																	<div class="col-sm-6 text-center">
																		<label><?= $this->lang->line('document_image_front') ?></label>
																		<img src="<?= $document_front_file ? $document_front : base_url('images/broken.png') ?>"
																			 alt="document_front"/>

																	</div>
																	<div class="col-sm-6 text-center">
																		<label><?= $this->lang->line('document_image_back') ?></label>
																		<img src="<?= $document_back_file ? $document_back : base_url('images/broken.png')?>"
																			 alt="document_back"/>

																	</div>
																</div>

															<?php } ?>

														</form>
													</div>
													<div class="modal-footer">
														<button type="button" class="btn btn-secondary"
																data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
														<?php if(!isset($category)) { ?>
															<button type="button" id="valid-infos-s"
																	class="btn btn-primary"><?= $this->lang->line('Valider'); ?></button>
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<?php
									}
								}
							}
							?>
						</div>
					</div>
				<?php } elseif ($result_search == 2) { ?>
					<?php $simple_users = $res_simple_users;
					if ($simple_users != null) {
						?>
						<h3 class="box-title"><?= $simple_users->num_rows().' '.$this->lang->line($simple_users->num_rows() == 1 ? 'utilisateur trouvé' : 'users_found')  ?></h3>
						<div class="box-body">
							<div class="row">
								<?php
								$numrows = $simple_users->num_rows();
								$num = 0;
								if ($numrows > 0) {
									foreach ($simple_users->result() as $row) {
										$num++;
										?>

										<div class="col-md-3">
											<!-- Profile Image -->
											<div class="box box-success">
												<div class="box-body box-profile">
													<img class="profile-user-img img-responsive img-circle"
														 src="<?= base_url('dist/img/user-s.png')?>" alt="User profile picture">

													<h3 class="profile-username text-center"><?= $row->lastname ?></h3>

													<p class="text-muted text-center"><?= $this->lang->line('Utilisateur simple'); ?></p>

													<ul class="list-group list-group-unbordered">
														<li class="list-group-item">
															<b><?= $this->lang->line('Reseau'); ?></b> <a
																	class="pull-right"><?= $row->network ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Pays'); ?></b> <a
																	class="pull-right"><?= $row->country ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Contact'); ?></b> <a
																	class="pull-right"><?= $row->phone ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('Date inscription'); ?></b>
															<a class="pull-right"><?= $row->date_created ?></a>
														</li>
														<li class="list-group-item">
															<b><?= $this->lang->line('identified'); ?></b> <a
																	class="pull-right"><?= $row->status ? $this->lang->line('Oui') : $this->lang->line('Non') ?></a>
														</li>
													</ul>

													<?php if($row->qr_code) { ?>
														<a href="<?= $row->qr_code ?>" class='btn btn-success btn-block mb3' target='_blank'>
															<b><?= $this->lang->line('display_qr_code')?> </b>
														</a>
													<?php } else { ?>
														<button class='btn btn-primary btn-block generateQRCode mb-3' data-id="<?=$row->id?>"  data-type="<?=$row->type?>">
															<b> <?= $this->lang->line('generate_qr_code') ?> </b>
														</button>
													<?php } ?>

													<a href="#" class="btn btn-success btn-block" data-toggle="modal"
													   data-target="#infos-s"><b><?= $this->lang->line('Voir plus...'); ?></b></a>
												</div>
												<!-- /.box-body -->
											</div>
											<!-- /.box -->
										</div>
										<div class="modal fade" id="infos-s" data-id="<?= $row->id_user; ?>"
											 tabindex="-1" role="dialog" aria-labelledby="infos-s-ModalLabel"
											 aria-hidden="true">
											<div class="modal-dialog modal-lg" role="document">
												<div class="modal-content">
													<div class="modal-header">
														<h3 class="modal-title"><?= $this->lang->line('Informations de l utilisateur'); ?></h3>
													</div>
													<div class="modal-body">
														<form>
															<div class="form-group">
																<label for="nom"
																	   class="col-form-label"><?= $this->lang->line('Nom'); ?></label>
																<input type="text" class="form-control" id="nom-s"
																	   name="nom" value="<?= $row->lastname ?>">
															</div>
															<div class="form-group">
																<label for="adresse"
																	   class="col-form-label"><?= $this->lang->line('Adresse'); ?></label>
																<input class="form-control" id="adresse-s"
																	   name="adresse"
																	   value="<?= $row->adresse ?>">
															</div>
															<div class="form-group">
																<label for="email"
																	   class="col-form-label"><?= $this->lang->line('Email'); ?></label>
																<input class="form-control" id="email-s" name="email"
																	   value="<?= $row->email ?>">
															</div>
															<div class="form-group">
																<label for="m-phone"
																	   class="col-form-label"><?= $this->lang->line('Contact'); ?></label>
																<input class="form-control" id="phone-s" name="m-phone"
																	   value="<?= $row->phone ?>">
															</div>
															<?php if ($row->status) {
																	$user_image = $row->user_image;
																	$user_image_file = empty($user_image) ? null : @fopen($user_image ,'r');

																	$document_front = $row->document_image_front;
																	$document_front_file = empty($document_front) ? null :  @fopen($document_front ,'r');

																	$document_back =  $row->document_image_back;
																	$document_back_file = empty($document_back) ? null :  @fopen($document_back ,'r');
																?>
																<label class="text-center text-muted" style="padding: 10px"> Identification </label>
																<div class="row">
																	<div class="form-group col-sm-5">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Nom'); ?></label>
																		<input class="form-control" readonly

																			   value="<?= $row->id_firstname ?>">
																	</div>
																	<div class="form-group col-sm-5">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Prénom'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_lastname ?>">
																	</div>
																	<div class="form-group col-sm-2">
																		<label
																				class="col-form-label"><?= $this->lang->line('gender'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->gender ?>">
																	</div>
																</div>
																<div class="row">
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('birth_date'); ?></label>
																		<input class="form-control" readonly name="code-p"
																			   value="<?= $row->birth_date ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Ville'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_town ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('Pays'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_country?>">
																	</div>
																</div>
																<div class="row">
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('identity_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->identity_document ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('id_identity_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->id_identity_document ?>">
																	</div>
																	<div class="form-group col-sm-4">
																		<label
																			   class="col-form-label"><?= $this->lang->line('expiry_date_document'); ?></label>
																		<input class="form-control" readonly
																			   value="<?= $row->expiry_date_document ?>">
																	</div>
																</div>
																<div class="row text-center">
																	<div class="col-12">
																		<label><?= $this->lang->line('user_image') ?></label>
																		<div>
																			<img src="<?= $user_image_file ? $user_image : base_url('images/broken.png') ?>"
																				 alt="user_image"/>
																		</div>
																	</div>
																</div>

																<div class="row" style="margin-top: 10px">
																	<div class="col-sm-6 text-center">
																		<label><?= $this->lang->line('document_image_front') ?></label>
																		<img src="<?= $document_front_file ? $document_front : base_url('images/broken.png') ?>"
																				 alt="document_front"/>

																	</div>
																	<div class="col-sm-6 text-center">
																		<label><?= $this->lang->line('document_image_back') ?></label>
																		<img src="<?= $document_back_file ? $document_back : base_url('images/broken.png')?>"
																				 alt="document_back"/>

																	</div>
																</div>

															<?php } ?>

														</form>
													</div>
													<div class="modal-footer">
														<button type="button" class="btn btn-secondary"
																data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
														<?php if(!isset($category)) { ?>
															<button type="button" id="valid-infos-s"
																	class="btn btn-primary"><?= $this->lang->line('Valider'); ?></button>
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<?php
									}
								}
								?>
							</div>
						</div>

						<?php
					} else {
						?>
						<h3 class="box-title"><?= $this->lang->line('Aucun utilisateur trouvé'); ?></h3>
						<?php
					}
					?>
				<?php } elseif ($result_search == 0) { ?>
					<div class="conteneur-img">
						<img class="img-style" src="<?= base_url('dist/img/search.png')?>" alt="icon search">
					</div>
				<?php } ?>
			</div>
		</div>
	</section>
</div>

<!-- jQuery 2.2.4 -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

<!-- Bootstrap 3.3.7 -->
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<!-- DataTables -->
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
<!-- FastClick -->
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
<!-- AdminLTE App -->
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
<!-- AdminLTE for demo purposes -->
<script src="<?= base_url('dist/js/demo.js') ?>"></script>

<script src="<?= base_url('dist/js/demo.js') ?>"></script>

<script src="<?= base_url('bower_components/moment/min/moment.min.js') ?>"></script>
<script src="<?= base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?= base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>

<script type="text/javascript">
	//Date picker
	//$('#date-debut').datepicker({autoclose: true,format: 'yyyy-mm-dd'});
	$("#date-debut").datetimepicker({
		format: 'YYYY-MM-DD HH:mm:ss',
		locale: moment.locale('fr')
	});
	$('#date-fin').datetimepicker({
		format: 'YYYY-MM-DD HH:mm:ss'
	});

</script>

<script>
	toastr.options.closeButton = true;
	toastr.options.closeMethod = 'fadeOut';
	toastr.options.closeDuration = 5000;
	toastr.options.closeEasing = 'swing';

	$('#phone').on('input', function () {
		if ($(this).val() !== '') {
			$('#search').prop('disabled', false);
		} else {
			if ($('#transac').val() == '' && $('#code').val() == '' && $('#nom').val() == '') {
				$('#search').prop('disabled', true);
			}
		}
	});
	$('#nom').on('input', function () {
		if ($(this).val() !== '') {
			$('#search').prop('disabled', false);
		} else {
			if ($('#transac').val() == '' && $('#code').val() == '' && $('#phone').val() == '') {
				$('#search').prop('disabled', true);
			}
		}
	});
	$('#transac').on('input', function () {
		if ($(this).val() !== '') {
			$('#search').prop('disabled', false);
		} else {
			if ($('#phone').val() == '' && $('#code').val() == '' && $('#nom').val() == '') {
				$('#search').prop('disabled', true);
			}
		}
	});
	$('#code').on('input', function () {
		if ($(this).val() !== '') {
			$('#search').prop('disabled', false);
		} else {
			if ($('#transac').val() == '' && $('#phone').val() == '' && $('#nom').val() == '') {
				$('#search').prop('disabled', true);
			}
		}
	});
	$('#valid-infos-s').click(function () {

		var user_id = $('#infos-s').data('id');
		var nom = $('#nom-s').val();
		var adresse = $('#adresse-s').val();
		var contact = $('#phone-s').val();
		var email = $('#email-s').val();


		$.ajax({
			url: '<?= base_url('Gestion/update_info_user')?>',
			type: 'POST',
			dataType: 'json',
			data: {"user_id": user_id, "nom": nom, "adresse": adresse, "contact": contact, "email": email},
			success: function (data, statut) {
				if (data == '200') {
					alert("Les informations ont été mises à jour.") ? "" : location.reload(true);
				} else {
					alert("Une erreur s'est produite.");
				}
			},

			error: function (resultat, statut, erreur) {
				console.log(resultat + " " + erreur);
			}
		});

	});
	$('.valid-infos-g').click(function () {

		var num = $(this).attr('data-num');
		var user_id = $(this).attr('data-idUser');
		var net_ag_id = $(this).attr('data-idnetworkAgent');
		var nom = $('#nom-g' + num).val();
		var adresse = $('#adresse-g' + num).val();
		var email = $('#email-g' + num).val();
		var contact = $('#phone-g' + num).val();
		var transac = $('#transac-g' + num).val();

		$.ajax({
			url: '<?= base_url('Gestion/update_info_geolocated')?>',
			type: 'POST',
			dataType: 'json',
			data: {
				"user_id": user_id,
				"id_netAg": net_ag_id,
				"nom": nom,
				"adresse": adresse,
				"contact": contact,
				"transac": transac,
				"email": email
			},
			success: function (data, statut) {
				if (data == '200') {
					alert("Les informations ont été mises à jour.") ? "" : location.reload(true);
				} else if (data == '400') {
					toastr.error("<?= $this->lang->line('phone_already_exists')?>", "<?= $this->lang->line('request_error')?>");
				}else{
					alert("Une erreur s'est produite.");
				}
			},

			error: function (resultat, statut, erreur) {
				console.log(resultat + " " + erreur);
				toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
			}
		});

	});

	$(document).on("click", ".generateQRCode", function () {
		let id_agent = $(this).data('id');
		let type = $(this).data('type');
		$.ajax({
			url: '<?= base_url('index.php/Hyperviseur_dash/generateQRCode')?>',
			type: 'POST',
			data: {'user_id': id_agent , 'type' : type},
			dataType: 'json',
			success: function (data) {
				if(data.status === 200){
					Swal.fire({
						icon: 'success',
						title: "<?= $this->lang->line('qr_code_generated')?>",
						text: "<?= $this->lang->line('informations_updated')?>",
						timer: 3000
					}).then(() => {
						location.reload();
					});
				}else{
					toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
				}
			},
			error: function (error) {
				toastr.error("<?= $this->lang->line('error_message')?>", "<?= $this->lang->line('request_error')?>");
			}
		});
	});

</script>
