CMXX - Changed history to equipment_history

This commit is contained in:
“VeLiTi”
2024-12-02 15:40:05 +01:00
parent 868d73c6b5
commit ad51669e32
17 changed files with 103 additions and 68 deletions

View File

@@ -56,7 +56,7 @@ case 'validateSerial':
//BUILD SQL
$whereclause = "WHERE description like '%$filter1%'";
$sql = "SELECT rowID from history $whereclause";
$sql = "SELECT rowID FROM equipment_history $whereclause";
$stmt = $pdo->prepare($sql);
$stmt->execute();
//Get results
@@ -115,11 +115,11 @@ $sn_found = 0;
switch ($_GET['type']) {
case 'latest':
if ($sn_found == 1){
$whereclause .= ' AND h.rowID in (Select MAX(h.rowID) AS row_ID FROM history h GROUP BY h.equipmentid)';
$whereclause .= ' AND h.rowID in (Select MAX(h.rowID) AS row_ID FROM equipment_history h GROUP BY h.equipmentid)';
}
else
{
$whereclause = "WHERE h.rowID in (Select MAX(h.rowID) AS row_ID FROM history h WHERE h.description like '%historycreated%' GROUP BY h.equipmentid)";
$whereclause = "WHERE h.rowID in (Select MAX(h.rowID) AS row_ID FROM equipment_history h WHERE h.description like '%historycreated%' GROUP BY h.equipmentid)";
}
break;
@@ -152,7 +152,7 @@ $sn_found = 0;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$pdo = dbConnect($dbname);
$sql = "SELECT h.rowID, h.description from history h $whereclause";
$sql = "SELECT h.rowID, h.description FROM equipment_history h $whereclause";
$stmt = $pdo->prepare($sql);
$stmt->execute();
//Get results
@@ -338,7 +338,7 @@ case 'getCartest':
//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";
$sql = "SELECT * FROM equipment_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

View File

@@ -194,10 +194,10 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Insert or update history item ++++++++++++++++++++++++
// Insert or UPDATE equipment_history item ++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ($updateObject_visual == 1){
$sql = "UPDATE history SET description = '$testdetails' WHERE rowID = ?";
$sql = "UPDATE equipment_history SET description = '$testdetails' WHERE rowID = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$visualinspectionID]);
$last_id = $visualinspectionID;
@@ -263,7 +263,7 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
changelog($dbname,'equipment',$rowID,'status',$update_status,$user);
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Update history type ++++++++++++++++++++++++++
//UPDATE equipment_history type ++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ($historyUpdate_type == 1){
//Check if servicereport comes from ServiceTool else inhouse
@@ -275,8 +275,8 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
$visualID = $post_content['testdetails']['visualinspection'];
}
//Update history record
$sql = "UPDATE history SET type = ? where rowID= ? or rowID= ?";
//UPDATE equipment_history record
$sql = "UPDATE equipment_history SET type = ? where rowID= ? or rowID= ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$type15,$visualID,$maintenanceID]);
}
@@ -305,7 +305,7 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Update history of service tool ++++++++++++++++++++++++++
// UPDATE equipment_history of service tool ++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ($servicetoolHistoryUpdate == 1 && !empty($sn_service)){
@@ -336,7 +336,7 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ($sendServiceReport == 1){
//GET STORED SERVICE REPORT
$sql = 'SELECT h.rowID as historyID, h.type, h.description, h.created, h.createdby FROM history h WHERE rowID = ?';
$sql = 'SELECT h.rowID as historyID, h.type, h.description, h.created, h.createdby FROM equipment_history h WHERE rowID = ?';
$pdo = dbConnect($dbname);
$stmt = $pdo->prepare($sql);
$stmt->execute([$last_id]);