2
include('funciones.php');
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"));
11
while($row = mysql_fetch_array($resultado)){
15
celda($row['categoria']);
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");
24
boton('Volver','alianza.php?accion=sistema');
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']);
40
boton('Volver','ccl.php?accion=listado');
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",'');
52
boton('Volver','ccl.php?accion=listado');
55
function actualizar(){
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' ) ;
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' ) ;
72
duplicado('ccl.php?accion=listado');
75
if (!$_GET['accion']) {
79
$accion = $_GET['accion'];
100
confirmar_borrar($_GET['id'],'ccl.php');
104
borrar('cat_clientes',$_POST['id'],'ccl.php?accion=listado');