def show_order(request, venue_id, template_name="checkout/show_order.html"):
    postdata = request.POST.copy()
    postdata.__setitem__('venue', venue_id)
    success=True
    form_message='Overview of pending, accepted, and processed orders.'
    form_title='My Orders'

    if postdata['submit'] == 'order_accepted':
        form_message='Order accepted by merchant.'
        form_title='Order Accepted'
        if cart.get_cart_items2_1(request, venue_id):
            response = checkout.merchant_order_accepted(request, venue_id)
        if cart.get_cart_items2_2(request, venue_id):
            response = checkout.merchant_order_finalized(request, venue_id)
        if cart.get_cart_items2_3(request, venue_id):
            response = checkout.merchant_order_paid(request, venue_id)
        skip_refresh = False

    if postdata['submit'] == 'cash':
        request.session['billing_name'] = request.POST.get('billing_name')
        request.session['email'] = request.POST.get('email')
        request.session['phone'] = request.POST.get('phone')
        request.session['payment_method'] = request.POST.get('cash')

        form = CheckoutFormCash(postdata)
        if form.is_valid():
            form_message='Order sent.'
            form_title='Order Sent'
            response = checkout.process(request, venue_id)
            order_number = response.get('order_number',0)
            error_message = response.get('message','')
            skip_refresh = False
            if order_number:
                request.session['order_number'] = order_number
        else:
            form_message='Error: incomplete info.'
            form_title='Info Error'
            success=False
            ferrors=form.errors
            skip_refresh = True
    if postdata['submit'] == 'Remove':
        cart.remove_from_cart(request, venue_id)
        form_message='Order cancelled. Thank you for shopping'
        form_title='Order Cancelled'
        skip_refresh = False
    if postdata['submit'] == 'Update':
        cart.update_cart(request, venue_id)
        form_message='Order updated.'
        form_title='Order Updated'
        skip_refresh = False
    if postdata['submit'] == 'New':
        skip_refresh = True
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
def ajax_order_accepted(request, venue_id, template_name="checkout/order_accepted_ajax.json"):
    postdata = request.POST.copy()
    postdata.__setitem__('venue', venue_id)
    if cart.get_cart_items2_1(request, venue_id):
        response = checkout.merchant_order_accepted(request, venue_id)
    elif cart.get_cart_items2_2(request, venue_id):
        response = checkout.merchant_order_finalized(request, venue_id)
    else:
        response = checkout.merchant_order_paid(request, venue_id)
    cart_items2_1 = cart.get_cart_items2_1(request, venue_id)
    cart_items2_2 = cart.get_cart_items2_2(request, venue_id)
    cart_items2_3 = cart.get_cart_items2_3(request, venue_id)
    orders = Order.objects.filter(user=request.user.id, venue=venue_id).order_by('-id')
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))