Commit 979ffd27 by David Villalba

Guardamos menus personalizados.

parent 5f2942dc
......@@ -41,11 +41,30 @@ class Controller_Menupersonalizado_Index extends \Controller_App{
public function post_update(){
\Fuel\Core\Log::error("INPUTS --< " .print_r(\Fuel\Core\Input::post(),true));
$ids_recipes_selected = array();
$week = date("W");
foreach (\Input::post('input') as $item){
array_push($ids_recipes_selected,$this['recipe_id']);
$conditions = array(
'user_id' => \Session::get('user_id'),
'year' => date('Y'),
'week_year' => date("W"),
'recipe_id' => $item['recipe_id'],
'option' => $item['option'],
'day_week' => $item['day_week'],
);
$query = Model_Recipe::find('all',array('where' => $conditions));
if(!$query){
Model_Recipe::forge($conditions)->save();
}
}
\Fuel\Core\Log::error("SEMANA ----> ".print_r($week,true));
}
......
......@@ -61,12 +61,13 @@
<div class="row">
<div class="col-xs-11 plr0">
<input
id="{{ day.ds }}_lunchFirst"
id="{{ day.lunchFirst[0].id }}"
name="{{ day.ds }}_lunchFirst"
value="{{ day.lunchFirst[0].id }}"
type="radio"
data-day="{{ loop.index }}">
<label for="{{ day.ds }}_lunchFirst">{{ day.lunchFirst[0].name }}</label>
data-day="{{ loop.index }}"
data-option="lunchFirst">
<label for="{{ day.lunchFirst[0].id }}">{{ day.lunchFirst[0].name }}</label>
</div>
<div class="col-xs-1 plr0">
<i class="fa fa-search pointer a-black"></i>
......@@ -77,12 +78,14 @@
<div class="row mt20">
<div class="col-xs-11 plr0">
<input
id="{{ day.ds }}_lunchFirst"
id="{{ day.lunchFirst[1].id }}"
name="{{ day.ds }}_lunchFirst"
value="{{ day.lunchFirst[1].id }}"
type="radio"
data-day="{{ loop.index }}">
<label for="{{ day.ds }}_lunchFirst">{{ day.lunchFirst[1].name }}</label>
data-day="{{ loop.index }}"
data-option="lunchFirst">
<label for="{{ day.lunchFirst[1].id }}">{{ day.lunchFirst[1].name }}</label>
</div>
<div class="col-xs-1 plr0">
<i class="fa fa-search pointer a-black"></i>
......@@ -108,7 +111,9 @@
name="{{ day.ds }}_lunchSecond"
value="{{ day.lunchSecond[0].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="lunchSecond">
<label for="{{ day.lunchSecond[0].id }}">{{ day.lunchSecond[0].name }}</label>
</div>
<div class="col-xs-1 plr0">
......@@ -124,7 +129,9 @@
name="{{ day.ds }}_lunchSecond"
value="{{ day.lunchSecond[1].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="lunchSecond">
<label for="{{ day.lunchSecond[1].id }}">{{ day.lunchSecond[1].name }}</label>
</div>
<div class="col-xs-1 plr0">
......@@ -155,7 +162,9 @@
name="{{ day.ds }}_dinnerFirst"
value="{{ day.dinnerFirst[0].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="dinnerFirst">
<label for="{{ day.dinnerFirst[0].id }}">{{ day.dinnerFirst[0].name }}</label>
</div>
<div class="col-xs-1 plr0">
......@@ -171,7 +180,9 @@
name="{{ day.ds }}_dinnerFirst"
value="{{ day.dinnerFirst[1].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="dinnerFirst">
<label for="{{ day.dinnerFirst[1].id }}">{{ day.dinnerFirst[1].name }}</label>
</div>
<div class="col-xs-1 plr0">
......@@ -198,7 +209,9 @@
name="{{ day.ds }}_dinnerSecond"
value="{{ day.dinnerSecond[0].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="dinnerSecond">
<label for="{{ day.dinnerSecond[0].id }}">{{ day.dinnerSecond[0].name }}</label>
</div>
<div class="col-xs-1 plr0">
......@@ -214,7 +227,9 @@
name="{{ day.ds }}_dinnerSecond"
value="{{ day.dinnerSecond[1].id }}"
type="radio"
data-day="{{ loop.index }}">
data-day="{{ loop.index }}"
data-option="dinnerSecond">
<label for="{{ day.dinnerSecond[1].id }}">{{ day.dinnerSecond[1].name }}</label>
</div>
<div class="col-xs-1 plr0">
......
......@@ -7,13 +7,13 @@ $(document).ready(function() {
$(':input:checked').map(function () {
inputs.push({
'recipe_id': $(this).val(),
'recipe_id':$(this).val(),
'option': $(this).attr('data-option'),
'day_week': $(this).attr('data-day')
}
)
});
});
$.ajax({
url: "menupersonalizado/update",
type: "POST",
......
-- UPDATE TABLE RECIPES
ALTER TABLE `recipes`
ADD COLUMN `option` enum('lunchFirst','lunchSecond','dinnerFirst','dinnerSecond') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `year`;
/*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 50640
Source Host : localhost:3306
Source Database : inutralia_webapp
Target Server Type : MYSQL
Target Server Version : 50640
File Encoding : 65001
Date: 2018-12-10 16:46:14
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for ingredients
-- ----------------------------
DROP TABLE IF EXISTS `ingredients`;
CREATE TABLE `ingredients` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`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 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of ingredients
-- ----------------------------
-- ----------------------------
-- Table structure for recipes
-- ----------------------------
DROP TABLE IF EXISTS `recipes`;
CREATE TABLE `recipes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`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 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of recipes
-- ----------------------------
-- ----------------------------
-- Table structure for sessions
-- ----------------------------
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE `sessions` (
`session_id` varchar(40) NOT NULL,
`previous_id` varchar(40) NOT NULL,
`user_agent` text NOT NULL,
`ip_hash` char(32) NOT NULL DEFAULT '',
`created` int(10) unsigned NOT NULL DEFAULT '0',
`updated` int(10) unsigned NOT NULL DEFAULT '0',
`payload` longtext NOT NULL,
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:{}}');
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