LobbySIO/printvwf.php

248 lines
12 KiB
PHP
Raw Normal View History

2021-06-15 11:14:55 -04:00
<?php
/*
* Copyright (C) 2018 josh.north@point808.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
ini_set('session.gc_maxlifetime', 24*60*60); // MIN SESSION
ini_set('session.gc_probability', 1); // GC RATES
ini_set('session.gc_divisor', 100); // TIMES
ini_set('session.use_cookies', '1');
ini_set('session.use_only_cookies', '1');
ini_set('session.cookie_secure', '0');
ini_set('session.cookie_httponly', '0');
ini_set('session.cookie_samesite', 'Lax');
session_save_path('.tmp'); // TEMP
session_start(); // START
require_once __DIR__ . '/autoload.php'; // AUTOLOAD
use App\LobbySIO\Config\Registry;
$Users = new \App\LobbySIO\Database\Users();
if (Registry::AUTHMETHOD == 'SAML') {
//simplesaml
require_once('../simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple(Registry::AUTHIDP);
//$auth->requireAuth();
$auth->isAuthenticated();
if (!$auth->isAuthenticated()) {
$attributes = 'none';
} else {
$attributes = $auth->getAttributes();
$saml_user_email = $attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'][0];
$saml_user_info = $Users->getUserInfoByEmail($saml_user_email, "1", "0");
$saml_user_id = $saml_user_info["0"]["users_id"];
}
$session = \SimpleSAML\Session::getSessionFromRequest();
$session->cleanup();
}
$StaticFunctions = new \App\LobbySIO\Misc\StaticFunctions(); // DEFAULT CLASSES
$SiteInfo = new \App\LobbySIO\Database\SiteInfo();
if (isset($_SESSION['user_id'])) { // LOGGED IN? GET USER OBJECT
if (isset($saml_user_id)) {
$sessuserid=$saml_user_id;
} else {
$sessuserid=$_SESSION['user_id'];
}
} elseif (!isset($_SESSION['user_id'])) {
if (isset($saml_user_id)) {
$sessuserid=$saml_user_id;
} else {
$sessuserid='2';
}
$session_user = $Users->getUserInfo($sessuserid, "1", "0"); }
if (isset($session_user)) { // GET UID OR SET TO KIOSK
$uid = $session_user["0"]["users_id"];} else { $uid = "2"; }
$app_disp_lang = filter_input(INPUT_COOKIE, 'app_disp_lang'); // SETUP LANGUAGE
if(!isset($app_disp_lang)) {
$app_disp_lang=$StaticFunctions->getDefaultLanguage(); }
$siteidcookie = filter_input(INPUT_COOKIE, 'app_site'); // SETUP SITE
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"; }
$Translate = new \App\LobbySIO\Language\Translate($app_disp_lang); // SETUP TRANSLATOR
$transLang = $Translate->userLanguage();
$defaulttimezone = $StaticFunctions->getDefaultTZ();
date_default_timezone_set('UTC'); // DEFAULT TO UTC
date_default_timezone_set($defaulttimezone); // UPDATE TO DEFAULT APP SETTING
$timezone = $SiteInfo->getSite($siteid, "0", "0", "0")[0]["sites_timezone"]; // GET TIMEZONE FROM SITE ID
$timeplus = new DateTime($StaticFunctions->getUTC(), new DateTimeZone('UTC')); // DUMB WAY TO CALCULATE SOME TIMES
$timeplus->setTimezone(new DateTimeZone("$timezone"));
$timenow = $timeplus->format('Y-m-d H:i:s');
$app_current_pagename = $transLang['ACCOUNT']; // PAGE SETUP
$app_current_pageicon = '<i class="fas fa-user-circle"></i> ';
// require_once("inc/header.inc.php");
if ($StaticFunctions->getUserSessionStatus() == false) { // CHECK STATUS
echo $StaticFunctions->killSession(); // ELSE DIE
} else { ?>
<!-- START CONTENT -->
<!doctype html>
<html lang="<?php echo $app_disp_lang; ?>">
<!-- START HEAD -->
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<link rel="manifest" href="manifest.webmanifest">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="<?php echo $transLang['STR_VENDORINFO_FORM_TITLE']; ?>">
<link rel="apple-touch-icon" href="assets/touch-logo.png?v3">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<?php if (basename($_SERVER['PHP_SELF']) == 'signin_display.php'): ?> <meta http-equiv="refresh" content="5; url=index.php" /><?php endif; ?>
<?php if (basename($_SERVER['PHP_SELF']) == 'signout.php'): ?><?php if (!empty($_POST['endvisit'])): ?> <meta http-equiv="refresh" content="5; url=index.php" /><?php endif; ?><?php endif; ?>
<link rel="stylesheet" href="css/bootstrap.min.css?v3"/>
<link rel="stylesheet" href="css/sticky-footer-navbar.css?v3">
<link rel="stylesheet" href="css/all.min.css?v3"/>
<link rel="stylesheet" href="css/fontawesome.min.css?v3"/>
<link rel="stylesheet" href="css/brands.min.css?v3"/>
<link rel="stylesheet" href="css/regular.min.css?v3"/>
<link rel="stylesheet" href="css/animate.min.css?v3"/>
<link rel="stylesheet" href="css/datatables.min.css?v3" />
<link rel="stylesheet" href="css/styles.css?v3"/>
<link rel="stylesheet" href="css/tempusdominus-bootstrap-4.min.css?v3"/>
<meta name="description" content="<?php echo $transLang['META_DESC']; ?>" />
<script src="js/jquery.min.js?v3"></script>
<script src="js/bootstrap.bundle.min.js?v3"></script>
<script src="js/datatables.min.js?v3"></script>
<script src="js/buttons.flash.min.js?v3"></script>
<script src="js/buttons.html5.min.js?v3"></script>
<script src="js/buttons.print.min.js?v3"></script>
<script src="js/dataTables.buttons.min.js?v3"></script>
<script src="js/jszip.min.js?v3"></script>
<script src="js/pdfmake.min.js?v3"></script>
<script src="js/vfs_fonts.js?v3"></script>
<script src="js/moment.min.js?v3"></script>
<script src="js/tempusdominus-bootstrap-4.min.js?v3"></script>
<script src="js/jSignature.min.js?v3"></script>
<title><?php echo $transLang['STR_VENDORINFO_FORM_TITLE']; ?></title>
</head>
<!-- END HEAD -->
<!-- START BODY -->
<body>
<?php
$form_data = filter_input_array(INPUT_POST, [
'form_data_stage' => (string)FILTER_SANITIZE_STRING,
'form_data_sitename' => (string)FILTER_SANITIZE_STRING,
'form_data_timein' => (string)FILTER_SANITIZE_STRING,
'form_data_timeout' => (string)FILTER_SANITIZE_STRING,
'form_data_isvendor' => (int)FILTER_VALIDATE_INT,
'form_data_badge' => (int)FILTER_VALIDATE_INT,
'form_data_manualsignindate' => (string)FILTER_SANITIZE_STRING,
'form_data_firstname' => (string)FILTER_SANITIZE_STRING,
'form_data_idtypename' => (string)FILTER_SANITIZE_STRING,
'form_data_lastname' => (string)FILTER_SANITIZE_STRING,
'form_data_country' => (string)FILTER_SANITIZE_STRING,
'form_data_carnum' => (string)FILTER_SANITIZE_STRING,
'form_data_ssanum' => (string)FILTER_SANITIZE_STRING,
'form_data_company' => (string)FILTER_SANITIZE_STRING,
'form_data_contact1' => (string)FILTER_SANITIZE_STRING,
'form_data_contact2' => (string)FILTER_SANITIZE_STRING,
'form_data_workstart' => (string)FILTER_SANITIZE_STRING,
'form_data_workend' => (string)FILTER_SANITIZE_STRING,
'form_data_visittype' => (int)FILTER_VALIDATE_INT,
'form_data_escortrequired' => (int)FILTER_VALIDATE_INT,
'form_data_v_signature' => (string)FILTER_SANITIZE_STRING,
'form_data_e_signature' => (string)FILTER_SANITIZE_STRING,
'form_data_escortname' => (string)FILTER_SANITIZE_STRING
]);
?>
<div class="container">
<div class="row row-cols-1">
<div class="col d-grid gap-2">
<h2><?php echo $transLang['STR_VENDORINFO_FORM_TITLE']; ?></h2>
</div>
</div>
<div class="row row-cols-2">
<div class="col d-grid gap-2">
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['SITE']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_sitename']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['NAME']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_lastname'] . ", " . $form_data['form_data_firstname']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['CARNUM']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_carnum']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['LOCAL_TIME'] . " " . $transLang['IN']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_timein']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['COUNTRY']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_country']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['BADGE']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_badge']; ?></dd>
</dl>
</div>
<div class="col d-grid gap-2">
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['PRINT']; ?></dt>
<dd class="col-sm-9"><?php echo $timenow; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['COMPANY']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_company']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['SSANUM']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_ssanum']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['LOCAL_TIME'] . " " . $transLang['OUT']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_timeout']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['ID_TYPE']; ?></dt>
<dd class="col-sm-9"><?php echo $form_data['form_data_idtypename']; ?></dd>
</dl>
<dl class="row">
<dt class="col-sm-3"><?php echo $transLang['SIGNATURE']; ?></dt>
<dd class="col-sm-9"><img src="<?php echo $form_data['form_data_v_signature']; ?>" width="200" height="50"/></dd>
</dl>
</div>
</div>
</div>
<?php }