Promotion Product Add
This commit is contained in:
32
app/views/settings/promotion_products/_form.html.erb
Normal file
32
app/views/settings/promotion_products/_form.html.erb
Normal file
@@ -0,0 +1,32 @@
|
||||
<%= simple_form_for([:settings,@promotion,@promotion_product]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<div class="div-border">
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :item_code %></div>
|
||||
</div>
|
||||
<% if @promotion.promo_type == Promotion::PROMO_TYPE1 %>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :min_qty %></div>
|
||||
</div>
|
||||
<% elsif @promotion.promo_type == Promotion::PROMO_TYPE2 %>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :net_off %></div>
|
||||
</div>
|
||||
<% elsif @promotion.promo_type == Promotion::PROMO_TYPE3 %>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :net_price %></div>
|
||||
</div>
|
||||
<% elsif @promotion.promo_type == Promotion::PROMO_TYPE4 %>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :percentage %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,2 @@
|
||||
json.extract! promotion, :id, :created_at, :updated_at
|
||||
json.url promotion_url(promotion, format: :json)
|
||||
11
app/views/settings/promotion_products/edit.html.erb
Normal file
11
app/views/settings/promotion_products/edit.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= edit_settings_promotion_path(@promotion) %>">Promotions</a></li>
|
||||
<li>Promotion Products</li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', promotion_products: @promotion_product %>
|
||||
</div>
|
||||
47
app/views/settings/promotion_products/index.html.erb
Normal file
47
app/views/settings/promotion_products/index.html.erb
Normal file
@@ -0,0 +1,47 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_promotions_path %>">Promotions</a></li>
|
||||
<li>PromotionProducts</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_promotion_promotion_product_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Promotion Code</th>
|
||||
<th>Item Code</th>
|
||||
<th>Minimum Quantity</th>
|
||||
<th>Net Off</th>
|
||||
<th>Net Price</th>
|
||||
<th>Percentage</th>
|
||||
<th>Created At</th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @promotion_products.each do |pro| %>
|
||||
<tr>
|
||||
<td><%= link_to pro.promotion.promo_code, settings_promotion_promotion_path(pro.promotion) %></td>
|
||||
<td><%= pro.item_code %></td>
|
||||
<td><%= pro.min_qty %></td>
|
||||
<td><%= pro.net_off rescue "-" %></td>
|
||||
<td><%= pro.net_price rescue "-" %></td>
|
||||
<td><%= pro.percentage %></td>
|
||||
<td><%= pro.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_promotion_promotion_product_path(pro) %></td>
|
||||
<td><%= link_to 'Destroy', settings_promotion_promotion_product_path(pro), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
json.array! @promotions, partial: 'promotions/promotion', as: :promotion
|
||||
15
app/views/settings/promotion_products/new.html.erb
Normal file
15
app/views/settings/promotion_products/new.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= edit_settings_promotion_path(@promotion) %>">Promotion</a></li>
|
||||
<!-- <li><a href="<%= settings_promotion_promotion_products_path %>">Promotion Products</a></li> -->
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', promotion_products: @promotion_product %>
|
||||
</div>
|
||||
<script>
|
||||
$("#promotion_promo_code").val(Math.random().toString(36).slice(5) + Math.random().toString(36).slice(5));
|
||||
</script>
|
||||
28
app/views/settings/promotion_products/show.html.erb
Normal file
28
app/views/settings/promotion_products/show.html.erb
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_promotion_path(@promotion) %>">Promotion</a></li>
|
||||
<li>Promotion Products</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Promotion Product</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
|
||||
<tr><td style="width:20%">Promotion Code</td><td><%= @promotion_product.promo_code %></td></tr>
|
||||
<tr><td style="width:20%">Item Code</td><td><%= @promotion_product.item_code %></td></tr>
|
||||
<tr><td style="width:20%">Min Qty</td><td><%= @promotion_product.min_qty %></td></tr>
|
||||
<tr><td style="width:20%">Net off</td><td><%= @promotion_product.net_off %></td></tr>
|
||||
<tr><td style="width:20%">Net Price</td><td><%= @promotion_product.net_price %></td></tr>
|
||||
<tr><td style="width:20%">Percentage</td><td><%= @promotion_product.percentage %></td></tr>
|
||||
<tr><td style="width:20%"><%= link_to 'Edit', edit_settings_promotion_product_path(@promotion_product) %></td><td><%= link_to 'Destroy', settings_promotion_product_path(@promotion_product), method: :delete, data: { confirm: 'Are you sure?' } %></td></tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/settings/promotion_products/show.json.jbuilder
Normal file
1
app/views/settings/promotion_products/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "promotions/promotion", promotion: @promotion
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= simple_form_for([:settings,@promotion]) do |f| %>
|
||||
<%= simple_nested_form_for([:settings,@promotion]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
@@ -32,13 +32,62 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<%= f.input :promo_type,input_html: { class: "" },
|
||||
collection: %w{Quantity Net_off Net_price Percentage},:class => 'form-control' ,:label => "" %>
|
||||
collection: %w{Quantity Net_off Net_price Percentage},:class => 'form-control' ,:label => "Promotion Type" %>
|
||||
</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 :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>
|
||||
|
||||
<% 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>
|
||||
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to 'Edit', edit_promotion_path(@promotion) %> |
|
||||
<%= link_to 'Back', promotions_path %>
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_promotions_path %>">Promotions</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Promotion</h4>
|
||||
<table class="table">
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr><td style="width:20%">Promotion code</td><td><%= @promotion.promo_code %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Date</td><td><%= @promotion.promo_start_date %></td></tr>
|
||||
<tr><td style="width:20%">Promotion End Date</td><td><%= @promotion.promo_end_date %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_start_hour %></td></tr>
|
||||
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_end_hour %></td></tr>
|
||||
<tr><td style="width:20%"><%= link_to 'Edit', edit_settings_promotion_path(@promotion) %></td><td><%= link_to 'Destroy', settings_promotion_path(@promotion), method: :delete, data: { confirm: 'Are you sure?' } %></td></tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user