CalculatePriceInDiningCharges
This commit is contained in:
@@ -97,6 +97,6 @@ class Settings::DiningChargesController < ApplicationController
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_charge_params
|
||||
# params.fetch(:dining_charge, {})
|
||||
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
|
||||
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id, :time_rounding_block_price)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :item_code, :input_html => { :id => 'item_code' } %>
|
||||
<%= f.input :unit_price %>
|
||||
<%= f.input :unit_price, :input_html => { :id => 'unit_price'} %>
|
||||
<%= f.input :taxable %>
|
||||
<%= f.input :charge_type, :collection => [:hr, :day] %>
|
||||
<%= f.input :minimum_free_time %>
|
||||
<%= f.input :charge_block %>
|
||||
<%= f.input :charge_block, :input_html => { :id => 'charge_block'} %>
|
||||
<%= f.input :time_rounding %>
|
||||
<%= f.input :time_rounding_block %>
|
||||
<%= f.input :time_rounding_block, :input_html => { :id => 'time_rounding_block'} %>
|
||||
<%= f.input :time_rounding_block_price, :input_html => { :id => 'time_rounding_block_price'} %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
@@ -17,3 +18,39 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
|
||||
function price(){
|
||||
var unit_price = $("#unit_price").val();
|
||||
|
||||
var hour1 = $("select[name='dining_charge[time_rounding_block(4i)]']").val();
|
||||
var min1 = $("select[name='dining_charge[time_rounding_block(5i)]']").val();
|
||||
var time1=(parseInt(hour1)*60)+parseInt(min1);
|
||||
|
||||
var hour2 = $("select[name='dining_charge[charge_block(4i)]']").val();
|
||||
var min2 = $("select[name='dining_charge[charge_block(5i)]']").val();
|
||||
var time2=(parseInt(hour2)*60)+parseInt(min2);
|
||||
|
||||
var result=(unit_price*time1)/time2;
|
||||
$("#time_rounding_block_price").val(result);
|
||||
// return result;
|
||||
}
|
||||
|
||||
|
||||
$( "#unit_price" ).change(function() {
|
||||
price();
|
||||
});
|
||||
$( "select[name='dining_charge[time_rounding_block(4i)]']" ).change(function() {
|
||||
price();
|
||||
});
|
||||
$( "select[name='dining_charge[time_rounding_block(5i)]']" ).change(function() {
|
||||
price();
|
||||
});
|
||||
$( "select[name='dining_charge[charge_block(4i)]']" ).change(function() {
|
||||
price();
|
||||
});
|
||||
$( "select[name='dining_charge[charge_block(5i)]']" ).change(function() {
|
||||
price();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
</div>
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function randomNumber(len) {
|
||||
var randomNumber;
|
||||
@@ -27,6 +28,5 @@ function randomNumber(len) {
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
document.getElementById("item_code").value = "<%= @zone.id %>"+"<%= @settings_dining_facility.id %>"+"_"+randomNumber(5);
|
||||
</script>
|
||||
Reference in New Issue
Block a user