<%= simple_nested_form_for([:settings,@promotion]) do |f| %> <%= f.error_notification %>
<%= f.input :promo_code %>
* Promo Start Date <%= f.date_field :promo_start_date, :placeholder => "From Date" , :class => "form-control"%>
* Promo End Date <%= f.date_field :promo_end_date ,:placeholder => "To Date" , :class => "form-control"%>
<% 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 %> <%= f.input :promo_start_hour, as: :string, input_html: { } %> <% end %>
<% 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 %> <%= f.input :promo_end_hour, as: :string, input_html: {} %> <% end %>
<%= f.hidden_field :promo_day, :value => "", :class => "form-control col-md-1" %>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
<%= f.input :promo_type,input_html: { class: "" }, collection: %w{Quantity Net_off Net_price Percentage},:class => 'form-control' ,:label => "Promotion Type" %>
<% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> <% arr.push(p) %> <% end %>
<% sample = [] %> <% if !@promotion.original_product.nil? %> <% if !MenuItemInstance.find_by_item_instance_code(@promotion.original_product).nil? %> <% sample = MenuItemInstance.where("item_instance_code=?",@promotion.original_product).pluck(:item_instance_name,:item_instance_code)%> <% else %> <% sample = Product.where("item_code=?",@promotion.original_product).pluck(:name,:item_code)%> <% end %> <% end %>
<%= f.input :original_product,collection: sample %>
<%= f.input :min_qty %>

Item Code
Min Qty
Net off
Net Price
Percentage
<%= f.fields_for :promotion_products do |pro| %>
<% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> <% arr.push(p) %> <% end %>
<% sample = [] %>
<%= pro.input :item_code, :class => 'promoproduct', collection: sample,input_html: { selected: 2 }, label: false %>
<%= pro.input :min_qty , label: false%>
<%= pro.input :net_off , label: false %>
<%= pro.input :net_price , label: false %>
<%= pro.input :percentage , label: false %>
<%= pro.link_to_remove "X" %>
<% end %>
<%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary addProduct' %>

<%= f.button :submit %>
<% end %>