Fix more IOS stuff. Adjust sig size. Adjust bootstrap inc. Add site welcome. Fix User admin. Fix site delete. NOTE - updates past this must adjust sql initial column. ALTER TABLE lsio_visits MODIFY initials INT. Also add WELCOMETO to lang file or recopy if you use defaults.

This commit is contained in:
Josh North 2021-04-21 12:07:02 -04:00
parent f9a4849cd6
commit 7540e4dc29
9 changed files with 158 additions and 35 deletions

View File

@ -82,18 +82,18 @@
}
#esignature-parent {
max-height: 150px;
max-height: 350px;
width: 100%;
height: auto;
height: 350px;
}
#vsignature-parent {
max-height: 150px;
max-height: 350px;
width: 100%;
height: auto;
height: 350px;
}
canvas.jSignature {
max-height: 120px !important;
max-height: 360px !important;
}
.vertical-center {

View File

@ -52,8 +52,15 @@
?>
<!-- GUEST CONTENT START -->
<div class="jumbotron vertical-center">
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-sm">
<div class="alert alert-info text-center">
<?php echo $transLang['WELCOMETO'] . " " . $SiteInfo->getSite($siteid, $uid, "0", "0")[0]["sites_name"]; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm">
&nbsp;
@ -192,7 +199,7 @@
<label class="form-check-label" for="citizen"><?php echo $transLang['CITIZEN']; ?></label>
<?php }; ?>
</td>
<td><input type="text" id="badge" name="badge" class="form-control" autofocus disabled value="<?php echo $row['visits_badge']; ?>"> <input type="text" id="initials" name="initials" class="form-control" autofocus disabled value="<?php echo $row['visits_initials']; ?>"></td>
<td><input type="text" id="badge" name="badge" class="form-control" autofocus disabled value="<?php echo $row['visits_badge']; ?>"> <input type="text" id="initials" name="initials" class="form-control" autofocus disabled value="<?php echo $Users->getUserInitials($row['visits_initials'])[0]["users_firstname"] . " " . $Users->getUserInitials($row['visits_initials'])[0]["users_lastname"]; ?>"></td>
<?php if($SiteInfo->getSite($siteid, $uid, "0", "0")[0]["sites_region"] == "EMEA") { ?>
<td><?php echo $carnum; ?> / <?php echo $ssanum; ?></td>
<?php }; ?>
@ -226,7 +233,7 @@
<td>
<input type="text" id="badge" name="badge" class="form-control<?php if( isset($badge_error) && $badge_error == "1" && $_POST['approvevisit'] == $visitid ) { echo " is-invalid"; } ?>" placeholder="<?php echo $transLang['BADGE']; ?>" autofocus maxlength="15">
<div class="invalid-feedback"><?php echo $transLang['REQUIRED']; ?></div>
<input type="text" id="initials" name="initials" class="form-control<?php if( isset($initials_error) && $initials_error == "1" && $_POST['approvevisit'] == $visitid ) { echo " is-invalid"; } ?>" placeholder="<?php echo $transLang['INITIALS']; ?>" autofocus maxlength="5">
<input type="hidden" id="initials" name="initials" class="form-control<?php if( isset($initials_error) && $initials_error == "1" && $_POST['approvevisit'] == $visitid ) { echo " is-invalid"; } ?>" placeholder="<?php echo $uid; ?>" value="<?php echo $uid; ?>" autofocus maxlength="5">
<div class="invalid-feedback"><?php echo $transLang['REQUIRED']; ?></div>
</td>
<?php if($SiteInfo->getSite($siteid, $uid, "0", "0")[0]["sites_region"] == "EMEA") { ?>

View File

@ -65,6 +65,42 @@ class SiteInfo {
return $rows;
}
// Return Site Information array. 0 eliminates argument
public function getSitePerms ($sites_id, $users_id) {
$query = "
SELECT DISTINCT
" . Registry::DB_PRFX . "users_sites.sites_id as users_sites_sites_id,
" . Registry::DB_PRFX . "users_sites.users_id as users_sites_users_id
FROM " . Registry::DB_PRFX . "users_sites
WHERE " . Registry::DB_PRFX . "users_sites.sites_id=\"$sites_id\" AND " . Registry::DB_PRFX . "users_sites.users_id=\"$users_id\"";
$database = new \App\LobbySIO\Database\Connect();
$rows = $database->getQuery($query);
if(empty($rows)) {
return "0";} else { return "1";};
}
// Update site perms. For now we delete all uid matches and then insert.
public function delSitePerms ($users_id) {
$query = "
DELETE
FROM " . Registry::DB_PRFX . "users_sites
WHERE " . Registry::DB_PRFX . "users_sites.users_id=\"$users_id\"";
$database = new \App\LobbySIO\Database\Connect();
$rows = $database->getQuery($query);
if(empty($rows)) {
return "0";} else { return "1";};
}
public function setSitePerms ($sites_id, $users_id) {
$query = "
INSERT
INTO " . Registry::DB_PRFX . "users_sites
VALUES (\"$sites_id\", \"$users_id\")";
$database = new \App\LobbySIO\Database\Connect();
$rows = $database->getQuery($query);
if(empty($rows)) {
return "0";} else { return "1";};
}
// Return Site Information array. 0 eliminates argument
public function listSite ($rowsperpage, $offset) {
if ($rowsperpage == "0") { $c_rowsperpage = NULL; }

View File

@ -50,6 +50,19 @@ class Users {
return $rows;
}
public function getUserInitials($userid) {
$query = "
SELECT
" . Registry::DB_PRFX . "users.id as users_id,
" . Registry::DB_PRFX . "users.firstname as users_firstname,
" . Registry::DB_PRFX . "users.lastname as users_lastname
FROM " . Registry::DB_PRFX . "users
WHERE " . Registry::DB_PRFX . "users.id LIKE \"$userid\"";
$database = new \App\LobbySIO\Database\Connect();
$rows = $database->getQuery($query);
return $rows;
}
public function loginUser ($username) {
$query = "
SELECT
@ -106,6 +119,23 @@ class Users {
return $count;
}
public function editUserInfo($uid, $firstname, $lastname, $username, $email, $usertypeid) {
$query = "
UPDATE
" . Registry::DB_PRFX . "users
SET
" . Registry::DB_PRFX . "users.firstname = \"$firstname\",
" . Registry::DB_PRFX . "users.lastname = \"$lastname\",
" . Registry::DB_PRFX . "users.email = \"$email\",
" . Registry::DB_PRFX . "users.usertype = \"$usertypeid\",
" . Registry::DB_PRFX . "users.username = \"$username\"
WHERE " . Registry::DB_PRFX . "users.id = \"$uid\"
";
$database = new \App\LobbySIO\Database\Connect();
$count = $database->runQuery($query);
return $count;
}
public function getUserType ($usertypeid){
$query = "
SELECT

View File

@ -142,5 +142,6 @@ VISITOR = 'Besucher'
VOID = 'Leere'
VOID_WARNING = 'Sind Sie sicher, dass Sie diesen Besuch aufheben möchten? Es gibt kein Rückgängig.'
VSIGNATURE = 'Unterschrift des Besuchers'
WELCOMETO = 'Willkommen zu'
YESYES = 'Ja'
NONO = 'Nein'

View File

@ -142,5 +142,6 @@ VISITOR = 'Visitor'
VOID = 'Void'
VOID_WARNING = 'Are you sure you want to VOID this visit? There is no undo.'
VSIGNATURE = 'Visitor Signature'
WELCOMETO = 'Welcome to'
YESYES = 'Yes'
NONO = 'No'

View File

@ -142,5 +142,6 @@ VISITOR = 'Visitante'
VOID = 'Invalidar'
VOID_WARNING = '¿Seguro que quieres anular esta visita? No hay deshacer.'
VSIGNATURE = 'Firma del Visitante'
WELCOMETO = 'Bienvenido a'
YESYES = 'Sí'
NONO = 'No'

View File

@ -142,5 +142,6 @@ VISITOR = 'Visiteur'
VOID = 'Vide'
VOID_WARNING = 'Êtes-vous sûr de vouloir annuler cette visite? Il n&#39;y a pas d&#39;annuler.'
VSIGNATURE = 'Visiteur Signature'
WELCOMETO = 'Bienvenue à'
YESYES = 'Oui'
NONO = 'Non'

100
users.php
View File

@ -59,29 +59,47 @@
?>
<!-- USER EDIT START -->
<div class="container">
<div class="container bg-info rounded">
<div class="row">
<div class="col-sm">
<h2><?php echo $app_current_pageicon . $transLang['EDIT_PROFILE']; ?></h2>
</div>
</div>
<form class="form-inline my-2 my-lg-0" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<form class="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset id="editor">
<div class="form-group">
<div class="row">
<div class="col-sm">
<div class="form-row">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="firstname"><?php echo $transLang['FIRSTNAME']; ?></span>
</div>
<input type="text" class="form-control" id="firstname" name="firstname" value="<?php echo $edituser["0"]["users_firstname"]; ?>" required />
</div>
<div class="col-sm">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="lastname"><?php echo $transLang['LASTNAME']; ?></span>
</div>
<input type="text" class="form-control" id="lastname" name="lastname" value="<?php echo $edituser["0"]["users_lastname"]; ?>" required />
</div>
<div class="col-sm">
</div>
<div class="form-row">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="username"><?php echo $transLang['USERNAME']; ?></span>
</div>
<input type="text" class="form-control" id="username" name="username" value="<?php echo $edituser["0"]["users_username"]; ?>" required />
</div>
<div class="col-sm">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="email"><?php echo $transLang['EMAIL']; ?></span>
</div>
<input type="text" class="form-control" id="email" name="email" value="<?php echo $edituser["0"]["users_email"]; ?>" />
</div>
<div class="col-sm">
</div>
<div class="form-row">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="username"><?php echo $transLang['ACCESS_LEVEL']; ?></span>
</div>
<select class="custom-select" id="usertype" aria-label="<?php echo $transLang['ACCESS_LEVEL']; ?>" name="usertype" required>
<?php foreach($Users->getUserTypeInfo("%") as $row): ?>
<option value="<?php echo $row['usertypes_id']; ?>"<?php if ($row['usertypes_id']==$edituser["0"]["users_usertypeid"]) { echo " selected"; } ?>><?php echo $transLang[$row['usertypes_name']]; ?></option>
@ -89,29 +107,24 @@
</select>
</div>
</div>
<div class="row">
<div class="col-sm">
<?php
// var_dump($SiteInfo->getSite("0", "0", "0", "0"));
// foreach($SiteInfo->getSite("0", $uid, "0", "0") as $arr) {
// $lookup_array[$arr['sites_id']]=1; }
// if(isset($lookup_array[$siteidcookie])) {
// $siteid = $siteidcookie; } else { $siteid = "1"; }
// if(!isset($siteid)) { $siteid="1"; }
?>
<select id="sitepermissions" name="sitepermissions" class="custom-select" multiple size="5">
<?php foreach($SiteInfo->getSite("0", $edituser["0"]["users_id"], "0", "0") as $row): ?>
<option value="<?php echo $row['sites_id']; ?>"<?php if ($row['users_sites_users_id']==$edituser["0"]["users_id"]) { echo " selected"; } ?>><?php echo $row['sites_name']; ?></option>
<div class="form-row">
<div class="col input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="username"><?php echo $transLang['SITE']; ?></span>
</div>
<select id="sitepermissions" name="sitepermissions[]" class="custom-select" multiple size="5">
<?php foreach($SiteInfo->listSite("0", "0") as $row): ?>
<option value="<?php echo $row['sites_id']; ?>"<?php if ($SiteInfo->getSitePerms($row['sites_id'], $edituser["0"]["users_id"])=="1") { echo " selected"; } ?>><?php echo $row['sites_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="row">
<div class="col-sm">
<button type="submit" class="form-control btn btn-block btn-primary" value="Submit" name="editusercomplete"><i class="fa fa-user-plus"></i> <?php echo $transLang['SAVE']; ?></button>
<div class="form-row">
<div class="col input-group">
<input type="hidden" id="edituserid" name="edituserid" value="<?php echo $edituser["0"]["users_id"]; ?>" />
<button type="submit" class="form-control btn btn-block btn-success" value="Submit" name="editusercomplete"><i class="fa fa-user-plus"></i> <?php echo $transLang['SAVE']; ?></button>
</div>
</div>
</div>
</fieldset>
</form>
</div>
@ -156,6 +169,39 @@
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
if (!empty($_POST['editusercomplete'])): // EDIT USER
require_once("src/Misc/PasswordHash.php");
if (empty($_POST['username'])): $errors['username'] = $transLang['USERNAME_NOTEMPTY']; endif;
if (preg_match('/[^a-zA-Z0-9 .-_]/', $_POST['username'])): $errors['username'] = $transLang['ILLEGAL_CHARACTERS']; endif;
// if (empty($_POST['password'])): $errors['password'] = $transLang['PASSWORD_NOTEMPTY']; endif;
// if (strlen($_POST['password']) < $minpasslength): $errors['password'] = $transLang['MIN_PASSWORD_LENGTH'] . $minpasslength; endif;
// if (empty($_POST['password_confirm'])): $errors['password_confirm'] = $transLang['PASSWORD_NOTCONFIRMED']; endif;
// if ($_POST['password'] != $_POST['password_confirm']): $errors['password_confirm'] = $transLang['PASSWORD_NOTMATCH']; endif;
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
if (!$email): $errors['email'] = $transLang['EMAIL_NOTVALID']; endif;
// $existing = $Users->checkUser($_POST['username'], $email);
// if ($existing):
// if ($existing[0]["users_username"] == $_POST['username']): $errors['username'] = $transLang['USERNAME_USED']; endif;
// if ($existing[0]["users_email"] == $email): $errors['email'] = $transLang['PASSWORD_USED']; endif;
// endif;
endif;
if (!empty($_POST['editusercomplete']) && empty($errors)):
// $hasher = new PasswordHash(8, FALSE);
// $password = $hasher->HashPassword($_POST['password']);
$Users->editUserInfo($_POST['edituserid'], $_POST['firstname'], $_POST['lastname'], $_POST['username'], $_POST['email'], $_POST['usertype']);
//foreach loop to check if exists, if new, delete or add as needed
if (!empty($_POST['sitepermissions'])){
$SiteInfo->delSitePerms($_POST['edituserid']);
foreach($_POST['sitepermissions'] as $editsitepermission) {
$SiteInfo->setSitePerms($editsitepermission, $_POST['edituserid']);
}
}
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
// DEL USER
if (!empty($_POST['deluser'])) {
if ($_SERVER['REQUEST_METHOD'] == 'DELETE' || ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['_METHOD'] == 'DELETE')) {
$deleteid = (int) $_POST['deleteid'];
@ -294,7 +340,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
<?php
// delete user only if submitted by button
// delete site only if submitted by button
if (!empty($_POST['delsite'])) {
if ($_SERVER['REQUEST_METHOD'] == 'DELETE' || ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['_METHOD'] == 'DELETE')) {
$deleteid = (int) $_POST['deleteid'];