update addorder
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
if(@id)
|
||||
menu_item = MenuItem.find(@id.menu_item_id)
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
menu_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
|
||||
|
||||
json.success true
|
||||
json.id @id.id
|
||||
json.name @id.item_instance_name
|
||||
json.code @id.item_instance_code
|
||||
|
||||
json.item_id @id.menu_item_id
|
||||
json.attributes @id.item_attributes
|
||||
json.price @id.price
|
||||
json.is_default @id.is_default
|
||||
|
||||
json.options opt_format
|
||||
else
|
||||
json.success false
|
||||
end
|
||||
@@ -147,39 +147,41 @@
|
||||
<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>
|
||||
<h4 class="modal-title" style="color:#fff;" id="set_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 set-item">
|
||||
<div class="col-md-5">
|
||||
<div class="col-md-4">
|
||||
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
|
||||
<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">
|
||||
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="set_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>
|
||||
<p class="hidden" id="set_unit_price"></p>
|
||||
<p class="hidden" id="set_instance_code"></p>
|
||||
<p class="hidden" id="set_instance_name"></p>
|
||||
<p class="hidden" id="set_promotion_price"></p>
|
||||
<p class="hidden" id="set_item_instances"></p>
|
||||
<p class="hidden" id="set_item_code"></p>
|
||||
<p></p>
|
||||
<div class="opt-list">
|
||||
<h4>Options</h4>
|
||||
<br><br><br><br>
|
||||
<div class="options-list">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<div class="col-md-8">
|
||||
<div class="instance-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="mr-auto">
|
||||
<h4 class=" pull-left">Total : <span id="total_price"></span></h4>
|
||||
<h4 class=" pull-left">Total : <span id="set_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>
|
||||
<button type="button" class="btn btn-success set_order" data-dismiss="modal" id="set_order">Add to Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
if(@id)
|
||||
menu_item = MenuItem.find(@id.menu_item_id)
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
menu_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
|
||||
|
||||
json.success true
|
||||
json.id @id.id
|
||||
json.name @id.item_instance_name
|
||||
@@ -8,6 +32,8 @@ if(@id)
|
||||
json.attributes @id.item_attributes
|
||||
json.price @id.price
|
||||
json.is_default @id.is_default
|
||||
|
||||
json.options opt_format
|
||||
else
|
||||
json.success false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user