예제 #1
0
def list_orders(request, user_id=None):
    if user_id:
        customer = get_object_or_404(Customer, pk=user_id)
    else:
        customer = None
    ctx = {}
    if user_id:
        queryset = pos_models.Order.objects.filter(
            customer__id=user_id
        )
    else:
        queryset=pos_models.Order.objects.all()
    queryset = queryset.filter(store=request.store)
    queryset = queryset.order_by('-created')

    initial = {
        'order_type': customer.customer_type.name,
        'customer': customer,
    }
    ctx['form'] = process_form(request, OrderForm, initial=initial)
    ctx['customer_id'] = int(user_id)
    ctx['customer'] = customer
    ctx['pos_models'] = pos_models

    return list_detail.object_list(
        request,
        queryset=queryset,
        template_object_name='order',
        extra_context=ctx,
    )
예제 #2
0
파일: views.py 프로젝트: AymenSe/jazzpos
def add_customer(request):
    ctx = {}
    redirect_to = reverse('jazzpos.views.list_customers')
    initial = {
        'store': request.session['store_id'],
        'customer_type': 'patient',
    }
    ctx['form'] = process_form(request,
                               CustomerForm,
                               initial=initial,
                               redirect_to=redirect_to)
    return render_response(request, 'customer_add.html', ctx)
예제 #3
0
파일: main.py 프로젝트: AymenSe/jazzpos
def show_order(request, order_id):
    order = get_object_or_404(pos_models.Order, pk=order_id)
    payments = Payment.objects.filter(order=order_id)
    initial = {
        'order_id': order_id,
    }
    response_dict = {
        "order_item_form": process_form(request,
                                        OrderItemForm,
                                        initial=initial),
        "order": order,
        "customer": order.customer,
        "payments": payments,
        "payment_form": process_form(request, PaymentForm, initial=initial),
        "confirm_form": process_form(request,
                                     OrderConfirmForm,
                                     initial=initial),
        "cancel_form": process_form(request, OrderCancelForm, initial=initial),
    }

    return render_response(request, 'xpos/order_detail.html', response_dict)
예제 #4
0
파일: main.py 프로젝트: k4ml/jazzpos
def show_order(request, order_id):
    order = get_object_or_404(pos_models.Order, pk=order_id)
    payments = Payment.objects.filter(order=order_id)
    initial = {
        'order_id': order_id,
    }
    response_dict = {
        "order_item_form": process_form(request, OrderItemForm, initial=initial),
        "order": order,
        "customer": order.customer,
        "payments": payments,
        "payment_form": process_form(request, PaymentForm, initial=initial),
        "confirm_form": process_form(request, OrderConfirmForm, initial=initial),
        "cancel_form": process_form(request, OrderCancelForm, initial=initial),
    }

    return render_response(
        request,
        'xpos/order_detail.html',
        response_dict
    )
예제 #5
0
파일: main.py 프로젝트: AymenSe/jazzpos
def list_payments(request, order_id):
    ctx = {}
    order = get_object_or_404(pos_models.Order, pk=order_id)
    payments = Payment.objects.filter(order=order_id)
    initial = {
        'order_id': order_id,
    }

    ctx['payments'] = payments
    ctx['order'] = order
    ctx['customer'] = order.customer
    ctx['payment_form'] = process_form(request, PaymentForm, initial=initial)
    return render_response(request, 'xpos/payment_list.html', ctx)
예제 #6
0
파일: views.py 프로젝트: k4ml/jazzpos
def add_customer(request):
    ctx = {}
    redirect_to = reverse('jazzpos.views.list_customers')
    initial = {
        'store': request.session['store_id'],
        'customer_type': 'patient',
    }
    ctx['form'] = process_form(request, CustomerForm, initial=initial, redirect_to=redirect_to)
    return render_response(
        request,
        'customer_add.html',
        ctx
    )
예제 #7
0
파일: views.py 프로젝트: AymenSe/jazzpos
def add_treatment(request, patient_id):
    patient = get_object_or_404(Patient, pk=patient_id)
    ctx = {}
    redirect_to = reverse('jazzpos.views.list_treatments',
                          args=(patient.customer_id, ))
    initial = {
        'store': request.session['store_id'],
        'patient': patient,
    }
    ctx['form'] = process_form(request,
                               TreatmentForm,
                               initial=initial,
                               redirect_to=redirect_to)
    ctx['patient'] = patient
    ctx['action'] = 'Tambah'
    return render_response(request, 'treatment_edit.html', ctx)
예제 #8
0
파일: views.py 프로젝트: k4ml/jazzpos
def add_treatment(request, patient_id):
    patient = get_object_or_404(Patient, pk=patient_id)
    ctx = {}
    redirect_to = reverse('jazzpos.views.list_treatments', args=(patient.customer_id,))
    initial = {
        'store': request.session['store_id'],
        'patient': patient,
    }
    ctx['form'] = process_form(request, TreatmentForm, initial=initial, redirect_to=redirect_to)
    ctx['patient'] = patient
    ctx['action'] = 'Tambah'
    return render_response(
        request,
        'treatment_edit.html',
        ctx
    )
예제 #9
0
파일: main2.py 프로젝트: k4ml/jazzpos
def list_payments(request, order_id):
    ctx = {}
    order = get_object_or_404(pos_models.Order, pk=order_id)
    payments = Payment.objects.filter(order=order_id)
    initial = {
        'order_id': order_id,
    }

    ctx['payments'] = payments
    ctx['order'] = order
    ctx['customer'] = order.customer
    ctx['payment_form'] = process_form(request, PaymentForm, initial=initial)
    return render_response(
        request,
        'xpos/payment_list.html',
        ctx
    )
예제 #10
0
파일: views.py 프로젝트: AymenSe/jazzpos
def edit_patient(request, customer_id):
    patient = get_object_or_404(Patient, customer=customer_id)

    # allow only customer own store except for admin
    if not request.user.is_superuser:
        if patient.customer.store != request.store:
            return HttpResponseForbidden()

    ctx = {}
    redirect_to = reverse('jazzpos.views.view_customer', args=(customer_id, ))
    initial = {
        'store': request.session['store_id'],
    }
    ctx['form'] = process_form(request,
                               PatientForm,
                               initial=initial,
                               redirect_to=redirect_to,
                               instance=patient)
    ctx['patient'] = patient
    return render_response(request, 'patient_edit.html', ctx)
예제 #11
0
파일: views.py 프로젝트: k4ml/jazzpos
def edit_patient(request, customer_id):
    patient = get_object_or_404(Patient, customer=customer_id)

    # allow only customer own store except for admin
    if not request.user.is_superuser:
        if patient.customer.store != request.store:
            return HttpResponseForbidden()

    ctx = {}
    redirect_to = reverse('jazzpos.views.view_customer', args=(customer_id,))
    initial = {
        'store': request.session['store_id'],
    }
    ctx['form'] = process_form(request, PatientForm, initial=initial, redirect_to=redirect_to, instance=patient)
    ctx['patient'] = patient
    return render_response(
        request,
        'patient_edit.html',
        ctx
    )
예제 #12
0
파일: views.py 프로젝트: k4ml/jazzpos
def edit_treatment(request, treatment_id):
    treatment = get_object_or_404(Treatment, pk=treatment_id)

    # allow only customer own store except for admin
    if not request.user.is_superuser:
        if treatment.store != request.store:
            return HttpResponseForbidden()

    ctx = {}
    redirect_to = reverse('jazzpos.views.list_treatments', args=(treatment.patient.customer_id,))
    initial = {
        'store': request.session['store_id'],
    }
    ctx['form'] = process_form(request, TreatmentForm, initial=initial, redirect_to=redirect_to, instance=treatment)
    ctx['treatment'] = treatment
    ctx['patient'] = treatment.patient
    ctx['action'] = 'Edit'
    return render_response(
        request,
        'treatment_edit.html',
        ctx
    )
예제 #13
0
파일: views.py 프로젝트: AymenSe/jazzpos
def edit_treatment(request, treatment_id):
    treatment = get_object_or_404(Treatment, pk=treatment_id)

    # allow only customer own store except for admin
    if not request.user.is_superuser:
        if treatment.store != request.store:
            return HttpResponseForbidden()

    ctx = {}
    redirect_to = reverse('jazzpos.views.list_treatments',
                          args=(treatment.patient.customer_id, ))
    initial = {
        'store': request.session['store_id'],
    }
    ctx['form'] = process_form(request,
                               TreatmentForm,
                               initial=initial,
                               redirect_to=redirect_to,
                               instance=treatment)
    ctx['treatment'] = treatment
    ctx['patient'] = treatment.patient
    ctx['action'] = 'Edit'
    return render_response(request, 'treatment_edit.html', ctx)