def index(request):
    # search for order that had status active
    order = Order.objects.filter(user__id=request.user.id).\
    filter(status_order='A').first()
    context = {}

    if order:
        order.value = Order.get_total(order.id)
        order.save()

        context['order'] = order
        context['orderItems'] = OrderItem.objects.filter(order__id=order.id)
        context['total'] = order.value
    else:
        messages.warning(request, 'Você não tem nenhum pedido ativo')

    return render(request, 'dashboard_client/index.html', context)
def send_order(request, order_id):

    order = Order.objects.get(id=order_id)
    items = OrderItem.objects.filter(order=order_id)
    order.value = Order.get_total(order.id)
    order.sended = True
    order.status_order = 'I'  # dont appears in dash board as not sended
    money = Utils.convertStringForNumber(request.GET['money'])

    if (money):
        order.money = money
    else:
        messages.warning(request,
                         'Por favor digite um calor válido para Dinheiro')
        return HttpResponseRedirect(reverse('dashboard_client:index'))

    order.save()

    del request.session['order_id']
    del request.session['howItems']

    return render(request, 'dashboard_client/sended.html')