Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -76,6 +76,11 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
sale_item_id = params[:sale_item_id]
|
||||
@sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
|
||||
@commissioners = Commissioner.active.all
|
||||
|
||||
respond_to do |format|
|
||||
format.json {render json: @commissioners}
|
||||
# format.html {render @commissioners}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -4,7 +4,7 @@ class Settings::PromotionsController < ApplicationController
|
||||
# GET /promotions
|
||||
# GET /promotions.json
|
||||
def index
|
||||
@promotions = Promotion.all
|
||||
@promotions = Promotion.all.order("created_at asc")
|
||||
end
|
||||
|
||||
# GET /promotions/1
|
||||
@@ -85,6 +85,6 @@ class Settings::PromotionsController < ApplicationController
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def promotion_params
|
||||
params.require(:promotion).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by,
|
||||
:promotion_products_attributes => [:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy])
|
||||
:promotion_products_attributes => [:id,:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class Promotion < ApplicationRecord
|
||||
|
||||
has_many :promotion_products
|
||||
|
||||
accepts_nested_attributes_for :promotion_products , :allow_destroy => true
|
||||
accepts_nested_attributes_for :promotion_products , :allow_destroy => true , update_only: true
|
||||
|
||||
PROMO_TYPE1 = "Quantity"
|
||||
PROMO_TYPE2 = "Net_off" # 3000 => - 500 => 2500 [total]
|
||||
@@ -204,6 +204,6 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.calculate_discount(total, discount)
|
||||
self (total.to_i * discount.to_i) / 100
|
||||
return (total.to_i * discount.to_i) / 100
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class PromotionProduct < ApplicationRecord
|
||||
validates_presence_of :item_code
|
||||
belongs_to :promotion
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div><strong id="order-title">COMMISSIONERS </strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
|
||||
<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">
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5" style="height: 100%">
|
||||
<%= render 'origami/commissioners/commissioners_form', commissioners: @commissioners %>
|
||||
<%= render 'origami/commissions/commissioners', commissioners: @commissioners %>
|
||||
</div>
|
||||
|
||||
<!-- Column Two -->
|
||||
@@ -210,7 +210,11 @@
|
||||
url: ajax_url,
|
||||
data: 'sale_item_id=' + sale_item_id,
|
||||
success: function (result) {
|
||||
// window.location.href = '/origami/table/' + table_id;
|
||||
$('#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);
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -310,39 +310,40 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<!-- Column Three -->
|
||||
<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" id="add_order" class="btn btn-primary btn-block" >Add Order</button>
|
||||
<% if @dining.bookings.length >= 1 %>
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
|
||||
<% else %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
||||
<% end %>
|
||||
<!-- Cashier Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
<button type="button" id="add_order" class="btn btn-primary btn-block">Add Order</button>
|
||||
<% if @dining.bookings.length >= 1 %>
|
||||
<% if @status_order == 'order' && @status_sale != 'sale' %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
|
||||
<button type="button" class="btn btn-primary btn-block" disabled> Void</button>
|
||||
<% else %>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-block">Customer</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
|
||||
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
|
||||
<button type="button" id="other-charges" class="btn btn-primary btn-block">Charges</button>
|
||||
<button type="button" id="commissions" class="btn btn-primary btn-block">Commissions</button>
|
||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||
<button type="button" id="void" class="btn btn-primary btn-block"> Void</button>
|
||||
<% end %>
|
||||
<!-- Cashier Buttons -->
|
||||
|
||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button> -->
|
||||
<% end %>
|
||||
</div>
|
||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button> -->
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<span>Promo Start Date</span>
|
||||
<span>* Promo Start Date</span>
|
||||
<%= f.date_field :promo_start_date, :placeholder => "From Date" , :class => "form-control"%>
|
||||
<br>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span>Promo End Date</span>
|
||||
<span>* Promo End Date</span>
|
||||
<%= f.date_field :promo_end_date ,:placeholder => "To Date" , :class => "form-control"%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<!-- <%= f.input :promo_start_hour %> -->
|
||||
<!-- <span>* Promo Start Hour</span> -->
|
||||
<% if !@promotion.promo_start_hour.nil?%>
|
||||
<%= f.input :promo_start_hour, as: :string, input_html: { :value => @promotion.promo_start_hour.utc.strftime('%H:%M') } %>
|
||||
<% else %>
|
||||
@@ -31,7 +31,7 @@
|
||||
<%= text_field_tag :promo_start_hour , nil, :placeholder => "From Time", :id => "fromtime", :class => 'form-control' %> -->
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<!-- <%= f.input :promo_end_hour %> -->
|
||||
<!-- <span>* Promo End Hour</span> -->
|
||||
<% if !@promotion.promo_end_hour.nil?%>
|
||||
<%= f.input :promo_end_hour, as: :string, input_html: {:value => @promotion.promo_end_hour.utc.strftime('%H:%M') } %>
|
||||
<% else %>
|
||||
@@ -49,60 +49,38 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6"><%= f.input :original_product,collection: MenuItem.order("name desc"),input_html: { selected: 2 } %></div>
|
||||
<div class="col-md-6"><%= f.input :original_product,collection: MenuItem.order("name desc").pluck(:name,:item_code),input_html: { selected: 2 } %></div>
|
||||
<div class="col-md-6"><%= f.input :min_qty %></div>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<table class="table" style="border : 1px solid #555555 !important;margin:0px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <td>Promotion Code</td> -->
|
||||
<td>Item Code</td>
|
||||
<td>Min Qty</td>
|
||||
<td>Net off</td>
|
||||
<td>Net Price</td>
|
||||
<td>Percentage</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
|
||||
<!-- <% @promotion.promotion_products.each do |pp| %>
|
||||
|
||||
<tr>
|
||||
<!-- <td><%= pp.promotion_id %></td>
|
||||
<td><%= pp.item_code %></td>
|
||||
<td><%= pp.min_qty %></td>
|
||||
<td><%= pp.net_off %></td>
|
||||
<td><%= pp.net_price %></td>
|
||||
<td><%= pp.percentage %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_promotion_promotion_product_path(@promotion,pp) %></td>
|
||||
<td><%= link_to 'Destroy', settings_promotion_promotion_product_path(@promotion,pp), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
|
||||
<% end %> -->
|
||||
</tbody>
|
||||
</table>
|
||||
<%= f.fields_for :promotion_products do |pro| %>
|
||||
<table class="table" style="margin:0px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <td></td> -->
|
||||
<td><%= pro.input :item_code, label: false%></td>
|
||||
<td><%= pro.input :min_qty , label: false%></td>
|
||||
<td><%= pro.input :net_off , label: false %></td>
|
||||
<td><%= pro.input :net_price , label: false %></td>
|
||||
<td><%= pro.input :percentage , label: false %></td>
|
||||
<td><%= pro.link_to_remove "X" %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>
|
||||
|
||||
<div class="" style="border: 1px solid #cccccc;padding:1%">
|
||||
<div class="row">
|
||||
<div class="col-md-2" style="text-align:center">Item Code</div>
|
||||
<div class="col-md-2" style="text-align:center">Min Qty</div>
|
||||
<div class="col-md-2" style="text-align:center">Net off</div>
|
||||
<div class="col-md-2" style="text-align:center">Net Price</div>
|
||||
<div class="col-md-2" style="text-align:center">Percentage</div>
|
||||
<div class="col-md-2" style="text-align:center"></div>
|
||||
</div>
|
||||
<div class="row"></div >
|
||||
<%= f.fields_for :promotion_products do |pro| %>
|
||||
<div class="row">
|
||||
<div class="col-md-2"><%= pro.input :item_code, label: false,collection: MenuItem.order("name desc").pluck(:name,:item_code)%></div>
|
||||
<div class="col-md-2"><%= pro.input :min_qty , label: false%></div>
|
||||
<div class="col-md-2"><%= pro.input :net_off , label: false %></div>
|
||||
<div class="col-md-2"><%= pro.input :net_price , label: false %></div>
|
||||
<div class="col-md-2"><%= pro.input :percentage , label: false %></div>
|
||||
<div class="col-md-2" style="text-align:right"><%= pro.link_to_remove "X" %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-md-12" style="text-align:right;"><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
|
||||
@@ -39,9 +39,7 @@
|
||||
<td><%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_day %></td>
|
||||
<td>
|
||||
<% if MenuItem.exists?(pro.original_product) %>
|
||||
<%= MenuItem.find(pro.original_product).name %>
|
||||
<% end %>
|
||||
<%= MenuItem.find_by_item_code(pro.original_product).name rescue "-"%>
|
||||
</td>
|
||||
<% if Employee.exists?(pro.created_by) %>
|
||||
<td><%= Employee.find(pro.created_by).name %></td>
|
||||
|
||||
Reference in New Issue
Block a user