CM89 - expired contract handling

This commit is contained in:
“VeLiTi”
2024-09-25 12:01:18 +02:00
parent ffb29b731a
commit ae821d3870
16 changed files with 923 additions and 159 deletions

View File

@@ -53,6 +53,11 @@ if (isset($post_content['assigned_users'])){
$post_content['assigned_users'] = array_map('trim', $post_content['assigned_users']);
$post_content['assigned_users'] = array_filter($post_content['assigned_users'], 'strlen');
}
if (isset($post_content['ignore_list'])){
$post_content['ignore_list'] = array_map('trim', $post_content['ignore_list']);
$post_content['ignore_list'] = array_filter($post_content['ignore_list'], 'strlen');
}
if ($id != ''){
//DEFINE ACCOUNTHIERARCHY
@@ -165,6 +170,13 @@ if ($command == 'insert' && !isset($post_content['delete'])){
if (isset($post_content['servicetool'])){
$post_content['servicetool'] = json_encode($post_content['servicetool'], JSON_UNESCAPED_UNICODE);
}
if (isset($post_content['ignore_list'])){
$post_content['ignore_list'] = json_encode($post_content['ignore_list'], JSON_UNESCAPED_UNICODE);
//ONLY ADMINS ARE ALLOWED TO UPDATE IGNORE LIST
if ($permission != 3 && $permission != 4){
unset($post_content['ignore_list']);
}
}
if (isset($post_content['assigned_users'])){
//Check for all users in array if exist then update service or create
foreach ($post_content['assigned_users'] as $user_assigned){
@@ -177,10 +189,16 @@ if (isset($post_content['assigned_users'])){
if (count($response) != 0){
$id_exist_user = $response[0]['id'];
$generate_service = bin2hex(random_bytes(25));
//Remove serviceflag from user
$sql = 'UPDATE users SET service = ? WHERE id = ? ';
$stmt = $pdo->prepare($sql);
$stmt->execute([$generate_service,$id_exist_user]);
if (isset($post_content['status']) && $post_content['status'] != 2){
//Add serviceflag from user
$stmt->execute([$generate_service,$id_exist_user]);
}
else {
//Remove serviceflag from user when status is Closed
$stmt->execute(['',$id_exist_user]);
}
} else {
//Decode the account structure of the contract and create user
$ah_array = json_decode($post_content['accounthierarchy'],true);