Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-06-22 09:51:22 +06:30
53 changed files with 1580 additions and 574 deletions

View File

@@ -66,6 +66,8 @@ gem 'kaminari', '~> 1.0.1'
# Datatable
gem 'filterrific'
gem 'cancancan', '~> 1.10'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

View File

@@ -39,7 +39,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (8.0.0)
autoprefixer-rails (7.1.1)
autoprefixer-rails (7.1.1.2)
execjs
bcrypt (3.1.11)
bindex (0.5.0)
@@ -50,6 +50,7 @@ GEM
railties (>= 3.0)
builder (3.2.3)
byebug (9.0.6)
cancancan (1.17.0)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
@@ -121,7 +122,7 @@ GEM
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pdf-core (0.7.0)
pg (0.20.0)
pg (0.21.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -159,8 +160,8 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (3.3.3)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
@@ -191,7 +192,7 @@ GEM
activesupport (>= 3.2.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
sidekiq (5.0.2)
sidekiq (5.0.3)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
@@ -245,6 +246,7 @@ DEPENDENCIES
bootstrap (~> 4.0.0.alpha3)
bootstrap-datepicker-rails
byebug
cancancan (~> 1.10)
coffee-rails (~> 4.2)
cups (~> 0.0.7)
database_cleaner

View File

@@ -25,6 +25,12 @@ $(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$('.dropdown-toggle').dropdown();
});
function export_to(path)
{
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
}
/*
* ToDo Move to here from pages
*

File diff suppressed because one or more lines are too long

View File

@@ -8,8 +8,293 @@
//= require bootstrap-datepicker
$(document).ready(function(){
$(".orders").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/' + dining_id;
})
// auto refresh every 60 seconds
// setTimeout(function(){
// window.location.reload(1);
// }, 60000);
// For selected order return
var order_status = "";
order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim();
// Enable/Disable Button
control_button(order_status);
$(".orders").on('click', function(){
$("#order-sub-total").text('');
// $("#order-food").text('');
// $("#order-beverage").text('');
$("#order-discount").text('');
$("#order-Tax").text('');
$("#order-grand-total").text('');
var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id = $(this).find(".orders-id").text();
var order_status=$(this).find(".orders-order-status").text().trim();
// Enable/Disable Button
control_button(order_status);
var customer_id=$(this).find(".customer-id").text();
//show_customer_details(customer_id);
$("#re-print").val(unique_id);
var cashier="";
var receipt_date="";
var sub_total=0.0;
var discount_amount=0;
var tax_amount=0;
var grand_total_amount=0;
$("#order-title").text("ORDER DETAILS - " + zone_name);
// clear order items
$("#order-items-table").children("tbody").empty();
// AJAX call for order
$.ajax({
type: "POST",
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
var show_date = "";
// Receipt Header
receipt_no = result[i].receipt_no;
cashier = result[i].cashier_name;
if(result[i].receipt_date != null){
receipt_date = new Date(result[i].receipt_date);
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
}
//Receipt Charges
sub_total += parseFloat(parse_data.price);
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
// Ordered Items
var order_items_rows = "<tr>" +
"<td class='item-name'>" + parse_data.item_name + "</td>" +
"<td class='item-attr'>" + parse_data.qty + "</td>" +
"<td class='item-attr'>" + parse_data.price + "</td>" +
"</tr>";
$("#order-items-table").children("tbody").append(order_items_rows);
}
// Cashier Info
$("#receipt_no").text(receipt_no);
$("#cashier").text(cashier == null ? "" : cashier);
$("#receipt_date").text(show_date);
// Payment Info
$("#order-sub-total").text(sub_total);
// $("#order-food").text('');
// $("#order-beverage").text('');
$("#order-discount").text(discount_amount);
$("#order-Tax").text(tax_amount);
$("#order-grand-total").text(grand_total_amount);
}
});
// End AJAX Call
$('.orders').removeClass('selected-item');
$(this).addClass('selected-item');
});
// Bill Request
$('#request_bills').click(function() {
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
if(order_id!=""){
window.location.href = '/origami/' + order_id + '/request_bills'
}
else {
alert("Please select an order!");
}
return false;
});
// Discount for Payment
$('#discount').click(function() {
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
if(order_id!=""){
window.location.href = '/origami/' + order_id + '/discount'
}
else {
alert("Please select an order!");
}
return false;
});
// Pay Discount for Payment
$("#pay-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sale_item_id = $('.selected-item').attr('id').substr(0,16);
var sub_total = $('#order-sub-total').text();
var grand_total = $('#order-grand-total').text();
var discount_type = $('#discount-type').val();
var discount_value = $('#discount-amount').val();
var discount_amount = discount_value;
var ajax_url = "/origami/" + sale_id + "/discount";
if(sale_item_id != null){
ajax_url = "/origami/" + sale_item_id + "/discount";
sub_total = $("#"+sale_item_id).children().find("#item-total-price").text();
}
// For Percentage Discount
if(discount_type == 1){
discount_amount=(sub_total*discount_value)/100;
}
var params = {'sale_id': sale_id, 'sale_item_id': sale_item_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
$.ajax({
type: "POST",
url: ajax_url,
data: params,
success:function(result){ }
});
});
// Payment for Bill
$('#pay-bill').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16);
if(sale_id!=""){
window.location.href = '/origami/sale/'+ sale_id + "/payment"
}
else {
alert("Please select an order!");
}
return false;
});
$('#customer').click(function() {
var sale = $(".selected-item").find(".orders-id").text().substr(0,16);
if (sale.substring(0, 3)=="SAL") {
var sale_id = sale
}else{
var sale_id = $(".selected-item").find(".order-cid").text();
}
window.location.href = '/origami/'+ sale_id + "/customers"
return false;
});
$('#re-print').click(function() {
var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16);
window.location.href = '/origami/'+ sale_id + "/reprint"
return false;
});
function show_customer_details(customer_id){
if(window.location.pathname.substring(0, 12) == "/origami/SAL"){
var url = customer_id+"/get_customer/"
}else{
var url = "origami/"+customer_id+"/get_customer/"
}
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
if (data["response_data"]["data"].length) {
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + data["response_data"]["data"][i]["accountable_type"] +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}else{
$('.rebate_amount').addClass('hide');
}
}
});
//End Ajax
}
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-amount').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
update_balance();
}
else{
$('#discount-amount').val(original_value + '' + input_value);
update_balance();
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
$('#discount-type').val(1);
update_balance();
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
update_balance();
break;
case 'clr':
$('#discount-amount').val("0.0");
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
});
$('.discount-item-row').on('click',function(){
$('.discount-item-row').removeClass('selected-item');
$(this).addClass('selected-item');
});
// $(".orders").on('click', function(){
// var dining_id = $(this).attr("data-id");
// window.location.href = '/origami/' + dining_id;
// })
});

View File

@@ -23,3 +23,17 @@
.assign .text-muted{
color: #fff !important;
}
.red{
color: #fff !important;
background-color: red;
}
.green{
color: #fff !important;
background-color: green;
}
.required abbr{
color: red !important;
}
.jconfirm-box-container{
margin-left:-40px !important
}

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,16 @@ class ApplicationController < ActionController::Base
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
# rescue_from CanCan::AccessDenied do |exception|
# flash[:warning] = exception.message
# redirect_to root_path
# end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
def current_company
begin
return Company.first

View File

@@ -7,23 +7,19 @@ class Crm::CustomersController < BaseCrmController
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
@crm_customers = Customer.all
else
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
# if flash["errors"]
# @crm_customer.valid?
# end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @crm_customers }
@@ -51,14 +47,7 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
@response = Customer.get_membership_transactions(@customer)
#end customer amount
end
@@ -87,6 +76,8 @@ class Crm::CustomersController < BaseCrmController
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -95,14 +86,18 @@ class Crm::CustomersController < BaseCrmController
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
dob: dob,address: address,nrc:nrc,
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
rescue Net::OpenTimeout
response = { status: false }
end
if response["status"] == true
@@ -151,6 +146,8 @@ end
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
@@ -159,22 +156,24 @@ end
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
dob: dob,address: address,nrc:nrc,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
rescue Net::OpenTimeout
response = { status: false }
end
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
flash[:errors] = @crm_customers.errors
flash[:errors] = @crm_customer.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
@@ -201,6 +200,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
end
end

View File

@@ -84,12 +84,15 @@ class Crm::DiningQueuesController < BaseCrmController
queue = DiningQueue.find(params[:id])
table_id = params[:table_id]
queue.update_attributes(dining_facility_id: table_id,status:"Assign")
DiningFacility.find(table_id).update_attributes(status: "occupied")
respond_to do |format|
format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' }
format.json { head :no_content }
end
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
status = DiningFacility.find(table_id).update_attributes(status: "occupied")
if status == true
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end

View File

@@ -10,11 +10,13 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
sale_payment.process_payment(saleObj, @user, cash, "cash")
rebate_amount = nil
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
rebate_amount = Customer.get_membership_transactions(customer)
# get member information
member_info = Customer.get_member_account(customer)
@@ -24,7 +26,7 @@ class Origami::PaymentsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
end
end
@@ -88,7 +90,7 @@ class Origami::PaymentsController < BaseOrigamiController
# get member information
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -96,7 +98,7 @@ class Origami::PaymentsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
end

View File

@@ -20,8 +20,11 @@ class Origami::RequestBillsController < BaseOrigamiController
end
unique_code = "ReceiptBillPdf"
customer= Customer.where('customer_id=' + @sale_data.customer_id)
# customer= Customer.where('customer_id=' +.customer_id)
customer= Customer.find( @sale_data.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -32,6 +35,9 @@ class Origami::RequestBillsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info)
# redirect_to origami_path(@sale_data.sale_id)
end
end

View File

@@ -1,23 +1,11 @@
class Reports::DailySaleController < BaseReportController
def index
from, to = get_date_range_from_params
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
end
# @locations = Location.all
# branch,from, to, report_type = get_date_range_from_params
# @location = Location.find_by_id(current_location)
# @sale_data = Sale.daily_sales_report(current_location,from,to)
# @tax = SaleT.get_tax(current_location,from,to)
# if @sale_data.blank? && @tax.blank? && request.post?
# flash.now[:notice] = "No data available for selected filters"
# end
def show
end

View File

@@ -1,4 +1,5 @@
class Reports::ReceiptNoController < BaseReportController
def index
from, to = get_date_range_from_params
puts "from..."

View File

@@ -0,0 +1,14 @@
class Reports::SaleItemController < BaseReportController
def index
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
end
def show
end
end

View File

@@ -1,6 +1,8 @@
class Settings::EmployeesController < ApplicationController
# load_and_authorize_resource
before_action :set_employee, only: [:show, :edit, :update, :destroy]
# GET /employees
# GET /employees.json
def index

View File

@@ -53,13 +53,7 @@ class Transactions::SalesController < ApplicationController
#get customer amount
@customer = Customer.find(@sale.customer_id)
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
@response = Customer.get_membership_transactions(@customer)
#end customer amount
respond_to do |format|

33
app/models/ability.rb Normal file
View File

@@ -0,0 +1,33 @@
class Ability
include CanCan::Ability
def initialize(user)
user ||= Employee.new
if user.role? :administrator
can :manage, :all
elsif user.role? :cashier
can :read, Order
can :update, Order
can :completed_order_item, Order
can :read, Sale
can :update, Sale
elsif user.role? :accountant
can :read, Order
can :update, Order
can :completed_order_item, Order
can :read, Sale
can :update, Sale
can :manual_complete_sale, Sale
end
end
end

View File

@@ -6,9 +6,10 @@ class Customer < ApplicationRecord
has_many :orders
has_many :sales
validates_presence_of :name, :contact_no, :email
validates_presence_of :name, :contact_no, :email,:company,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :card_no, uniqueness: true
paginates_per 50
@@ -36,52 +37,52 @@ class Customer < ApplicationRecord
end
def self.get_membership_transactions(customer)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_member_transactions")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# urltest =self.url_exist?(url)
begin
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
end
return response;
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
else
find(:all)
end
end
# require "net/http"
# def self.url_exist?(url_string)
# url = URI.parse(url_string)
# req = Net::HTTP.new(url.host, url.port)
# puts "hhhhhhhhhhhh"
# puts req.to_json
# req.use_ssl = (url.scheme == 'https')
# puts "aaaaaaaaaaaa"
# puts req.use_ssl?
# path = url.path if url.path.present?
# puts "bbbbbbbbbbbbb"
# puts path
# res = req.request_head(path || '/')
# puts "cccccccccccccc"
# puts res.to_json
# puts "ddddddddd"
# puts res.kind_of?(Net::HTTPRedirection)
# if res.kind_of?(Net::HTTPRedirection)
# url_exist?(res['location']) # Go after any redirect and make sure you can access the redirected URL
# else
# ! %W(4 5).include?(res.code[0]) # Not from 4xx or 5xx families
# end
# rescue Errno::ENOENT
# false #false if can't find the server
# end
# def self.search(search)
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
# end
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end
def self.count_customer
all = self.all.count+1
count = all-2
end
WALKIN = "CUS-000000000001"
TAKEAWAY = "CUS-000000000002"
private
def generate_custom_id
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")

View File

@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil)
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount)
pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf")

View File

@@ -17,6 +17,14 @@ class Sale < ApplicationRecord
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
REPORT_TYPE = {
"daily" => 0,
"monthly" => 1,
"yearly" => 2
}
SALE_STATUS_COMPLETED = "completed"
def generate_invoice_from_booking(booking_id, requested_by)
booking = Booking.find(booking_id)
status = false
@@ -336,6 +344,40 @@ class Sale < ApplicationRecord
return daily_total
end
def self.get_by_range_by_saleitems(from,to,status,report_type)
query = Sale.select("
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
SUM(i.qty) as total_item," +
" i.unit_price as unit_price,
mi.name as product_name,
mc.name as menu_category_name,
mc.id as menu_category_id ")
.group('mi.id')
.order("mi.menu_category_id")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
JOIN menu_items mi ON i.product_code = mi.item_code" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
JOIN employees ea ON ea.id = sales.cashier_id")
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
case report_type.to_i
when REPORT_TYPE["daily"]
return query
when REPORT_TYPE["monthly"]
return query.group("MONTH(date)")
when REPORT_TYPE["yearly"]
return query.group("YEAR(date)")
end
end
private
def generate_custom_id

View File

@@ -54,8 +54,8 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}"
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
return true, self.sale
return true, self.save
else
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
@@ -84,12 +84,15 @@ class SalePayment < ApplicationRecord
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
sale_data = Sale.find_by_sale_id(sale_id)
if sale_data
# Control for Paypar Cloud
begin
@@ -199,6 +202,10 @@ class SalePayment < ApplicationRecord
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm'
puts membership_data.to_json
puts "amountttttttttttttttttttttt"
puts self.received_amount
if membership_data["status"]==true
self.payment_method = "paypar"
self.payment_amount = self.received_amount
@@ -257,7 +264,7 @@ class SalePayment < ApplicationRecord
def rebat(sObj)
rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
puts "rebate_prices"
puts "eeeeeeeeeeeeeeeeeeeeeeee"
puts rebate_prices
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
@@ -292,8 +299,8 @@ class SalePayment < ApplicationRecord
rescue Net::OpenTimeout
response = { status: false }
end
# puts response.to_json
return response
# puts response.to_json
end
end
end

View File

@@ -1,6 +1,6 @@
class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil)
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil)
self.page_width = 210
self.page_height = 2500
self.margin = 5
@@ -32,9 +32,13 @@ class ReceiptBillPdf < Prawn::Document
line_items(sale_items, food_total, beverage_total)
all_total(sale_data)
if member_info != nil
member_info(member_info)
member_info(member_info,customer_name,rebate_amount,sale_data)
end
customer(customer_name)
footer
end
@@ -60,6 +64,15 @@ class ReceiptBillPdf < Prawn::Document
end
move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
# text "Customer:", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.label_width,y_position], :width =>self.item_width) do
# text "#{customer_name}" , :size => self.item_font_size,:align => :left
# end
# move_down 5
y_position = cursor
bounding_box([0, y_position], :width =>self.item_width) do
text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
@@ -98,7 +111,7 @@ class ReceiptBillPdf < Prawn::Document
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -128,7 +141,7 @@ class ReceiptBillPdf < Prawn::Document
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 3
end
@@ -200,33 +213,111 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
move_down 5
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Grand Total", :size => self.item_font_size,:align => :left
text "Grand Total", :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
text "#{sale_data.grand_total}" , :size => self.header_font_size,:align => :right
end
move_down 5
# stroke_horizontal_rule
sale_payment(sale_data)
end
def sale_payment(sale_data)
stroke_horizontal_rule
move_down 5
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ payment.payment_amount }" , :size => self.item_font_size,:align => :right
end
move_down 5
end
if sale_data.amount_received > 0
y_position = cursor
move_down 5
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.amount_changed}" , :size => self.item_font_size,:align => :right
end
move_down 5
end
end
# show member information
def member_info(member_info)
def member_info(member_info,customer_name,rebate_amount,sale_data)
move_down 7
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
rebate_amount["data"].each do |res|
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate"
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right
end
end
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right
end
end
end
end
end
if member_info["status"] == true
member_info["data"].each do |res|
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
if res["accountable_type"]== "RebateAccount"
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Current Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
end
end
end
end
end
def customer(customer_name)
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Customer Name", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
end
end
def footer

View File

@@ -1 +1,3 @@
json.array! @customers, :id, :name, :company, :contact_no, :email, :membership_id, :membership_type
json.array! @customers, :id, :name, :company, :contact_no,:salution,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at

View File

@@ -1,4 +1,6 @@
json.extract! @customer, :id, :name, :company, :contact_no, :membership_type, :membership_id, :created_at
json.extract! @customer, :id, :name, :company, :contact_no,:salution,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at
json.invoices do
json.array! @customer.lastest_invoices ,:id, :receipt_no, :receipt_date, :sale_status, :payment_status
end

View File

@@ -0,0 +1,20 @@
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog" style="margin-left:-180px">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

@@ -1,9 +0,0 @@
<div class="form-group">
<select class="selectpicker form-control col-md-12" name="membership_id">
<option>Select Member Group</option>
<% @member_group.each do |member| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</div>

View File

@@ -0,0 +1,122 @@
<div class="col-lg-4 col-md-4 col-sm-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>
<input type="radio" value="Mr" name="salutation" class="salutation mr" style="width: 30px">Mr
</label>
<label>
<input type="radio" value="Miss" name="salutation" class="salutation miss" style="width: 30px">Miss
</label>
<label>
<input type="radio" value="Mrs" name="salutation" class="salutation mrs" style="width: 30px">Mrs
</label>
<label>
<input type="radio" value="Mdm" name="salutation" class="salutation mdm" style="width: 30px">Mdm
</label>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Gender :</label><br>
<label>
<input type="radio" value="Male" name="gender" class="gender male" style="width:30px;">Male
</label>
<label>
<input type="radio" value="Female" name="gender" class="gender female" style="width:30px;">Female
</label>
</div>
<div class="form-group">
<%= f.input :nrc_no, :class => "form-control nrc_no" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :address, :class => "form-control col-md-6 address" %>
</div>
<div class="form-group">
<label>Sr.No</label>
<input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true">
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
<%end%>
</div>

View File

@@ -11,8 +11,6 @@
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-7 col-md-7 col-sm-7">
@@ -26,14 +24,18 @@
<td colspan="6">
<%= form_tag crm_customers_path, :method => :get do %>
<div class="input-append col-md-12 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" class="form-control input-sm col-md-4">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-4">
<button type="submit" class="btn btn-primary btn-md">Search</button>
<!-- <a href="modal-window" data-toggle= "modal" data-target="#modal-window" class="btn btn-primary btn-md" id="card_read" >Read Card</a> -->
<!-- <button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">Open Modal</button> -->
</div>
<% end %>
</td>
</tr>
<tr>
<th>Select</th>
<th>Sr.no</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
@@ -42,12 +44,13 @@
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
@@ -57,9 +60,7 @@
</tr>
<% end %>
<% end %>
<%else%>
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
<% end %>
</tbody>
</table>
<br>
@@ -67,85 +68,33 @@
<%= paginate @crm_customers %>
</div>
</div>
<%= render 'card_read_form' %>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<%= render 'new_form', crm_customer: @crm_customer %>
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['name'] %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['contact_no'] %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['email'] %></span>
<% end -%>
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
<%end%>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<br>
<div class="col-lg-1 col-md-1 col-sm-1">
<br>
<a href="<%= crm_customers_path%>" class="btn btn-primary">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
$(document).on('click',".customer_tr",function(){
$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
@@ -171,8 +120,28 @@ $(function() {
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_salution').val(data.salution);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
if(data.salution == 'Mr') {
$('.mr').prop( "checked", true )
}else if(data.salution == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
// $('.selectpicker > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);

View File

@@ -1,61 +1,74 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<li><%= @customer.customer_id%></li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<!-- Column One -->
<div class="tab-pane active" id="queue" role="tabpanel"">
<div class="row">
<div class="col-md-6">
<br>
<h4>Customer Profile</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<th>Name</th>
<td><%= @crm_customer.name %></td>
</tr>
<tr>
<th>Email</th>
<td><%= @crm_customer.email %></td>
</tr>
<tr>
<th>Contact no</th>
<td><%= @crm_customer.contact_no %></td>
</tr>
<tr>
<th>Company</th>
<td><%= @crm_customer.company %></td>
</tr>
<tr>
<th>Date Of Birth</th>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<br>
<h4>Membership Detail</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<th><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Card No</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>NRC/Passport No</th>
<th>Address</th>
<th>DOB</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @customer.card_no rescue '-'%></td>
<td><%= @customer.name %></td>
<td><%= @customer.company rescue '-' %></td>
<td><%= @customer.contact_no %></td>
<td><%= @customer.email %></td>
<td><%= @customer.nrc_no %></td>
<td><%= @customer.address%></td>
<td><%= @customer.date_of_birth %></td>
</tr>
<tr>
<th colspan="8">Membership Transactions</th>
</tr>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Account No</th> -->
<th>Status</th>
<th>Receipt No</th>
</tr>
<%
if @response["status"] == true %>
<% @response["data"].each do |transaction| %>
<tr>
<td><%= transaction["date"]%></td>
<td><%= transaction["redeem"]%></td>
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["account_no"] %></td> -->
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -1,2 +1,5 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:created_at, :updated_at,
:salution, :gender,:nrc_no,:address,:card_no
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -1,44 +1,112 @@
<div class="row">
<div class="col-lg-12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
<li>New</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<%= form_tag crm_assign_table_path, :method => :post do %>
<input type="hidden" name="id" value="<%=@queue.id%>">
<div class="form-group">
<label>Queue No</label>
<input type="text" name="queue" class="form-control" readonly="true" value="<%=@queue.queue_no%>">
</div>
<div class="form-inputs">
<div class="form-group">
<label>Select Table</label>
<select class="selectpicker form-control col-md-12" name="table_id" style="height: 40px" >
<% @tables.each do |table| %>
<option value="<%= table.id %>">
<%= table.name %></option>
<%end %>
</select>
</div>
</div>
<br>
<div class="form-actions">
<button type="submit" class="btn btn-default">Assign Table</button>
</div>
<% end %>
</div>
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Queue</li>
<li>Assign Queue <%=@queue.queue_no%></li>
</ul>
</div>
<div class="row">
<!-- Column One -->
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 1 - Table Orders -->
<div class="active" id="tables" role="tabpanel">
<div class="tab-pane" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @i =0 %>
<% DiningFacility.all.each do |table| %>
<div class="card assign_table <%= table.status=="available" ? "green" : "red"%>" data-id="<%= table.id %>">
<div class="card-block">
<p class="hidden queue-id"><%= @queue.id %></p>
<p class="hidden queue-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<br>
<a href="<%= crm_dining_queues_path%>" class="btn btn-primary">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
</div>
</div>
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script> -->
<script type="text/javascript">
$(document).on('click',".assign_table",function(){
var queue_id = $(this).find(".queue-id").text();
var table_id = $(this).attr('data-id');
url = '<%= crm_assign_table_path %>';
var status = $(this).find(".queue-status").text()
if (status == "available") {
assign_table(queue_id,table_id,url);
} else {
$.confirm({
title: 'Alert!',
content: 'You cannot assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
}
}
});
}
})
function assign_table(id,table_id,url) {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
buttons: {
cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
url: url ,
data: {id:id,table_id:table_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
window.location.href = '<%=crm_dining_queues_path%>'
}else{
alert('Record not found!');
location.reload();
}
}
});
}
}
}
});
}
</script>

View File

@@ -9,39 +9,41 @@
</div>
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11" style="min-height:670px; max-height:670px; overflow-y:scroll">
<!-- Column One -->
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="row">
<% @i = 0 %> .
<% @dining_queues.each do |queue| %>
<div class="col-md-3 ">
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" style="border:1px solid #ccc;margin-bottom: 10px ">
<div class="card-block">
<p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-status"><%= queue.status %></p>
<h4 class="card-title"><%= @i += 1 %> . Queue No </h4>
<h1 style="text-align: center"><%= queue.queue_no %></h1>
<p class="card-text">
<small class="text-muted">Name : <%= queue.name %></small> <br>
<small class="text-muted">Contact : <%= queue.contact_no %></small>
<br>
<small class="text-muted">Status : <%= queue.status rescue '-' %></small>
</p>
</div>
</div>
<div class="tab-content" style="max-height:670px; overflow-y:scroll">
</div>
<% end %>
</div>
</div>
<!--- Panel 1 - Table Orders -->
<div class="active" role="tabpanel">
<div class="tab-pane" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @i =0 %>
<% @dining_queues.each do |queue| %>
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" data-id="<%= queue.id %>">
<div class="card-block">
<p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-status"><%= queue.status %></p>
<span class="card-title">
<%= @i += 1 %> . Queue No </span>
<p style="font-size: 30px ;text-align: center;">
<strong><%= queue.queue_no %></strong>
</p>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<!-- tabs - End -->
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
@@ -53,7 +55,7 @@ $(function(){
if(status != "Assign"){
$("#assign").removeAttr("disabled");
}else{
$("#assign").addAttr("disabled");
$("#assign").attr("disabled","disabled");
}
$("#assign").val($(this).find(".queue-id").text());
}); //End Click

View File

@@ -0,0 +1,69 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Queue</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11" style="min-height:670px; max-height:670px; overflow-y:scroll">
<div class="row">
<% @i = 0 %> .
<% @dining_queues.each do |queue| %>
<div class="col-md-3 ">
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" style="border:1px solid #ccc;margin-bottom: 10px ">
<div class="card-block">
<p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-status"><%= queue.status %></p>
<h4 class="card-title"><%= @i += 1 %> . Queue No </h4>
<h1 style="text-align: center"><%= queue.queue_no %></h1>
<p class="card-text">
<small class="text-muted">Name : <%= queue.name %></small> <br>
<small class="text-muted">Contact : <%= queue.contact_no %></small>
<br>
<small class="text-muted">Status : <%= queue.status rescue '-' %></small>
</p>
</div>
</div>
</div>
<% end %>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
$(".select-queue").on("click", function(){
$('.select-queue').removeClass('selected-item');
$(this).addClass('selected-item');
var status = $(this).find(".queue-status").text();
if(status != "Assign"){
$("#assign").removeAttr("disabled");
}else{
$("#assign").addAttr("disabled");
}
$("#assign").val($(this).find(".queue-id").text());
}); //End Click
});
$('#assign').click(function() {
var id = $(this).val();
window.location.href = "dining_queues/"+id + "/assign"
});
</script>

View File

@@ -11,6 +11,8 @@
<%= stylesheet_link_tag 'CRM', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'CRM', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %>
</head>
<body>

View File

@@ -39,7 +39,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;Reports</a>
<ul class="dropdown-menu">
<li><%= link_to "Daily Sale Report", reports_daily_sale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", origami_root_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", reports_sale_item_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li>
</ul>
</li>

View File

@@ -11,6 +11,8 @@
<%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %>
</head>
<body>

View File

@@ -29,6 +29,7 @@
</tr>
<tr>
<th>Select</th>
<th>Sr.no</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
@@ -37,12 +38,14 @@
</thead>
<tbody>
<% if @crm_customers.count > 0 %>
<% if @crm_customers.count > 0 %>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
@@ -72,32 +75,86 @@
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<label>Salutation :</label><br>
<label>
<input type="radio" value="Mr" name="salutation" class="salutation mr" style="width: 30px">Mr
</label>
<label>
<input type="radio" value="Miss" name="salutation" class="salutation miss" style="width: 30px">Miss
</label>
<label>
<input type="radio" value="Mrs" name="salutation" class="salutation mrs" style="width: 30px">Mrs
</label>
<label>
<input type="radio" value="Mdm" name="salutation" class="salutation mdm" style="width: 30px">Mdm
</label>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name" %>
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['name'] %></span>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Gender :</label><br>
<label>
<input type="radio" value="Male" name="gender" class="gender male" style="width:30px;">Male
</label>
<label>
<input type="radio" value="Female" name="gender" class="gender female" style="width:30px;">Female
</label>
</div>
<div class="form-group">
<%= f.input :nrc_no, :class => "form-control nrc_no" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
<%= f.input :company, :class => "form-control col-md-6 company",:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['contact_no'] %></span>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<span class="help-block"><%= msg['email'] %></span>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<%= f.input :address, :class => "form-control col-md-6 address" %>
</div>
<div class="form-group">
<label>Sr.No</label>
<input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true">
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
@@ -127,8 +184,6 @@
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(function() {
$('.datepicker').datepicker({
@@ -170,6 +225,25 @@
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_salution').val(data.salution);
$('#customer_nrc_no').val(data.nrc_no);
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
if (data.salution == 'Mr') {
$('.mr').prop( "checked", true )
} else if(data.salution == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');

View File

@@ -175,7 +175,7 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">VOID</button>
<button type="button" id="void" class="btn btn-primary btn-block">VOID</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button>
</div>
</div>
@@ -206,4 +206,10 @@ $('#pay').on('click',function() {
$('#back').on('click',function(){
window.location.href = '/origami/';
})
$('#re-print').click(function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/'+ sale_id + "/reprint"
return false;
});
</script>

View File

@@ -145,68 +145,7 @@ $(function(){
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -32,16 +32,16 @@
<tr>
<th style='text-align:center;'>Sr.no</th>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Daily Void Amount</th>
<th style='text-align:center;'>Daily mpu Sales</th>
<th style='text-align:center;'>Daily master Sales</th>
<th style='text-align:center;'>Daily visa Sales</th>
<th style='text-align:center;'>Daily jcb Sales</th>
<th style='text-align:center;'>Daily paypar Sales</th>
<th style='text-align:center;'>Daily Cash Sales</th>
<th style='text-align:center;'>Daily Credit Sales</th>
<th style='text-align:center;'>Daily FOC Sales</th>
<th style='text-align:center;'>(Daily Discount)</th>
<th style='text-align:center;'>Void Amount</th>
<th style='text-align:center;'>Mpu Sales</th>
<th style='text-align:center;'>Master Sales</th>
<th style='text-align:center;'>Visa Sales</th>
<th style='text-align:center;'>Jcb Sales</th>
<th style='text-align:center;'>Paypar Sales</th>
<th style='text-align:center;'>Cash Sales</th>
<th style='text-align:center;'>Credit Sales</th>
<th style='text-align:center;'>FOC Sales</th>
<th style='text-align:center;'>(Discount)</th>
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
<th style='text-align:center;'>Rounding Adj.</th>
<th style='text-align:center;'>Grand Total</th>

View File

@@ -10,16 +10,16 @@
<tr>
<th style='text-align:center;'>Sr.no</th>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Daily Void Amount</th>
<th style='text-align:center;'>Daily mpu Sales</th>
<th style='text-align:center;'>Daily master Sales</th>
<th style='text-align:center;'>Daily visa Sales</th>
<th style='text-align:center;'>Daily jcb Sales</th>
<th style='text-align:center;'>Daily paypar Sales</th>
<th style='text-align:center;'>Daily Cash Sales</th>
<th style='text-align:center;'>Daily Credit Sales</th>
<th style='text-align:center;'>Daily FOC Sales</th>
<th style='text-align:center;'>(Daily Discount)</th>
<th style='text-align:center;'>Void Amount</th>
<th style='text-align:center;'>Mpu Sales</th>
<th style='text-align:center;'>Master Sales</th>
<th style='text-align:center;'>Visa Sales</th>
<th style='text-align:center;'>Jcb Sales</th>
<th style='text-align:center;'>Paypar Sales</th>
<th style='text-align:center;'>Cash Sales</th>
<th style='text-align:center;'>Credit Sales</th>
<th style='text-align:center;'>FOC Sales</th>
<th style='text-align:center;'>(Discount)</th>
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
<th style='text-align:center;'>Rounding Adj.</th>
<th style='text-align:center;'>Grand Total</th>

View File

@@ -1,20 +0,0 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Receipt List Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>

View File

@@ -30,7 +30,9 @@
<th style='text-align:center;'>Gross Sales</th>
<th style='text-align:center;'>Discount</th>
<th style='text-align:center;'>Total Sales</th>
<th style='text-align:center;'>CT</th>
<% TaxProfile.all.each do |r|%>
<th style='text-align:center;'><%=r.name%></th>
<% end %>
<th style='text-align:center;'>Nett Sales</th>
</tr>
</thead>
@@ -48,7 +50,10 @@
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %></td>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %></td>
<% sale.sale_taxes.each do |sale|%>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %></td>
<% end %>
<td style='text-align:center;'><%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %></td>
</tr>
<% end %>

View File

@@ -18,7 +18,8 @@
<option value="9">Last year</option>
</select>
</div>
<div class="form-group col-md-2">
<input type="hidden" name="report_type" value="sale_item" id="sel_sale_type">
<!-- <div class="form-group col-md-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="0">All Sale Type</option>
@@ -28,7 +29,7 @@
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</option>
</select>
</div>
</div> -->
<div class="form-group col-md-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="">From</label>
@@ -143,69 +144,13 @@ $(function(){
$('#frm_report').submit();
// window.location = url;
});
function export_to(path)
{
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
}
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,141 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Daily Sale Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_item_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_sale_item_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th id="date"></th>
</tr>
<tr>
<th>Menu Category</th>
<th>Code</th>
<th>Product</th>
<th>Total Item</th>
<th>Unit Price</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
var cate = [];
var y;
var count = 0;
var sub_total = 0;
var sub_total_arr = [];
<% @sale_data.each do |result| %>
count = count + 1;
if(count == 1)
$('#date').append('<%= result.date_name rescue '-'%>');
y = $.inArray(<%= result.menu_category_id %>, cate);
if(y == -1){
//add sub total row
sub_total_arr.push(sub_total);
var total_row = '<tr><td colspan="4"></td>'+
'<td > Sub Total</td> ' +
'<td><span class="underline">'+ sub_total +'</span></td>'+
'</tr>';
if(count != 1){
$('.table').append(total_row);
sub_total = 0;
}
cate.push(<%= result.menu_category_id %>);
var th = '<tr><td colspan="6"><%= result.menu_category_name rescue '-'%></td></tr>';
var tr = '<tr>'+
'<td></td>'+
'<td><%= result.code rescue '-'%></td>' +
'<td><%= result.product_name rescue '-'%></td>' +
'<td><%= result.total_item.to_i rescue '-'%></td>' +
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%>'+
'</td>'+
'</tr>';
$('.table').append(th);
$('.table').append(tr);
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
}
else{
var tr = '<tr>'+
'<td></td>'+
'<td><%= result.code rescue '-'%></td>' +
'<td><%= result.product_name rescue '-'%></td>' +
'<td><%= result.total_item.to_i rescue '-'%></td>' +
'<td><%= number_with_precision(result.unit_price, :precision => 0) rescue '-'%></td>'+
'<td><%= number_with_precision(result.grand_total, :precision => 0) rescue '-'%></td></tr>';
$('.table').append(tr);
sub_total = parseInt(sub_total) + parseInt(<%= result.grand_total rescue '-'%>);
}
<% end %>
last_line_subtotal(sub_total);
sub_total_arr.push(parseInt(sub_total));
grand_total(sub_total_arr);
})
function last_line_subtotal(sub_total){
var total_row = '<tr><td colspan="4"></td>'+
'<td > Sub Total</td> ' +
'<td><span class="underline">'+ sub_total +'</span></td>'+
'</tr>';
$('.table').append(total_row);
}
function grand_total(sub_total_arr){
var total = 0;
for(var i=0; i< sub_total_arr.length; i++){
//total_1 = (total_1) + (sub_total_arr[i]);
total = parseInt(total) + parseInt(sub_total_arr[i]);
}
var row = '<tr><td colspan="4"></td>'+
'<td > Grand Total</td> ' +
'<td><span class="double_underline">'+ total +'</span></td>'+
'</tr>';
$('.table').append(row);
}
</script>

View File

@@ -0,0 +1,116 @@
<div class="card row">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<% if params[:from]%>
<tr>
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
</tr>
<% end %>
<tr>
<th style='text-align:center;'>Sr.no</th>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Daily Void Amount</th>
<th style='text-align:center;'>Daily mpu Sales</th>
<th style='text-align:center;'>Daily master Sales</th>
<th style='text-align:center;'>Daily visa Sales</th>
<th style='text-align:center;'>Daily jcb Sales</th>
<th style='text-align:center;'>Daily paypar Sales</th>
<th style='text-align:center;'>Daily Cash Sales</th>
<th style='text-align:center;'>Daily Credit Sales</th>
<th style='text-align:center;'>Daily FOC Sales</th>
<th style='text-align:center;'>(Daily Discount)</th>
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
<th style='text-align:center;'>Rounding Adj.</th>
<th style='text-align:center;'>Grand Total</th>
</tr>
</thead>
<% unless @sale_data.empty? %>
<tbody>
<% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
<% total = 0 %>
<% grand_total = 0 %>
<% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% rounding_adj += sale[:rounding_adj].to_f %>
<tr>
<td style='text-align:right;'><%= count %></td>
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
</tr>
<% count = count + 1 %>
<% end %>
<tr style="font-weight:600;">
<td colspan="3" style='text-align:center;'>Total</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
</tr>
<% total_tax = 0 %>
<% unless @tax.empty? %>
<% @tax.each do |tax| %>
<% total_tax += tax.tax_amount.to_f %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>
<% net = total - total_tax %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'>Net Amount</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>
</tbody>
<% end %>
</table>
</div>
</div>

View File

@@ -66,7 +66,7 @@
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier_name rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at %> </td>
<td> <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>
@@ -175,63 +175,63 @@
</div>
<div class="tab-pane" id="customer" role="tabpanel">
<div class="table-responsive">
<div class="row">
<div class="col-md-6">
<br>
<h4>Customer Profile</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<th>Name</th>
<td><%= @customer.name %></td>
</tr>
<tr>
<th>Email</th>
<td><%= @customer.email %></td>
</tr>
<tr>
<th>Contact no</th>
<td><%= @customer.contact_no %></td>
</tr>
<tr>
<th>Company</th>
<td><%= @customer.company %></td>
</tr>
<tr>
<th>Date Of Birth</th>
<td><%= @customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<br>
<h4>Membership Detail</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<th><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<br>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Card No</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>NRC/Passport No</th>
<th>Address</th>
<th>DOB</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @customer.card_no rescue '-'%></td>
<td><%= @customer.name %></td>
<td><%= @customer.company rescue '-' %></td>
<td><%= @customer.contact_no %></td>
<td><%= @customer.email %></td>
<td><%= @customer.nrc_no %></td>
<td><%= @customer.address%></td>
<td><%= @customer.date_of_birth %></td>
</tr>
<tr>
<th colspan="8">Membership Transactions</th>
</tr>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Account No</th> -->
<th>Status</th>
<th>Receipt No</th>
</tr>
<%
if @response["status"] == true %>
<% @response["data"].each do |transaction| %>
<tr>
<td><%= transaction["date"]%></td>
<td><%= transaction["redeem"]%></td>
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["account_no"] %></td> -->
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@@ -3,3 +3,4 @@ require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View File

@@ -22,3 +22,7 @@ Rails.application.config.assets.precompile += %w( settings.css )
# --- Customer/ Customer - Crm ----
Rails.application.config.assets.precompile += %w( CRM.css )
Rails.application.config.assets.precompile += %w( CRM.js )
# --- Customer/ Customer - Crm ----
Rails.application.config.assets.precompile += %w( jquery-confirm.css )
Rails.application.config.assets.precompile += %w( jquery-confirm.js )

View File

@@ -89,7 +89,7 @@ Rails.application.routes.draw do
get "/:id/discount" => "discounts#index"
post "/:id/discount" => "discounts#create"
post "/:id/request_bills" => "request_bills#print"
post "/:id/request_bills" => "request_bills#print" ,:defaults => { :format => 'json' }
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
#--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show'
@@ -219,6 +219,7 @@ Rails.application.routes.draw do
namespace :reports do
resources :receipt_no, :only => [:index, :show]
resources :daily_sale, :only => [:index, :show]
resources :sale_item, :only => [:index, :show]
# resources :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show]

View File

@@ -10,6 +10,11 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
t.string :membership_id
t.string :membership_type
t.string :membership_authentication_code
t.string :salution
t.string :gender
t.string :nrc_no
t.string :address
t.string :card_no, :unique => true
t.timestamps
end

View File

@@ -161,7 +161,8 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
{membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"},
{membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})