CMXX - Include updated/by on multiple tables and views
This commit is contained in:
@@ -155,16 +155,16 @@ if (!isset($criterias['productrowid']) && isset($criterias['sn']) && $criterias[
|
||||
|
||||
//check if current version is send and update the equipment record
|
||||
if(isset($criterias['version']) && $criterias['version'] !=''){
|
||||
$sql = 'UPDATE equipment SET sw_version = ? WHERE serialnumber = ? ';
|
||||
$sql = 'UPDATE equipment SET sw_version = ?, updatedby = ? WHERE serialnumber = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$criterias['version'],$criterias['sn']]);
|
||||
$stmt->execute([$criterias['version'],$username,$criterias['sn']]);
|
||||
}
|
||||
|
||||
//check if current version is send and update the equipment record
|
||||
if(isset($criterias['hw_version']) && $criterias['hw_version'] !=''){
|
||||
$sql = 'UPDATE equipment SET hw_version = ? WHERE serialnumber = ? ';
|
||||
$sql = 'UPDATE equipment SET hw_version = ?, updatedby = ? WHERE serialnumber = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$criterias['hw_version'],$criterias['sn']]);
|
||||
$stmt->execute([$criterias['hw_version'],$username,$criterias['sn']]);
|
||||
}
|
||||
|
||||
//GET PRODUCTCODE, SW_VERSION_UPGRADE, HW_VERSION from equipment SN
|
||||
|
||||
@@ -58,6 +58,8 @@ if (isset($post_content['ignore_list'])){
|
||||
$post_content['ignore_list'] = array_filter($post_content['ignore_list'], 'strlen');
|
||||
}
|
||||
|
||||
$post_content['updatedby'] = $username;
|
||||
|
||||
if ($id != ''){
|
||||
|
||||
//DEFINE ACCOUNTHIERARCHY
|
||||
@@ -121,9 +123,9 @@ if ($id != ''){
|
||||
if (count($response) != 0){
|
||||
$id_removed_user = $response[0]['id'];
|
||||
//Remove serviceflag from user
|
||||
$sql = 'UPDATE users SET service = "" WHERE id = ? ';
|
||||
$sql = 'UPDATE users SET service = "", updatedby = ? WHERE id = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$id_removed_user]);
|
||||
$stmt->execute([$username,$id_removed_user]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,9 +155,11 @@ foreach ($account as $key => $value){
|
||||
// CREATE ACCOUNTHIERARCHY JSON FROM ACCOUNT ARRAY
|
||||
$accounthierarchy = json_encode($account, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$post_content['updatedby'] = $username;
|
||||
|
||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||
if ($command == 'update'){
|
||||
|
||||
|
||||
//RESET WARRANTY AND SERVICE DATES WHEN STATUS IS CHANGED TO SEND(3)
|
||||
if (isset($post_content['status']) && $post_content['status'] == 3 && $equipment_data['status'] != 3)
|
||||
{
|
||||
|
||||
@@ -183,16 +183,16 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){
|
||||
// Insert or UPDATE equipment_history item ++++++++++++++++++++++++
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
if ($updateObject_visual == 1){
|
||||
$sql = "UPDATE equipment_history SET description = '$testdetails' WHERE rowID = ?";
|
||||
$sql = "UPDATE equipment_history SET description = '$testdetails', updatedby = ? WHERE rowID = ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$visualinspectionID]);
|
||||
$stmt->execute([$user,$visualinspectionID]);
|
||||
$last_id = $visualinspectionID;
|
||||
}
|
||||
else {
|
||||
// Insert Equipment
|
||||
$sql = "INSERT INTO equipment_history (equipmentid,type,description,createdby ) VALUES (?,?,?,?)";
|
||||
$sql = "INSERT INTO equipment_history (equipmentid,type,description,createdby,updatedby ) VALUES (?,?,?,?,?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$rowID,$historytype,$testdetails,$user]);
|
||||
$stmt->execute([$rowID,$historytype,$testdetails,$user,$user]);
|
||||
$last_id = $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
@@ -262,9 +262,9 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){
|
||||
}
|
||||
|
||||
//UPDATE equipment_history record
|
||||
$sql = "UPDATE equipment_history SET type = ? where rowID= ? or rowID= ?";
|
||||
$sql = "UPDATE equipment_history SET type = ?, updatedby = ? where rowID= ? or rowID= ?";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$type15,$visualID,$maintenanceID]);
|
||||
$stmt->execute([$type15,$user,$visualID,$maintenanceID]);
|
||||
}
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//Update productcode on equipment ++++++++++++++++++++++++++
|
||||
@@ -308,9 +308,9 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){
|
||||
|
||||
if($total_servicetool != 0){
|
||||
// Insert historyitem
|
||||
$sql = "INSERT INTO equipment_history (equipmentid,type,description,createdby) VALUES (?,?,?,?)";
|
||||
$sql = "INSERT INTO equipment_history (equipmentid,type,description,createdby,updatedby) VALUES (?,?,?,?,?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user]);
|
||||
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user,$user]);
|
||||
//Update status to InUse
|
||||
$sql = "UPDATE equipment SET status = ? $whereclause";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
@@ -353,6 +353,8 @@ else {
|
||||
$clause_insert ='';
|
||||
$input_insert = '';
|
||||
|
||||
$post_content['updatedby'] = $username;
|
||||
|
||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||
if ($command == 'update' && !isset($post_content['delete'])){
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ $clause = '';
|
||||
$clause_insert ='';
|
||||
$input_insert = '';
|
||||
|
||||
$post_content['updatedby'] = $username;
|
||||
|
||||
//GET EXISTING USER DATA
|
||||
if ($id != '' && $command != 'reset'){
|
||||
//Define Query
|
||||
@@ -130,9 +132,9 @@ $location_new = ((isset($post_content['location']) && $post_content['location']
|
||||
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
||||
$resetkey = generate_jwt($headers, $payload);
|
||||
//STEP 2- Store resetkey
|
||||
$sql = 'UPDATE users SET resetkey = ? WHERE id = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE users SET resetkey = ?, updatedby = ? WHERE id = ? '.$whereclause.'';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$resetkey,$id]);
|
||||
$stmt->execute([$resetkey,$username,$id]);
|
||||
//STEP 3 - Send to user
|
||||
include_once './assets/mail/email_template_reset.php';
|
||||
send_mail($user_data['email'],$subject,$message,'','');
|
||||
|
||||
Reference in New Issue
Block a user