Files
assetmgt/register.php
2024-05-13 16:28:30 +02:00

321 lines
9.2 KiB
PHP

<?php
include './assets/functions.php';
include './settings/settings.php';
include './settings/config.php';
include_once './settings/translations/translations_US.php';
// Default input values
$display ='';
$register = [
'sn' => '',
'organization' => '',
'email' => '',
'phone' => '',
'city' => '',
'country' => ''
];
if (isset($_POST['register'])){
//Update register ARRAY
$register = $_POST;
//GET USERKEY
$data = json_encode(array("username" => interface_user, "password" => interface_pw), JSON_UNESCAPED_UNICODE);
//Secure data
$payload = generate_payload($data);
//API call
$responses = ioServer('/v1/authorization', $payload);
//Decode Payload
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = '400';}
if ($responses === 'NOK' || $responses === '400'){
//Not allowed
exit;
}
else {
// Start a new session
session_start();
// Store data in session
$_SESSION['userkey'] = $responses->userkey;
// GET ALL POST DATA
$data = json_encode($register, JSON_UNESCAPED_UNICODE);
// Secure data
$payload = generate_payload($data);
// API call
$message_return = ioServer('/v1/application/register', $payload);
if (!empty($message_return)){
$message_return = decode_payload($message_return);
$display = 'display:none;';
}
else{
$message_return = '400';
}
}
}
echo '
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<title>Productregistration</title>
<link rel="icon" type="image/png" href="'.icon_image.'">
<style>
* {
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "segoe ui", roboto, oxygen, ubuntu, cantarell, "fira sans", "droid sans", "helvetica neue", Arial, sans-serif;
font-size: 16px;
}
body {
position: relative;
min-height: 100%;
color: #555555;
background-color: #FFFFFF;
margin: 0;
padding-bottom: 100px;
/* Same height as footer */
}
h1, h2, h3, h4, h5 {
color: #fff;
}
.content-wrapper {
width: 1050px;
margin: 0 auto;
}
header {
position: relative;
border-bottom: 1px solid #EEEEEE;
}
header .content-wrapper {
display: flex;
}
main .myaccount h1 {
display: block;
font-weight: normal;
color: #fff;
margin: 0;
padding: 40px 0;
font-size: 50px;
text-align: center;
width: 100%;
}
main .myaccount {
display: flex;
flex-flow: wrap;
}
main .myaccount form {
width: 100%;
}
main .myaccount h2 {
width: 100%;
font-weight: normal;
font-size: 20px;
padding: 30px 0 20px 0;
margin: 0 0 10px 0;
border-bottom: 1px solid #EEEEEE;
}
main .myaccount .login-register {
display: flex;
width: 100%;
justify-content: space-between;
margin-top: 40px;
}
main .myaccount .login-register h1 {
text-align: left;
padding-top: 15px;
}
main .myaccount .login-register .login {
width: 100%;
border-right: 1px solid #f6f6f6;
padding-right: 45px;
}
main .myaccount .login-register .register {
width: 100%;
padding-left: 45px;
}
main .myaccount .login-register .btn {
margin-top: 25px;
}
.btn {
text-decoration: none;
background: #03337a;
border: 0;
color: #FFFFFF;
padding: 11px 16px;
font-size: 14px;
font-weight: 500;
border-radius: 4px;
cursor: pointer;
}
.btn:hover {
background: #444954;
}
.btn:disabled {
background: #ddd;
}
.form-label {
display: block;
padding: 20px 0 10px 0;
}
.form-field {
width: 100%;
padding: 10px;
border: 1px solid #d5d5d5;
border-radius: 4px;
background-color: #fff;
}
footer {
position: absolute;
padding: 20px 0;
width: 100%;
}
footer a {
text-decoration: none;
color: #555555;
}
footer a:hover {
text-decoration: underline;
}
/* Responsive CSS below */
@media screen and (max-width: 1050px) {
.rhide {
display: none;
}
.content-wrapper {
width: 100%;
padding: 0 10px;
}
main .checkout form, main .myaccount form {
width: 100%;
}
main .myaccount .login-register {
flex-flow: column;
}
main .myaccount .login-register .login {
border-right: 0;
padding: 10px;
}
main .myaccount .login-register .register {
padding: 10px;
}
main .myaccount .menu {
width: 100%;
padding-right: 0;
}
}
</style>
</head>
<body style="background-image:linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url(./assets/images/emergencyplug-auto-in-licht.jpg);
background-position: center center;background-size: 100% 100%; min-height: 100vh;background-repeat: no-repeat;">
<header>
</header>
<main style="color:#fff">
<div class="myaccount content-wrapper">
<h1>Productregistration</h1>
<div class="login-register">
<div class="login">
<h4>1. find serialnumber on device</h4>
<img style="width: 80%;
margin-top: -75px;
margin-bottom: -40px;" src="./assets/images/EP_register.gif" alt="">
<h4>2. enter serialnumber (8-digits)</h4>
<form action="" method="post">
<label for="email" class="form-label">Serialnumber * </label>
<input type="text" name="sn[]" id="sn" placeholder="Enter Serialnumber" style="margin-bottom:10px;" minlength="8" maxlength="8" required="" class="form-field">
<button type="button" class="btn" onclick="addField(\'sn\',\'sn[]\');"> + </button><small>(add more serialnumbers)</small>
</div>
<div class="register" style="'.$display.'">
<h4>3. register product</h4>
<label for="company" class="form-label">Company/Organization Name *</label>
<input type="text" name="organization" placeholder="Company/Organization Name" value="'.$register['organization'].'" required="" class="form-field">
<label for="email" class="form-label">Email *</label>
<input type="email" name="email" id="email" placeholder="info@example.com" value="'.$register['email'].'" required="" class="form-field">
<label for="company" class="form-label">Phone *</label>
<input type="text" name="phone" placeholder="Phone" value="'.$register['phone'].'" required="" class="form-field">
<label for="city" class="form-label">City *</label>
<input type="text" name="city" placeholder="City" value="'.$register['city'].'" required="" class="form-field">
<label for="city" class="form-label">Country *</label>
<input type="text" name="country" placeholder="Country" value="'.$register['country'].'" required="" class="form-field" style="margin-bottom: 20px;">
<input type="checkbox" name="email_consent" checked required/>I would like to recieve email communication about TotalSafetySolutions news and product updates <br>
<input type="checkbox" name="terms_consent" required/>I agree with <a href="" target="blank">terms and conditions</a>*<br>
<input name="register" type="submit" value="Registeer" class="btn">
</form>
<br>
<small>* mandatory</small>
</div>';
//IF MESSAGES ARE RETURN SHOW THEM
if (!empty($message_return)){
echo '
<div class="register">
<h4>4. Registration Completed</h4>
<p>'.$register_message_4.'</p>
<h4>5. Registration details</h4>';
foreach($message_return as $return_message){
echo'
<p>'.$return_message.'"</p>
';
}
echo'
<h4>6. Return to registration</h4>
<p> <a href="register.php" class="btn alt mar-right-2">Back</a><p>
';
}
echo'
</div>
</div>
</main>
<footer>
</footer>
</body>
<script>
function addField(id, name) {
var x = document.createElement("INPUT");
x.setAttribute("type", "text");
x.setAttribute("name", name);
x.setAttribute("value", "");
x.setAttribute("placeholder", "Enter Serialnumber");
x.setAttribute("class", "form-field");
x.setAttribute("style", "margin-bottom:10px;");
x.setAttribute("minlength", "8");
x.setAttribute("maxlength", "8");
x.setAttribute("required", "");
var td_new = document.getElementById(id);
td_new.parentNode.insertBefore(x, td_new.nextSibling);
}
</script>
</html>
';