368 lines
16 KiB
Plaintext
Executable File
368 lines
16 KiB
Plaintext
Executable File
<div class="row">
|
|
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
|
<%= simple_nested_form_for([:settings,@promotion]) do |f| %>
|
|
<%= f.error_notification %>
|
|
|
|
<div class="form-inputs p-l-15">
|
|
<div class="div-border">
|
|
<div class="row">
|
|
<div class="col-md-6 form-group">
|
|
<label>*Promo Code</label>
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="material-icons">vpn_key</i>
|
|
</span>
|
|
<input type="text" name="promotion[promo_code]" value="<%= @promotion.promo_code%>" class="form-control" id="promotion_promo_code">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 form-group">
|
|
<label>* Start Date</label>
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="material-icons">date_range</i>
|
|
</span>
|
|
<% if !@promotion.promo_start_date.nil?%>
|
|
<input type="text" name="promotion[promo_start_date]" value="<%= @promotion.promo_start_date.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-8" placeholder="Start Date...">
|
|
<% else %>
|
|
<input type="text" name="promotion[promo_start_date]" class="datepicker form-control col-md-8" placeholder="Start Date...">
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6 form-group">
|
|
<label>* End Date</label>
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="material-icons">date_range</i>
|
|
</span>
|
|
<% if !@promotion.promo_end_date.nil?%>
|
|
<input type="text" name="promotion[promo_end_date]" value="<%= @promotion.promo_end_date.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-8" placeholder="Start Date...">
|
|
<% else %>
|
|
<input type="text" name="promotion[promo_end_date]" class="datepicker form-control col-md-8" placeholder="End Date...">
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 form-group">
|
|
<label class="control-label">* Start Hour</label>
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="material-icons">access_time</i>
|
|
</span>
|
|
<% if !@promotion.promo_start_hour.nil?%>
|
|
<input type="text" name="promotion[promo_start_hour]" value="<%= @promotion.promo_start_hour.utc.strftime('%H:%M') %>" class="timepicker form-control col-md-8" placeholder="Start Time...">
|
|
<% else %>
|
|
<input type="text" name="promotion[promo_start_hour]" class="timepicker form-control col-md-8" placeholder="Start Time...">
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6 form-group">
|
|
<label class="control-label">* End Hour</label>
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<i class="material-icons">access_time</i>
|
|
</span>
|
|
<% if !@promotion.promo_end_hour.nil?%>
|
|
<input type="text" name="promotion[promo_end_hour]" value="<%= @promotion.promo_end_hour.utc.strftime('%H:%M') %>" class="timepicker form-control col-md-8" placeholder="End Time...">
|
|
<% else %>
|
|
<input type="text" name="promotion[promo_end_hour]" class="timepicker form-control col-md-8" placeholder="End Time...">
|
|
<% end %>
|
|
</div>
|
|
<!-- <% if !@promotion.promo_end_hour.nil?%>
|
|
<%= f.input :promo_end_hour, as: :string, input_html: {:value => @promotion.promo_end_hour.utc.strftime('%H:%M') },:class=>"form-control timepicker" %>
|
|
<% else %>
|
|
<%= f.input :promo_end_hour, as: :string, input_html: {},:class=>"form-control timepicker" %>
|
|
<% end %> -->
|
|
</div>
|
|
</div>
|
|
|
|
<br>
|
|
<div class="row checkboxes ">
|
|
<div class="col-md-2">
|
|
<label class="control-label font-14"><abbr title="required">*</abbr> Promotion Day</label>
|
|
</div>
|
|
<%= f.hidden_field :promo_day, :class => "form-control" %>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Sunday" value="0" id="0"> Sun</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Monday" value="1" id="1">Mon</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Tuesday" value="2" id="2"> Tue</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Wednesday" value="3" id="3"> Wed</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Thursday" value="4" id="4"> Thu</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Friday" value="5" id="5"> Fri</label></div>
|
|
<div class="col-md-1"><label><input class="selectDay" type="checkbox" name="Saturday" value="6" id="6"> Sat</label></div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-5 form-group">
|
|
<select name="promotion[promo_type]" class="form-control">
|
|
<option>Quantity</option>
|
|
<option>Net_off</option>
|
|
<option>Net_price</option>
|
|
<option>Percentage</option>
|
|
</select>
|
|
<!-- <%= f.input :promo_type, collection: %w{Quantity Net_off Net_price Percentage},:class => 'form-control' ,:label => "Promotion Type" %> -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<% 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 %>
|
|
<div class="col-md-3 form-group">
|
|
<label class="control-label"><abbr title="required">*</abbr> Item</label>
|
|
<select class="form-control item_code_place">
|
|
<% if !@promotion.original_product.nil? %>
|
|
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@promotion.original_product) %>
|
|
<% if menuiteminstance.nil?%>
|
|
<% code = @promotion.original_product %>
|
|
<% else %>
|
|
<% code = menuiteminstance.menu_item.item_code %>
|
|
<% end %>
|
|
<% end %>
|
|
<option value="" selected>Choose Something</option>
|
|
<% arr.each do |a| %>
|
|
<% if a[1] == code %>
|
|
<option value="<%= a[1]%>" selected><%= a[0] %></option>
|
|
<% else %>
|
|
<option value="<%= a[1]%>"><%= a[0] %></option>
|
|
<% end %>
|
|
<% end %>
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<% 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 %>
|
|
<div class="col-md-3 form-group"><%= f.input :original_product,collection: sample %></div>
|
|
<!-- <div class="col-md-6"><%= f.input :original_product,collection: MenuItemInstance.order("item_instance_name desc").pluck(:item_instance_name,:item_instance_code),input_html: { selected: 2 } %></div> -->
|
|
<div class="col-md-6 form-group"><%= f.input :min_qty %></div>
|
|
</div>
|
|
<br>
|
|
<div class="card">
|
|
<div class="row">
|
|
<div class="col-md-4" style="text-align:center">Item Code</div>
|
|
<div class="col-md-2" style="text-align:center">Min Qty</div>
|
|
<div class="col-md-2" style="text-align:center">Net off</div>
|
|
<div class="col-md-2" style="text-align:center">Net Price</div>
|
|
<div class="col-md-1" style="text-align:center">Percentage</div>
|
|
<div class="col-md-1" style="text-align:center"></div>
|
|
</div>
|
|
<div class="row"></div >
|
|
<%= f.fields_for :promotion_products do |pro| %>
|
|
<div class="row">
|
|
<%= pro.hidden_field :item_code,:class => "promo_product" %>
|
|
<% 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 %>
|
|
<div class="col-md-2 menu_item_choose" style="text-align:left">
|
|
<select class="form-control item_code_place1">
|
|
<option value="">Choose Something</option>
|
|
<% arr.each do |a| %>
|
|
<option value="<%= a[1 ]%>"><%= a[0] %></option>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
<!-- <% sample = [] %> -->
|
|
|
|
<div class="col-md-2" style="text-align:left"><%= pro.input :item_code, :class => 'promoproduct', collection:[],input_html: { selected: 2 }, label: false %></div>
|
|
|
|
<div class="col-md-2"><%= pro.input :min_qty , label: false%></div>
|
|
<div class="col-md-2"><%= pro.input :net_off , label: false %></div>
|
|
<div class="col-md-2"><%= pro.input :net_price , label: false %></div>
|
|
<div class="col-md-1"><%= pro.input :percentage , label: false %></div>
|
|
<div class="col-md-1" style="text-align:right"><%= pro.link_to_remove "X" %></div>
|
|
</div>
|
|
<% end %>
|
|
<div class="row">
|
|
<div class="col-md-12" style="text-align:right;"><%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary addProduct' %></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<br>
|
|
<div class="form-actions">
|
|
<%= f.button :submit %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
|
<div class="card">
|
|
<div class="body">
|
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
|
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<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'
|
|
// });
|
|
|
|
// $('#promotion_promo_start_hour').on('change', function(event) {
|
|
// $('#promotion_promo_start_hour').val($('#promotion_promo_start_hour').val().split(":")[0]+":00");
|
|
// });
|
|
|
|
// $('#promotion_promo_end_hour').on('change', function(event) {
|
|
// $('#promotion_promo_end_hour').val($('#promotion_promo_end_hour').val().split(":")[0]+":00");
|
|
// });
|
|
|
|
// $('.datepicker').bootstrapMaterialDatePicker({
|
|
// format: 'dddd DD MM YYYY',
|
|
// clearButton: true,
|
|
// weekStart: 1,
|
|
// time: false
|
|
// });
|
|
|
|
// $('.timepicker').bootstrapMaterialDatePicker({
|
|
// format: 'HH:mm',
|
|
// clearButton: true,
|
|
// date: false
|
|
// });
|
|
|
|
// var dayy = $("#promotion_promo_day").val().replace("[","").replace("]","");
|
|
// jQuery.each( dayy.split(","), function( i, d ) {
|
|
// $("input.selectDay[value='"+d+"']").prop( "checked", true );
|
|
// });
|
|
|
|
var form = document.getElementById("new_promotion");
|
|
var inputs = $("input");
|
|
var arr = [];
|
|
var count = 0;
|
|
var day = "[";
|
|
|
|
$(".selectDay").click(function() {
|
|
// debugger;
|
|
day = "[";
|
|
for (var j = 8; j <=15; j += 1){
|
|
if (inputs[j].type === "checkbox" && inputs[j].checked)
|
|
{
|
|
if(day == "["){
|
|
day = day + (inputs[j].value);
|
|
}
|
|
else{
|
|
day = day + "," + (inputs[j].value);
|
|
}
|
|
}
|
|
if(j==15)
|
|
{
|
|
day = day + "]";
|
|
}
|
|
}
|
|
document.getElementById("promotion_promo_day").value = '';
|
|
document.getElementById("promotion_promo_day").value = day;
|
|
});
|
|
|
|
// $("#promotion_original_product").select2();
|
|
// $(".item_code_place").select2();
|
|
|
|
$(".item_code_place").on('change', function(event) {
|
|
var ajax_url = "<%= settings_find_item_instance_path %>";
|
|
var item_code = this.value;
|
|
$.ajax({
|
|
type: "GET",
|
|
url: ajax_url,
|
|
data: 'item_code=' + item_code,
|
|
success: function (result) {
|
|
$("#promotion_original_product").empty();
|
|
var itemlist;
|
|
for (var i = 0; i < result.length; i++) {
|
|
itemlist += "<option value ="+result[i][1]+">"+result[i][0]+"</option>"
|
|
}
|
|
$("#promotion_original_product").append(itemlist);
|
|
//$("#promotion_original_product").select2();
|
|
}
|
|
});
|
|
});
|
|
|
|
//$(".promotion_promotion_products_item_code select").select2();
|
|
//$(".item_code_place1").select2();
|
|
|
|
callforpromoproduct();
|
|
|
|
$(".addProduct").on('click', function(event) {
|
|
setTimeout(function(){
|
|
// $(".promotion_promotion_products_item_code select").select2();
|
|
callforpromoproduct();
|
|
}, 0);
|
|
});
|
|
|
|
// for promotion products data showing
|
|
var promopdt = $(".promo_product");
|
|
jQuery.each( promopdt, function( i, ppdt ) {
|
|
var ajax_url = "<%= settings_find_parent_item_path %>";
|
|
var item_code = ppdt.value;
|
|
var select_id = ppdt.id;
|
|
$.ajax({
|
|
type: "GET",
|
|
url: ajax_url,
|
|
data: 'item_instance_code=' + item_code,
|
|
success: function (result) {
|
|
if(result.length > 0){
|
|
$("select#"+select_id).empty();
|
|
$("select#"+select_id).append("<option value='"+item_code+"'>"+result[0]+"</option>");
|
|
$("select#"+select_id).parent().parent().siblings("div.menu_item_choose").find("select").find("option[value='"+result[1]+"']").attr("selected","true")
|
|
// $("select#"+select_id).parent().parent().siblings("div.menu_item_choose").find("select").select2();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// promotion_promotion_products_attributes_0_item_code
|
|
function callforpromoproduct(){
|
|
//$(".item_code_place1").select2();
|
|
$(".item_code_place1").on('change', function(event) {
|
|
id = $(this).parent().next().find("select").attr("id");
|
|
var ajax_url = "<%= settings_find_item_instance_path %>";
|
|
var item_code = this.value;
|
|
$.ajax({
|
|
type: "GET",
|
|
url: ajax_url,
|
|
data: 'item_code=' + item_code,
|
|
success: function (result) {
|
|
$("select#"+id).empty();
|
|
var itemlist;
|
|
for (var i = 0; i < result.length; i++) {
|
|
itemlist += "<option value ="+result[i][1]+">"+result[i][0]+"</option>"
|
|
}
|
|
$("select#"+id).append(itemlist);
|
|
//$("select#"+id).select2();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
});
|
|
</script>
|