From 04a5d7d352a97e8b642a9309f4d6f02bd2351812 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Thu, 26 Jun 2014 16:39:14 -0600 Subject: [PATCH 01/22] First Commit --- controladores/index.php | 12 +++++ controladores/libros.php | 19 ++++++++ controladores/utilidades.php | 9 ++++ dao/dao.php | 45 +++++++++++++++++++ index.php | 40 +++++++++++++++++ modelos/libros.php | 16 +++++++ publico/estilos/estilo.css | 32 +++++++++++++ recursos/nw201402.sql | 55 +++++++++++++++++++++++ test.php | 4 ++ vistas/index.tpl | 24 ++++++++++ vistas/libros.tpl | 20 +++++++++ vistas/renderizador.php | 87 ++++++++++++++++++++++++++++++++++++ 12 files changed, 363 insertions(+) create mode 100644 controladores/index.php create mode 100644 controladores/libros.php create mode 100644 controladores/utilidades.php create mode 100644 dao/dao.php create mode 100644 index.php create mode 100644 modelos/libros.php create mode 100644 publico/estilos/estilo.css create mode 100644 recursos/nw201402.sql create mode 100644 test.php create mode 100644 vistas/index.tpl create mode 100644 vistas/libros.tpl create mode 100644 vistas/renderizador.php diff --git a/controladores/index.php b/controladores/index.php new file mode 100644 index 0000000..d889dc2 --- /dev/null +++ b/controladores/index.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/controladores/libros.php b/controladores/libros.php new file mode 100644 index 0000000..9fb8925 --- /dev/null +++ b/controladores/libros.php @@ -0,0 +1,19 @@ +$valor){ + setData($columna, $valor); + } + echo renderizarVista("libros", $pageData); + }else{ + header("location:index.php"); + die(); + } +} +if ($method == "post"){ + +} +?> \ No newline at end of file diff --git a/controladores/utilidades.php b/controladores/utilidades.php new file mode 100644 index 0000000..44268d5 --- /dev/null +++ b/controladores/utilidades.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/dao/dao.php b/dao/dao.php new file mode 100644 index 0000000..e3d4aaf --- /dev/null +++ b/dao/dao.php @@ -0,0 +1,45 @@ +errno!=0){ + die("Error de Conexion a la DB"); + } + + $conn->set_charset('utf8'); + + function obtenerRegistros(&$conn, $sqlstr){ + $resultado = array(); + if($conn){ + $cursor = $conn->query($sqlstr); + if($cursor){ + foreach($cursor as $registro){ + $resultado[] = $registro; + } + } + } + return $resultado; + } + function obtenerRegistro(&$conn, $sqlstr){ + $resultado = array(); + if($conn){ + $cursor = $conn->query($sqlstr); + if($cursor){ + foreach($cursor as $registro){ + $resultado = $registro; + break; + } + } + } + return $resultado; + } +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..35b9ddd --- /dev/null +++ b/index.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/modelos/libros.php b/modelos/libros.php new file mode 100644 index 0000000..3cfd8bf --- /dev/null +++ b/modelos/libros.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/publico/estilos/estilo.css b/publico/estilos/estilo.css new file mode 100644 index 0000000..2b3e772 --- /dev/null +++ b/publico/estilos/estilo.css @@ -0,0 +1,32 @@ +body{ + font-size:16px; + font-family:helvetica, arial, sans-serif; + margin:0px; + padding:0px; +} +h1{ + font-size:2em; + margin: 1em 2em; +} +.grid920{ + clear:both; + margin:2em auto; + max-width:80%; + min-width:26.25em; + vertical-align: top; +} +.item{ + float:left; + display:block; + min-width:18em; + width:28%; + margin:1%; + box-shadow: 0 0 0.125em black; + padding:1em; + min-height: 10em; + border-radius:0.125em; + text-align:center; +} +.item span{ + display:block; +} \ No newline at end of file diff --git a/recursos/nw201402.sql b/recursos/nw201402.sql new file mode 100644 index 0000000..493076f --- /dev/null +++ b/recursos/nw201402.sql @@ -0,0 +1,55 @@ +CREATE DATABASE IF NOT EXISTS `nw201402` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */; +USE `nw201402`; +-- MySQL dump 10.13 Distrib 5.6.17, for osx10.6 (i386) +-- +-- Host: 127.0.0.1 Database: nw201402 +-- ------------------------------------------------------ +-- Server version 5.5.29 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `libros` +-- + +DROP TABLE IF EXISTS `libros`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `libros` ( + `isbn` varchar(20) COLLATE utf8_bin NOT NULL, + `titulo` varchar(128) COLLATE utf8_bin NOT NULL, + `casaedit` varchar(128) COLLATE utf8_bin NOT NULL, + `edicion` int(11) NOT NULL, + PRIMARY KEY (`isbn`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `libros` +-- + +LOCK TABLES `libros` WRITE; +/*!40000 ALTER TABLE `libros` DISABLE KEYS */; +INSERT INTO `libros` VALUES ('00000000000001','Programación de Negocios Web Php Mysql MVC','UNICAH',1),('00000000000002','Seminario de Software MongoDb, Jquery Mobile, Php REST API','UNICAH',1),('00000000000003','Diseño de Portales WEB','UNICAH',1),('00000000000004','Tecnología y Educación Una praxis en educación Superior','UNICAH',1),('00000000000005','Prueba de Mysqli e Insert','UNICAH',2); +/*!40000 ALTER TABLE `libros` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2014-06-26 16:37:27 diff --git a/test.php b/test.php new file mode 100644 index 0000000..014e062 --- /dev/null +++ b/test.php @@ -0,0 +1,4 @@ +"Hola Mundo Test","links"=>array("link"=>"publico/estilos/estilo.css"))); +?> \ No newline at end of file diff --git a/vistas/index.tpl b/vistas/index.tpl new file mode 100644 index 0000000..3d0a47b --- /dev/null +++ b/vistas/index.tpl @@ -0,0 +1,24 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + +

{{page-titulo}}

+
+ {{foreach libros}} +
+ +

{{titulo}}

+ ISBN:{{isbn}} + Editorial: {{casaedit}} +
+ {{endfor libros}} +
+ + \ No newline at end of file diff --git a/vistas/libros.tpl b/vistas/libros.tpl new file mode 100644 index 0000000..2bafb76 --- /dev/null +++ b/vistas/libros.tpl @@ -0,0 +1,20 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + +

{{page-titulo}}

+
+

{{titulo}}

+

{{isbn}}

+

{{casaedit}}

+
+ Regresar + + \ No newline at end of file diff --git a/vistas/renderizador.php b/vistas/renderizador.php new file mode 100644 index 0000000..b4ac294 --- /dev/null +++ b/vistas/renderizador.php @@ -0,0 +1,87 @@ +$valor){ + if(is_array($valor)){ + $pos = strpos($str,"{{foreach ".$llave."}}"); + if($pos){ + $startpos = $pos + strlen("{{foreach ".$llave."}}"); + $endpos = strpos($str,"{{endfor ".$llave."}}"); + $lastpos = $endpos + strlen("{{endfor ".$llave."}}"); + $tmpstr = substr($str, $startpos, ($endpos - $startpos )); + $replace = renderRepeater($tmpstr, $valor); + $str = substr_replace($str,$replace,$pos,$lastpos - $pos); + }else{ + if($base){ + render($str, $valor, $base.".".$llave); + }else { + render($str, $valor, $llave); + } + } + }else{ + if($base){ + $str =str_replace('{{'.$base.".".$llave.'}}', $valor, $str); + }else{ + $str = str_replace('{{'.$llave.'}}', $valor, $str); + } + } + } + } +} + +function limpiar(&$str){ + //limpiando cualquier foreach + $posstarter = false; + do{ + $posstarter = strpos($str,"{{foreach"); + if($posstarter){ + $posEndStarter = strpos($str,"}}", $posstarter); + $strEndBlock = substr($str, $posstarter, $posEndStarter - $posstarter + 2); + $strEndBlock = str_replace("foreach","endfor", $strEndBlock); + $posEnderLast = strpos($str,$strEndBlock) + strlen($strEndBlock); + $str = substr_replace($str,"",$posstarter, $posEnderLast - $posstarter); + } + }while($posstarter); + //limpiando cualquier etiqueta + $posstarter = false; + do{ + $posstarter = strpos($str,"{{"); + if($posstarter){ + $posEndStarter = strpos($str,"}}", $posstarter) + 2; + $str = substr_replace($str,"",$posstarter, $posEndStarter - $posstarter); + } + }while($posstarter); +} + +function renderRepeater($str, $data){ + $rtStr = ""; + if(is_array($data)){ + foreach($data as $key=>$row){ + $repeatTmp = $str; + if(is_array($row)){ + foreach($row as $llave=>$valor){ + $repeatTmp = str_replace("{{".$llave."}}",$valor,$repeatTmp); + } + }else { + $repeatTmp = str_replace("{{".$key."}}",$row,$repeatTmp); + } + $rtStr .= $repeatTmp; + } + } + return $rtStr; +} + +function cargarVista($vista){ + $htmlstr = ""; + $htmlstr = preg_replace('/\s\s+/', ' ', file_get_contents('vistas/'.$vista.".tpl")); + return $htmlstr; +} + +?> \ No newline at end of file From 781ea5a413cdb5da7f679b68adc42e180bf150f1 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Fri, 27 Jun 2014 09:04:50 -0600 Subject: [PATCH 02/22] Agregando funcionalidad para nuevo libro --- controladores/nuevolibro.php | 33 ++++++++++++++++++++++++++ controladores/plantilla.php | 9 +++++++ dao/dao.php | 8 +++++++ index.php | 3 +++ modelos/libros.php | 9 +++++++ vistas/nuevolibro.tpl | 46 ++++++++++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 controladores/nuevolibro.php create mode 100644 controladores/plantilla.php create mode 100644 vistas/nuevolibro.tpl diff --git a/controladores/nuevolibro.php b/controladores/nuevolibro.php new file mode 100644 index 0000000..67e5ad8 --- /dev/null +++ b/controladores/nuevolibro.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/controladores/plantilla.php b/controladores/plantilla.php new file mode 100644 index 0000000..297fec5 --- /dev/null +++ b/controladores/plantilla.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/dao/dao.php b/dao/dao.php index e3d4aaf..09b5c03 100644 --- a/dao/dao.php +++ b/dao/dao.php @@ -42,4 +42,12 @@ function obtenerRegistro(&$conn, $sqlstr){ } return $resultado; } + + function ejecutarNoQuery(&$conn, $sqlstr){ + if($conn){ + //Cuando son updates o Inserts devuelve false si falla el query. + return $conn->query($sqlstr); + } + return false; + } ?> \ No newline at end of file diff --git a/index.php b/index.php index 35b9ddd..f7858ce 100644 --- a/index.php +++ b/index.php @@ -26,6 +26,9 @@ case "libros": require_once("controladores/libros.php"); break; + case "nuevolibro": + require_once("controladores/nuevolibro.php"); + break; case "error": echo "error"; break; diff --git a/modelos/libros.php b/modelos/libros.php index 3cfd8bf..18ce35d 100644 --- a/modelos/libros.php +++ b/modelos/libros.php @@ -13,4 +13,13 @@ function obtenerLibroPorISBN($isbn){ $libro = obtenerRegistro($conn, sprintf($sqlstr, $isbn)); return $libro; } + function nuevoLibro($isbn, $titulo, $casaEdit, $edicion){ + global $conn; + $sqlInsert = "INSERT INTO libros(isbn, titulo, casaedit , edicion) VALUES ('%s','%s','%s',%d);"; + if(!ejecutarNoQuery($conn, sprintf($sqlInsert,$isbn,$titulo,$casaEdit,$edicion))){ + return false; + }else{ + return true; + } + } ?> \ No newline at end of file diff --git a/vistas/nuevolibro.tpl b/vistas/nuevolibro.tpl new file mode 100644 index 0000000..bebf54c --- /dev/null +++ b/vistas/nuevolibro.tpl @@ -0,0 +1,46 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + +

{{page-subtitulo}}

+
+
+ + +
+ + +
+ + +
+ + +
+ +
+
+ {{error-msg}} +
+
+ + \ No newline at end of file From 23f2a3ec82ef03b7782497e0704b39ec7932c7d6 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Fri, 27 Jun 2014 09:38:22 -0600 Subject: [PATCH 03/22] Agregando Estilos y otros elementos a considerar --- controladores/nuevolibro.php | 9 ++++++--- publico/estilos/estilo.css | 36 ++++++++++++++++++++++++++++++++++++ vistas/index.tpl | 3 +++ vistas/libros.tpl | 3 ++- vistas/nuevolibro.tpl | 2 ++ 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/controladores/nuevolibro.php b/controladores/nuevolibro.php index 67e5ad8..3262fc4 100644 --- a/controladores/nuevolibro.php +++ b/controladores/nuevolibro.php @@ -15,11 +15,14 @@ $txtEditorial = $_POST["txtEditorial"]; $intEdicion = intval($_POST["intEdicion"]); //Aqui debera ir validaciones de datos - + $validado = true; + if($txtISBN == ""){ + $validado=false; + } //grabando require_once('modelos/libros.php'); - if(nuevoLibro($txtISBN,$txtTitulo,$txtEditorial,$intEdicion)){ - header("location:index.php?page=index"); + if(nuevoLibro($txtISBN,$txtTitulo,$txtEditorial,$intEdicion) && $validado){ + header("location:index?page=libros&id=$txtISBN"); }else{ setData("page-subtitulo","Agregar Nuevo Libro"); setData("error-msg","Error al ingresar el Libro."); diff --git a/publico/estilos/estilo.css b/publico/estilos/estilo.css index 2b3e772..10850b5 100644 --- a/publico/estilos/estilo.css +++ b/publico/estilos/estilo.css @@ -29,4 +29,40 @@ h1{ } .item span{ display:block; +} +.error{ + background-color:rgba(255,0,0,0.3); + padding:1em; + margin:1em 0em; +} +label{ + display:inline-block; + font-weight: bold; + min-width:9em; +} +input, select{ + box-sizing: content-box; + display:inline-block; + border:0.125em solid lightblue; + border-radius:0.2em; + padding:1.1em 1.3em; + min-width:20em; +} +select{ + -webkit-appearance: none; + line-height: 1; + +} +input[type="submit"]{ + background-color:lightblue; +} + +.actionBtn{ + display: inline-block; + background-color: lightgreen; + text-align: center; + padding:1em; + font-weight: bold; + text-decoration: none; + color:black; } \ No newline at end of file diff --git a/vistas/index.tpl b/vistas/index.tpl index 3d0a47b..b56293a 100644 --- a/vistas/index.tpl +++ b/vistas/index.tpl @@ -10,6 +10,9 @@

{{page-titulo}}

+
{{foreach libros}}
diff --git a/vistas/libros.tpl b/vistas/libros.tpl index 2bafb76..b51595c 100644 --- a/vistas/libros.tpl +++ b/vistas/libros.tpl @@ -14,7 +14,8 @@

{{titulo}}

{{isbn}}

{{casaedit}}

+ Regresar
- Regresar + \ No newline at end of file diff --git a/vistas/nuevolibro.tpl b/vistas/nuevolibro.tpl index bebf54c..297c932 100644 --- a/vistas/nuevolibro.tpl +++ b/vistas/nuevolibro.tpl @@ -10,6 +10,7 @@

{{page-subtitulo}}

+
@@ -35,6 +36,7 @@
+
From b354a3d0f9095442027e59517b8b9122dc45b389 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Fri, 27 Jun 2014 10:14:29 -0600 Subject: [PATCH 04/22] =?UTF-8?q?correcci=C3=B3n=20de=20un=20error=20que?= =?UTF-8?q?=20permit=C3=ADa=20ingresar=20datos=20vacios=20aun=20validado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controladores/nuevolibro.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/controladores/nuevolibro.php b/controladores/nuevolibro.php index 3262fc4..f855577 100644 --- a/controladores/nuevolibro.php +++ b/controladores/nuevolibro.php @@ -21,16 +21,18 @@ } //grabando require_once('modelos/libros.php'); - if(nuevoLibro($txtISBN,$txtTitulo,$txtEditorial,$intEdicion) && $validado){ - header("location:index?page=libros&id=$txtISBN"); - }else{ - setData("page-subtitulo","Agregar Nuevo Libro"); - setData("error-msg","Error al ingresar el Libro."); - setData("txtISBN",$txtISBN); - setData("txtTitulo",$txtTitulo); - setData("txtEditorial",$txtEditorial); - echo renderizarVista("nuevolibro",$pageData); + if($validado){ + if(nuevoLibro($txtISBN,$txtTitulo,$txtEditorial,$intEdicion)){ + header("location:index?page=libros&id=$txtISBN"); + die(); + } } + setData("page-subtitulo","Agregar Nuevo Libro"); + setData("error-msg","Error al ingresar el Libro."); + setData("txtISBN",$txtISBN); + setData("txtTitulo",$txtTitulo); + setData("txtEditorial",$txtEditorial); + echo renderizarVista("nuevolibro",$pageData); } } ?> \ No newline at end of file From 822e8d42cfd96c5fbc9f8024dc9693e209fd516f Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Mon, 21 Jul 2014 23:08:03 -0600 Subject: [PATCH 05/22] =?UTF-8?q?Cambios=20realizados=20y=20ejemplo=20de?= =?UTF-8?q?=20catalogo=20de=20productos=20con=20paginaci=C3=B3n=20simple.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controladores/nuevopostit.php | 36 ++++++++ controladores/postits.php | 11 +++ controladores/productos.php | 26 ++++++ index.php | 13 ++- modelos/postit.php | 22 +++++ modelos/productos.php | 16 ++++ publico/estilos/estilo.css | 32 ++++++- recursos/nw201402.sql | 166 +++++++++++++++++++++++++++++++++- vistas/nuevopostit.tpl | 35 +++++++ vistas/postits.tpl | 25 +++++ vistas/productos.tpl | 31 +++++++ 11 files changed, 409 insertions(+), 4 deletions(-) create mode 100644 controladores/nuevopostit.php create mode 100644 controladores/postits.php create mode 100644 controladores/productos.php create mode 100644 modelos/postit.php create mode 100644 modelos/productos.php create mode 100644 vistas/nuevopostit.tpl create mode 100644 vistas/postits.tpl create mode 100644 vistas/productos.tpl diff --git a/controladores/nuevopostit.php b/controladores/nuevopostit.php new file mode 100644 index 0000000..ede0ec2 --- /dev/null +++ b/controladores/nuevopostit.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/controladores/postits.php b/controladores/postits.php new file mode 100644 index 0000000..9b16c95 --- /dev/null +++ b/controladores/postits.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/controladores/productos.php b/controladores/productos.php new file mode 100644 index 0000000..eeddd28 --- /dev/null +++ b/controladores/productos.php @@ -0,0 +1,26 @@ +$i); + } + + //TODO: Enlazar con la vista + setData('paginas',$paginas); + setData('productos',$productos); + echo renderizarVista("productos",$pageData); +} +if ($method == "post"){ + +} +?> \ No newline at end of file diff --git a/index.php b/index.php index f7858ce..132c877 100644 --- a/index.php +++ b/index.php @@ -16,7 +16,9 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ $method="post"; } - //en este arreglo se iran depositando toda la información necesaria que será pasada a las plantillas para ser renderizadas + //$pageData + //en este arreglo se iran depositando toda la información necesaria que será pasada + //a las plantillas para ser renderizadas switch($page){ @@ -29,6 +31,15 @@ case "nuevolibro": require_once("controladores/nuevolibro.php"); break; + case "postit": + require_once("controladores/postits.php"); + break; + case "nuevopostit": + require_once("controladores/nuevopostit.php"); + break; + case "productos": + require_once("controladores/productos.php"); + break; case "error": echo "error"; break; diff --git a/modelos/postit.php b/modelos/postit.php new file mode 100644 index 0000000..77c8025 --- /dev/null +++ b/modelos/postit.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/modelos/productos.php b/modelos/productos.php new file mode 100644 index 0000000..b64a387 --- /dev/null +++ b/modelos/productos.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/publico/estilos/estilo.css b/publico/estilos/estilo.css index 10850b5..7f79138 100644 --- a/publico/estilos/estilo.css +++ b/publico/estilos/estilo.css @@ -2,7 +2,7 @@ body{ font-size:16px; font-family:helvetica, arial, sans-serif; margin:0px; - padding:0px; + padding:1em; } h1{ font-size:2em; @@ -65,4 +65,34 @@ input[type="submit"]{ font-weight: bold; text-decoration: none; color:black; +} + +.board{ + border:2em ridge #888888; + padding:1em; + background-image: url('../img/bcg.jpg'); +} + +.postit{ + display: inline-block; + background-color:yellow; + padding:1em; + margin:1.5em; + width:13.75em; + min-height:13.75em; + box-shadow: 0.25em 0.25em 0.25em #444; +} + +.postit:nth-child(2n){ + -webkit-transform: rotate(10deg); + -o-transform: rotate(10deg); + -moz-transform: rotate(10deg); + transform:rotate(10deg); +} + +.postit:nth-child(3n){ + -webkit-transform: rotate(-10deg); + -o-transform: rotate(-10deg); + -moz-transform: rotate(-10deg); + transform:rotate(-10deg); } \ No newline at end of file diff --git a/recursos/nw201402.sql b/recursos/nw201402.sql index 493076f..c9e6a78 100644 --- a/recursos/nw201402.sql +++ b/recursos/nw201402.sql @@ -17,6 +17,113 @@ USE `nw201402`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +-- +-- Table structure for table `blogs` +-- + +DROP TABLE IF EXISTS `blogs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `blogs` ( + `id_blog` bigint(20) NOT NULL AUTO_INCREMENT, + `ttl_blog` varchar(45) COLLATE utf8_bin DEFAULT NULL, + `bdy_blog` varchar(2000) COLLATE utf8_bin DEFAULT NULL, + `eml_autor` varchar(150) COLLATE utf8_bin DEFAULT NULL, + `fch_blog` datetime DEFAULT NULL, + PRIMARY KEY (`id_blog`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `blogs` +-- + +LOCK TABLES `blogs` WRITE; +/*!40000 ALTER TABLE `blogs` DISABLE KEYS */; +INSERT INTO `blogs` VALUES (1,'Entry de Prueba','Este es un ejemplo de un micro blogging sistema para cualquier uso.','obetancourthunicah@gmail.com','2014-07-10 20:00:59'),(2,'Segundo Entry de Prueba','Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id nisl non urna faucibus vulputate. Aliquam pharetra lorem vel dapibus aliquam. Mauris et tempus nunc. Morbi sodales lacus sit amet tincidunt sagittis. Curabitur lorem tortor, semper id fringilla non, pharetra non felis. Donec felis tellus, porttitor eu dapibus at, imperdiet a dui. Phasellus auctor orci sem, tempor semper dolor lobortis vitae. Etiam commodo urna vitae elit hendrerit, in condimentum eros imperdiet. Proin augue quam, placerat nec auctor nec, imperdiet nec lacus. In sed eleifend enim, id feugiat ligula. Morbi nec molestie arcu. Suspendisse potenti. Aliquam lacinia non velit non sodales. Nam scelerisque eu nulla ac feugiat. Aenean bibendum ultricies orci, in scelerisque mauris pharetra non. Pellentesque at dolor vel lacus tempus lobortis elementum blandit erat.\r\n\r\nAliquam ac iaculis diam. Morbi ac libero congue, elementum orci gravida, mattis mauris. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas blandit nulla eget odio adipiscing, eget tincidunt nisi posuere. Nam vel tempor neque. Suspendisse in diam quis purus ullamcorper placerat tempor ut mi. In vitae porta diam. Curabitur semper, arcu sit amet tempor tempus, nunc ante consectetur risus, eu sodales nulla ante ac ante. Morbi ullamcorper tempus elit, ac venenatis libero sollicitudin vitae. Sed suscipit a felis non dictum. Aenean non blandit dui. Quisque congue odio eu metus pulvinar fringilla. Ut dignissim justo eget sapien cursus, varius tincidunt metus tincidunt. Donec cursus, nunc non commodo vulputate, tortor mi pretium tellus, eu semper justo dui ac purus.\r\n\r\nIn convallis quam sit amet arcu lacinia sodales. Cras quis neque molestie, malesuada est ut, tristique diam. Maecenas tempor, enim ut iaculis eleifend, massa nunc dictum tortor, sed aliquam elit ligula non est. Etiam posuere ornare ante et tempus. Phasellus sed viverra leo. Donec nec orci diam. Vestibulum at molestie ante. Integer ','obetancourthunicah@gmail.com','2014-07-10 20:18:28'),(3,'asdfgh','asdfghjklpoiuytrewaszdxfcghjk,mnbv dfghjkl,. ertuiokl,','sdfghj@sdfghj.com','2014-07-10 20:58:39'); +/*!40000 ALTER TABLE `blogs` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `carretilla` +-- + +DROP TABLE IF EXISTS `carretilla`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `carretilla` ( + `carretillaid` bigint(20) NOT NULL AUTO_INCREMENT, + `carrfching` datetime DEFAULT NULL, + `carrFchLstUpt` datetime DEFAULT NULL, + `carrCckOutUser` varchar(45) COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`carretillaid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `carretilla` +-- + +LOCK TABLES `carretilla` WRITE; +/*!40000 ALTER TABLE `carretilla` DISABLE KEYS */; +/*!40000 ALTER TABLE `carretilla` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `carretilla_d` +-- + +DROP TABLE IF EXISTS `carretilla_d`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `carretilla_d` ( + `carretillaid` bigint(20) NOT NULL, + `carretillaln` int(11) NOT NULL, + `productoid` bigint(20) NOT NULL, + `carrCtd` int(11) NOT NULL, + `carrPrc` decimal(11,2) DEFAULT NULL, + `carrIva` decimal(3,2) DEFAULT NULL, + PRIMARY KEY (`carretillaid`,`carretillaln`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `carretilla_d` +-- + +LOCK TABLES `carretilla_d` WRITE; +/*!40000 ALTER TABLE `carretilla_d` DISABLE KEYS */; +/*!40000 ALTER TABLE `carretilla_d` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `empresa` +-- + +DROP TABLE IF EXISTS `empresa`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `empresa` ( + `empresa_id` int(11) NOT NULL AUTO_INCREMENT, + `empresa_abr` varchar(7) COLLATE utf8_bin NOT NULL, + `empresa_dsc` varchar(75) COLLATE utf8_bin NOT NULL, + `empresa_rtn` varchar(45) COLLATE utf8_bin DEFAULT NULL, + `empresa_dir` varchar(255) COLLATE utf8_bin DEFAULT NULL, + `empresa_tip` char(3) COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`empresa_id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `empresa` +-- + +LOCK TABLES `empresa` WRITE; +/*!40000 ALTER TABLE `empresa` DISABLE KEYS */; +INSERT INTO `empresa` VALUES (1,'PART','Pura Artesanía','RTN010234','Tegucigalpa M.D.C Honduras','RTL'); +/*!40000 ALTER TABLE `empresa` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `libros` -- @@ -39,9 +146,64 @@ CREATE TABLE `libros` ( LOCK TABLES `libros` WRITE; /*!40000 ALTER TABLE `libros` DISABLE KEYS */; -INSERT INTO `libros` VALUES ('00000000000001','Programación de Negocios Web Php Mysql MVC','UNICAH',1),('00000000000002','Seminario de Software MongoDb, Jquery Mobile, Php REST API','UNICAH',1),('00000000000003','Diseño de Portales WEB','UNICAH',1),('00000000000004','Tecnología y Educación Una praxis en educación Superior','UNICAH',1),('00000000000005','Prueba de Mysqli e Insert','UNICAH',2); +INSERT INTO `libros` VALUES ('00000000000001','Programación de Negocios Web Php Mysql MVC','UNICAH',1),('00000000000002','Seminario de Software MongoDb, Jquery Mobile, Php REST API','UNICAH',1),('00000000000003','Diseño de Portales WEB','UNICAH',1),('00000000000004','Tecnología y Educación Una praxis en educación Superior','UNICAH',1),('00000000000005','Prueba de Mysqli e Insert','UNICAH',2),('00000000000006','Lean WEB Development','UNICAH',1),('00000000000007','SCRUM for Educators','UNICAH',2); /*!40000 ALTER TABLE `libros` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Table structure for table `postits` +-- + +DROP TABLE IF EXISTS `postits`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `postits` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `postName` varchar(80) COLLATE utf8_bin DEFAULT NULL, + `postbody` varchar(255) COLLATE utf8_bin DEFAULT NULL, + `postpriority` smallint(6) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `postits` +-- + +LOCK TABLES `postits` WRITE; +/*!40000 ALTER TABLE `postits` DISABLE KEYS */; +INSERT INTO `postits` VALUES (1,'Post 1','Lero Lero Candelero',1),(2,'Post # 2','Se trata de mostrar como se integra un segundo post-it',0); +/*!40000 ALTER TABLE `postits` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `productos` +-- + +DROP TABLE IF EXISTS `productos`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `productos` ( + `productoid` bigint(20) NOT NULL AUTO_INCREMENT, + `producto` varchar(70) COLLATE utf8_bin NOT NULL, + `prodStock` int(11) DEFAULT NULL, + `prodPrc` decimal(11,2) DEFAULT NULL, + `prodIva` decimal(3,2) DEFAULT NULL, + `prodest` char(3) COLLATE utf8_bin DEFAULT NULL, + `produri` varchar(45) COLLATE utf8_bin DEFAULT NULL, + PRIMARY KEY (`productoid`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `productos` +-- + +LOCK TABLES `productos` WRITE; +/*!40000 ALTER TABLE `productos` DISABLE KEYS */; +INSERT INTO `productos` VALUES (1,'Panadol',10,5.30,0.00,'ACT','0001.svg'),(2,'Panadol Antigripal',10,5.00,0.00,'ACT','0002.svg'),(3,'Acitromicina 500 mg',9,65.00,0.00,'ACT','0003.svg'),(4,'Levofloxacina',10,95.00,0.00,'ACT','0004.svg'),(5,'Agua Azul 16 oz fl',20,13.00,0.15,'ACT','0005.svg'),(6,'Enfamil Soya Premiun',4,769.00,0.10,'ACT','0006.svg'); +/*!40000 ALTER TABLE `productos` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -52,4 +214,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2014-06-26 16:37:27 +-- Dump completed on 2014-07-21 22:58:14 diff --git a/vistas/nuevopostit.tpl b/vistas/nuevopostit.tpl new file mode 100644 index 0000000..c7b1216 --- /dev/null +++ b/vistas/nuevopostit.tpl @@ -0,0 +1,35 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + +

{{page-subtitulo}}

+ +
+
+ + +
+ + +
+ + +
+
+ {{error-msg}} +
+
+ + \ No newline at end of file diff --git a/vistas/postits.tpl b/vistas/postits.tpl new file mode 100644 index 0000000..86eb89f --- /dev/null +++ b/vistas/postits.tpl @@ -0,0 +1,25 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + + +
+ {{foreach postitsColl}} +
+

{{postName}}

+ {{postbody}} +
+ {{endfor postitsColl}} +
+ + + diff --git a/vistas/productos.tpl b/vistas/productos.tpl new file mode 100644 index 0000000..dba9e6a --- /dev/null +++ b/vistas/productos.tpl @@ -0,0 +1,31 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + +

Catálogo de Productos

+
+ {{foreach productos}} +
+

{{producto}}

+
+ Precio: {{prodPrc}}
+ Iva: {{prodIva}}
+ Stock: {{prodStock}}
+ Agregar a Carretilla +
+ {{endfor productos}} +
+
+ {{foreach paginas}} + {{pagina}} | + {{endfor paginas}} +
+ + \ No newline at end of file From 6aa1677c29aa6bc5a9652f26b199f7f4438cd0b3 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Tue, 22 Jul 2014 21:04:43 -0600 Subject: [PATCH 06/22] Se Agrega funcionalidad de carretilla de compras parcial falta las validaciones de stock disponible. --- controladores/carretilla.php | 33 +++++++++++++++++++++++++++++++++ controladores/productos.php | 1 + dao/dao.php | 4 ++++ index.php | 3 +++ modelos/carretilla.php | 23 +++++++++++++++++++++++ vistas/productos.tpl | 2 +- 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 controladores/carretilla.php create mode 100644 modelos/carretilla.php diff --git a/controladores/carretilla.php b/controladores/carretilla.php new file mode 100644 index 0000000..5f91f55 --- /dev/null +++ b/controladores/carretilla.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/controladores/productos.php b/controladores/productos.php index eeddd28..ab57e86 100644 --- a/controladores/productos.php +++ b/controladores/productos.php @@ -16,6 +16,7 @@ } //TODO: Enlazar con la vista + setData('paginaActual', $pageNum); setData('paginas',$paginas); setData('productos',$productos); echo renderizarVista("productos",$pageData); diff --git a/dao/dao.php b/dao/dao.php index 09b5c03..080534f 100644 --- a/dao/dao.php +++ b/dao/dao.php @@ -50,4 +50,8 @@ function ejecutarNoQuery(&$conn, $sqlstr){ } return false; } + + function obtenerUltimoID(&$conn){ + return $conn->insert_id; + } ?> \ No newline at end of file diff --git a/index.php b/index.php index 132c877..40f2cd9 100644 --- a/index.php +++ b/index.php @@ -40,6 +40,9 @@ case "productos": require_once("controladores/productos.php"); break; + case "addCrt": + require_once("controladores/carretilla.php"); + break; case "error": echo "error"; break; diff --git a/modelos/carretilla.php b/modelos/carretilla.php new file mode 100644 index 0000000..51dfdec --- /dev/null +++ b/modelos/carretilla.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/vistas/productos.tpl b/vistas/productos.tpl index dba9e6a..e2cbe66 100644 --- a/vistas/productos.tpl +++ b/vistas/productos.tpl @@ -18,7 +18,7 @@ Precio: {{prodPrc}}
Iva: {{prodIva}}
Stock: {{prodStock}}
- Agregar a Carretilla + Agregar a Carretilla
{{endfor productos}}
From fe969c287abc63e3153600dcaefea319db1fb8a5 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Thu, 24 Jul 2014 04:54:59 -0600 Subject: [PATCH 07/22] =?UTF-8?q?Se=20agrega=20validaci=C3=B3n=20de=20stoc?= =?UTF-8?q?k=20disponible,=20manejados=20de=20errores=20por=20medio=20de?= =?UTF-8?q?=20middlewares=20y=20cambios=20a=20los=20estilos=20para=20el=20?= =?UTF-8?q?catalogo=20de=20productos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controladores/carretilla.php | 10 +- controladores/middleware.php | 23 ++++ controladores/productos.php | 2 +- index.php | 2 + modelos/productos.php | 11 ++ publico/estilos/estilo.css | 40 ++++++ publico/imagenes/0001.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/0002.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/0003.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/0004.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/0005.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/0006.svg | 230 +++++++++++++++++++++++++++++++++++ publico/imagenes/defualt.svg | 230 +++++++++++++++++++++++++++++++++++ vistas/productos.tpl | 20 ++- vistas/renderizador.php | 7 ++ 15 files changed, 1717 insertions(+), 8 deletions(-) create mode 100644 controladores/middleware.php create mode 100644 publico/imagenes/0001.svg create mode 100644 publico/imagenes/0002.svg create mode 100644 publico/imagenes/0003.svg create mode 100644 publico/imagenes/0004.svg create mode 100644 publico/imagenes/0005.svg create mode 100644 publico/imagenes/0006.svg create mode 100644 publico/imagenes/defualt.svg diff --git a/controladores/carretilla.php b/controladores/carretilla.php index 5f91f55..dfe0d53 100644 --- a/controladores/carretilla.php +++ b/controladores/carretilla.php @@ -4,11 +4,19 @@ if($_GET["page"]=="addCrt"){ //funcionalidad para la carretilla require_once("modelos/carretilla.php"); + require_once("modelos/productos.php"); $carretillaID = obtenerCarretillaCliente(); - if(guardarLinea($carretillaID, + if(obtenerStockDisponible($_GET["prdid"])>0){ + if(guardarLinea($carretillaID, obtenerSiguienteLinea($carretillaID), $_GET["prdid"])){ + header("location:index.php?page=productos&pageNum=".$_GET["pageNum"]); + die(); + } + }else{ + agregarError("WARNING", "El producto no tiene stock disponible"); header("location:index.php?page=productos&pageNum=".$_GET["pageNum"]); + die(); } } } diff --git a/controladores/middleware.php b/controladores/middleware.php new file mode 100644 index 0000000..041f587 --- /dev/null +++ b/controladores/middleware.php @@ -0,0 +1,23 @@ +$cod,"error"=>$error); + $_SESSION["app_errores"] = $app_errores; + } + + function limpiarErrors(){ + global $app_errores; + $app_errores = array(); + $_SESSION["app_errores"] = $app_errores; + } + + function obtenerErrores(){ + global $app_errores; + return $app_errores; + } +?> \ No newline at end of file diff --git a/controladores/productos.php b/controladores/productos.php index ab57e86..5501f60 100644 --- a/controladores/productos.php +++ b/controladores/productos.php @@ -12,7 +12,7 @@ $totalPaginas = floor( $totaTmp / 3) + (($totaTmp%3==0)?0:1); $paginas = array(); for($i=1;$i<=$totalPaginas;$i++){ - $paginas[] = array("pagina"=>$i); + $paginas[] = array("pagina"=>$i,"selected"=>($i==$pageNum)?"sel":""); } //TODO: Enlazar con la vista diff --git a/index.php b/index.php index 40f2cd9..372d978 100644 --- a/index.php +++ b/index.php @@ -20,6 +20,8 @@ //en este arreglo se iran depositando toda la información necesaria que será pasada //a las plantillas para ser renderizadas + //para levantar los errores guardados en session. + require_once("controladores/middleware.php"); switch($page){ case "index": diff --git a/modelos/productos.php b/modelos/productos.php index b64a387..e490fd2 100644 --- a/modelos/productos.php +++ b/modelos/productos.php @@ -13,4 +13,15 @@ function obtenerTotalProd(){ $sqlstr = "select count(*) as total from productos;"; return obtenerRegistro($conn,$sqlstr)["total"]; } + function obtenerStockDisponible($idPrd){ + global $conn; + $stockdisp = 0; + $sqlstr = "select a.productoid, a.prodStock - ifnull(b.ctdCrt,0) as stockDisp,a.prodStock,ifnull(b.ctdCrt,0) as ctdCrt from productos a left join ( select productoid, count(*) as ctdCrt from carretilla_d group by productoid) b on a.productoid = b.productoid where a.productoid = %d;"; + $resultTmp = obtenerRegistro($conn, sprintf( + $sqlstr, $idPrd)); + if(count($resultTmp)){ + $stockdisp = $resultTmp["stockDisp"]; + } + return $stockdisp; + } ?> \ No newline at end of file diff --git a/publico/estilos/estilo.css b/publico/estilos/estilo.css index 7f79138..622e37c 100644 --- a/publico/estilos/estilo.css +++ b/publico/estilos/estilo.css @@ -66,6 +66,9 @@ input[type="submit"]{ text-decoration: none; color:black; } +.actionBtn:hover{ + background-color: #48DD7B; +} .board{ border:2em ridge #888888; @@ -95,4 +98,41 @@ input[type="submit"]{ -o-transform: rotate(-10deg); -moz-transform: rotate(-10deg); transform:rotate(-10deg); +} +.showerror{ + display:block; + padding:0.5em 1em; + font-size:0.9em; + font-weight: bold; + +} +.hideerror{ + display:none; +} + +.prd{ + display: inline-block; + text-align:center; + width:18.125em; +} +.circle{ + padding:1em; + margin-bottom: 1em; + border-radius: 100%; + background-color: #DDD; +} +.pager{ + text-align: center; + font-weight: bold; + font-family: monospace; + font-size: 0.8em; +} +.pager a{ + padding:0.4em; + text-decoration: none; + color:black; +} +.pager .sel{ + background-color:lightblue; + border-radius: 15%; } \ No newline at end of file diff --git a/publico/imagenes/0001.svg b/publico/imagenes/0001.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0001.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/0002.svg b/publico/imagenes/0002.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0002.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/0003.svg b/publico/imagenes/0003.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0003.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/0004.svg b/publico/imagenes/0004.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0004.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/0005.svg b/publico/imagenes/0005.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0005.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/0006.svg b/publico/imagenes/0006.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/0006.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/defualt.svg b/publico/imagenes/defualt.svg new file mode 100644 index 0000000..58036a8 --- /dev/null +++ b/publico/imagenes/defualt.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vistas/productos.tpl b/vistas/productos.tpl index e2cbe66..ae8125b 100644 --- a/vistas/productos.tpl +++ b/vistas/productos.tpl @@ -10,22 +10,30 @@

Catálogo de Productos

+
+
    + {{foreach glberrors}} +
  1. {{codigo}} | {{error}}
  2. + {{endfor glberrors}} +
+
{{foreach productos}}

{{producto}}

-
+
Precio: {{prodPrc}}
Iva: {{prodIva}}
- Stock: {{prodStock}}
- Agregar a Carretilla + Stock: {{prodStock}}

+ Agregar a Carretilla
{{endfor productos}}
-
- {{foreach paginas}} - {{pagina}} | +
+ |{{foreach paginas}} + {{pagina}} | {{endfor paginas}}
+ \ No newline at end of file diff --git a/vistas/renderizador.php b/vistas/renderizador.php index b4ac294..b30fb20 100644 --- a/vistas/renderizador.php +++ b/vistas/renderizador.php @@ -1,5 +1,12 @@ Date: Thu, 24 Jul 2014 10:00:55 -0600 Subject: [PATCH 08/22] =?UTF-8?q?Cambio=20al=20Renderizador=20para=20poder?= =?UTF-8?q?=20utilizar=20layouts=20simples,=20y=20cambios=20de=20estilos?= =?UTF-8?q?=20para=20el=20catalogo=20y=20el=20sitio=20en=20general,=20se?= =?UTF-8?q?=20agrega=20una=20barra=20de=20navegaci=C3=B3n=20en=20layout.tp?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controladores/index.php | 1 + controladores/postits.php | 1 + controladores/productos.php | 6 +- publico/estilos/estilo.css | 71 ++++++++++++-- publico/imagenes/carretilla.svg | 119 +++++++++++++++++++++++ publico/imagenes/logo.svg | 162 ++++++++++++++++++++++++++++++++ vistas/index.tpl | 18 +--- vistas/layout.tpl | 33 +++++++ vistas/libros.tpl | 17 +--- vistas/nuevolibro.tpl | 16 +--- vistas/nuevopostit.tpl | 17 +--- vistas/postits.tpl | 16 +--- vistas/productos.tpl | 27 +----- vistas/renderizador.php | 10 +- 14 files changed, 403 insertions(+), 111 deletions(-) create mode 100644 publico/imagenes/carretilla.svg create mode 100644 publico/imagenes/logo.svg create mode 100644 vistas/layout.tpl diff --git a/controladores/index.php b/controladores/index.php index d889dc2..2f3d18f 100644 --- a/controladores/index.php +++ b/controladores/index.php @@ -3,6 +3,7 @@ if ($method == "get"){ require_once("modelos/libros.php"); + setData('page-subtitulo',"Simple MVC NW"); setData("libros", obtenerLibrosIndex()); echo renderizarVista("index", $pageData); } diff --git a/controladores/postits.php b/controladores/postits.php index 9b16c95..7e74542 100644 --- a/controladores/postits.php +++ b/controladores/postits.php @@ -2,6 +2,7 @@ if ($method == "get"){ require_once("modelos/postit.php"); + setData('page-subtitulo',"Ejemplo de Post-Its"); setData("postitsColl", obtenerPostits()); echo renderizarVista("postits", $pageData); } diff --git a/controladores/productos.php b/controladores/productos.php index 5501f60..8265609 100644 --- a/controladores/productos.php +++ b/controladores/productos.php @@ -4,18 +4,20 @@ require_once("modelos/productos.php"); $productos = array(); $pageNum = 1; + $pagelimit = 3; if(isset($_GET['pageNum'])){ $pageNum = intVal($_GET['pageNum']); } - $productos = obtenerProductos($pageNum,3); + $productos = obtenerProductos($pageNum,$pagelimit); $totaTmp = obtenerTotalProd(); - $totalPaginas = floor( $totaTmp / 3) + (($totaTmp%3==0)?0:1); + $totalPaginas = floor( $totaTmp / $pagelimit) + (($totaTmp%$pagelimit==0)?0:1); $paginas = array(); for($i=1;$i<=$totalPaginas;$i++){ $paginas[] = array("pagina"=>$i,"selected"=>($i==$pageNum)?"sel":""); } //TODO: Enlazar con la vista + setData('page-subtitulo',"Catálogo de Productos"); setData('paginaActual', $pageNum); setData('paginas',$paginas); setData('productos',$productos); diff --git a/publico/estilos/estilo.css b/publico/estilos/estilo.css index 622e37c..0efdc1c 100644 --- a/publico/estilos/estilo.css +++ b/publico/estilos/estilo.css @@ -1,12 +1,55 @@ body{ + font-family: lucida, helvetica, sans-serif; font-size:16px; - font-family:helvetica, arial, sans-serif; - margin:0px; - padding:1em; + margin: 0; + padding: 0; +} + +.menu{ + background-color:white; + padding:0; + padding-right:5.5em; + margin:0; + text-align:right; + list-style: none; +} +.menu li{ + display:inline-block; + padding:0; + margin:0; +} +.menu li a{ + display:inline-block; + padding:1.5em 2em; + color: #9E3B33; + text-decoration: none; + text-align:center; +} +.menu li a:hover{ + background-color:#DDD; +} +.menu li a.activo{ + text-decoration: underline; } -h1{ - font-size:2em; - margin: 1em 2em; +.logo{ + position: absolute; + top:0.5em; + left:1.5em; +} +.logo img{ + width:2.8em; + height:2.8em; + vertical-align: middle; +} +.logo h1{ + position:absolute; + font-size:1.4em; + font-weight: bold; + min-width:20em; + top:0.4em; + left:2.3em; + margin:0; + padding:0; } .grid920{ clear:both; @@ -114,6 +157,13 @@ input[type="submit"]{ display: inline-block; text-align:center; width:18.125em; + margin:1em 1em; + border-radius:0.25em; + box-shadow: 0em 0.115em 0.135em #888; + padding-bottom: 1.5em; +} +.prd:hover{ + } .circle{ padding:1em; @@ -135,4 +185,13 @@ input[type="submit"]{ .pager .sel{ background-color:lightblue; border-radius: 15%; +} + +.footer{ + clear:both; + margin:0; + padding:2em; + background-color:#444; + color:white; + text-align:center; } \ No newline at end of file diff --git a/publico/imagenes/carretilla.svg b/publico/imagenes/carretilla.svg new file mode 100644 index 0000000..861df88 --- /dev/null +++ b/publico/imagenes/carretilla.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/publico/imagenes/logo.svg b/publico/imagenes/logo.svg new file mode 100644 index 0000000..0d27d14 --- /dev/null +++ b/publico/imagenes/logo.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + S + MVC + + + S + MVC + + + S + MVC + + + + diff --git a/vistas/index.tpl b/vistas/index.tpl index b56293a..6a686d4 100644 --- a/vistas/index.tpl +++ b/vistas/index.tpl @@ -1,16 +1,4 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - -

{{page-titulo}}

-
+
@@ -22,6 +10,4 @@ Editorial: {{casaedit}}
{{endfor libros}} -
- - \ No newline at end of file +
\ No newline at end of file diff --git a/vistas/layout.tpl b/vistas/layout.tpl new file mode 100644 index 0000000..9cb26b8 --- /dev/null +++ b/vistas/layout.tpl @@ -0,0 +1,33 @@ + + + + {{page-titulo}} + + + {{foreach links}} + + {{endfor links}} + + + + +
+
    + {{foreach glberrors}} +
  1. {{codigo}} | {{error}}
  2. + {{endfor glberrors}} +
+
+ {{{mvc_contenido}}} + + + \ No newline at end of file diff --git a/vistas/libros.tpl b/vistas/libros.tpl index b51595c..b481d6f 100644 --- a/vistas/libros.tpl +++ b/vistas/libros.tpl @@ -1,21 +1,6 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - -

{{page-titulo}}

{{titulo}}

{{isbn}}

{{casaedit}}

Regresar -
- - - \ No newline at end of file + \ No newline at end of file diff --git a/vistas/nuevolibro.tpl b/vistas/nuevolibro.tpl index 297c932..03bf5b2 100644 --- a/vistas/nuevolibro.tpl +++ b/vistas/nuevolibro.tpl @@ -1,15 +1,3 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - -

{{page-subtitulo}}

@@ -43,6 +31,4 @@
{{error-msg}}
-
- - \ No newline at end of file + \ No newline at end of file diff --git a/vistas/nuevopostit.tpl b/vistas/nuevopostit.tpl index c7b1216..2870cef 100644 --- a/vistas/nuevopostit.tpl +++ b/vistas/nuevopostit.tpl @@ -1,15 +1,4 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - -

{{page-subtitulo}}

+
@@ -30,6 +19,4 @@
{{error-msg}}
-
- - \ No newline at end of file + \ No newline at end of file diff --git a/vistas/postits.tpl b/vistas/postits.tpl index 86eb89f..1f45efc 100644 --- a/vistas/postits.tpl +++ b/vistas/postits.tpl @@ -1,14 +1,3 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - @@ -19,7 +8,4 @@ {{postbody}} {{endfor postitsColl}} - - - - + \ No newline at end of file diff --git a/vistas/productos.tpl b/vistas/productos.tpl index ae8125b..9cf558c 100644 --- a/vistas/productos.tpl +++ b/vistas/productos.tpl @@ -1,22 +1,3 @@ - - - - {{page-titulo}} - - - {{foreach links}} - - {{endfor links}} - - -

Catálogo de Productos

-
-
    - {{foreach glberrors}} -
  1. {{codigo}} | {{error}}
  2. - {{endfor glberrors}} -
-
{{foreach productos}}
@@ -25,7 +6,8 @@ Precio: {{prodPrc}}
Iva: {{prodIva}}
Stock: {{prodStock}}

- Agregar a Carretilla + + Agregar a Carretilla
{{endfor productos}}
@@ -33,7 +15,4 @@ |{{foreach paginas}} {{pagina}} | {{endfor paginas}} - - - - \ No newline at end of file + \ No newline at end of file diff --git a/vistas/renderizador.php b/vistas/renderizador.php index b30fb20..4f26bf6 100644 --- a/vistas/renderizador.php +++ b/vistas/renderizador.php @@ -1,5 +1,5 @@ \ No newline at end of file From eda5fb1cb1d1ebfc877ada234967b0645f2c9363 Mon Sep 17 00:00:00 2001 From: Orlando Betancourth Date: Thu, 24 Jul 2014 20:59:34 -0600 Subject: [PATCH 09/22] Agregando Visor de carretilla y listado de los productos de la carretilla sin estilos --- controladores/carretilla.php | 21 ++--- controladores/middleware.php | 18 +++++ index.php | 3 + modelos/carretilla.php | 12 +++ publico/imagenes/carretillaflag.svg | 118 ++++++++++++++++++++++++++++ vistas/carretilla.tpl | 16 ++++ vistas/layout.tpl | 1 + 7 files changed, 175 insertions(+), 14 deletions(-) create mode 100644 publico/imagenes/carretillaflag.svg create mode 100644 vistas/carretilla.tpl diff --git a/controladores/carretilla.php b/controladores/carretilla.php index dfe0d53..eda33b5 100644 --- a/controladores/carretilla.php +++ b/controladores/carretilla.php @@ -19,23 +19,16 @@ die(); } } + if($_GET["page"]=="carretilla"){ + require_once("modelos/carretilla.php"); + setData('page-subtitulo',"Mi Carretilla de Compra"); + setData("crrtproductos", obtenerProductosCarretillaXId(obtenerCarretillaCliente())); + echo renderizarVista("carretilla", $pageData); + + } } if ($method == "post"){ } - -//------------------------------- -function obtenerCarretillaCliente(){ - if(isset($_COOKIE["crtid"])){ - return $_COOKIE["crtid"]; - }else{ - //crear la cabecera de carretilla - //obtener el id del carretilla - require_once("modelos/carretilla.php"); - $carretillaID = nuevaCarretilla(); - setcookie("crtid", $carretillaID); - return $carretillaID; - } -} ?> \ No newline at end of file diff --git a/controladores/middleware.php b/controladores/middleware.php index 041f587..4e97819 100644 --- a/controladores/middleware.php +++ b/controladores/middleware.php @@ -20,4 +20,22 @@ function obtenerErrores(){ global $app_errores; return $app_errores; } + + function obtenerCarretillaCliente(){ + if(isset($_COOKIE["crtid"])){ + return $_COOKIE["crtid"]; + }else{ + //crear la cabecera de carretilla + //obtener el id del carretilla + require_once("modelos/carretilla.php"); + $carretillaID = nuevaCarretilla(); + setcookie("crtid", $carretillaID); + return $carretillaID; + } + } + + if($method == "get"){ + require_once("modelos/carretilla.php"); + setData("ctdcarretilla",obtenerCtdProducto(obtenerCarretillaCliente())); + } ?> \ No newline at end of file diff --git a/index.php b/index.php index 372d978..85f8824 100644 --- a/index.php +++ b/index.php @@ -45,6 +45,9 @@ case "addCrt": require_once("controladores/carretilla.php"); break; + case "carretilla": + require_once("controladores/carretilla.php"); + break; case "error": echo "error"; break; diff --git a/modelos/carretilla.php b/modelos/carretilla.php index 51dfdec..e1cd98e 100644 --- a/modelos/carretilla.php +++ b/modelos/carretilla.php @@ -20,4 +20,16 @@ function guardarLinea($carretillaID, $linea, $productoID){ sprintf($sqlInsert,$carretillaID,$linea,$productoID,$productoID) ); } + function obtenerCtdProducto($carretillaId){ + global $conn; + $sqlstr = "select count(*) as productos from carretilla_d where carretillaid = %d;"; + return obtenerRegistro($conn, + sprintf($sqlstr, $carretillaId))["productos"]; + } + function obtenerProductosCarretillaXId($carretillaId){ + global $conn; + $sqlstr = "SELECT a.carretillaid, a.carretillaln, a.productoid, b.producto, a.carrCtd, a.CarrPrc, a.carrIva FROM carretilla_d a inner join productos b on a.productoid = b.productoid where carretillaid = %d order by a.carretillaln;"; + return obtenerRegistros($conn, + sprintf($sqlstr, $carretillaId)); + } ?> \ No newline at end of file diff --git a/publico/imagenes/carretillaflag.svg b/publico/imagenes/carretillaflag.svg new file mode 100644 index 0000000..fb679e3 --- /dev/null +++ b/publico/imagenes/carretillaflag.svg @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/vistas/carretilla.tpl b/vistas/carretilla.tpl new file mode 100644 index 0000000..4666897 --- /dev/null +++ b/vistas/carretilla.tpl @@ -0,0 +1,16 @@ +
+
+ Linea + Producto + Ctd + Precio + Iva
+ {{foreach crrtproductos}} +
{{carretillaln}} + {{producto}} + {{carrCtd}} + {{CarrPrc}} + {{carrIva}} +
+ {{endfor crrtproductos}} +
\ No newline at end of file diff --git a/vistas/layout.tpl b/vistas/layout.tpl index 9cb26b8..27a15a0 100644 --- a/vistas/layout.tpl +++ b/vistas/layout.tpl @@ -13,6 +13,7 @@
  • Libros
  • Postits
  • Catalogo
  • +
  • Carretilla {{ctdcarretilla}}

  • \ No newline at end of file diff --git a/vistas/layout.tpl b/vistas/layout.tpl index 89d565a..9d9dc51 100644 --- a/vistas/layout.tpl +++ b/vistas/layout.tpl @@ -14,6 +14,13 @@
  • Postits
  • Catálogo
  • Carretilla {{ctdcarretilla}}
  • + {{foreach isnotlogged}} +
  • Iniciar Sesión
  • +
  • Regístrate
  • + {{endfor isnotlogged}} + {{foreach security}} +
  • Cerrar Sesión
  • + {{endfor security}}