CMXX - Cartest update

This commit is contained in:
“VeLiTi”
2024-11-13 11:57:17 +01:00
parent ccdd5b6347
commit fa1bb61712
7 changed files with 303 additions and 113 deletions

View File

@@ -2262,17 +2262,30 @@ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
$questions = json_encode($cartest["Questions"] ??'');
$datapoints = json_encode($cartest["plugDataPoints"] ?? '');
$nametester = $cartest["NameTester"] ?? 'Unknown';
$plug_sn = $cartest["SN"] ?? 0;
$accounthierarchy = '';
//get header data only
unset($cartest["Questions"]);
unset($cartest["plugDataPoints"]);
$header = json_encode($cartest);
//GET ACCOUNTHIERARCHY FROM SN OF
if ($plug_sn !=0){
$sql ='SELECT accounthierarchy FROM equipment WHERE serialnumber = ?';
$stmt = $pdo->prepare($sql);
//Excute Query
$stmt->execute([$plug_sn]);
//Get results
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
$accounthierarchy = $messages[0]['accounthierarchy'];
}
//INSERT INTO CARTEST
$sql = 'INSERT INTO cartest (carbrand, cartype,header,questions,datapoints,createdby) VALUES (?,?,?,?,?,?)';
$sql = 'INSERT INTO cartest (carbrand, cartype,header,questions,datapoints,createdby,accounthierarchy) VALUES (?,?,?,?,?,?,?)';
$stmt = $pdo->prepare($sql);
//Excute Query
$stmt->execute([$carbrand,$cartype,$header,$questions,$datapoints,$nametester]);
$stmt->execute([$carbrand,$cartype,$header,$questions,$datapoints,$nametester,$accounthierarchy]);
//MARK HISTORY ITEM FOR DELETATION
$sql = 'UPDATE history SET type = "delete" WHERE rowID = '.$message['rowID'];