CMXX - Include updated/by on multiple tables and views
This commit is contained in:
@@ -156,16 +156,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
|
||||
|
||||
@@ -125,9 +125,9 @@ switch ($action) {
|
||||
$firmware_account_send = 1;
|
||||
//create history
|
||||
// Prepare queries
|
||||
$sql = 'INSERT INTO equipment_history (equipmentid, type, description, created, createdby) VALUES (?,?,?,?,?)';
|
||||
$sql = 'INSERT INTO equipment_history (equipmentid, type, description, created, createdby,updatedby) VALUES (?,?,?,?,?,?)';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$rowID['rowID'],$type9,$description,$timestamp,$post_content['email']]);
|
||||
$stmt->execute([$rowID['rowID'],$type9,$description,$timestamp,$post_content['email'],$post_content['email']]);
|
||||
|
||||
//GET PARTNER DETAILS OF EQUIPMENT
|
||||
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
||||
@@ -193,9 +193,9 @@ switch ($action) {
|
||||
// --------------------------------------------
|
||||
// Update equipment record warranty_date, partnerhierarchy, status equipment
|
||||
// --------------------------------------------
|
||||
$sql = 'UPDATE equipment SET status = ?, warranty_date = ?, accounthierarchy = ? WHERE rowID = ?';
|
||||
$sql = 'UPDATE equipment SET status = ?, warranty_date = ?, accounthierarchy = ?,updatedby = ? WHERE rowID = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$rowID['rowID']]);
|
||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$username,$rowID['rowID']]);
|
||||
|
||||
//Add warranty to changelog
|
||||
$warranty_user = $post_content['email'] ?? 'system';
|
||||
@@ -232,9 +232,9 @@ switch ($action) {
|
||||
// --------------------------------------------
|
||||
$firmware_account_send = 1;
|
||||
//create history
|
||||
$sql = 'INSERT INTO equipment_history (equipmentid, type, description, created, createdby) VALUES (?,?,?,?,?)';
|
||||
$sql = 'INSERT INTO equipment_history (equipmentid, type, description, created, createdby, updatedby) VALUES (?,?,?,?,?,?)';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$rowID['rowID'],$type9,$description,$timestamp,$post_content['email']]);
|
||||
$stmt->execute([$rowID['rowID'],$type9,$description,$timestamp,$post_content['email'],$post_content['email']]);
|
||||
|
||||
//GET PARTNER DETAILS OF EQUIPMENT
|
||||
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
||||
@@ -299,9 +299,9 @@ switch ($action) {
|
||||
// --------------------------------------------
|
||||
// Update equipment record warranty_date, partnerhierarchy, status equipment
|
||||
// --------------------------------------------
|
||||
$sql = 'UPDATE equipment SET status = ?, warranty_date = ?, accounthierarchy = ? WHERE rowID = ?';
|
||||
$sql = 'UPDATE equipment SET status = ?, warranty_date = ?, accounthierarchy = ?, updatedby = ? WHERE rowID = ?';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$rowID['rowID']]);
|
||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$username,$rowID['rowID']]);
|
||||
|
||||
//Add warranty to changelog
|
||||
$warranty_user = $post_content['email'] ?? 'system';
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,11 +191,11 @@ if (isset($post_content['assigned_users'])){
|
||||
if (count($response) != 0){
|
||||
$id_exist_user = $response[0]['id'];
|
||||
$generate_service = bin2hex(random_bytes(25));
|
||||
$sql = 'UPDATE users SET service = ? WHERE id = ? ';
|
||||
$sql = 'UPDATE users SET service = ? , updatedby = ? WHERE id = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
if (isset($post_content['status']) && $post_content['status'] != 2){
|
||||
//Add serviceflag from user
|
||||
$stmt->execute([$generate_service,$id_exist_user]);
|
||||
$stmt->execute([$generate_service,$username,$id_exist_user]);
|
||||
}
|
||||
else {
|
||||
//Remove serviceflag from user when status is Closed
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@ $clause = '';
|
||||
$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'])){
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ $owner_user = 0;
|
||||
$id = $post_content['id'] ?? ''; //check for rowID
|
||||
$command = ($post_content['reset'])? 'reset' : ''; // change command to reset
|
||||
|
||||
$post_content['updatedby'] = $username;
|
||||
|
||||
//GET EXISTING USER DATA
|
||||
if ($id != ''){
|
||||
//Define Query
|
||||
@@ -25,9 +27,9 @@ $owner_user = (($user_data['username'] == $username)? 1 : 0);
|
||||
|
||||
|
||||
if ($command != 'reset' && $owner_user === 1 && $post_content['language']){
|
||||
$sql = 'UPDATE users SET language = ? WHERE id = ? ';
|
||||
$sql = 'UPDATE users SET language = ?, updatedby = ? WHERE id = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$post_content['language'],$id]);
|
||||
$stmt->execute([$post_content['language'],$username,$id]);
|
||||
}
|
||||
|
||||
if ($command == 'reset' && $owner_user === 1){
|
||||
@@ -36,9 +38,9 @@ $owner_user = (($user_data['username'] == $username)? 1 : 0);
|
||||
$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 = ? ';
|
||||
$sql = 'UPDATE users SET resetkey = ?, updatedby = ? WHERE id = ? ';
|
||||
$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,'','');
|
||||
|
||||
@@ -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 = (($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