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
fac1f0e7
authored
May 12, 2023
by
Juan Montilla
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/developmanu' into developJC
parents
a6a37484
17a568fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
66 deletions
app/Controllers/InsertRecipeController.php
app/Views/pages/home.php
app/Views/templates/header.php
app/Controllers/InsertRecipeController.php
View file @
fac1f0e7
...
...
@@ -9,11 +9,12 @@ class InsertRecipeController extends Controller
public
function
index
()
{
return
view
(
'templates/header'
)
.
view
(
'pages/insertRecipe'
)
.
view
(
'pages/insertRecipe'
)
.
view
(
'templates/footer'
);
}
public
function
search_ingredient
()
{
public
function
search_ingredient
()
{
// Obtener la consulta de búsqueda desde el formulario
$query
=
$this
->
request
->
getVar
(
'query'
);
...
...
@@ -28,7 +29,7 @@ class InsertRecipeController extends Controller
}
public
function
insert_recipe
()
{
{
// Cargar los modelos necesarios
$recipeModel
=
new
\App\Models\RecipesModel
();
$recipesIngredientModel
=
new
\App\Models\RecipesIngredientModel
();
...
...
@@ -68,7 +69,7 @@ class InsertRecipeController extends Controller
// Redireccionar a la página principal
return
redirect
()
->
to
(
'/home'
);
}
}
}
\ No newline at end of file
app/Views/pages/home.php
View file @
fac1f0e7
<main
id=
"main"
class=
"main"
>
<div
class=
"pagetitle"
>
<h1>
Recetas
</h1>
<nav>
...
...
@@ -11,8 +10,8 @@
</nav>
</div>
<!-- End Page Title -->
<section
class=
"section dashboard"
id=
"recipeSection"
>
<div
id=
"recipeCards"
>
<section
class=
"section dashboard"
>
<?php
$recipesModel
=
new
\App\Models\RecipesModel
();
$recipes
=
$recipesModel
->
findAll
();
...
...
@@ -22,6 +21,8 @@
$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
);
?>
"
>
...
...
@@ -70,55 +71,9 @@
}
}
?>
</div>
</section>
</main>
<!-- End #main -->
<script>
let
originalRecipes
;
$
(
document
).
ready
(
function
()
{
// Cuando se hace click en cualquier checkbox
originalRecipes
=
$
(
"#recipeCards"
).
html
();
$
(
"input[type='checkbox']"
).
click
(
function
()
{
let
vegan
=
$
(
'#checkboxOne'
).
is
(
':checked'
)
?
1
:
0
;
let
origins
=
[];
let
seasons
=
[];
// Recoger los valores de los checkboxes de origen seleccionados
$
(
"input[id^='checkboxFour']:checked, input[id^='checkboxFive']:checked, input[id^='checkboxSix']:checked, input[id^='checkboxSeven']:checked, input[id^='checkboxEight']:checked, input[id^='checkboxNine']:checked"
).
each
(
function
()
{
origins
.
push
(
$
(
this
).
val
());
});
// Recoger los valores de los checkboxes de estaciones seleccionados
$
(
"input[id^='checkboxTen']:checked, input[id^='checkboxEleven']:checked, input[id^='checkboxTwelve']:checked, input[id^='checkbox13']:checked"
).
each
(
function
()
{
seasons
.
push
(
$
(
this
).
val
());
});
</section>
// Verificar si todos los checkboxes están desmarcados
if
(
$
(
"input[type='checkbox']:checked"
).
length
==
0
)
{
// Si todos los checkboxes están desmarcados, restablece el contenido de las recetas
$
(
"#recipeCards"
).
html
(
originalRecipes
);
}
else
{
// Si no, realiza la petición AJAX
$
.
ajax
({
url
:
'/filter_recipes'
,
// Asegúrate de que esta ruta esté definida en tus rutas
method
:
'POST'
,
data
:
{
is_vegan
:
vegan
,
origin
:
origins
,
season
:
seasons
},
//Meter los datos en un body para hacer el query directamente, especificar el formato JSON y comprobar si hay que especificar en header
success
:
function
(
data
)
{
// Actualizamos el contenido de las recetas
$
(
"#recipeCards"
).
html
(
data
);
originalRecipes
=
$
(
"#recipeCards"
).
html
();
}
});
}
});
});
</script>
</main>
<!-- End #main -->
\ No newline at end of file
app/Views/templates/header.php
View file @
fac1f0e7
...
...
@@ -96,7 +96,6 @@
<img
src=
"
<?=
base_url
(
"imagenes/profile.png"
)
?>
"
alt=
"Profile"
class=
"rounded-circle"
>
<?php
endif
;
?>
<span
class=
"d-none d-md-block dropdown-toggle ps-2"
>
</span>
...
...
@@ -215,41 +214,41 @@
<!--Contenido del dropdown-->
<ul
class=
"indian-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxFour"
value=
"
India
"
>
<input
type=
"checkbox"
id=
"checkboxFour"
value=
"
Order four
"
>
<label
for=
"checkboxFour"
>
India
</label>
</li>
</ul>
<ul
class=
"french-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxFive"
value=
"
Francia
"
>
<input
type=
"checkbox"
id=
"checkboxFive"
value=
"
Order five
"
>
<label
for=
"checkboxFive"
>
Francia
</label>
</li>
</ul>
<ul
class=
"chinese-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxSix"
value=
"
China
"
>
<input
type=
"checkbox"
id=
"checkboxSix"
value=
"
Order six
"
>
<label
for=
"checkboxSix"
>
China
</label>
</li>
</ul>
<ul
class=
"mexican-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxSeven"
value=
"
México
"
>
<input
type=
"checkbox"
id=
"checkboxSeven"
value=
"
Order seven
"
>
<label
for=
"checkboxSeven"
>
México
</label>
</li>
</ul>
<ul
class=
"spanish-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxEight"
value=
"
España
"
>
<input
type=
"checkbox"
id=
"checkboxEight"
value=
"
Order eigth
"
>
<label
for=
"checkboxEight"
>
España
</label>
</li>
</ul>
<ul
class=
"japanese-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxNine"
value=
"
Japón
"
>
<input
type=
"checkbox"
id=
"checkboxNine"
value=
"
Order nine
"
>
<label
for=
"checkboxNine"
>
Japón
</label>
</li>
</ul>
...
...
@@ -268,27 +267,27 @@
<!--Contenido del dropdown-->
<ul
class=
"winter-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxTen"
value=
"
Invierno
"
>
<input
type=
"checkbox"
id=
"checkboxTen"
value=
"
Order ten
"
>
<label
for=
"checkboxTen"
>
Invierno
</label>
</li>
</ul>
<ul
class=
"spring-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxEleven"
value=
"
Primavera
"
>
<input
type=
"checkbox"
id=
"checkboxEleven"
value=
"
Order eleven
"
>
<label
for=
"checkboxEleven"
>
Primavera
</label>
</li>
</ul>
<ul
class=
"summer-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkboxTwelve"
value=
"
Verano
"
>
<input
type=
"checkbox"
id=
"checkboxTwelve"
value=
"
Order twelve
"
>
<label
for=
"checkboxTwelve"
>
Verano
</label>
</li>
</ul>
<ul
class=
"autumn-cboxtags"
>
<li>
<input
type=
"checkbox"
id=
"checkbox13"
value=
"O
toño
"
>
<input
type=
"checkbox"
id=
"checkbox13"
value=
"O
rder 13
"
>
<label
for=
"checkbox13"
>
Otoño
</label>
</li>
</ul>
...
...
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