Update
This commit is contained in:
@@ -17,5 +17,4 @@ if (menu.menu_categories)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,44 +1,82 @@
|
||||
# Format for attributes json
|
||||
attr_format = []
|
||||
param_count = item.item_attributes.count
|
||||
# Format for attributes json
|
||||
item.item_attributes.each do|attr_id|
|
||||
menu_attr = MenuItemAttribute.find(attr_id)
|
||||
if attr_format.count == 0
|
||||
attr_format.push({ type: menu_attr.attribute_type, value: [] })
|
||||
end
|
||||
|
||||
attr_format.each do |af|
|
||||
if menu_attr.attribute_type == af[:type]
|
||||
af[:value].push(menu_attr.value)
|
||||
else
|
||||
new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
|
||||
attr_format.push(new_attr)
|
||||
# Format for attributes json
|
||||
if item.item_attributes.count > 0
|
||||
item.item_attributes.each do|attr_id|
|
||||
menu_attr = MenuItemAttribute.find(attr_id)
|
||||
if attr_format.count == 0
|
||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||
next
|
||||
end
|
||||
|
||||
break if attr_format.count > param_count
|
||||
end
|
||||
|
||||
param_count -= 1
|
||||
attr_format.each do |af|
|
||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||
if menu_attr.attribute_type == af[:type]
|
||||
af[:values].push(menu_attr.name)
|
||||
end
|
||||
else
|
||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||
attr_format.push(new_attr)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
if item.item_options.count > 0
|
||||
item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||
next
|
||||
end
|
||||
|
||||
opt_format.each do |of|
|
||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||
if menu_opt.option_type == of[:type]
|
||||
of[:values].push(menu_opt.name)
|
||||
end
|
||||
else
|
||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||
opt_format.push(new_opt)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.item_code item.item_code
|
||||
json.code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.image item.image_path.url
|
||||
json.description item.description
|
||||
json.Information item.information
|
||||
json.information item.information
|
||||
json.type item.type
|
||||
json.account_id item.account_id
|
||||
json.min_qty item.min_qty
|
||||
json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
json.item_sets item.item_sets
|
||||
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets do |its|
|
||||
json.id its.id
|
||||
json.name its.name
|
||||
json.alt_name its.alt_name
|
||||
json.min_selectable_qty its.min_selectable_qty
|
||||
json.max_selectable_qty its.max_selectable_qty
|
||||
json.instances its.menu_item_instances do |i|
|
||||
json.id i.id
|
||||
end
|
||||
end
|
||||
|
||||
json.attributes attr_format
|
||||
json.options item.item_options
|
||||
json.options opt_format
|
||||
# json.min_selectable_item item.min_selectable_item
|
||||
# json.max_selectable_item item.max_selectable_item
|
||||
|
||||
@@ -52,6 +90,7 @@ json.options item.item_options
|
||||
# json.item_attributes = item_instance.item_attributes
|
||||
|
||||
json.instances item.menu_item_instances do |is|
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
@@ -59,8 +98,8 @@ json.options item.item_options
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.item_attributes is.item_attributes
|
||||
json.item_sets is.item_sets
|
||||
json.values is.item_attributes
|
||||
# json.item_sets is.item_sets
|
||||
end
|
||||
|
||||
#Child Menu items
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
json.array! @menus do |menu|
|
||||
menu_json = json.array! @menus do |menu|
|
||||
json.id menu.id
|
||||
json.name menu.name
|
||||
json.valid_days menu.valid_days
|
||||
@@ -12,3 +12,4 @@ json.array! @menus do |menu|
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -25,6 +25,7 @@
|
||||
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
|
||||
<div class="input-append col-md-7 form-group pull-left">
|
||||
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-9">
|
||||
<input type="hidden" name="type" id="type" value="">
|
||||
<button type="submit" class="btn btn-primary btn-md">Search</button>
|
||||
<!-- <a href="modal-window" data-toggle= "modal" data-target="#modal-window" class="btn btn-primary btn-md" id="card_read" >Read Card</a> -->
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
|
||||
<hr class="hr_advance" />
|
||||
<li><%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissions", origami_commissions_path , :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissioners", origami_commissioners_path , :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissions", settings_commissions_path , :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commissioners", settings_commissioners_path , :tabindex =>"-1" %></li>
|
||||
<hr class="hr_advance" />
|
||||
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
|
||||
<hr class="hr_advance" />
|
||||
@@ -55,6 +55,7 @@
|
||||
<li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %></li>
|
||||
<li><%= link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="navbar-nav mr-auto">
|
||||
|
||||
@@ -49,48 +49,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Large modal -->
|
||||
<button class="btn btn-primary" data-toggle="modal" data-target=".sx_item_detailModal">Large modal</button>
|
||||
|
||||
<div class="modal fade sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<%= image_tag "logo.png" ,width: '', height: '', :style => '' %>
|
||||
<br><br>
|
||||
<div class="form-group">
|
||||
<h4 class="col-md-12">Quantity</h4>
|
||||
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<h4 class="col-md-6">Total</h4>
|
||||
<h4 class="col-md-6" id="total_price"> 2500 Ks</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<h4>Options</h4>
|
||||
|
||||
<h4>Attributes</h4>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal" id="save_order">Add Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true">
|
||||
@@ -130,6 +88,51 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Large modal -->
|
||||
|
||||
<div class="modal fade sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<%= image_tag "logo.png" ,width: '', height: '', :style => '' %>
|
||||
<br><br>
|
||||
<div class="form-group">
|
||||
<h4 class="col-md-12">Quantity</h4>
|
||||
<input type="number" name="qty" class="form-control col-md-12 input-number change_qty" id="change_qty" value="" min="1" max="100">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<h4 class="col-md-6">Total</h4>
|
||||
<h4 class="col-md-6" id="total_price"></h4>
|
||||
<p class="hidden" id="unit_price"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7 item-detail">
|
||||
<div class="hide attr-alert alert-danger" role="alert">
|
||||
<strong>Oh !</strong>Have not attribute for this item Please select another attribute .
|
||||
</div>
|
||||
<div class="attributes-list">
|
||||
</div>
|
||||
<div class="option-list">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
|
||||
<button type="button" class="btn btn-success add_to_order" data-dismiss="modal" id="add_to_order">Add to Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function(){
|
||||
@@ -141,6 +144,13 @@ $(function(){
|
||||
show_menu_item_list(url);
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
$(".change_qty").change(function(){
|
||||
qty = $(this).val();
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(qty*price);
|
||||
|
||||
});
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item){
|
||||
@@ -154,43 +164,36 @@ $(function(){
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
menu_items = data.menu_items;
|
||||
console.log(data);
|
||||
|
||||
for(var field in menu_items) {
|
||||
|
||||
var code = menu_items[field].instances[0].code
|
||||
var name = menu_items[field].instances[0].name
|
||||
var price = parseFloat(menu_items[field].instances[0].price).toFixed(2);
|
||||
var is_available = menu_items[field].instances[0].is_available
|
||||
var is_on_promotion = menu_items[field].instances[0].is_on_promotion
|
||||
var item_attributes = menu_items[field].instances[0].item_attributes
|
||||
var promotion_price = menu_items[field].instances[0].promotion_price
|
||||
instances = menu_items[field].instances ;
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
code = instances[i].code;
|
||||
name = instances[i].name;
|
||||
price = parseFloat(instances[i].price).toFixed(2);
|
||||
is_available = instances[i].is_available ;
|
||||
is_on_promotion = instances[i].is_on_promotion;
|
||||
item_attributes = instances[i].values;
|
||||
promotion_price = instances[i].promotion_price;
|
||||
code = instances[i].code;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
row = '<div class="card">'
|
||||
row = '<div class="card">'
|
||||
+'<div class="card-head" style="line-height:14px;">'
|
||||
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
|
||||
+'<div class="col-md-3 add_icon"'
|
||||
+'data-id="'+ menu_items[field].name +'"'
|
||||
+'data-item-code="'+ menu_items[field].item_code +'"'
|
||||
+'data-name="'+ menu_items[field].name +'"'
|
||||
+'data-price="'+ price +'"'
|
||||
+'data-available="'+ is_available +'"'
|
||||
+'data-promotion="'+ is_on_promotion +'"'
|
||||
+'data-attributes="'+ item_attributes +'"'
|
||||
+'data-instance-code="'+ code +'"'
|
||||
+'data-instance="'+ name +'"'
|
||||
+'data-promotion-price="'+ promotion_price +'"'
|
||||
+'>'
|
||||
+"<div class='col-md-3 add_icon' data-item-code='"+ menu_items[field].code +"' data-name='"+ menu_items[field].name +"' data-price = '"+ price +"' data-instance-code = '"+ code +"' data-instance = '"+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"+ JSON.stringify(item_attributes) +"'>"
|
||||
+'<i class="fa fa-plus "'
|
||||
+ 'style="margin-top:4px;">'
|
||||
+'</i></div>'
|
||||
+'</div>'
|
||||
|
||||
+'<div class="menu_item_box" data-toggle="modal" data-target=".sx_item_detailModal">'
|
||||
+"<div class='menu_item_box' data-instance = '"+JSON.stringify(menu_items[field].instances)+"' data-id = '"+JSON.stringify(menu_items[field].attributes)+"' data-item = '"+JSON.stringify(item_attributes)+"' data-toggle='modal' data-target='.sx_item_detailModal'>"
|
||||
|
||||
+'<div class="card-block">'
|
||||
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
|
||||
+'</div>'
|
||||
@@ -206,7 +209,115 @@ $(function(){
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
//end show detail function
|
||||
//end show list function
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$('.attributes-list').empty();
|
||||
$('.attr-alert').addClass('hide');
|
||||
|
||||
data = $(this).parent().children().children('.add_icon');
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('item');
|
||||
instances = $(this).data('instance');
|
||||
|
||||
for(var field in attributes) {
|
||||
value = attributes[field]["values"];
|
||||
type = attributes[field]["type"]
|
||||
row = "<h4>"+attributes[field]["type"]+"</h4>"
|
||||
|
||||
$(value).each(function(i){
|
||||
status ="";
|
||||
if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
|
||||
status = "selected-option";
|
||||
}
|
||||
row +="<button id='selected-option' data-instances='"+JSON.stringify(instances)+"' data-type='"+type+"' data-value='"+value[i]+"' class='btn btn-default attribute_btn "+ status +" "+ type +" '>"+value[i]+"</button>";
|
||||
});
|
||||
$(".attributes-list").append(row);
|
||||
}
|
||||
|
||||
$('#change_qty').val(1);
|
||||
$('#title_name').text(data.attr('data-name'));
|
||||
$('#item_code').text(data.attr('data-item-code'));
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
$('#unit_price').text(data.attr('data-price'));
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
console.log(instances);
|
||||
if ($(".attribute_btn").attr("data-type")==type){
|
||||
$('.'+type).removeClass("selected-option");
|
||||
}
|
||||
$(this).addClass('selected-option');
|
||||
selected_item = $('.selected-option').text();
|
||||
qty = $('#change_qty').val();
|
||||
total_price = 0;
|
||||
|
||||
for(var field in instances) {
|
||||
item_attr = instances[field].values;
|
||||
if(parseInt(jQuery.inArray(selected_item, item_attr))!== -1){
|
||||
unit_price = instances[field].price
|
||||
total_price = qty * unit_price
|
||||
$('#instance_name').text(instances[field].name);
|
||||
$('#instance_code').text(instances[field].code);
|
||||
$('#promotion_price').text(instances[field].promotion_price);
|
||||
$('#total_price').text(total_price);
|
||||
$('#unit_price').text(unit_price);
|
||||
}
|
||||
}
|
||||
if (total_price == 0) {
|
||||
$('.attr-alert').removeClass('hide');
|
||||
$('#total_price').text(total_price);
|
||||
}else{
|
||||
$('.attr-alert').addClass('hide');
|
||||
$('#total_price').text(total_price);
|
||||
}
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '.add_to_order', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
unit_price = $('#unit_price').text();
|
||||
qty = $('#change_qty').val();
|
||||
var item_row = $('.selected-option');
|
||||
var arr = [];
|
||||
|
||||
var attribute_arr = [];
|
||||
$(item_row).each(function(i){
|
||||
value = $(item_row[i]).attr('data-value');
|
||||
arr = {value};
|
||||
|
||||
});
|
||||
console.log(arr);
|
||||
if(total_price > 0){
|
||||
|
||||
$('.add_to_order').attr('data-item-code',$('#item_code').text());
|
||||
$('.add_to_order').attr('data-name',$('#title_name').text());
|
||||
$('.add_to_order').attr('data-price',unit_price);
|
||||
$('.add_to_order').attr('data-instance-code',$('#instance_code').text());
|
||||
$('.add_to_order').attr('data-instance',$('#instance_name').text());
|
||||
$('.add_to_order').attr('data-promotion-price',$('#promotion_price').text());
|
||||
$('.add_to_order').attr('data-attributes',$('#instance_name').text());
|
||||
|
||||
var item_data = $(this);
|
||||
show_item_detail(item_data);
|
||||
calculate_sub_total();
|
||||
}else{
|
||||
$.alert({
|
||||
title: 'Alert!',
|
||||
content: 'Please select another item',
|
||||
type: 'red',
|
||||
typeAnimated: true,
|
||||
btnClass: 'btn-danger',
|
||||
});
|
||||
}
|
||||
|
||||
}); //End Add Icon Click
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
@@ -219,9 +330,9 @@ $(function(){
|
||||
qty = 1;
|
||||
append = 0;
|
||||
price = parseFloat(data.attr('data-price')).toFixed(2);
|
||||
instance_code = data.attr('data-instance');
|
||||
instance_name = data.attr('data-instance');
|
||||
|
||||
if (instance_code == "undefined"){
|
||||
if (instance_name == "undefined"){
|
||||
instance = '';
|
||||
}else{
|
||||
instance = "("+data.attr('data-instance')+")";
|
||||
@@ -231,11 +342,13 @@ $(function(){
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
$(item_row).each(function(i){
|
||||
if ($(item_row[i]).attr('data-code') == data.attr('data-item-code')) {
|
||||
item_code = $(item_row[i]).attr('data-code');
|
||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
|
||||
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')) {
|
||||
qty = parseInt($(item_row[i]).children('#item_qty').text()) +1;
|
||||
$(item_row[i]).children('#item_qty').text(qty);
|
||||
parseFloat($(item_row[i]).children('#item_price').text(price*qty)).toFixed(2);
|
||||
|
||||
append = 1;
|
||||
}else{
|
||||
qty = 1;
|
||||
@@ -243,9 +356,9 @@ $(function(){
|
||||
});
|
||||
|
||||
if (append===0) {
|
||||
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "'data-code='"+data.attr('data-item-code')+"'>"
|
||||
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"+data.attr('data-instance-code')+"' data-attributes='"+data.attr('data-attributes')+"'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance + '</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
@@ -253,7 +366,6 @@ $(function(){
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//click item row for update qty
|
||||
@@ -265,14 +377,6 @@ $(function(){
|
||||
$('#modal-qty').val(qty);
|
||||
});
|
||||
|
||||
//click item row for update qty
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
|
||||
data = $(this).parent().children().children('.add_icon');
|
||||
$('#title_name').text(data.attr('data-name'));
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
//click remove buttom in modal box
|
||||
$('#sx_itemModal').on('click','#remove', function(){
|
||||
$('.summary-items tr').filter(function(){
|
||||
@@ -321,7 +425,6 @@ $(function(){
|
||||
|
||||
function summary_items_filter(){
|
||||
$('.summary-items tr').filter(function(){
|
||||
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
qty = $('#modal-qty').val();
|
||||
price = parseFloat($(this).attr('data-price'));
|
||||
@@ -406,6 +509,17 @@ $(function(){
|
||||
padding-top: 100px;
|
||||
|
||||
}
|
||||
.selected-option {
|
||||
color: #fff !important;
|
||||
background-color: green !important;
|
||||
}
|
||||
.attribute_btn {
|
||||
white-space: normal !important;
|
||||
height: 60px;
|
||||
width: 90px;
|
||||
margin-bottom: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami, @commissioner]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.label :emp_id %>
|
||||
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %><br/>
|
||||
<%= f.label :commission_type %>
|
||||
<%= f.select :commission_type, Commission.all.map{ |l| [l.menu_item.name, l.id] } %>
|
||||
<br/>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div><br/>
|
||||
|
||||
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-info' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,47 +0,0 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
|
||||
|
||||
<span style="float: right">
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Commissioner</h4>
|
||||
<table class="table">
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td style="width:20%">Name</td>
|
||||
<td><%= @commissioner.name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Employee Name</td>
|
||||
<td>
|
||||
<%= @commissioner.employee.name rescue '-' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Commission Type</td>
|
||||
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Active</td>
|
||||
<td><%= @commissioner.is_active %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Created By</td>
|
||||
<td><%= Employee.find(@commissioner.created_by).name %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Edit', edit_origami_commissioner_path(@commissioner), class: 'btn btn-info' %>
|
||||
<%= link_to 'Destroy', origami_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -22,6 +22,7 @@
|
||||
<%= form_tag path, :id => "filter_form", :method => :get do %>
|
||||
<div class="input-append col-md-7 form-group pull-left">
|
||||
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
|
||||
<input type="hidden" name="type" id="type" value="">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -258,12 +259,23 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "get_customer" ,
|
||||
data: { filter : customer_mamber_card_no },
|
||||
data: { filter : customer_mamber_card_no ,type :"card"},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
customer_id = data[0].customer_id;
|
||||
customer_name = data[0].name;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
success: function(data) {
|
||||
if (data[0].customer_id == false) {
|
||||
$.alert({
|
||||
title: 'Alert!',
|
||||
content: data[0].message,
|
||||
type: 'red',
|
||||
typeAnimated: true,
|
||||
btnClass: 'btn-danger',
|
||||
});
|
||||
}else{
|
||||
customer_id = data[0].customer_id;
|
||||
customer_name = data[0].name;
|
||||
update_sale(customer_id, customer_name,sale_id);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -282,6 +294,7 @@
|
||||
if(cardNo.length == 16){
|
||||
$("#paypar_account_no").val(cardNo);
|
||||
$("#search").val(cardNo);
|
||||
$("#type").val("card")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +1,43 @@
|
||||
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<%= f.error_notification %>
|
||||
<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<%= f.error_notification %>
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-inputs">
|
||||
|
||||
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
|
||||
|
||||
<label>Dining Name:</label>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<label>Commissioner Name:</label>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
|
||||
<br/><br/>
|
||||
|
||||
<%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %>
|
||||
|
||||
<%= f.input :out_time, :placeholder => "From Date", :class => "form-control" %>
|
||||
|
||||
</div><br>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Create", :class => 'btn btn-primary ', :id => 'create' %>
|
||||
<%= f.button :submit, "Update", :class => 'btn btn-primary ', :disabled => '', :id => 'update' %>
|
||||
<%= f.button :button, "Reset", :class => 'btn btn-danger ', :id => 'reset' %>
|
||||
</div>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
|
||||
<label>Dining Name:</label>
|
||||
<%= @table.name %>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<label>Commissioner Name:</label>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||
<label>In time</label>
|
||||
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
|
||||
<label>Out time</label>
|
||||
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
|
||||
</div><br>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
|
||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
|
||||
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
$('.datepicker').datepicker({
|
||||
format : 'dd-mm-yyyy',
|
||||
autoclose: true
|
||||
$(document).ready(function () {
|
||||
$('#reset').click(function () {
|
||||
location.reload();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$('.datepicker').attr('ReadOnly','true');
|
||||
$('.datepicker').css('cursor','pointer');
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :dinning_id %>
|
||||
<%= f.input :commissioner_ids %>
|
||||
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
|
||||
<%= f.input :in_time %>
|
||||
<%= f.input :out_time %>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-md-8">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th>Dining Facility Name</th>
|
||||
<th>Commissioner Ids</th>
|
||||
<th>In time</th>
|
||||
@@ -15,65 +16,67 @@
|
||||
<tbody>
|
||||
<% @juties_in.each do |in_juty| %>
|
||||
<tr class="injuty_tr" data-ref="<%= in_juty.id %>">
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||
<td>
|
||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check"></td>
|
||||
<td><%= in_juty.dining_facility.name rescue '-' %></td>
|
||||
<td><%= in_juty.commissioner.name rescue '-' %></td>
|
||||
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
|
||||
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
|
||||
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
|
||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginate @juties_in %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-4">
|
||||
<%= render 'assign_in_juty', in_juty: @in_juty ,table: @table %>
|
||||
<%= render 'assign_in_juty', in_juty: @in_juty, table: @table %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-1">
|
||||
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).on('click',".injuty_tr",function(){
|
||||
debugger;
|
||||
// if(this.checked){
|
||||
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||
//$( "#checkbox_check" ).prop( "checked", true );
|
||||
|
||||
var in_juty_id = $(this).attr('data-ref');
|
||||
var table_id = "<%= @table.id %>";
|
||||
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
||||
$(document).on('click', ".injuty_tr", function () {
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
// Selected for Taxes
|
||||
$('#in_juty_commissioner_ids').val(data.commissioner.name);
|
||||
$('#in_juty_in_time').val(data.in_time);
|
||||
$('#in_juty_out_time').val(data.out_time);
|
||||
$(this).closest('tr').find('.checkbox_check').prop("checked", true);
|
||||
|
||||
$('#update').removeAttr('disabled');
|
||||
$('#update').attr('value', 'Update');
|
||||
$('#create').attr('disabled','disabled');
|
||||
var in_juty_id = $(this).attr('data-ref');
|
||||
var table_id = "<%= @table.id %>";
|
||||
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
|
||||
|
||||
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
|
||||
var id = customer_id;
|
||||
$("#new_customer").attr('id', id);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
|
||||
$(".edit_customer").attr('id', id);
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
|
||||
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
success: function (data) {
|
||||
|
||||
// }
|
||||
})
|
||||
</script>
|
||||
$('#in_juty_id').val(data.in_juty.id);
|
||||
$('#in_juty_commissioner_ids').val(data.commissioner.id);
|
||||
$('#in_juty_in_time').val(data.in_juty.in_time);
|
||||
$('#in_juty_out_time').val(data.in_juty.out_time);
|
||||
|
||||
$('#update').removeAttr('disabled').val('');
|
||||
$('#update').attr('value', 'Update');
|
||||
$('#create').attr('disabled', 'disabled');
|
||||
|
||||
$("#new_in_juty").attr('class', 'simple_form edit_in_juty');
|
||||
var id = "edit_in_juty_" + in_juty_id;
|
||||
$("#new_in_juty").attr('id', id);
|
||||
|
||||
$(".edit_in_juty").attr('id', id);
|
||||
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
|
||||
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
|
||||
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/origami/table/' + "<%= @table.id %>";
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<%= form_tag report_path, :method => :get, :id => "frm_report", :class => "form" do %>
|
||||
<% if period_type != false %>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="">Select Date Range</label>
|
||||
<% if @daterange %>
|
||||
<input class="form-control" name="daterange" id="daterange" value="<%= @daterange %>" type="text" placeholder="Date Range" readonly="true">
|
||||
<% else %>
|
||||
<input class="form-control" name="daterange" id="daterange" type="text" placeholder="Date Range" readonly="true">
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="">Commissioner</label>
|
||||
<select class="form-control" name="commissioner" id="commissioner">
|
||||
<option value=""></option>
|
||||
<% @commissioner.each do |c| %>
|
||||
<% if @com_id == c.id %>
|
||||
<option value="<%= c.id %>" selected><%= c.name %></option>
|
||||
<% else %>
|
||||
<option value="<%= c.id %>"><%= c.name %></option>
|
||||
<% end %> %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="submit" value="Generate Report" class='btn btn-primary'>
|
||||
</div>
|
||||
<div class="form-group col-md-2 margin-top-20">
|
||||
<input type="button" value="Clear Filter" id="clear_filter" class='btn btn-danger'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#commissioner').select2({
|
||||
placeholder: 'Select Commissioner'
|
||||
});
|
||||
|
||||
$('#clear_filter').click(function () {
|
||||
$('#daterange').val('');
|
||||
$('#commissioner').val('').text('');
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').daterangepicker({
|
||||
autoUpdateInput: false,
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD'
|
||||
}
|
||||
},
|
||||
function (start, end, label) {
|
||||
$('input[name="daterange"]').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('apply.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
|
||||
|
||||
from_date = picker.startDate.format('YYYY-MM-DD 00:00:00');
|
||||
to_date = picker.endDate.format('YYYY-MM-DD 23:59:59');
|
||||
});
|
||||
|
||||
$('input[name="daterange"]').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$('input[name="daterange"]').val('');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
81
app/views/reports/commission/index.html.erb
Normal file
81
app/views/reports/commission/index.html.erb
Normal file
@@ -0,0 +1,81 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= dashboard_path %>">Home</a></li>
|
||||
<li>Commission Report</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<%= render :partial => 'commission_report_filter',
|
||||
:locals => {:period_type => true, :shift_name => true, :report_path => reports_commission_index_path} %>
|
||||
<hr/>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<a href="javascript:export_to('<%= reports_commission_index_path %>.xls')" class="btn btn-default">Export to
|
||||
Excel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= result.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= result.commission.menu_item.name rescue '-' %>
|
||||
</td>
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
|
||||
</tr>
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.to_f %>
|
||||
<% end %>
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="2"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
52
app/views/reports/commission/index.xls.erb
Normal file
52
app/views/reports/commission/index.xls.erb
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="container margin-top-20">
|
||||
<div class="card row">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commissioner Name</th>
|
||||
<th>Product Name</th>
|
||||
<th>Qty</th>
|
||||
<th>Commission Price</th>
|
||||
<th>Commission Amount</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% total_qty = 0 %>
|
||||
<% total_price = 0 %>
|
||||
<% total_amount = 0 %>
|
||||
|
||||
<% @transaction.each do |result| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= result.commissioner.name rescue '-' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= result.commission.menu_item.name rescue '-' %>
|
||||
</td>
|
||||
<td><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %></td>
|
||||
<td><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %></td>
|
||||
<td><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %></td>
|
||||
</tr>
|
||||
<% total_qty += result.qty.to_f %>
|
||||
<% total_price += result.price.to_f %>
|
||||
<% total_amount += result.amount.to_f %>
|
||||
<% end %>
|
||||
|
||||
<tr style="border-top: 3px solid grey;">
|
||||
<td colspan="2"></td>
|
||||
<td><b><%= sprintf("%.2f", total_qty) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_price) rescue '-' %></b></td>
|
||||
<td><b><%= sprintf("%.2f", total_amount) rescue '-' %></b></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
42
app/views/settings/commissioners/_form.html.erb
Normal file
42
app/views/settings/commissioners/_form.html.erb
Normal file
@@ -0,0 +1,42 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:settings, @commissioner]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.label :emp_id, 'Employee' %>
|
||||
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %>
|
||||
<br/>
|
||||
<%= f.label :commission_id, 'Commission' %><br/>
|
||||
<%= f.select :commission_id, Commission.all.map {|l| [l.menu_item.name, l.id]}, {prompt: 'Select a Product'}, {class: 'form-control'} %>
|
||||
<br/>
|
||||
<%= f.label :joined_date %><br/>
|
||||
<%= f.text_field :joined_date, {class: 'form-control', id: 'joined_date', readonly: true} %><br/>
|
||||
<%= f.label :resigned_date %><br/>
|
||||
<%= f.text_field :resigned_date, {class: 'form-control', id: 'resigned_date', readonly: true} %><br/>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', settings_commissioners_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-info' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#joined_date').datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
$('#resigned_date').datepicker({
|
||||
format: 'yyyy-mm-dd',
|
||||
autoclose: true
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
|
||||
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissioners_path %>">Commissioners</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1,9 +1,9 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
|
||||
<li>Commissioner</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commissioner_path, :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_settings_commissioner_path, :class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -16,8 +16,10 @@
|
||||
<th>Name</th>
|
||||
<th>Employee Name</th>
|
||||
<th>Commission type</th>
|
||||
<th>Joined Date</th>
|
||||
<th>Resigned Date</th>
|
||||
<th>Active</th>
|
||||
<th colspan="3"></th>
|
||||
<th colspan="4"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -29,10 +31,12 @@
|
||||
<%= commissioner.employee.name rescue '-' %>
|
||||
</td>
|
||||
<td><%= commissioner.commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
|
||||
<td><%= commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
|
||||
<td><%= commissioner.is_active %></td>
|
||||
<td><%= link_to 'Show', origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
<td><%= link_to 'Show', settings_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_commissioner_path(commissioner) %></td>
|
||||
<td><%= link_to 'Destroy', settings_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
|
||||
<li><a href="<%= settings_commissioners_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissioners_path %>">Commissioners</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
132
app/views/settings/commissioners/show.html.erb
Normal file
132
app/views/settings/commissioners/show.html.erb
Normal file
@@ -0,0 +1,132 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= settings_commissioner_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissioner_path %>">Commissioners</a></li>
|
||||
|
||||
<span style="float: right">
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#info" role="tab">Info</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#transaction" id="transaction_tab" role="tab">Transaction</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content">
|
||||
<!--- Panel 0 - Info -->
|
||||
<div class="tab-pane active" id="info" role="tabpanel" style="max-height:670px; overflow:auto">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:20%">Name</td>
|
||||
<td><%= @commissioner.name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Employee Name</td>
|
||||
<td><%= @commissioner.employee.name rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Commission Type</td>
|
||||
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Joined Date</td>
|
||||
<td><%= @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Resigned Date</td>
|
||||
<td><%= @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d') rescue '-' %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Active</td>
|
||||
<td><%= @commissioner.is_active %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:20%">Created By</td>
|
||||
<td><%= Employee.find(@commissioner.created_by).name %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= link_to 'Back', settings_commissioners_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Edit', edit_settings_commissioner_path(@commissioner), class: 'btn btn-info' %>
|
||||
<%= link_to 'Destroy', settings_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--- Panel 1 - Transaction -->
|
||||
<div class="tab-pane" id="transaction" role="tabpanel" style="max-height:670px; overflow:auto">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
|
||||
<table class="table" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= 'Product Type' %></th>
|
||||
<th><%= 'Product Name' %></th>
|
||||
<th><%= 'Qty' %></th>
|
||||
<th><%= 'Price' %></th>
|
||||
<th><%= 'Amount' %></th>
|
||||
<th><%= 'Date' %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#transaction_tab").click(function () {
|
||||
get_transaction();
|
||||
});
|
||||
|
||||
function get_transaction() {
|
||||
var commissioner_id = <%= @commissioner.id %>
|
||||
paramlist = 'commissioner_id=' + commissioner_id ;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '<%= settings_get_transaction_by_commissioner_path() %>',
|
||||
data: paramlist,
|
||||
success: function (data) {
|
||||
// $('#myTable').DataTable().destroy();
|
||||
$('#myTable tbody > tr').remove();
|
||||
$.each(data, function (i, item) {
|
||||
tr = "<tr>" + "<td>" + data[i][0].product_type + "</td>" + "<td>" + data[i][1] + "</td>" + "<td>" + data[i][0].qty + "</td>" + "<td>" + data[i][0].price + "</td>" + "<td>" + data[i][0].amount + "</td>" + "<td>" + new Date(data[i][0].updated_at).toISOString().split('T')[0] + "</td>" + "</tr>";
|
||||
$('#myTable tbody').append(tr);
|
||||
});
|
||||
// $('#myTable').DataTable({
|
||||
// data: data,
|
||||
// columns: [
|
||||
// {data: 'product_type'},
|
||||
// {data: 'product_code'},
|
||||
// {data: 'commission_id'},
|
||||
// {data: 'qty'},
|
||||
// {data: 'price'},
|
||||
// {data: 'amount'}
|
||||
// ],
|
||||
// "order": [[0, "desc"]]
|
||||
// });
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -1,17 +1,17 @@
|
||||
<div class="col-md-3">
|
||||
<%= simple_form_for([:origami,@commission]) do |f| %>
|
||||
<%= simple_form_for([:settings,@commission]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.label :product_id %>
|
||||
<%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
|
||||
<%= f.input :amount %>
|
||||
<%= f.label :product_code, 'Product' %>
|
||||
<%= f.collection_select :product_code, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
|
||||
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
|
||||
<%= f.input :amount %>
|
||||
<label><%= f.check_box :is_active %> Active </label>
|
||||
|
||||
</div><br>
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Back', settings_commissions_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-info' %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1,9 +1,9 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Home</a></li>
|
||||
<li>Commissions</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path, :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")), new_settings_commission_path, :class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -14,8 +14,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Name</th>
|
||||
<th>Commission Type</th>
|
||||
<th>Amount</th>
|
||||
<th>Commission type</th>
|
||||
<th>Active</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
@@ -25,12 +25,12 @@
|
||||
<% @commissions.each do |commission| %>
|
||||
<tr>
|
||||
<td><%= commission.menu_item.name rescue '-' %></td>
|
||||
<td><%= commission.amount rescue '-' %></td>
|
||||
<td><%= commission.commission_type rescue '-' %></td>
|
||||
<td><%= commission.amount rescue '-' %></td>
|
||||
<td><%= commission.is_active rescue '-' %></td>
|
||||
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
<td><%= link_to 'Show', settings_commissions_path(commission) %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_commission_path(commission) %></td>
|
||||
<td><%= link_to 'Destroy', settings_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
@@ -1,8 +1,8 @@
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= origami_root_path %>">Home</a></li>
|
||||
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_commissions_path %>">Commissions</a></li>
|
||||
|
||||
<span style="float: right">
|
||||
</span>
|
||||
@@ -32,9 +32,9 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Edit', edit_origami_commission_path(@commission), class: 'btn btn-info' %>
|
||||
<%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
|
||||
<%= link_to 'Back', settings_commissions_path, class: 'btn btn-success' %>
|
||||
<%= link_to 'Edit', edit_settings_commission_path(@commission), class: 'btn btn-info' %>
|
||||
<%= link_to 'Destroy', settings_commissions_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,5 +13,4 @@
|
||||
$("#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>
|
||||
|
||||
Reference in New Issue
Block a user