nested form
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
// about supported directives.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_nested_form
|
||||
//= require tether
|
||||
//= require bootstrap
|
||||
//= require jquery_ujs
|
||||
@@ -80,7 +81,3 @@ function export_to(path)
|
||||
var form_params = $("#frm_report").serialize();
|
||||
window.location = path+"?"+ form_params;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ 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])
|
||||
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])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,54 +39,20 @@
|
||||
<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 :min_qty %></div>
|
||||
</div>
|
||||
|
||||
<!-- <% if @promotion.id != nil %>
|
||||
<div class="div-border">
|
||||
<div class="col-md-10">
|
||||
<%= link_to 'Promotion Product', new_settings_promotion_promotion_product_path(@promotion),:class => 'btn btn-primary' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %> -->
|
||||
<br>
|
||||
<table class="table" style="border : 1px solid #555555 !important">
|
||||
<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"><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %></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>
|
||||
<p><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %></p>
|
||||
<br>
|
||||
<%= f.fields_for :promotion_products do |p| %>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-1"><%= p.input :item_code , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :min_qty , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :net_off , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :net_price , :class => "form-control" %></div>
|
||||
<div class="col-md-1"><%= p.input :percentage , :class => "form-control" %></div>
|
||||
<div class="col-md-1" style='padding-top:30px;'><%= p.link_to_remove "X"%></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= f.fields_for :promotion_products, PromotionProduct.new do |pro| %>
|
||||
<tr>
|
||||
<!-- <td></td> -->
|
||||
<td><%= pro.input :item_code , :class => "form-control" %></td>
|
||||
<td><%= pro.input :min_qty , :class => "form-control"%></td>
|
||||
<td><%= pro.input :net_off , :class => "form-control" %></td>
|
||||
<td><%= pro.input :net_price , :class => "form-control" %></td>
|
||||
<td><%= pro.input :percentage , :class => "form-control" %></td>
|
||||
<td><%= pro.link_to_remove "X" %></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user