Commit 89679d00 by gema

Merge branch 'master' of http://git.setisl.com/inutraliaapp/2018_web_app into gemis_dev

parents 61b5a199 5f2942dc
......@@ -14,17 +14,43 @@ use Auth\Auth;
class Controller_Listacompra_Index extends \Controller_App{
//Variable para guardar las migas de pan que van a aparecer en las vistas
private $_bc = array();
//Array con los elementos del menu que se deben marcar con la clase "active" para que esten seleccionados en el menu.
private $_option_menu=array('Lista de la compra');
public function before()
{
$recipes = Model_Recipe::query()->where('week_year',date('W'))->get();
//PEDIR 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.
// foreach ()
parent::before();
}
public function action_index(){
$view = View::forge('listacompra/index.twig');
//Titulo de la vista
$view->title = "Lista de la Compra";
//Paso de las migas de pan a la vista
$view->bc = $this->_bc;
//Paso de las opciones de menu que deben aparecer seleccionadas
$view->option_menu = $this->_option_menu;
//Pasar la leyenda para la info funcionamiento de la página
$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
$view->action = "¿Estás seguro de que quieres borrar los productos de la lista de la compra?";
return Response::forge($view);
}
......
......@@ -67,7 +67,10 @@ class Controller_Login_Index extends Controller
if(!isset($return['status'])){
\Session::set_flash('name', current($return)->name);
$user = current($return);
\Session::set_flash('name', $user->name);
\Session::set('user_id', $user->id);
Response::redirect('/dashboard');
......
......@@ -14,7 +14,13 @@ use Auth\Auth;
class Controller_Menupersonalizado_Index extends \Controller_App{
public function before(){
// //Se cargan funciones de javascript especificas de esta funcionalidad
Casset::js('menupersonalizado/index.js');
parent::before();
}
public function get_index(){
......@@ -33,4 +39,14 @@ class Controller_Menupersonalizado_Index extends \Controller_App{
return Response::forge($view);
}
public function post_update(){
\Fuel\Core\Log::error("INPUTS --< " .print_r(\Fuel\Core\Input::post(),true));
$week = date("W");
\Fuel\Core\Log::error("SEMANA ----> ".print_r($week,true));
}
}
\ No newline at end of file
......@@ -14,17 +14,17 @@ use Orm\Model;
* @link http://seticonsultyn.es
*/
class Model_Localidad extends Model{
class Model_Ingredient extends Model{
protected static $_table_name = 'localidades';
protected static $_table_name = 'ingredients';
protected static $_primary_key = array('id');
protected static $_belongs_to = array(
'provincia' => array(
'key_from' => 'provincia_id',
'recipe' => array(
'key_from' => 'recipe_local_od',
'key_to' => 'id',
'model_to' => 'Model_Provincia',
'model_to' => 'Model_Recipe',
'cascade_delete' => false
),
);
......
......@@ -14,20 +14,20 @@ use Orm\Model;
* @link http://seticonsultyn.es
*/
class Model_Provincia extends Model{
class Model_Recipe extends Model{
protected static $_table_name = 'provincias';
protected static $_table_name = 'recipes';
protected static $_primary_key = array('id');
protected static $_has_many = array(
'localidades' => array(
'model_to' => 'Model_Localidad',
protected static $_has_many = array(
'ingredients' => array(
'key_from' => 'id',
'key_to' => 'provincia_id',
'cascade_save' => true,
'key_to' => 'recipe_local_id',
'model_to' => 'Model_Ingredients',
'cascade_delete' => false
)
),
);
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ return array(
// MENU PERSONALIZADO
'menupersonalizado' => 'menupersonalizado/index',
'menupersonalizado/update' => 'menupersonalizado/index/update',
// MENU SALUDABLES
'menussaludables' => 'menussaludables/lista/index',
......
/*
Navicat MySQL Data Transfer
Source Server : localhost3306
Source Server Version : 50641
Source Server : localhost_3306
Source Server Version : 50640
Source Host : localhost:3306
Source Database : inutralia_webapp
Target Server Type : MYSQL
Target Server Version : 50641
Target Server Version : 50640
File Encoding : 65001
Date: 2018-11-27 14:49:38
Date: 2018-12-10 16:46:14
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for auth_groups
-- Table structure for ingredients
-- ----------------------------
DROP TABLE IF EXISTS `auth_groups`;
CREATE TABLE `auth_groups` (
DROP TABLE IF EXISTS `ingredients`;
CREATE TABLE `ingredients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nombre` varchar(45) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
`is_blocked` enum('S','N') NOT NULL DEFAULT 'N',
`is_assignable` enum('S','N') DEFAULT NULL,
`ingredient_id` int(11) DEFAULT NULL,
`recipe_local_id` int(11) DEFAULT NULL,
`used` enum('N','S') DEFAULT 'S',
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for auth_groups_roles
-- Records of ingredients
-- ----------------------------
DROP TABLE IF EXISTS `auth_groups_roles`;
CREATE TABLE `auth_groups_roles` (
`group_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
PRIMARY KEY (`group_id`,`role_id`),
KEY `fk_auth_groups_roles_auth_roles1_idx` (`role_id`),
CONSTRAINT `fk_auth_groups_roles_auth_groups1` FOREIGN KEY (`group_id`) REFERENCES `auth_groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_auth_groups_roles_auth_roles1` FOREIGN KEY (`role_id`) REFERENCES `auth_roles` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for auth_roles
-- Table structure for recipes
-- ----------------------------
DROP TABLE IF EXISTS `auth_roles`;
CREATE TABLE `auth_roles` (
DROP TABLE IF EXISTS `recipes`;
CREATE TABLE `recipes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`role` varchar(45) DEFAULT NULL,
`permission` varchar(45) DEFAULT NULL,
`is_assignable` char(1) NOT NULL DEFAULT 'S',
`orden` int(11) DEFAULT NULL,
`recipe_id` int(11) DEFAULT NULL,
`day_week` int(11) DEFAULT NULL,
`week_year` int(11) DEFAULT NULL,
`year` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`loaded` enum('N','S') DEFAULT 'N',
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for auth_users
-- Records of recipes
-- ----------------------------
DROP TABLE IF EXISTS `auth_users`;
CREATE TABLE `auth_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` char(80) DEFAULT NULL,
`reset_pass_request` datetime DEFAULT NULL,
`salt` char(32) DEFAULT NULL,
`is_active` enum('S','N') NOT NULL DEFAULT 'S',
`is_confirmed` enum('S','N') NOT NULL DEFAULT 'S',
`nombre` varchar(45) DEFAULT NULL,
`apellidos` varchar(150) DEFAULT NULL,
`group_id` int(11) NOT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_auth_users_auth_groups1_idx` (`group_id`),
CONSTRAINT `fk_auth_users_auth_groups1` FOREIGN KEY (`group_id`) REFERENCES `auth_groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
-- ----------------------------
-- Table structure for sessions
......@@ -93,3 +67,8 @@ CREATE TABLE `sessions` (
PRIMARY KEY (`session_id`),
UNIQUE KEY `PREVIOUS` (`previous_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
-- ----------------------------
-- Records of sessions
-- ----------------------------
INSERT INTO `sessions` VALUES ('70895b479218ec65bbbe4c5c8ce42588', 'c4afba0a99a39694d674b12aef25eadb', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36', '4869e012aa045958bdf5c461577cf02d', '1544453980', '1544453980', 'a:3:{i:0;a:7:{s:10:\"session_id\";s:32:\"70895b479218ec65bbbe4c5c8ce42588\";s:11:\"previous_id\";s:32:\"c4afba0a99a39694d674b12aef25eadb\";s:7:\"ip_hash\";s:32:\"4869e012aa045958bdf5c461577cf02d\";s:10:\"user_agent\";s:115:\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\";s:7:\"created\";i:1544453980;s:7:\"updated\";i:1544453980;s:7:\"payload\";s:0:\"\";}i:1;a:3:{s:7:\"empresa\";a:2:{s:12:\"nombre_corto\";s:9:\"INUTRALIA\";s:12:\"nombre_largo\";s:9:\"INUTRALIA\";}s:10:\"token_auth\";s:28:\"U3VwZXJMdWlzaXRvOmx1aXNpdG8=\";s:14:\"expire_session\";i:1544457580;}i:2;a:0:{}}');
$(document).ready(function() {
$('.save-menu').on('click', function () {
var inputs = [];
$(':input:checked').map(function () {
inputs.push({
'recipe_id': $(this).val(),
'day_week': $(this).attr('data-day')
}
)
});
$.ajax({
url: "menupersonalizado/update",
type: "POST",
method:"post",
data: {
input: inputs
},
success: function (data) {
if(data != "" && data != 0){
// Modal success
$('#modalSuccess').modal('show');
}else{
// Modal error
}
setTimeout(function(){
location.reload();
}, 2000);
}
})
});
});
\ 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