Commit bfbb32b7 by David Villalba

Merge branch 'master' into dev_villa

parents dfed8d4d 6eea228d
...@@ -22,14 +22,15 @@ class Controller_Listacompra_Index extends \Controller_App{ ...@@ -22,14 +22,15 @@ class Controller_Listacompra_Index extends \Controller_App{
public function before() public function before()
{ {
$recipes = Model_Recipe::query()->where('week_year',date('W'))->get(); $recipes = Model_Recipe::get_recipes_current_week();
//PEDIR INGREDIENTES //PEDIR INGREDIENTES
//Recorremos las recetas para obtener los ingredientes. //Recorremos las recetas para obtener los ingredientes.
//**AVISO: Si ya se han cargado los ingredientes de una de las recetas, no se vuelve a pedir. Por lo tanto si algo cambia esa semana, no se cambiarán. //**AVISO: Si ya se han cargado los ingredientes de una de las recetas, no se vuelve a pedir. Por lo tanto si algo cambia esa semana, no se cambiarán.
// foreach () foreach ($recipes as $recipe)
{
$recipe->load_ingredients();
}
parent::before(); parent::before();
} }
...@@ -38,6 +39,17 @@ class Controller_Listacompra_Index extends \Controller_App{ ...@@ -38,6 +39,17 @@ class Controller_Listacompra_Index extends \Controller_App{
$view = View::forge('listacompra/index.twig'); $view = View::forge('listacompra/index.twig');
$recipes = Model_Recipe::get_recipes_current_week();
$recipe_ids = array();
foreach ($recipes as $recipe)
{
$recipe_ids[] = $recipe->id;
}
$view->ingredients = count($recipe_ids)>0 ? Model_Ingredient::get_ingredients_week($recipe_ids) : array();
//Titulo de la vista //Titulo de la vista
$view->title = "Lista de la Compra"; $view->title = "Lista de la Compra";
...@@ -51,7 +63,35 @@ class Controller_Listacompra_Index extends \Controller_App{ ...@@ -51,7 +63,35 @@ class Controller_Listacompra_Index extends \Controller_App{
$view->leyenda = "En esta pantalla se han cargado todos los ingredientes necesarios para realizar el menú personalizado que has elegido. Puedes añadir ingredientes nuevos, eliminar algunos o eliminarlos todos. Ten siempre tu lista de la compra a mano. Te damos la posibilidad de hacer la compra a través de la web DelSuper en el supermercado que prefieras en un solo click. Si pulsas en el botón hacer compra en Del Super te redireccionamos a su web con todos estos ingredientes seleccionados."; $view->leyenda = "En esta pantalla se han cargado todos los ingredientes necesarios para realizar el menú personalizado que has elegido. Puedes añadir ingredientes nuevos, eliminar algunos o eliminarlos todos. Ten siempre tu lista de la compra a mano. Te damos la posibilidad de hacer la compra a través de la web DelSuper en el supermercado que prefieras en un solo click. Si pulsas en el botón hacer compra en Del Super te redireccionamos a su web con todos estos ingredientes seleccionados.";
//Pasar texto de confirmacion de accion //Pasar texto de confirmacion de accion
$view->action = "¿Estás seguro de que quieres borrar los productos de la lista de la compra?"; $view->action = "¿Estás seguro de que quieres borrar los productos de la lista de la compra?";
return Response::forge($view); return Response::forge($view);
} }
public function get_delete_all()
{
$recipes = Model_Recipe::get_recipes_current_week();
foreach ($recipes as $recipe)
{
Log::error("ENTRO EN RECETAS!!!");
foreach ($recipe->ingredients as $ingrediente)
{
Log::error("INTENTO BORRAR INGREDIENTE!!! $ingrediente->id");
$ingrediente->delete();
}
}
Session::set_flash('success', "Se han borrado los ingredientes correctamente");
return Response::redirect_back();
}
public function post_delete_ingredients()
{
$ingredients = Input::post('ingredients_ids');
foreach ($ingredients as $ingredient)
{
$ingredient->delete();
}
}
} }
\ No newline at end of file
...@@ -22,12 +22,17 @@ class Model_Ingredient extends Model{ ...@@ -22,12 +22,17 @@ class Model_Ingredient extends Model{
protected static $_belongs_to = array( protected static $_belongs_to = array(
'recipe' => array( 'recipe' => array(
'key_from' => 'recipe_local_od', 'key_from' => 'recipe_local_id',
'key_to' => 'id', 'key_to' => 'id',
'model_to' => 'Model_Recipe', 'model_to' => 'Model_Recipe',
'cascade_delete' => false 'cascade_delete' => false
), ),
); );
public static function get_ingredients_week($recipes_ids)
{
return self::query()->where('recipe_local_id', 'in',$recipes_ids)->order_by('used','DESC')->group_by('ingredient_id')->get();
}
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ class Model_Recipe extends Model{ ...@@ -27,7 +27,7 @@ class Model_Recipe extends Model{
'model_to' => 'Model_Ingredient', 'model_to' => 'Model_Ingredient',
'cascade_delete' => false, 'cascade_delete' => false,
'conditions' => array( 'conditions' => array(
'where' => array('used' => 0), 'where' => array('used' => 'N'),
'order_by' => array('used' => 'DESC'), 'order_by' => array('used' => 'DESC'),
'group_by' => 'ingredient_id' 'group_by' => 'ingredient_id'
) )
...@@ -62,9 +62,11 @@ class Model_Recipe extends Model{ ...@@ -62,9 +62,11 @@ class Model_Recipe extends Model{
$recipe = $this->ws_recipe_get($this->recipe_id); $recipe = $this->ws_recipe_get($this->recipe_id);
if(!$recipe)
return array();
foreach ($recipe->ingredients as $ingredientRecipe) foreach ($recipe->ingredients as $ingredientRecipe)
{ {
$ingredient = Model_Ingredient::forge(); $ingredient = Model_Ingredient::forge();
$ingredient->ingredient_id = $ingredientRecipe->id; $ingredient->ingredient_id = $ingredientRecipe->id;
...@@ -76,7 +78,6 @@ class Model_Recipe extends Model{ ...@@ -76,7 +78,6 @@ class Model_Recipe extends Model{
$ingredient->created_at = date("Y-m-d H:i:s"); $ingredient->created_at = date("Y-m-d H:i:s");
$this->ingredients[] = $ingredient; $this->ingredients[] = $ingredient;
} }
$this->loaded = 'S'; $this->loaded = 'S';
......
...@@ -53,6 +53,7 @@ return array( ...@@ -53,6 +53,7 @@ return array(
'articulo-detalle' => 'articulo/index', 'articulo-detalle' => 'articulo/index',
'lista-compra' => 'listacompra/index', 'lista-compra' => 'listacompra/index',
'lista-compra/delete_all' => 'listacompra/index/delete_all',
......
...@@ -27,8 +27,11 @@ ...@@ -27,8 +27,11 @@
<div class="container-box-border-box"> <div class="container-box-border-box">
<form class="ac-custom ac-checkbox" autocomplete="off"> <form class="ac-custom ac-checkbox" autocomplete="off">
<ul class="text-left ml0"> <ul class="text-left ml0">
{% for i in 0..14 %} {% if count(ingredients) == 0 %}
<li> <input id="check_{{ i }}" name="check_{{ i }}" type="checkbox" checked="true"/><label for="check_{{ i }}">Ingrediente {{ i }}</label></li> <h4>Sin Ingredientes</h4>
{% endif %}
{% for i in ingredients %}
<li> <input id="check_{{ i.id }}" name="check_{{ i.id }}" type="checkbox" checked="true"/><label for="check_{{ i.id }}">{{ i.desc }}</label></li>
{% endfor %} {% endfor %}
</ul> </ul>
</form> </form>
...@@ -60,7 +63,8 @@ ...@@ -60,7 +63,8 @@
<!--modal add producto--> <!--modal add producto-->
{% include 'modal_add_product.twig' %} {% include 'modal_add_product.twig' %}
<!--modal delete--> <!--modal delete-->
{% include 'modals/modal_delete.twig' %} {% include 'modal_delete_all.twig' %}
{% include 'modal_delete.twig' %}
{% endblock %} {% endblock %}
......
<!-- Modal DELETE PRODUCTOS -->
<div class="modal fade" id="modalDelete" tabindex="-1" role="dialog" aria-labelledby="modalDelete">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<div class="text-center">
<img src="assets/img/listacompra/delete.png" class="img-responsive-custom"/>
</div>
<h2 class="text-center">¿BORRAR?</h2>
<div class="content text-center pb40">
{{ action }}
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-6">
<button type="button" class="btn btn-custom btn-other" data-dismiss="modal">Cancelar</button>
</div>
<div class="col-md-6">
<a href="lista-compra/delete_all" type="button" class="btn btn-custom btn-danger">Sí, borrarlos</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
{% for i in items %} {% for i in items %}
<a href={{ "menussaludables-menu/"~ i.id }}> <a href={{ "menussaludables-menu/"~ i.id }}>
<div class="row item-list-style"> <div class="row item-list-style">
<div class="col-xs-11"> Menú {{ i.ds }}</div> <div class="col-xs-10"> Menú {{ i.ds }}</div>
<div class="col-xs-1"><i class="fa fa-angle-right"></i></div> <div class="col-xs-2 text-right"><i class="fa fa-angle-right"></i></div>
</div> </div>
</a> </a>
{% endfor %} {% endfor %}
......
...@@ -136,11 +136,7 @@ ...@@ -136,11 +136,7 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-4 col-md-offset-8">
<button class="btn btn-custom btn-menus-saludables mt20" ><i class="fa fa-save"></i> Guardar Selección</button>
</div>
</div>
</div> </div>
......
<h2>{{ recipe.name }}</h2> <h2>{{ recipe.shortName }}</h2>
<!-- imagen mas caja negra--> <!-- imagen mas caja negra-->
<img src="{{ recipe.image }}" class="img-responsive-custom w100pc"> <img src="{{ recipe.image }}" class="img-responsive-custom w100pc">
......
...@@ -470,6 +470,18 @@ a:focus { ...@@ -470,6 +470,18 @@ a:focus {
font-size:0.7em; font-size:0.7em;
text-transform: lowercase; text-transform: lowercase;
} }
@media (min-width:200px) and (max-width:400px){
h2{
font-size:16px;
}
}
@media (min-width:401px) and (max-width:600px){
h2{
font-size:20px;
}
}
/*****************************************************************************/ /*****************************************************************************/
/**********************************CHECKBOX Y RADIOBUTTON CUSTOM*****************/ /**********************************CHECKBOX Y RADIOBUTTON CUSTOM*****************/
/***************************************************************************************/ /***************************************************************************************/
...@@ -896,6 +908,11 @@ a:focus { ...@@ -896,6 +908,11 @@ a:focus {
top:0; top:0;
right:0; right:0;
} }
@media(max-width:500px){
.date-box{
font-size:0.8em;
}
}
/*****************************************************************************************************************************************/ /*****************************************************************************************************************************************/
/*********************************************************MENÚS SALUDABLES***************************************************************/ /*********************************************************MENÚS SALUDABLES***************************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment