Esempio n. 1
0
 function grabar()
 {
     $sql = "";
     $count = 0;
     if (!$this->_existe) {
         $this->cveTramite = UtilDB::getSiguienteNumero("tramites", "cve_tramite");
         $sql = "INSERT INTO tramites VALUES({$this->cveTramite}," . $this->cveCategoriaTramite->getCveCategoriaTramite() . "," . $this->cveDependencia->getCveDependencia() . ",'{$this->nombre}',NULL,{$this->activo})";
         $count = UtilDB::ejecutaSQL($sql);
         if ($count > 0) {
             $this->_existe = true;
         }
     } else {
         $sql = "UPDATE tramites SET ";
         $sql .= "cve_categoria_tramite = " . $this->cveCategoriaTramite->getCveCategoriaTramite() . ",";
         $sql .= "cve_dependencia = " . $this->cveDependencia->getCveDependencia() . ",";
         $sql .= "nombre = '{$this->nombre}',";
         $sql .= "activo = {$this->activo} ";
         $sql .= " WHERE cve_tramite = {$this->cveDependencia}";
         $count = UtilDB::ejecutaSQL($sql);
     }
     return $count;
 }
$rst = NULL;
if (isset($_POST['txtCveCategoriaTramite'])) {
    if ($_POST['txtCveCategoriaTramite'] != 0) {
        $categoria = new CategoriaTramite((int) $_POST['txtCveCategoriaTramite']);
    }
}
if (isset($_POST['xAccion'])) {
    if ($_POST['xAccion'] == 'grabar') {
        $categoria->setCveTipoTramite(new TipoTramite((int) $_POST['cmbTipoTramite']));
        $categoria->setNombre($_POST['txtNombre']);
        $categoria->setActivo(isset($_POST['cbxActivo']) ? 1 : 0);
        $count = $categoria->grabar();
    }
    if ($_POST['xAccion'] == 'eliminar') {
        $categoria->borrar();
        $categoria = new CategoriaTramite();
    }
    if ($_POST['xAccion'] == 'logout') {
        unset($_SESSION['cve_usuario']);
        unset($_SESSION['nombre']);
        header('Location:login.php');
        return;
    }
}
?>
<!DOCTYPE html>
<html lang="es">
    <head>
        <title>Gestor de contenido del H. Ayuntamiento de Macuspana 2016-2018 | Categoria trámites</title>
        <meta charset="utf-8">
        <meta name="author" content="Webxico & Cuetox">