This commit is contained in:
Cherry
2017-06-12 18:28:18 +06:30
50 changed files with 1335 additions and 407 deletions

View File

@@ -5,9 +5,10 @@
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
// Temp Disable
// (function() {
// this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
// App.cable = ActionCable.createConsumer();
}).call(this);
// }).call(this);

View File

@@ -28,7 +28,7 @@ $(document).ready(function(){
$("#order-Tax").text('');
$("#order-grand-total").text('');
var zone_name=$(this).find(".orders-table").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();
@@ -37,15 +37,12 @@ $(document).ready(function(){
control_button(order_status);
//for customer button
if(unique_id.charAt(0) == 'S'){
$("#customer").removeAttr('disabled');
}else{
$("#customer").attr('disabled','disabled');
}
var customer_id=$(this).find(".customer-id").text();
show_customer_details(customer_id);
var cashier="";
var receipt_date="";
@@ -63,13 +60,7 @@ $(document).ready(function(){
type: "POST",
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
success:function(result){
// =======
// type: "GET",
// url: "origami/" + unique_id,
// data: { 'id' : unique_id },
// success:function(result){
// >>>>>>> 5ee3ae257a59269b651dcc5c0232b95d7f41fb77
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
@@ -86,7 +77,7 @@ $(document).ready(function(){
//Receipt Charges
sub_total += (parse_data.qty*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;
@@ -184,27 +175,45 @@ $(document).ready(function(){
});
$('#customer').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
var sale = $(".selected-item").find(".orders-id").text();
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 + "/add_customer"
return false;
});
function show_customer_details(customer_id){
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: "origami/"+customer_id+"/get_customer/",
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data.name);
$("#customer_name").text(data.name);
}
});
//End Ajax
}
function show_customer_details(customer_id){
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: "origami/"+customer_id+"/get_customer/",
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
console.log(balance);
if (balance) {
$("#customer_amount").text(balance);
}else{
$("#customer_amount").text('00');
}
}
});
}
});
//End Ajax
}
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -21,8 +21,9 @@
}
.cashier_number{
height:60px;
line-height:60px;
width: 33%;
height:70px;
line-height:70px;
text-align:center;
background:#54A5AF;
// float:left;
@@ -34,8 +35,8 @@
.pay{
width: 98%;
height:210px;
line-height:210px;
height:211px;
line-height:211px;
text-align:center;
font-size:20px;
color:white;
@@ -46,7 +47,7 @@
}
.long{
width:100%;
width:49%;
}
.sold {
@@ -121,4 +122,4 @@ select.form-control {
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
}
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the settings/orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -38,9 +38,8 @@ class Api::OrdersController < Api::ApiController
#Create Table Booking or Room Booking
if !params["booking_id"].nil? && params[:booking_id].to_i > 0
#@order.new_booking = false
@order.new_booking = true
if !params["booking_id"].nil?
@order.new_booking = false
@order.booking_id = params[:booking_id]
end

View File

@@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController
end
#@crm_customers = Customer.all
@crm_customer = Customer.new
@crm_customer.valid?
if @crm_customer.valid?
@crm_customer.errors.messages
end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -30,6 +30,15 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
@orders = Order.where("customer_id=?", params[:id])
if @orders
@order_items = []
@orders.each do |bo|
@order_items = @order_items + bo.order_items
end
end
end
# GET /crm/customers/new
@@ -45,66 +54,64 @@ class Crm::CustomersController < BaseCrmController
# POST /crm/customers
# POST /crm/customers.json
def create
def create
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
membership_id = params[:membership_id]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
app_token = membership.auth_token.to_s
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
membership_id: membership_id}.to_json,
member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
if response["status"] == true
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id].nil?
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
end
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
if params[:sale_id].nil?
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end
# format.json { render :index, status: :created, location: @crm_customers }
else
if params[:sale_id].nil?
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
end
end
end
end
end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
@@ -118,15 +125,16 @@ class Crm::CustomersController < BaseCrmController
email = customer_params[:email]
date_of_birth = customer_params[:date_of_birth]
id = customer_params[:membership_id]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
app_token = membership.auth_token.to_s
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
date_of_birth: date_of_birth,
id: id}.to_json,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -155,22 +163,6 @@ class Crm::CustomersController < BaseCrmController
end
end
# DELETE /crm/customers/1
# DELETE /crm/customers/1.json
def get_sale_id
@sale_id = params[:sale_id]
@crm_customers = Customer.all
@crm_customer = Customer.new
@membership = Customer.get_member_group
if @membership["status"] == true
@member_group = @membership["data"]
end
respond_to do |format|
format.html { render action: "index"}
format.json { render json: @crm_customers }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_crm_customer

View File

@@ -18,15 +18,20 @@ class Origami::CustomersController < BaseOrigamiController
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("name").page(params[:page])
@crm_customers = Customer.order("name").page params[:page]
else
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page]
end
# @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2)
@crm_customer = Customer.new
@membership = Customer.get_member_group
if @membership["status"] == true
@member_group = @membership["data"]
end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
puts "Errrrrrrrrrrrrrrrrr"
puts @crm_customer.new_record?
respond_to do |format|
# format.html { render :template => "crm/customers/index" }
format.html { render action: "index"}

View File

@@ -12,6 +12,7 @@ class Origami::HomeController < BaseOrigamiController
@selected_item_type="Order"
end
end
puts params[:booking_id]
@completed_orders = Order.get_completed_order()
@booking_orders = Order.get_booking_order_table()
@@ -48,20 +49,47 @@ class Origami::HomeController < BaseOrigamiController
def update_sale_by_customer
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: params[:customer_id])
if status == true
id = params[:sale_id][0,3]
if(id == "SAL")
sale = Sale.find(params[:sale_id])
else
sale = Order.find(params[:sale_id])
end
status = sale.update_attributes(customer_id: params[:customer_id])
if status == true
render json: JSON.generate({:status => true})
else
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end
def get_customer
@customer = Customer.find(params[:customer_id])
render :json => @customer.to_json
@customer = Customer.find(params[:customer_id])
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
respond_to do |format|
format.js do
render :json => {
:response_data => response.as_json,
:customer => @customer}
end
end
end
end

View File

@@ -16,7 +16,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
if member_actions.gateway_url
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id)
merchant_uid= member_actions.merchant_account_id
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id

View File

@@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
redirect_to origami_path(sale_order.sale_id)
redirect_to origami_path(@sale_data.sale_id)
end
end

View File

@@ -0,0 +1,32 @@
class Settings::OrdersController < ApplicationController
def index
filter = params[:filter]
if filter.nil?
orders = Order.order("order_id desc").limit(1000)
else
order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page])
if order.count > 0
orders = order
else
orders = Order.order("order_id desc").limit(1000)
flash[:notice] = "There is no data."
end
end
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
def show
@order = Order.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
end
end
end

View File

@@ -0,0 +1,42 @@
class Settings::SalesController < ApplicationController
def index
search_date = params[:date]
receipt_no = params[:receipt_no]
today = Date.today
if receipt_no.nil? && search_date.nil?
@sales = Sale.where("NOT sale_status = 'void'" ).order("sale_id desc").limit(500)
else
if !search_date.blank? && receipt_no.blank?
sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", search_date).order("sale_id desc").limit(500).page(params[:page])
elsif !search_date.blank? && !receipt_no.blank?
sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%Y-%b-%d') = ?", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
else
sale = Sale.where("receipt_no LIKE ?", receipt_no).order("sale_id desc").limit(500).page(params[:page])
end
if sale.count > 0
@sales = sale
else
@sales = Sale.where("NOT sale_status = 'void'").order("sale_id desc").limit(500)
end
end
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
end
end
def show
@sale = Sale.find(params[:id])
# @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }
end
end
end

View File

@@ -0,0 +1,2 @@
module Settings::OrdersHelper
end

View File

@@ -14,9 +14,9 @@ class Customer < ApplicationRecord
def self.get_member_group
membership = MembershipSetting.find_by_membership_type("paypar_url")
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
app_token = membership.auth_token.to_s
app_token = membership.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url,

View File

@@ -9,10 +9,11 @@ class DiningFacility < ApplicationRecord
scope :active, -> {where(is_active: true)}
def get_current_booking
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
puts "enter booking"
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
if booking.count > 0 then
return booking[0]
return booking[0].booking_id
else
return nil
end

View File

@@ -1,3 +1,2 @@
class DiningQueue < ApplicationRecord
end

View File

@@ -17,6 +17,10 @@ class Lookup < ApplicationRecord
"Gateway Communication Type" => "gateway_communication_type"}
end
# def self.get_by_type( lookup_type)
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end
def self.collection_of(type)
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }

View File

@@ -25,14 +25,15 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
puts "a"
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
if (self.booking_id.to_i > 0 )
booking = Booking.find(self.booking_id)
end
booking = Booking.find(self.booking_id)
end
booking.save!
@@ -222,28 +223,29 @@ class Order < ApplicationRecord
#Origami: Cashier : to view booking order Table
def self.get_booking_order_table
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.customer_id as customer_id,
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
end
#Origami: Cashier : to view booking order Table
def self.get_completed_order
completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
completed_orders = Booking.select("sales.receipt_no,orders.status as order_status,orders.order_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
<<<<<<< HEAD
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
end
#Origami: Cashier : to view booking order Table
@@ -252,24 +254,25 @@ class Order < ApplicationRecord
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status")
.where("sales.sale_status<>'completed' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id")
end
#Origami: Cashier : to view order type Room
def self.get_booking_order_rooms
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,orders.customer_id as customer_id,
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,orders.customer_id as customer_id,
sales.sale_id as sale_id,dining_facilities.name as room_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sale_orders on sale_orders.order_id = orders.order_id")
.joins("left join sales on sales.sale_id = sale_orders.sale_id")
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name")
.where("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id")
end
#Origami: Cashier : to view order type Room
@@ -290,15 +293,16 @@ class Order < ApplicationRecord
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,
orders.customer_id as customer_id,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id
,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
left join bookings on bookings.booking_id = booking_orders.order_id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.order_id
left join sale_orders on sale_orders.order_id = orders.order_id
left join sales on sales.sale_id = sale_orders.sale_id")
.where("sales.sale_status<>'complete' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id")
.where("sales.sale_status<>'completed' and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id")
end

View File

@@ -1,6 +1,6 @@
class SaleItem < ApplicationRecord
self.primary_key = "sale_item_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
@@ -12,17 +12,17 @@ class SaleItem < ApplicationRecord
def self.get_order_items_details(sale_id)
order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,
order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , sales.total_discount as discount_amount,sales.receipt_date as receipt_date,
sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
.joins("left join sales on sales.sale_id = sale_items.sale_id")
.where("sale_items.sale_id=?",sale_id)
# sale_orders = SaleOrder.where("sale_id=?",sale_id)
# if sale_orders
# sale_orders.each do |sale_order|
# sale_orders.each do |sale_order|
# order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
# .joins("left join sales on sales.id = sale_items.sale_id")
# .where("sale_items.sale_id=?",sale_order.sale_id)
# .where("sale_items.sale_id=?",sale_order.sale_id)
# return order_details
# end
# else
@@ -35,27 +35,30 @@ class SaleItem < ApplicationRecord
beverage_prices=0
sale_items.each do |si|
food_price = self.get_food_price(si.sale_item_id)
beverage_price = self.get_beverage_price(si.sale_item_id)
puts food_price
# food_prices = food_prices + food_price.price
# beverage_prices = beverage_prices + beverage_price.price
food_price, beverage_price = self.get_price(si.sale_item_id)
food_prices = food_prices + food_price
beverage_prices = beverage_prices + beverage_price
end
return food_prices, beverage_prices
end
def self.get_food_price(sale_item_id)
food_price=SaleItem.select("sale_items.price")
def self.get_price(sale_item_id)
food_price=0
beverage_price=0
item=SaleItem.select("sale_items.price , menu_items.account_id")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=0", sale_item_id)
.where("sale_items.sale_item_id=?", sale_item_id.to_s)
if item[0].account_id == 1
food_price = item[0].price
else
beverage_price = item[0].price
end
return food_price, beverage_price
end
def self.get_beverage_price(sale_item_id)
beverage_price=SaleItem.select("sale_items.price")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=? and menu_items.account_id=1", sale_item_id)
end
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")

View File

@@ -60,15 +60,15 @@ class SalePayment < ApplicationRecord
#record an payment in sale-audit
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by)
return false, "No outstanding Amount"
end
end
def self.get_paypar_account(url,token,membership_id,campaign_type_id)
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid)
response = HTTParty.get(url,
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id}.to_json,
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -82,9 +82,10 @@ class SalePayment < ApplicationRecord
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
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
merchant_uid = membership_actions_data.merchant_account_id
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
response = HTTParty.post(url,
:body => { generic_customer_id:membership_id,total_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:""}.to_json,
:body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipet_no:sale_id,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -211,18 +212,29 @@ class SalePayment < ApplicationRecord
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
end
if (self.sale.grand_total <= all_received_amount)
self.sale.payment_status = "paid"
self.sale.sale_status = "completed"
self.sale.save!
table_update_status(sObj)
rebat()
end
end
def table_update_status(sale_obj)
booking = Booking.find_by_sale_id(sale_obj.id)
if booking
table = DiningFacility.find(booking.dining_facility_id)
if table
table.status = "available"
table.save
end
end
end
def rebat
end
private

View File

@@ -1,16 +1,16 @@
class ReceiptBillPdf < Prawn::Document
attr_accessor :receipt_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
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)
self.page_width = 300
self.page_width = 250
self.page_height = 1450
self.margin = 10
self.price_width = 50
self.qty_width = 30
self.total_width = 50
self.item_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.price_width = 40
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)+(self.margin*4))
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.receipt_width=100
self.label_width=80
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
@@ -22,8 +22,8 @@ class ReceiptBillPdf < Prawn::Document
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
self.header_font_size = 12
self.item_font_size = 10
self.header_font_size = 11
self.item_font_size = 9
header( printer_settings.printer_name, printer_settings.name)
@@ -31,66 +31,64 @@ class ReceiptBillPdf < Prawn::Document
cashier_info(sale_data, customer_name)
line_items(sale_items, food_total, beverage_total)
all_total(sale_data)
all_total(sale_data)
footer
end
def header (printer_name, name)
text "#{printer_name}", :size => self.header_font_size,:align => :center
move_down 5
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name)
move_down 7
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Receipt No:", :size => self.item_font_size,:align => :left
end
bounding_box([self.receipt_width, y_position], :width =>self.receipt_width) do
bounding_box([self.label_width, y_position], :width =>self.item_width) do
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
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.receipt_width,y_position], :width =>self.receipt_width) do
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.receipt_width, :height => self.item_height) do
text "Date:", :size => self.item_font_size,:align => :left
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Date:", :size => self.item_font_size,:align => :left
end
bounding_box([self.receipt_width,y_position], :width =>self.receipt_width) do
text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
bounding_box([self.label_width,y_position], :width => self.item_width) do
text "#{sale_data.receipt_date.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
end
# stroke_horizontal_rule
move_down 5
stroke_horizontal_rule
move_down 5
end
def line_items(sale_items, food_total, beverage_total)
y_position = cursor
stroke_horizontal_rule
move_down 5
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width - 20, :height =>self.item_height, :size => self.item_font_size
text_box "Price", :at =>[self.item_width-20,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
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 => :right
text_box "Total", :at =>[self.item_width+self.price_width+self.qty_width,y_position], :width => self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
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 => :right, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+2),y_position], :width => self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
@@ -99,88 +97,88 @@ class ReceiptBillPdf < Prawn::Document
add_line_item_row(sale_items, food_total, beverage_total)
end
def add_line_item_row(sale_items, food_total, beverage_total)
item_name_width = self.item_width-20
item_name_width = (self.item_width+self.price_width)
y_position = cursor
move_down 5
sub_total = 0.0
sale_items.each do |item|
sale_items.each do |item|
sub_total += (item.qty*item.unit_price)
qty = item.qty
total_price = item.qty*item.unit_price
price = item.unit_price
product_name = item.product_name
sub_total += item.qty*item.unit_price
qty = item.qty
total_price = item.qty*item.unit_price
price = item.unit_price
product_name = item.product_name
y_position = cursor
y_position = cursor
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :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.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{total_price}", :at =>[(item_name_width+2),y_position], :width =>self.total_width+2, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "#{product_name}", :at =>[0,y_position], :width => item_name_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size
text_box "#{price}", :at =>[item_name_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
text_box "#{qty.to_i}", :at =>[item_name_width+self.price_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
text_box "#{total_price}", :at =>[item_name_width+self.price_width+self.qty_width,y_position], :width =>self.total_width, :height =>self.item_height, :size => self.item_font_size, :align => :right
}
move_down 3
end
}
move_down 3
end
stroke_horizontal_rule
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>item_name_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
text "#{sub_total}" , :size => self.item_font_size,:align => :right
bounding_box([item_name_width,y_position], :width =>self.total_width) do
text "#{ sub_total }" , :size => self.item_font_size,:align => :right
end
# Food and Beverage
food_beverage_total = food_total.to_s + '/' + beverage_total.to_s
food_beverage_total = food_total.to_s + "/" + beverage_total.to_s
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>(item_name_width), :height => self.item_height) do
text "Food/Beverage Total", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
bounding_box([item_name_width,y_position], :width =>self.total_width) do
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right
end
end
def all_total(sale_data)
item_name_width = self.item_width-20
item_name_width = self.item_width
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Discount", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Total Tax", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
end
move_down 5
y_position = cursor
move_down 5
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
bounding_box([0,y_position], :width =>(item_name_width+self.price_width), :height => self.item_height) do
text "Grand Total", :size => self.item_font_size,:align => :left
end
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
bounding_box([(item_name_width+self.price_width),y_position], :width =>self.total_width) do
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
end
move_down 5
@@ -188,4 +186,14 @@ class ReceiptBillPdf < Prawn::Document
end
def footer
move_down 5
stroke_horizontal_rule
move_down 5
text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
end
end

View File

@@ -0,0 +1,9 @@
<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

@@ -51,7 +51,7 @@
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td>
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
<%= link_to 'Show', crm_customer_path(crm_customer) %>
</td>
@@ -71,7 +71,6 @@
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<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 " %>
@@ -94,17 +93,20 @@
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
<%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%>
</div>
<div class="form-group">
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% 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.input :membership_type, :class => "form-control col-md-6 membership_type" %>
</div>
<div class="form-group">
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
</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' %>

View File

@@ -1,40 +1,84 @@
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @crm_customer.name %>
</p>
<p>
<strong>Company:</strong>
<%= @crm_customer.company %>
</p>
<p>
<strong>Contact no:</strong>
<%= @crm_customer.contact_no %>
</p>
<p>
<strong>Email:</strong>
<%= @crm_customer.email %>
</p>
<p>
<strong>Date of birth:</strong>
<%= @crm_customer.date_of_birth %>
</p>
<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 class="active">Details
</li>
</ol>
</div>
</div>
<p>
<strong>Membership type:</strong>
<%= @crm_customer.membership_type %>
</p>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<hr>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Contact no</th>
<th>Company</th>
<th>Date Of Birth</th>
</tr>
</thead>
<p>
<strong>Membership authentication code:</strong>
<%= @crm_customer.membership_authentication_code %>
</p>
<tbody>
<tr>
<td><%= @crm_customer.name %></td>
<td><%= @crm_customer.email %></td>
<td><%= @crm_customer.contact_no %></td>
<td><%= @crm_customer.company %></td>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
<br>
<h3>Order Details</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Created at </th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Option</th>
<th>Status</th>
<th>Waiter</th>
</tr>
</thead>
<tbody>
<% @order_items.each do |order_item| %>
<tr>
<td><%= order_item.created_at %></td>
<td><%= order_item.item_name %></td>
<td><%= order_item.qty %></td>
<td><%= order_item.price %></td>
<td><%= order_item.options %></td>
<td><%= order_item.order_item_status %></td>
<td><%= order_item.item_order_by %> </td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<%= link_to 'Edit', edit_crm_customer_path(@crm_customer) %> |
<%= link_to 'Back', crm_customers_path %>

View File

@@ -0,0 +1,11 @@
<%# Link to the "First" page
- available local variables
url: url to the first page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="first">
<%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote %>
</span>

View File

@@ -0,0 +1,8 @@
<%# Non-link tag that stands for skipped pages...
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page gap"><%= t('views.pagination.truncate').html_safe %></span>

View File

@@ -0,0 +1,11 @@
<%# Link to the "Last" page
- available local variables
url: url to the last page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="last">
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %>
</span>

View File

@@ -0,0 +1,11 @@
<%# Link to the "Next" page
- available local variables
url: url to the next page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="next">
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %>
</span>

View File

@@ -0,0 +1,12 @@
<%# Link showing page number
- available local variables
page: a page object for "this" page
url: url to this page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="page<%= ' current' if page.current? %>">
<%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</span>

View File

@@ -0,0 +1,23 @@
<%# The container tag
- available local variables
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
paginator: the paginator that renders the pagination tags inside
-%>
<%= paginator.render do -%>
<nav class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</nav>
<% end -%>

View File

@@ -0,0 +1,11 @@
<%# Link to the "Previous" page
- available local variables
url: url to the previous page
current_page: a page object for the currently displayed page
total_pages: total number of pages
per_page: number of items to fetch per page
remote: data-remote
-%>
<span class="prev">
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %>
</span>

View File

@@ -0,0 +1,233 @@
<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>
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
</a> -->
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="6">
<%= form_tag crm_customers_path, :method => :get do %>
<div class="input-append form-group pull-left">
<input type="text" name="filter" placeholder="Search" class="form-control input-sm col-md-8">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
</td>
</tr>
<tr>
<th>Select</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<% @crm_customers.each do |crm_customer| %>
<tr>
<td>
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td>
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
</div>
</div>
</div>
<div class="col-lg-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<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">
<%= f.input :name, :class => "form-control col-md-6 name" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6 email" %>
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
</div>
<div class="form-group">
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% 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.input :membership_type, :class => "form-control col-md-6 membership_type" %>
</div>
<div class="form-group">
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
</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' %>
</div>
<%end%>
</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 () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).val();
if(sale_id != 0){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
}else{
var url = "customers/"+customer_id;
}
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type);
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val();
$("#new_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").append('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH');
}
});
}else{
}
})
function update_sale(customer_id,sale_id) {
$.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: "update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
alert('Customer has assigned');
window.location.href = '/origami'
}else{
alert('Record not found!');
location.reload();
}
}
});
}
}
}
});
}
</script>

View File

@@ -4,7 +4,7 @@
<!-- Order Details -->
<div class="card" >
<!-- <div class="card-header">
<!-- <div class="card-header">
<div><strong id="order-title">ORDER DETAILS</strong></div>
</div> -->
<div class="card-block">
@@ -13,10 +13,10 @@
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
<p>Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
</div>
<div class="card-text">
<table class="table table-default" id="order-items-table">
@@ -75,7 +75,7 @@
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Column One -->
@@ -88,7 +88,7 @@
</div>
<div class="card-block">
<div class="card-title">
<div class="form-horizontal">
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-3">
<select name="discount_type" id="discount-type" class="form-control">
@@ -97,27 +97,27 @@
</select>
</div>
<div class="col-md-9">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
</div>
</div>
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
</div>
</div>
<button id="pay-discount" class="btn btn-primary long">Discount</button>
</div>
</div>
</div>
<hr />
<div class="col-md-12">
<div class="col-md-12">
<div class="row">
<div class="col-md-5">
<div class="col-md-12 cashier_number long" data-value="5" data-type="add">5%</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -125,12 +125,12 @@
<div class="col-md-12 cashier_number long" data-value="10" data-type="add">10%</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -138,12 +138,12 @@
<div class="col-md-12 cashier_number long" data-value="20" data-type="add">20%</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -151,12 +151,12 @@
<div class="col-md-12 cashier_number long" data-value="30" data-type="add">30%</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
<div class="col-md-3 left cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 left cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -166,13 +166,13 @@
<div class="col-md-7">
<div class="row">
<div class="col-md-3 cashier_number"></div>
<div class="col-md-3 cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 cashier_number green" data-type="clr">CLR</div>
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -23,37 +23,44 @@
<!--- Panel 0 - Completed Orders -->
<div class="tab-pane" id="Completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@completed_orders.each do |cpo|
<%
@completed_orders.each do |cpo|
# ToDo no need check new
# Assigned Id for new Order? Sale?
unique_id=""
unique_id = ""
customer_id = ""
# For CSS- Class for Order? Sale?
sale_status=""
if cpo.order_status == 'new'
if cpo.order_status == 'new'
unique_id=cpo.booking_id
# check selected item and assign
if @selected_item != nil
customer_id=cpo.order_customer_id
# check selected item and assign
if @selected_item != nil
if cpo.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
else
else
unique_id=cpo.sale_id
customer_id=cpo.sale_customer_id
sale_status="paid"
# check selected item and assign
# check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
end
end
%>
<div class="card orders <%= sale_status %>">
<div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= bko.customer_id %></p>
<h4 class="card-title orders-table"><%= cpo.table_name %></h4>
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= customer_id %></p>
<p class="hidden order-cid"><%= cpo.order_id %></p>
<h4 class="card-title orders-table"><%= cpo.table_name %></h4>
<p class="card-text">
Receipt No :
<span class="orders-receipt-no">
@@ -64,12 +71,12 @@
Order Status :
<span class="orders-order-status">
<%= cpo.order_status %>
</span>
</span>
</small>
</p>
</div>
</div>
<%
</p>
</div>
</div>
<%
end
%>
</div>
@@ -78,34 +85,39 @@
<!--- Panel 1 - Table Orders -->
<div class="tab-pane active" id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@booking_orders.each do |bko|
<%
@booking_orders.each do |bko|
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
# For CSS- Class for Order? Sale?
sale_status=""
if bko.order_status == 'new'
if bko.order_status == 'new'
unique_id=bko.booking_id
# check selected item and assign
if @selected_item != nil
customer_id=bko.order_customer_id
# check selected item and assign
if @selected_item != nil
if bko.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
else
else
unique_id=bko.sale_id
customer_id=bko.sale_customer_id
sale_status="sold"
# check selected item and assign
# check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
end
end
%>
<div class="card orders <%= sale_status %>">
<div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= customer_id %></p>
<p class="hidden order-cid"><%= bko.order_id %></p>
<h4 class="card-title orders-table"><%= bko.table_name %></h4>
<p class="card-text">
Receipt No :
@@ -135,34 +147,37 @@
@booking_rooms.each do |rmo|
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
# For CSS- Class for Order? Sale?
sale_status=""
if rmo.order_status == 'new'
if rmo.order_status == 'new'
unique_id=rmo.booking_id
# check selected item and assign
if @selected_item != nil
customer_id=rmo.order_customer_id
# check selected item and assign
if @selected_item != nil
if rmo.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
else
end
end
else
unique_id=rmo.sale_id
customer_id=rmo.sale_customer_id
sale_status="sold"
# check selected item and assign
# check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
end
end
%>
<div class="card orders <%= sale_status %>">
<div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= rmo.customer_id %></p>
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
<p class="hidden customer-id"><%= customer_id %></p>
<p class="hidden order-cid"><%= rmo.order_id %></p>
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
<p class="card-text">
Receipt No :
<span class="orders-receipt-no">
@@ -186,40 +201,42 @@
<!--- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@orders.each do |odr|
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@orders.each do |odr|
# Assigned Id for new Order? Sale?
unique_id=""
customer_id=""
# For CSS- Class for Order? Sale?
sale_status=""
sale_status=""
if odr.order_status == 'new'
if odr.order_status == 'new'
unique_id=odr.booking_id
# check selected item and assign
if @selected_item != nil
customer_id = odr.order_customer_id
if @selected_item != nil
if odr.order_id == @selected_item.order_id
sale_status = sale_status + " selected-item"
end
end
else
else
unique_id=odr.sale_id
sale_status="sold"
# check selected item and assign
if @selected_item != nil
customer_id = odr.sale_customer_id
sale_status="sold"
# check selected item and assign
if @selected_item != nil
if unique_id == @selected_item.sale_id
sale_status = sale_status + " selected-item"
end
end
end
end
%>
<div class="card orders <%= sale_status %>">
<div class="card-block">
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= odr.customer_id %></p>
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
<p class="card-text">
<p class="hidden orders-id"><%= unique_id %></p>
<p class="hidden customer-id"><%= customer_id %></p>
<p class="hidden order-cid"><%= odr.order_id %></p>
<h4 class="card-title orders-table"><%= odr.table_name %></h4
<p class="card-text">
Receipt No :
<span class="orders-receipt-no">
<%= odr.receipt_no %>
@@ -256,19 +273,19 @@
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Receipt No: <span id="receipt_no"><%=@selected_item.receipt_no rescue ' '%></span></p>
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Amount : <span id="customer_amount"></span></p>
</div>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
@@ -280,7 +297,7 @@
</tr>
</thead>
<tbody>
<%
<%
# For Sale Items
sub_total = 0
if @selected_item_type == "Sale"
@@ -288,16 +305,16 @@
sub_total += sale_item.qty*sale_item.unit_price
%>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.qty*sale_item.price %></td>
</tr>
<%
<%
end
end
%>
<%
<%
# For Order Items
sub_total = 0
if @selected_item_type == "Order"
@@ -305,11 +322,11 @@
sub_total += order_item.qty*order_item.unit_price
%>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
<%
end
end
%>
@@ -354,7 +371,8 @@
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
<button type="button" class="btn btn-primary btn-lg btn-block" id="customer" disabled>Customer</button>
<button type="button" id="customer" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block" disabled>Req.Bill</button>
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block" disabled>Req.Bill</button>
<!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block" disabled>Discount</button>

View File

@@ -13,7 +13,7 @@ Amount :
var sale_id = "<%= @sale_id %>";
$.ajax({type: "POST",
url: "<%= origami_create_mpu_payment_path %>",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){

View File

@@ -6,8 +6,8 @@
<div id="order-title">
<table>
<tr>
<td style="width:60%;"><strong>Receipt No : <%=@sale_data.receipt_no rescue ' '%></strong></td>
<td style="width:40%;"><strong>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></strong></td>
<td style="width:55%;"><strong>Receipt No : <%=@sale_data.receipt_no rescue ' '%></strong></td>
<td style="width:45%;"><strong>Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></strong></td>
</tr>
<tr>
<td><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></td>
@@ -130,7 +130,7 @@
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number"></div>
<div class=" cashier_number" data-type="nett">Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number green left" data-type="clr">Clr</div>
</div>
@@ -195,6 +195,10 @@ $(document).on('click', '.cashier_number', function(event){
$('#cash').text("0.0");
update_balance();
break;
case 'nett':
$('#cash').text($('#amount_due').text());
update_balance();
break;
}
event.handled = true;
} else {
@@ -216,7 +220,6 @@ $( document ).ready(function() {
});
$('#pay').click(function() {
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
}else{
@@ -226,10 +229,15 @@ $( document ).ready(function() {
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_process_path %>",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
success:function(result){
alert("Thank you")
if($('#balance').text() < 0){
alert("Changed amount " + $('#balance').text() * (-1) )
}else{
alert("Thank you")
}
window.location.href = '/origami';
}
});

View File

@@ -1,7 +1,7 @@
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="card">
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
@@ -22,15 +22,15 @@
</div>
<div class="col-lg-7 col-md-7 col-sm-7">
<div class="row">
<div class="row" style="margin-top:10px;">
<div class="col-md-12">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number" data-value="3" data-type="num">3</div>
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
<div class="col-md-5">
@@ -39,10 +39,10 @@
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-3 cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number" data-value="6" data-type="num">6</div>
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
<div class="col-md-5">
@@ -51,10 +51,10 @@
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 cashier_number" data-value="9" data-type="num">9</div>
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
<div class="col-md-5">
@@ -63,10 +63,10 @@
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 cashier_number" data-value="00" data-type="num">00</div>
<div class="col-md-3 left cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-3 left cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
<div class="col-md-5">
@@ -75,10 +75,10 @@
</div>
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="row bottom">
<div class="col-md-3 cashier_number"></div>
<div class="col-md-3 cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 cashier_number green" data-type="clr">CLR</div>
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
<div class="col-md-5">
@@ -140,13 +140,14 @@ $("#redeem").click(function(){
membership_id = $("#valid_amount").attr('data-member-value');
redeem_amount = parseInt($("#used_amount").text());
if(redeem_amount<=0 ){
alert(" Insufficient Amount!")
}else if(valid_amount< redeem_amount || redeem_amount == ""){
alert("Please type valid amount");
}else if(valid_amount< redeem_amount){
alert(" Insufficient Amount!")
}else{
$.ajax({
type: "POST",
url: "<%=origami_paypar_payment_process_path%>",
url: "<%=origami_payment_paypar_path%>",
data: {redeem_amount:redeem_amount,membership_id:membership_id,sale_id:sale_id},
success: function(result){
if(result.status == true){

View File

@@ -0,0 +1,68 @@
<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="<%= settings_orders_path %>">Order</a>
</li>
</ol>
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="6">
<%= form_tag settings_orders_path, :method => :get do %>
<div class="input-append form-group pull-right">
<input type="text" name="filter" placeholder="Order ID" class="form-control input-sm col-md-8">
<button type="submit" class="btn btn-primary btn-sm">Search</button>
</div>
<% end %>
</td>
</tr>
<tr>
<th>Order ID </th>
<th>Type</th>
<th>Customer</th>
<th>Order status</th>
<th>Order date</th>
<th>Items Count</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% @orders.each do |order| %>
<tr>
<td><%= order.order_id %></td>
<td><%= order.order_type %></td>
<td><%= order.customer.name rescue '-' %></td>
<td><%= order.status %></td>
<td> <%= order.date.strftime("%d-%m-%Y") %> </td>
<td> <%= order.item_count %> </td>
<td><%= link_to 'Show', settings_order_path(order) %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @orders %>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,85 @@
<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="<%= settings_orders_path %>">Order</a>
</li>
<li class="active">
<a href="<%= settings_orders_path %>"><%= @order.order_id %></a>
</li>
</ol>
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Type</th>
<th>Customer</th>
<th>Order status</th>
<th>Order date</th>
<th>Order By</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @order.order_type %></td>
<td><%= @order.customer.name rescue '-' %></td>
<td><%= @order.status %></td>
<td> <%= @order.date.strftime("%d-%m-%Y") %> </td>
<td> <%= @order.waiter rescue '-' %> </td>
</tr>
</tbody>
</table>
<h3>Order Items</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Item Name</th>
<th>Qty</th>
<th> Unit Price</th>
<th>Total Price</th>
<th>Option</th>
<th>Status</th>
<th>Order By</th>
<th>Created at</th>
</tr>
</thead>
<tbody>
<% @order.order_items.each do |order| %>
<tr>
<td><%= order.item_name %></td>
<td><%= order.qty %></td>
<td><%= order.price %></td>
<td><%= order.qty * order.price %></td>
<td> <%= order.options %> </td>
<td> <%= order.order_item_status %> </td>
<td> <%= order.item_order_by %> </td>
<td> <%= order.created_at.strftime("%d-%m-%Y") %> </td>
</tr>
<% end %>
</tbody>
</table>
<a href="<%= settings_orders_path%>" class="btn btn-primary pull-left">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,85 @@
<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="<%= settings_sales_path %>">Sale</a>
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td colspan="8">
<%= form_tag settings_sales_path, :method => :get do %>
<div class="input-append form-group pull-right">
<input data-behaviour='datepicker' class="datepicker col-md-3 form-control" name="date" id="date" type="text" placeholder="Search by date" style="margin-right: 10px">
<input type="text" name="receipt_no" class="col-md-4 form-control" placeholder="Receipt No" style="margin-right: 10px">
<button type="submit" class="btn btn-primary btn">Search</button>
</div>
<% end %>
</td>
</tr>
<tr>
<th>Sale Id </th>
<th>Receipt no </th>
<th>Grand total</th>
<th>Tax amount</th>
<th>Cashier</th>
<th>Sales status</th>
<th>Receipt Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% @sales.each do |sale| %>
<tr>
<td><%= sale.sale_id %></td>
<td><%= sale.receipt_no %></td>
<td><%= sale.grand_total rescue '-' %></td>
<td><%= sale.total_tax %></td>
<td><%= sale.cashier_name rescue '-' %></td>
<td> <%= sale.sale_status %> </td>
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
<td><%= link_to 'Show', settings_sale_path(sale) %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @sales %>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
</script>

View File

@@ -0,0 +1,103 @@
<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="<%= settings_sales_path %>">Sale</a>
</li>
<li class="active">
<a href="<%= settings_sales_path %>"><%= @sale.sale_id %></a>
</li>
</ol>
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Receipt Date </th>
<th>Receipt no</th>
<th>Cashier</th>
<th>OSales status</th>
<th>Receipt generated at</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @sale.receipt_date.strftime("%d-%M-%Y") %></td>
<td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier rescue '-' %></td>
<td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td>
</tr>
<tr style="border-top:2px solid #000">
<th>Sale item name</th>
<th> Qty</th>
<th>Unit price</th>
<th>Total pirce </th>
<th>Created at</th>
</tr>
<% @sale.sale_items.each do |s| %>
<tr>
<td><%=s.product_name rescue ' '%></td>
<td><%=s.qty rescue ' '%></td>
<td><%= number_with_precision(s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%= number_with_precision(s.qty * s.price, :precision => 2, :delimiter => ',') rescue ' '%></td>
<td><%=l s.created_at.utc.getlocal , :format => :short rescue ' ' %></td>
</tr>
<% end %>
<tr style="border-top:2px solid #000">
<td colspan=2 style="text-align:center"></td>
<td>Total</td>
<td colspan="2"><%= number_with_precision(@sale.total_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Tax</td>
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Discount</td>
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Grand Total</td>
<td colspan="2"><%= number_with_precision(@sale.grand_total, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr><td>&nbsp;<td></tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
</tbody>
</table>
<a href="<%= settings_sales_path%>" class="btn btn-primary pull-left">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div>
</div>
</div>
</div>

View File

@@ -1,5 +1,5 @@
Kaminari.configure do |config|
# config.default_per_page = 25
config.default_per_page = 2
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0

View File

@@ -9,7 +9,7 @@ Rails.application.routes.draw do
mount Sidekiq::Web => '/kiq'
# Action Cable Creation
mount ActionCable.server => "/cable"
# mount ActionCable.server => "/cable"
#--------- SmartSales Installation ------------#
get 'install' => 'install#index'
@@ -72,7 +72,7 @@ Rails.application.routes.draw do
#--------- Cashier ------------#
namespace :origami do
root "home#index"
get "/:booking_id" => "home#show" do #origami/:booking_id will show
get "/:booking_id" => "home#index" do #origami/:booking_id will show
# resources :discounts, only: [:index,:new, :create ] #add discount type
resources :customers #add customer type
end
@@ -82,17 +82,19 @@ Rails.application.routes.draw do
get "/:id/discount" => "discounts#index"
post "/:id/discount" => "discounts#create"
get "/:id/request_bills" => "request_bills#print"
get "/:id/request_bills" => "request_bills#print"
#--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show'
post 'payment_process' => 'payments#create'
post 'paypar_payment_process' => 'paypar_payments#create'
post 'payment/cash' => 'payments#create'
post 'payment/paypar' => 'paypar_payments#create'
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
# get 'sale/:sale_id/payment/others_payment/:payment_method' => "redeem_payments#index"
get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index"
post 'create_mpu_payment' => "mpu#create"
post 'payment/mpu' => "mpu#create"
get 'sale/:sale_id/payment/others_payment/REDEEMREBATE' => "redeem_payments#index"
#---------Add Customer --------------#
@@ -100,7 +102,6 @@ Rails.application.routes.draw do
get '/:sale_id/add_customer', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer'
post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table
end
#--------- Waiter/Ordering Station ------------#
@@ -167,8 +168,10 @@ Rails.application.routes.draw do
resources :tax_profiles
#lookups
resources :lookups
#orders
#orders
resources :orders
#sales
resources :sales
#cashier_terminals
resources :cashier_terminals
#order_job_stations

View File

@@ -51,6 +51,10 @@ menu_item_type = Lookup.create([{lookup_type:'menu_item_type', name: 'SIMPLE', v
{lookup_type:'menu_item_type', name: 'Set Menu', value: 'setMenu'},
{lookup_type:'menu_item_type', name: 'DIY', value: 'diy'}])
member_group_type = Lookup.create([{lookup_type:'member_group_type', name: 'Platinum', value: '1'},
{lookup_type:'member_group_type', name: 'Silver', value: '2'}
])
#menu_item_attribute:[size|]
menu_item_attribute_type = Lookup.create([{lookup_type:'menu_item_attribute_type', name: 'Size', value: 'size'}])
# {lookup_type:'menu_item_attribute_type', name: 'Spicy', value: 'spicy'},
@@ -141,20 +145,24 @@ order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSu
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "192.168.1."})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})
member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1}},
{membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1}},
{membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer"},
{membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer"},
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1}},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data"}
member_actions= MembershipAction.create([{membership_type:"get_account_balance",gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"redeem",gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"create_membership_customer",gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS"},
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}
])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"REDEEMREBATE",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})
# shop = Shop.create(
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
# {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon",
# country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license",
# activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"}
# )

BIN
dump.rdb

Binary file not shown.

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Settings::OrdersController, type: :controller do
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Settings::OrdersHelper. For example:
#
# describe Settings::OrdersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Settings::OrdersHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe DiningQueue, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end