LANIA_Proyecto/controllers/CatalogosController.php

92 lines
3.0 KiB
PHP

<?php
require_once __DIR__ . '/../models/CatalogosModel.php';
class CatalogosController {
private static $catalogosModel = null;
public static function inicializar() {
if (self::$catalogosModel === null) {
self::$catalogosModel = new Catalogos();
}
}
public static function obtenerInfiCodigoPostal($codigo_postal){
return self::$catalogosModel->obtenerInfiCodigoPostal($codigo_postal);
}
public static function obtenerGiros(){
return self::$catalogosModel->obtenerGiros();
}
public static function obtenerNombresExamenes(){
return self::$catalogosModel->obtenerNombresExamenes();
}
public static function obtenerTiposIdentificacion(){
return self::$catalogosModel->obtenerTiposIdentificacion();
}
public static function obtenerRangosEdad(){
return self::$catalogosModel->obtenerRangosEdad();
}
public static function obtenerNivelesEstudio(){
return self::$catalogosModel->obtenerNivelesEstudio();
}
public static function obtenerNombresEmpresasInstituciones(){
return self::$catalogosModel->obtenerNombresEmpresasInstituciones();
}
}
CatalogosController::inicializar();
// Petición GET para información del código postal
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['codigo_postal'])) {
header('Content-Type: application/json');
$codigo_postal = $_GET['codigo_postal'];
$result = CatalogosController::obtenerInfiCodigoPostal($codigo_postal);
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'giros') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerGiros();
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'examenes') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerNombresExamenes();
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'identificacion') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerTiposIdentificacion();
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'rangosedad') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerRangosEdad();
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'nivelesestudio') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerNivelesEstudio();
echo json_encode($result);
}
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['obtener']) && $_GET['obtener'] === 'empresasinstituciones') {
header('Content-Type: application/json');
$result = CatalogosController::obtenerNombresEmpresasInstituciones();
echo json_encode($result);
}
?>