Promotion CRUD
This commit is contained in:
48
app/views/settings/promotions/_form.html.erb
Normal file
48
app/views/settings/promotions/_form.html.erb
Normal file
@@ -0,0 +1,48 @@
|
||||
<%= simple_form_for([:settings,@promotion]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<div class="div-border">
|
||||
<div class="row">
|
||||
<div class="col-md-6"><%= f.input :promo_code %></div>
|
||||
<div class="col-md-6"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<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>
|
||||
<%= 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>
|
||||
<%= 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 %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12"><%= f.input :promo_day %></div>
|
||||
</div>
|
||||
<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 => "" %>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
2
app/views/settings/promotions/_promotion.json.jbuilder
Normal file
2
app/views/settings/promotions/_promotion.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! promotion, :id, :created_at, :updated_at
|
||||
json.url promotion_url(promotion, format: :json)
|
||||
10
app/views/settings/promotions/edit.html.erb
Normal file
10
app/views/settings/promotions/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<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>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', promotion: @promotion %>
|
||||
</div>
|
||||
58
app/views/settings/promotions/index.html.erb
Normal file
58
app/views/settings/promotions/index.html.erb
Normal file
@@ -0,0 +1,58 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li>Promotions</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_promotion_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>Start Date</th>
|
||||
<th>End Date</th>
|
||||
<th>Start Time</th>
|
||||
<th>End Time</th>
|
||||
<th>Promotion Day</th>
|
||||
<th>Original Product</th>
|
||||
<th>Created By</th>
|
||||
<th>Created At</th>
|
||||
<th colspan="2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @promotions.each do |pro| %>
|
||||
<tr>
|
||||
<td><%= link_to pro.promo_code, settings_promotion_path(pro) %></td>
|
||||
<td><%= pro.promo_start_date %></td>
|
||||
<td><%= pro.promo_end_date %></td>
|
||||
<td><%= pro.promo_start_hour.strftime("%I:%M %P") rescue "-" %></td>
|
||||
<td><%= pro.promo_end_hour.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 %>
|
||||
</td>
|
||||
<% if Employee.exists?(pro.created_by) %>
|
||||
<td><%= Employee.find(pro.created_by).name %></td>
|
||||
<% else %>
|
||||
<td><%= pro.created_by %></td>
|
||||
<% end %>
|
||||
<td><%= pro.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_promotion_path(pro) %></td>
|
||||
<td><%= link_to 'Destroy', settings_promotion_path(pro), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
1
app/views/settings/promotions/index.json.jbuilder
Normal file
1
app/views/settings/promotions/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @promotions, partial: 'promotions/promotion', as: :promotion
|
||||
17
app/views/settings/promotions/new.html.erb
Normal file
17
app/views/settings/promotions/new.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
<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>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', promotion: @promotion %>
|
||||
</div>
|
||||
<script>
|
||||
$("#promotion_promo_code").val(Math.random().toString(36).slice(5) + Math.random().toString(36).slice(5));
|
||||
// $( "#fromtime" ).timepicker();
|
||||
// $( "#totime" ).timepicker({ 'scrollDefault': 'now' });
|
||||
$('#scrollDefaultExample').timepicker({ 'scrollDefault': 'now' });
|
||||
</script>
|
||||
4
app/views/settings/promotions/show.html.erb
Normal file
4
app/views/settings/promotions/show.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to 'Edit', edit_promotion_path(@promotion) %> |
|
||||
<%= link_to 'Back', promotions_path %>
|
||||
1
app/views/settings/promotions/show.json.jbuilder
Normal file
1
app/views/settings/promotions/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "promotions/promotion", promotion: @promotion
|
||||
Reference in New Issue
Block a user