function run()
{
    //Agregar codigo aqui
    $categorias = array();
    if (isset($_POST["btnIngresar"])) {
        $ctgdsc = $_POST["txtCtgDsc"];
        $ctgest = $_POST["cmbCtgEst"];
        ingresarCategoria($ctgdsc, $ctgest);
    } elseif (isset($_POST["btnActualizar"])) {
        $ctgdsc = $_POST["txtCtgDsc"];
        $ctgest = $_POST["cmbCtgEst"];
        $ctgcod = $_GET["cod"];
        actualizarCategoria($ctgcod, $ctgdsc, $ctgest);
    } elseif (isset($_POST["btnEliminar"])) {
        $ctgcod = $_GET["cod"];
        eliminarCategoria($ctgcod);
    }
    if (isset($_GET["modo"])) {
        $modo = $_GET["modo"];
        switch ($modo) {
            case 'ACT':
                $categoria = obtenerCategoria($_GET["cod"]);
                $datos = array("actualizar" => 'ACT', "ctgcod" => $categoria["ctgcod"], "ctgdsc" => $categoria["ctgdsc"], "ctgest" => $categoria["ctgest"] == "INA" ? "ACT" : NULL);
                break;
            case 'INS':
                $datos = array("ingresar" => 'INS');
                break;
            case 'ELI':
                $categoria = obtenerCategoria($_GET["cod"]);
                $datos = array("eliminar" => 'ELI', "ctgcod" => $categoria["ctgcod"], "ctgdsc" => $categoria["ctgdsc"], "ctgest" => $categoria["ctgest"] == "INA" ? "ACT" : NULL);
                break;
        }
        renderizar("formularioCategorias", $datos);
    } else {
        $categorias = obtenerCategorias();
        renderizar("categorias", array("categorias" => $categorias));
    }
    //areglo de arreglos
    //debe existir un archivo en vistas
}
示例#2
0
					<th>Categoria</th>
					<th class="col-sm-1">Imagen</th>
					<th>Editar</th>
					<th>Eliminar</th>
				</tr>
			</thead>
			<tbody>
				<?php 
include $_SERVER['DOCUMENT_ROOT'] . "/admin/conexion.php";
$sql = "SELECT * FROM clientes";
$result = mysqli_query($con, $sql);
for ($i = 0; $i < $result->num_rows; $i++) {
    $result->data_seek($i);
    $fila = $result->fetch_assoc();
    $ID = $fila["ID"];
    $CategoriaObtenida = obtenerCategoria($fila["categoria"]);
    echo '<tr>
								<td>' . $fila["nombre"] . '</td>
								<td>' . $CategoriaObtenida . '</td>
								<td><img class="img-rounded" alt="sin imagen" src="' . $fila["imagen"] . '" width="100%"></td>
								<td><a href="editar.php?t=' . $ID . '"><span class="glyphicon glyphicon-edit text-primary"></span></a></td>
								<td><a href="#" data-toggle="modal" data-target="#myModal" onclick="funcionDelete(\'' . $ID . '\')">
										<span class="glyphicon glyphicon-remove-circle text-danger"></span>
									</a></td>
							</tr>';
}
?>
				
			</tbody>
		</table>
		<div class="modal-footer">
function run()
{
    //htmlDatos, arreglo que contiene todas las substituciones
    // que se darán en la plantilla.
    $htmlDatos = array();
    $htmlDatos["categoryTitle"] = "";
    $htmlDatos["categoryMode"] = "";
    $htmlDatos["ctgid"] = "";
    $htmlDatos["ctgdsc"] = "";
    $htmlDatos["ctgest"] = "";
    $htmlDatos["actSelected"] = "selected";
    $htmlDatos["inaSelected"] = "";
    $htmlDatos["disabled"] = "";
    if (isset($_GET["acc"])) {
        switch ($_GET["acc"]) {
            //Manejando si es un insert
            case "ins":
                $htmlDatos["categoryTitle"] = "Ingreso de Nueva Categoría";
                $htmlDatos["categoryMode"] = "ins";
                //se determina si es una acción del formulario
                if (isset($_POST["btnacc"])) {
                    $lastID = insertarCategoria($_POST);
                    if ($lastID) {
                        redirectWithMessage("¡Categoría Ingresada!", "index.php?page=category&acc=upd&ctgid=" . $lastID);
                    } else {
                        //Se obtiene los datos que estaban en el post
                        $htmlDatos["ctgid"] = $_POST["ctgid"];
                        $htmlDatos["ctgdsc"] = $_POST["ctgdsc"];
                        $htmlDatos["ctgest"] = $_POST["ctgest"];
                        $htmlDatos["actSelected"] = $_POST["ctgest"] == "ACT" ? "selected" : "";
                        $htmlDatos["inaSelected"] = $_POST["ctgest"] == "INA" ? "selected" : "";
                    }
                }
                //si no es una acción del post se muestra los datos
                renderizar("category", $htmlDatos);
                break;
                //Manejando si es un Update
            //Manejando si es un Update
            case "upd":
                if (isset($_POST["btnacc"])) {
                    //implementar logica de guardado
                    if (actualizarCategoria($_POST)) {
                        //forzando a que se actualice con los datos de la db
                        redirectWithMessage("¡Categoría Actualizada!", "index.php?page=category&acc=upd&ctgid=" . $_POST["ctgid"]);
                    }
                }
                if (isset($_GET["ctgid"])) {
                    $categoria = obtenerCategoria($_GET["ctgid"]);
                    if ($categoria) {
                        $htmlDatos["categoryTitle"] = "Actualizar " . $categoria["ctgdsc"];
                        $htmlDatos["categoryMode"] = "upd";
                        $htmlDatos["ctgid"] = $categoria["ctgid"];
                        $htmlDatos["ctgdsc"] = $categoria["ctgdsc"];
                        $htmlDatos["ctgest"] = $categoria["ctgest"];
                        $htmlDatos["actSelected"] = $categoria["ctgest"] == "ACT" ? "selected" : "";
                        $htmlDatos["inaSelected"] = $categoria["ctgest"] == "INA" ? "selected" : "";
                        renderizar("category", $htmlDatos);
                    } else {
                        redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                    }
                } else {
                    redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                }
                break;
                //Manejando un delete
            //Manejando un delete
            case "dlt":
                if (isset($_POST["btnacc"])) {
                    //implementar logica de guardado
                    if (borrarCategoria($_POST["ctgid"])) {
                        //forzando a que se actualice con los datos de la db
                        redirectWithMessage("¡Categoría Borrada!", "index.php?page=categorias");
                    }
                }
                if (isset($_GET["ctgid"])) {
                    $categoria = obtenerCategoria($_GET["ctgid"]);
                    if ($categoria) {
                        $htmlDatos["categoryTitle"] = "¿Desea borrar " . $categoria["ctgdsc"] . "?";
                        $htmlDatos["categoryMode"] = "dlt";
                        $htmlDatos["ctgid"] = $categoria["ctgid"];
                        $htmlDatos["ctgdsc"] = $categoria["ctgdsc"];
                        $htmlDatos["ctgest"] = $categoria["ctgest"];
                        $htmlDatos["actSelected"] = $categoria["ctgest"] == "ACT" ? "selected" : "";
                        $htmlDatos["inaSelected"] = $categoria["ctgest"] == "INA" ? "selected" : "";
                        $htmlDatos["disabled"] = 'disabled="disabled"';
                        renderizar("category", $htmlDatos);
                    } else {
                        redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                    }
                } else {
                    redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                }
                break;
                defualt:
                redirectWithMessage("¡Acción no permitida!", "index.php?page=categorias");
                break;
        }
    }
}
示例#4
0
<?php

error_reporting(0);
include "conexion2.php";
$contenido = "";
if ($statusConexion == true) {
    $contenido = consultaProgramas($conex);
    $catego = obtenerCategoria($conex);
}
?>
    
    <section class="content-header">
      <h1>
       Programas
      </h1>
      <ol class="breadcrumb">
        <li><a><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a>Programas</a></li>
      </ol>
    </section>
    <!-- Main content -->    
    <div id="div_frm_pro">
          <form id="frm_programa" name="frm_programa" action="" method="post">
            <fieldset>
              <label>Nombre del Programa</label>            
              <input type="text" id="nombre_pro" name="nombre_pro" placeholder="nombre del programa" required />
            </fieldset>
            <fieldset id="btnp">
              <input type="submit" id="enviar" value="Finalizar" class="btn btn-primary" />
            </fieldset>
            <fieldset id="loaderp">
示例#5
0
function run()
{
    $DatosCategoria = array();
    $DatosCategoria["categoryTitle"] = "";
    $DatosCategoria["categoryMode"] = "";
    $DatosCategoria["ctgid"] = "";
    $DatosCategoria["ctgdsc"] = "";
    $DatosCategoria["ctgest"] = "";
    $DatosCategoria["actSelected"] = "selected";
    $DatosCategoria["inaSelected"] = "";
    $DatosCategoria["disabled"] = "";
    if (isset($_GET["acc"])) {
        switch ($_GET["acc"]) {
            case "ins":
                $DatosCategoria["categoryTitle"] = "Ingreso de Nueva Categoría";
                $DatosCategoria["categoryMode"] = "ins";
                if (isset($_POST["btnacc"])) {
                    $lastID = insertarCategoria($_POST);
                    if ($lastID) {
                        redirectWithMessage("¡Categoría Ingresada!", "index.php?page=category&acc=upd&ctgid=" . $lastID);
                    } else {
                        $DatosCategoria["ctgid"] = $_POST["ctgid"];
                        $DatosCategoria["ctgdsc"] = $_POST["ctgdsc"];
                        $DatosCategoria["ctgest"] = $_POST["ctgest"];
                        $DatosCategoria["actSelected"] = $_POST["ctgest"] == "ACT" ? "selected" : "";
                        $DatosCategoria["inaSelected"] = $_POST["ctgest"] == "INA" ? "selected" : "";
                    }
                }
                renderizar("category", $DatosCategoria);
                break;
            case "upd":
                if (isset($_POST["btnacc"])) {
                    if (actualizarCategoria($_POST)) {
                        redirectWithMessage("¡Categoría Actualizada!", "index.php?page=category&acc=upd&ctgid=" . $_POST["ctgid"]);
                    }
                }
                if (isset($_GET["ctgid"])) {
                    $categoria = obtenerCategoria($_GET["ctgid"]);
                    if ($categoria) {
                        $DatosCategoria["categoryTitle"] = "Actualizar " . $categoria["ctgdsc"];
                        $DatosCategoria["categoryMode"] = "upd";
                        $DatosCategoria["ctgid"] = $categoria["ctgid"];
                        $DatosCategoria["ctgdsc"] = $categoria["ctgdsc"];
                        $DatosCategoria["ctgest"] = $categoria["ctgest"];
                        $DatosCategoria["actSelected"] = $categoria["ctgest"] == "ACT" ? "selected" : "";
                        $DatosCategoria["inaSelected"] = $categoria["ctgest"] == "INA" ? "selected" : "";
                        renderizar("category", $DatosCategoria);
                    } else {
                        redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                    }
                } else {
                    redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                }
                break;
            case "dlt":
                if (isset($_POST["btnacc"])) {
                    if (borrarCategoria($_POST["ctgid"])) {
                        redirectWithMessage("¡Categoría Borrada!", "index.php?page=categorias");
                    }
                }
                if (isset($_GET["ctgid"])) {
                    $categoria = obtenerCategoria($_GET["ctgid"]);
                    if ($categoria) {
                        $DatosCategoria["categoryTitle"] = "¿Desea borrar " . $categoria["ctgdsc"] . "?";
                        $DatosCategoria["categoryMode"] = "dlt";
                        $DatosCategoria["ctgid"] = $categoria["ctgid"];
                        $DatosCategoria["ctgdsc"] = $categoria["ctgdsc"];
                        $DatosCategoria["ctgest"] = $categoria["ctgest"];
                        $DatosCategoria["actSelected"] = $categoria["ctgest"] == "ACT" ? "selected" : "";
                        $DatosCategoria["inaSelected"] = $categoria["ctgest"] == "INA" ? "selected" : "";
                        $DatosCategoria["disabled"] = 'disabled="disabled"';
                        renderizar("category", $DatosCategoria);
                    } else {
                        redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                    }
                } else {
                    redirectWithMessage("¡Categoría No Encontrada!", "index.php?page=categorias");
                }
                break;
                defualt:
                redirectWithMessage("¡Acción no permitida!", "index.php?page=categorias");
                break;
        }
    }
}