function is_working_day($datecalc) { global $config; $date_formated = $datecalc; $datecalc = strtotime($datecalc); $date1 = getdate($datecalc); if ($date1["wday"] == 0 or $date1["wday"] == 6) { //Check if weekends are working days or not if ($config["working_weekends"]) { return 1; } else { return 0; } } else { if (is_holidays($date_formated)) { return 0; } } return 1; }
function check_incident_sla_max_response($id_incident) { $incident = get_incident($id_incident); $sla_info = incidents_get_sla_info($incident['id_grupo']); if ($sla_info != false) { $id_sla_type = $sla_info['id_sla_type']; switch ($id_sla_type) { case 0: //NORMAL SLA /* If closed, disable any affected SLA */ if ($incident['estado'] == 6 || $incident['estado'] == 7) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; case 1: //THIRD PARTY SLA /* If closed, disable any affected SLA */ if ($incident['estado'] != 6) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; case 2: //NORMAL SLA AND THIRD PARTY SLA if ($incident['estado'] == 7) { if ($incident['affected_sla_id']) { $sql = sprintf('UPDATE tincidencia SET affected_sla_id = 0 WHERE id_incidencia = %d', $id_incident); process_sql($sql); } return false; } break; } } $slas = incidents_get_incident_slas($id_incident, false); $start = strtotime($incident['inicio']); $now = time(); foreach ($slas as $sla) { // Datetime/Time check when exists (version compatibility code), this // was added as a 3.0 post-feature :-) if (isset($sla["five_daysonly"]) || isset($sla["no_holidays"])) { $dow = date("w", time()); $hod = date("G", time()); // Skip if we're on weekend if ($sla["five_daysonly"] == 1 and ($dow == 0 or $dow == 6)) { continue; } //Check if holidays enabled and today is holidays $datecalc = date("Y-m-d", time()) . ' 00:00:00'; if ($sla["no_holidays"] == 1 and is_holidays($datecalc)) { continue; } // Skip if we're out of job time if ($sla["time_from"] != $sla["time_to"]) { if ($sla["time_from"] > $hod or $sla["time_to"] < $hod) { continue; } } } if ($now < $start + $sla['max_response'] * 3600) { continue; } $sql = sprintf('UPDATE tincidencia SET affected_sla_id = %d WHERE id_incidencia = %d', $sla['id'], $id_incident); process_sql($sql); /* SLA has expired */ return $sla['id']; } return false; }