~marcelo-escobal/geined/Alianza

« back to all changes in this revision

Viewing changes to ccl.php.moved

  • Committer: Cualquier Desarrollador
  • Date: 2010-01-29 21:15:22 UTC
  • Revision ID: desarrollo@marte-20100129211522-u97qh9o90mhdap04
Importación inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
include('funciones.php');
 
3
include('datos.php');
 
4
function listado(){
 
5
        encabezado('Listado de categorías de clientes');
 
6
        boton("Nuevo","ccl.php?accion=nuevo");
 
7
        $sql='SELECT * FROM cat_clientes ORDER BY categoria';
 
8
        $resultado = mysql_query($sql); 
 
9
        encabezado_tabla(array("Nº","Categoria","Acciones"));
 
10
        $i = 0;
 
11
        while($row = mysql_fetch_array($resultado)){
 
12
                fila_alterna($i);
 
13
                $id = $row['id'];
 
14
                celda($id);
 
15
                celda($row['categoria']);
 
16
                echo '<td>';
 
17
                boton("Detalles","ccl_ver?accion=categoria&id=$id");
 
18
                boton("Editar","ccl.php?id=$id&accion=editar");
 
19
                boton("Borrar","ccl.php?accion=confirmar&id=$id");
 
20
                echo '</td></tr>';
 
21
                $i = $i + 1;
 
22
        }
 
23
        fin_tabla();
 
24
        boton('Volver','alianza.php?accion=sistema');
 
25
        fin();
 
26
}
 
27
function editar(){
 
28
        autorizacion(2);
 
29
        encabezado('Edición de categoría de clientes');
 
30
        encabezado_tabla(array("Campo","Valor"));
 
31
        formulario("ccl.php?accion=actualizar");
 
32
        $sql='select * from cat_clientes where id="' . $_GET['id'].'"';
 
33
        $resultado = mysql_query($sql);
 
34
        $fila=mysql_fetch_array($resultado);
 
35
        campo_oculto('id',$_GET['id']);
 
36
        input_texto("Categoría:","categoria",$fila['categoria']);
 
37
        botones();
 
38
        fin_formulario();
 
39
        fin_tabla();
 
40
        boton('Volver','ccl.php?accion=listado');
 
41
        fin();
 
42
}
 
43
function nuevo(){
 
44
        autorizacion(2);
 
45
        encabezado('Nueva categoría de cliente');
 
46
        encabezado_tabla(array("Campo","Valor"));
 
47
        formulario("ccl.php?accion=agregar");
 
48
        input_texto("Categoría:","categoria",'');
 
49
        botones();
 
50
        fin_formulario();
 
51
        fin_tabla();
 
52
        boton('Volver','ccl.php?accion=listado');
 
53
        fin();
 
54
}       
 
55
function actualizar(){
 
56
        $id = $_POST['id'];
 
57
        $sql = 'UPDATE cat_clientes SET categoria= "' . $_POST['categoria'] . 
 
58
                '" WHERE id = "' . $_POST['id'] . '"';
 
59
        $result = mysql_query($sql) or die('Invalid query: ' . mysql_error());
 
60
        header( 'Location: ccl.php?accion=listado' ) ;
 
61
}
 
62
function agregar(){
 
63
        $id = $_POST['id'];
 
64
        $sql1 = 'SELECT * FROM cat_clientes WHERE categoria="'.$_POST['categoria'].'"';
 
65
        $res1 = mysql_query($sql1);
 
66
        if (mysql_num_rows($res1)==0){
 
67
                $sql = 'INSERT INTO cat_clientes SET categoria = "' . $_POST['categoria'].'"';
 
68
                $result = mysql_query($sql) or die('Consulta inválida: ' . mysql_error());
 
69
                header( 'Location: '. $_SERVER['PHP_SELF'] . '?accion=listado' ) ;
 
70
        }
 
71
        else {
 
72
                duplicado('ccl.php?accion=listado');
 
73
        }
 
74
}
 
75
if (!$_GET['accion']) {
 
76
        $accion = 'listado';
 
77
}
 
78
else {
 
79
        $accion = $_GET['accion'];
 
80
}
 
81
autorizacion(5);
 
82
switch ($accion){
 
83
        // L I S T A D O
 
84
        case 'listado':
 
85
                listado();
 
86
                break;
 
87
        case 'editar':
 
88
                editar();
 
89
                break;
 
90
        case 'actualizar':
 
91
                actualizar();
 
92
                break;
 
93
        case 'nuevo':
 
94
                nuevo();
 
95
                break;
 
96
        case 'agregar':
 
97
                agregar();
 
98
                break;
 
99
        case 'confirmar':
 
100
                confirmar_borrar($_GET['id'],'ccl.php');
 
101
                break;
 
102
        case 'eliminar':
 
103
                autorizacion(2);
 
104
                borrar('cat_clientes',$_POST['id'],'ccl.php?accion=listado');
 
105
                break;
 
106
        }
 
107
?>