From 0b4ba34ea5c4b9032fe7c34c709814d801ca5bc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”>
Date: Tue, 23 Apr 2024 17:09:31 +0200
Subject: [PATCH] CIM69 - Car database
---
api/v0/get/application.php | 18 ++
api/v1/get/cartests.php | 115 +++++++++++
api/v1/get/equipments.php | 2 +-
api/v1/post/application.php | 2 +-
api/v1/post/equipments.php | 2 +-
assets/functions.php | 1 +
cartest.php | 232 ++++++++++++++++++++++
cartests.php | 166 ++++++++++++++++
equipment_manage.php | 2 +-
equipments_mass_update.php | 10 +-
settings/translations/translations_NL.php | 32 ++-
settings/translations/translations_US.php | 32 ++-
12 files changed, 604 insertions(+), 10 deletions(-)
create mode 100644 api/v1/get/cartests.php
create mode 100644 cartest.php
create mode 100644 cartests.php
diff --git a/api/v0/get/application.php b/api/v0/get/application.php
index 3d4074a..d1da30e 100644
--- a/api/v0/get/application.php
+++ b/api/v0/get/application.php
@@ -324,5 +324,23 @@ case 'getfirmwareCommunication':
break;
+case 'getCartest':
+
+ //FILTER FOR GROUPBY FILTERS on CAR
+ $filter1 = '"CarBrand": "';
+ $filter2 = '"CarType": "';
+ $filter3 = '"CarVIN": "';
+
+ //CONNECT TO DB
+ $pdo = dbConnect($dbname);
+ $sql = "SELECT * from history where type='cartest' group by SUBSTRING_INDEX(SUBSTRING_INDEX(description, '$filter1', -1),'$filter2',1), SUBSTRING_INDEX(SUBSTRING_INDEX(description, '$filter2', -1),'$filter3',1) ORDER BY description ASC";
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute();
+ //Get results
+ $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ echo json_encode($result,JSON_UNESCAPED_UNICODE);
+break;
+
}
// end switch
diff --git a/api/v1/get/cartests.php b/api/v1/get/cartests.php
new file mode 100644
index 0000000..84c05ab
--- /dev/null
+++ b/api/v1/get/cartests.php
@@ -0,0 +1,115 @@
+prepare($sql);
+
+//Bind to query
+if (str_contains($whereclause, ':condition')){
+ $stmt->bindValue('condition', $condition, PDO::PARAM_STR);
+}
+
+if (!empty($criterias)){
+ foreach ($criterias as $key => $value){
+ $key_condition = ':'.$key;
+ if (str_contains($whereclause, $key_condition)){
+ if ($key == 'search'){
+ $search_value = '%'.$value.'%';
+ $stmt->bindValue($key, $search_value, PDO::PARAM_STR);
+ }
+ else {
+ $stmt->bindValue($key, $value, PDO::PARAM_STR);
+ }
+ }
+ }
+}
+
+//Add paging details
+if(isset($criterias['totals']) && $criterias['totals']==''){
+ $stmt->execute();
+ $messages = $stmt->fetch();
+ $messages = $messages[0];
+}
+elseif(isset($criterias['list']) && $criterias['list']==''){
+ //Excute Query
+ $stmt->execute();
+ //Get results
+ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+else {
+ $current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
+ $stmt->bindValue('page', ($current_page - 1) * $page_rows_cartest, PDO::PARAM_INT);
+ $stmt->bindValue('num_products', $page_rows_cartest, PDO::PARAM_INT);
+
+ //Excute Query
+ $stmt->execute();
+ //Get results
+ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+
+//Encrypt results
+$messages = generate_payload($messages);
+//Send results
+echo $messages;
+
+?>
\ No newline at end of file
diff --git a/api/v1/get/equipments.php b/api/v1/get/equipments.php
index 95a9b7a..f34efbc 100644
--- a/api/v1/get/equipments.php
+++ b/api/v1/get/equipments.php
@@ -109,7 +109,7 @@ if(isset($get_content) && $get_content!=''){
}
if (isset($criterias['download']) && $criterias['download'] ==''){
//Request for download
-$sql = 'SELECT e.rowID as equipmentID, e.productrowid, e.serialnumber, e.status, e.created, e.hw_version, e.sw_version, e.accounthierarchy, e.service_date, e.warranty_date, p.productcode, p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY equipmentID';
+$sql = 'SELECT e.rowID as equipmentID, e.*, p.productcode, p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY equipmentID';
}
elseif (isset($criterias['totals']) && $criterias['totals'] =='' && !isset($criterias['type'])){
//Request for total rows
diff --git a/api/v1/post/application.php b/api/v1/post/application.php
index 88db30e..13c0b5a 100644
--- a/api/v1/post/application.php
+++ b/api/v1/post/application.php
@@ -312,7 +312,7 @@ switch ($action) {
// --------------------------------------------
// Send generic account to user for software updates
// --------------------------------------------
- if ($firmware_account_send == 2){
+ if ($firmware_account_send == 1){
include_once './assets/mail/email_template_software.php';
send_mail($post_content['email'],$subject,$message,'','');
}
diff --git a/api/v1/post/equipments.php b/api/v1/post/equipments.php
index 85e1411..38b979a 100644
--- a/api/v1/post/equipments.php
+++ b/api/v1/post/equipments.php
@@ -107,7 +107,7 @@ else {
foreach ($account as $key => $value){
if ($key != "section"){
//CHECK for id- pattern
- if (preg_match('/\-.*/',$value)){
+ if (empty($value) ||$value == '' || preg_match('/\-.*/',$value)){
//Do Nothing
}
else {
diff --git a/assets/functions.php b/assets/functions.php
index 1b83f03..616b485 100644
--- a/assets/functions.php
+++ b/assets/functions.php
@@ -232,6 +232,7 @@ echo <<