CIM71 - Add related users to assest, CIM72 Add related users to accounts
This commit is contained in:
16
account.php
16
account.php
@@ -235,13 +235,27 @@ $view .= '<div class="content-block">
|
||||
';
|
||||
|
||||
$soldto_id = explode("-",$account_hierarchy->soldto) ?? '';
|
||||
|
||||
//DISPLAY RELATED COMMUNICATION RECORDS
|
||||
$view_communication = '';
|
||||
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
|
||||
$view_communication = ' <a href="index.php?page=communications&partnerid='.$soldto_id[0].'" class="btn">'.$button_partner_assigned_communication.'</a>';
|
||||
}
|
||||
|
||||
//DISPLAY RELATED USERS
|
||||
$view_users ='';
|
||||
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
|
||||
$view_users = ' <a href="index.php?page=users&partnerid='.$soldto_id[0].'" class="btn">'.$button_partner_assigned_users.'</a>';
|
||||
}
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$view_asset_actions.'
|
||||
</div>
|
||||
<a href="index.php?page=equipments&partnerid='.$soldto_id[0].'" class="btn">'.$button_partner_assigned_equipment.'</a>
|
||||
<a href="index.php?page=contracts&accountID='.$account_hierarchy->soldto.'" class="btn">'.$button_partner_assigned_contracts.'</a>
|
||||
|
||||
'.$view_communication.'
|
||||
'.$view_users.'
|
||||
</div>';
|
||||
|
||||
//OUTPUT
|
||||
|
||||
@@ -48,6 +48,10 @@ if(isset($get_content) && $get_content!=''){
|
||||
//build up search
|
||||
$clause .= ' AND email like :'.$v[0];
|
||||
}
|
||||
elseif ($v[0] == 'partnerid') {
|
||||
//check partnerID related records
|
||||
$clause .= ' AND partnerID like :'.$v[0];
|
||||
}
|
||||
else {//create clause
|
||||
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||
}
|
||||
@@ -87,6 +91,10 @@ if (!empty($criterias)){
|
||||
$search_value = '%'.$value.'%';
|
||||
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
|
||||
}
|
||||
elseif ($key == 'partnerid'){
|
||||
$search_value = $value.'-%';
|
||||
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
|
||||
}
|
||||
else {
|
||||
$stmt->bindValue($key, $value, PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ if(isset($get_content) && $get_content!=''){
|
||||
//build up search
|
||||
$clause .= ' AND username like :'.$v[0];
|
||||
}
|
||||
elseif ($v[0] == 'partnerid') {
|
||||
//check accounthierarchy related users
|
||||
$clause .= ' AND partnerhierarchy like :'.$v[0];
|
||||
}
|
||||
else {//create clause
|
||||
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||
}
|
||||
@@ -86,6 +90,10 @@ if (!empty($criterias)){
|
||||
$search_value = '%'.$value.'%';
|
||||
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
|
||||
}
|
||||
elseif ($key == 'partnerid'){
|
||||
$search_value = '%"_"'.$value.'-%';
|
||||
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
|
||||
}
|
||||
else {
|
||||
$stmt->bindValue($key, $value, PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ const VPP1 = []; //for VPP1 values
|
||||
const VPP2 = []; //for VPP2 values
|
||||
const VBAT = []; //for VBAT values
|
||||
const PWM = []; //for PWM values
|
||||
const STATE = []; //for STATE values
|
||||
const xChart = []; //x-axis chart values
|
||||
|
||||
|
||||
function progressBar(percentage, message, color){
|
||||
var readbar = document.getElementById("readBar");
|
||||
readBar.style.background = color;
|
||||
@@ -238,14 +238,13 @@ const serialResultsDiv = document.getElementById("serialResults");
|
||||
|
||||
async function appendToTerminal(newStuff) {
|
||||
serialResultsDiv.innerHTML += newStuff;
|
||||
|
||||
serialOutput +=newStuff
|
||||
}
|
||||
|
||||
|
||||
|
||||
function renderChart(){
|
||||
var test = serialResultsDiv.innerHTML.split(";");
|
||||
console.log(test)
|
||||
test.forEach(getData);
|
||||
const xValues = xChart;
|
||||
new Chart("chart_VCP", {
|
||||
@@ -263,6 +262,26 @@ function renderChart(){
|
||||
data: VBAT,
|
||||
borderColor: "black",
|
||||
fill: false
|
||||
},{
|
||||
label: "VPP1",
|
||||
data: VPP1,
|
||||
borderColor: "green",
|
||||
fill: false
|
||||
},{
|
||||
label: "VPP2",
|
||||
data: VPP2,
|
||||
borderColor: "blue",
|
||||
fill: false
|
||||
},{
|
||||
label: "PWM",
|
||||
data: PWM,
|
||||
backgroundColor: "yellow",
|
||||
fill: false
|
||||
},{
|
||||
label: "STATE",
|
||||
data: STATE,
|
||||
backgroundColor: "purple",
|
||||
fill: false
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -270,75 +289,57 @@ function renderChart(){
|
||||
legend: {display: true}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
new Chart("chart_VPP", {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: xValues,
|
||||
datasets: [{
|
||||
label: "VPP1",
|
||||
data: VPP1,
|
||||
borderColor: "green",
|
||||
fill: false
|
||||
}, {
|
||||
label: "VPP2",
|
||||
data: VPP2,
|
||||
borderColor: "blue",
|
||||
fill: false
|
||||
},
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {display: true}
|
||||
}
|
||||
});
|
||||
|
||||
new Chart("chart_PWM", {
|
||||
type: "bar",
|
||||
data: {
|
||||
labels: xValues,
|
||||
datasets: [{
|
||||
label: "PWM",
|
||||
data: PWM,
|
||||
backgroundColor: "yellow",
|
||||
fill: false
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
legend: {display: true}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//Get the RAW data and turn into object
|
||||
function getData(item) {
|
||||
|
||||
let item_array = item.split("=");
|
||||
let xaxis = xChart.length + 1;
|
||||
|
||||
if (item_array[0] == "VCP"){
|
||||
VCP.push(item_array[1])
|
||||
let vcp = item_array[1] / 1000000;
|
||||
VCP.push(vcp)
|
||||
xChart.push(xaxis);
|
||||
}
|
||||
if (item_array[0] == "VPP1"){
|
||||
VPP1.push(item_array[1])
|
||||
let vpp1 = item_array[1] / 1000000;
|
||||
VPP1.push(vpp1)
|
||||
}
|
||||
if (item_array[0] == "VPP2"){
|
||||
VPP2.push(item_array[1])
|
||||
let vpp2 = item_array[1] / 1000000;
|
||||
VPP2.push(vpp2)
|
||||
}
|
||||
if (item_array[0] == "VBAT"){
|
||||
VBAT.push(item_array[1])
|
||||
let vbat = item_array[1] / 1000000;
|
||||
VBAT.push(vbat)
|
||||
}
|
||||
if (item_array[0] == "STATE"){
|
||||
let state
|
||||
switch (item_array[1]) {
|
||||
case 'FULL_CONNECT':
|
||||
state = 5;
|
||||
break;
|
||||
case 'REACTIVATE':
|
||||
state = 3;
|
||||
break;
|
||||
case 'WAIT_CONNECT':
|
||||
state = -5;
|
||||
break;
|
||||
case 'DISCONNECTED':
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
STATE.push(state)
|
||||
}
|
||||
if (item_array[0] == "PWM")
|
||||
{
|
||||
var check_return = item_array[1].match(/[^\r\n]+/g);
|
||||
console.log(check_return, check_return[0])
|
||||
if (check_return.length == 2){
|
||||
PWM.push(check_return[0])
|
||||
let pwm = check_return[0] / 10;
|
||||
PWM.push(pwm)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function closePort(){
|
||||
|
||||
127
cartest_manage.php
Normal file
127
cartest_manage.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
defined(page_security_key) or exit;
|
||||
|
||||
if (debug && debug_id == $_SESSION['id']){
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
$page = 'cartest_manage';
|
||||
//Check if allowed
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
exit;
|
||||
}
|
||||
//PAGE Security
|
||||
$update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U');
|
||||
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
|
||||
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
|
||||
|
||||
$bearertoken = createCommunicationToken($_SESSION['userkey']);
|
||||
|
||||
//GET PRODUCTS FROM DB
|
||||
$pdo = dbConnect($dbname);
|
||||
$sql = 'SELECT rowID, productcode, productname, product_category,sn from products where status = "1" and build = "1"';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
template_header('Buildtool', 'buildtool','view');
|
||||
|
||||
$view = '
|
||||
<div class="content-title">
|
||||
<div class="title">
|
||||
<i class="fa-solid fa-box-open"></i>
|
||||
<div class="txt">
|
||||
<h2>'.$buildtool_h2 .'</h2>
|
||||
<p>'.$buildtool_p.'</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$view .= '
|
||||
<div class="content-header responsive-flex-column pad-top-5">
|
||||
<a href="index.php?page=dashboard" class="btn">'.$button_cancel.'</a>
|
||||
</div>
|
||||
';
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i><span id="time">25:00</span>
|
||||
</div>
|
||||
<input type="hidden" id="lineToSend" >
|
||||
|
||||
<div id="connectdevice" style="display:flex;">
|
||||
<div>
|
||||
<button class="btn" style="margin-right:10px;" onclick="connectSerial();startGraph()">Connect</button>
|
||||
<button class="btn" id="clear" onclick="closePort()" style="">X</button>
|
||||
<button class="btn" onClick="window.location.reload()">↺</button>
|
||||
</div>
|
||||
<div id="readStatus" style="width: 75%;background-color: #f1f1f1;">
|
||||
<div id="readBar"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="Device_output" style="margin-top: 10px;">
|
||||
<div><canvas id="chart_VCP" style="width:400px;max-width:100%"></canvas></div>
|
||||
<p><small>STATE: -5 = WAIT_CONNECT, 0 = DISCONNECTED, 3 = REACTIVATE, 5 = FULL_CONNECT</small></p>
|
||||
</div>
|
||||
<div id="serialResults" style="display:none;font-family: monospace;white-space: pre;padding: 10px;background-color:#f1f1f1;"></div>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
';
|
||||
|
||||
|
||||
//OUTPUT
|
||||
echo $view;
|
||||
|
||||
//ADD JS FILES
|
||||
echo '
|
||||
<script src = "./assets/readdevice.js?'.script_version.'"></script>
|
||||
<script src = "./assets/charts.js?'.script_version.'"></script>
|
||||
<script src = "./assets/jquery-2.1.4.min.js"></script>
|
||||
<script src = "./assets/DYMO.Label.Framework.latest.js?'.script_version.'" type="text/javascript" charset="UTF-8"> </script>
|
||||
<script>
|
||||
var link = "'.$baseurl.'";
|
||||
|
||||
function startGraph(){
|
||||
setInterval(renderChart,5000);
|
||||
}
|
||||
|
||||
function startTimer(duration, display) {
|
||||
var timer = duration, minutes, seconds;
|
||||
setInterval(function () {
|
||||
minutes = parseInt(timer / 60, 10);
|
||||
seconds = parseInt(timer % 60, 10);
|
||||
|
||||
minutes = minutes < 10 ? "0" + minutes : minutes;
|
||||
seconds = seconds < 10 ? "0" + seconds : seconds;
|
||||
|
||||
display.textContent = minutes + ":" + seconds;
|
||||
|
||||
if (--timer < 0) {
|
||||
timer = duration;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
var startMinute = 60 * 25,
|
||||
display = document.querySelector(\'#time\');
|
||||
startTimer(startMinute, display);
|
||||
};
|
||||
</script>
|
||||
';
|
||||
|
||||
|
||||
|
||||
template_footer();
|
||||
?>
|
||||
@@ -76,7 +76,7 @@ $view .= ' <div class="msg success">
|
||||
$view .= '
|
||||
<div class="content-header responsive-flex-column pad-top-5">';
|
||||
if ($create_allowed ===1){
|
||||
$view .= '<a href="index.php?page=cartests" class="btn">'.$button_create_cartest.'</a>';
|
||||
$view .= '<a href="index.php?page=cartest_manage" class="btn">'.$button_create_cartest.'</a>';
|
||||
}
|
||||
$view .= '
|
||||
<form action="" method="get">
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
defined(page_security_key) or exit;
|
||||
|
||||
//SET ORIGIN FOR NAVIGATION
|
||||
$_SESSION['prev_origin'] = $_SERVER['REQUEST_URI'];
|
||||
$page = $_SESSION['origin'] = 'communication';
|
||||
|
||||
$page = 'communication';
|
||||
//Check if allowed
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
|
||||
@@ -8,11 +8,16 @@ defined(page_security_key) or exit;
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
//SET ORIGIN FOR NAVIGATION
|
||||
$_SESSION['prev_origin'] = '';
|
||||
//SET PAGE ORIGIN FOR NAVIGATION AND SECURITY
|
||||
$prev_page = ($_SESSION['origin'] == 'equipments') ? $_SESSION['prev_origin_equipment'] : (($_SESSION['origin'] == 'account')? $_SESSION['prev_origin'] :'');
|
||||
$page = 'communications';
|
||||
|
||||
//create backbutton to prev_origin
|
||||
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">'.$button_back.'</a>':'';
|
||||
|
||||
|
||||
//Check if allowed
|
||||
if (isAllowed('communications',$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
exit;
|
||||
}
|
||||
@@ -64,6 +69,7 @@ $view = '
|
||||
<p>'.$communication_p.'</p>
|
||||
</div>
|
||||
</div>
|
||||
'.$back_btn_orgin.'
|
||||
</div>';
|
||||
|
||||
if (isset($success_msg)){
|
||||
|
||||
@@ -9,8 +9,16 @@ if (debug && debug_id == $_SESSION['id']){
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
|
||||
//SET PAGE ORIGIN FOR NAVIGATION AND SECURITY
|
||||
$prev_page = ($_SESSION['origin'] == 'equipments') ? $_SESSION['prev_origin_equipment'] : (($_SESSION['origin'] == 'account')? $_SESSION['prev_origin'] :'');
|
||||
$page = 'contracts';
|
||||
|
||||
//create backbutton to prev_origin
|
||||
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">'.$button_back.'</a>':'';
|
||||
|
||||
//Check if allowed
|
||||
if (isAllowed('contracts',$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
exit;
|
||||
}
|
||||
@@ -58,6 +66,7 @@ $view = '
|
||||
<p>'.$contract_p .'</p>
|
||||
</div>
|
||||
</div>
|
||||
'.$back_btn_orgin.'
|
||||
</div>';
|
||||
|
||||
if (isset($success_msg)){
|
||||
|
||||
@@ -10,6 +10,8 @@ if (debug && debug_id == $_SESSION['id']){
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
//SET ORIGIN FOR NAVIGATION
|
||||
$_SESSION['prev_origin_equipment'] = $_SERVER['REQUEST_URI'];
|
||||
$page = 'equipment';
|
||||
//Check if allowed
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
@@ -276,11 +278,31 @@ if ($update_allowed === 1){
|
||||
';
|
||||
}
|
||||
|
||||
//DISPLAY RELATED COMMUNICATION RECORDS
|
||||
$soldto_id = explode("-",$partner_data->soldto) ?? '';
|
||||
$shipto_id = explode("-",$partner_data->shipto) ?? '';
|
||||
|
||||
$partner_users_id = ($shipto_id[0] != '')? $shipto_id[0] : (($soldto_id[0] != '')? $soldto_id[0] : 1);
|
||||
|
||||
$view_communication = '';
|
||||
if ($partner_users_id != 1 && ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4)){
|
||||
$view_communication = ' <a href="index.php?page=communications&partnerid='.$soldto_id[0].'" class="btn">'.$button_partner_assigned_communication.'</a>';
|
||||
}
|
||||
|
||||
//DISPLAY RELATED USERS
|
||||
$view_users ='';
|
||||
if ($partner_users_id != 1 && ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4)){
|
||||
$view_users = ' <a href="index.php?page=users&partnerid='.$soldto_id[0].'" class="btn">'.$button_partner_assigned_users.'</a>';
|
||||
}
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$view_asset_actions.'
|
||||
</div>
|
||||
<a href="index.php?page=history&equipmentID='.$_GET['equipmentID'].'" class="btn">'.$button_history.'</a>';
|
||||
<a href="index.php?page=history&equipmentID='.$_GET['equipmentID'].'" class="btn">'.$button_history.'</a>
|
||||
'.$view_communication.'
|
||||
'.$view_users.'
|
||||
';
|
||||
|
||||
if ($update_allowed === 1){
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ $button_create_communication = 'Maak communicatie';
|
||||
$button_create_account = 'Maak klant';
|
||||
$button_partner_assigned_equipment = 'Gerelateerde activa';
|
||||
$button_partner_assigned_contracts = 'Gerelateerde contracten';
|
||||
$button_partner_assigned_communication = 'Gerelateerde communicatie';
|
||||
$button_partner_assigned_users = 'Gerelateerde gebruikers';
|
||||
$button_create_contract = 'Maak contract';
|
||||
$button_create_communication_send = 'Firmware communicatie';
|
||||
$button_create_cartest = 'Maak autotest';
|
||||
|
||||
@@ -73,6 +73,8 @@ $button_create_communication = 'Create communication';
|
||||
$button_create_account = 'Create account';
|
||||
$button_partner_assigned_equipment = 'Related assets';
|
||||
$button_partner_assigned_contracts = 'Related contracts';
|
||||
$button_partner_assigned_communication = 'Related communication';
|
||||
$button_partner_assigned_users = 'Related users';
|
||||
$button_create_contract = 'Create contract';
|
||||
$button_create_communication_send = 'Firmware communication';
|
||||
$button_create_cartest = 'Create cartest';
|
||||
|
||||
2
user.php
2
user.php
@@ -175,7 +175,7 @@ $view .= '<div class="content-block tab-content active">
|
||||
<option value="0" '.(($user['userkey']==0 || $user['userkey'] =='' )?' selected':'').'>'.$disabled .'</option>
|
||||
</select>
|
||||
<label for="username">'.$User_username.'</label>
|
||||
<input id="name" type="text" name="username" placeholder="'.$User_username.'" value="'.$user['username'].'" required">
|
||||
<input id="name" type="text" name="username" placeholder="'.$User_username.'" value="'.$user['username'].'" pattern="^\S+$" required">
|
||||
<label for="username">'.$User_email.'</label>
|
||||
<input id="name" type="email" name="email" placeholder="'.$User_email.'" value="'.$user['email'].'" required">
|
||||
<label for="view">'.$User_permission.'</label>
|
||||
|
||||
@@ -8,7 +8,13 @@ defined(page_security_key) or exit;
|
||||
include_once './assets/functions.php';
|
||||
include_once './settings/settings.php';
|
||||
|
||||
//SET PAGE ORIGIN FOR NAVIGATION AND SECURITY
|
||||
$prev_page = ($_SESSION['origin'] == 'equipments') ? $_SESSION['prev_origin_equipment'] : (($_SESSION['origin'] == 'account')?$_SESSION['prev_origin'] :'');
|
||||
$page = 'users';
|
||||
|
||||
//create backbutton to prev_origin
|
||||
$back_btn_orgin = ($prev_page != '')? '<a href="'.$prev_page.'" class="btn alt mar-right-2">'.$button_back.'</a>':'';
|
||||
|
||||
//Check if allowed
|
||||
if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){
|
||||
header('location: index.php');
|
||||
@@ -64,6 +70,7 @@ $view = '
|
||||
<p>'.$users_p.'</p>
|
||||
</div>
|
||||
</div>
|
||||
'.$back_btn_orgin.'
|
||||
</div>';
|
||||
|
||||
if (isset($success_msg)){
|
||||
|
||||
Reference in New Issue
Block a user