Pull from master
This commit is contained in:
@@ -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 = "<div class='selected-set card custom-card' style='margin-bottom:10px !important'"
|
||||
+"' data-name='"+$(this).data('name')
|
||||
+"' data-code='"+code
|
||||
+"' data-price='"+$(this).data('price')
|
||||
+"' data-option='"+JSON.stringify($(this).data('option'))
|
||||
+"' data-min-qty='"+$(this).data('min-qty')
|
||||
+"' data-max-qty='"+$(this).data('max-qty')
|
||||
+"' data-parent-code='"+$(this).data('parent-code')
|
||||
+"' data-parent-id='"+$(this).data('parent-id')
|
||||
+"' data-sub-item='true"
|
||||
+"'>"
|
||||
|
||||
+'<div class="card-block" style="background-color:#54A5AF;">'
|
||||
+' <button type="button" class="close" id="remove_set" style="font-size: 20px;">×</button>'
|
||||
+'<span style="color:#fff">'+$(this).data('name')+'</span>'
|
||||
+'</div>'
|
||||
+'<div class="card-block custom-card-block">'
|
||||
|
||||
+' <small style="float:" id="instance_option"></small>'
|
||||
+'</div>'
|
||||
// +'<div class="card-footer custom-card-footer">'
|
||||
// +' <span>'+$(this).data('price')+'</span>'
|
||||
// // +' <small style="float:right" id="instance_option"></small>'
|
||||
// +'</div>'
|
||||
+'</div>'
|
||||
$(".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"){
|
||||
|
||||
@@ -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');
|
||||
|
||||
47
app/controllers/api/survey_controller.rb
Normal file
47
app/controllers/api/survey_controller.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
class Api::SurveyController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def index
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
survey_data = Survey.find_by_dining_name(dining_facility.name)
|
||||
countries = Lookup.collection_of("country")
|
||||
if !countries.nil? || !survey_data.nil?
|
||||
render :json => { :status => true, :data => { :countries => countries, :survey_data => survey_data} }
|
||||
else
|
||||
render :json => { :status => true, :error_message => "There is no data" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
|
||||
if params[:survey_id]
|
||||
survey = Survey.find(params[:survey_id])
|
||||
else
|
||||
survey = Survey.new
|
||||
end
|
||||
survey.dining_name = dining_facility.name
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.child = params[:child]
|
||||
survey.adult = params[:adult]
|
||||
survey.male = params[:male]
|
||||
survey.female = params[:female]
|
||||
survey.local = params[:local]
|
||||
survey.created_by = current_login_employee.name
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.total_amount = params[:total_amount]
|
||||
survey.foreigner = params[:foreigner].to_json
|
||||
survey.save!
|
||||
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
# private
|
||||
# def survey_params
|
||||
# params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner,
|
||||
# :dining_name,:created_by,:total_customer,:total_amount)
|
||||
# end
|
||||
|
||||
end
|
||||
@@ -16,7 +16,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@@ -33,6 +33,8 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
#bill channel
|
||||
ActionCable.server.broadcast "bill_channel",table: table
|
||||
if order.source == "quick_service"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
render :json => result.to_json
|
||||
|
||||
@@ -3,18 +3,26 @@ 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_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)
|
||||
|
||||
@@ -54,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|
|
||||
@@ -68,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}
|
||||
|
||||
|
||||
@@ -134,24 +134,36 @@ 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)
|
||||
|
||||
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 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
|
||||
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?
|
||||
@@ -164,7 +176,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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -472,7 +472,7 @@ class SalePayment < ApplicationRecord
|
||||
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
elsif method_status && paid_amount.to_f == 0
|
||||
elsif method_status && paid_amount.to_f == 0 && is_credit == 0
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
end
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">
|
||||
<!-- <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext" rel="stylesheet" type="text/css">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" type="text/css">-->
|
||||
|
||||
<%= stylesheet_link_tag 'login', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
|
||||
@@ -405,9 +405,15 @@
|
||||
<p class="hidden" id="set_item_code"></p>
|
||||
<p></p>
|
||||
|
||||
<div class="options-list">
|
||||
<div class="" id="modal-slimscroll" data-height="250">
|
||||
<div class="options-list" style="margin-top:-5px">
|
||||
</div>
|
||||
|
||||
<div class='selected-set-list'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="instance-list row"></div>
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user