Commit 290718c3 by Luis Perez

Actualizaciones listra de la compra

parent 6eea228d
......@@ -22,7 +22,12 @@ class Controller_Listacompra_Index extends \Controller_App{
public function before()
{
$recipes = Model_Recipe::get_recipes_current_week();
//Se cargan funciones de javascript especificas de esta funcionalidad
Casset::js('listacompra/index.js');
$recipes = Model_Recipe::get_recipes_current_week();
//PEDIR INGREDIENTES
//Recorremos las recetas para obtener los ingredientes.
......
......@@ -54,6 +54,7 @@ return array(
'lista-compra' => 'listacompra/index',
'lista-compra/delete_all' => 'listacompra/index/delete_all',
'lista-compra/delete' => 'listacompra/index/delete_ingredients',
......
......@@ -25,13 +25,13 @@
</div>
<div class="container-box-border-box">
<form class="ac-custom ac-checkbox" autocomplete="off">
<form class="ac-custom ac-checkmark" autocomplete="off">
<ul class="text-left ml0">
{% if count(ingredients) == 0 %}
<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>
<li> <input id="check_{{ i.id }}" name="check_{{ i.id }}" type="checkbox" rel="{{ i.id }}"/><label for="check_{{ i.id }}">{{ i.desc }}</label></li>
{% endfor %}
</ul>
</form>
......
......@@ -20,7 +20,7 @@
<button type="button" class="btn btn-custom btn-other" data-dismiss="modal">Cancelar</button>
</div>
<div class="col-md-6">
<button type="button" class="btn btn-custom btn-danger">Sí, borrarlos</button>
<button type="button" class="btn btn-custom btn-danger btn-delete-checked">Sí, borrarlos</button>
</div>
</div>
</div>
......
var ids =[];
$(document).ready(function() {
$(':input:checked').each(function () {
ids += $(this).attr('rel');
})
$('.btn-lista-compra').on('click', function (e) {
get_checkeds();
window.location.href = 'http://www.delsuper.es/inutralia?ids='+ids.toString()
})
$('.btn-delete-checked').on('click', function (e) {
get_checkeds();
$.ajax({
url: "listacompra/delete",
type: "POST",
method:"post",
data: {
id: $('#profile_id').val(),
inputs: inputs
},
success: function (data) {
if(data != "" && data != 0){
// Modal success
$('#modalSuccess').modal('show');
}else{
// Modal error
}
setTimeout(function(){
location.reload();
}, 2000);
}
})
})
});
function get_checkeds()
{
$(':input:checked').each(function () {
let id_val = $(this).attr('rel');
if( jQuery.inArray(id_val, ids)<0)
{
ids.push(id_val);
}
});
}
\ No newline at end of file
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