top.window.location = '../../index.php'"; exit; } require_once __DIR__ . "/" . "../../includes/include_basics_only.php"; require_once __DIR__ . "/" . "../../includes/classes/ConnectPDO.php"; $auth = new AuthNew($_SESSION['s_logado'], $_SESSION['s_nivel'], 1); use includes\classes\ConnectPDO; $conn = ConnectPDO::getInstance(); $uareas = $_SESSION['s_uareas']; $post = (isset($_POST) ? $_POST : ''); $havingScripts = (isset($post['having_scripts']) && $post['having_scripts'] == 'on' ? true : false); $config = getConfig($conn); $exception = ""; $options = [ 'prob_tipo_1' => [ 'label' => $config['conf_prob_tipo_1'], 'table' => 'prob_tipo_1', 'field_id' => 'probt1_cod', 'field_name' => 'probt1_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_1', 'sql_alias' => 'p.prob_tipo_1', 'alias' => 'pt1', 'value' => '' ], 'prob_tipo_2' => [ 'label' => $config['conf_prob_tipo_2'], 'table' => 'prob_tipo_2', 'field_id' => 'probt2_cod', 'field_name' => 'probt2_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_2', 'sql_alias' => 'p.prob_tipo_2', 'alias' => 'pt2', 'value' => '' ], 'prob_tipo_3' => [ 'label' => $config['conf_prob_tipo_3'], 'table' => 'prob_tipo_3', 'field_id' => 'probt3_cod', 'field_name' => 'probt3_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_3', 'sql_alias' => 'p.prob_tipo_3', 'alias' => 'pt3', 'value' => '' ], 'prob_tipo_4' => [ 'label' => $config['conf_prob_tipo_4'], 'table' => 'prob_tipo_4', 'field_id' => 'probt4_cod', 'field_name' => 'probt4_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_4', 'sql_alias' => 'p.prob_tipo_4', 'alias' => 'pt4', 'value' => '' ], 'prob_tipo_5' => [ 'label' => $config['conf_prob_tipo_5'], 'table' => 'prob_tipo_5', 'field_id' => 'probt5_cod', 'field_name' => 'probt5_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_5', 'sql_alias' => 'p.prob_tipo_5', 'alias' => 'pt5', 'value' => '' ], 'prob_tipo_6' => [ 'label' => $config['conf_prob_tipo_6'], 'table' => 'prob_tipo_6', 'field_id' => 'probt6_cod', 'field_name' => 'probt6_desc', 'table_reference' => 'problemas', 'table_reference_alias' => 'p', 'field_reference' => 'prob_tipo_6', 'sql_alias' => 'p.prob_tipo_6', 'alias' => 'pt6', 'value' => '' ] ]; if (!empty($post)) { /* Níveis possíveis de agrupamento */ $groups = [ 'group_1' => '', 'group_2' => '', 'group_3' => '', 'group_4' => '', 'group_5' => '', 'group_6' => '' ]; 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 resultante */ $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']} "); } } $termsHavingScripts = ""; if ($havingScripts) { $termsHavingScripts = " AND (SELECT MAX(prscpt_id) FROM prob_x_script WHERE prscpt_prob_id = p.prob_id) IS NOT NULL "; } $sql = "SELECT DISTINCT p.prob_id, p.problema, p.prob_descricao, p.prob_active, p.prob_profile_form, p.prob_area_default, p.need_authorization, p.card_in_costdash, sl.slas_desc, pt1.probt1_desc, pt2.probt2_desc, pt3.probt3_desc, pt4.probt4_desc, pt5.probt5_desc, pt6.probt6_desc FROM areas_x_issues as ai, problemas as p LEFT JOIN sla_solucao as sl on sl.slas_cod = p.prob_sla LEFT JOIN prob_tipo_1 as pt1 on pt1.probt1_cod = p.prob_tipo_1 LEFT JOIN prob_tipo_2 as pt2 on pt2.probt2_cod = p.prob_tipo_2 LEFT JOIN prob_tipo_3 as pt3 on pt3.probt3_cod = p.prob_tipo_3 LEFT JOIN prob_tipo_4 as pt4 on pt4.probt4_cod = p.prob_tipo_4 LEFT JOIN prob_tipo_5 as pt5 on pt5.probt5_cod = p.prob_tipo_5 LEFT JOIN prob_tipo_6 as pt6 on pt6.probt6_cod = p.prob_tipo_6 WHERE p.prob_id = ai.prob_id {$termsHavingScripts} {$sql_terms} ORDER BY p.problema "; /* 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 */ $area_default = $rowDetail['prob_area_default']; $active = ($rowDetail['prob_active'] ? '' : ''); $inactive_class = (empty($active) ? 'table-danger' : ''); $listAreas = ""; if (count($hiddenInAreas = hiddenAreasByIssue($conn, $rowDetail['prob_id']))) { $listAreas = '

' . TRANS('EXCEPT') . ':

'; foreach ($hiddenInAreas as $area) { $listAreas .= '
  • ' . $area['area_name'] ?? '' . '
  • '; } } $areasByIssue = getAreasByIssue($conn, $rowDetail['prob_id'], TRANS('ALL_A')); $linkedAreas = ""; foreach ($areasByIssue as $areaByIssue) { if ($areaByIssue['sistema'] != TRANS('ALL_A')) { $boldDefaulArea = ""; if ($areaByIssue['sis_id'] == $area_default) { $boldDefaulArea = "font-weight-bold"; } $linkedAreas .= '
  • ' . $areaByIssue['sistema'] ?? '' . '
  • '; } else { $linkedAreas .= '
  • ' . $areaByIssue['sistema'] ?? '' . '
  • '; } } $td_class = (empty($listAreas) ? 'except_areas' : ''); // $ShowlinkScript = ""; // $qryScript = "SELECT * FROM prob_x_script WHERE prscpt_prob_id = {$rowDetail['prob_id']}"; // $execQryScript = $conn->query($qryScript); // if ($execQryScript->rowCount() > 0) // $ShowlinkScript = ""; $showScripts = ""; $issueScripts = getScripts($conn, null, $rowDetail['prob_id']); foreach ($issueScripts as $script) { $showScripts .= "
  • " . $script['scpt_nome'] . "
  • "; } ?>
      ' : $rowDetail['probt1_desc']); ?> ' : $rowDetail['probt2_desc']); ?> ' : $rowDetail['probt3_desc']); ?> ' : $rowDetail['probt4_desc']); ?> ' : $rowDetail['probt5_desc']); ?> ' : $rowDetail['probt6_desc']); ?>
    " . $e->getMessage(); } } }