CMXX - Include updated/by on multiple tables and views
This commit is contained in:
@@ -197,16 +197,16 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
|
|||||||
// Insert or UPDATE equipment_history item ++++++++++++++++++++++++
|
// Insert or UPDATE equipment_history item ++++++++++++++++++++++++
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
if ($updateObject_visual == 1){
|
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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$visualinspectionID]);
|
$stmt->execute([$user,$visualinspectionID]);
|
||||||
$last_id = $visualinspectionID;
|
$last_id = $visualinspectionID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Insert Equipment
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$rowID,$historytype,$testdetails,$user]);
|
$stmt->execute([$rowID,$historytype,$testdetails,$user,$user]);
|
||||||
$last_id = $pdo->lastInsertId();
|
$last_id = $pdo->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +276,9 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//UPDATE equipment_history record
|
//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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$type15,$visualID,$maintenanceID]);
|
$stmt->execute([$type15,$user,$visualID,$maintenanceID]);
|
||||||
}
|
}
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
//Update productcode on equipment ++++++++++++++++++++++++++
|
//Update productcode on equipment ++++++++++++++++++++++++++
|
||||||
@@ -322,9 +322,9 @@ if (!empty($post_content['sn']) && !empty($post_content['testdetails'])) {
|
|||||||
|
|
||||||
if($total_servicetool != 0){
|
if($total_servicetool != 0){
|
||||||
// Insert historyitem
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user]);
|
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user,$user]);
|
||||||
//Update status to InUse
|
//Update status to InUse
|
||||||
$sql = "UPDATE equipment SET status = ? $whereclause";
|
$sql = "UPDATE equipment SET status = ? $whereclause";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
|
|||||||
@@ -156,16 +156,16 @@ if (!isset($criterias['productrowid']) && isset($criterias['sn']) && $criterias[
|
|||||||
|
|
||||||
//check if current version is send and update the equipment record
|
//check if current version is send and update the equipment record
|
||||||
if(isset($criterias['version']) && $criterias['version'] !=''){
|
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 = $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
|
//check if current version is send and update the equipment record
|
||||||
if(isset($criterias['hw_version']) && $criterias['hw_version'] !=''){
|
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 = $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
|
//GET PRODUCTCODE, SW_VERSION_UPGRADE, HW_VERSION from equipment SN
|
||||||
|
|||||||
@@ -125,9 +125,9 @@ switch ($action) {
|
|||||||
$firmware_account_send = 1;
|
$firmware_account_send = 1;
|
||||||
//create history
|
//create history
|
||||||
// Prepare queries
|
// 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 = $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
|
//GET PARTNER DETAILS OF EQUIPMENT
|
||||||
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
||||||
@@ -193,9 +193,9 @@ switch ($action) {
|
|||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// Update equipment record warranty_date, partnerhierarchy, status equipment
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$rowID['rowID']]);
|
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$username,$rowID['rowID']]);
|
||||||
|
|
||||||
//Add warranty to changelog
|
//Add warranty to changelog
|
||||||
$warranty_user = $post_content['email'] ?? 'system';
|
$warranty_user = $post_content['email'] ?? 'system';
|
||||||
@@ -232,9 +232,9 @@ switch ($action) {
|
|||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
$firmware_account_send = 1;
|
$firmware_account_send = 1;
|
||||||
//create history
|
//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 = $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
|
//GET PARTNER DETAILS OF EQUIPMENT
|
||||||
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
$partner_equipment = getrowID($dbname,'accounthierarchy','equipment','rowID="'.$rowID['rowID'].'"');
|
||||||
@@ -299,9 +299,9 @@ switch ($action) {
|
|||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// Update equipment record warranty_date, partnerhierarchy, status equipment
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$rowID['rowID']]);
|
$stmt->execute(['4',$warranty_extended,$partnerhierarchy,$username,$rowID['rowID']]);
|
||||||
|
|
||||||
//Add warranty to changelog
|
//Add warranty to changelog
|
||||||
$warranty_user = $post_content['email'] ?? 'system';
|
$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['ignore_list'] = array_filter($post_content['ignore_list'], 'strlen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
if ($id != ''){
|
if ($id != ''){
|
||||||
|
|
||||||
//DEFINE ACCOUNTHIERARCHY
|
//DEFINE ACCOUNTHIERARCHY
|
||||||
@@ -121,9 +123,9 @@ if ($id != ''){
|
|||||||
if (count($response) != 0){
|
if (count($response) != 0){
|
||||||
$id_removed_user = $response[0]['id'];
|
$id_removed_user = $response[0]['id'];
|
||||||
//Remove serviceflag from user
|
//Remove serviceflag from user
|
||||||
$sql = 'UPDATE users SET service = "" WHERE id = ? ';
|
$sql = 'UPDATE users SET service = "", updatedby = ? WHERE id = ? ';
|
||||||
$stmt = $pdo->prepare($sql);
|
$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){
|
if (count($response) != 0){
|
||||||
$id_exist_user = $response[0]['id'];
|
$id_exist_user = $response[0]['id'];
|
||||||
$generate_service = bin2hex(random_bytes(25));
|
$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);
|
$stmt = $pdo->prepare($sql);
|
||||||
if (isset($post_content['status']) && $post_content['status'] != 2){
|
if (isset($post_content['status']) && $post_content['status'] != 2){
|
||||||
//Add serviceflag from user
|
//Add serviceflag from user
|
||||||
$stmt->execute([$generate_service,$id_exist_user]);
|
$stmt->execute([$generate_service,$username,$id_exist_user]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Remove serviceflag from user when status is Closed
|
//Remove serviceflag from user when status is Closed
|
||||||
|
|||||||
@@ -155,9 +155,11 @@ foreach ($account as $key => $value){
|
|||||||
// CREATE ACCOUNTHIERARCHY JSON FROM ACCOUNT ARRAY
|
// CREATE ACCOUNTHIERARCHY JSON FROM ACCOUNT ARRAY
|
||||||
$accounthierarchy = json_encode($account, JSON_UNESCAPED_UNICODE);
|
$accounthierarchy = json_encode($account, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
if ($command == 'update'){
|
if ($command == 'update'){
|
||||||
|
|
||||||
//RESET WARRANTY AND SERVICE DATES WHEN STATUS IS CHANGED TO SEND(3)
|
//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)
|
if (isset($post_content['status']) && $post_content['status'] == 3 && $equipment_data['status'] != 3)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ $clause = '';
|
|||||||
$clause_insert ='';
|
$clause_insert ='';
|
||||||
$input_insert = '';
|
$input_insert = '';
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
if ($command == 'update' && !isset($post_content['delete'])){
|
if ($command == 'update' && !isset($post_content['delete'])){
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ $owner_user = 0;
|
|||||||
$id = $post_content['id'] ?? ''; //check for rowID
|
$id = $post_content['id'] ?? ''; //check for rowID
|
||||||
$command = ($post_content['reset'])? 'reset' : ''; // change command to reset
|
$command = ($post_content['reset'])? 'reset' : ''; // change command to reset
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//GET EXISTING USER DATA
|
//GET EXISTING USER DATA
|
||||||
if ($id != ''){
|
if ($id != ''){
|
||||||
//Define Query
|
//Define Query
|
||||||
@@ -25,9 +27,9 @@ $owner_user = (($user_data['username'] == $username)? 1 : 0);
|
|||||||
|
|
||||||
|
|
||||||
if ($command != 'reset' && $owner_user === 1 && $post_content['language']){
|
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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$post_content['language'],$id]);
|
$stmt->execute([$post_content['language'],$username,$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($command == 'reset' && $owner_user === 1){
|
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));
|
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
||||||
$resetkey = generate_jwt($headers, $payload);
|
$resetkey = generate_jwt($headers, $payload);
|
||||||
//STEP 2- Store resetkey
|
//STEP 2- Store resetkey
|
||||||
$sql = 'UPDATE users SET resetkey = ? WHERE id = ? ';
|
$sql = 'UPDATE users SET resetkey = ?, updatedby = ? WHERE id = ? ';
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute([$resetkey,$id]);
|
$stmt->execute([$resetkey,$username,$id]);
|
||||||
//STEP 3 - Send to user
|
//STEP 3 - Send to user
|
||||||
include_once './assets/mail/email_template_reset.php';
|
include_once './assets/mail/email_template_reset.php';
|
||||||
send_mail($user_data['email'],$subject,$message,'','');
|
send_mail($user_data['email'],$subject,$message,'','');
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ $clause = '';
|
|||||||
$clause_insert ='';
|
$clause_insert ='';
|
||||||
$input_insert = '';
|
$input_insert = '';
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//GET EXISTING USER DATA
|
//GET EXISTING USER DATA
|
||||||
if ($id != '' && $command != 'reset'){
|
if ($id != '' && $command != 'reset'){
|
||||||
//Define Query
|
//Define Query
|
||||||
@@ -130,9 +132,9 @@ $location_new = (($post_content['location'] != '' && $post_content['location'] !
|
|||||||
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
||||||
$resetkey = generate_jwt($headers, $payload);
|
$resetkey = generate_jwt($headers, $payload);
|
||||||
//STEP 2- Store resetkey
|
//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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$resetkey,$id]);
|
$stmt->execute([$resetkey,$username,$id]);
|
||||||
//STEP 3 - Send to user
|
//STEP 3 - Send to user
|
||||||
include_once './assets/mail/email_template_reset.php';
|
include_once './assets/mail/email_template_reset.php';
|
||||||
send_mail($user_data['email'],$subject,$message,'','');
|
send_mail($user_data['email'],$subject,$message,'','');
|
||||||
|
|||||||
@@ -155,16 +155,16 @@ if (!isset($criterias['productrowid']) && isset($criterias['sn']) && $criterias[
|
|||||||
|
|
||||||
//check if current version is send and update the equipment record
|
//check if current version is send and update the equipment record
|
||||||
if(isset($criterias['version']) && $criterias['version'] !=''){
|
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 = $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
|
//check if current version is send and update the equipment record
|
||||||
if(isset($criterias['hw_version']) && $criterias['hw_version'] !=''){
|
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 = $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
|
//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['ignore_list'] = array_filter($post_content['ignore_list'], 'strlen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
if ($id != ''){
|
if ($id != ''){
|
||||||
|
|
||||||
//DEFINE ACCOUNTHIERARCHY
|
//DEFINE ACCOUNTHIERARCHY
|
||||||
@@ -121,9 +123,9 @@ if ($id != ''){
|
|||||||
if (count($response) != 0){
|
if (count($response) != 0){
|
||||||
$id_removed_user = $response[0]['id'];
|
$id_removed_user = $response[0]['id'];
|
||||||
//Remove serviceflag from user
|
//Remove serviceflag from user
|
||||||
$sql = 'UPDATE users SET service = "" WHERE id = ? ';
|
$sql = 'UPDATE users SET service = "", updatedby = ? WHERE id = ? ';
|
||||||
$stmt = $pdo->prepare($sql);
|
$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
|
// CREATE ACCOUNTHIERARCHY JSON FROM ACCOUNT ARRAY
|
||||||
$accounthierarchy = json_encode($account, JSON_UNESCAPED_UNICODE);
|
$accounthierarchy = json_encode($account, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
if ($command == 'update'){
|
if ($command == 'update'){
|
||||||
|
|
||||||
//RESET WARRANTY AND SERVICE DATES WHEN STATUS IS CHANGED TO SEND(3)
|
//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)
|
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 ++++++++++++++++++++++++
|
// Insert or UPDATE equipment_history item ++++++++++++++++++++++++
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
if ($updateObject_visual == 1){
|
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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$visualinspectionID]);
|
$stmt->execute([$user,$visualinspectionID]);
|
||||||
$last_id = $visualinspectionID;
|
$last_id = $visualinspectionID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Insert Equipment
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$rowID,$historytype,$testdetails,$user]);
|
$stmt->execute([$rowID,$historytype,$testdetails,$user,$user]);
|
||||||
$last_id = $pdo->lastInsertId();
|
$last_id = $pdo->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,9 +262,9 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//UPDATE equipment_history record
|
//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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$type15,$visualID,$maintenanceID]);
|
$stmt->execute([$type15,$user,$visualID,$maintenanceID]);
|
||||||
}
|
}
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
//Update productcode on equipment ++++++++++++++++++++++++++
|
//Update productcode on equipment ++++++++++++++++++++++++++
|
||||||
@@ -308,9 +308,9 @@ if (isset($post_content['sn']) && isset($post_content['payload'])){
|
|||||||
|
|
||||||
if($total_servicetool != 0){
|
if($total_servicetool != 0){
|
||||||
// Insert historyitem
|
// 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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user]);
|
$stmt->execute([$rowID_servicetool,$historytype,$testdetails,$user,$user]);
|
||||||
//Update status to InUse
|
//Update status to InUse
|
||||||
$sql = "UPDATE equipment SET status = ? $whereclause";
|
$sql = "UPDATE equipment SET status = ? $whereclause";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
@@ -353,6 +353,8 @@ else {
|
|||||||
$clause_insert ='';
|
$clause_insert ='';
|
||||||
$input_insert = '';
|
$input_insert = '';
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
if ($command == 'update' && !isset($post_content['delete'])){
|
if ($command == 'update' && !isset($post_content['delete'])){
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ $clause = '';
|
|||||||
$clause_insert ='';
|
$clause_insert ='';
|
||||||
$input_insert = '';
|
$input_insert = '';
|
||||||
|
|
||||||
|
$post_content['updatedby'] = $username;
|
||||||
|
|
||||||
//GET EXISTING USER DATA
|
//GET EXISTING USER DATA
|
||||||
if ($id != '' && $command != 'reset'){
|
if ($id != '' && $command != 'reset'){
|
||||||
//Define Query
|
//Define Query
|
||||||
@@ -130,9 +132,9 @@ $location_new = ((isset($post_content['location']) && $post_content['location']
|
|||||||
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
$payload = array('username'=>$user_data['username'], 'exp'=>(time() + 1800));
|
||||||
$resetkey = generate_jwt($headers, $payload);
|
$resetkey = generate_jwt($headers, $payload);
|
||||||
//STEP 2- Store resetkey
|
//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 = $pdo->prepare($sql);
|
||||||
$stmt->execute([$resetkey,$id]);
|
$stmt->execute([$resetkey,$username,$id]);
|
||||||
//STEP 3 - Send to user
|
//STEP 3 - Send to user
|
||||||
include_once './assets/mail/email_template_reset.php';
|
include_once './assets/mail/email_template_reset.php';
|
||||||
send_mail($user_data['email'],$subject,$message,'','');
|
send_mail($user_data['email'],$subject,$message,'','');
|
||||||
|
|||||||
@@ -2283,7 +2283,7 @@ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
$stmt->execute([$carbrand,$cartype,$header,$questions,$datapoints,$nametester,$accounthierarchy]);
|
$stmt->execute([$carbrand,$cartype,$header,$questions,$datapoints,$nametester,$accounthierarchy]);
|
||||||
|
|
||||||
//MARK HISTORY ITEM FOR DELETATION
|
//MARK HISTORY ITEM FOR DELETATION
|
||||||
$sql = 'UPDATE equipment_history SET type = "delete" WHERE rowID = '.$message['rowID'];
|
$sql = 'UPDATE equipment_history SET type = "delete", updatedby = "system" WHERE rowID = '.$message['rowID'];
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
//Excute Query
|
//Excute Query
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -2477,9 +2477,9 @@ foreach ($messages as $message){
|
|||||||
//Validate if contract end date is in the past change contact status to closed and set users to not active
|
//Validate if contract end date is in the past change contact status to closed and set users to not active
|
||||||
if (date("Y-m-d") > $end_date){
|
if (date("Y-m-d") > $end_date){
|
||||||
//Contract expired -> change status to closed (2)
|
//Contract expired -> change status to closed (2)
|
||||||
$sql = 'UPDATE contracts SET status = ? WHERE rowID = ?';
|
$sql = 'UPDATE contracts SET status = ?, updatedby = ? WHERE rowID = ?';
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute([2,$message['rowID']]);
|
$stmt->execute([2,"system",$message['rowID']]);
|
||||||
|
|
||||||
//CHECK FOR ASSIGNED USER END SET SERVICE TO INACTIVE
|
//CHECK FOR ASSIGNED USER END SET SERVICE TO INACTIVE
|
||||||
foreach (json_decode($message['assigned_users']) as $user_assigned){
|
foreach (json_decode($message['assigned_users']) as $user_assigned){
|
||||||
|
|||||||
@@ -351,6 +351,14 @@ $view .= '<div class="content-block">
|
|||||||
<td style="width:25%;">'.$general_createdby.'</td>
|
<td style="width:25%;">'.$general_createdby.'</td>
|
||||||
<td>'.$responses->createdby.'</td>
|
<td>'.$responses->createdby.'</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:25%;">'.$general_updated.'</td>
|
||||||
|
<td>'.getRelativeTime($responses->updated).'</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:25%;">'.$general_updatedby.'</td>
|
||||||
|
<td>'.$responses->updatedby.'</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ $contract = [
|
|||||||
'contract_details' => '',
|
'contract_details' => '',
|
||||||
'created' => '',
|
'created' => '',
|
||||||
'createdby' => '',
|
'createdby' => '',
|
||||||
|
'updated' => '',
|
||||||
|
'updatedby' => '',
|
||||||
'billing_plan' => '',
|
'billing_plan' => '',
|
||||||
'pricing' => '',
|
'pricing' => '',
|
||||||
'reference' => '',
|
'reference' => '',
|
||||||
@@ -276,7 +278,11 @@ $view .= '<div class="content-block tab-content">
|
|||||||
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$contract['created'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$contract['created'].'" readonly>
|
||||||
<label for="">'.$general_createdby.'</label>
|
<label for="">'.$general_createdby.'</label>
|
||||||
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$contract['createdby'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$contract['createdby'].'" readonly>
|
||||||
<input id="name" type="hidden" name="rowID" value="'.$contract['rowID'].'" readonly>
|
<label for="productcode">'.$general_updated.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.$contract['updated'].'" readonly>
|
||||||
|
<label for="productcode">'.$general_updatedby.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$contract['updatedby'].'" readonly>
|
||||||
|
<input id="name" type="hidden" name="rowID" value="'.$contract['rowID'].'" readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
|||||||
@@ -360,6 +360,10 @@ $view .= '<div class="content-block">
|
|||||||
<td style="width:25%;">'.$general_created.'</td>
|
<td style="width:25%;">'.$general_created.'</td>
|
||||||
<td>'.getRelativeTime($responses->created).'</td>
|
<td>'.getRelativeTime($responses->created).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:25%;">'.$general_updated.'</td>
|
||||||
|
<td>'.getRelativeTime($responses->updated).'</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ $equipment = [
|
|||||||
'service_date' => $date,
|
'service_date' => $date,
|
||||||
'warranty_date' => $date,
|
'warranty_date' => $date,
|
||||||
'order_ref' => '',
|
'order_ref' => '',
|
||||||
'geolocation' => []
|
'geolocation' => [],
|
||||||
|
'updated' =>'',
|
||||||
|
'updatedby' =>''
|
||||||
];
|
];
|
||||||
|
|
||||||
$equipment_ID = $_GET['equipmentID'] ?? '';
|
$equipment_ID = $_GET['equipmentID'] ?? '';
|
||||||
@@ -264,6 +266,10 @@ $view .= '<div class="content-block tab-content">
|
|||||||
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$equipment['created'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$equipment['created'].'" readonly>
|
||||||
<label for="productcode">'.$general_createdby.'</label>
|
<label for="productcode">'.$general_createdby.'</label>
|
||||||
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$equipment['createdby'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$equipment['createdby'].'" readonly>
|
||||||
|
<label for="productcode">'.$general_updated.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.$equipment['updated'].'" readonly>
|
||||||
|
<label for="productcode">'.$general_updatedby.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$equipment['updatedby'].'" readonly>
|
||||||
<label for="productcode">'.$equipment_label11.'</label>
|
<label for="productcode">'.$equipment_label11.'</label>
|
||||||
<input id="name" type="text" name="order_ref" placeholder="'.$equipment_label11.'" value="'.$equipment['order_ref'].'">
|
<input id="name" type="text" name="order_ref" placeholder="'.$equipment_label11.'" value="'.$equipment['order_ref'].'">
|
||||||
<label for="productcode">'.$equipment_label12.'</label>
|
<label for="productcode">'.$equipment_label12.'</label>
|
||||||
|
|||||||
7
user.php
7
user.php
@@ -23,6 +23,9 @@ $user = [
|
|||||||
'settings' => '',
|
'settings' => '',
|
||||||
'userkey' => 1,
|
'userkey' => 1,
|
||||||
'created' => '',
|
'created' => '',
|
||||||
|
'createdby' => '',
|
||||||
|
'updated' => '',
|
||||||
|
'updatedby' => '',
|
||||||
'lastlogin' => '',
|
'lastlogin' => '',
|
||||||
'language' => 'US',
|
'language' => 'US',
|
||||||
'login_count' => 0
|
'login_count' => 0
|
||||||
@@ -300,6 +303,10 @@ $view .= '<div class="content-block tab-content">
|
|||||||
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$user['created'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$user['created'].'" readonly>
|
||||||
<label for="">'.$User_lastlogin.'</label>
|
<label for="">'.$User_lastlogin.'</label>
|
||||||
<input id="name" type="text" name="" placeholder="'.$User_lastlogin.'" value="'.$user['lastlogin'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$User_lastlogin.'" value="'.$user['lastlogin'].'" readonly>
|
||||||
|
<label for="productcode">'.$general_updated.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.$equipment['updated'].'" readonly>
|
||||||
|
<label for="productcode">'.$general_updatedby.'</label>
|
||||||
|
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$equipment['updatedby'].'" readonly>
|
||||||
<label for="">'.$User_pw_login_count.'</label>
|
<label for="">'.$User_pw_login_count.'</label>
|
||||||
'.$login_count.'
|
'.$login_count.'
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user