Promotion Time Fixed

This commit is contained in:
Phyo
2017-08-23 19:09:44 +06:30
parent 790b7939fc
commit 857fcd419f
8 changed files with 100 additions and 18 deletions

View File

@@ -1,3 +1,4 @@
<%= simple_nested_form_for([:settings,@promotion]) do |f| %>
<%= f.error_notification %>
@@ -20,11 +21,23 @@
</div>
<div class="row">
<div class="col-md-6">
<%= f.input :promo_start_hour %>
<!-- <%= f.input :promo_start_hour %> -->
<% 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 %>
<!-- <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 class="col-md-6">
<!-- <%= f.input :promo_end_hour %> -->
<% 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 %>
</div>
</div>
<div class="row">
<div class="col-md-12"><%= f.input :promo_day %></div>
@@ -40,19 +53,52 @@
<div class="col-md-6"><%= f.input :min_qty %></div>
</div>
<br>
<p><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %></p>
<br>
<%= f.fields_for :promotion_products do |p| %>
<table class="table" style="border : 1px solid #555555 !important;margin:0px">
<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"></td>
</tr>
<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>
<!-- <% @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 %> -->
</tbody>
</table>
<%= f.fields_for :promotion_products do |pro| %>
<table class="table" style="margin:0px">
<tbody>
<tr>
<!-- <td></td> -->
<td><%= pro.input :item_code, label: false%></td>
<td><%= pro.input :min_qty , label: false%></td>
<td><%= pro.input :net_off , label: false %></td>
<td><%= pro.input :net_price , label: false %></td>
<td><%= pro.input :percentage , label: false %></td>
<td><%= pro.link_to_remove "X" %></td>
<td></td>
</tr>
</tbody>
</table>
<% end %>
<%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>
</div>
</div>
@@ -61,3 +107,23 @@
<%= f.button :submit %>
</div>
<% end %>
<script>
$(document).ready(function(){
$('#promotion_promo_start_date').datetimepicker({
timepicker:false,
format:'Y-m-d'
});
$('#promotion_promo_end_date').datetimepicker({
timepicker:false,
format:'Y-m-d'
});
$('#promotion_promo_start_hour').datetimepicker({
datepicker:false,
format:'H:m'
});
$('#promotion_promo_end_hour').datetimepicker({
datepicker:false,
format:'H:m'
});
});
</script>

View File

@@ -35,8 +35,8 @@
<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_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>
<% if MenuItem.exists?(pro.original_product) %>

View File

@@ -17,8 +17,8 @@
<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%">Promotion Start Hour</td><td><%= @promotion.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %></td></tr>
<tr><td style="width:20%">Promotion Start Hour</td><td><%= @promotion.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %></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>