<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?=$this->section('content');  ?>
<div class="row">
    <div class="col-md-12">

        <div class="card card-info">
            <div class="card-header">
                <h3 class="card-title"><?=lang('Users.userList') ?></h3>
				<?=anchor(route_to('newUser'), lang('Basic.global.addNew').' '.lang('Users.user'), ['class'=>'btn btn-primary float-end']); ?>
           </div><!--//.card-header -->
            <div class="card-body">
				<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>

					<table id="tableOfUsers" class="table table-striped table-hover using-data-table" style="width: 100%;">
						<thead>
							<tr>
								<?php /*<th><?= lang('Users.idUser') ?></th> */?>
								<th><?= lang('Users.firstName') ?></th>
								<th><?= lang('Users.lastName') ?></th>
								<th><?= lang('Users.group') ?></th>
								<th><?= lang('Users.mobile') ?></th>
								<th><?= lang('Users.email') ?></th>
								<th><?= lang('Users.address') ?></th>
								<th><?= lang('Users.city') ?></th>
								<th><?= lang('Users.state') ?></th>
								<th><?= lang('Users.country') ?></th>
								<th><?= lang('Users.zipCode') ?></th>
								<th><?= lang('Users.lastIp') ?></th>
								<th><?= lang('Users.lastAccess') ?></th>
								<th><?= lang('Users.picture') ?></th>
								<th><?= lang('Users.language') ?></th>
								<th><?= lang('Users.blocked') ?></th>
								<th><?= lang('Users.emailConfirmed') ?></th>
								<?php /* 
								<th><?= lang('Users.token') ?></th>
								<th><?= lang('Users.status') ?></th>
								<th><?= lang('Users.createdAt') ?></th>
								<th><?= lang('Users.updatedAt') ?></th>
								*/?>
								<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
							</tr>
						</thead>
						<tbody>
						<?php foreach ($userList as $item ) : ?>
							<tr>
								<?php /*
								<td class="align-middle text-center">
									<?=$item->id_user ?>
								</td>
								*/?>
								<td class="align-middle">
									<?= empty($item->first_name) || strlen($item->first_name) < 51 ? esc($item->first_name) : character_limiter(esc($item->first_name), 50)   ?>
								</td>
								<td class="align-middle">
									<?= empty($item->last_name) || strlen($item->last_name) < 51 ? esc($item->last_name) : character_limiter(esc($item->last_name), 50)   ?>
								</td>
								
								<td class="align-middle">
									<?= empty($user_model->getGroupsTitles($item->token)) || strlen($user_model->getGroupsTitles($item->token)) < 51 ? esc($user_model->getGroupsTitles($item->token)) : character_limiter($user_model->getGroupsTitles($item->token), 50)   ?>
								</td>

								<td class="align-middle">
									<?= empty($item->mobile) || strlen($item->mobile) < 51 ? esc($item->mobile) : character_limiter(esc($item->mobile), 50)   ?>
								</td>
								<td class="align-middle">
									<?= esc($item->email) ?>
								</td>

								<td class="align-middle">
									<?= empty($item->address) || strlen($item->address) < 51 ? esc($item->address) : character_limiter(esc($item->address), 50)   ?>
								</td>
								<td class="align-middle">
									<?= empty($item->city) || strlen($item->city) < 51 ? esc($item->city) : character_limiter(esc($item->city), 50)   ?>
								</td>
								<td class="align-middle">
									<?= empty($item->state) || strlen($item->state) < 51 ? esc($item->state) : character_limiter(esc($item->state), 50)   ?>
								</td>
								<td class="align-middle">
									<?= esc($item->country) ?>
								</td>
								<td class="align-middle">
									<?= empty($item->zip_code) || strlen($item->zip_code) < 51 ? esc($item->zip_code) : character_limiter(esc($item->zip_code), 50)   ?>
								</td>
								<td class="align-middle">
									<?= empty($item->last_ip) || strlen($item->last_ip) < 51 ? esc($item->last_ip) : character_limiter(esc($item->last_ip), 50)   ?>
								</td>
								<td class="align-middle text-nowrap">
									<?= empty($item->last_access) ? '' : date('d/m/Y H:m:s', strtotime($item->last_access))  ?>
								</td>
								<td class="align-middle">
									<?= empty($item->picture) || strlen($item->picture) < 51 ? esc($item->picture) : character_limiter(esc($item->picture), 50)   ?>
								</td>
								<td class="align-middle">
									<?= esc($item->language) ?>
								</td>
								
								<td class="align-middle text-nowrap">
									<?= empty($item->blocked) ? '' : date('d/m/Y H:m:s', strtotime($item->blocked))  ?>
								</td>
								<td class="align-middle">
									<?= esc($item->email_confirmed) ?>
								</td>
								<?php /*
								<td class="align-middle">
									<?= esc($item->token) ?>
								</td>
								<td class="align-middle text-center text-green">

								<?php if ( $item->status ) { ?>

									<i class="text-success bi bi-check-lg"></i>

								<?php  }  ?>

								</td>
								<td class="align-middle text-nowrap">
									<?= empty($item->created_at) ? '' : date('d/m/Y H:m:s', strtotime($item->created_at))  ?>
								</td>
								<td class="align-middle text-nowrap">
									<?= empty($item->updated_at) ? '' : date('d/m/Y H:m:s', strtotime($item->updated_at))  ?>
								</td>
								*/ ?>
								<td class="align-middle text-center text-nowrap">
									<?=anchor(route_to('editUser', $item->id_user), "<i class='ti ti-pencil ti-sm mx-2'></i>", ['class'=>'text-body',  'data-id'=>$item->id_user,]); ?>
									<?=anchor('#confirm2delete', "<i class='ti ti-trash ti-sm mx-2'></i>", ['class'=>'text-body', 'data-href'=>route_to('deleteUser', $item->id_user), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
								</td>
							</tr>

						<?php endforeach; ?>
						</tbody>
					</table>
            </div><!--//.card-body -->
            <div class="card-footer">
				
            </div><!--//.card-footer -->
        </div><!--//.card -->
    </div><!--//.col -->
</div><!--//.row -->

<?=$this->endSection() ?>