Date post: | 18-Nov-2014 |
Category: |
Education |
Upload: | victor-escamilla |
View: | 1,282 times |
Download: | 0 times |
1
Nombre del estudiante: Escamilla Vega Victor Javier
Gerson Ceniceros
Nombre del trabajo: Integrador segundo parcial
Fecha de entrega: 06-Abril-2013
Campus: ROMA
Carrera: LASCA
Cuatrimestre: Tercero
Nombre del maestro: Adán Salas
2
Índice
Introducción………………………………………………………….2
Desarrollo y documentación………..………………………..5
Conclusiones………………………………………………………...50
Bibliografía…………………………………………………………..51
3
Introducción
Base de datos
Una base de datos es un conjunto de datos informativos organizados en un mismo contexto para su uso y vinculación, categorizados según su naturaleza y la manera en que se piensa ser utilizados, todos los datos están contenidos en tablas, también llamadas tuplas, que a su vez presentan atributos que definen el tipo de datos que la tabla contendrá, se pueden entrelazar varias tablas a fin de relacionar el contenido y que las consultas a la base de datos sean exactas en cuanto a la información que arrojarán; las bases de datos nos sirven para almacenar datos que son útiles para el negocio, se administra mediante un lenguaje llamado SQL (Standard Query Language) el cual nos permite realizar todas las operaciones dentro de nuestra base.
PHP (PHP Hypertext Pre-processor)
Lenguaje de programación usado generalmente en la creación de contenidos web. Es un lenguaje interpretado especialmente usado para crear contenido dinámico y aplicaciones para servidores, aunque también puede ser utilizado en aplicaciones gráficas utilizando GTK+.
Generalmente es código embebido en el HTML original, aunque para este proyecto se manejara por separado, enviando los valores desde el formulario de HTML, realizando la conexión a servidores, y en este caso a nuestro servidor local que contiene la base de datos.
HTML (HyperText Markup Language)
Lenguaje de programación surgido a partir de las etiquetas SGML (Standard Generalized MArkup Language). Concepto traducido generalmente como “Estándar de lenguaje de marcado generalizado” y que se entiende como un sistema que permite ordenar y etiquetar diversos documentos dentro de una lista. Este lenguaje es el que se utiliza para especificar los nombres de las etiquetas que se utilizarán al ordenar, no existen reglas para dicha organización, por esto es llamado un sistema de formato abierto.
4
ERP
LA Planificación de recursos empresariales, es un conjunto de sistemas de información gerencial que permite la integración de algunas operaciones de una empresa. A través del ERP se trabaja de una forma integrada que permite la interconexión entre los diferentes programas, esto se hace mediante una base de datos centralizada que permite la optimización de los procesos y la posibilidad de obtener información de una forma rápida y precisa.
Conocido también como software “Black Office”, ya que está encargado de los aspectos administrativos internos, el software debe cumplir con las siguientes características para ser considerado de esta manera:
-Ser integral.-Administra todos los aspectos dentro de una empresa.
-Modular.- Dividir sus aspectos según los departamentos de la empresa.
-Adaptable.- Amoldarse a las particularidades de la empresa.
-Contar con una base de datos centralizada (Datawarehouse).
-Los datos se ingresan una vez y deben ser consistentes, completos y comunes.
Se organiza mediante módulos que se conectan a distintas bases de datos según lo que se requiera. El primer paso es realizar el desarrollo personalizado del ERP para los módulos más utilizados según la empresa. Luego debemos integrarlo dentro de la empresa, lo que en general suele llevar mucho tiempo, siendo sin dudas una inversión necesaria, ya que nos permitirá reducir las dudas concernientes a la veracidad de la información, mejoraremos la comunicación entre las diferentes áreas de la empresa, reduciremos la duplicación de la información, y proveeremos una eficiente integración de los procesos comerciales.
5
Desarrollo
La empresa Ingeniería y Diseño – Innovaciones Medico-Odontológicas ha solicitado un sistema que le permita llevar el control de sus clientes y proveedores.
La empresa tiene los siguientes datos de cada cliente y proveedor respectivamente, y nos hace la observación que en ningún caso puede faltar algún dato en cada registro que se genera:
Clientes.- ID, Nombre, Apellido(s), Dirección, Teléfono y si es cliente VIP o no.
Proveedores.- ID, Nombre, Dirección, Teléfono, Contacto, y si es un proveedor activo o no.
En el caso de los proveedores le interesa a la empresa saber si es un proveedor activo ya que en ocasiones se puede prescindir del mismo por el decremento de la demanda de refacciones, sin perder la relación de negocios con el mismo, esto le ayuda al personal para generar las órdenes de compra, asegurándonos que no se realicen a proveedores que por el momento no están surtiendo refacciones a la empresa.
En la operación diaria la empresa requiere hacer el alta y baja de clientes, actualizar los datos y consultar la información de los mismos.
Respecto a los proveedores la actividad no es tan frecuente, pero se requiere realizar las mismas operaciones, mayormente cambiar el status del proveedor (Activo/inactivo).
Como observación adicional se nos indicó que todo el personal que tuviese acceso al sistema puede modificar información tanto de clientes como de proveedores, por lo que no se agregaron condicionantes al login de los usuarios.
6
A continuación se enlistan las características de las tablas a desarrollar:
Clientes Proveedores Atributo Tipo Atributo Tipo ID Número ID Número Nombre Texto Nombre Texto Apellido Texto Dirección Texto Dirección Texto Teléfono Número Teléfono Número Contacto Texto VIP Texto Activo Texto
Adicionalmente se generó una tabla para llevar el registro de las personas que tienen acceso al sistema, asignando un usuario y contraseña confidenciales, la base cuenta solamente con un administrador que no se maneja desde el sistema sino directamente conectado a la base de datos.
A continuación se muestra la sintaxis que se ocupo para la base de datos.
-Create database ingeydis;
-Create table clientes(
ID int primary key,
Nombre varchar (20),
Apellido varchar (20),
Direccion varchar (35),
Telefono int,
VIP varchar (3));
-Create table proveedores(
ID int primary key,
Nombre varchar (35),
Direccion varchar (40),
Telefono int,
Contacto varchar (30),
Activo varchar (3));
7
-Create table login(
Nombre varchar (15) primary key,
Pass varchar (15));
Se tienen los siguientes valores que fueron agregados desde la base a manera de prueba:
8
Se generaron las siguientes interfaces para el usuario:
ACCESO AL SISTEMA (index)
<html>
<head><title>Acceso al sistema</Title></head>
<body background=bkgnd.jpg>
<form name=acceso action=acceso.php method=post>
<font size=6>Ingresa la información a continuación:</font>
<table width=150 height=100 border=1>
9
<td><font size=5><center>Usuario</center></font></td><td><input type=text name="user" maxlength=15></td>
<tr>
<td><font size=5><center>Contraseña</font></td><td><input type="password" name="pass" maxlength=15></td>
<tr>
<td colspan=2><center><input type=submit value=Ingresar></td>
</table>
</form>
<center><input type="button" value="Publicidad" onclick="window.open('http://www.itxperts.mx','Publicidad','height=800,width=1200,left=400,top=300,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=yes');"></center>
</body>
</html>
VALIDADOR DE ACCESO AL SISTEMA RESPECTO A LA BASE DE DATOS
<?php
$conectar=mysql_connect("127.0.0.1","root","1234");
$use=mysql_select_db("ingeydis",$conectar);
$qacceso="SELECT nombre, pass
FROM login
WHERE nombre = '".$_POST['user']."'";
10
$valores=mysql_query($qacceso);
#Arreglo para validar
$reg=mysql_fetch_array($valores);
#Variables para trabajar
$nick=$reg['nombre'];
$pass=$reg['pass'];
$nickf=$_POST['user'];
$passf=$_POST['pass'];
if ($nickf == NULL || $passf == NULL){
echo '<center>No se ingresaron datos <br> <a href="index.html">Intentalo de nuevo</a></center>';
}elseif ($nickf==$nick && $passf==$pass){
header("Location: index2.html");
}else {
echo '<center>Usuario o password incorrecto <br> <a href="index.html">Intentalo de nuevo</a></center>';
}
?>
11
MENÚ PRINCIPAL (index2)
<html>
<head><title>Sistema de consulta y manejo de información - Página principal</title></head>
<body background=bkgnd.jpg>
<font size=7><center>Bienvenido al sistema de información de clientes y amigos del proyecto <br> "Ingeniería y diseño" (BETA)</font>
<br>
<br>
<br>
<br>
<br>
<br>
12
<font size=5><b>Selecciona la opción deseada: </b></font></center>
<br>
<br>
<br>
<br>
<form name=form1 action=decide.php method=post>
<center><table width=30% height=10% border=1>
<td><center><font size=4><b>Administración/registro de clientes</b></td><td><input name=opcion value=1 type=radio checked="checked"></td>
<tr>
<td><center><font size=4><b>Administración/registro de proveedores</b></td><td><input name=opcion value=2 type=radio></td>
<tr>
<td colspan=2><center><input name=b1 type=submit value=Siguiente></td>
</font></table>
</form>
<br>
<br>
<form name=atras action=/clientes/action.php method=post>
<center><input type=submit name=exit value=Salir>
</form>
</body>
</html>
13
PROCESAR LA ELECCIÓN DEL USUARIO EN EL MENÚ PRINCIPAL:
<?php
$v1 = "$_POST[opcion]";
if ($v1 == 1){
header ("Location:/clientes/clientes.html");
}elseif ($v1 == 2){
header ("Location:/proveedores/proveedores.html");
}
?>
14
MENÚ PRINCIPAL DE CLIENTES
<html> <head><title>Administración de clientes</title></head> <body background=bkgnd.jpg> <font size=6><center>Bienvenido <br><br><br> Por favor selecciona la tarea a realizar: </font> <br> <br> <br> <br> <form name=formcli action=tcli.php method=post> <br> <br> <br> <br> <center> <table width=40% height=10% border=1> <td><font size=4><b>Ingresar información</td><td><center><input type=radio name=tcliop value=1 checked="checked"></td> <tr> <td><font size=4 color=red><b>Borrar información</td><td><center><input type=radio name=tcliop value=2></td> <tr>
15
<td><font size=4><b>Modificar información</td><td><center><input type=radio name=tcliop value=3></td> <tr> <td><font size=4><b>Consultar información</td><td><center><input type=radio name=tcliop value=4></td> <tr> <td colspan=2><center><input type=submit name=envia value=Continuar></td> </table> </form> <br> <br> <form name=atras action=action.php method=post> <PRE><input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </form> </body> </html> MENÚ DE NAVEGACIÓN DE CLIENTES (QUE SE REUTILIZA EN TODOS LOS MÓDULOS) <?php if ($_POST['atras']){ header("Location: /clientes/clientes.html"); }elseif ($_POST['principal']){ header("Location: /index2.html"); }elseif ($_POST['exit']){ header("Location: /index.html"); } ?> SELECCIÓN DE BLOQUE A UTILIZAR <?php $v1 = "$_POST[tcliop]"; if ($v1 == 1){ header ("Location:/clientes/ingresa.html"); }elseif ($v1 == 2){ header ("Location:/clientes/borra/borra.html"); }elseif ($v1 == 3){ header ("Location:/clientes/cambia/cambia.html"); }elseif($v1 == 4){ header ("Location:/clientes/consulta/consulta.html"); } ?>
16
AGREGAR CLIENTE
<html> <head><title>Ingresar información</title></head> <body background=clientes.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los datos del cliente <form name=form1 action=ingresar.php method=post> <br> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name="id" maxlength=6></td> <tr> <td><font size=4>Nombre</td><td><input type=text name="nombre" maxlength=20></td> <tr> <td><font size=4>Apellido</td><td><input type=text name="apellido" maxlength=20></td> <tr>
17
<td><font size=4>Dirección</td><td><input type=text name="direccion" maxlength=35></td> <tr> <td><font size=4>Teléfono</td><td><input type=text name="tel" maxlength=15></td> <tr> <td rowspan=2><font size=4>Es cliente VIP: </td><td><input type=radio name=vip value=1>Si</td> <tr> <td><input type=radio name=vip value=2 checked="checked">No</td> <tr> <td colspan=2><center><input type=submit name=enviar value="Ingresar datos"></td> </table> </form> <form name=atras action=action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> PROCESO DE VALIDACIÓN DE LA INFORMACIÓN <?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $nombre=$_POST['nombre']; $apellido=$_POST['apellido']; $direccion=$_POST['direccion']; $tel=$_POST['tel']; if ($_POST['vip'] == 1){ $vip='Si'; }elseif ($_POST['vip'] == 2){ $vip='No'; } $NoDuplicates="SELECT ID FROM clientes WHERE ID = '".$_POST['id']."'";
18
$valores=mysql_query($NoDuplicates); $nodup=mysql_fetch_array($valores); $iduser=$nodup['ID']; $iduserf=$_POST['id']; if ($id == NULL || $nombre == NULL || $apellido == NULL || $direccion == NULL || $tel == NULL){ echo '<center><font size=4>No puedes dejar campos en blanco, por favor intenta de nuevo.'; echo '<br><br><center><a href="ingresa.html"><font size=4>Atras</a>'; }elseif ($iduserf == $iduser){ echo '<center><font size=4>Este Id ya existe, intenta de nuevo'; echo '<br><br><center><a href="ingresa.html"><font size=4>Atras</a>'; }else{ $inserta="insert into clientes values('$id','$nombre','$apellido','$direccion','$tel','$vip')"; $result=mysql_query($inserta); echo '<center><font size=4>Se han insertado los valores correctamente. <br><br><br><a href="ingresa.html">Siguiente registro</a> <br><br><a href="clientes.html">Menú principal de clientes</a><br><br><a href="/index2.html">Menú principal</a> <br><br><a href="/index.html">Salir</a>'; } ?> SI SE OBTIENE UN CORRECTO INGRESO SE OBTIENE EL MENSAJE:
19
LA BASE DE DATOS ES MODIFICADA:
20
ELIMINAR INFORMACIÓN EN CLIENTES:
<html> <head><title>Eliminar información</title></head> <body background=/clientes/clientes.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los datos del cliente que deseas eliminar <form name=form1 action=borra.php method=post> <br> <br> <br> <table width=30% height=10% border=2> <td><font size=4>ID</td><td><input type=number name="id" maxlength=6></td> <tr> <td colspan=2><center><input type=submit name=enviar value="Eliminar datos"></td> </table> </form>
21
<form name=atras action=/clientes/action.php method=post> <PRE><input type=submit name=atras value="Menú de clientes"> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </form> </body> </html> SE EJECUTA LA INSTRUCCIÓN
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $NoDuplicates="SELECT ID, nombre, apellido, direccion, telefono, VIP FROM clientes WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($NoDuplicates); $nodup=mysql_fetch_array($valores); $iduser=$nodup['ID']; $nombre=$nodup['nombre']; $apellido=$nodup['apellido']; $direccion=$nodup['direccion'];
22
$telefono=$nodup['telefono']; $vip=$nodup['VIP']; $iduserf=$_POST['id']; if ($id == NULL){ echo '<center><font size=4>No puedes dejar campos en blanco, por favor intenta de nuevo.'; echo '<br><br><center><a href="/clientes/borra/borra.html"><font size=4>Atras</a>'; }elseif ($iduserf != $iduser){ echo '<center><font size=5 color=red>No se encontró el registro:<br><br>'; echo '<br><br><PRE><a href="/clientes/borra/borra.html"><font size=4>Atras</a>'; }elseif($iduserf == $iduser){ echo '<center><font size=5 color=red>Se ha eliminado la siguiente información del cliente:<br><br>'; echo '<center><table width=25% height=10% border=1>'; echo '<td>'.$_POST['id'].'</td><tr><td>'.$nombre.'</td><tr><td>'.$apellido.'</td><tr><td>'.$direccion.'</td><tr><td>'.$telefono.'</td><tr><td>'.$vip.'</td></table>'; echo '<br><br><PRE><a href="/clientes/borra/borra.html"><font size=4>Atras</a>'; $borrar="DELETE FROM clientes WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($borrar); } ?> SE MODIFICA LA BASE DE DATOS
23
MODIFICAR LA INFORMACIÓN DE UN CLIENTE:
<html> <head><title>Ingresar información</title></head> <body background=/clientes/clientes.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los nuevos datos del cliente: <form name=form1 action=cambiar.php method=post> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name=id maxlength=6></td> <tr> <td><font size=4>Nombre</td><td><input type=text name=nombre maxlength=20></td> <tr> <td><font size=4>Apellido</td><td><input type=text name=apellido maxlength=20></td> <tr>
24
<td><font size=4>Dirección</td><td><input type=text name=direccion maxlength=35></td> <tr> <td><font size=4>Teléfono</td><td><input type=text name=tel maxlength=15></td> <tr> <td rowspan=2><font size=4>Es cliente VIP: </td><td><input type=radio name=vip value=1>Si</td> <tr> <td><input type=radio name=vip value=2 checked="checked">No</td> <tr> <td colspan=2><center><input type=submit name=enviar value="Actualizar información"></td> </table> </form> <form name=atras action=/clientes/action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> SE EJECUTA LA INSTRUCCIÓN
25
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $nombre=$_POST['nombre']; $apellido=$_POST['apellido']; $direccion=$_POST['direccion']; $tel=$_POST['tel']; if ($_POST['vip'] == 1){ $vip='Si'; }elseif ($_POST['vip'] == 2){ $vip='No'; } $buscar="SELECT ID FROM clientes WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($buscar); $nodup=mysql_fetch_array($valores); $iduser=$nodup['ID']; $iduserf=$_POST['id']; if ($id == NULL || $nombre == NULL || $apellido == NULL || $direccion == NULL || $tel == NULL){ echo '<center><font size=4>No puedes dejar campos en blanco, por favor intenta de nuevo.'; echo '<br><br><center><a href="ingresa.html"><font size=4>Atras</a>'; }elseif ($iduserf == $iduser){ $cambia="UPDATE clientes SET nombre='$nombre', apellido='$apellido', direccion='$direccion', telefono='$tel' WHERE ID='$id' "; $result=mysql_query($cambia); echo '<center><font size=4>Se han modificado los valores correctamente. <br><br><br><a href="cambia.html">Siguiente registro</a> <br><br><a href="clientes.html">Menú principal de clientes</a><br><br><a href="/index2.html">Menú principal</a> <br><br><a href="/index.html">Salir</a>'; } ?>
26
SE MODIFICA EL REGISTRO EN LA BASE:
27
CONSULTAR INFORMACIÓN En este módulo la información se puede obtener ingresando el Id del cliente, el apellido o ambos valores.
<html> <head><title>Ingresar información</title></head> <body background=/clientes/clientes.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los datos del cliente que deseas consultar: <form name=form1 action=buscar.php method=post> <br> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name=id maxlength=6></td> <tr> <td><font size=4>Apellido</td><td><input type=text name=apellido maxlength=20></td>
28
<tr> <td colspan=2><center><input type=submit name=enviar value="Buscar cliente"></td> </table> </form> <form name=atras action=/clientes/action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> EJECUTA LA INSTRUCCIÓN
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $Selecciona=mysql_select_db("ingeydis",$conectar); $idf=$_REQUEST['id']; $apef=$_REQUEST['apellido'];
29
$consulta1="select * from clientes where ID=$idf"; $consulta2="select * from clientes where apellido LIKE '%$apef%'"; $consulta3="select * from clientes where apellido LIKE '%$apef%' || ID=$idf"; $consuno=mysql_query($consulta1,$conectar); $consdos=mysql_query($consulta2,$conectar); $constres=mysql_query($consulta3,$conectar); if ($idf == NULL && $apef == NULL) { echo '<br><br><center><font size=5>No has ingresado información, intenta de nuevo.<br><br>'; echo '<center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/clientes/clientes.html">Menú principal de clientes</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; }elseif ($idf != NULL && $apef == NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<center><table width=40% height=10% border=1>'; echo '<Font size=4><td>ID</td><td>Nombre</td><td>Apellido</td><td>Dirección</td><td>Teléfono</td><td>VIP</td>'; while ($registro=mysql_fetch_row($consuno)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/clientes/clientes.html">Menú principal de clientes</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } elseif ($idf == NULL && $apef != NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<table width=40% height=10% border=1>';
30
echo '<Font size=4><td>ID</td><td>Nombre</td><td>Apellido</td><td>Dirección</td><td>Teléfono</td><td>VIP</td>'; while ($registro=mysql_fetch_row($consdos)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/clientes/clientes.html">Menú principal de clientes</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } elseif ($idf != NULL && $apef != NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<table width=40% height=10% border=1>'; echo '<Font size=4><td>ID</td><td>Nombre</td><td>Apellido</td><td>Dirección</td><td>Teléfono</td><td>VIP</td>'; while ($registro=mysql_fetch_row($constres)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/clientes/clientes.html">Menú principal de clientes</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } mysql_close($conectar); ?>
31
ACCESO AL MENÚ DE PROVEEDORES
<html> <head><title>Administración de clientes</title></head> <body background=prov.jpg> <font size=6><center>Bienvenido <br><br><br> Por favor selecciona la tarea a realizar: </font> <br> <br> <br> <br> <form name=formcli action=Decideprov.php method=post> <br> <br> <br> <br> <center> <table width=40% height=10% border=1> <td><font size=4><b>Ingresar información</td><td><center><input type=radio name=tcliop value=1 checked="checked"></td> <tr>
32
<td><font size=4 color=red><b>Borrar información</td><td><center><input type=radio name=tcliop value=2></td> <tr> <td><font size=4><b>Modificar información</td><td><center><input type=radio name=tcliop value=3></td> <tr> <td><font size=4><b>Consultar información</td><td><center><input type=radio name=tcliop value=4></td> <tr> <td colspan=2><center><input type=submit name=envia value=Continuar></td> </table> </form> <br> <br> <form name=atras action=action.php method=post> <PRE><input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </form> </body> </html> SELECCIÓN DE MODULO A UTILIZAR <?php $v1 = "$_POST[tcliop]"; if ($v1 == 1){ header ("Location:/proveedores/Agrega/ingresa.html"); }elseif ($v1 == 2){ header ("Location:/proveedores/borra/borra.html"); }elseif ($v1 == 3){ header ("Location:/proveedores/cambia/cambia.html"); }elseif($v1 == 4){ header ("Location:/proveedores/consulta/consulta.html"); } ?>
33
MENÚ DE NAVEGACIÓN DE PROVEEDORES (QUE SE REUTILIZA EN TODOS LOS MÓDULOS) <?php if ($_POST['atras']){ header("Location: /proveedores/proveedores.html"); }elseif ($_POST['principal']){ header("Location: /index2.html"); }elseif ($_POST['exit']){ header("Location: /index.html"); } ?>
34
AGREGAR INFORMACIÓN DE PROVEEDOR
<html> <head><title>Ingresar información</title></head> <body background=/proveedores/prov.jpg width=1000 height=1000 > <br> <br> <font size=6>Ingresa los datos del proveedor: <form name=form1 action=ingresar.php method=post> <br> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name=id maxlength=6></td> <tr> <td><font size=4>Nombre</td><td><input type=text name=nombre maxlength=35></td> <tr> <td><font size=4>Dirección</td><td><input type=text name=direccion maxlength=40></td>
35
<tr> <td><font size=4>Teléfono</td><td><input type=text name=tel maxlength=13></td> <tr> <td><font size=4>Contacto</td><td><input type=text name=contacto maxlength=30></td> <tr> <td rowspan=2><font size=4>Está activo: </td><td><input type=radio name=activo value=1 checked="checked">Si</td> <tr> <td><input type=radio name=activo value=2>No</td> <tr> <td colspan=2><center><input type=submit name=enviar value="Ingresar datos"></td> </table> </form> <form name=atras action=/proveedores/action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> EJECUTA LA INSTRUCCIÓN
36
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $nombre=$_POST['nombre']; $direccion=$_POST['direccion']; $tel=$_POST['tel']; $contacto=$_POST['contacto']; if ($_POST['activo'] == 1){ $activo='Si'; }elseif ($_POST['activo'] == 2){ $activo='No'; } $NoDuplicates="SELECT ID FROM proveedores WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($NoDuplicates); $nodup=mysql_fetch_array($valores); $idprov=$nodup['ID']; $idprovf=$_POST['id']; if ($id == NULL || $nombre == NULL || $direccion == NULL || $tel == NULL || $contacto == NULL){ echo '<center><font size=4>No se llenaron todos los campos, intentalo de nuevo.'; echo '<br><br><center><a href="ingresa.html"><font size=4>Atras</a>'; }elseif ($idprovf == $idprov){ echo '<center><font size=4>Este ID ya existe, intenta de nuevo'; echo '<br><br><center><a href="ingresa.html"><font size=4>Atras</a>'; }else{ $inserta="insert into proveedores values('$id','$nombre','$direccion','$tel','$contacto','$activo')"; $result=mysql_query($inserta);
37
echo '<center><font size=4>Se han insertado los valores correctamente. <br><br><br><a href="ingresa.html">Siguiente registro</a> <br><br><a href="proveedores/proveedores.html">Menú principal de proveedores</a><br><br><a href="/index2.html">Menú principal</a> <br><br><a href="/index.html">Salir</a>'; } ?> SE MODIFICA LA BASE DE DATOS
38
BORRAR INFORMACIÓN DE UN PROVEEDOR
<html> <head><title>Eliminar información</title></head> <body background=/proveedores/prov.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los datos del proveedor que deseas eliminar <form name=form1 action=borra.php method=post> <br> <br> <br> <table width=30% height=10% border=2> <td><font size=4>ID</td><td><input type=number name=id maxlength=6></td> <tr> <td colspan=2><center><input type=submit name=enviar value="Eliminar datos"></td> </table> </form>
39
<form name=atras action=/proveedores/action.php method=post> <PRE><input type=submit name=atras value="Menú de proveedores"> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </form> </body> </html> EJECUTA LA INSTRUCCIÓN
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $query="SELECT ID, nombre, direccion, telefono, contacto, activo FROM proveedores WHERE ID = '".$_POST['id']."'";
40
$valores=mysql_query($query); $nodup=mysql_fetch_array($valores); $iduser=$nodup['ID']; $nombre=$nodup['nombre']; $direccion=$nodup['direccion']; $telefono=$nodup['telefono']; $contacto=$nodup['contacto']; $activo=$nodup['activo']; $idprovf=$_POST['id']; if ($id == NULL){ echo '<center><font size=4>No se ingresaron datos, intenta de nuevo..'; echo '<br><br><center><a href="/clientes/borra/borra.html"><font size=4>Atras</a>'; }elseif ($idprovf != $iduser){ echo '<center><font size=5 color=red>No se encontró el registro:<br><br>'; echo '<br><br><PRE><a href="/clientes/borra/borra.html"><font size=4>Atras</a>'; }elseif($idprovf == $iduser){ echo '<center><font size=5 color=red>Se ha eliminado la siguiente información del cliente:<br><br>'; echo '<center><table width=25% height=10% border=1>'; echo '<td>'.$_POST['id'].'</td><tr><td>'.$nombre.'</td><tr><td>'.$direccion.'</td><tr><td>'.$telefono.'</td><tr><td>'.$contacto.'</td><tr><td>'.$activo.'</td></table>'; echo '<br><br><PRE><a href="/proveedores/borra/borra.html"><font size=4>Atras</a>'; $borrar="DELETE FROM proveedores WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($borrar); } ?>
41
SE MODIFICA LA BASE DE DATOS
42
MODIFICAR LOS DATOS DEL PROVEEDOR
<html> <head><title>Ingresar información</title></head> <body background=/proveedores/prov.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los nuevos datos del proveedor: <form name=form1 action=cambia.php method=post> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name=id maxlength=6></td> <tr> <td><font size=4>Nombre</td><td><input type=text name=nombre maxlength=20></td> <tr> <td><font size=4>Dirección</td><td><input type=text name=direccion maxlength=35></td> <tr>
43
<td><font size=4>Teléfono</td><td><input type=text name=tel maxlength=15></td> <tr> <td><font size=4>Contacto</td><td><input type=text name=contacto maxlength=20></td> <tr> <td rowspan=2><font size=4>Está activo: </td><td><input type=radio name=activo value=1>Si</td> <tr> <td><input type=radio name=activo value=2 checked="checked">No</td> <tr> <td colspan=2><center><input type=submit name=enviar value="Actualizar información"></td> </table> </form> <form name=atras action=/proveedores/action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> SE EJECUTA LA INSTRUCCIÓN
44
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $use=mysql_select_db("ingeydis",$conectar); $id=$_POST['id']; $nombre=$_POST['nombre']; $direccion=$_POST['direccion']; $tel=$_POST['tel']; $contacto=$_POST['contacto']; if ($_POST['activo'] == 1){ $activo='Si'; }elseif ($_POST['activo'] == 2){ $activo='No'; } $buscar="SELECT ID FROM proveedores WHERE ID = '".$_POST['id']."'"; $valores=mysql_query($buscar); $nodup=mysql_fetch_array($valores); $iduser=$nodup['ID']; $iduserf=$_POST['id']; if ($id == NULL || $nombre == NULL || $direccion == NULL || $tel == NULL || $contacto == NULL){ echo '<center><font size=4>No puedes dejar campos en blanco, por favor intenta de nuevo.'; echo '<br><br><center><a href="cambia.html"><font size=4>Atras</a>'; }elseif ($iduserf == $iduser){ $cambia="UPDATE proveedores SET nombre='$nombre', direccion='$direccion', telefono='$tel', contacto='$contacto', activo='$activo' WHERE ID='$id' "; $result=mysql_query($cambia); echo '<center><font size=4>Se han modificado los valores correctamente. <br><br><br><a href="cambia.html">Siguiente registro</a> <br><br><a href="/proveedores/proveedores.html">Menú principal de clientes</a><br><br><a href="/index2.html">Menú principal</a> <br><br><a href="/index.html">Salir</a>'; } ?>
45
SE MODIFICA LA BASE DE DATOS
46
CONSULTAR INFORMACIÓN DE PROVEEDORES
<html> <head><title>Ingresar información</title></head> <body background=/proveedores/prov.jpg width=1000 height=1000> <br> <br> <font size=6>Ingresa los datos del cliente que deseas cambiar: <form name=form1 action=buscar.php method=post> <br> <br> <br> <table width=40% height=10% border=2> <td><font size=4>ID</td><td><input type=text name=id maxlength=6></td> <tr> <td><font size=4>Nombre</td><td><input type=text name=nombre maxlength=30></td> <tr> <td colspan=2><center><input type=submit name=enviar value="Buscar Proveedor"></td>
47
</table> </form> <form name=atras action=/proveedores/action.php method=post> <PRE><input type=submit name=atras value=atras> <input type=submit name=principal value="Menú Principal"> <input type=submit name=exit value=Salir></PRE> </body> </html> EJECUTA LA INSTRUCCIÓN
<?php $conectar=mysql_connect("127.0.0.1","root","1234"); $Selecciona=mysql_select_db("ingeydis",$conectar); $idf=$_REQUEST['id']; $nomf=$_REQUEST['nombre'];
48
$consulta1="select * from proveedores where ID=$idf"; $consulta2="select * from proveedores where nombre LIKE '%$nomf%'"; $consulta3="select * from proveedores where nombre LIKE '%$nomf%' || ID=$idf"; $consuno=mysql_query($consulta1,$conectar); $consdos=mysql_query($consulta2,$conectar); $constres=mysql_query($consulta3,$conectar); # 19 if ($idf == NULL && $nomf == NULL) { echo '<br><br><center><font size=5>No has ingresado información, intenta de nuevo.<br><br>'; echo '<center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/proveedores/proveedores.html">Menú principal de Proveedores</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; }elseif ($idf != NULL && $nomf == NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<center><table width=40% height=10% border=1>'; echo '<Font size=4><td>ID</td><td>Nombre</td><td>Dirección</td><td>Teléfono</td><td>Contacto</td><td>Activo</td>'; while ($registro=mysql_fetch_row($consuno)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/proveedores/proveedores.html">Menú principal de Proveedores</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } elseif ($idf == NULL && $nomf != NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<table width=40% height=10% border=1>'; echo '<Font size=4><td>ID</td><td>Nombre</td><td>Dirección</td><td>Teléfono</td><td>Contacto</td><td>Activo</td>';
49
while ($registro=mysql_fetch_row($consdos)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/proveedores/proveedores.html">Menú principal de Proveedores</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } elseif ($idf != NULL && $nomf != NULL) { echo '<br><center><font size=5> Se han encontrado los siguientes resultados:<br><br>'; echo '<table width=40% height=10% border=1>'; echo '<Font size=4><td>ID</td><td>Nombre</td><td>Dirección</td><td>Teléfono</td><td>Contacto</td><td>Activo</td>'; while ($registro=mysql_fetch_row($constres)) { echo'<tr>'; foreach($registro as $dato) echo'<td>'.$dato. '</td>'; echo '<tr>'; } echo '</table>'; echo '<br><br><center><font size=4><PRE><a href="consulta.html">Siguiente busqueda</a> <a href="/proveedores/proveedores.html">Menú principal de Proveedores</a> <a href="/index2.html">Menú principal</a> <a href="/index.html">Salir</a>'; } mysql_close($conectar); ?>
50
Conclusiones Con este tipo de herramientas se puede agilizar el tiempo de diseño de los sistemas ya que no es necesario crear las interfaces desde cero, se utilizar los recursos ya instalados en el sistema y se asegura el buen funcionamiento ya que todo se ejecuta de manera rápida y según el grado de seguridad empleado se obtienen resultados convenientes para la operación de la empresa, en este caso se cumplió con la solicitud del cliente y se redujo bastante el tiempo de entrega ya que no hubo que crear las ventanas desde cero y basándose en HTML este sistema se puede proyectar a que sea utilizado sin tener un vinculo con la infraestructura de la empresa a través de una VPN, simplemente se accede a la dirección web y se puede trabajar desde cualquier sitio, lo que porpicia un desempeño más ágil por parte del personal, ya que la única restricción es que se requiere de una computadora con acceso a internet.
51
Bibliografía Diccionario de informática http://www.alegsa.com.ar/Dic/php.php Definición ABC http://www.definicionabc.com/tecnologia/base-de-datos.php Definición ABC http://definicion.de/html/ Definición ABC http://www.definicionabc.com/tecnologia/erp.php