CM89 - expired contract handling
This commit is contained in:
@@ -65,7 +65,7 @@ if(isset($get_content) && $get_content!=''){
|
||||
$v = explode("=", $y);
|
||||
//INCLUDE VARIABLES IN ARRAY
|
||||
$criterias[$v[0]] = $v[1];
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='target' || $v[0] =='success_msg'){
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='between' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='target' || $v[0] =='success_msg'){
|
||||
//do nothing
|
||||
}
|
||||
elseif ($v[0] == 'serialnumber') {
|
||||
@@ -89,15 +89,42 @@ if(isset($get_content) && $get_content!=''){
|
||||
$clause .= ' AND e.serialnumber IN ('.$new_querystring.')';
|
||||
//remove original key/value from array
|
||||
unset($criterias[$v[0]]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$clause .= ' AND e.serialnumber IN (:'.$v[0].')';
|
||||
}
|
||||
}
|
||||
elseif ($v[0] == 'ignore') {
|
||||
//build up serialnumbers to ignore
|
||||
//check if multiple serialnumbers are provided
|
||||
if (str_contains($v[1], ',')){
|
||||
$inputs = explode(",",$v[1]);
|
||||
$x=0;
|
||||
foreach($inputs as $input){
|
||||
//create key
|
||||
$new_key = $v[0].'_'.$x;
|
||||
//inject new key/value to array
|
||||
$criterias[$new_key] = '%serialnumber%'.$input.'%';
|
||||
$clause .= ' AND h.description not like :'.$new_key.'';
|
||||
$x++;
|
||||
}
|
||||
//remove original key/value from array
|
||||
unset($criterias[$v[0]]);
|
||||
}
|
||||
else {
|
||||
$criterias[$v[0]] = '%serialnumber%'.$v[1].'%';
|
||||
$clause .= ' AND h.description not like :'.$v[0].'';
|
||||
}
|
||||
}
|
||||
else {//create clause
|
||||
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||
}
|
||||
}
|
||||
if (isset($criterias['between']) && $criterias['between'] !=''){
|
||||
//ADD BETWEEN STATEMENT IF BETWEEN IS IN URL
|
||||
//BETWEEN delim ||
|
||||
$clause .= ' AND (h.created BETWEEN :start AND :end)';
|
||||
}
|
||||
if ($whereclause == '' && $clause !=''){
|
||||
$whereclause = 'WHERE '.substr($clause, 4);
|
||||
} else {
|
||||
@@ -221,6 +248,13 @@ if (!empty($criterias)){
|
||||
if (str_contains($whereclause, $key_condition)){
|
||||
$stmt->bindValue($key, $value, PDO::PARAM_STR);
|
||||
}
|
||||
//CHECK IF BETWEEN STATEMENT IS SENT
|
||||
if (str_contains($whereclause, ':start') && str_contains($whereclause, ':end')){
|
||||
//DATES ARE DELIM WITH ||
|
||||
$dates = explode("||", $value);
|
||||
$stmt->bindValue('start', $dates[0], PDO::PARAM_STR);
|
||||
$stmt->bindValue('end', $dates[1], PDO::PARAM_STR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user