Commit 65f44adc by David Villalba

RECETARIO --> Funcionalidad filtros terminados.

parent 98f23780
......@@ -68,7 +68,36 @@ class Controller_Recetario_Index extends \Controller_App{
$view->groups_filters = $this->ws_options_get();
$view->recipes = $this->ws_recipe_get();
$inputs = array();
$criterio_options = array();
// Preparamos el array para que lo acepte la API
if(\Input::post('desc') != ""){
$inputs['desc'] = \Input::post('desc');
}
if(!is_null(\Input::post('flags_or'))){
$inputs['flags_or'] = implode(",",\Input::post('flags_or'));
$criterio_options = array_merge($criterio_options,\Input::post('flags_or'));
}
if(!is_null(\Input::post('flags'))){
$inputs['flags'] = implode(",",\Input::post('flags'));
$criterio_options = array_merge($criterio_options,\Input::post('flags'));
}
$view->recipes = $this->ws_recipes_post($inputs);
$view->criterio_desc = \Input::post('desc');
$view->criterio_options = $criterio_options;
return Response::forge($view);
......
......@@ -131,9 +131,15 @@ trait Trait_InutraliaWS {
}
public function ws_options_post(){
public function ws_recipes_post($data){
return json_decode($this->request_generic('options'));
$data_json = json_encode($data);
$extra_options = array(
CURLOPT_POSTFIELDS => $data_json
);
return json_decode($this->request_generic('recipes',"post",1,$extra_options,array('Content-Length: ' . strlen($data_json))));
}
......
......@@ -11,7 +11,11 @@
</div>
<!--contenido desplegable filtros-->
<div class="hidden" id="content-filter-recetario">
<form>
<form action="{{ url('recetario') }}" method="post">
<labe> Nombre de receta </labe>
<input class="form-control" name="desc" value="{{ criterio_desc }}">
<br>
{% for group in groups_filters %}
{# ETIQUETA DEL GRUPO #}
......@@ -21,8 +25,13 @@
{% for option in group.options %}
<div class="col-md-3">
<div class="form-group text-center">
<label class="switch" for="switch_filter_{{ group.id~'_'~option.id }}">
<input type="checkbox" id="switch_filter_{{ group.id~'_'~option.id }}" />
<label class="switch" for="switch_filter_{{ option.id }}">
<input type="checkbox"
{% if group.id == 1 %} name="flags_or[]" {% else %} name="flags[]"{% endif %}
id="switch_filter_{{ option.id }}"
value="{{ option.id }}"
{% if option.id in criterio_options %} checked {% endif %}
/>
<div class="slider round"></div>
</label>
<p>{{ option.name }}</p>
......@@ -34,7 +43,7 @@
<div class="row">
<div class="col-md-6 col-md-offset-6">
<button class="btn btn-custom btn-other mt20" > aplicar <i class="fa fa-angle-double-right"></i></button>
<button type="submit" class="btn btn-custom btn-other mt20" > aplicar <i class="fa fa-angle-double-right"></i></button>
</div>
</div>
</form>
......
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