示例#1
0
$cbxActivo = 0;
$msg = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $xAccion = test_input($_POST["xAccion"]);
    $txtCveActividad = (int) test_input($_POST["txtCveActividad"]);
    $txtCveTipo = (int) test_input($_POST["txtCveTipo"]);
    $txtNombre = test_input($_POST["txtNombre"]);
    $txtDescripcion = test_input($_POST["txtDescripcion"]);
    $cbxActivo = isset($_POST["cbxActivo"]) ? 1 : 0;
    if ($txtCveActividad != 0) {
        $a = new Actividad($txtCveActividad);
    }
    if ($xAccion == 'grabar') {
        $a->setCve_tipo(new TipoActividad($txtCveTipo));
        $a->setNombre($txtNombre);
        $a->setDescripcion($txtDescripcion);
        $a->setActivo($cbxActivo);
        $count = $a->grabar();
        if ($count > 0) {
            $msg = "Los datos han sido guardados.";
        } else {
            $msg = "Ha ocurrido un imprevisto al guardar los datos";
        }
    } elseif ($xAccion == 'eliminar') {
        $count = $a->borrar();
        if ($count > 0) {
            $msg = "El registro ha sido borrado con éxito";
            $a = NULL;
        } else {
            $msg = "Ha ocurrido un imprevisto al borrar el registro";
            $a = NULL;