From 361e43966420e7e9a7cff1c47611a2d3113bb2dc Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Mon, 11 Sep 2017 15:44:45 +0630 Subject: [PATCH 01/12] update qr code --- app/assets/stylesheets/CRM.scss | 12 ++++++ app/views/crm/customers/_new_form.html.erb | 22 ++++++++++ app/views/crm/customers/index.html.erb | 49 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) 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/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 @@

Card Tap

+ + From bbcce13a2e2c068f73d8dfb7457af72f1402a12a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 13 Sep 2017 09:21:35 +0630 Subject: [PATCH 04/12] update addorder --- app/assets/javascripts/OQS.js | 6 +- app/assets/javascripts/addorder.js | 69 +++++++++++++++---- .../menu_item_attributes_controller.rb | 5 +- .../menu_item_attributes/show.json.jbuilder | 8 +++ app/views/origami/addorders/detail.html.erb | 21 +++++- config/routes.rb | 2 +- 6 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 app/views/api/restaurant/menu_item_attributes/show.json.jbuilder diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index c4035ead..64ebc678 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -18,8 +18,6 @@ //= require cable $(document).ready(function(){ - - $(".nav-completed").on("click", function(){ $("#completed").removeClass('hide') @@ -36,9 +34,7 @@ $(document).ready(function(){ var oqs_id = $(this).find(".oqs-id").text(); var url = 'oqs/get_items/'+oqs_id; - show_details(url); - - + show_details(url); }); //End Click diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index a394e468..ca424526 100644 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -8,12 +8,6 @@ $(function(){ }); //End menu category Click - $("#set_change_qty").change(function(){ - qty = $(this).val(); - price = $("#set_total_price").text(); - $("#set_total_price").text(qty*price); - }); - //show menu item list when click menu category function show_menu_item_list(url_item){ var menu_list = $('.menu_items_list'); @@ -152,7 +146,8 @@ $(function(){ $('#set_item_instances').text(instances); $('#set_name').text(data.attr('data-name')); $('#set_item_code').text(data.attr('data-item-code')); - $('#set_total_price').text(data.attr('data-price')); + // $('#set_total_price').text(data.attr('data-price')); + $('#set_total_price').text(0); $('#set_unit_price').text(data.attr('data-price')); }); // click instance for add item set @@ -179,7 +174,8 @@ $(function(){ sub_total = $('#set_total_price').text(); name = $(this).data('name'); price = $(this).data('price'); - qty = $('#set_change_qty').val(); + // qty = $('#set_change_qty').val(); + qty = document.getElementById("count").value; total = qty*price; var total_price = +sub_total - +total; $(this).removeClass('selected-instance'); @@ -187,10 +183,12 @@ $(function(){ $(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 = $('#set_change_qty').val(); + qty = document.getElementById("count").value; total = qty*price; var total_price = +sub_total + +total; $(this).addClass('selected-instance'); @@ -273,21 +271,48 @@ $(function(){ for(var field in instances) { value = instances[field].values; $(value).each(function(i){ - options = value[i]; - instance_attributes.push(options); + // options = value[i]; + // instance_attributes.push(options); + $.ajax({ + type: "GET", + url: '../../api/restaurant/menu_item_attributes/'+value[i], + data: {id:value[i]}, + success:function(result){ + + options = result["name"]; + instance_attributes.push(options); + } + }); }); } + selected_arr = [] + $(selected_item).each(function(i){ + $.ajax({ + type: "GET", + url: '../../api/restaurant/menu_item_attributes/'+selected_item[i], + data: {id:selected_item[i]}, + success:function(result){ + name = result["name"]; + selected_arr.push(name); + } + }); + }); + + for(var field in attributes) { value = attributes[field]["values"]; type = attributes[field]["type"] - row = "

"+attributes[field]["type"]+"

" + row = "

"+attributes[field]["type"]+"

"; + console.log(selected_arr); + console.log(value); + + console.log(instance_attributes); + $(value).each(function(i){ disabled = "" status =""; - - - if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){ + if(parseInt(jQuery.inArray(value[i], selected_arr)) !== -1){ status = "selected-attribute"; } if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){ @@ -654,13 +679,18 @@ $(function(){ var count = 1; var countEl = document.getElementById("count"); + $("#plus").on("click", function(){ count++; countEl.value = count; price = $("#unit_price").text(); $("#total_price").text(count*price); + + set_price = $("#set_unit_price").text(); + $("#set_total_price").text(qty*set_price); }); + $("#minus").on("click", function(){ if (count > 1) { count--; @@ -668,9 +698,18 @@ $(function(){ price = $("#unit_price").text(); $("#total_price").text(count*price); + + set_price = $("#set_unit_price").text(); + $("#set_total_price").text(qty*set_price); } }) + // $("#set_change_qty").change(function(){ + // qty = $(this).val(); + // price = $("#set_total_price").text(); + // $("#set_total_price").text(qty*price); + // }); + // $(".change_qty").change(function(){ // qty = $(this).val(); // price = $("#unit_price").text(); diff --git a/app/controllers/api/restaurant/menu_item_attributes_controller.rb b/app/controllers/api/restaurant/menu_item_attributes_controller.rb index 1b6a48d4..37719c37 100644 --- a/app/controllers/api/restaurant/menu_item_attributes_controller.rb +++ b/app/controllers/api/restaurant/menu_item_attributes_controller.rb @@ -1,9 +1,12 @@ class Api::Restaurant::MenuItemAttributesController < Api::ApiController - + skip_before_action :authenticate #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id def index @menu_attributes = MenuItemAttribute.all end + def show + @attribute = MenuItemAttribute.find(params[:id]) + end end diff --git a/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder b/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder new file mode 100644 index 00000000..e158f807 --- /dev/null +++ b/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder @@ -0,0 +1,8 @@ +if(@attribute) + json.id @attribute.id + json.type @attribute.attribute_type + json.name @attribute.name + json.value @attribute.value +else + json.success false +end \ No newline at end of file diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 4c32390b..c5da651b 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -120,7 +120,7 @@ - + + + + + + + + diff --git a/config/routes.rb b/config/routes.rb index 6ac723aa..72d129ad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,7 +33,7 @@ Rails.application.routes.draw do resources :menu, only: [:index, :show] resources :menu_categories, only: [:index, :show] resources :menu_items, only: [:index, :show] - resources :menu_item_attributes, only: [:index] + resources :menu_item_attributes, only: [:index, :show] resources :menu_item_options, only: [:index] resources :menu_sold_out, only: [:index] resources :menu_item_instances, only: [:show] From abde6745a4634e4cf2ed83623cbbd6c1fbf2c090 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 13 Sep 2017 12:27:37 +0630 Subject: [PATCH 05/12] update addorder modefined --- app/assets/javascripts/addorder.js | 150 +++++++++++------- .../origami/addorders_controller.rb | 13 +- .../addorders/_menu_item.json.jbuilder | 117 ++++++++++++++ app/views/origami/addorders/detail.html.erb | 8 +- .../addorders/get_menu_category.json.jbuilder | 5 + config/routes.rb | 5 +- 6 files changed, 233 insertions(+), 65 deletions(-) create mode 100644 app/views/origami/addorders/_menu_item.json.jbuilder create mode 100644 app/views/origami/addorders/get_menu_category.json.jbuilder diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index ca424526..6d79ca2a 100644 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -98,10 +98,10 @@ $(function(){ } //end show list function //click item row for item set - $(document).on('click', '.set_item_box', function(event){ - $(".instance-list").empty(); - $(".options-list").empty(); - + $(document).on('click', '.set_item_box', function(event){ + $(".instance-list").empty(); + $(".options-list").empty(); + change_qty_plus_minus("set_count","set_plus","set_minus"); data = $(this).parent().children().children('.add_icon'); instances = $(this).data('instance'); @@ -149,6 +149,7 @@ $(function(){ // $('#set_total_price').text(data.attr('data-price')); $('#set_total_price').text(0); $('#set_unit_price').text(data.attr('data-price')); + // $('#set_unit_price').text(0); }); // click instance for add item set $(document).on('click', '.instance_box', function(event){ @@ -175,7 +176,7 @@ $(function(){ name = $(this).data('name'); price = $(this).data('price'); // qty = $('#set_change_qty').val(); - qty = document.getElementById("count").value; + qty = document.getElementById("set_count").value; total = qty*price; var total_price = +sub_total - +total; $(this).removeClass('selected-instance'); @@ -188,18 +189,19 @@ $(function(){ name = $(this).data('name'); price = $(this).data('price'); // qty = $('#set_change_qty').val(); - qty = document.getElementById("count").value; + 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 $(document).on('click', '.set_order', function(event){ total_price = $('#set_total_price').text(); - qty = parseInt($('#set_change_qty').val()); + qty = parseInt($('#set_count').val()); item_code = $('#set_item_code').text(); item_name = $('#set_name').text(); @@ -251,6 +253,8 @@ $(function(){ $('.add_to_order').removeAttr('data-attributes'); $('.add_to_order').removeAttr('data-options'); + change_qty_plus_minus("count","plus","minus"); + data = $(this).parent().children().children('.add_icon'); $('#total_price').text(data.attr('data-price')); @@ -271,48 +275,44 @@ $(function(){ for(var field in instances) { value = instances[field].values; $(value).each(function(i){ - // options = value[i]; - // instance_attributes.push(options); - $.ajax({ - type: "GET", - url: '../../api/restaurant/menu_item_attributes/'+value[i], - data: {id:value[i]}, - success:function(result){ + options = value[i]; + instance_attributes.push(options); + // $.ajax({ + // type: "GET", + // url: '../../api/restaurant/menu_item_attributes/'+value[i], + // data: {id:value[i]}, + // success:function(result){ - options = result["name"]; - instance_attributes.push(options); - } - }); + // options = result["name"]; + // instance_attributes.push(options); + // } + // }); }); } - selected_arr = [] - $(selected_item).each(function(i){ - $.ajax({ - type: "GET", - url: '../../api/restaurant/menu_item_attributes/'+selected_item[i], - data: {id:selected_item[i]}, - success:function(result){ - name = result["name"]; - selected_arr.push(name); - } - }); - }); + // selected_arr = [] + // $(selected_item).each(function(i){ + // $.ajax({ + // type: "GET", + // url: '../../api/restaurant/menu_item_attributes/'+selected_item[i], + // data: {id:selected_item[i]}, + // success:function(result){ + // name = result["name"]; + // selected_arr.push(name); + // } + // }); + // }); for(var field in attributes) { value = attributes[field]["values"]; type = attributes[field]["type"] row = "

"+attributes[field]["type"]+"

"; - console.log(selected_arr); - console.log(value); - - console.log(instance_attributes); $(value).each(function(i){ disabled = "" status =""; - if(parseInt(jQuery.inArray(value[i], selected_arr)) !== -1){ + if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){ status = "selected-attribute"; } if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){ @@ -351,6 +351,8 @@ $(function(){ // click select option icon for add $(document).on('click', '.attribute_btn', function(event){ + + $('.change_qty').val(1); value = $(this).data('value'); type = $(this).data('type'); instances = $(this).data('instances'); @@ -370,7 +372,7 @@ $(function(){ var selected_attr = get_selected_attributes('selected-attribute'); - qty = $('#change_qty').val(); + qty = $('.change_qty').val(); for(var field in instances) { item_attr = instances[field].values; @@ -677,33 +679,67 @@ $(function(){ } }); - var count = 1; - var countEl = document.getElementById("count"); + // Get Selected Class + function change_qty_plus_minus(id,plus,minus) { - $("#plus").on("click", function(){ - count++; - countEl.value = count; + var count = 1; + var countEl = document.getElementById(id); - price = $("#unit_price").text(); - $("#total_price").text(count*price); - - set_price = $("#set_unit_price").text(); - $("#set_total_price").text(qty*set_price); - }); - - $("#minus").on("click", function(){ - if (count > 1) { - count--; + $('#'+plus).on("click", function(){ + + count++; countEl.value = count; - price = $("#unit_price").text(); - $("#total_price").text(count*price); - set_price = $("#set_unit_price").text(); - $("#set_total_price").text(qty*set_price); - } - }) + if (id == "count") { + price = $("#unit_price").text(); + $("#total_price").text(count*price); + }else{ + var item_row = $('.selected-instance'); + price = $("#set_unit_price").text(); + set_total_price = $("#set_total_price").text(); + if (item_row.length > 1) { + total = 0 ; + $(item_row).each(function(i){ + total += count * $(item_row[i]).attr('data-price'); + total_price = total; + }); + }else{ + total_price = count*price; + } + + $("#set_total_price").text(total_price); + } + }); + + $('#'+minus).on("click", function(){ + if (count > 1) { + count--; + countEl.value = count; + + if (id=="count") { + price = $("#unit_price").text(); + $("#total_price").text(count*price); + }else{ + var item_row = $('.selected-instance'); + price = $("#set_unit_price").text(); + set_total_price = $("#set_total_price").text(); + + if (item_row.length > 1) { + total = 0 ; + $(item_row).each(function(i){ + total += count * $(item_row[i]).attr('data-price'); + total_price = total; + }); + }else{ + total_price = count*price; + } + $("#set_total_price").text(total_price); + } + } + }) + } // $("#set_change_qty").change(function(){ // qty = $(this).val(); // price = $("#set_total_price").text(); diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 1f9d70f3..6c9127ae 100644 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -30,10 +30,19 @@ class Origami::AddordersController < BaseOrigamiController else @booking = nil end - - end + def get_menu_category () + if (params[:id]) + #Pull this menu + @menu = MenuCategory.find_by_id(params[:id]) + return @menu + else + MenuCategory.current_menu + end + end + + def create Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Table ID - " + params[:table_id].to_s diff --git a/app/views/origami/addorders/_menu_item.json.jbuilder b/app/views/origami/addorders/_menu_item.json.jbuilder new file mode 100644 index 00000000..32451524 --- /dev/null +++ b/app/views/origami/addorders/_menu_item.json.jbuilder @@ -0,0 +1,117 @@ +# Format for attributes json +attr_format = [] +# Format for attributes json +if item.item_attributes.count > 0 + item.item_attributes.each do|attr_id| + menu_attr = MenuItemAttribute.find(attr_id) + if attr_format.count == 0 + attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] }) + next + end + + attr_format.each do |af| + if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]} + if menu_attr.attribute_type == af[:type] + af[:values].push(menu_attr.name) + end + else + new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] } + attr_format.push(new_attr) + break + end + end + end +end + +# Format for option json +opt_format = [] +# Format for attributes json +if item.item_options.count > 0 + item.item_options.each do|opt| + menu_opt = MenuItemOption.find(opt) + if opt_format.count == 0 + opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] }) + next + end + + opt_format.each do |of| + if menu_opt.option_type.in? opt_format.map {|k| k[:type]} + if menu_opt.option_type == of[:type] + of[:values].push(menu_opt.name) + end + else + new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] } + opt_format.push(new_opt) + break + end + end + end +end + +#Menu Item Information +json.id item.id +json.code item.item_code +json.name item.name +json.alt_name item.alt_name +json.image item.image_path.url +json.description item.description +json.information item.information +json.type item.type +json.account_id item.account_id +json.min_qty item.min_qty +json.is_available item.is_available +json.is_sub_item item.is_sub_item +json.unit item.unit + +# Item Sets of Menu Item +json.item_sets item.item_sets do |its| + json.id its.id + json.name its.name + json.alt_name its.alt_name + json.min_selectable_qty its.min_selectable_qty + json.max_selectable_qty its.max_selectable_qty + json.instances its.menu_item_instances do |i| + json.id i.id + end +end + +json.attributes attr_format +json.options opt_format +# json.min_selectable_item item.min_selectable_item +# json.max_selectable_item item.max_selectable_item + +#Item instance +# if item.menu_item_instances.count == 1 then +# item_instance = item.menu_item_instances[0] +# json.price = item_instance.price +# json.is_available = item_instance.is_available +# json.is_on_promotion = item_instance.is_on_promotion +# json.promotion_price = item_instance.promotion_price +# json.item_attributes = item_instance.item_attributes + +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(ia).name + instance_attr.push(mItemAttr) + end + + json.id is.id + json.code is.item_instance_code + json.name is.item_instance_name + json.price is.price + json.is_available is.is_available + json.is_default is.is_default + json.is_on_promotion is.is_on_promotion + json.promotion_price is.promotion_price + json.values instance_attr + # json.item_sets is.item_sets +end + +#Child Menu items +# if (item.children) then +# json.set_items item.children.each do |item| +# json.partial! 'api/restaurant/menu/menu_item', item: item +# end +# end \ No newline at end of file diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index c5da651b..34920a1d 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -4,7 +4,7 @@
-
-
-
-
- - -
-
+ + + +
+
+
+
+ +
- <% if @jcbcount != 0 %> -
-
- - -
-
+
+
+ <% if @jcbcount != 0 %> +
+
+ +
- <% end %> -
-
- - -
-
-
-
-
- -
0.0
-
-
-
-
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
-
+
-
-
-
-
1
-
2
-
3
-
-
-
4
-
5
-
6
-
-
-
7
-
8
-
9
-
-
-
0
-
.
-
00
-
-
-
Nett
-
Del
-
Clr
-
-
-
-
-
1000
-
3000
-
-
-
5000
-
10000
-
-
-
Pay
-
-
-
- -
- -
- +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+ +
+ +
+ +
diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index 6afc1081..14286215 100644 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -7,160 +7,177 @@

Master

-
-
-
-
- - -
-
-
- <% if @mastercount != 0 %> -
-
- - -
-
-
- <% end %> -
-
- - -
-
-
-
-
- -
0.0
-
-
-
-
-
- - -
- -
-
-
-
1
-
2
-
3
-
-
-
4
-
5
-
6
-
-
-
7
-
8
-
9
-
-
-
0
-
.
-
00
-
-
-
Nett
-
Del
-
Clr
-
-
-
-
-
1000
-
3000
-
-
-
5000
-
10000
-
-
-
Pay
-
-
+ + + +
+
+
+
+ + +
+
- + <% if @mastercount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+ +
0.0
+
+
+
+
+
+
-
- -
+
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+ +
+ +
diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index e8e25b2f..263996b7 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -7,160 +7,178 @@

MPU

-
-
-
-
- - -
-
-
- <% if @mpucount != 0 %> -
-
- - -
-
-
- <% end %> -
-
- - -
-
-
-
-
- -
0.0
-
-
-
-
+ + + +
+
+
+
+ + +
+
+
+ <% if @mpucount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
-
+
-
-
-
-
1
-
2
-
3
-
-
-
4
-
5
-
6
-
-
-
7
-
8
-
9
-
-
-
0
-
.
-
00
-
-
-
Nett
-
Del
-
Clr
-
-
-
-
-
1000
-
3000
-
-
-
5000
-
10000
-
-
-
Pay
-
-
-
- -
- -
- +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+ +
+ +
+ +
+ }); + $('#mpu_pay').on('click',function(){ + var amount = $('#amount').text(); + var sale_id = "<%= @sale_id %>"; + if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){ + //start member discount 5% by pay card + var sub_total = $('#sub-total').text(); + var member_id = $('#membership_id').text(); + var member_discount = $('#member_discount').text(); + if (member_id && member_discount) { + $.ajax({ + type: "POST", + url: "/origami/" + sale_id + "/member_discount", + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + }); + } + //end member discount + //Mpu Payment + $.ajax({type: "POST", + url: "<%= origami_payment_mpu_path %>", + data: "amount="+ amount + "&sale_id="+ sale_id, + success:function(result){ + if(result){ + alert("Payment success") + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + } + }); + }else{ + alert("Paid Amount is over!") + } + }) + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 36c4cc0e..f0298e73 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1,8 +1,8 @@ +
+
-
+
@@ -17,6 +17,8 @@ Customer : <%= @sale_data.customer.name%> + + Customer ID : <%= @sale_data.customer.customer_id%> @@ -26,82 +28,82 @@
- - - - + + + - -
#ItemsQTY +
#ItemsQTY Price -
-
-
- - - <% sub_total = 0 - count = 0 - %> - <% @sale_data.sale_items.each do |sale_item| - count += 1 - %> + + +
+
+
+ + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> - <% sub_total += sale_item.price%> - + <% sub_total += sale_item.price%> + - - - - <%end %> - -
<%= count %> - <%=sale_item.product_name%>@<%=sale_item.unit_price%> - - <%=sale_item.qty%> - - <%=(sale_item.price)%> -
-
- -
+ <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + + <%=sale_item.qty%> + + + <%=(sale_item.price)%> + + + <%end %> + + +
+ +
+ -->
@@ -123,159 +125,159 @@
<%= @credit %>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%> -
-
Other Payments
-
<%= @other %>
-
+
+
Other Payments
+
<%= @other %>
+
<% else %> -
-
Other Payments
-
+
+
Other Payments
+
<% end %> - - <% if @other != 0.0 %> -
-
-
MPU
-
<%= @other %>
-
- <% else %> - - <% end %> - - <% if @ppamount != 0.0 %> -
-
-
Redeem
-
<%= @ppamount %>
-
- <% else %> - - <% end %> - - <% if @visacount != 0.0 %> -
-
-
Visa
-
<%= @visacount %>
-
- <% else %> - - <% end %> - - <% if @jcbcount != 0.0 %> -
-
-
JCB
-
<%= @jcbcount %>
-
- <% else %> - - <% end %> - - <% if @mastercount != 0.0 %> -
-
-
Master
-
<%= @mastercount %>
-
- <% else %> - - <% end %> -
+ + <% if @other != 0.0 %> +
+
+
MPU
+
<%= @other %>
+
+ <% else %> + + <% end %> + + <% if @ppamount != 0.0 %> +
+
+
Redeem
+
<%= @ppamount %>
+
+ <% else %> + + <% end %> + + <% if @visacount != 0.0 %> +
+
+
Visa
+
<%= @visacount %>
+
+ <% else %> + + <% end %> + + <% if @jcbcount != 0.0 %> +
+
+
JCB
+
<%= @jcbcount %>
+
+ <% else %> + + <% end %> + + <% if @mastercount != 0.0 %> +
+
+
Master
+
<%= @mastercount %>
+
+ <% else %> + + <% end %> +
Balance
<%= @sale_data.grand_total %>

-
-
-
-
1
-
2
-
3
-
-
-
4
-
5
-
6
-
-
-
7
-
8
-
9
-
-
-
0
-
.
-
00
-
-
-
Nett
-
Del
-
Clr
-
-
-
-
-
1000
-
3000
-
-
-
5000
-
10000
-
-
-
Pay
-
-
-
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
-
-
- +
+
+ - - - -
+ + + +
-
+ \ No newline at end of file diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index 1589ca1b..bc78608b 100644 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -7,160 +7,177 @@

VISA

-
-
-
-
- - -
-
-
- <% if @visacount != 0 %> -
-
- - -
-
-
- <% end %> -
-
- - -
-
-
-
-
- -
0.0
-
-
-
-
-
- - -
- -
-
-
-
1
-
2
-
3
-
-
-
4
-
5
-
6
-
-
-
7
-
8
-
9
-
-
-
0
-
.
-
00
-
-
-
Nett
-
Del
-
Clr
-
-
-
-
-
1000
-
3000
-
-
-
5000
-
10000
-
-
-
Pay
-
-
+ + + +
+
+
+
+ + +
+
- + <% if @visacount != 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+ +
0.0
+
+
+
+
+
+
-
- -
+
+ +
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+
+ +
+ +
+ +
From 07ea214eee4bee0dad30c5ed19ae05065304dbc0 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 14 Sep 2017 17:49:11 +0630 Subject: [PATCH 09/12] update other payment alert box --- app/views/origami/jcb/index.html.erb | 23 ++++++++++++++++++++--- app/views/origami/master/index.html.erb | 23 ++++++++++++++++++++--- app/views/origami/mpu/index.html.erb | 25 +++++++++++++++++++++---- app/views/origami/visa/index.html.erb | 23 ++++++++++++++++++++--- 4 files changed, 81 insertions(+), 13 deletions(-) diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index 42927273..eaf1f07e 100644 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -174,13 +174,30 @@ $('#jcb_pay').on('click',function(){ data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ - alert("Payment success") - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + $.confirm({ + title: 'Infomation!', + content: 'Payment Successfully', + buttons: { + confirm: { + text: 'Ok', + btnClass: 'btn-green', + action: function(){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + } + } + }); } } }); }else{ - alert("Paid Amount is over!"); + $.alert({ + title: 'Alert!', + content: "Paid Amount is over!", + type: 'red', + typeAnimated: true, + btnClass: 'btn-danger', + }); } }) diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index 14286215..ab396252 100644 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -171,13 +171,30 @@ data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ - alert("Payment success") - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + $.confirm({ + title: 'Infomation!', + content: 'Payment Successfully', + buttons: { + confirm: { + text: 'Ok', + btnClass: 'btn-green', + action: function(){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + } + } + }); } } }); }else{ - alert("Paid Amount is over!"); + $.alert({ + title: 'Alert!', + content: "Paid Amount is over!", + type: 'red', + typeAnimated: true, + btnClass: 'btn-danger', + }); } }) diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index 263996b7..30d12d35 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -172,13 +172,30 @@ data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ - alert("Payment success") - window.location.href = '/origami/sale/'+ sale_id + "/payment"; - } + $.confirm({ + title: 'Infomation!', + content: 'Payment Successfully', + buttons: { + confirm: { + text: 'Ok', + btnClass: 'btn-green', + action: function(){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + } + } + }); + } } }); }else{ - alert("Paid Amount is over!") + $.alert({ + title: 'Alert!', + content: "Paid Amount is over!", + type: 'red', + typeAnimated: true, + btnClass: 'btn-danger', + }); } }) diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index bc78608b..073b7e60 100644 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -171,13 +171,30 @@ data: "amount="+ amount + "&sale_id="+ sale_id, success:function(result){ if(result){ - alert("Payment success") - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + $.confirm({ + title: 'Infomation!', + content: 'Payment Successfully', + buttons: { + confirm: { + text: 'Ok', + btnClass: 'btn-green', + action: function(){ + window.location.href = '/origami/sale/'+ sale_id + "/payment"; + } + } + } + }); } } }); }else{ - alert("Paid Amount is over!"); + $.alert({ + title: 'Alert!', + content: "Paid Amount is over!", + type: 'red', + typeAnimated: true, + btnClass: 'btn-danger', + }); } }) From 77c399d7cd7e0b87e20f8c2cf472dd6e962f1b72 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 14 Sep 2017 18:23:16 +0630 Subject: [PATCH 10/12] add qr --- app/views/crm/customers/index.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d0321e95..b0e23e6b 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -129,8 +129,9 @@ $(function() { code2lab.readQRCode(); } - // get CardNo from Java + // get QRCode from Java function setQRCode(code){ + alert(code); $("#search").val(code); } From 3e0371a9fba8ac72e5c7443c77114c876ebb981a Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 15 Sep 2017 14:20:53 +0630 Subject: [PATCH 11/12] done --- app/views/crm/customers/index.html.erb | 8 ++++---- app/views/origami/redeem_payments/index.html.erb | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index b0e23e6b..ca5404ec 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -119,19 +119,19 @@ $(function() { $("#qr_code").on('click', function(e){ var code = ""; setTimeout(function(){ - console.log("hi") - getQRCode(); + var hi=getQRCode(); + alert(hi); },100); }); // Read qrcode from java function getQRCode(){ - code2lab.readQRCode(); + return code2lab.readQRCode(); } // get QRCode from Java function setQRCode(code){ - alert(code); + $("#qr_code").text(code); $("#search").val(code); } diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index a4783010..df4e7cf9 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -147,6 +147,7 @@ $(document).on('click', '.cashier_number', function(event){ return false; } }); + $("#redeem").click(function(){ valid_amount = $("#valid_amount").val(); sale_id = $("#valid_amount").attr('data-value'); From f4270ffd87f4f800116895cc43d0d403ab4c932e Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 18 Sep 2017 17:36:17 +0630 Subject: [PATCH 12/12] fix promotion date format --- app/models/promotion.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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