Files
sx-fc/app/views/settings/promotions/index.html.erb
2017-08-31 14:03:43 +06:30

63 lines
2.1 KiB
Plaintext

<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.utc.strftime("%I:%M %P") rescue "-" %></td>
<td><%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></td>
<td><%= pro.promo_day %></td>
<td>
<% item = MenuItemInstance.find_by_item_instance_code(pro.original_product)%>
<% if item.nil? %>
<%= Product.find_by_item_code(pro.original_product).name rescue "-" %>
<% else %>
<%= item.menu_item.name rescue "-" %>
- <%= item.item_instance_name rescue "-" %>
<% 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>