top.window.location = '../../index.php'"; exit; } require_once __DIR__ . "/" . "../../includes/include_basics_only.php"; require_once __DIR__ . "/" . "../../includes/classes/ConnectPDO.php"; require_once __DIR__ . "/" . "../../includes/classes/worktime/Worktime.php"; include_once __DIR__ . "/" . "../../includes/functions/getWorktimeProfile.php"; require_once __DIR__ . "/" . "../../includes/components/html2text-master/vendor/autoload.php"; $auth = new AuthNew($_SESSION['s_logado'], $_SESSION['s_nivel'], 2, 1); use includes\classes\ConnectPDO; $conn = ConnectPDO::getInstance(); $uareas = $_SESSION['s_uareas']; $post = (isset($_POST) ? $_POST : ''); $imgsPath = "../../includes/imgs/"; $iconFrozen = ""; $iconOutOfWorktime = ""; $iconTicketClosed = ""; $config = getConfig($conn); $percLimit = $config['conf_sla_tolerance']; $exception = ""; $calc_slas = (isset($post['calc_slas']) && $post['calc_slas'] == 'on' ? true : false); $options = [ 'area' => [ 'label' => TRANS('SERVICE_AREA'), 'table' => 'sistemas', 'field_id' => 'sis_id', 'field_name' => 'sistema', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'sistema', 'sql_alias' => 'o.sistema', 'alias' => 'ar', 'value' => '' ], 'status' => [ 'label' => TRANS('COL_STATUS'), 'table' => 'status', 'field_id' => 'stat_id', 'field_name' => 'status', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'status', 'sql_alias' => 'o.status', 'alias' => 'st', 'value' => '' ], 'client' => [ 'label' => TRANS('CLIENT'), 'table' => 'clients', 'field_id' => 'id', 'field_name' => 'nickname', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'client', 'sql_alias' => 'cl.id', 'alias' => 'cl', 'value' => '' ], 'requester_area' => [ 'label' => TRANS('REQUESTER_AREA'), 'table' => 'sistemas', 'field_id' => 'sis_id', 'field_name' => 'sistema', 'table_reference' => 'usuarios', 'table_reference_alias' => 'ua', 'field_reference' => 'AREA', 'sql_alias' => 'asol.sis_id', 'alias' => 'uar', 'value' => '' ], 'priority' => [ 'label' => TRANS('COL_PRIORITY'), 'table' => 'prior_atend', 'field_id' => 'pr_cod', 'field_name' => 'pr_desc', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'oco_prior', 'sql_alias' => 'o.oco_prior', 'alias' => 'pr', 'value' => '' ], 'issue_type' => [ 'label' => TRANS('ISSUE_TYPE'), 'table' => 'problemas', 'field_id' => 'prob_id', 'field_name' => 'problema', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'problema', 'sql_alias' => 'p.prob_id', 'alias' => 'prob', 'value' => '' ], 'department' => [ 'label' => TRANS('DEPARTMENT'), 'table' => 'localizacao', 'field_id' => 'loc_id', 'field_name' => 'local', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'local', 'sql_alias' => 'l.loc_id', 'alias' => 'loc', 'value' => '' ], 'unit' => [ 'label' => TRANS('COL_UNIT'), 'table' => 'instituicao', 'field_id' => 'inst_cod', 'field_name' => 'inst_nome', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'instituicao', 'sql_alias' => 'i.inst_cod', 'alias' => 'un', 'value' => '' ], 'opened_by' => [ 'label' => TRANS('OPENED_BY'), 'table' => 'usuarios', 'field_id' => 'user_id', 'field_name' => 'nome', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'aberto_por', 'sql_alias' => 'o.aberto_por', 'alias' => 'ua', 'value' => '' ], 'authorization_status' => [ 'label' => TRANS('AUTHORIZATION_STATUS'), 'table' => 'authorization_status', 'field_id' => 'id', 'field_name' => 'name_key', 'table_reference' => 'ocorrencias', 'table_reference_alias' => 'o', 'field_reference' => 'authorization_status', 'sql_alias' => 'o.authorization_status', 'alias' => 'aus', 'value' => '' ] ]; if (!empty($post)) { /* Níveis possíveis de agrupamento */ $groups = [ 'group_1' => '', 'group_2' => '', 'group_3' => '', 'group_4' => '', 'group_5' => '', ]; foreach ($groups as $key => $group) { if (!empty($post[$key])) { $groups[$key] = $post[$key]; } else { unset($groups[$key]); } } $table_id = $post['params']; $params = []; if (isset($post['params']) && !empty($post['params'])) { /* Tratamento quando o último parâmetro for de valor nulo */ if (substr($post['params'], -1) == '-') { $post['params'] .= '0'; } $params = explode('--', str_replace('---','-0--', $post['params'])); } $tmp = []; /** Adicionando o valor para pesquisa no array principal $options */ foreach ($params as $param) { $tmp = explode('-' , $param); $options[$tmp[0]]['value'] = (array_key_exists(1, $tmp) ? $tmp[1] : '0'); } /* Monta os termos de pesquisa para a consulta SQL que exibirá a tabela de chamados */ $sql_terms = ""; foreach ($options as $key => $value) { if ($value['value'] !== '') { $sql_terms .= ($value['value'] == 0 ? "AND {$value['sql_alias']} IS NULL " : "AND {$value['sql_alias']}={$value['value']} "); } } /* Chamado mais antigo em aberto */ $ticketStart = getOlderTicketInProgress($conn); $ticketInfo = getTicketData($conn, $ticketStart, ['data_abertura']); $terms = (!empty($ticketInfo['data_abertura']) ? " o.data_abertura >= '{$ticketInfo['data_abertura']}' AND " : ""); $sql = $QRY["tickets_in_queues"] . " AND {$terms} -- s.stat_ignored <> 1 AND -- s.stat_painel in (1,2) AND s.not_done = 1 AND o.sistema IN ({$uareas}) {$sql_terms} "; /* Só enviará dados se for o último nível do agrupamento selecionado */ if (count($params) == count($groups)) { try { $res = $conn->query($sql); ?>
fetchall() as $rowDetail) { /* registros */ ?> query($qryImg); $rowTela = $execImg->fetch(); $regImg = $execImg->rowCount(); if ($regImg != 0) { $linkImg = ""; } else $linkImg = ""; $sqlSubCall = "SELECT * FROM ocodeps WHERE dep_pai = {$rowDetail['numero']} OR dep_filho = {$rowDetail['numero']} "; $execSubCall = $conn->query($sqlSubCall); $regSub = $execSubCall->rowCount(); if ($regSub > 0) { #É CHAMADO PAI? $_sqlSubCall = "SELECT * FROM ocodeps WHERE dep_pai = {$rowDetail['numero']}"; $_execSubCall = $conn->query($_sqlSubCall); $_regSub = $_execSubCall->rowCount(); $comDeps = false; foreach ($_execSubCall->fetchall() as $rowSubPai) { $_sqlStatus = "SELECT o.*, s.* FROM ocorrencias o, `status` s WHERE o.numero = {$rowSubPai['dep_filho']} AND o.`status` = s.stat_id AND s.stat_painel NOT IN (3) AND s.stat_ignored <> 1 "; $_execStatus = $conn->query($_sqlStatus); $_regStatus = $_execStatus->rowCount(); if ($_regStatus > 0) { $comDeps = true; } } if ($comDeps) { $imgSub = ""; } else $imgSub = ""; } else $imgSub = ""; $lastEntryNotification = ''; $lastEntry = getLastEntry($conn, $rowDetail['numero']); if (!empty($lastEntry['numero'])) { $responsible = getUserInfo($conn, $lastEntry['responsavel']); $dateLastEntry = dateScreen($lastEntry['data']); $title = ($responsible['nome'] ?? ''); $content = $lastEntry['assentamento'] . '
' . $dateLastEntry; if ($lastEntry['responsavel'] == $rowDetail['aberto_por_cod']) { /* Assentamento realizado pelo solicitante */ $lastEntryNotification = "
"; } else { /* Se o assentamento tiver sido feito por um operador */ $lastEntryNotification = "
"; } } else { /* Sem nenhum assentamento */ $lastEntryNotification = '
'; } $clientName = (!empty($rowDetail['nickname']) ? "" . $rowDetail['nickname'] . "

" : ""); $departmentName = (!empty($rowDetail['setor']) ? "" . noHtml($rowDetail['setor']) . "

" : ""); // $texto = trim(noHtml($rowDetail['descricao'])); $texto = $rowDetail['descricao']; $texto = (new \Html2Text\Html2Text(safeStrip($texto)))->getText(); if (strlen((string)$texto) > 200) { // $texto = substr($texto, 0, 195) . " ..... "; }; if (!isset($rowDetail['cor'])) { $COR = '#CCCCCC'; } else { $COR = $rowDetail['cor']; } $cor_font = "#000000"; if (isset($rowDetail['cor_fonte']) && !empty($rowDetail['cor_fonte'])) { $cor_font = $rowDetail['cor_fonte']; } $renderTicketStatus = "" . $rowDetail['chamado_status'] . ""; $absoluteTime = absoluteTime($rowDetail['data_abertura'], date('Y-m-d H:i:s')); if ($calc_slas) { /** Trecho sobre o tempo filtrado e SLAs */ $referenceDate = (!empty($rowDetail['oco_real_open_date']) ? $rowDetail['oco_real_open_date'] : $rowDetail['data_abertura']); $dataAtendimento = $rowDetail['data_atendimento']; //data da primeira resposta ao chamado $dataFechamento = $rowDetail['data_fechamento']; /* NOVOS MÉTODOS PARA O CÁLCULO DE TEMPO VÁLIDO DE RESPOSTA E SOLUÇÃO */ $holidays = getHolidays($conn); $profileCod = getProfileCod($conn, $_SESSION['s_wt_areas'], $rowDetail['numero']); $worktimeProfile = getWorktimeProfile($conn, $profileCod); /* Objeto para o cálculo de Tempo válido de SOLUÇÃO - baseado no perfil de jornada de trabalho e nas etapas em cada status */ $newWT = new WorkTime( $worktimeProfile, $holidays ); /* Objeto para o cálculo de Tempo válido de RESPOSTA baseado no perfil de jornada de trabalho e nas etapas em cada status */ $newWTResponse = new WorkTime( $worktimeProfile, $holidays ); /* Objeto para checagem se o momento atual está coberto pelo perfil de jornada associado */ $objWT = new Worktime( $worktimeProfile, $holidays ); /* Realiza todas as checagens necessárias para retornar os tempos de resposta e solução para o chamado */ $ticketTimeInfo = getTicketTimeInfo($conn, $newWT, $newWTResponse, $rowDetail['numero'], $referenceDate, $dataAtendimento, $dataFechamento, $rowDetail['status_cod'], $objWT); /* Retorna os leds indicativos (bolinhas) para os tempos de resposta e solução */ $ledSlaResposta = showLedSLA($ticketTimeInfo['response']['seconds'], $percLimit, $rowDetail['sla_resposta_tempo']); $ledSlaSolucao = showLedSLA($ticketTimeInfo['solution']['seconds'], $percLimit, $rowDetail['sla_solucao_tempo']); // $isRunning = $ticketTimeInfo['running']; // $colTVNew = $ticketTimeInfo['solution']['time']; // if (isTicketFrozen($conn, $rowDetail['numero'])) { // $colTVNew = $iconFrozen . " " . $colTVNew; // } elseif (!$isRunning) { // $colTVNew = $iconOutOfWorktime . " " . $colTVNew; // } /* Final do trecho sobre o tempo filtrado e SLAs */ } ?>
/


)>
 

" . $rowDetail['pr_descricao'] . ""; ?>  "; ?>
" . $e->getMessage(); } } }