emile 12 months ago
parent 71108fe3ec
commit 6fca097b18

BIN
.DS_Store vendored

Binary file not shown.

BIN
osinaweb/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -659,22 +659,30 @@ def add_ticket(request, customer_id):
customer_orders_completed = customer_orders_with_last_status.filter(orderstatus__status='Completed', orderstatus__date=F('max_status_date'))
customer_products = OrderItem.objects.filter(active__in=[True, None], item__type='Product', order__customer=customer, order__in=customer_orders_completed)
customer_projects = Project.objects.filter(customer=customer)
departments = Department.objects.all().order_by('name')
all_departments = Department.objects.all().order_by('name')
support_department = get_object_or_404(Department, name='Support')
if request.method == 'POST':
project = None
product = None
department_ids = request.POST.getlist('departments') # Changed to get a list of department IDs
selected_departments = Department.objects.filter(id__in=department_ids)
regarding = 'General/Account/Billing'
departments = [support_department]
if request.POST.get('project'):
project = get_object_or_404(Project, id=request.POST.get('project'))
regarding = 'Project/Product'
project_types = project.project_type.all()
departments = [project_type.department for project_type in project_types]
elif request.POST.get('product'):
product = get_object_or_404(Item, id=request.POST.get('product'))
departments = [product.item_type.department]
regarding = 'Project/Product'
if request.POST.getlist('departments'):
department_ids = request.POST.getlist('departments')
departments = Department.objects.filter(id__in=department_ids)
ticket = Ticket(
status='Open',
@ -689,7 +697,7 @@ def add_ticket(request, customer_id):
)
ticket.save()
ticket.departments.set(selected_departments) # Assign multiple departments
ticket.departments.set(departments)
ticket_status_update = TicketStatus(
ticket=ticket,
@ -712,7 +720,7 @@ def add_ticket(request, customer_id):
'customer_products': customer_products,
'customer_projects': customer_projects,
'customer': customer,
'departments': departments
'all_departments': all_departments
}
return render(request, 'add_templates/add-ticket.html', context)

Binary file not shown.

@ -33,13 +33,10 @@
<div class="w-full hidden" id="projectsSelectTag">
<label class="text-gray-500">Choose one of {{customer.user.first_name}}'s projects:</label>
<select name="project" class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-1">
{% if not customer_projects %}
<option value="" selected disabled>Select Project</option>
{% else %}
{% for customer_project in customer_projects %}
<option value="{{customer_project.id}}">{{customer_project.name}}</option>
{% endfor %}
{% endif %}
</select>
</div>
@ -47,13 +44,10 @@
<div class="w-full hidden" id="productsSelectTag">
<label class="text-gray-500">Choose one of {{customer.user.first_name}}'s products/subscriptions:</label>
<select name="product" class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-1" >
{% if not customer_products %}
<option value="" selected disabled>Select Product</option>
{% else %}
{% for customer_product in customer_products %}
<option value="{{customer_product.item.id}}">{{customer_product.item.title}}</option>
{% endfor %}
{% endif %}
</select>
</div>
@ -62,7 +56,7 @@
<label class="text-gray-500">Department:</label>
<select name="department" class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-1" >
<option value="" selected disabled>Select Department</option>
{% for department in departments %}
{% for department in all_departments %}
<option value="{{department.id}}">{{department.name}}</option>
{% endfor %}
</select>

Loading…
Cancel
Save