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'], 3, 1); use includes\classes\ConnectPDO; $conn = ConnectPDO::getInstance(); //Todas as áreas que o usuário percente // $uareas = $_SESSION['s_area']; // if ($_SESSION['s_uareas']) { // $uareas .= "," . $_SESSION['s_uareas']; // } $imgsPath = "../../includes/imgs/"; $iconFrozen = ""; $iconOutOfWorktime = ""; $config = getConfig($conn); $percLimit = $config['conf_sla_tolerance']; // storing request (ie, get/post) global array to a variable $requestData = $_POST; //FOR ORDER BY $columns = array( // datatable column index => database column name 0 => '', 1 => 'numero', 2 => 'problema', 3 => 'contato', 4 => 'setor', 5 => 'chamado_status' ); $doneStatus = $config['conf_status_done']; $daysToApprove = $config['conf_time_to_close_after_done']; $onlyBusinessDays = ($config['conf_only_weekdays_to_count_after_done'] ? true : false); // /* Data base para o filtro de chamados que precisam de aprovação e avaliação */ /* Ignrando o código acima - aparentemente possui um bug */ $tickets = []; $tickets = userHasTicketWaitingToBeRated($conn, $_SESSION['s_uid']); $searchIn = (!empty($tickets) ? implode(",", $tickets) : "-1"); // getting total number records without any search $sql = $QRY["tickets_in_queues_count"] . " AND stat_ignored <> 1 AND o.numero IN ({$searchIn}) "; $sqlResult = $conn->query($sql); $totalData = $sqlResult->fetch()['total']; $totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows. $sql = $QRY["tickets_in_queues"] . " AND stat_ignored <> 1 AND o.numero IN ({$searchIn}) "; if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter $sql.=" AND ( p.problema LIKE '%".$requestData['search']['value']."%' "; $sql.=" OR a.sistema LIKE '%".$requestData['search']['value']."%' "; $sql.=" OR o.contato LIKE '%".$requestData['search']['value']."%' "; $sql.=" OR l.local LIKE '%".$requestData['search']['value']."%' "; $sql.=" OR s.status LIKE '%".$requestData['search']['value']."%' "; $sql.=" OR o.numero LIKE '%".$requestData['search']['value']."%' )"; } $sqlResult = $conn->query($sql); $totalFiltered = $sqlResult->rowCount(); $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; $sqlResult = $conn->query($sql); $data = array(); foreach ($sqlResult->fetchAll() as $row){ $nestedData = array(); /* CHECAGEM DE SUB-CHAMADOS */ $sqlSubCall = "select * from ocodeps where dep_pai = " . $row['numero'] . " or dep_filho = " . $row['numero'] . ""; $execSubCall = $conn->query($sqlSubCall); $regSub = $execSubCall->rowCount(); if ($regSub > 0) { #É CHAMADO PAI? $sqlSubCall = "select * from ocodeps where dep_pai = " . $row['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) "; $execStatus = $conn->query($sqlStatus); $regStatus = $execStatus->rowCount(); if ($regStatus > 0) { $comDeps = true; } } if ($comDeps) { $imgSub = ""; } else { $imgSub = ""; } } else { $imgSub = ""; } /* FINAL DA CHEGAGEM DE SUB-CHAMADOS */ /* CHECAGEM DE ANEXOS */ $qryImg = "select * from imagens where img_oco = " . $row['numero'] . ""; $execImg = $conn->query($qryImg); $regImg = $execImg->rowCount(); if ($regImg != 0) { $linkImg = ""; } else { $linkImg = ""; } /* FINAL DA CHECAGEM DE ANEXOS */ /* DESCRIÇÃO DO CHAMADO */ $texto = $row['descricao']; // $texto = trim(noHtml($row['descricao'])); $texto = (new \Html2Text\Html2Text(safeStrip($texto)))->getText(); /* COR DO BADGE DA PRIORIDADE */ if (!isset($row['cor'])) { $COR = '#CCCCCC'; } else { $COR = $row['cor']; } $cor_font = "#000000"; if (isset($row['cor_fonte']) && !empty($row['cor_fonte'])) { $cor_font = $row['cor_fonte']; } $renderTicketStatus = "" . $row['chamado_status'] . ""; $referenceDate = (!empty($row['oco_real_open_date']) ? $row['oco_real_open_date'] : $row['data_abertura']); $dataAtendimento = $row['data_atendimento']; //data da primeira resposta ao chamado $dataFechamento = $row['data_fechamento']; /* NOVOS MÉTODOS PARA O CÁLCULO DE TEMPO VÁLIDP DE RESPOSTA E SOLUÇÃO */ $holidays = getHolidays($conn); $profileCod = getProfileCod($conn, $_SESSION['s_wt_areas'], $row['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, $row['numero'], $referenceDate, $dataAtendimento, $dataFechamento, $row['status_cod'], $objWT); /* Retorna os leds indicativos (bolinhas) para os tempos de resposta e solução */ $ledSlaResposta = showLedSLA($ticketTimeInfo['response']['seconds'], $percLimit, $row['sla_resposta_tempo']); $ledSlaSolucao = showLedSLA($ticketTimeInfo['solution']['seconds'], $percLimit, $row['sla_solucao_tempo']); $isRunning = $ticketTimeInfo['running']; $colTVNew = $ticketTimeInfo['solution']['time']; if (isTicketFrozen($conn, $row['numero'])) { $colTVNew = $iconFrozen . " " . $colTVNew; } elseif (!$isRunning) { $colTVNew = $iconOutOfWorktime . " " . $colTVNew; } /* FINAL DO TRECHO SOBRE O TEMPO FILTRADO */ $tags = "
" .strToTags($row['oco_tag'], 3); $lastEntryNotification = ''; $lastEntry = getLastEntry($conn, $row['numero']); if (!empty($lastEntry['numero'])) { $responsible = getUserInfo($conn, $lastEntry['responsavel']); $dateLastEntry = dateScreen($lastEntry['data']); $title = ($responsible['nome'] ?? ''); $content = $lastEntry['assentamento'] . '
' . $dateLastEntry; if ($lastEntry['responsavel'] == $row['aberto_por_cod']) { /* Assentamento realizado pelo solicitante */ $lastEntryNotification = "
"; } else { /* Se o assentamento tiver sido feito por um operador */ $lastEntryNotification = "
"; } } else { /* Sem nenhum assentamento */ $lastEntryNotification = '
'; } /* $ticketRate = getTicketRate($conn, $row['numero']); $isDone = ($config['conf_status_done'] == $row['status_cod'] ? true : false); $isRequester = ($_SESSION['s_uid'] == $row['aberto_por_cod'] ? true : false); $ratedInfo = getRatedInfo($conn, $row['numero']); $isRejected = (!empty($ratedInfo) && empty($ratedInfo['rate']) && !$isDone); $renderedRate = renderRate($ticketRate, $isDone, $isRequester, $isRejected); */ /** Dias passados desde a conclusao do atendimento */ $daysFromDone = daysFromDate($dataFechamento); /** Dias restantes para a aprovação e avaliacao */ $remainingDays = $daysToApprove - $daysFromDone; /** Data limite para a aprovação e avaliação do chamado */ $deadlineToApprove = dateScreen(addDaysToDate($dataFechamento, $daysToApprove, $onlyBusinessDays), 0, 'd/m/Y H:i'); $nestedData[] = ""; /* reservado para o botao de expandir e esconder quando responsivo */ $nestedData[] = $lastEntryNotification . "{$imgSub} " . $row['numero'] . "
" . $row['area']; $nestedData[] = $linkImg." ".$row['problema'] . $tags; $nestedData[] = "" . $row['contato'] . "

" . $row['telefone']; $nestedData[] = "" . $row['setor'] . "
" . $texto; $nestedData[] = $renderTicketStatus; $nestedData[] = $colTVNew; $nestedData[] = $deadlineToApprove; // $nestedData[] = $remainingDays . ' ' . ($remainingDays > 1 ? TRANS('DAYS') : TRANS('DAY')); // $nestedData[] = " " . dateScreen($row['oco_scheduled_to']); // $nestedData[] = "" . $row['pr_descricao'] . ""; $nestedData[] = " "; $nestedData['DT_RowId'] = 'id_' . $row['numero']; //DT_RowId é reservado $data[] = $nestedData; } /* MENSAGEM QUE SERÁ EXIBIDA EM CASO DE NENHUM REGISTRO ENCONTRADO */ // $customMessage = message('secondary','', TRANS('OCO_NOT_PENDING_TO_USER'),'','',true); $json_data = array( "draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. "recordsTotal" => intval( $totalData ), // total number of records "recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData // "customMessage" => $customMessage, "data" => $data // total data array ); echo json_encode($json_data); // send data as json format ?>