Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Juan Montilla
/
TBW2223_equipo12
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
17a568fc
authored
May 12, 2023
by
Manuel Ruiz Toribio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Vista de mis recetas
parent
f92b1e87
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
177 additions
and
30 deletions
app/Config/Routes.php
app/Controllers/RecipesController.php
app/Models/RecipesModel.php
app/Views/pages/home.php
app/Views/pages/insertRecipe.php
app/Views/pages/recipe_cards.php
app/Views/pages/recipe_view.php
app/Views/pages/userRecipes.php
app/Views/templates/footer.php
app/Views/templates/header.php
public/js/main.js
app/Config/Routes.php
View file @
17a568fc
...
@@ -62,7 +62,6 @@ $routes->post('/insert_recipe', 'InsertRecipeController::insert_recipe');
...
@@ -62,7 +62,6 @@ $routes->post('/insert_recipe', 'InsertRecipeController::insert_recipe');
// Ruta para la búsqueda de recetas
// Ruta para la búsqueda de recetas
$routes
->
match
([
'get'
,
'post'
],
'/search_recipe'
,
'RecipesController::search_recipe'
);
$routes
->
match
([
'get'
,
'post'
],
'/search_recipe'
,
'RecipesController::search_recipe'
);
$routes
->
post
(
'filter_recipes'
,
'RecipesController::get_filtered_recipes'
);
// Ruta para vista "Mis recetas"
// Ruta para vista "Mis recetas"
$routes
->
get
(
'/myrecipes'
,
'User::personalRecipes'
,
[
'filter'
=>
'user_auth'
]);
$routes
->
get
(
'/myrecipes'
,
'User::personalRecipes'
,
[
'filter'
=>
'user_auth'
]);
...
@@ -79,6 +78,10 @@ $routes->get('home','Pages::prueba');
...
@@ -79,6 +78,10 @@ $routes->get('home','Pages::prueba');
$routes
->
get
(
'(:segment)'
,
'Home::index'
);
$routes
->
get
(
'(:segment)'
,
'Home::index'
);
// Ruta para la búsqueda de re
$routes
->
post
(
'/filter_recipes'
,
'RecipesController::filter_recipes'
);
...
...
app/Controllers/RecipesController.php
View file @
17a568fc
...
@@ -35,7 +35,6 @@ class RecipesController extends Controller
...
@@ -35,7 +35,6 @@ class RecipesController extends Controller
return
view
(
'templates/header'
,
$data
)
return
view
(
'templates/header'
,
$data
)
.
view
(
'pages/recipe_view'
)
.
view
(
'pages/recipe_view'
)
.
view
(
'pages/recipe_view'
)
.
view
(
'templates/footer'
);
.
view
(
'templates/footer'
);
}
}
...
@@ -87,16 +86,22 @@ class RecipesController extends Controller
...
@@ -87,16 +86,22 @@ class RecipesController extends Controller
// En tu controlador de recetas
// En tu controlador de recetas
public
function
get_filtered_recipes
()
{
public
function
filter_recipes
()
{
$is_vegan
=
$this
->
request
->
getPost
(
'is_vegan'
);
$origin
=
$this
->
request
->
getPost
(
'origin'
);
$season
=
$this
->
request
->
getPost
(
'season'
);
$recipesModel
=
new
\App\Models\RecipesModel
();
$recipesModel
=
new
\App\Models\RecipesModel
();
$vegan
=
$this
->
request
->
getPost
(
'is_vegan'
)
==
"true"
?
true
:
false
;
// Utiliza el método del modelo para obtener las recetas filtradas
$country
=
$this
->
request
->
getPost
(
'origin'
);
$recipes
=
$recipesModel
->
filter_recipes
(
$is_vegan
,
$origin
,
$season
);
$season
=
$this
->
request
->
getPost
(
'season'
);
$filtered_recipes
=
$recipesModel
->
get_filtered_recipes
(
$vegan
,
$country
,
$season
);
// Crear la vista parcial de las recetas y la devuelve
$data
=
[
'recipes'
=>
$recipes
];
return
$this
->
response
->
setJSON
(
$filtered_recipes
);
echo
view
(
'pages/recipe_cards'
,
$data
);
}
}
...
...
app/Models/RecipesModel.php
View file @
17a568fc
...
@@ -62,5 +62,25 @@ class RecipesModel extends Model
...
@@ -62,5 +62,25 @@ class RecipesModel extends Model
return
$this
->
delete
(
$id
);
return
$this
->
delete
(
$id
);
}
}
public
function
filter_recipes
(
$is_vegan
,
$origin
,
$season
)
{
$builder
=
$this
->
db
->
table
(
'recipes'
);
// Filtra por si es vegano o no
if
(
$is_vegan
==
1
)
{
$builder
->
where
(
'is_vegan'
,
$is_vegan
);
}
// Filtra por origen
if
(
!
empty
(
$origin
))
{
$builder
->
whereIn
(
'origin'
,
$origin
);
}
// Filtra por estaciones
if
(
!
empty
(
$season
))
{
$builder
->
whereIn
(
'season'
,
$season
);
}
return
$builder
->
get
()
->
getResult
();
}
}
}
\ No newline at end of file
app/Views/pages/home.php
View file @
17a568fc
This diff is collapsed.
Click to expand it.
app/Views/pages/insertRecipe.php
View file @
17a568fc
...
@@ -40,10 +40,10 @@
...
@@ -40,10 +40,10 @@
<div
class=
"form-group col-md-4"
>
<div
class=
"form-group col-md-4"
>
<label
for=
"origin"
>
Origen:
</label>
<label
for=
"origin"
>
Origen:
</label>
<select
id=
"origin"
name=
"origin"
class=
"form-control"
>
<select
id=
"origin"
name=
"origin"
class=
"form-control"
>
<option
value=
"Españ
ol
a"
>
Española
</option>
<option
value=
"España"
>
Española
</option>
<option
value=
"Franc
es
a"
>
Francesa
</option>
<option
value=
"Franc
i
a"
>
Francesa
</option>
<option
value=
"
Italiana
"
>
Japonesa
</option>
<option
value=
"
Japón
"
>
Japonesa
</option>
<option
value=
"M
exiana
"
>
Mexicana
</option>
<option
value=
"M
éxico
"
>
Mexicana
</option>
<option
value=
"China"
>
China
</option>
<option
value=
"China"
>
China
</option>
<option
value=
"India"
>
India
</option>
<option
value=
"India"
>
India
</option>
</select>
</select>
...
@@ -53,10 +53,10 @@
...
@@ -53,10 +53,10 @@
<div
class=
"form-group col-md-4"
>
<div
class=
"form-group col-md-4"
>
<label
for=
"season"
>
Temporada:
</label>
<label
for=
"season"
>
Temporada:
</label>
<select
id=
"season"
name=
"season"
class=
"form-control"
>
<select
id=
"season"
name=
"season"
class=
"form-control"
>
<option
value=
"
i
nvierno"
>
Invierno
</option>
<option
value=
"
I
nvierno"
>
Invierno
</option>
<option
value=
"
p
rimavera"
>
Primavera
</option>
<option
value=
"
P
rimavera"
>
Primavera
</option>
<option
value=
"
v
erano"
>
Verano
</option>
<option
value=
"
V
erano"
>
Verano
</option>
<option
value=
"
o
toño"
>
Otoño
</option>
<option
value=
"
O
toño"
>
Otoño
</option>
<option
value=
"4estaciones"
>
4 estaciones
</option>
<option
value=
"4estaciones"
>
4 estaciones
</option>
</select>
</select>
</div>
</div>
...
...
app/Views/pages/recipe_cards.php
0 → 100644
View file @
17a568fc
<?php
if
(
sizeof
(
$recipes
)
>
0
)
{
foreach
(
$recipes
as
$row
)
{
$ingredients
=
$recipesModel
->
get_recipe_ingredients
(
$row
->
id
);
?>
<!-- Inicio de la tarjeta de la receta -->
<div
class=
"card info-card sales-card"
onclick=
"window.location.href='
<?php
echo
base_url
(
'recipe/'
.
$row
->
id
);
?>
'"
>
<a
href=
"
<?php
echo
base_url
(
'recipe/'
.
$row
->
id
);
?>
"
>
</a>
<div
class=
"row flex-nowrap"
>
<div
class=
"col-lg-3 col-md-4 col-sm-12 imagen-container"
>
<img
src=
"
<?php
echo
base_url
(
'recipe/image/'
.
$row
->
id
);
?>
"
alt=
""
class=
"img-fluid rounded-start"
>
</div>
<div
class=
"col-lg-9 col-md-8 col-sm-12"
>
<div
class=
"filter"
>
<a
class=
"icon"
href=
"#"
data-bs-toggle=
"dropdown"
><i
class=
"bi bi-three-dots"
></i></a>
<ul
class=
"dropdown-menu dropdown-menu-end dropdown-menu-arrow"
>
<li
class=
"dropdown-header text-start"
>
<h6>
Opciones
</h6>
</li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Guardar
</a></li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Compartir
</a></li>
</ul>
</div>
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
<?php
echo
$row
->
name
;
?>
<span>
|
<?php
echo
$row
->
origin
;
?>
</span>
</h5>
<!--ingredientes-->
<?php
foreach
(
$ingredients
as
$ingredient
)
{
?>
<div
class=
"chip"
title=
"Cantidad:
<?php
echo
$ingredient
->
amount
;
?>
"
>
<img
src=
"imagenes/ingredientes/
<?php
echo
$ingredient
->
icon
;
?>
"
>
<b
style=
"font-size: 14px"
>
<?php
echo
$ingredient
->
name
;
?>
</b>
</div>
<?php
}
?>
<!--fin ingredientes-->
</div>
</div>
</div>
</div>
<!-- Fin de la tarjeta de la receta -->
<?php
}
}
?>
app/Views/pages/recipe_view.php
View file @
17a568fc
...
@@ -64,7 +64,7 @@ function getYoutubeVideoId($url)
...
@@ -64,7 +64,7 @@ function getYoutubeVideoId($url)
.video-container
{
.video-container
{
position
:
relative
;
position
:
relative
;
padding-bottom
:
56.25%
;
padding-bottom
:
56.25%
;
/* Relaci
ó
n de aspecto 16:9 */
/* Relaci
ó
n de aspecto 16:9 */
height
:
0
;
height
:
0
;
overflow
:
hidden
;
overflow
:
hidden
;
}
}
...
@@ -150,4 +150,4 @@ function getYoutubeVideoId($url)
...
@@ -150,4 +150,4 @@ function getYoutubeVideoId($url)
</div>
</div>
</section>
</section>
</main>
<!-- End #main -->
</main>
<!-- End #main -->
\ No newline at end of file
app/Views/pages/userRecipes.php
View file @
17a568fc
<?php
$session
=
session
();
?>
<main
id=
"main"
class=
"main"
>
<main
id=
"main"
class=
"main"
>
<section
class=
"section dashboard"
>
<section
class=
"section dashboard"
>
<h1>
Vista por hacer🤠
</h1>
<?php
$recipesModel
=
new
\App\Models\RecipesModel
();
$recipes
=
$recipesModel
->
findAll
();
if
(
sizeof
(
$recipes
)
>
0
)
{
foreach
(
$recipes
as
$row
)
{
$ingredients
=
$recipesModel
->
get_recipe_ingredients
(
$row
->
id
);
?>
<?php
if
(
$session
->
get
(
'user'
)
->
email
==
$row
->
email_user
)
:
?>
<!-- Inicio de la tarjeta de la receta -->
<div
class=
"card info-card sales-card"
onclick=
"window.location.href='
<?php
echo
base_url
(
'recipe/'
.
$row
->
id
);
?>
'"
>
<a
href=
"
<?php
echo
base_url
(
'recipe/'
.
$row
->
id
);
?>
"
>
</a>
<div
class=
"row flex-nowrap"
>
<div
class=
"col-lg-3 col-md-4 col-sm-12 imagen-container"
>
<img
src=
"
<?php
echo
base_url
(
'recipe/image/'
.
$row
->
id
);
?>
"
alt=
""
class=
"img-fluid rounded-start"
>
</div>
<div
class=
"col-lg-9 col-md-8 col-sm-12"
>
<div
class=
"filter"
>
<a
class=
"icon"
href=
"#"
data-bs-toggle=
"dropdown"
><i
class=
"bi bi-three-dots"
></i></a>
<ul
class=
"dropdown-menu dropdown-menu-end dropdown-menu-arrow"
>
<li
class=
"dropdown-header text-start"
>
<h6>
Opciones
</h6>
</li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Guardar
</a></li>
<li><a
class=
"dropdown-item"
href=
"#"
>
Compartir
</a></li>
</ul>
</div>
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
<?php
echo
$row
->
name
;
?>
<span>
|
<?php
echo
$row
->
origin
;
?>
</span>
</h5>
<!--ingredientes-->
<?php
foreach
(
$ingredients
as
$ingredient
)
{
?>
<div
class=
"chip"
title=
"Cantidad:
<?php
echo
$ingredient
->
amount
;
?>
"
>
<img
src=
"imagenes/ingredientes/
<?php
echo
$ingredient
->
icon
;
?>
"
>
<b
style=
"font-size: 14px"
>
<?php
echo
$ingredient
->
name
;
?>
</b>
</div>
<?php
}
?>
<!--fin ingredientes-->
</div>
</div>
</div>
</div>
<?php
endif
;
?>
<!-- Fin de la tarjeta de la receta -->
<?php
}
}
?>
</section>
</section>
...
...
app/Views/templates/footer.php
View file @
17a568fc
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
<script
src=
"js/validate.js"
></script>
<script
src=
"js/validate.js"
></script>
<!-- Template Main JS File -->
<!-- Template Main JS File -->
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"
></script>
<script
src=
"js/main.js"
></script>
<script
src=
"js/main.js"
></script>
</body>
</body>
...
...
app/Views/templates/header.php
View file @
17a568fc
...
@@ -215,41 +215,41 @@
...
@@ -215,41 +215,41 @@
<!--Contenido del dropdown-->
<!--Contenido del dropdown-->
<ul
class=
"indian-cboxtags"
>
<ul
class=
"indian-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxFour"
value=
"
Order four
"
>
<input
type=
"checkbox"
id=
"checkboxFour"
value=
"
India
"
>
<label
for=
"checkboxFour"
>
India
</label>
<label
for=
"checkboxFour"
>
India
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"french-cboxtags"
>
<ul
class=
"french-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxFive"
value=
"
Order five
"
>
<input
type=
"checkbox"
id=
"checkboxFive"
value=
"
Francia
"
>
<label
for=
"checkboxFive"
>
Francia
</label>
<label
for=
"checkboxFive"
>
Francia
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"chinese-cboxtags"
>
<ul
class=
"chinese-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxSix"
value=
"
Order six
"
>
<input
type=
"checkbox"
id=
"checkboxSix"
value=
"
China
"
>
<label
for=
"checkboxSix"
>
China
</label>
<label
for=
"checkboxSix"
>
China
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"mexican-cboxtags"
>
<ul
class=
"mexican-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxSeven"
value=
"
Order seven
"
>
<input
type=
"checkbox"
id=
"checkboxSeven"
value=
"
México
"
>
<label
for=
"checkboxSeven"
>
México
</label>
<label
for=
"checkboxSeven"
>
México
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"spanish-cboxtags"
>
<ul
class=
"spanish-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxEight"
value=
"
Order eigth
"
>
<input
type=
"checkbox"
id=
"checkboxEight"
value=
"
España
"
>
<label
for=
"checkboxEight"
>
España
</label>
<label
for=
"checkboxEight"
>
España
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"japanese-cboxtags"
>
<ul
class=
"japanese-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxNine"
value=
"
Order nine
"
>
<input
type=
"checkbox"
id=
"checkboxNine"
value=
"
Japón
"
>
<label
for=
"checkboxNine"
>
Japón
</label>
<label
for=
"checkboxNine"
>
Japón
</label>
</li>
</li>
</ul>
</ul>
...
@@ -268,27 +268,27 @@
...
@@ -268,27 +268,27 @@
<!--Contenido del dropdown-->
<!--Contenido del dropdown-->
<ul
class=
"winter-cboxtags"
>
<ul
class=
"winter-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxTen"
value=
"
Order ten
"
>
<input
type=
"checkbox"
id=
"checkboxTen"
value=
"
Invierno
"
>
<label
for=
"checkboxTen"
>
Invierno
</label>
<label
for=
"checkboxTen"
>
Invierno
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"spring-cboxtags"
>
<ul
class=
"spring-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxEleven"
value=
"
Order eleven
"
>
<input
type=
"checkbox"
id=
"checkboxEleven"
value=
"
Primavera
"
>
<label
for=
"checkboxEleven"
>
Primavera
</label>
<label
for=
"checkboxEleven"
>
Primavera
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"summer-cboxtags"
>
<ul
class=
"summer-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkboxTwelve"
value=
"
Order twelve
"
>
<input
type=
"checkbox"
id=
"checkboxTwelve"
value=
"
Verano
"
>
<label
for=
"checkboxTwelve"
>
Verano
</label>
<label
for=
"checkboxTwelve"
>
Verano
</label>
</li>
</li>
</ul>
</ul>
<ul
class=
"autumn-cboxtags"
>
<ul
class=
"autumn-cboxtags"
>
<li>
<li>
<input
type=
"checkbox"
id=
"checkbox13"
value=
"O
rder 13
"
>
<input
type=
"checkbox"
id=
"checkbox13"
value=
"O
toño
"
>
<label
for=
"checkbox13"
>
Otoño
</label>
<label
for=
"checkbox13"
>
Otoño
</label>
</li>
</li>
</ul>
</ul>
...
...
public/js/main.js
View file @
17a568fc
...
@@ -422,4 +422,5 @@
...
@@ -422,4 +422,5 @@
});
});
*/
*/
})();
})();
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment