This commit is contained in:
Josh North 2021-06-23 10:06:26 -04:00
parent c7c5ae17fa
commit 3ae19a8ea5
6 changed files with 109 additions and 92 deletions

View File

@ -148,6 +148,16 @@ class SiteInfo {
return $rows;
}
public function countSiteUsers ($siteid) {
$query = "
SELECT *
FROM " . Registry::DB_PRFX . "users_sites WHERE " . Registry::DB_PRFX . "users_sites.sites_id LIKE \"$siteid\"
";
$database = new \App\LobbySIO\Database\Connect();
$rows = count($database->getQuery($query));
return $rows;
}
public function addSite ($sitename, $timezone, $region) {
$query = "
INSERT INTO " . Registry::DB_PRFX . "sites (" . Registry::DB_PRFX . "sites.name, " . Registry::DB_PRFX . "sites.timezone, " . Registry::DB_PRFX . "sites.region)

View File

@ -122,6 +122,8 @@ STR_COMMON_TIMEZONE = 'Zeitzone'
STR_COMMON_TOUR = 'Tour'
STR_COMMON_VSIGNATURE = 'Unterschrift des Besuchers'
STR_COMMON_YES = 'Ja'
STR_COMMON_USERCOUNT = 'Benutzeranzahl'
STR_COMMON_NEVERLOGGEDIN = 'Nie eingeloggt'
STR_COVID_ACKNOWLEDGEMENT = 'Das neuartige Coronavirus COVID-19 wurde von der Weltgesundheitsorganisation zur weltweiten Pandemie erklärt. Mit der Anmeldung bestätige ich, dass soziale Distanzierung praktiziert und Gesichtsbedeckungen zu jeder Zeit getragen werden müssen. Dieses Unternehmen kann nicht garantieren, dass seine Mitarbeiter, Lieferanten, Kunden oder andere teilnehmende Personen nicht mit COVID-19 infiziert werden.'
STR_COVID_Q1-DESC = 'Fieber, Schüttelfrost, Husten, Kurzatmigkeit, Müdigkeit, Muskel- oder Gliederschmerzen, Kopfschmerzen, neuer Geschmacks- oder Geruchsverlust, Halsschmerzen, Verstopfung oder laufende Nase, Übelkeit oder Erbrechen, Durchfall.'
STR_COVID_Q1-TITLE = 'Ich hatte in den letzten 48 Stunden keines der folgenden Symptome.'

View File

@ -122,6 +122,8 @@ STR_COMMON_TIMEZONE = 'Timezone'
STR_COMMON_TOUR = 'Tour'
STR_COMMON_VSIGNATURE = 'Visitor Signature'
STR_COMMON_YES = 'Yes'
STR_COMMON_USERCOUNT = 'User Count'
STR_COMMON_NEVERLOGGEDIN = 'Never Logged In'
STR_COVID_ACKNOWLEDGEMENT = 'The novel coronavirus, COVID-19, has been declared a worldwide pandemic by the World Health Organization. By signing in, I acknowledge social distancing must be practiced and face coverings worn at all times. This company cannot guarantee that its employees, vendors, customers, or others entering will not become infected with COVID-19.'
STR_COVID_Q1-DESC = 'Fever, chills, cough, shortness of breath, fatigue, muscle or body aches, headache, new loss of taste or smell, sore throat, congestion or runny nose, nausea or vomiting, diarrhea.'
STR_COVID_Q1-TITLE = 'I have NOT experienced any of the following symptoms in the past 48 hours.'

View File

@ -122,6 +122,8 @@ STR_COMMON_TIMEZONE = 'Zona horaria'
STR_COMMON_TOUR = 'Visitar'
STR_COMMON_VSIGNATURE = 'Firma del Visitante'
STR_COMMON_YES = 'Sí'
STR_COMMON_USERCOUNT = 'Recuento de usuarios'
STR_COMMON_NEVERLOGGEDIN = 'Nunca iniciaste sesión'
STR_COVID_ACKNOWLEDGEMENT = 'El nuevo coronavirus, COVID-19, ha sido declarado pandemia mundial por la Organización Mundial de la Salud. Al registrarme, reconozco que se debe practicar el distanciamiento social y que se debe usar protección para la cara en todo momento. Esta empresa no puede garantizar que sus empleados, proveedores, clientes u otras personas que ingresen no se infecten con COVID-19.'
STR_COVID_Q1-DESC = 'Fiebre, escalofríos, tos, dificultad para respirar, fatiga, dolores musculares o corporales, dolor de cabeza, nueva pérdida del gusto u olfato, dolor de garganta, congestión o secreción nasal, náuseas o vómitos, diarrea.'
STR_COVID_Q1-TITLE = 'NO he experimentado ninguno de los siguientes síntomas en las últimas 48 horas.'

View File

@ -122,6 +122,8 @@ STR_COMMON_TIMEZONE = 'Fuseau horaire'
STR_COMMON_TOUR = 'Visiter'
STR_COMMON_VSIGNATURE = 'Visiteur Signature'
STR_COMMON_YES = 'Oui'
STR_COMMON_USERCOUNT = 'Nombre d'utilisateurs'
STR_COMMON_NEVERLOGGEDIN = 'Jamais connecté'
STR_COVID_ACKNOWLEDGEMENT = 'Le nouveau coronavirus, COVID-19, a été déclaré pandémie mondiale par l'Organisation mondiale de la santé. En m'inscrivant, je reconnais que la distance sociale doit être pratiquée et que les masques doivent être portés en tout temps. Cette société ne peut garantir que ses employés, fournisseurs, clients ou autres personnes entrant ne seront pas infectés par le COVID-19.'
STR_COVID_Q1-DESC = 'Fièvre, frissons, toux, essoufflement, fatigue, douleurs musculaires ou corporelles, maux de tête, nouvelle perte du goût ou de l'odorat, mal de gorge, congestion ou écoulement nasal, nausées ou vomissements, diarrhée.'
STR_COVID_Q1-TITLE = 'I have NOT experienced any of the following symptoms in the past 48 hours.'

183
users.php
View File

@ -87,6 +87,8 @@
<?php // FILTER POSTED DATA
$form_data = filter_input_array(INPUT_POST, [
'fd_formAction' => (string)FILTER_SANITIZE_STRING,
'fd_pgNumUsers' => (int)FILTER_VALIDATE_INT,
'fd_pgNumSites' => (int)FILTER_VALIDATE_INT,
'edituser' => (string)FILTER_SANITIZE_STRING,
'fd_editUserId' => (string)FILTER_SANITIZE_STRING,
'fd_initialPassword' => (string)FILTER_SANITIZE_STRING,
@ -98,6 +100,9 @@ $form_data = filter_input_array(INPUT_POST, [
'fd_newSiteTimezone' => (string)FILTER_SANITIZE_STRING,
'fd_newSiteRegion' => (string)FILTER_SANITIZE_STRING
]);
if(empty($form_data['fd_formAction'])){ // SET INITIAL STAGE
$form_data['fd_formAction'] = 'actionInitial';
}
?>
<?php // PAGE CONSTANTS
@ -303,90 +308,89 @@ if (Registry::AUTHMETHOD == 'INTERNAL') {
header('Location: users.php');
}
}
// Set up pagination
$page_num = 1;
if(!empty($_GET['pnum'])):
$page_num = filter_input(INPUT_GET, 'pnum', FILTER_VALIDATE_INT);
if(false === $page_num):
$page_num = 1;
endif;
endif;
$offset = ($page_num - 1) * $StaticFunctions->getPageRows();
$row_count = count($Users->getUserInfo("%", "%", "%"));
$page_count = 0;
if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctions->getPageRows()); if($page_num > $page_count): $page_num = 1; endif; endif;
?>
<!-- USER MANAGEMENT SECTION -->
<?php if ($form_data['fd_formAction'] == 'actionInitial') { // SHOW USERS LISTING
$pgNumUsers=(int)1; // PAGINATION LOGIC
if(!empty($form_data['fd_pgNumUsers'])){$pgNumUsers = $form_data['fd_pgNumUsers'];}
$pgOffsetUsers=(int)($pgNumUsers-1)*$StaticFunctions->getPageRows();
$pgRowCountUsers=(int)count($Users->getUserInfo("%", "%", "%"));
$pgCountUsers=(int)0;
if(0===$pgRowCountUsers){}else{$pgCountUsers=(int)ceil($pgRowCountUsers/$StaticFunctions->getPageRows());if($pgNumUsers>$pgCountUsers){$pgNumUsers=(int)1;}} ?>
<!-- USER MANAGEMENT -->
<div class="container-fluid">
<div class="row row-cols-3 mb-2">
<div class="col d-grid gap-2">
<h2><i class="fas fa-users"></i> <?php echo $transLang['USER-USERS']; ?></h2>
</div>
<div class="col d-grid gap-2 text-center">
<form method="post">
<ul class="pagination pagination-sm">
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><?php echo $transLang['STR_COMMON_PAGE']; ?></a></li>
<?php for ($i = 1; $i <= $page_count; $i++): ?>
<li class="page-item<?php if ($i === $page_num): echo ' active'; else: echo ' '; endif; ?>"><a class="page-link" href="<?php echo 'users.php?pnum=' . $i; ?>"><?php echo $i; ?></a></li>
<?php endfor; ?>
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><?=$transLang['STR_COMMON_PAGE']?></a></li>
<?php for($i=1; $i<=$pgCountUsers; $i++){ ?>
<li class="page-item<?php if($i===$pgNumUsers){echo ' active';} ?>"><button type="submit" class="page-link<?php if($i===$pgNumUsers){echo ' active';} ?>" id="fd_pgNumUsers" name="fd_pgNumUsers" value="<?php echo $i; ?>"><?php echo $i; ?></button></li>
<?php } ?>
</ul>
</form>
</div>
<div class="col text-end">
<a data-bs-toggle="modal" data-bs-target="#addUserModal" href="#addUserModal" name="addUserModal" type="button" class="btn btn-info btn-lg open-addUserModal"><i class="fas fa-user-plus"></i> <?php echo $transLang['STR_ACCOUNTINFO_ADDUSER_TITLE']; ?></a>
<a data-bs-toggle="modal" data-bs-target="#modalAddUser" href="#modalAddUser" name="modalAddUser" type="button" class="btn btn-info btn-lg open-modalAddUser"><i class="fas fa-user-plus"></i> <?php echo $transLang['STR_ACCOUNTINFO_ADDUSER_TITLE']; ?></a>
<a href="users.php" type="button" class="btn btn-primary btn-lg"><i class="fa fa-redo"></i> <?php echo $transLang['REFRESH']; ?></a>
</div>
</div>
<div class="row row-cols-1 mb-2">
<div class="row row-cols-1">
<div class="col d-grid gap-2">
<table class="table table-striped w-auto">
<thead>
<tr>
<th><?php echo $transLang['NAME']; ?></th><th><?php echo $transLang['USER-USERNAME']; ?></th><th><?php echo $transLang['EMAIL']; ?></th><th><?php echo $transLang['CREATED']; ?></th><th><?php echo $transLang['USER-TYPE']; ?></th><th><?php echo $transLang['STR_COMMON_SITE']; ?></th><th><?php echo $transLang['ACTIONS']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach($Users->getUserInfo("%", $StaticFunctions->getPageRows(), $offset) as $row): ?>
<?php if ($row['users_id'] == "1"): echo " "; else: ?>
<?php if ($row['users_id'] == "2"): echo " "; else: ?>
<tr>
<td><?php echo $row['users_lastname'] . ", " . $row['users_firstname']; ?></td>
<td><?php echo $row['users_username']; ?></td>
<td><?php echo $row['users_email']; ?></td>
<td><?php echo $row['users_created']; ?></td>
<td><?php echo $transLang[$row['users_usertype']]; ?></td>
<td>
<?php $sidrowcount=0; foreach($SiteInfo->getSite("0", $row['users_id'], "0", "0") as $sidrow) { ?>
<table class="table table-striped table-sm table-responsive-sm text-nowrap">
<thead class="thead-dark">
<tr>
<th class="small col-xs-1"><?php echo $transLang['NAME']; ?></th><th class="small col-xs-1"><?php echo $transLang['USER-USERNAME']; ?></th><th class="small col-xs-1"><?php echo $transLang['EMAIL']; ?></th><th class="small col-xs-1"><?php echo $transLang['CREATED']; ?></th><th class="small col-xs-1"><?php echo $transLang['USER-TYPE']; ?></th><th class="small col-xs-1"><?php echo $transLang['STR_COMMON_SITE']; ?></th><th class="small col-xs-1"><?php echo $transLang['ACTIONS']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach($Users->getUserInfo("%", $StaticFunctions->getPageRows(), $pgOffsetUsers) as $rowUsers): ?>
<?php if ($rowUsers['users_id'] == "1"): echo " "; else: ?>
<?php if ($rowUsers['users_id'] == "2"): echo " "; else: ?>
<tr>
<td class="small"><?php echo $rowUsers['users_lastname'] . ", " . $rowUsers['users_firstname']; ?></td>
<td class="small"><?php echo $rowUsers['users_username']; ?></td>
<td class="small"><?php echo $rowUsers['users_email']; ?></td>
<td class="small"><?php echo $rowUsers['users_created']; ?></td>
<td class="small"><?php echo $transLang[$rowUsers['users_usertype']]; ?></td>
<td class="small">
<?php $sidrowcount=0; foreach($SiteInfo->getSite("0", $rowUsers['users_id'], "0", "0") as $sidrow) { ?>
<span class="badge rounded-pill bg-info text-dark"><?php echo $sidrow['sites_name']; ?></span>
<?php ++$sidrowcount; if($sidrowcount==3) { echo "<br>"; } elseif($sidrowcount==5) {echo '<span class="badge rounded-pill bg-danger">...</span>'; break; } } ?>
</td>
<td class="nowrap">
<form method="post">
<input type="hidden" id="_METHOD" name="_METHOD" value="EDITUSER" />
<input type="hidden" id="fd_editUserId" name="fd_editUserId" value="<?php echo $row['users_id']; ?>" />
<button class="btn btn-primary btn-sm" id="edituser" name="edituser" value="edituser" type="submit" <?php if ($row['users_username'] == "admin"): echo "disabled"; endif; if ($row['users_username'] == "KIOSK"): echo "disabled"; endif; ?>><i class="fa fa-edit"></i> </button>
</form>
<form method="post" onsubmit="return confirm('<?php echo $transLang['DELETE_WARNING']; ?>')">
<input type="hidden" id="_METHOD" name="_METHOD" value="DELETE" />
<input type="hidden" id="deleteid" name="deleteid" value="<?php echo $row['users_id']; ?>" />
<button class="btn btn-danger btn-sm" id="deluser" name="deluser" value="deluser" type="submit" <?php if ($row['users_username'] == "admin"): echo "disabled"; endif; if ($row['users_username'] == "KIOSK"): echo "disabled"; endif; ?>><i class="fa fa-trash"></i> </button>
</form>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</td>
<td class="small" class="nowrap">
<div class="btn-group">
<form method="post">
<input type="hidden" id="_METHOD" name="_METHOD" value="EDITUSER" />
<input type="hidden" id="fd_editUserId" name="fd_editUserId" value="<?php echo $rowUsers['users_id']; ?>" />
<button class="btn btn-primary btn-sm" id="edituser" name="edituser" value="edituser" type="submit" <?php if ($rowUsers['users_username'] == "admin"): echo "disabled"; endif; if ($rowUsers['users_username'] == "KIOSK"): echo "disabled"; endif; ?>><i class="fa fa-edit"></i> </button>
</form>
<form method="post" onsubmit="return confirm('<?php echo $transLang['DELETE_WARNING']; ?>')">
<input type="hidden" id="_METHOD" name="_METHOD" value="DELETE" />
<input type="hidden" id="deleteid" name="deleteid" value="<?php echo $rowUsers['users_id']; ?>" />
<button class="btn btn-danger btn-sm" id="deluser" name="deluser" value="deluser" type="submit" <?php if ($rowUsers['users_username'] == "admin"): echo "disabled"; endif; if ($rowUsers['users_username'] == "KIOSK"): echo "disabled"; endif; ?>><i class="fa fa-trash"></i> </button>
</form>
</div>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- END USER MANAGEMENT SECTION -->
<!-- USER MANAGEMENT END -->
<?php } ?>
<!-- ADD USER FORM MODAL -->
<div class="modal fade" id="addUserModal" tabindex="-1" role="dialog">
<div class="modal fade" id="modalAddUser" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header text-light bg-secondary">
@ -497,54 +501,49 @@ if (!empty($_POST['delsite'])) {
header('Location: users.php');
}
}
// Set up pagination
$page_num1 = 1;
if(!empty($_GET['pnum1'])):
$page_num1 = filter_input(INPUT_GET, 'pnum1', FILTER_VALIDATE_INT);
if(false === $page_num1):
$page_num1 = 1;
endif;
endif;
$offset1 = ($page_num1 - 1) * $StaticFunctions->getPageRows();
$row_count1 = count($SiteInfo->listSite("0", "0"));
$page_count1 = 0;
if (0 === $row_count1): else: $page_count1 = (int)ceil($row_count1 / $StaticFunctions->getPageRows()); if($page_num1 > $page_count1): $page_num1 = 1; endif; endif;
?>
<!-- SITE MGMT START -->
<?php if ($form_data['fd_formAction'] == 'actionInitial') { // SHOW SITES LISTING
$pgNumSites=(int)1; // PAGINATION LOGIC
if(!empty($form_data['fd_pgNumSites'])){$pgNumSites = $form_data['fd_pgNumSites'];}
$pgOffsetSites=(int)($pgNumSites-1)*$StaticFunctions->getPageRows();
$pgRowCountSites=(int)count($SiteInfo->listSite("0", "0"));
$pgCountSites=(int)0;
if(0===$pgRowCountSites){}else{$pgCountSites=(int)ceil($pgRowCountSites/$StaticFunctions->getPageRows());if($pgNumSites>$pgCountSites){$pgNumSites=(int)1;}} ?>
<!-- SITE MANAGEMENT -->
<div class="container-fluid">
<div class="row row-cols-3 mb-2">
<div class="col d-grid gap-2">
<h2><i class="fas fa-globe-americas"></i> <?php echo $transLang['USER-SITES']; ?></h2>
</div>
<div class="col d-grid gap-2 text-center">
<form method="post">
<ul class="pagination pagination-sm">
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><?php echo $transLang['STR_COMMON_PAGE']; ?></a></li>
<?php for ($i1 = 1; $i1 <= $page_count1; $i1++): ?>
<li class="page-item<?php if ($i1 === $page_num1): echo ' active'; else: echo ' '; endif; ?>"><a class="page-link" href="<?php echo 'users.php?pnum1=' . $i1; ?>"><?php echo $i1; ?></a></li>
<?php endfor; ?>
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><?=$transLang['STR_COMMON_PAGE']?></a></li>
<?php for($i=1; $i<=$pgCountSites; $i++){ ?>
<li class="page-item<?php if($i===$pgNumSites){echo ' active';} ?>"><button type="submit" class="page-link<?php if($i===$pgNumSites){echo ' active';} ?>" id="fd_pgNumSites" name="fd_pgNumSites" value="<?php echo $i; ?>"><?php echo $i; ?></button></li>
<?php } ?>
</ul>
</form>
</div>
<div class="col text-end">
<a data-bs-toggle="modal" data-bs-target="#modalAddSite" href="#modalAddSite" name="modalAddSite" type="button" class="btn btn-info btn-lg open-modalAddSite"><i class="fas fa-map-marker-alt"></i> <?php echo $transLang['ADD_SITE']; ?></a>
<a href="users.php" type="button" class="btn btn-primary btn-lg"><i class="fa fa-redo"></i> <?php echo $transLang['REFRESH']; ?></a>
</div>
</div>
<div class="row row-cols-1 mb-2">
<div class="row row-cols-1">
<div class="col d-grid gap-2">
<table class="table table-striped w-auto">
<thead>
<tr>
<th><?php echo $transLang['NAME']; ?></th><th><?php echo $transLang['STR_COMMON_TIMEZONE']; ?></th><th><?php echo $transLang['STR_COMMON_REGION']; ?></th><th><?php echo $transLang['ACTIONS']; ?></th>
<table class="table table-striped table-sm table-responsive-sm text-nowrap">
<thead class="thead-dark">
<tr>
<th class="small col-xs-1"><?php echo $transLang['NAME']; ?></th><th class="small col-xs-1"><?php echo $transLang['STR_COMMON_TIMEZONE']; ?></th><th class="small col-xs-1"><?php echo $transLang['STR_COMMON_REGION']; ?></th><th class="small col-xs-1"><?php echo $transLang['STR_COMMON_USERCOUNT']; ?></th><th class="small col-xs-1"><?php echo $transLang['ACTIONS']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach($SiteInfo->listSite($StaticFunctions->getPageRows(), $offset1) as $row1): ?>
<?php if ($row1['sites_name'] === "NOSITE"): echo " "; else: ?>
<?php foreach($SiteInfo->listSite($StaticFunctions->getPageRows(), $pgOffsetSites) as $rowSites): ?>
<?php if ($rowSites['sites_name'] === "NOSITE"): echo " "; else: ?>
<tr>
<td><?php echo $row1['sites_name']; ?></td><td><?php echo $row1['sites_timezone']; ?></td><td><?php echo $row1['sites_region']; ?></td><td><form method="post" onsubmit="return confirm('<?php echo $transLang['DELETE_WARNING']; ?>')"><input type="hidden" id="_METHOD" name="_METHOD" value="DELETE" /><input type="hidden" id="deleteid" name="deleteid" value="<?php echo $row1['sites_id']; ?>" /><button class="btn btn-danger btn-sm" id="deluser" name="delsite" value="delsite" type="submit"><i class="fa fa-trash"></i> </button></form></td>
<td class="small"><?php echo $rowSites['sites_name']; ?></td><td class="small"><?php echo $rowSites['sites_timezone']; ?></td><td class="small"><?php echo $rowSites['sites_region']; ?></td><td class="small"><?=$SiteInfo->countSiteUsers($rowSites['sites_id'])?></td><td class="small"><form method="post" onsubmit="return confirm('<?php echo $transLang['DELETE_WARNING']; ?>')"><input type="hidden" id="_METHOD" name="_METHOD" value="DELETE" /><input type="hidden" id="deleteid" name="deleteid" value="<?php echo $rowSites['sites_id']; ?>" /><button class="btn btn-danger btn-sm" id="deluser" name="delsite" value="delsite" type="submit"><i class="fa fa-trash"></i> </button></form></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
@ -553,10 +552,11 @@ if (0 === $row_count1): else: $page_count1 = (int)ceil($row_count1 / $StaticFunc
</div>
</div>
</div>
<hr />
<!-- SITE MANAGEMENT END -->
<?php } ?>
<!-- START ADDSITE MODAL -->
<!-- SITE ADD MODAL -->
<form class="form form-approve" method="post">
<input type="hidden" name="fd_formAction" id="fd_formAction" value="actionNewSite" />
<div class="modal fade" id="modalAddSite" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" role="dialog">
@ -615,9 +615,8 @@ if (0 === $row_count1): else: $page_count1 = (int)ceil($row_count1 / $StaticFunc
</div>
</form>
<!-- END ADDSITE MODAL -->
<!-- SITE ADD MODAL END -->
<?php } ?>
<hr />
<!-- END PAGE -->
<?php } require_once("inc/footer.inc.php");