Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -59,6 +59,8 @@ gem 'sidekiq'
|
||||
# Pagination
|
||||
gem 'kaminari', '~> 0.16.3'
|
||||
|
||||
# Datatable
|
||||
gem 'filterrific'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
@@ -72,6 +72,7 @@ GEM
|
||||
faker (1.7.3)
|
||||
i18n (~> 0.5)
|
||||
ffi (1.9.18)
|
||||
filterrific (2.1.2)
|
||||
font-awesome-rails (4.7.0.2)
|
||||
railties (>= 3.2, < 5.2)
|
||||
globalid (0.4.0)
|
||||
@@ -238,6 +239,7 @@ DEPENDENCIES
|
||||
database_cleaner
|
||||
factory_girl_rails (~> 4.0)
|
||||
faker
|
||||
filterrific
|
||||
font-awesome-rails
|
||||
httparty (~> 0.15.5)
|
||||
jbuilder (~> 2.5)
|
||||
|
||||
17
app/assets/javascripts/CRM.js
Normal file
17
app/assets/javascripts/CRM.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require jquery
|
||||
//= require bootstrap
|
||||
//= require jquery_ujs
|
||||
//= require turbolinks
|
||||
//= require cable
|
||||
@@ -40,31 +40,36 @@ $(document).ready(function(){
|
||||
|
||||
// complete for queue item
|
||||
$('.order-complete').on('click',function(){
|
||||
var _self= $(this);
|
||||
var _self = $(this); // To know in ajax return
|
||||
var assigned_item_id=$(this).attr('id').substr(15);
|
||||
var params = { 'id':assigned_item_id };
|
||||
var station=$(this).parent().parent(".queue_station").parent().parent().attr('id');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/oqs/update_delivery',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
var queue_station=_self.parent().parent(".queue_station");
|
||||
success: function(data){
|
||||
for (i = 0; i < data.length; i++) {
|
||||
var queue_station = $('#assigned_queue_' + data[i]).parent().parent(".queue_station");
|
||||
var station = queue_station.parent().parent().attr('id');
|
||||
|
||||
// Remove a queue card from current station
|
||||
queue_station.remove();
|
||||
// Remove a queue card from current station
|
||||
queue_station.remove();
|
||||
|
||||
// Remove a queue card from current station
|
||||
queue_station.children('.card-footer').remove();
|
||||
|
||||
// Add removed queue card from station to completed
|
||||
$("#completed").children('.card-columns').append(queue_station);
|
||||
// Remove a queue card from current station
|
||||
queue_station.children('.card-footer').remove();
|
||||
|
||||
// Add removed queue card from station to completed
|
||||
$("#completed").children('.card-columns').append(queue_station);
|
||||
|
||||
// update queue item count in station
|
||||
$("#"+station+"_count").text(parseInt($("#"+station+"_count").text())-1);
|
||||
$("#completed_count").text(parseInt($("#completed_count").text())+1);
|
||||
// update queue item count in each station
|
||||
var station_count=parseInt($("#"+station+"_count").text()) - 1;
|
||||
$("#"+station+"_count").text(station_count);
|
||||
}
|
||||
|
||||
// update queue item count in completed station
|
||||
$("#completed_count").text(parseInt($("#completed_count").text()) + data.length);
|
||||
|
||||
alert("updated!");
|
||||
}
|
||||
|
||||
3
app/assets/javascripts/crm/dining_queues.coffee
Normal file
3
app/assets/javascripts/crm/dining_queues.coffee
Normal 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/
|
||||
@@ -17,10 +17,20 @@
|
||||
//= require cable
|
||||
|
||||
$(document).ready(function(){
|
||||
// Enable/Disable Button
|
||||
control_button("disabled");
|
||||
|
||||
$(".orders").on('click', function(){
|
||||
var zone_name=$(this).find(".orders-table").text();
|
||||
$("#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 unique_id = $(this).find(".orders-id").text();
|
||||
var order_status=$(this).find(".orders-order-status").text().trim();
|
||||
|
||||
// Enable/Disable Button
|
||||
@@ -33,6 +43,10 @@ $(document).ready(function(){
|
||||
$("#customer").attr('disabled','disabled');
|
||||
}
|
||||
|
||||
var customer_id=$(this).find(".customer-id").text();
|
||||
show_customer_details(customer_id);
|
||||
|
||||
|
||||
var cashier="";
|
||||
var receipt_date="";
|
||||
var sub_total=0;
|
||||
@@ -46,10 +60,16 @@ $(document).ready(function(){
|
||||
|
||||
// AJAX call for order
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "origami/" + unique_id,
|
||||
data: { 'id' : unique_id },
|
||||
success:function(result){
|
||||
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
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
var parse_data = JSON.parse(data);
|
||||
@@ -60,19 +80,20 @@ $(document).ready(function(){
|
||||
receipt_date = result[i].receipt_date;
|
||||
|
||||
$("#receipt_no").text(receipt_no);
|
||||
$("#cashier").text(cashier==null?"":cashier);
|
||||
$("#cashier").text(cashier == null ? "" : cashier);
|
||||
$("#receipt_date").text(receipt_date);
|
||||
|
||||
|
||||
//Receipt Charges
|
||||
sub_total += (parse_data.qty*parse_data.price);
|
||||
discount_amount = parse_data.discount_amount;
|
||||
|
||||
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;
|
||||
|
||||
$("#order-sub-total").text(sub_total);
|
||||
$("#order-food").text('');
|
||||
$("#order-beverage").text('');
|
||||
// $("#order-food").text('');
|
||||
// $("#order-beverage").text('');
|
||||
$("#order-discount").text(discount_amount);
|
||||
$("#order-Tax").text(tax_amount);
|
||||
$("#order-grand-total").text(grand_total_amount);
|
||||
@@ -98,7 +119,7 @@ $(document).ready(function(){
|
||||
$('#request_bills').click(function() {
|
||||
var order_id=$(".selected-item").find(".orders-id").text();
|
||||
if(order_id!=""){
|
||||
window.location.href = '/origami/request_bills/'+ order_id
|
||||
window.location.href = '/origami/' + order_id + '/request_bills'
|
||||
}
|
||||
else {
|
||||
alert("Please select an order!");
|
||||
@@ -110,7 +131,7 @@ $(document).ready(function(){
|
||||
$('#discount').click(function() {
|
||||
var order_id=$(".selected-item").find(".orders-id").text();
|
||||
if(order_id!=""){
|
||||
window.location.href = '/origami/discount/'+ order_id
|
||||
window.location.href = '/origami/' + order_id + '/discount'
|
||||
}
|
||||
else {
|
||||
alert("Please select an order!");
|
||||
@@ -122,26 +143,33 @@ $(document).ready(function(){
|
||||
// Pay Discount for Payment
|
||||
$("#pay-discount").on('click', function(){
|
||||
var sale_id = $('#sale-id').text();
|
||||
var sale_item_id = $('.selected-item').attr('id');
|
||||
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;
|
||||
|
||||
if(sale_item_id == null){
|
||||
alert('Please select item row to discount!');
|
||||
return;
|
||||
}
|
||||
|
||||
// For Percentage Discount
|
||||
if(discount_type == 1){
|
||||
discount_amount=(sub_total*discount_value)/100;
|
||||
}
|
||||
|
||||
var params = {'sale_id': sale_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
|
||||
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: "/origami/discount",
|
||||
url: "/origami/" + sale_item_id + "/discount",
|
||||
data: params,
|
||||
success:function(result){ }
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Payment for Bill
|
||||
$('#pay-bill').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||
@@ -157,10 +185,27 @@ $(document).ready(function(){
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
|
||||
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
|
||||
}
|
||||
|
||||
/* For Receipt - Calculate discount or tax */
|
||||
$('.cashier_number').on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
@@ -184,8 +229,9 @@ $(document).ready(function(){
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value) + parseInt(original_value);
|
||||
amount = parseInt(input_value);
|
||||
$('#discount-amount').val(amount);
|
||||
$('#discount-type').val(1);
|
||||
update_balance();
|
||||
break;
|
||||
|
||||
@@ -207,6 +253,11 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
|
||||
$('.discount-item-row').on('click',function(){
|
||||
$('.discount-item-row').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* Button Control by Status */
|
||||
@@ -221,6 +272,11 @@ function control_button(order_status){
|
||||
$("#discount").prop('disabled', true);
|
||||
$("#pay-bill").prop('disabled', true);
|
||||
}
|
||||
else {
|
||||
$("#request_bills").prop('disabled', true);
|
||||
$("#discount").prop('disabled', true);
|
||||
$("#pay-bill").prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
/* For Receipt - Update Balance */
|
||||
|
||||
@@ -7,3 +7,5 @@
|
||||
// min-height: 75rem;
|
||||
// padding-top: 4.5rem;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
.cashier_number{
|
||||
width: 30%;
|
||||
height:71px;
|
||||
line-height:71px;
|
||||
.orders-table {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cashier_number{
|
||||
width: 33%;
|
||||
height:70px;
|
||||
line-height:70px;
|
||||
text-align:center;
|
||||
background:#54A5AF;
|
||||
// float:left;
|
||||
@@ -32,8 +35,8 @@
|
||||
|
||||
.pay{
|
||||
width: 98%;
|
||||
height:210px;
|
||||
line-height:210px;
|
||||
height:211px;
|
||||
line-height:211px;
|
||||
text-align:center;
|
||||
font-size:20px;
|
||||
color:white;
|
||||
@@ -44,15 +47,20 @@
|
||||
}
|
||||
|
||||
.long{
|
||||
width:49%
|
||||
width:49%;
|
||||
}
|
||||
|
||||
.sold {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.paid {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.selected-item {
|
||||
background-color: blue;
|
||||
color: #fff !important;
|
||||
background-color: blue !important;
|
||||
}
|
||||
|
||||
/* Reciept Style */
|
||||
@@ -101,3 +109,17 @@
|
||||
select.form-control {
|
||||
height: inherit !important;
|
||||
}
|
||||
|
||||
.form-horizontal .form-group {
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
|
||||
/* Discount */
|
||||
|
||||
.discount-item-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
tr.discount-item-row:hover {
|
||||
background-color: #e3e3e3 !important;
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ class Api::CustomersController < ActionController::API
|
||||
def show
|
||||
@customer = Customer.find_by(params[:id])
|
||||
end
|
||||
|
||||
#Show customer detail by Order item
|
||||
def get_customer_order
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
8
app/controllers/base_report_controller.rb
Normal file
8
app/controllers/base_report_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class Crm::BookingsController < ApplicationController
|
||||
class Crm::BookingsController < BaseCrmController
|
||||
|
||||
def update_booking
|
||||
booking = Booking.find(params[:booking_id])
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
class Crm::CustomersController < ApplicationController
|
||||
class Crm::CustomersController < BaseCrmController
|
||||
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /crm/customers
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
@sale_id = 0
|
||||
@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group
|
||||
if @membership["status"] == true
|
||||
@member_group = @membership["data"]
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@crm_customer.valid?
|
||||
|
||||
|
||||
# @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 }
|
||||
@@ -41,8 +51,6 @@ class Crm::CustomersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
|
||||
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -63,40 +71,37 @@ class Crm::CustomersController < ApplicationController
|
||||
}
|
||||
)
|
||||
|
||||
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] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
|
||||
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/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' }
|
||||
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] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
|
||||
if params[:sale_id].nil?
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
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] != 0
|
||||
format.html { redirect_to crm_customers_path}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
end
|
||||
|
||||
|
||||
if params[:sale_id].nil?
|
||||
|
||||
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
|
||||
@@ -133,7 +138,7 @@ class Crm::CustomersController < ApplicationController
|
||||
|
||||
else
|
||||
|
||||
format.html { render :edit }
|
||||
format.html { render :index }
|
||||
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
||||
@@ -153,7 +158,6 @@ class Crm::CustomersController < ApplicationController
|
||||
# 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
|
||||
@@ -176,6 +180,6 @@ class Crm::CustomersController < ApplicationController
|
||||
# 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, :membership_type, :membership_authentication_code)
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
|
||||
end
|
||||
end
|
||||
|
||||
74
app/controllers/crm/dining_queues_controller.rb
Normal file
74
app/controllers/crm/dining_queues_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Crm::DiningQueuesController < BaseCrmController
|
||||
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /crm/dining_queues
|
||||
# GET /crm/dining_queues.json
|
||||
def index
|
||||
@dining_queues = DiningQueue.all
|
||||
end
|
||||
|
||||
# GET /crm/dining_queues/1
|
||||
# GET /crm/dining_queues/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /crm/dining_queues/new
|
||||
def new
|
||||
@dining_queue = DiningQueue.new
|
||||
end
|
||||
|
||||
# GET /crm/dining_queues/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /crm/dining_queues
|
||||
# POST /crm/dining_queues.json
|
||||
def create
|
||||
@dining_queue = DiningQueue.new(dining_queue_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @dining_queue.save
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @dining_queue }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /crm/dining_queues/1
|
||||
# PATCH/PUT /crm/dining_queues/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @dining_queue.update(dining_queue_params)
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @dining_queue }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /crm/dining_queues/1
|
||||
# DELETE /crm/dining_queues/1.json
|
||||
def destroy
|
||||
@dining_queue.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_queue
|
||||
@dining_queue = DiningQueue.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:name, :contact_no, :queue_no)
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,13 @@
|
||||
class Crm::HomeController < BaseCrmController
|
||||
def index
|
||||
|
||||
@booking = Booking.all
|
||||
@booking = Booking.all
|
||||
@customer = Customer.all
|
||||
from = Time.now.beginning_of_day.utc
|
||||
to = Time.now.end_of_day.utc
|
||||
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
|
||||
|
||||
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -27,10 +27,18 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
# update delivery status when complete click
|
||||
def update_delivery_status
|
||||
removed_item = []
|
||||
assigned_item_id = params[:id]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_item.delivery_status=true
|
||||
assigned_item.save
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# update delivery status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.delivery_status=true
|
||||
ai.save
|
||||
removed_item.push(ai.assigned_order_item_id)
|
||||
end
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
# Query for OQS with status
|
||||
|
||||
@@ -1,31 +1,39 @@
|
||||
class Oqs::PrintController < ApplicationController
|
||||
# Print Order Item
|
||||
def print
|
||||
unique_code="OrderItemPdf"
|
||||
assigned_item_id=params[:id]
|
||||
assigned_order_item=AssignedOrderItem.select("order_id, item_code").where("assigned_order_item_id='" + assigned_item_id + "'")
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# print when complete click
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings,assigned_order_item[0].order_id, assigned_order_item[0].item_code )
|
||||
|
||||
# update print status when complete click
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_item.print_status=true
|
||||
assigned_item.save
|
||||
order_queue_printer.print_order_item(print_settings,assigned_item.order_id, assigned_item.item_code )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
|
||||
# Print Order Details
|
||||
def print_order_summary
|
||||
unique_code="OrderSummaryPdf"
|
||||
assigned_item_id=params[:id]
|
||||
assigned_order_item=AssignedOrderItem.select("order_id").where('assigned_order_item_id='+assigned_item_id)
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# print when complete click
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_summary(print_settings,assigned_order_item[0].order_id)
|
||||
order_queue_printer.print_order_summary(print_settings,assigned_item.order_id)
|
||||
|
||||
# update print status when complete click
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_item.print_status=true
|
||||
assigned_item.save
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,38 @@
|
||||
class Origami::CustomersController < BaseOrigamiController
|
||||
#Form to add customer -
|
||||
def index
|
||||
|
||||
|
||||
end
|
||||
def create
|
||||
|
||||
# GET /crm/customers/1
|
||||
# GET /crm/customers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
|
||||
|
||||
def add_customer
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("name").page(params[:page])
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
@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 :template => "crm/customers/index" }
|
||||
format.html { render action: "index"}
|
||||
format.json { render json: @crm_customers }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def index
|
||||
sale_id = params[:id]
|
||||
sale_id = params[:id]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
end
|
||||
@@ -11,30 +11,32 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#discount for selected order
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
sale_item_id = params[:sale_item_id]
|
||||
discount_type = params[:discount_type]
|
||||
discount_value = params[:discount_value]
|
||||
discount_amount = params[:discount_amount]
|
||||
grand_total = params[:grand_total]
|
||||
discount_value = params[:discount_value]
|
||||
discount_amount = params[:discount_amount]
|
||||
grand_total = params[:grand_total]
|
||||
|
||||
if discount_type == 0
|
||||
remark="Discount " + discount_amount + " as net"
|
||||
else
|
||||
remark="Discount " + discount_amount + " as percentage"
|
||||
end
|
||||
if discount_type == 0
|
||||
remark="Discount " + discount_amount + " as net"
|
||||
else
|
||||
remark="Discount " + discount_amount + " as percentage"
|
||||
end
|
||||
|
||||
#update discount for sale
|
||||
sale = Sale.find(sale_id)
|
||||
sale.total_discount = discount_amount
|
||||
sale.grand_total = grand_total
|
||||
sale.save
|
||||
#update discount for sale
|
||||
sale = Sale.find(sale_id)
|
||||
sale.total_discount = sale.total_discount + discount_amount.to_f
|
||||
sale.grand_total = grand_total
|
||||
sale.save
|
||||
|
||||
#save sale item for discount
|
||||
origin_sale_item = SaleItem.find(sale_item_id)
|
||||
sale_item = SaleItem.new
|
||||
|
||||
#pull
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = 0
|
||||
sale_item.product_name = "Discount"
|
||||
sale_item.product_code = origin_sale_item.product_code
|
||||
sale_item.product_name = origin_sale_item.product_name + " Discount"
|
||||
sale_item.remark = remark
|
||||
|
||||
sale_item.qty = 1
|
||||
@@ -45,7 +47,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_item.price = sale_item.qty * sale_item.unit_price
|
||||
sale_item.save
|
||||
|
||||
redirect_to origami_root_path
|
||||
redirect_to origami_path(sale_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,28 +1,67 @@
|
||||
class Origami::HomeController < BaseOrigamiController
|
||||
def index
|
||||
if params[:booking_id] != nil
|
||||
type=params[:booking_id].split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
@selected_item = Sale.find(params[:booking_id])
|
||||
@selected_item_type="Sale"
|
||||
# Booking
|
||||
else
|
||||
@selected_item = Order.find(params[:booking_id])
|
||||
@selected_item_type="Order"
|
||||
end
|
||||
end
|
||||
|
||||
@completed_orders = Order.get_completed_order()
|
||||
@booking_orders = Order.get_booking_order_table()
|
||||
@booking_rooms = Order.get_booking_order_rooms()
|
||||
@orders = Order.get_orders()
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
str = []
|
||||
type=params[:id].split('-')[0];
|
||||
def item_show
|
||||
selection(params[:booking_id],1)
|
||||
end
|
||||
|
||||
def selection(selected_id, is_ajax)
|
||||
str = []
|
||||
type=selected_id.split('-')[0];
|
||||
# Sale
|
||||
if type == "SAL"
|
||||
@order_details = SaleItem.get_order_items_details(params[:id])
|
||||
@order_details = SaleItem.get_order_items_details(params[:booking_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
end
|
||||
render :json => str.to_json
|
||||
# Booking
|
||||
else
|
||||
@order_details = OrderItem.get_order_items_details(params[:id])
|
||||
@order_details = OrderItem.get_order_items_details(params[:booking_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
end
|
||||
render :json => str.to_json
|
||||
end
|
||||
end
|
||||
if is_ajax == 1
|
||||
render :json => str.to_json
|
||||
else
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: params[:customer_id])
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def get_customer
|
||||
@customer = Customer.find(params[:customer_id])
|
||||
|
||||
render :json => @customer.to_json
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,17 +14,23 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||
end
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer_name = Customer.select("name").where('customer_id=' + @sale_data.customer_id)
|
||||
customer= Customer.where('customer_id=' + @sale_data.customer_id)
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# find order id by sale id
|
||||
sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||
|
||||
# Calculate Food and Beverage Total
|
||||
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)
|
||||
redirect_to origami_root_path
|
||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
|
||||
redirect_to origami_path(sale_order.sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
9
app/controllers/reports/receipt_no_controller.rb
Normal file
9
app/controllers/reports/receipt_no_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Reports::ReceiptNoController < BaseReportController
|
||||
def index
|
||||
@hi = "hi"
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
end
|
||||
2
app/helpers/crm/dining_queues_helper.rb
Normal file
2
app/helpers/crm/dining_queues_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Crm::DiningQueuesHelper
|
||||
end
|
||||
5
app/models/crm.rb
Normal file
5
app/models/crm.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Crm
|
||||
def self.table_name_prefix
|
||||
'crm_'
|
||||
end
|
||||
end
|
||||
@@ -9,7 +9,8 @@ class Customer < ApplicationRecord
|
||||
validates_presence_of :name, :contact_no, :email
|
||||
validates :contact_no, uniqueness: true
|
||||
validates :email, uniqueness: true
|
||||
|
||||
|
||||
paginates_per 50
|
||||
|
||||
def self.get_member_group
|
||||
|
||||
@@ -31,6 +32,14 @@ class Customer < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
end
|
||||
|
||||
def lastest_invoices
|
||||
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
3
app/models/dining_queue.rb
Normal file
3
app/models/dining_queue.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class DiningQueue < ApplicationRecord
|
||||
|
||||
end
|
||||
@@ -28,11 +28,13 @@ class Order < ApplicationRecord
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
booking.save!
|
||||
@@ -220,13 +222,41 @@ class Order < ApplicationRecord
|
||||
.group("orders.order_id, order_items.order_items_id,dining_facilities.name")
|
||||
end
|
||||
|
||||
#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,
|
||||
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 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")
|
||||
|
||||
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")
|
||||
.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 sales on sales.sale_id = bookings.sale_id")
|
||||
|
||||
.where("sales.sale_status='completed'")
|
||||
.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
|
||||
def self.get_booking_order_table
|
||||
booking_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")
|
||||
.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")
|
||||
@@ -235,15 +265,17 @@ class Order < ApplicationRecord
|
||||
|
||||
#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,
|
||||
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,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<>'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
|
||||
@@ -264,15 +296,15 @@ 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,
|
||||
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
|
||||
orders.customer_id as 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("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<>'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,orders.customer_id")
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||
.where("orders.order_id='" + code.to_s + "'")
|
||||
.where("orders.order_id='" + code + "'")
|
||||
.group("order_items.item_code")
|
||||
end
|
||||
|
||||
|
||||
@@ -63,12 +63,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
self.print(filename)
|
||||
end
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name)
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total)
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
end
|
||||
|
||||
@@ -29,6 +29,32 @@ class SaleItem < ApplicationRecord
|
||||
# return false
|
||||
# end
|
||||
end
|
||||
|
||||
def self.calculate_food_beverage(sale_items)
|
||||
food_prices=0
|
||||
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
|
||||
end
|
||||
return food_prices, beverage_prices
|
||||
end
|
||||
|
||||
def self.get_food_price(sale_item_id)
|
||||
food_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=0", sale_item_id)
|
||||
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
|
||||
|
||||
@@ -106,7 +106,6 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
@@ -204,30 +203,28 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
puts "sale update"
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
|
||||
self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f
|
||||
|
||||
all_received_amount = 0.0
|
||||
sObj = self.sale
|
||||
sObj = Sale.find(self.sale_id)
|
||||
sObj.sale_payments.each do |spay|
|
||||
puts spay
|
||||
puts spay.payment_amount
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
end
|
||||
puts all_received_amount
|
||||
puts self.sale.grand_total
|
||||
if (self.sale.grand_total <= all_received_amount)
|
||||
puts " sale update ......"
|
||||
self.sale.payment_status = "paid"
|
||||
self.sale.sale_status = "completed"
|
||||
self.sale.save!
|
||||
#TODO: table status
|
||||
rebat()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def rebat
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class CrmOrderPdf < Prawn::Document
|
||||
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
||||
def initialize(booking,order_items,print_settings)
|
||||
def initialize(booking,order_items,printer_settings)
|
||||
self.p_width = 200
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
@@ -18,20 +18,19 @@ class CrmOrderPdf < Prawn::Document
|
||||
@half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
|
||||
self.header_font_size = 7
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 9
|
||||
|
||||
header( booking.type, booking.dining_facility.name)
|
||||
header( printer_settings.printer_name, printer_settings.name)
|
||||
stroke_horizontal_rule
|
||||
order_detail(booking.checkin_by,booking.checkin_at,booking.dining_facility.name)
|
||||
cashier_info(booking)
|
||||
line_items(order_items)
|
||||
#all_total(order_items)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def header (type, name)
|
||||
text "#{type}", :size => self.header_font_size,:align => :center
|
||||
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
|
||||
@@ -41,37 +40,37 @@ class CrmOrderPdf < Prawn::Document
|
||||
|
||||
end
|
||||
|
||||
def order_detail(order_by,order_at,customer)
|
||||
def cashier_info(booking)
|
||||
move_down 5
|
||||
move_down 2
|
||||
y_position = cursor
|
||||
qty_column_width = self.p_width * 0.2
|
||||
item_description_width = self.p_width * 0.5
|
||||
price_column_width = self.p_width * 0.3
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
text "Order By:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
|
||||
text "#{booking.checkin_by}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Order By", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "Order At", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Customer", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
text "Customer:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
text "#{booking.customer_id}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
|
||||
text_box "#{order_by}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{order_at.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{customer}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
text "#{booking.checkin_at.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
# stroke_horizontal_rule
|
||||
move_down 5
|
||||
end
|
||||
|
||||
def line_items(order_items)
|
||||
@@ -97,10 +96,41 @@ y_position = cursor
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
|
||||
|
||||
add_line_item_row(order_items)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def add_line_item_row(order_items)
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
sub_total = 0.0
|
||||
order_items.each do |item|
|
||||
|
||||
sub_total += item.qty*item.price
|
||||
qty = item.qty
|
||||
total_price = item.qty*item.price
|
||||
price = item.price
|
||||
item_name = item.item_name
|
||||
|
||||
|
||||
y_position = cursor
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "#{item_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
|
||||
}
|
||||
move_down 3
|
||||
end
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,29 +1,46 @@
|
||||
class OrderItemPdf < 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,:item_description_width
|
||||
def initialize(order_item, print_settings)
|
||||
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
self.page_width = 300
|
||||
self.page_height = 400
|
||||
self.margin = 10
|
||||
self.price_width = 50
|
||||
self.qty_width = 50
|
||||
self.item_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.receipt_width=130
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
font_size 9
|
||||
text "#{order_item.dining}", :size => 15
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
text "#{order_item.dining}", :size => self.header_font_size,:align => :center
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
#order_info
|
||||
order_info(order_item.order_by,order_item.order_at, order_item.customer)
|
||||
order_info(order_item.order_by,order_item.order_at)
|
||||
|
||||
# order items
|
||||
order_items(order_item)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_by, order_at, customer)
|
||||
def order_info(order_by, order_at)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 200, :height => 15) do
|
||||
text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width - 50, :height => self.item_height) do
|
||||
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 50,y_position], :width => self.item_width + 50, :height => self.item_height) do
|
||||
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -35,12 +52,12 @@ class OrderItemPdf < Prawn::Document
|
||||
def order_items(order_item)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 15) do
|
||||
text "Item", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Item", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 15) do
|
||||
text "Qty", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "Qty", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -56,12 +73,12 @@ class OrderItemPdf < Prawn::Document
|
||||
|
||||
move_down 5
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 20) do
|
||||
text "#{order_item.item_name}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "#{order_item.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 20) do
|
||||
text "#{order_item.qty}", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "#{order_item.qty}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
class OrderSummaryPdf < 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,:item_description_width
|
||||
def initialize(order, print_settings)
|
||||
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
self.page_width = 300
|
||||
self.page_height = 400
|
||||
self.margin = 10
|
||||
self.price_width = 60
|
||||
self.qty_width = 60
|
||||
self.item_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width)
|
||||
self.receipt_width=130
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# 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
|
||||
|
||||
font_size 9
|
||||
text "#{order[0].dining}", :size => 15
|
||||
text "#{order[0].dining}", :size => self.header_font_size,:align => :center
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
#order_info
|
||||
order_info(order[0].order_by,order[0].order_at, order[0].customer)
|
||||
order_info(order[0].order_by,order[0].order_at)
|
||||
|
||||
# order items
|
||||
order_items(order)
|
||||
@@ -21,11 +32,15 @@ class OrderSummaryPdf < Prawn::Document
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_by, order_at, customer)
|
||||
def order_info(order_by, order_at)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 200, :height => 15) do
|
||||
text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width - 20, :height => self.item_height) do
|
||||
text "OrderBy:#{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width - 20,y_position], :width => self.item_width + 20, :height => self.item_height) do
|
||||
text "Date:#{order_at.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -37,12 +52,12 @@ class OrderSummaryPdf < Prawn::Document
|
||||
def order_items(order_item)
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => 180, :height => 15) do
|
||||
text "Item", :size => 7,:align => :left
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Item", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 15) do
|
||||
text "Qty", :size => 7,:align => :right
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "Qty", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
@@ -59,13 +74,13 @@ class OrderSummaryPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
order_item.each do|odi|
|
||||
bounding_box([0,y_position], :width => 180, :height => 20) do
|
||||
text "#{odi.item_name}", :size => 7,:align => :left
|
||||
end
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 20) do
|
||||
text "#{odi.qty}", :size => 7,:align => :right
|
||||
end
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "#{odi.qty}", :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
class ReceiptBillPdf < Prawn::Document
|
||||
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name)
|
||||
self.p_width = 200
|
||||
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
|
||||
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total)
|
||||
self.page_width = 300
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
# self.price_width = self.p_width / 2
|
||||
self.price_width=80
|
||||
self.item_width = self.p_width - self.price_width
|
||||
self.item_height = self.item_height
|
||||
self.qty_column_width = self.p_width / 2
|
||||
self.item_description_width=self.p_width - self.price_width
|
||||
self.receipt_width=130
|
||||
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.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.receipt_width=100
|
||||
|
||||
@item_width = self.p_width.to_i / 2
|
||||
@qty_width = @item_width.to_i / 3
|
||||
@double = @qty_width * 1.3
|
||||
@half_qty = @qty_width / 2
|
||||
# @item_width = self.page_width.to_i / 2
|
||||
# @qty_width = @item_width.to_i / 3
|
||||
# @double = @qty_width * 1.3
|
||||
# @half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
|
||||
self.header_font_size = 10
|
||||
self.item_font_size = 9
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# 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
|
||||
|
||||
header( printer_settings.printer_name, printer_settings.name)
|
||||
stroke_horizontal_rule
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
cashier_info(sale_data, customer_name)
|
||||
line_items(sale_items)
|
||||
line_items(sale_items, food_total, beverage_total)
|
||||
all_total(sale_data)
|
||||
|
||||
|
||||
@@ -38,71 +44,66 @@ class ReceiptBillPdf < Prawn::Document
|
||||
move_down 5
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
end
|
||||
|
||||
def cashier_info(sale_data, customer_name)
|
||||
move_down 5
|
||||
move_down 2
|
||||
move_down 7
|
||||
# move_down 2
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Receipt No:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
|
||||
text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left
|
||||
bounding_box([self.receipt_width, y_position], :width =>self.receipt_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.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Customer:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([self.receipt_width,y_position], :width =>self.receipt_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.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>self.receipt_width, :height => self.item_height) do
|
||||
text "Date:", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
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
|
||||
end
|
||||
# stroke_horizontal_rule
|
||||
move_down 5
|
||||
end
|
||||
|
||||
def line_items(sale_items)
|
||||
def line_items(sale_items, food_total, beverage_total)
|
||||
y_position = cursor
|
||||
qty_column_width = self.p_width * 0.2
|
||||
item_description_width = self.p_width * 0.5
|
||||
price_column_width = self.p_width * 0.3
|
||||
|
||||
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "Items", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "Price", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Qty", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "Total", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
|
||||
add_line_item_row(sale_items)
|
||||
add_line_item_row(sale_items, food_total, beverage_total)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def add_line_item_row(sale_items)
|
||||
def add_line_item_row(sale_items, food_total, beverage_total)
|
||||
item_name_width = self.item_width-20
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
sub_total = 0.0
|
||||
@@ -119,53 +120,67 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
pad_top(15) {
|
||||
# @item_width.to_i + @half_qty.to_i
|
||||
text_box "#{product_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
|
||||
text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
|
||||
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
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Sub Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
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
|
||||
end
|
||||
|
||||
# Food and Beverage
|
||||
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
|
||||
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
|
||||
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
|
||||
move_down 5
|
||||
y_position =cursor
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Discount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_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
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_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 =>self.price_width, :height => self.item_height) do
|
||||
bounding_box([0,y_position], :width =>(item_name_width+self.price_width+self.qty_width), :height => self.item_height) do
|
||||
text "Grand Total", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.price_width,y_position], :width =>self.price_width) do
|
||||
bounding_box([(item_name_width+self.price_width+self.qty_width),y_position], :width =>self.total_width) do
|
||||
text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
move_down 5
|
||||
|
||||
38
app/views/api/customers/get_customer_order.json.jbuilder
Normal file
38
app/views/api/customers/get_customer_order.json.jbuilder
Normal file
@@ -0,0 +1,38 @@
|
||||
if (@customer)
|
||||
json.id @customer.customer_id
|
||||
json.name @customer.name
|
||||
json.email @customer.email
|
||||
json.contact_no @customer.contact_no
|
||||
json.date_of_birth @customer.date_of_birth
|
||||
|
||||
|
||||
@total_amount = 0.00
|
||||
@total_tax = 0.00
|
||||
|
||||
if @customer.orders
|
||||
order_items = []
|
||||
@customer.orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
#if (order.status == "new")
|
||||
order_items = order_items + order.order_items
|
||||
#end
|
||||
end
|
||||
|
||||
json.order_items order_items do |item|
|
||||
json.item_instance_code item.item_code
|
||||
json.item_name item.item_name
|
||||
json.price item.price
|
||||
json.qty item.qty
|
||||
json.options item.options
|
||||
json.remark item.remark
|
||||
json.item_status item.order_item_status
|
||||
@total_amount = @total_amount + (item.price * item.qty)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
json.sub_total @total_amount
|
||||
json.commerical_tax @total_amount * 0.05
|
||||
json.total @total_amount + (@total_amount * 0.05)
|
||||
|
||||
end
|
||||
@@ -16,5 +16,5 @@
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- -->
|
||||
<!---->
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
@@ -21,6 +21,17 @@
|
||||
<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>
|
||||
@@ -48,66 +59,63 @@
|
||||
<% 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.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :name, :class => "form-control col-md-6 name" %>
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
|
||||
</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" %>
|
||||
<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>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :email, :class => "form-control col-md-6 email" %>
|
||||
</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 datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<%= 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">
|
||||
<!-- <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>
|
||||
<%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) {
|
||||
@@ -124,11 +132,11 @@
|
||||
$(document).on('click',".checkbox_check",function(){
|
||||
if(this.checked){
|
||||
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var sale_id = $("#sale_id").val() || 0;
|
||||
var customer_id = $(this).val();
|
||||
|
||||
if(sale_id != 0){
|
||||
var url = "../"+customer_id;
|
||||
// var url = "/"+customer_id;
|
||||
update_sale(customer_id,sale_id);
|
||||
}else{
|
||||
|
||||
@@ -185,7 +193,7 @@
|
||||
action: function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../../update_sale/" ,
|
||||
url: "update_sale/" ,
|
||||
data: {customer_id:customer_id,sale_id:sale_id},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
@@ -207,23 +215,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*function changeMethod() {
|
||||
$("#update_customer").attr('method', 'put');
|
||||
}*/
|
||||
|
||||
|
||||
/* $("#update_customer").click(function() {
|
||||
$("#new_customer").attr('class', 'edit_customer');
|
||||
var id = "edit_customer_"+$('#customer_id').val();alert(id);
|
||||
$("#new_customer").attr('id', id);
|
||||
alert(";;")
|
||||
//$('#new_customer').removeClass('new_customer');
|
||||
//$('#new_customer').addClass('edit_customer')
|
||||
}); */
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
json.extract! crm_dining_queue, :id, :name, :contact, :queue_no, :created_at, :updated_at
|
||||
json.url crm_dining_queue_url(crm_dining_queue, format: :json)
|
||||
16
app/views/crm/dining_queues/_form.html.erb
Normal file
16
app/views/crm/dining_queues/_form.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
<%= simple_form_for([:crm,@dining_queue]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.input :contact_no %>
|
||||
<%= f.input :queue_no %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
11
app/views/crm/dining_queues/edit.html.erb
Normal file
11
app/views/crm/dining_queues/edit.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
<div class="span12">
|
||||
<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>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', dining_queue: @dining_queue %>
|
||||
</div>
|
||||
38
app/views/crm/dining_queues/index.html.erb
Normal file
38
app/views/crm/dining_queues/index.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:25%">Name</th>
|
||||
<th style="width:25%">Contact No</th>
|
||||
<th style="width:25%">Queue No</th>
|
||||
<th style="width:25%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @dining_queues.each do |dining_queue| %>
|
||||
<tr>
|
||||
<td><%= dining_queue.name %></td>
|
||||
<td><%= dining_queue.contact_no %></td>
|
||||
<td><%= dining_queue.queue_no %></td>
|
||||
<td>
|
||||
<%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
1
app/views/crm/dining_queues/index.json.jbuilder
Normal file
1
app/views/crm/dining_queues/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue
|
||||
11
app/views/crm/dining_queues/new.html.erb
Normal file
11
app/views/crm/dining_queues/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
<div class="span12">
|
||||
<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>
|
||||
<%= render 'form', dining_queue: @dining_queue %>
|
||||
</div>
|
||||
19
app/views/crm/dining_queues/show.html.erb
Normal file
19
app/views/crm/dining_queues/show.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @crm_dining_queue.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Contact:</strong>
|
||||
<%= @crm_dining_queue.contact %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Queue no:</strong>
|
||||
<%= @crm_dining_queue.queue_no %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_crm_dining_queue_path(@crm_dining_queue) %> |
|
||||
<%= link_to 'Back', crm_dining_queues_path %>
|
||||
1
app/views/crm/dining_queues/show.json.jbuilder
Normal file
1
app/views/crm/dining_queues/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue
|
||||
@@ -6,29 +6,29 @@
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "new" %>
|
||||
<div class="card">
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
</h4>
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
</h4>
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -38,67 +38,95 @@
|
||||
$(function(){
|
||||
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
|
||||
var booking_id = $(this).find(".booking-id").text();
|
||||
$("#crm_print").val(booking_id);
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
var booking_id = $(this).find(".booking-id").text();
|
||||
$("#crm_print").val(booking_id);
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
|
||||
});
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
|
||||
}); //End Booking Click
|
||||
|
||||
$('.nav-link').click(function () {
|
||||
var href = $(this).attr('href');
|
||||
if(href== "#customer" || href == "#queue"){
|
||||
$("#cancel").attr("disabled","disabled");
|
||||
$("#assign").attr("disabled","disabled");
|
||||
}
|
||||
});
|
||||
//End nav-liik
|
||||
|
||||
$('.crm_print').click(function() {
|
||||
var booking_id = $('#crm_print').val();
|
||||
var booking_id = $('#crm_print').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+booking_id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+booking_id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
//End Print Click
|
||||
|
||||
$('.assign').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
var booking_id = $(this).val();
|
||||
var type = $(this).attr("data-type");
|
||||
alert(booking_id);
|
||||
|
||||
update_booking(booking_id,type)
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
//End Assing Click
|
||||
|
||||
$('.cancel').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
|
||||
update_booking(booking_id,type)
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
//End cancle Click
|
||||
|
||||
|
||||
$(".customer_detail").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
var id = $(this).attr('data-ref');
|
||||
$('.customer_detail').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
customer_details(id);
|
||||
|
||||
});
|
||||
//end customer click
|
||||
|
||||
|
||||
});
|
||||
|
||||
function show_details(url_item){
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
//console.log(item_data.length);
|
||||
|
||||
|
||||
$("#table").text(data.table_name)
|
||||
$("#order_at").text(data.checkin_at)
|
||||
$("#order_by").text(data.checkin_by)
|
||||
$("#assign").val(data.id)
|
||||
$("#cancel").val(data.id)
|
||||
$('.no_record').addClass('hide');
|
||||
|
||||
for(var field in item_data) {
|
||||
if (item_data[field].item_name){
|
||||
if (item_data[field].item_name){
|
||||
var price = parseFloat(item_data[field].price).toFixed(2);
|
||||
|
||||
row = "<tr>"
|
||||
@@ -106,32 +134,82 @@ function show_details(url_item){
|
||||
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
|
||||
+'<td style="width:33%; text-align:right">' + price + '</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
$('.booking_click').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
|
||||
function customer_details(id){
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/customers/get_order/"+id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
|
||||
$("#for-booking").remove();
|
||||
var div_data = "<strong>CUSTOMER DETAILS</strong>";
|
||||
$("#order-title").replaceWith(div_data);
|
||||
$('.no_record').addClass('hide');
|
||||
$('.customer-detail').removeClass('hide') ;
|
||||
|
||||
$("#cus_name").text(data.name)
|
||||
$("#cus_email").text(data.email)
|
||||
$("#cus_contact_no").text(data.contact_no)
|
||||
|
||||
|
||||
if(item_data.length>0){
|
||||
for(var field in item_data) {
|
||||
if (item_data[field].item_name){
|
||||
var price = parseFloat(item_data[field].price).toFixed(2);
|
||||
|
||||
row = "<tr>"
|
||||
+'<td style="width:33%; text-align:left">' + item_data[field].item_name +'</td>'
|
||||
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
|
||||
+'<td style="width:33%; text-align:right">' + price + '</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
}else{
|
||||
$('.no_record').removeClass('hide');
|
||||
$("#crm_print").attr("disabled","disabled");
|
||||
}
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
}
|
||||
|
||||
function update_booking(booking_id,type) {
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true && data.type == "cancel")
|
||||
{
|
||||
alert('Booking has canceled!');
|
||||
}else{
|
||||
alert('Booking has completed!');
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
type: "POST",
|
||||
url: "crm/update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true && data.type == "cancel")
|
||||
{
|
||||
alert('Booking has canceled!');
|
||||
}else{
|
||||
alert('Booking has completed!');
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});//End Ajax
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.selected-item {
|
||||
background-color: #ccc;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<% @customer.each do |customer| %>
|
||||
<div class="card">
|
||||
<div class="card customer_detail" data-ref="<%= customer.id%>">
|
||||
<div class="card-block">
|
||||
<!-- <h4 class="card-title">Customer Name : <%= customer.name %></h4> -->
|
||||
<p class="card-text">Name : <%= customer.name %></p>
|
||||
|
||||
@@ -1,33 +1,21 @@
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
|
||||
<% @i = 0 %>
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "assign" %>
|
||||
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
|
||||
<div class="card-block" id="card-block" style="width:100%;">
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<% @queue.each do |queue| %>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-block" style="width:100%;">
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
<%= @i += 1 %> . <%= queue.name %>
|
||||
</h4>
|
||||
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
Contact No - <%= queue.contact_no %>
|
||||
</p>
|
||||
</div>
|
||||
<!-- <div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button id="assign" data-ref="<%= booking.id%>" data-type="complete" class="btn assign btn-primary btn-sm btn-block">ASSIGN</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button id="cancel" data-ref="<%= booking.id%>" data-type="cancel" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -3,34 +3,34 @@
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<!-- <ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Queue <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","assign").count %></span></a>
|
||||
<a class="nav-link" data-toggle="tab" href="#queue" role="tab">Queue <span class="badge badge-pill badge-default"><%= @queue.count %></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
|
||||
<a class="nav-link active" data-toggle="tab" href="#booking" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Customers</a>
|
||||
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customers</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<!--- Panel 0 - Completed -->
|
||||
<div class="tab-pane" id="completed" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<div class="tab-pane" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<%= render :partial => 'queue' %>
|
||||
|
||||
</div>
|
||||
<!-- Panel 1 - Tables -->
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<div class="tab-pane active" id="booking" role="tabpanel">
|
||||
|
||||
<%= render :partial => 'booking' %>
|
||||
|
||||
</div>
|
||||
<!-- Panel 1 - Tables - End -->
|
||||
<!-- Panel 2 - Rooms -->
|
||||
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<%= render :partial => 'customer' %>
|
||||
</div>
|
||||
<!-- Panel 2 - Rooms - End -->
|
||||
@@ -47,12 +47,12 @@
|
||||
<div id="station"></div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<table class="table" >
|
||||
<table class="table for-booking" id="for-booking">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:33%; text-align:left">Order By</th>
|
||||
<th style="width:33%; text-align:center;">Order At</td>
|
||||
<th style="width:33%; text-align:right">Customer</td>
|
||||
<th style="width:33%; text-align:center;">Order At</th>
|
||||
<th style="width:33%; text-align:right">Customer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -67,17 +67,38 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table customer-detail hide">
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Name</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_name"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Email</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_email"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Contact No</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_contact_no"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:33%; text-align:left">Items</th>
|
||||
<th style="width:33%; text-align:center">Qty</th>
|
||||
<th style="width:33%; text-align:right">Price</td>
|
||||
<th style="width:33%; text-align:right">Price</th>
|
||||
</tr>
|
||||
<tr class="hide no_record">
|
||||
<td style="width:44%; text-align:center;" id="no_record">No Order Items</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table summary-items">
|
||||
<tbody>
|
||||
@@ -95,12 +116,10 @@
|
||||
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
|
||||
Print
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
|
||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button> -->
|
||||
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
|
||||
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<title>SmartSales : Restaurant</title>
|
||||
<%= csrf_meta_tags %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
<%= stylesheet_link_tag 'CRM', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'CRM', 'data-turbolinks-track': 'reload' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<strong>CRM</strong>
|
||||
</div>
|
||||
<div style="float:left;margin-top:3px;text-align:left; width:600px">
|
||||
Queue | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
|
||||
<%= link_to 'Queue', crm_dining_queues_path, :html=>":color:white" %> | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
|
||||
</div>
|
||||
|
||||
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
<!-- Order Details -->
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||
<!-- <div class="card-header">
|
||||
<div><strong id="order-title">ORDER DETAILS</strong></div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<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>
|
||||
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
|
||||
</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-striped" id="order-items-table">
|
||||
<table class="table table-default" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
@@ -31,7 +31,7 @@
|
||||
<% sub_total = 0 %>
|
||||
<% @sale_data.sale_items.each do |sale_item| %>
|
||||
<% sub_total += sale_item.qty*sale_item.unit_price%>
|
||||
<tr>
|
||||
<tr class="discount-item-row" id=<%= sale_item.sale_item_id %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
|
||||
</td>
|
||||
@@ -52,30 +52,30 @@
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
<td class="item-attr"><strong id="order-food"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Beverage:</strong></td>
|
||||
<td class="item-attr"><strong id="order-beverage"></strong></td>
|
||||
</tr>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount">(<%=@sale_data.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr class="hidden">
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
@@ -84,11 +84,11 @@
|
||||
<!-- Discount Amount -->
|
||||
<div class="card row">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">Pay Discount</strong></div>
|
||||
<div><strong id="order-title">Overall Discount</strong></div>
|
||||
</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,82 +97,82 @@
|
||||
</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 class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="500" data-type="add">500</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<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 class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="1000" data-type="add">1000</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<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>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="5000" data-type="add">5000</div>
|
||||
<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 bottom">
|
||||
<div class="col-md-3 cashier_number" data-value="7" data-type="num">7</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 class="row">
|
||||
<div class="col-md-7">
|
||||
<div class="row">
|
||||
<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>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="30" data-type="add">30%</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="10000" data-type="add">10000</div>
|
||||
<div class="col-md-7">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-3 cashier_number" data-value="0" data-type="num">0</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 class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="50" data-type="add">50%</div>
|
||||
</div>
|
||||
<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 class="col-md-5">
|
||||
<div class="col-md-12 cashier_number long" data-value="50000" data-type="add">50000</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#Completed" role="tab">Completed</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
|
||||
</li>
|
||||
@@ -16,23 +19,89 @@
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow:auto">
|
||||
<div class="tab-content" style="max-height:670px; overflow:auto">
|
||||
<!--- 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|
|
||||
# ToDo no need check new
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if cpo.order_status == 'new'
|
||||
unique_id=cpo.booking_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
|
||||
unique_id=cpo.sale_id
|
||||
sale_status="paid"
|
||||
# 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
|
||||
%>
|
||||
<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="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
<%= cpo.receipt_no %>
|
||||
</span>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
Order Status :
|
||||
<span class="orders-order-status">
|
||||
<%= cpo.order_status %>
|
||||
</span>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 0 - Table Orders -->
|
||||
<!--- 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|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if bko.order_status == 'new'
|
||||
unique_id=bko.booking_id
|
||||
else
|
||||
unique_id=bko.sale_id
|
||||
sale_status="sold"
|
||||
<%
|
||||
@booking_orders.each do |bko|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if bko.order_status == 'new'
|
||||
unique_id=bko.booking_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
|
||||
unique_id=bko.sale_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
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
@@ -59,8 +128,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 1 - Room Orders -->
|
||||
<div class="tab-pane active" id="rooms" role="tabpanel">
|
||||
<!--- Panel 2 - Room Orders -->
|
||||
<div class="tab-pane" id="rooms" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@booking_rooms.each do |rmo|
|
||||
@@ -68,17 +137,32 @@
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if rmo.order_status == 'new'
|
||||
|
||||
if rmo.order_status == 'new'
|
||||
unique_id=rmo.booking_id
|
||||
else
|
||||
# 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
|
||||
unique_id=rmo.sale_id
|
||||
sale_status="sold"
|
||||
end
|
||||
# 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
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
|
||||
<p class="hidden customer-id"><%= rmo.customer_id %></p>
|
||||
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
|
||||
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
@@ -100,26 +184,41 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 2 - Orders -->
|
||||
<div class="tab-pane active" id="orders" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@orders.each do |odr|
|
||||
<!--- 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|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if odr.order_status == 'new'
|
||||
sale_status=""
|
||||
|
||||
if odr.order_status == 'new'
|
||||
unique_id=odr.booking_id
|
||||
else
|
||||
# check selected item and assign
|
||||
if @selected_item != nil
|
||||
if odr.order_id == @selected_item.order_id
|
||||
sale_status = sale_status + " selected-item"
|
||||
end
|
||||
end
|
||||
else
|
||||
unique_id=odr.sale_id
|
||||
sale_status="sold"
|
||||
end
|
||||
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
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
|
||||
<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">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
@@ -155,12 +254,21 @@
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p>Receipt No: <span id="receipt_no"></span></p>
|
||||
<p>Cashier: <span id="cashier"></span></p>
|
||||
</div>
|
||||
<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 class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date: <span id="receipt_date"></span></p>
|
||||
</div>
|
||||
<p>Date: <span id="receipt_date"><%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
|
||||
</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 class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Amount : <span id="customer_amount"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-text">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
@@ -172,7 +280,39 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Append Javascript Template -->
|
||||
<%
|
||||
# For Sale Items
|
||||
sub_total = 0
|
||||
if @selected_item_type == "Sale"
|
||||
@selected_item.sale_items.each do |sale_item|
|
||||
sub_total += sale_item.qty*sale_item.unit_price
|
||||
%>
|
||||
<tr>
|
||||
<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"
|
||||
@selected_item.order_items.each do |order_item|
|
||||
sub_total += order_item.qty*order_item.unit_price
|
||||
%>
|
||||
<tr>
|
||||
<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
|
||||
%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -180,27 +320,27 @@
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"></strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
<td class="item-attr"><strong id="order-food"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Beverage:</strong></td>
|
||||
<td class="item-attr"><strong id="order-beverage"></strong></td>
|
||||
</tr>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount"></strong></td>
|
||||
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"></strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"><%=@selected_item.total_tax rescue 0%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"></strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"><%=@selected_item.grand_total rescue 0%></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -214,13 +354,11 @@
|
||||
<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" disabled id="customer" disabled>Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" id="customer" disabled>Customer</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>
|
||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
|
||||
|
||||
<button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
||||
</div>
|
||||
|
||||
@@ -11,12 +11,13 @@ Amount :
|
||||
$('#mpu_pay').on('click',function(){
|
||||
var amount = $('#amount').val();
|
||||
var sale_id = "<%= @sale_id %>";
|
||||
alert(amount);
|
||||
|
||||
$.ajax({type: "POST",
|
||||
url: "<%= origami_create_mpu_payment_path %>",
|
||||
data: "amount="+ amount + "&sale_id="+ sale_id,
|
||||
success:function(result){
|
||||
if(result){
|
||||
alert("Payment success")
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||
}
|
||||
}
|
||||
|
||||
1
app/views/origami/payments/create.json.jbuilder
Normal file
1
app/views/origami/payments/create.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.status true
|
||||
@@ -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{
|
||||
@@ -229,7 +232,8 @@ $( document ).ready(function() {
|
||||
url: "<%= origami_payment_process_path %>",
|
||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
alert("THANK YOU")
|
||||
alert("Thank you")
|
||||
// window.location.href = '/origami';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
3
app/views/reports/receipt_no/index.html.erb
Normal file
3
app/views/reports/receipt_no/index.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="row">
|
||||
<%= @hi %>
|
||||
</div>
|
||||
@@ -18,3 +18,7 @@ Rails.application.config.assets.precompile += %w( OQS.css )
|
||||
Rails.application.config.assets.precompile += %w( OQS.js )
|
||||
|
||||
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 )
|
||||
|
||||
10
config/initializers/kaminari_config.rb
Normal file
10
config/initializers/kaminari_config.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
Kaminari.configure do |config|
|
||||
# config.default_per_page = 25
|
||||
# config.max_per_page = nil
|
||||
# config.window = 4
|
||||
# config.outer_window = 0
|
||||
# config.left = 0
|
||||
# config.right = 0
|
||||
# config.page_method_name = :page
|
||||
# config.param_name = :page
|
||||
end
|
||||
@@ -1,23 +1,17 @@
|
||||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
views:
|
||||
pagination:
|
||||
first: "« First"
|
||||
last: "Last »"
|
||||
previous: "‹ Prev"
|
||||
next: "Next ›"
|
||||
truncate: "…"
|
||||
helpers:
|
||||
page_entries_info:
|
||||
one_page:
|
||||
display_entries:
|
||||
zero: "No %{entry_name} found"
|
||||
one: "Displaying <b>1</b> %{entry_name}"
|
||||
other: "Displaying <b>all %{count}</b> %{entry_name}"
|
||||
more_pages:
|
||||
display_entries: "Displaying %{entry_name} <b>%{first} - %{last}</b> of <b>%{total}</b> in total"
|
||||
|
||||
@@ -51,7 +51,9 @@ Rails.application.routes.draw do
|
||||
|
||||
#Current active bookings
|
||||
resources :bookings, only: [:index, :show, :create, :update]
|
||||
resources :customers, only: [:index, :show, :create, :update]
|
||||
resources :customers
|
||||
#get customer details by order items
|
||||
get "customers/get_order/:id" => "customers#get_customer_order"
|
||||
|
||||
#Generating Invoice and making payments - output render @sale
|
||||
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
|
||||
@@ -71,13 +73,16 @@ Rails.application.routes.draw do
|
||||
namespace :origami do
|
||||
root "home#index"
|
||||
get "/:booking_id" => "home#show" do #origami/:booking_id will show
|
||||
resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers, only: [:index,:new, :create ] #add customer type
|
||||
# resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers #add customer type
|
||||
end
|
||||
|
||||
get "/request_bills/:id" => "request_bills#print"
|
||||
get "/discount/:id" => "discounts#index"
|
||||
post "/discount" => "discounts#create"
|
||||
post '/:booking_id' => 'home#item_show'
|
||||
|
||||
get "/:id/discount" => "discounts#index"
|
||||
post "/:id/discount" => "discounts#create"
|
||||
|
||||
get "/:id/request_bills" => "request_bills#print"
|
||||
|
||||
#--------- Payment ------------#
|
||||
get 'sale/:sale_id/payment' => 'payments#show'
|
||||
@@ -89,6 +94,13 @@ Rails.application.routes.draw do
|
||||
get 'sale/:sale_id/payment/others_payment/MPU' => "mpu#index"
|
||||
post 'create_mpu_payment' => "mpu#create"
|
||||
get 'sale/:sale_id/payment/others_payment/REDEEMREBATE' => "redeem_payments#index"
|
||||
|
||||
#---------Add Customer --------------#
|
||||
#resources :customers
|
||||
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 ------------#
|
||||
@@ -100,11 +112,10 @@ Rails.application.routes.draw do
|
||||
|
||||
#--------- Customer Relationship Management ------------#
|
||||
namespace :crm do
|
||||
root "home#index" #queue number
|
||||
get 'customers/:sale_id/assign_sale_id', to: "customers#get_sale_id", :as => "assign_sale"#get sale id with customer for crm
|
||||
root "home#index"
|
||||
resources :customers
|
||||
resources :dining_queues
|
||||
post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel
|
||||
post "update_sale" , to: "home#update_sale_by_customer"#update customer id in sale table
|
||||
get '/print/:id', to: "home#print_order"#print order for crm
|
||||
|
||||
end
|
||||
@@ -156,6 +167,8 @@ Rails.application.routes.draw do
|
||||
resources :tax_profiles
|
||||
#lookups
|
||||
resources :lookups
|
||||
#orders
|
||||
resources :orders
|
||||
#cashier_terminals
|
||||
resources :cashier_terminals
|
||||
#order_job_stations
|
||||
@@ -184,12 +197,13 @@ Rails.application.routes.draw do
|
||||
|
||||
#--------- Reports Controller Sections ------------#
|
||||
namespace :reports do
|
||||
resources :sales, :only => [:index, :show]
|
||||
resources :orders, :only => [:index, :show]
|
||||
resources :customers, :only => [:index, :show]
|
||||
resources :products, :only => [:index, :show]
|
||||
resources :inventory, :only => [:index, :show]
|
||||
resources :employees, :only => [:index, :show]
|
||||
resources :receipt_no, :only => [:index, :show]
|
||||
# resources :sales, :only => [:index, :show]
|
||||
# resources :orders, :only => [:index, :show]
|
||||
# resources :customers, :only => [:index, :show]
|
||||
# resources :products, :only => [:index, :show]
|
||||
# resources :inventory, :only => [:index, :show]
|
||||
# resources :employees, :only => [:index, :show]
|
||||
end
|
||||
|
||||
#mount_compendium at: '/report' #, controller: 'reports'
|
||||
|
||||
12
db/migrate/20170608105644_create_dining_queues.rb
Normal file
12
db/migrate/20170608105644_create_dining_queues.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateDiningQueues < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :dining_queues do |t|
|
||||
t.string :name
|
||||
t.string :contact_no
|
||||
t.string :queue_no
|
||||
t.string :status
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -8,7 +8,7 @@ class CreateMembershipActions < ActiveRecord::Migration[5.1]
|
||||
t.string :auth_token
|
||||
t.string :merchant_account_id
|
||||
t.string :created_by
|
||||
t.jsonb :additional_parameter
|
||||
t.json :additional_parameter
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -136,13 +136,10 @@ zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_o
|
||||
#Create Adminstrator employee
|
||||
admin_employee = Employee.create({name: "Administrator", role: "Administrator", password: "99999", emp_id:"999", created_by: "SYSTEM DEFAULT"})
|
||||
|
||||
#Account for Menu Item Type (eg: Food, Beverage)
|
||||
food = Account.create({title: "Food", account_type: "0"})
|
||||
beverage = Account.create({title: "Beverage", account_type: "1"})
|
||||
|
||||
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"})
|
||||
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"})
|
||||
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."})
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Crm::BookingsController, type: :controller do
|
||||
|
||||
end
|
||||
@@ -1,159 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe Crm::CustomersController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Crm::Customer. As you add validations to Crm::Customer, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Crm::CustomersController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all crm_customers as @crm_customers" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:crm_customers)).to eq([customer])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :show, params: {id: customer.to_param}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new crm_customer as @crm_customer" do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :edit, params: {id: customer.to_param}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Crm::Customer" do
|
||||
expect {
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
}.to change(Crm::Customer, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created crm_customer as @crm_customer" do
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a(Crm::Customer)
|
||||
expect(assigns(:crm_customer)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created crm_customer" do
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(Crm::Customer.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved crm_customer as @crm_customer" do
|
||||
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: new_attributes}, session: valid_session
|
||||
customer.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
|
||||
it "redirects to the crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(customer)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, params: {id: customer.to_param}, session: valid_session
|
||||
}.to change(Crm::Customer, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the crm_customers list" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
delete :destroy, params: {id: customer.to_param}, session: valid_session
|
||||
expect(response).to redirect_to(crm_customers_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/crm/dining_queues_helper_spec.rb
Normal file
15
spec/helpers/crm/dining_queues_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Crm::DiningQueuesHelper. For example:
|
||||
#
|
||||
# describe Crm::DiningQueuesHelper 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 Crm::DiningQueuesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/crm/crm_dining_queues_spec.rb
Normal file
10
spec/requests/crm/crm_dining_queues_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Crm::DiningQueues", type: :request do
|
||||
describe "GET /crm_dining_queues" do
|
||||
it "works! (now write some real specs)" do
|
||||
get crm_dining_queues_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/routing/crm/dining_queues_routing_spec.rb
Normal file
39
spec/routing/crm/dining_queues_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Crm::DiningQueuesController, type: :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/crm/dining_queues").to route_to("crm/dining_queues#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/crm/dining_queues/new").to route_to("crm/dining_queues#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/crm/dining_queues/1").to route_to("crm/dining_queues#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/crm/dining_queues/1/edit").to route_to("crm/dining_queues#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/crm/dining_queues").to route_to("crm/dining_queues#create")
|
||||
end
|
||||
|
||||
it "routes to #update via PUT" do
|
||||
expect(:put => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #update via PATCH" do
|
||||
expect(:patch => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/crm/dining_queues/1").to route_to("crm/dining_queues#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
24
spec/views/crm/dining_queues/edit.html.erb_spec.rb
Normal file
24
spec/views/crm/dining_queues/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/edit", type: :view do
|
||||
before(:each) do
|
||||
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
|
||||
:name => "MyString",
|
||||
:contact => "MyString",
|
||||
:queue_no => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit crm_dining_queue form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", crm_dining_queue_path(@crm_dining_queue), "post" do
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[name]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[contact]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
|
||||
end
|
||||
end
|
||||
end
|
||||
25
spec/views/crm/dining_queues/index.html.erb_spec.rb
Normal file
25
spec/views/crm/dining_queues/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:crm_dining_queues, [
|
||||
Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
),
|
||||
Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of crm/dining_queues" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Contact".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Queue No".to_s, :count => 2
|
||||
end
|
||||
end
|
||||
24
spec/views/crm/dining_queues/new.html.erb_spec.rb
Normal file
24
spec/views/crm/dining_queues/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:crm_dining_queue, Crm::DiningQueue.new(
|
||||
:name => "MyString",
|
||||
:contact => "MyString",
|
||||
:queue_no => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new crm_dining_queue form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", crm_dining_queues_path, "post" do
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[name]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[contact]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/crm/dining_queues/show.html.erb_spec.rb
Normal file
18
spec/views/crm/dining_queues/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/show", type: :view do
|
||||
before(:each) do
|
||||
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/Contact/)
|
||||
expect(rendered).to match(/Queue No/)
|
||||
end
|
||||
end
|
||||
9
test/system/dining_queues_test.rb
Normal file
9
test/system/dining_queues_test.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class Crm::DiningQueuesTest < ApplicationSystemTestCase
|
||||
# test "visiting the index" do
|
||||
# visit crm_dining_queues_url
|
||||
#
|
||||
# assert_selector "h1", text: "Crm::DiningQueue"
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user