updates for qr handling
This commit is contained in:
@@ -23,16 +23,6 @@ root.Qrammer =
|
||||
clear_active_list: ->
|
||||
window.active_products_list = {}
|
||||
$('#active-order-table').hide()
|
||||
handle_response: (res) ->
|
||||
if(typeof(res) == 'string')
|
||||
return unless res.length
|
||||
if res[0] == '{'
|
||||
res = JSON.parse(res)
|
||||
else
|
||||
eval(res)
|
||||
return
|
||||
window.location = '/' if res['message'] && !res['ok']
|
||||
window.location = '/user/active_list' if res['ok']
|
||||
load_active_orders: () ->
|
||||
$.get('/supplier/active_orders.json', (res) ->
|
||||
body = $('#active-orders-table tbody')
|
||||
|
||||
@@ -3,7 +3,7 @@ root.Quser=
|
||||
handle_active_list: (callback) ->
|
||||
$.get('/user/list_info.json', (res) ->
|
||||
if !res.list_active
|
||||
window.location = '/phone_home?list_closed=true'
|
||||
window.location = '/user?list_closed=true'
|
||||
return
|
||||
window.active_list = res
|
||||
callback.call() if callback
|
||||
@@ -60,10 +60,20 @@ root.Quser=
|
||||
foot.append('<tr><td></td><td class="currency"><strong>'+Qrammer.currency(res.total_amount)+'</strong></td></tr>')
|
||||
)
|
||||
order_selected_products: ()->
|
||||
h = {list_id: active_list_id}
|
||||
h = {}
|
||||
for product_id, info of window.active_products_list
|
||||
h['products['+product_id+']'] = info.number
|
||||
$.post('/user/order_selected_products', h, ((res) -> Qrammer.handle_response(res)), 'json')
|
||||
$.post('/user/order_selected_products', h, ((res) -> Quser.handle_response(res)), 'json')
|
||||
handle_response: (res) ->
|
||||
if(typeof(res) == 'string')
|
||||
return unless res.length
|
||||
if res[0] == '{'
|
||||
res = JSON.parse(res)
|
||||
else
|
||||
eval(res)
|
||||
return
|
||||
window.location = '/user' if res['message'] && !res['ok']
|
||||
window.location = res.location || '/user/list_products' if res['ok']
|
||||
build_product_list: ->
|
||||
table = $('#active-order-table')
|
||||
tbody = table.find('tbody')
|
||||
@@ -118,6 +128,13 @@ root.Quser=
|
||||
body.append(row)
|
||||
)
|
||||
|
||||
actions_for_table: (table_id)->
|
||||
$.get('/user/table_info.json?table_id='+table_id, (res)->
|
||||
if res.occupied
|
||||
alert('Table is occupied')
|
||||
else
|
||||
$.post('/user/create_list.json', {table_id: table_id}, (res)-> Quser.handle_response(res))
|
||||
, 'json')
|
||||
add_product: (product, count) ->
|
||||
count ||= 1
|
||||
window.active_products_list = {} unless window.active_products_list
|
||||
|
||||
Reference in New Issue
Block a user