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, )
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)
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)
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 )
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)
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 )
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)
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 )
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 )
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)
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 )
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 )
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)