update add order

This commit is contained in:
Aung Myo
2017-08-28 18:27:22 +06:30
parent 2522950019
commit 1372285c7f
8 changed files with 509 additions and 290 deletions

View File

@@ -1,146 +1,3 @@
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
</li>
<% end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7">
<div class="card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<div class="card-header">
<div>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%>
<p class="hidden" id="table_id"><%=@table_id%></p>
<p class="hidden" id="table_type"><%=@table_type%></p>
</div>
</div>
<div class="card-block">
<div class="card-text" style="max-height:550px; overflow:auto"">
<table class="table table-striped summary-items">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table>
<button type="button" class="btn btn-success create" id="create_order" disabled="disabled">Create Order</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="item_name" id="modal-item-name"></td>
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
</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">Update</button>
</div>
</div>
</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;">&times;</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>
<p class="hidden" id="instance_code"></p>
<p class="hidden" id="instance_name"></p>
<p class="hidden" id="promotion_price"></p>
<p class="hidden" id="item_instances"></p>
<p class="hidden" id="item_code"></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(){
//click menu sidebar menu category
@@ -188,20 +45,32 @@ $(function(){
});
qty = 1;
options = [];
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-item-code='"+ menu_items[field].code +"' data-name='"+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"+ price +"' data-instance-code = '"+ code +"' data-instance = '"+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"+ JSON.stringify(item_attributes) +"'>"
+"<div class='col-md-3 add_icon' data-item-code='"+ menu_items[field].code +"' data-name='"
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ options +"'>"
+'<i class="fa fa-plus "'
+ 'style="margin-top:4px;">'
+'</i></div>'
+'</div>'
+"<div class='menu_item_box' data-item-code='"+ menu_items[field].code +"' 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='menu_item_box' data-item-code='"
+ menu_items[field].code +"' data-instance = '"
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(menu_items[field].options)+"' data-toggle='modal' data-target='.sx_item_detailModal'>"
+'<div class="card-block">'
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
+'<img id="logo" src="/image/logo.png">'
+'</div>'
+'<div class="card-footer">'
@@ -219,6 +88,7 @@ $(function(){
//click item row for add order
$(document).on('click', '.menu_item_box', function(event){
$('.attributes-list').empty();
$('.options-list').empty();
$('.attr-alert').addClass('hide');
$('.add_to_order').removeAttr('data-instance-code');
$('.add_to_order').removeAttr('data-instance');
@@ -228,27 +98,57 @@ $(function(){
$('.add_to_order').removeAttr('data-qty');
$('.add_to_order').removeAttr('data-name');
$('.add_to_order').removeAttr('data-attributes');
$('.add_to_order').removeAttr('data-options');
data = $(this).parent().children().children('.add_icon');
attributes = $(this).data('id');
selected_item = $(this).data('item');
instances = $(this).data('instance');
attributes = $(this).data('id');
selected_item = $(this).data('item');
instances = $(this).data('instance');
item_options = $(this).data('option');
instance_attributes = []
for(var field in instances) {
value = instances[field].values;
$(value).each(function(i){
options = value[i];
instance_attributes.push(options);
});
}
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
row = "<h4>"+attributes[field]["type"]+"</h4>"
$(value).each(function(i){
disabled = ""
status ="";
if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
status = "selected-option";
status = "selected-attribute";
}
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>";
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
disabled = "disabled";
}
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
+type+"' data-value='"+value[i]+"' class='btn btn-default attribute_btn "
+ status +" "+ type +" "+ disabled +" '>"
+value[i]
+"</button>";
});
$(".attributes-list").append(row);
}
for(var field in item_options) {
value = item_options[field]["values"];
type = item_options[field]["type"];
row = "<h4>"+type+"</h4>"
$(value).each(function(i){
row +="<button class='btn btn-default option_btn "+ type +"' data-type='"+type+"' data-value='"
+value[i]+"'>"+value[i]+"</button>";
});
$(".options-list").append(row);
}
$('#change_qty').val(1);
$('#item_instances').text(instances);
$('#title_name').text(data.attr('data-name'));
@@ -263,46 +163,51 @@ $(function(){
type = $(this).data('type');
instances = $(this).data('instances');
if ($(".attribute_btn").attr("data-type")==type){
$('.'+type).removeClass("selected-option");
$('.'+type).removeClass("selected-attribute");
}
$(this).addClass('selected-option');
selected_item = $('.selected-option').text();
$(this).addClass('selected-attribute');
var selected_attr = get_selected_attributes('selected-attribute');
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
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
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 select option icon for add
$(document).on('click', '.option_btn', function(event){
value = $(this).data('value');
type = $(this).data('type');
if ($(".option_btn").attr("data-type")==type){
$('.'+type).removeClass("selected-option");
}
$(this).addClass('selected-option');
}); //End selecct attribute buttom
// click add order
$(document).on('click', '.add_to_order', function(event){
total_price = $('#total_price').text();
qty = parseInt($('#change_qty').val());
var item_row = $('.selected-option');
var item_row = $('.selected-attribute');
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
for(var field in instances) {
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
@@ -317,20 +222,10 @@ $(function(){
$('.add_to_order').attr('data-qty',qty);
$('.add_to_order').attr('data-name',$('#title_name').text());
$('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
var item_data = $(this);
show_item_detail(item_data);
calculate_sub_total();
// if(total_price > 0){
// }else{
// $.alert({
// title: 'Alert!',
// content: 'Please select another item',
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
// }
}); //End Add Icon Click
@@ -378,7 +273,12 @@ $(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')+"' data-instance-code='"+data.attr('data-instance-code')+"' data-attributes='"+data.attr('data-attributes')+"' data-row ='"+rowCount+ "'>"
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')+"' data-options ='"
+data.attr('data-options')+"' data-row ='"+rowCount+ "'>"
+'<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-qty" id="item_qty">' + qty + '</td>'
@@ -394,12 +294,20 @@ $(function(){
$("#create_order").on('click', function(e){
e.preventDefault();
$( "#loading_wrapper" ).show();
var table_id = $('#table_id').text();
var table_id = $('#table_id').text();
var booking_id = $('#booking_id').text();
if (!booking_id.length > 0) {
console.log("hi")
var params = {'order_source': "cashier", 'order_type': "dine_in",
'customer_id': "", 'guest_info': "",'booking_id':booking_id,
'table_id': table_id,
'order_items': order_items };
}
var table_type = $('#table_type').text();
var order_items = get_order_item_rows();
var order_items = JSON.stringify(get_order_item_rows());
console.log(order_items);
var ajax_url = '<%= api_orders_path %>';
var ajax_url = '../addorders/create';
console.log(ajax_url)
var params = {'order_source': "cashier", 'order_type': "dine_in",
'customer_id': "", 'guest_info': "",
@@ -410,6 +318,7 @@ $(function(){
type: "POST",
url: ajax_url,
data: params,
dataType: "json",
success:function(result){
$( "#loading_wrapper" ).show();
$.confirm({
@@ -421,10 +330,10 @@ $(function(){
btnClass: 'btn-green',
action: function(){
if(table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
window.location.href = "/origami/table/" + table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
window.location.href = "/origami/room/" + table_id
}
}
}
@@ -512,101 +421,21 @@ $(function(){
order_item.order_item_id = $(item_row[i]).attr('data-row');
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
order_item.quantity = $(item_row[i]).children('#item_qty').text();
order_item.options = [];
order_item.options = $(item_row[i]).attr('data-options');
order_items.push(order_item);
});
return order_items;
}
// $(item_row).each(function(i){
// value = $(item_row[i]).attr('data-value');
// str = value;
// attribute_arr.push(str);
// });
});
</script>
<style type="text/css">
.card-head{
height: 40px;
background-color: #54A5AF;
padding:5px;
color :#fff;
}
.card-block {
padding: 0.3rem !important;
}
@media (min-width: 34em) {
.card-columns {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
function get_selected_attributes(selected_class) {
var item_row = $('.'+selected_class);
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
return attribute_arr;
}
@media (min-width: 48em) {
.card-columns {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
}
@media (min-width: 62em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
@media (min-width: 75em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
.nav-tabs .nav-item {
border-bottom: 1px solid #fff;
border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF;
}
.nav > li > a{
color:#54A5AF;
}
.nav-tabs {
background-color: #eeeeee;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #fff;
border-left: 6px solid #111;
color:#54A5AF;
font-weight: bold;
border-color: #fff #fff #fff #54A5AF;
}
.modal-dialog {
left:auto;
right: auto;
width: 100%;
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>
});

View File

@@ -0,0 +1,102 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
.card-head{
height: 40px;
background-color: #54A5AF;
padding:5px;
color :#fff;
}
.card-block {
padding: 0.3rem !important;
}
@media (min-width: 34em) {
.card-columns {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
}
@media (min-width: 48em) {
.card-columns {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
}
@media (min-width: 62em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
@media (min-width: 75em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
.nav-tabs .nav-item {
border-bottom: 1px solid #fff;
border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF;
}
.nav > li > a{
color:#54A5AF;
}
.nav-tabs {
background-color: #eeeeee;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #fff;
border-left: 6px solid #111;
color:#54A5AF;
font-weight: bold;
border-color: #fff #fff #fff #54A5AF;
}
.modal-dialog {
left:auto;
right: auto;
width: 100%;
padding-top: 200px;
}
.selected-attribute {
color: #fff !important;
background-color: green !important;
}
.selected-option {
color: #fff !important;
background-color: green !important;
}
.attribute_btn {
white-space: normal !important;
height: 40px;
/*width: 80px;*/
margin-bottom: 5px;
margin-right: 5px;
}
.option_btn {
white-space: normal !important;
height: 40px;
/*width: 80px;*/
margin-bottom: 5px;
margin-right: 5px;
}
#logo{
margin: auto;
width: 50%;
border: 1px solid #54A5AF;
padding: 10px;
}

View File

@@ -1,5 +1,5 @@
class Origami::AddordersController < BaseOrigamiController
before_action :set_dining, only: [:show]
# before_action :set_dining, only: [:detail]
def index
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@@ -8,16 +8,134 @@ class Origami::AddordersController < BaseOrigamiController
@all_room = Room.all.active.order('status desc')
end
def show
def detail
@menu = MenuCategory.all
@table_id = params[:id]
@table_type = DiningFacility.find(@table_id).type
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
if @booking
@booking_id = @booking.booking_id
@order_items = Array.new
@booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
if (order.status == "new")
@obj_order = order
@customer = order.customer
@date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
end
end
end
else
@booking = nil
end
end
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
items_arr = []
JSON.parse(params[:order_items]).each { |i|
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items_arr.push(items)
}
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.employee_name = current_login_employee.name
#Create Table Booking or Room Booking
if !params["booking_id"].nil?
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if booking
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking)
# puts "WWwwWWWWWWww"
# puts sale_status
if sale_status
return return_json_status_with_code(400, "bill requested")
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
else
sale_status = check_order_with_table(params[:table_id])
# puts "OOOOOOOOO"
# puts sale_status
if sale_status
return return_json_status_with_code(400, "bill requested")
end
end
end #booking exists
else
sale_status = check_order_with_table(params[:table_id])
# puts "MMMMMMMM"
# puts sale_status
if sale_status
# return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")
end
end
@status, @booking = @order.generate
end
# render json for http status code
def return_json_status_with_code(code, msg)
render status: code, json: {
message: msg,
booking_id: booking_id
}.to_json
end
def check_order_with_table(table_id)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
# puts booking
if booking
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
end
else
@order.new_booking = false
@order.booking_id = booking.booking_id
return false
end
end
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
return false
end
end
private
def set_dining
@dining = DiningFacility.find(params[:id])
end
# def set_dining
# @dining = DiningFacility.find(params[:id])
# end
end

View File

@@ -134,6 +134,8 @@ class Order < ApplicationRecord
def re_order_items(form_items) #reorder inputs items as parents and child
parent_id = Array.new
parents = Array.new
puts form_items
puts "hhhhh"
parents_and_children_items = Array.new
new_items_list = Array.new

View File

@@ -0,0 +1,15 @@
if @status == true
json.status :success
json.id @order.id
json.booking_id @booking.id
json.order_items do
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark
end
else
json.status :error
if @error_messages
json.error_messages @error_messages
else
json.error_messages @order.errors
end
end

View File

@@ -0,0 +1,147 @@
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
</li>
<% end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7">
<div class="card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<div class="card-header">
<div>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%>
<p class="hidden" id="table_id"><%=@table_id%></p>
<p class="hidden" id="table_type"><%=@table.type%></p>
<p class="hidden" id="booking_id"><%=@booking_id%></p>
</div>
</div>
<div class="card-block">
<div class="card-text" style="max-height:550px; overflow:auto"">
<table class="table table-striped summary-items">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table>
<button type="button" class="btn btn-success create" id="create_order" disabled="disabled">Create Order</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="item_name" id="modal-item-name"></td>
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
</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">Update</button>
</div>
</div>
</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;">&times;</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-5">
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
<br><br>
<div class="form-group">
<label class="col-md-6" style="margin-top:5px">Quantity</label>
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="change_qty" value="" min="1" max="100">
</div>
<p class="hidden" id="unit_price"></p>
<p class="hidden" id="instance_code"></p>
<p class="hidden" id="instance_name"></p>
<p class="hidden" id="promotion_price"></p>
<p class="hidden" id="item_instances"></p>
<p class="hidden" id="item_code"></p>
</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> -->
<strong style="font-size: 18px;">Attributes</strong>
<div class="attributes-list">
</div>
<strong style="font-size: 18px;">Options</strong>
<div class="options-list">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="mr-auto">
<h4 class=" pull-left">Total : <span id="total_price"></span></h4>
</div>
<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>

View File

@@ -32,3 +32,7 @@ Rails.application.config.assets.precompile += %w( jquery-confirm.js )
# --- Image Uploader ----
Rails.application.config.assets.precompile += %w( fileinput.min.js )
# --- Customer/ Customer - Crm ----
Rails.application.config.assets.precompile += %w( addorder.css )
Rails.application.config.assets.precompile += %w( addorder.js )

View File

@@ -171,7 +171,9 @@ Rails.application.routes.draw do
post '/:sale_id/get_customer' => "customers#get_customer"
resources :addorders
get '/:addorders/:id' => "addorders#detail"
post '/:addorders/create' => "addorders#create", :defaults => { :format => 'json' }
resources :commissions
resources :commissioners
resources :in_juties