Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
This commit is contained in:
@@ -74,13 +74,18 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def select_sale_item
|
||||
# byebug
|
||||
sale_item_id = params[:sale_item_id]
|
||||
@sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
|
||||
@selected_sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
|
||||
@product_commission = ProductCommission.find_by_sale_item_id(@selected_sale_item.id)
|
||||
unless @product_commission.nil?
|
||||
selected_commissioner = @product_commission.commissioner
|
||||
end
|
||||
@commissioners = Commissioner.active.all
|
||||
|
||||
respond_to do |format|
|
||||
format.json {render json: @commissioners}
|
||||
# format.html {render @commissioners}
|
||||
end
|
||||
# respond_to do |format|
|
||||
# format.json {render json: {[@commissioners],[@selected_sale_item]}}
|
||||
# # format.html {render @commissioners}
|
||||
# end
|
||||
render json: {commissioner: @commissioners, selected_commissioner: selected_commissioner}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Origami::InJutiesController < BaseOrigamiController
|
||||
before_action :set_in_juty, only: [:show, :edit, :update,:edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty]
|
||||
before_action :set_in_juty, only: [:show, :edit, :update, :edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty]
|
||||
|
||||
# GET /in_juties
|
||||
# GET /in_juties.json
|
||||
@@ -9,6 +9,9 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
|
||||
def index_in_juty
|
||||
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@in_juty = InJuty.new
|
||||
|
||||
end
|
||||
# GET /in_juties/1
|
||||
# GET /in_juties/1.json
|
||||
@@ -22,9 +25,11 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
|
||||
# GET /in_juties/1/edit
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def edit_in_juty
|
||||
@in_juty = InJuty.find(params[:id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
end
|
||||
|
||||
@@ -49,12 +54,24 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def create_for_in_juty
|
||||
@in_juty = InJuty.new
|
||||
|
||||
@in_juty.dinning_id = in_juty_params[:dinning_id]
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_juty_params[:in_time]
|
||||
@in_juty.out_time = in_juty_params[:out_time]
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @in_juty.save
|
||||
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @in_juty }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
||||
@in_juty.dinning_id = params[:dining_id]
|
||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||
@in_juty.in_time = params[:in_time]
|
||||
@in_juty.out_time = params[:out_time]
|
||||
@in_juty.save
|
||||
end
|
||||
|
||||
# PATCH/PUT /in_juties/1
|
||||
@@ -77,7 +94,7 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||
@in_juty.in_time = params[:in_time]
|
||||
@in_juty.out_time = params[:out_time]
|
||||
@in_juty.update
|
||||
@in_juty.save
|
||||
end
|
||||
|
||||
# DELETE /in_juties/1
|
||||
@@ -91,9 +108,11 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def destroy_in_juty
|
||||
@table_id = params[:table_id]
|
||||
@in_juty.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' }
|
||||
format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,11 +28,11 @@ class Origami::ProductCommissionsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @product_commission.save
|
||||
format.html { redirect_to @product_commission, notice: 'Product commission was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @product_commission }
|
||||
format.html {redirect_to @product_commission, notice: 'Product commission was successfully created.'}
|
||||
format.json {render :show, status: :created, location: @product_commission}
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @product_commission.errors, status: :unprocessable_entity }
|
||||
format.html {render :new}
|
||||
format.json {render json: @product_commission.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,11 +42,11 @@ class Origami::ProductCommissionsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @product_commission.update(product_commission_params)
|
||||
format.html { redirect_to @product_commission, notice: 'Product commission was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @product_commission }
|
||||
format.html {redirect_to @product_commission, notice: 'Product commission was successfully updated.'}
|
||||
format.json {render :show, status: :ok, location: @product_commission}
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @product_commission.errors, status: :unprocessable_entity }
|
||||
format.html {render :edit}
|
||||
format.json {render json: @product_commission.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,19 +56,62 @@ class Origami::ProductCommissionsController < ApplicationController
|
||||
def destroy
|
||||
@product_commission.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to product_commissions_url, notice: 'Product commission was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
format.html {redirect_to product_commissions_url, notice: 'Product commission was successfully destroyed.'}
|
||||
format.json {head :no_content}
|
||||
end
|
||||
end
|
||||
|
||||
def set_commissioner_to_sale_item
|
||||
deselect = false
|
||||
sale_item_id = params[:sale_item_id]
|
||||
commissioner_id = params[:commissioner_id]
|
||||
@sale_item = SaleItem.find(sale_item_id)
|
||||
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
|
||||
@commission = Commission.where('product_id = ? AND is_active = ?', @menu_item.id, true).take
|
||||
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
|
||||
@product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take
|
||||
# byebug
|
||||
if !@product_commission.nil?
|
||||
if @product_commission.commissioner_id == @commissioner.id
|
||||
@product_commission.destroy
|
||||
deselect = true
|
||||
else
|
||||
@product_commission.commissioner_id = @commissioner.id
|
||||
deselect = false
|
||||
end
|
||||
else
|
||||
@product_commission = ProductCommission.new
|
||||
@product_commission.product_id = @menu_item.id
|
||||
unless @commission.nil?
|
||||
@product_commission.commission_id = @commission.id
|
||||
if @commission.commission_type == 'Percentage'
|
||||
@product_commission.price = @sale_item.unit_price * (@commission.amount / 100.0)
|
||||
@product_commission.amount = @product_commission.price * @sale_item.qty
|
||||
elsif @commission.commission_type == 'Net Amount'
|
||||
@product_commission.price = @commission.amount
|
||||
@product_commission.amount = @product_commission.price * @sale_item.qty
|
||||
end
|
||||
end
|
||||
@product_commission.commissioner_id = @commissioner.id
|
||||
@product_commission.qty = @sale_item.qty
|
||||
@product_commission.sale_id = @sale_item.sale_id
|
||||
@product_commission.sale_item_id = @sale_item.sale_item_id
|
||||
end
|
||||
if @product_commission.save
|
||||
render json: {status: true, deselect: deselect}
|
||||
else
|
||||
render json: {status: false, deselect: deselect}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_product_commission
|
||||
@product_commission = ProductCommission.find(params[:id])
|
||||
end
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_product_commission
|
||||
@product_commission = ProductCommission.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def product_commission_params
|
||||
params.fetch(:product_commission, {})
|
||||
end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def product_commission_params
|
||||
params.fetch(:product_commission, {})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Commission < ApplicationRecord
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
has_many :commissioners
|
||||
has_many :product_commissions
|
||||
end
|
||||
|
||||
@@ -2,5 +2,6 @@ class Commissioner < ApplicationRecord
|
||||
belongs_to :employee, foreign_key: 'emp_id'
|
||||
belongs_to :commission, foreign_key: 'commission_type'
|
||||
has_many :in_juties
|
||||
has_many :product_commissions
|
||||
scope :active, -> { where(is_active: true) }
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ class MenuItem < ApplicationRecord
|
||||
belongs_to :menu_category, :optional => true
|
||||
has_many :menu_item_instances
|
||||
has_many :commissions
|
||||
has_many :product_commissions
|
||||
|
||||
# belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
# has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
class ProductCommission < ApplicationRecord
|
||||
belongs_to :commission, foreign_key: 'commission_id'
|
||||
belongs_to :commissioner, foreign_key: 'commissioner_id'
|
||||
belongs_to :menu_item, foreign_key: 'product_id'
|
||||
belongs_to :sale_item, foreign_key: 'sale_item_id'
|
||||
belongs_to :sale, foreign_key: 'sale_id'
|
||||
|
||||
def self.check_product_commission(sale_item_id)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@ class Sale < ApplicationRecord
|
||||
has_many :sale_payments
|
||||
has_many :sale_orders
|
||||
has_many :bookings
|
||||
has_many :product_commissions
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
|
||||
@@ -5,6 +5,7 @@ class SaleItem < ApplicationRecord
|
||||
before_create :generate_custom_id
|
||||
|
||||
belongs_to :sale
|
||||
has_many :product_commissions
|
||||
|
||||
#compute items - discount, tax, price_change
|
||||
def compute_item
|
||||
@@ -80,7 +81,7 @@ class SaleItem < ApplicationRecord
|
||||
account_price[:amount] = account_price[:amount] + si.price
|
||||
price = price + si.price
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
rebate_arr.push(account_price)
|
||||
end
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">COMMISSIONERS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-columns" id="commissioners" style="float: left; padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
|
||||
<% @commissioners.each do |commissioner| %>
|
||||
<div class="card tables green text-white" data-id="<%= commissioner.id %>">
|
||||
<div class="card-block">
|
||||
<%= commissioner.name %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,11 +1,26 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5" style="height: 100%">
|
||||
<%= render 'origami/commissions/commissioners', commissioners: @commissioners %>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">COMMISSIONERS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-columns" id="commissioners" style="float: left; padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
|
||||
<% @commissioners.each do |commissioner| %>
|
||||
<div class="card tables green text-white commissioner" data-commissioner-id="<%= commissioner.id %>" data-commissioner-name="<%= commissioner.name %>">
|
||||
<div class="card-block">
|
||||
<%= commissioner.name %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">INVOICE DETAILS </strong></div>
|
||||
@@ -34,11 +49,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="4%">#</th>
|
||||
<th class="" width="60%">Items</th>
|
||||
<th style="" width="20%">QTY
|
||||
</td>
|
||||
<th class="" width="30%">Price
|
||||
</td>
|
||||
<th class="" width="40%">Items</th>
|
||||
<th style="" width="20%">QTY</th>
|
||||
<th class="" width="20%">Price</th>
|
||||
<th class="" width="20%">Commissioner</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -49,22 +63,26 @@
|
||||
count += 1
|
||||
sub_total = sub_total + sale_item.price
|
||||
%>
|
||||
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
|
||||
<input type="hidden" id="sale_id" class="sale_id" value="<%= @saleobj.sale_id %>">
|
||||
<%
|
||||
# Can't check for discount
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr id="sale_item" data-sale-item="<%= sale_item.sale_item_id %>">
|
||||
<tr id="sale_item" class="sale_item" data-sale-item="<%= sale_item.sale_item_id %>">
|
||||
<td width="4%"><%= count %></td>
|
||||
<td class='' width="60%">
|
||||
<td class='product_name' width="40%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<td class='' width="20%">
|
||||
<td class='qty' width="20%">
|
||||
<%= sale_item.qty %>
|
||||
</td>
|
||||
<td class='' width="20%">
|
||||
<td class='unit_price' width="20%">
|
||||
<%= sale_item.unit_price %>
|
||||
</td>
|
||||
<td class='commissioner' width="20%">
|
||||
<% product_commission = ProductCommission.find_by_sale_item_id(sale_item.id) %>
|
||||
<%= product_commission.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
</tr>
|
||||
<%
|
||||
end
|
||||
@@ -87,135 +105,78 @@
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='apply'>Apply</button>
|
||||
<!--<button type="button" class="btn btn-primary btn-block" id='apply'>Apply</button>-->
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Bill Request
|
||||
$(document).ready(function () {
|
||||
var selected_sale_item = 0;
|
||||
|
||||
$(".update").on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var qty = $('#' + sale_item_id + "_qty").val();
|
||||
var price = $('#' + sale_item_id + "_price").val();
|
||||
console.log(qty + "|" + price)
|
||||
var ajax_url = "/origami/item_edit";
|
||||
$('.sale_item').on('click', function () {
|
||||
$('#order-items-table tr').siblings().css( "background-color", "white" );
|
||||
this.style.backgroundColor = 'lightgray';
|
||||
var sale_item_id = this.getAttribute('data-sale-item');
|
||||
var ajax_url = "/origami/select_sale_item";
|
||||
selected_sale_item = sale_item_id;
|
||||
localStorage.setItem("selected_sale_item", selected_sale_item);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
$.confirm({
|
||||
title: 'Alert!',
|
||||
content: 'Qty and Price was successfully Updated',
|
||||
buttons: {
|
||||
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green btn-lg',
|
||||
action: function () {
|
||||
location.reload();
|
||||
if (result != null){
|
||||
$('#commissioners').empty();
|
||||
result.commissioner.forEach(function (c) {
|
||||
if (result.selected_commissioner != null){
|
||||
if (c.id == result.selected_commissioner.id){
|
||||
sale_item = "<div class=\"card tables blue text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
|
||||
}else {
|
||||
sale_item = "<div class=\"card tables green text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
|
||||
}
|
||||
}else {
|
||||
sale_item = "<div class=\"card tables green text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#commissioners').append(sale_item);
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.void').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_void";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
$('#back').on('click', function () {
|
||||
var table_id = '<%= @table_id %>';
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
});
|
||||
|
||||
$('.foc').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_foc";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
$('.cancel').on('click', function () {
|
||||
var sale_item_id = $(this).attr('data-id');
|
||||
var ajax_url = "/origami/item_void_cancel";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
})
|
||||
$('.commissioner').on('click', function () {
|
||||
alert('click');
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
||||
$('#back').on('click', function () {
|
||||
var table_id = '<%= @table_id %>'
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
})
|
||||
|
||||
$('#cancel_all_void').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/origami/cancel_all_void";
|
||||
function click_commissioner(commissioner) {
|
||||
var commissioner_id = commissioner.getAttribute('data-commissioner-id');
|
||||
var selected_sale_item = localStorage.getItem("selected_sale_item");
|
||||
$(commissioner).removeClass("green").addClass("blue");
|
||||
$(commissioner).siblings().removeClass("blue").addClass("green");
|
||||
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text(commissioner.getAttribute('data-commissioner-name'));
|
||||
var ajax_url = "/origami/select_commissioner";
|
||||
var param_data = 'sale_item_id=' + selected_sale_item + '&commissioner_id=' + commissioner_id;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id,
|
||||
data: param_data,
|
||||
success: function (result) {
|
||||
location.reload();
|
||||
console.log(selected_sale_item + "," +commissioner_id);
|
||||
if(result.deselect == true){
|
||||
$(commissioner).removeClass("blue").addClass("green");
|
||||
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text('-');
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
|
||||
$('#apply').on('click', function () {
|
||||
var sale_id = "<%= @saleobj.sale_id %>"
|
||||
var ajax_url = "/origami/apply_void";
|
||||
var table_id = '<%= @table_id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_id=' + sale_id,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/table/' + table_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#sale_item').on('click', function () {
|
||||
var sale_item_id = this.getAttribute('data-sale-item');
|
||||
var ajax_url = "/origami/select_sale_item";
|
||||
var table_id = '<%= @table_id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
$('#commissioners').empty();
|
||||
result.forEach(function (t) {
|
||||
sale_item = "<div class=\"card tables green text-white\" data-id=" + t.id + ">" + "<div class=\"card-block\">" + t.name + "</div>" + "</div>"
|
||||
$('#commissioners').append(sale_item);
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -243,7 +243,7 @@
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<p class="hidden customer-id"><%= customer_id %></p>
|
||||
<p class="hidden order-cid"><%= odr.order_id %></p>
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :dinning_id %>
|
||||
<br/>
|
||||
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
|
||||
<label>Dining Name:</label>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<%= f.label :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/>
|
||||
<label>Commissioner Name:</label>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<div class='row'>
|
||||
<div class="col-md-2">
|
||||
<%= link_to 'Back', origami_path(@table.id), class: 'btn btn-success' %>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
|
||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
|
||||
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -39,20 +37,4 @@ $(function() {
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#in_juty').on('click', function () {
|
||||
var ajax_url = "/origami/assign_in_juty";
|
||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||
var in_time = $('#in_juty_in_time').val();
|
||||
var out_time = $('#in_juty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/table/' + dining_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -1,59 +0,0 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :dinning_id %>
|
||||
<br/>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
|
||||
<%= f.label :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} ,:value => @in_juty.commissioner.name %><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.in_time %><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker" ,:value => @in_juty.out_time %>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<div class='row'>
|
||||
<div class="col-md-2">
|
||||
<%= link_to 'Back', origami_index_in_juty_path, class: 'btn btn-success' %>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Update In Juty</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#in_juty').on('click', function () {
|
||||
var id = '<%= @in_juty.id %>'
|
||||
var ajax_url = "/origami/edit_in_juty/" + id;
|
||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||
var in_time = $('#in_juty_in_time').val();
|
||||
var out_time = $('#in_juty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/assign_in_juty';
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
14
app/views/origami/in_juties/_edit_in_juty.html.erb
Normal file
14
app/views/origami/in_juties/_edit_in_juty.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :dinning_id %>
|
||||
<%= f.input :commissioner_ids %>
|
||||
<%= f.input :in_time %>
|
||||
<%= f.input :out_time %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,3 +1,64 @@
|
||||
<div class="span12">
|
||||
<%= render 'assign_in_juty', in_juty: @in_juty %>
|
||||
</div>
|
||||
<div class="page-header">
|
||||
<h3>Create In Juty</h3>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@in_juty]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<label>Dining Name:</label>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<label>Commissioner Name:</label>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<div class='row'>
|
||||
<div class="col-md-2">
|
||||
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
$('#in_juty').on('click', function () {
|
||||
var ajax_url = "/origami/assign_in_juty";
|
||||
var commissioner_ids = $('#in_juty_commissioner_ids').val();
|
||||
var in_time = $('#in_juty_in_time').val();
|
||||
var out_time = $('#in_juty_out_time').val();
|
||||
var dining_id = '<%= @table.id %>'
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/assign_in_juty/'+ dining_id;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -1,10 +1,6 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
<h3>Update In Juty</h3>
|
||||
</div>
|
||||
<%= render 'form', in_juty: @in_juty %>
|
||||
<%= render 'edit_in_juty', in_juty: @in_juty %>
|
||||
</div>
|
||||
@@ -1,37 +1,79 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li>In Juties</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), origami_assign_in_juty_path, :class => 'btn btn-primary btn-sm', :flag => 'new' %>
|
||||
</span>
|
||||
</ul>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Dining Facility Name</th>
|
||||
<th>Commissioner Ids</th>
|
||||
<th>In time</th>
|
||||
<th>Out time</th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @juties_in.each do |in_juty| %>
|
||||
<tr class="injuty_tr" data-ref="<%= in_juty.id %>">
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||
<td><%= in_juty.dining_facility.name rescue '-' %></td>
|
||||
<td><%= in_juty.commissioner.name rescue '-' %></td>
|
||||
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
|
||||
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
|
||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= render 'assign_in_juty', in_juty: @in_juty ,table: @table %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Dining Facility Name</th>
|
||||
<th>Commissioner Ids</th>
|
||||
<th>In time</th>
|
||||
<th>Out time</th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @juties_in.each do |in_juty| %>
|
||||
<tr>
|
||||
<td><%= in_juty.dining_facility.name rescue '-' %></td>
|
||||
<td><%= in_juty.commissioner.name rescue '-' %></td>
|
||||
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty) %></td>
|
||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).on('click',".injuty_tr",function(){
|
||||
debugger;
|
||||
// if(this.checked){
|
||||
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||
//$( "#checkbox_check" ).prop( "checked", true );
|
||||
|
||||
var in_juty_id = $(this).attr('data-ref');
|
||||
var table_id = "<%= @table.id %>";
|
||||
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
// Selected for Taxes
|
||||
$('#in_juty_commissioner_ids').val(data.commissioner.name);
|
||||
$('#in_juty_in_time').val(data.in_time);
|
||||
$('#in_juty_out_time').val(data.out_time);
|
||||
|
||||
$('#update').removeAttr('disabled');
|
||||
$('#update').attr('value', 'Update');
|
||||
$('#create').attr('disabled','disabled');
|
||||
|
||||
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
|
||||
var id = customer_id;
|
||||
$("#new_customer").attr('id', id);
|
||||
|
||||
$(".edit_customer").attr('id', id);
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
|
||||
// }
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user