emile 2 days ago
parent 48513d6ce2
commit 9a41e80e15

@ -5,6 +5,8 @@ from billing.add import views
urlpatterns = [
path('product', views.add_product, name='addproduct'),
path('service', views.add_service, name='addservice'),
path('service/<int:customer_id>/', views.add_service, name='addservice_with_customer'),
path('order/<int:customer_id>/', views.add_order, name='addorder'),
path('invoice-pdf/<int:order_id>/', views.add_invoice_pdf, name='addinvoice'),

@ -42,9 +42,14 @@ def add_product(request, *args, **kwargs):
@staff_login_required
def add_service (request, *args, **kwargs):
def add_service(request, customer_id=None, *args, **kwargs):
item_types = ProjectType.objects.all().order_by('name')
customers = CustomerProfile.objects.all().order_by('user__first_name')
selected_customer = None
if customer_id:
selected_customer = get_object_or_404(CustomerProfile, id=customer_id)
if request.method == 'POST':
title = request.POST.get('title')
description = request.POST.get('description')
@ -70,7 +75,8 @@ def add_service (request, *args, **kwargs):
return redirect('items')
context = {
'item_types' : item_types,
'customers' : customers
'customers' : customers,
'selected_customer' : selected_customer,
}
return render(request, 'add_templates/add-service.html', context)

@ -30,9 +30,11 @@
<label class="text-gray-500">Customer:</label>
<select name="customer" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1">
<option value="" disabled selected>Select Customer</option>
<option value="" disabled {% if not selected_customer %}selected{% endif %}>Select Customer</option>
{% for customer in customers %}
<option value="{{customer.id}}">{{customer.user.first_name}} {{customer.user.last_name}}</option>
<option value="{{ customer.id }}" {% if selected_customer and customer.id == selected_customer.id %}selected{% endif %}>
{{ customer.user.first_name }} {{ customer.user.last_name }}
</option>
{% endfor %}
</select>
</div>

@ -44,10 +44,16 @@
Project</button>
</a>
<a href="{% url 'addcustomerticket' customer.id %}" class="w-full md:w-fit">
<a href="{% url 'addservice_with_customer' customer.id %}" class="w-full md:w-fit">
<button
class="w-full md:w-fit text-base px-3 py-2 bg-osiblue text-white outline-none border border-osiblue rounded-md cursor-pointer hover:bg-white hover:text-osiblue duration-300">Add
Ticket</button>
</a>
<a href="{% url 'addservice' customer.id %}" class="w-full s:w-fit">
<button
class="w-full s:w-fit px-5 py-2 bg-white text-secondosiblue border border-white rounded-md cursor-pointer hover:bg-secondosiblue hover:text-white duration-300 hidden"
id="addServiceButton">Add
Service</button>
</a>
<a href="{% url 'addorder' customer.id %}" class="w-full md:w-fit">

Loading…
Cancel
Save