From 2cb6427aa1b78d1015dff4f7b7f38468323d6b5c Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 3 Apr 2018 10:54:06 +0630 Subject: [PATCH 1/6] update license check --- app/models/license.rb | 33 +++++++++++++++++---------------- config/license.yml | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 config/license.yml diff --git a/app/models/license.rb b/app/models/license.rb index ac82721c..132585d8 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -134,21 +134,23 @@ class License def verify_license api_token = read_license_no_decrypt("api_token") @params = { query: {lookup_type: "application", api_token: api_token} } - response = self.class.get("/verify", @params) - - rescue SocketError => e - Rails.logger.debug "In Socket errror" - return true - rescue => e - @varified = response.parsed_response - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@varified["status"]) - if (!check_expired(@varified["renewable_date"])) - return true - end - else - delete_license_file - end + + begin + response = self.class.get("/verify", @params) + @varified = response.parsed_response + Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + if (@varified["status"]) + + if (!check_expired(@varified["renewable_date"])) + return true + end + else + delete_license_file + end + rescue SocketError => e + Rails.logger.debug "In SocketError No Internet connection ! " + return true + end return false end @@ -164,7 +166,6 @@ class License def check_expired(renewal_date_str) expired_date_str = read_license("renewable_date") renewal_date = DateTime.parse(renewal_date_str) - if(renewal_date_str != expired_date_str) update_license("renewable_date", renewal_date_str) end diff --git a/config/license.yml b/config/license.yml new file mode 100644 index 00000000..9f4d1542 --- /dev/null +++ b/config/license.yml @@ -0,0 +1,15 @@ +iv_key: rwOZKWcQho6fE4V+A2zFuQ== +shop_name: AMZ_Test +email: aungmyo.zaw@code2lab.com +telephone: +fax: +address: +dbhost: dNzh66R80remB694OEds96OpuyZ4wmHeHFdQh0KwjYFvTInK6+pCN/y6HdbyIlqqjcBHkqPjkjzw45PznLn7hA== +dbschema: 4vooJDxgWdFv/8V7Qx8tzR/8B8T2c5U4XvYcF+2KOoA= +dbusername: Xc8ELRsW7N/f8KsVikMBlg== +dbpassword: HMg+TbLxmfYrDFI4IIAd4g== +api_token: bisryXiEnbTJlZwghAnIByQpiRUMouu +app_token: LycQXJYBZGeCygjIEKdlBXnjIGMiMzgmt +plan_sku: 84hdnSCgkfhvItY7uB/pPQ== +renewable_date: 8E6Ecz8QXAMSlKZnIzn0pQ== +plan_name: 4cMIO0n/JzGFPIccXM6u5A== From b0d7c3b1b8ece45d63386e8b21ec44e522f906b5 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 3 Apr 2018 15:01:54 +0630 Subject: [PATCH 2/6] update sale item report --- app/controllers/reports/saleitem_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 24c812eb..e2823d93 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -3,10 +3,14 @@ class Reports::SaleitemController < BaseReportController def index from, to = get_date_range_from_params - shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + shift_sale_range = '' shift = '' if params[:shift_name].to_i != 0 + + shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) @@ -14,6 +18,7 @@ class Reports::SaleitemController < BaseReportController shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) end + end @type = params[:sale_type] @sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) From 17562f6fcf6a75ef9f9c4e11c5cd19d7c872795d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 4 Apr 2018 09:43:02 +0630 Subject: [PATCH 3/6] update license and login dashboard --- app/models/license.rb | 12 +++++++++++- app/views/layouts/login_dashboard.html.erb | 4 ++-- config/initializers/action_controller.rb | 10 +++++----- config/secrets.yml | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/models/license.rb b/app/models/license.rb index 132585d8..ed8e3eb8 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -140,20 +140,30 @@ class License @varified = response.parsed_response Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s if (@varified["status"]) - if (!check_expired(@varified["renewable_date"])) return true end else delete_license_file end + rescue SocketError => e Rails.logger.debug "In SocketError No Internet connection ! " return true + rescue HTTParty::Error + Rails.logger.debug "Server Error HTTParty" + return true + rescue Net::OpenTimeout + Rails.logger.debug "connection Timeout" + return true + rescue OpenURI::HTTPError + Rails.logger.debug "Can't connect server" + return true end return false end + # Check Expired before 30 days def check_expiring(renewal_date_str) if !renewal_date_str.empty? diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index f2f6f958..04fe8ded 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -11,8 +11,8 @@ - - + <%= stylesheet_link_tag 'login', media: 'all', 'data-turbolinks-track': 'reload' %> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 02e35bb8..8f310dab 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end diff --git a/config/secrets.yml b/config/secrets.yml index 076b6691..0282c5fc 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: connect.smartsales.dev/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api + sx_provision_url: connect.smartsales.asia/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L From 8c9b0f756d86b6588a8b269090f520cd13d6ac9c Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 4 Apr 2018 14:09:35 +0630 Subject: [PATCH 4/6] update sale item report --- .../reports/saleitem_controller.rb | 21 +++++++++++-------- app/models/sale.rb | 9 ++++++++ app/views/reports/saleitem/index.html.erb | 3 ++- config/routes.rb | 3 ++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index e2823d93..92604b04 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -9,17 +9,20 @@ class Reports::SaleitemController < BaseReportController shift = '' if params[:shift_name].to_i != 0 - shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) - if to.blank? + if to.blank? shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) else - - shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + if shift_sale.shift_closed_at.blank? + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at) + else + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end end - end + @type = params[:sale_type] @sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) @@ -59,8 +62,8 @@ class Reports::SaleitemController < BaseReportController def show from, to, report_type = get_date_range_from_params - - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) +puts "aaaaaaaaaaaaaaaaaaaaaaaaaa" + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| @@ -73,8 +76,8 @@ class Reports::SaleitemController < BaseReportController date_arr.push(str) end - @totalByAccount = Hash.new {|hash, key| hash[key] = 0} - @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} + # @totalByAccount = Hash.new {|hash, key| hash[key] = 0} + # @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} out = {:status => 'ok', :message => date_arr} diff --git a/app/models/sale.rb b/app/models/sale.rb index e25589dc..9306b0eb 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -806,6 +806,15 @@ def self.get_by_shift_sale(from,to,status) return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to) end +def self.get_by_shift_sale_by_item(from,to,status) + query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, + shift_closed_at As closing_date," + + " grand_total AS grand_total, cash_sales AS cash," + + "total_taxes AS total_tax,total_discounts As total_discount") + .order("shift_sales.id DESC") + return query = query.where("shift_sales.shift_started_at >= ?" , from) +end + def self.get_item_query(type) if type == "revenue" || type.nil? diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index a972443f..a3937ec2 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -325,7 +325,8 @@ var str = ''; var param_shift = '<%= params[:shift_name]%>'; - url = '<%= reports_get_shift_by_date_path %>'; + url = '<%= reports_get_shift_by_sale_item_path %>'; + console.log(url) $.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){ console.log(data) diff --git a/config/routes.rb b/config/routes.rb index 4448b75f..5f0d21ba 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -407,8 +407,9 @@ scope "(:locale)", locale: /en|mm/ do resources :stock_check, :only => [:index, :show] resources :payment_method resources :product_sale, :only => [:index, :show] - + get "saleitem/get_shift_by_date", to: "saleitem#show", as: "get_shift_by_sale_item" get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" + end # ----------- Inventory --------------------------- From 03e8ba99a62ad894fde3535cf1aa5d7dc21a3f0d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 4 Apr 2018 17:20:49 +0630 Subject: [PATCH 5/6] update add --- app/assets/javascripts/custom.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index c6e6a47b..043fbb03 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -32,6 +32,26 @@ $(document).ready(function() { railBorderRadius: '0', touchScrollStep : 50 }); + + $('#modal-slimscroll').slimScroll({ + height: height-$('#modal-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 45 + }); + + $('#modal-set-slimscroll').slimScroll({ + height: height-$('#modal-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 45 + }); // $('.delete').click(function(){ // var method = $(this).attr('data-method'); From 9136e9de07278f0a8d0315aec5556990adf6a812 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 4 Apr 2018 17:51:51 +0630 Subject: [PATCH 6/6] update addorder set multiple --- app/assets/javascripts/addorder.js | 92 +++++++++++++++------ app/views/origami/addorders/detail.html.erb | 8 +- 2 files changed, 76 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 31209c99..a8de44b1 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -315,6 +315,7 @@ $(function() { $(".options-list").empty(); rowCount = $('.selected-instance'); + setCount = $('.selected-set'); item_options = $(this).data('option'); min_qty = $(this).data('min-qty'); @@ -335,19 +336,19 @@ $(function() { $(".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 { + // 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'); @@ -358,12 +359,55 @@ $(function() { total = qty*price; var total_price = +sub_total + +total; $(this).addClass('selected-instance'); + + set = "
" + + +'
' + +' ' + +''+$(this).data('name')+'' + +'
' + +'
' + + +' ' + +'
' + // +'' + +'
' + $(".selected-set-list").append(set); + }else{ + swal("Alert !", 'Maximum Qty is ' + max_qty + " items", "warning"); } - } + // } $('#set_unit_price').text(price); $('#set_total_price').text(total_price); }); //End selecct attribute buttom + + // click add order + $(document).on('click', '#remove_set', function(event){ + code = $(this).parent().parent('.selected-set').attr('data-code'); + instance = $(".selected-instance"); + console.log(code) + $(instance).each(function(i){ + if ($(instance[i]).attr('data-code')==code){ + console.log($(instance[i])) + $(instance[i]).removeClass("selected-instance") + } + }); + $(this).parent().parent('.selected-set').remove(); + }); // click add order $(document).on('click', '.set_order', function(event){ @@ -637,15 +681,17 @@ $(function() { if(group == "set_menu"){ - - instance = $(".selected-instance"); - $(instance).each(function(i){ - if ($(instance[i]).attr('data-code')==code){ - option_arr = get_selected_attributes('selected-option'); - $(instance[i]).attr('data-options',JSON.stringify(option_arr)); - $(instance[i]).children().children('#instance_option').text(option_arr); - } - }); + option_arr = get_selected_attributes('selected-option'); + $(".selected-set:last").attr('data-options',JSON.stringify(option_arr)); + $(".selected-set:last").children().children('#instance_option').text(option_arr); + // instance = $(".selected-instance"); + // $(instance).each(function(i){ + // if ($(instance[i]).attr('data-code')==code){ + // option_arr = get_selected_attributes('selected-option'); + // $(instance[i]).attr('data-options',JSON.stringify(option_arr)); + // $(instance[i]).children().children('#instance_option').text(option_arr); + // } + // }); } if(group == "set_menu_default"){ diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 607f4c0e..93569170 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -405,9 +405,15 @@

-
+ +