diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js
index 6d79ca2a..01d42309 100644
--- a/app/assets/javascripts/addorder.js
+++ b/app/assets/javascripts/addorder.js
@@ -10,6 +10,7 @@ $(function(){
//show menu item list when click menu category
function show_menu_item_list(url_item){
+
var menu_list = $('.menu_items_list');
menu_list.empty();
//Start Ajax
@@ -22,22 +23,11 @@ $(function(){
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
+
+
for(var field in menu_items) {
if (menu_items[field].is_sub_item == false) {
instances = menu_items[field].instances ;
- $(instances).each(function(i){
- if (instances[i].is_default === true) {
- code = instances[i].code;
- name = instances[i].name;
- price = parseFloat(instances[i].price).toFixed(2);
- is_available = instances[i].is_available ;
- is_on_promotion = instances[i].is_on_promotion;
- item_attributes = instances[i].values;
- promotion_price = instances[i].promotion_price;
- code = instances[i].code;
- }
- });
-
qty = 1;
options = [];
@@ -45,10 +35,32 @@ $(function(){
fa_plus = '';
menu_item_box = 'set_item_box';
data_target = 'sx_item_set_detailModal';
+
+ code = menu_items[field].code;
+ name = menu_items[field].name;
+ price = 0;//parseFloat( menu_items[field].price).toFixed(2);
+ is_available = menu_items[field].is_available ;
+ is_on_promotion = 0;
+ item_attributes = menu_items[field].attributes;
+ promotion_price = menu_items[field].promotion_price;
}else{
fa_plus = 'fa-plus';
menu_item_box = 'menu_item_box';
- data_target = 'sx_item_detailModal'
+ data_target = 'sx_item_detailModal';
+
+ $(instances).each(function(i){
+ if (instances[i].is_default === true) {
+ code = instances[i].code;
+ name = instances[i].name;
+ price = parseFloat(instances[i].price).toFixed(2);
+ is_available = instances[i].is_available ;
+ is_on_promotion = instances[i].is_on_promotion;
+ item_attributes = instances[i].values;
+ promotion_price = instances[i].promotion_price;
+ code = instances[i].code;
+ }
+ });
+
}
if (menu_items[field].image) {
@@ -108,6 +120,9 @@ $(function(){
item_sets = $(this).data('item-sets');
for(var field in item_sets) {
+
+ $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
+
value = item_sets[field]["instances"];
$(value).each(function(i){
$.ajax({
@@ -121,6 +136,8 @@ $(function(){
+"' data-code='"+result["code"]
+"' data-price='"+result["price"]
+"' data-option='"+JSON.stringify(result["options"])
+ +"' data-min-qty='"+item_sets[field]["min_selectable_qty"]
+ +"' data-max-qty='"+item_sets[field]["max_selectable_qty"]
+"'>"
+'
'
+'
'+result["name"]+''
@@ -156,46 +173,54 @@ $(function(){
$(".options-list").empty();
+ rowCount = $('.selected-instance');
item_options = $(this).data('option');
+
+ min_qty = $(this).data('min-qty');
+ max_qty = $(this).data('max-qty');
+
code = $(this).data('code');
- for(var field in item_options) {
- value = item_options[field]["values"];
- type = item_options[field]["type"];
- row = "
"+type+"
"
- $(value).each(function(i){
- row +="
";
- });
- $(".options-list").append(row);
+ if (rowCount.length+1 <= max_qty) {
+ for(var field in item_options) {
+ value = item_options[field]["values"];
+ type = item_options[field]["type"];
+ row = "
"+type+"
"
+ $(value).each(function(i){
+ row +="
";
+ });
+ $(".options-list").append(row);
+ }
}
-
- if($(this).hasClass('selected-instance') == true){
- sub_total = $('#set_total_price').text();
- name = $(this).data('name');
- price = $(this).data('price');
- // qty = $('#set_change_qty').val();
- qty = document.getElementById("set_count").value;
- total = qty*price;
- var total_price = +sub_total - +total;
- $(this).removeClass('selected-instance');
- $(".options-list").empty();
- $(this).removeAttr('data-options');
- $('#instance_option').text('')
- }else {
-
- sub_total = $('#set_total_price').text();
- name = $(this).data('name');
- price = $(this).data('price');
- // qty = $('#set_change_qty').val();
- qty = document.getElementById("set_count").value;
- total = qty*price;
- var total_price = +sub_total + +total;
- $(this).addClass('selected-instance');
- }
- $('#set_unit_price').text(price);
- $('#set_total_price').text(total_price);
+ if($(this).hasClass('selected-instance') == true){
+ sub_total = $('#set_total_price').text();
+ name = $(this).data('name');
+ price = $(this).data('price');
+ // qty = $('#set_change_qty').val();
+ qty = document.getElementById("set_count").value;
+ total = qty*price;
+ var total_price = +sub_total - +total;
+ $(this).removeClass('selected-instance');
+ $(".options-list").empty();
+ $(this).removeAttr('data-options');
+ $('#instance_option').text('')
+ }else {
+ if (rowCount.length+1 <= max_qty) {
+ sub_total = $('#set_total_price').text();
+ name = $(this).data('name');
+ price = $(this).data('price');
+ // qty = $('#set_change_qty').val();
+ qty = document.getElementById("set_count").value;
+ total = qty*price;
+ var total_price = +sub_total + +total;
+ $(this).addClass('selected-instance');
+ }
+ }
+ $('#set_unit_price').text(price);
+ $('#set_total_price').text(total_price);
+
}); //End selecct attribute buttom
// click add order
@@ -204,36 +229,49 @@ $(function(){
qty = parseInt($('#set_count').val());
item_code = $('#set_item_code').text();
item_name = $('#set_name').text();
+ min_qty = $(this).data('min-qty');
var items = $('.selected-instance');
- attribute_arr = []
- option_arr = []
- var rowCount = $('.summary-items tbody tr').length+1;
- $(items).each(function(i){
- code = $(items[i]).attr('data-code');
- name = $(items[i]).attr('data-name');
- price = $(items[i]).attr('data-price');
- option = $(items[i]).attr('data-options');
- total = qty * price ;
- option_arr.push(option);
- row ="
"
- +'| '+rowCount+' | '
- +'' + item_name+ ' ' + name +' | '
- +'' + qty + ' | '
- +''
- + parseFloat(total).toFixed(2)
- +' | '
- +'
';
- $(".summary-items tbody").append(row);
- rowCount = rowCount + 1;
- });
- calculate_sub_total();
+ if (items.length >= min_qty) {
+ attribute_arr = []
+ option_arr = []
+ var rowCount = $('.summary-items tbody tr').length+1;
+ $(items).each(function(i){
+ code = $(items[i]).attr('data-code');
+ name = $(items[i]).attr('data-name');
+ price = $(items[i]).attr('data-price');
+ option = $(items[i]).attr('data-options');
+ total = qty * price ;
+ option_arr.push(option);
+ row ="
"
+ +'| '+rowCount+' | '
+ +'' + item_name+ ' ' + name +' | '
+ +'' + qty + ' | '
+ +''
+ + parseFloat(total).toFixed(2)
+ +' | '
+ +'
';
+ $(".summary-items tbody").append(row);
+ rowCount = rowCount + 1;
+ });
+ calculate_sub_total();
+ $(".sx_item_set_detailModal").css({ 'display': "none" });
+ }else{
+ $(".sx_item_set_detailModal").css({ 'display': "block" });
+ $.alert({
+ title: 'Alert!',
+ content: 'Please Select Minimum ' + min_qty + " items",
+ type: 'red',
+ typeAnimated: true,
+ btnClass: 'btn-danger',
+ });
+ }
}); //End add order Click
@@ -596,6 +634,9 @@ $(function(){
$(".item_box").removeAttr("data-active");
});
+ $('#sx_item_set_detailModal').on('click','#close', function(){
+ $("#sx_item_set_detailModal").css({ 'display': "none" });
+ });
//click save buttom after change qty
$('#sx_itemModal').on('click','#save', function(){
summary_items_filter();
diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss
index 82b84afd..df008329 100644
--- a/app/assets/stylesheets/CRM.scss
+++ b/app/assets/stylesheets/CRM.scss
@@ -81,4 +81,16 @@
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
+}
+
+#container {
+ margin: 0px auto;
+ width: 480px;
+ height: 375px;
+
+}
+#videoElement {
+ width: 480px;
+ height: 375px;
+
}
\ No newline at end of file
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 6c9127ae..7f68eba3 100644
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -9,7 +9,7 @@ class Origami::AddordersController < BaseOrigamiController
end
def detail
- @menu = MenuCategory.all
+ @menu = MenuCategory.all.active
@table_id = params[:id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
@@ -36,6 +36,7 @@ class Origami::AddordersController < BaseOrigamiController
if (params[:id])
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
+ puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
MenuCategory.current_menu
diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb
index d37a59c9..f97aa09e 100644
--- a/app/controllers/settings/set_menu_items_controller.rb
+++ b/app/controllers/settings/set_menu_items_controller.rb
@@ -125,7 +125,8 @@ class Settings::SetMenuItemsController < ApplicationController
end
def set_settings_item_attribute
- @item_attributes = MenuItemAttribute.all.order("id asc").map{|a| [a.name, a.value]}
+ @item_attributes = MenuItemAttribute.all.order("id asc")#.map{|a| [a.name, a.value]}
+
end
def set_settings_item_option
diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb
index 29484bcc..e386a227 100644
--- a/app/models/menu_category.rb
+++ b/app/models/menu_category.rb
@@ -9,6 +9,7 @@ class MenuCategory < ApplicationRecord
validates_presence_of :name, :menu, :order_by
default_scope { order('order_by asc') }
+ scope :active, -> {where("is_available = 1")}
def self.destroyCategory(menu_category)
# find the sub menu item of current item
diff --git a/app/models/promotion.rb b/app/models/promotion.rb
index 021fda65..d17a39b0 100644
--- a/app/models/promotion.rb
+++ b/app/models/promotion.rb
@@ -23,7 +23,7 @@ class Promotion < ApplicationRecord
end
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
- promoList = Promotion.where("(Date_Format(promo_start_date, 'YYYY-MM-DD') <=? AND Date_Format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
+ promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
return promoList
end
diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
index 94b29837..fe7c1979 100644
--- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder
+++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
@@ -92,9 +92,12 @@ json.options opt_format
json.instances item.menu_item_instances do |is|
# Convert id to name for attributes
instance_attr = []
+
is.item_attributes.each do |ia|
# mItemAttr = MenuItemAttribute.find(is)
- instance_attr.push(ia)
+ # instance_attr.push(ia)
+ mItemAttr = MenuItemAttribute.find(ia).name
+ instance_attr.push(mItemAttr)
end
json.id is.id
diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb
index c39f065f..260bdbcd 100644
--- a/app/views/crm/customers/_new_form.html.erb
+++ b/app/views/crm/customers/_new_form.html.erb
@@ -138,7 +138,29 @@
+
+