solved some data issues
This commit is contained in:
parent
e5cee1caca
commit
3a1150da5a
@ -26,7 +26,7 @@ class Crunchbutton_Dish extends Cana_Table {
|
||||
public function toppings() {
|
||||
if (!isset($this->_toppings)) {
|
||||
$this->_toppings = Topping::q('
|
||||
select topping.* from topping
|
||||
select topping.*, dish_topping.default from topping
|
||||
left join dish_topping using(id_topping)
|
||||
where id_dish="'.$this->id_dish.'"
|
||||
');
|
||||
@ -36,8 +36,8 @@ class Crunchbutton_Dish extends Cana_Table {
|
||||
|
||||
public function substitutions() {
|
||||
if (!isset($this->_substitution)) {
|
||||
$this->_substitution = Topping::q('
|
||||
select substitution.* from substitution
|
||||
$this->_substitution = Substitution::q('
|
||||
select substitution.*, dish_substitution.default from substitution
|
||||
left join dish_substitution using(id_substitution)
|
||||
where id_dish="'.$this->id_dish.'"
|
||||
');
|
||||
|
||||
@ -149,6 +149,7 @@ body {
|
||||
padding: 5px;
|
||||
width: 300px;
|
||||
float: right;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.restaurant-pic {
|
||||
@ -435,6 +436,7 @@ and (max-device-width : 480px) {
|
||||
}
|
||||
body {
|
||||
background: #fff url(/assets/images/bg.gif);
|
||||
background: #fff url(/assets/images/crisp_paper_ruffles-mobile.png);
|
||||
}
|
||||
.logo-img {
|
||||
width: 184px;
|
||||
|
||||
@ -243,21 +243,42 @@ App.cart = {
|
||||
extras: {},
|
||||
},
|
||||
add: function(type, item) {
|
||||
var id = _.uniqueId('cart-');
|
||||
var
|
||||
id = _.uniqueId('cart-'),
|
||||
top = App.cached['Dish'][item].toppings(),
|
||||
sub = App.cached['Dish'][item].substitutions(),
|
||||
toppings = {},
|
||||
substitutions = {};
|
||||
|
||||
switch (type) {
|
||||
case 'Dish':
|
||||
|
||||
for (x in top) {
|
||||
if (top[x]['default'] == 1) {
|
||||
toppings[top[x].id_topping] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (x in sub) {
|
||||
if (sub[x]['default'] == 1) {
|
||||
substitutions[sub[x].id_substitution] = true;
|
||||
}
|
||||
}
|
||||
|
||||
App.cart.items.dishes[id] = {
|
||||
id: item,
|
||||
substitutions: [],
|
||||
toppings: []
|
||||
substitutions: substitutions,
|
||||
toppings: toppings
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
case 'Side':
|
||||
App.cart.items.sides[id] = {
|
||||
id: item
|
||||
};
|
||||
break;
|
||||
|
||||
case 'Extra':
|
||||
App.cart.items.extras[id] = {
|
||||
id: item
|
||||
@ -321,15 +342,23 @@ App.cart = {
|
||||
sub = obj.substitutions();
|
||||
|
||||
for (x in top) {
|
||||
var check = $('<input type="checkbox" class="cart-customize-check">');
|
||||
if (cartitem.toppings[top[x].id_topping]) {
|
||||
check.attr('checked','checked');
|
||||
}
|
||||
var topping = $('<div class="cart-item-customize-item" data-id_topping="' + top[x].id_topping + '"></div>')
|
||||
.append('<input type="checkbox" class="cart-customize-check">')
|
||||
.append(check)
|
||||
.append('<label>' + top[x].name + '</label>');
|
||||
el.append(topping);
|
||||
}
|
||||
|
||||
for (x in sub) {
|
||||
var check = $('<input type="checkbox" class="cart-customize-check">');
|
||||
if (cartitem.substitutions[sub[x].id_substitution]) {
|
||||
check.attr('checked','checked');
|
||||
}
|
||||
var substitution = $('<div class="cart-item-customize-item" data-id_substitution="' + sub[x].id_substitution + '"></div>')
|
||||
.append('<input type="checkbox" class="cart-customize-check">')
|
||||
.append(check)
|
||||
.append('<label>' + sub[x].name + '</label>');
|
||||
el.append(substitution);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user