academy/ajax/revisa.ajax.php

58 lines
2.0 KiB
PHP

<?php
require_once "../controllers/home.controller.php";
require_once "../models/home.model.php";
class ajaxReportes {
public $id;
public $todos_los_campos;
public function ajaxListarReportes() {
$respuesta = ReportesController::ctrListarReportes();
header('Content-Type: application/json; charset=utf-8');
echo json_encode($respuesta, JSON_UNESCAPED_UNICODE);
}
public function ajaxDatosReporte() {
$respuesta = ReportesController::ctrDatosReporte($this->id);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($respuesta, JSON_UNESCAPED_UNICODE);
}
public function ajaxEditarReporte() {
$registros = ReportesController::ctrEditarReporte($this->todos_los_campos);
echo json_encode($registros, JSON_UNESCAPED_UNICODE);
}
public function ajaxNuevoReporte() {
$registros = ReportesController::ctrNuevoReporte($this->todos_los_campos);
echo json_encode($registros, JSON_UNESCAPED_UNICODE);
}
public function ajaxBorrarReporte() {
$respuesta = ReportesController::ctrBorrarReporte($this->id);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($respuesta, JSON_UNESCAPED_UNICODE);
}
}
if (isset($_POST['accion']) && $_POST['accion'] == "LISTAR") {
$registros = new ajaxReportes();
$registros->ajaxListarReportes();
}
if (isset($_POST['accion']) && $_POST['accion'] == "DATOS") {
$registros = new ajaxReportes();
$registros->id = $_POST['id'];
$registros->ajaxDatosReporte();
}
if (isset($_POST['accion']) && $_POST['accion'] == "EDITAR") {
$registros = new ajaxReportes();
$registros->todos_los_campos = $_POST;
$registros->ajaxEditarReporte();
}
if (isset($_POST['accion']) && $_POST['accion'] == "NUEVO") {
$registros = new ajaxReportes();
$registros->todos_los_campos = $_POST;
$registros->ajaxNuevoReporte();
}
if (isset($_POST['accion']) && $_POST['accion'] == "BORRAR") {
$registros = new ajaxReportes();
$registros->id = $_POST['id'];
$registros->ajaxBorrarReporte();
}