top.window.location = '../../index.php'"; exit; } require_once __DIR__ . "/" . "../../includes/include_basics_only.php"; require_once __DIR__ . "/" . "../../includes/classes/ConnectPDO.php"; use includes\classes\ConnectPDO; $conn = ConnectPDO::getInstance(); $post = $_POST; $config = getConfig($conn); $exception = ""; $data = []; $data['success'] = true; $data['message'] = ""; $data['cod'] = (isset($post['cod']) ? intval($post['cod']) : ""); $data['action'] = $post['action']; $data['field_id'] = ""; $data['cat_table'] = (isset($post['cat_table']) ? noHtml($post['cat_table']) : ""); $data['cat_label'] = (isset($post['cat_label']) ? noHtml($post['cat_label']) : ""); $data['current_label'] = $config['conf_' . $data['cat_table']]; $cat1 = $config['conf_prob_tipo_1']; $cat2 = $config['conf_prob_tipo_2']; $cat3 = $config['conf_prob_tipo_3']; $terms = ""; if ($data['cat_table'] == "prob_tipo_1") { $terms = "WHERE conf_prob_tipo_2 <> '" . $data['cat_label'] . "' AND conf_prob_tipo_3 <> '" . $data['cat_label'] . "' "; } elseif ($data['cat_table'] == "prob_tipo_2") { $terms = "WHERE conf_prob_tipo_1 <> '" . $data['cat_label'] . "' AND conf_prob_tipo_3 <> '" . $data['cat_label'] . "' "; } elseif ($data['cat_table'] == "prob_tipo_3") { $terms = "WHERE conf_prob_tipo_1 <> '" . $data['cat_label'] . "' AND conf_prob_tipo_2 <> '" . $data['cat_label'] . "' "; } /* Validações */ if ($data['action'] == "edit") { if (empty($data['cat_label'])) { $data['success'] = false; $data['field_id'] = 'cat_label'; } if (!$data['success']) { $data['message'] = message('warning', 'Ooops!', TRANS('MSG_EMPTY_DATA'),''); echo json_encode($data); return false; } } if ($data['action'] == 'edit') { $sql = "SELECT * FROM config {$terms}"; try { $res = $conn->query($sql); if (!$res->rowCount()) { $data['success'] = false; $data['field_id'] = 'cat_label'; $data['message'] = message('warning', 'Ooops!', TRANS('MSG_RECORD_EXISTS'),''); echo json_encode($data); return false; } } catch (Exception $e) { $exception .= "