diff --git a/helpdesk/admin.py b/helpdesk/admin.py
index 04cb41d1b..dfa6121e3 100644
--- a/helpdesk/admin.py
+++ b/helpdesk/admin.py
@@ -3,6 +3,7 @@ from django.contrib import admin
from helpdesk.models import (
FAQ,
Attachment,
+ ClaimRequest,
Comment,
DepartmentManager,
FAQCategory,
@@ -18,3 +19,4 @@ admin.site.register(FAQ)
admin.site.register(FAQCategory)
admin.site.register(Attachment)
admin.site.register(DepartmentManager)
+admin.site.register(ClaimRequest)
diff --git a/helpdesk/forms.py b/helpdesk/forms.py
index f898e56b9..b907d86e7 100644
--- a/helpdesk/forms.py
+++ b/helpdesk/forms.py
@@ -27,7 +27,7 @@ from django import forms
from django.template.loader import render_to_string
from base.forms import ModelForm
-from base.methods import is_reportingmanager
+from base.methods import filtersubordinatesemployeemodel, is_reportingmanager
from base.models import Department, JobPosition
from employee.forms import MultipleFileField
from employee.models import Employee
@@ -121,14 +121,30 @@ class TicketForm(ModelForm):
self.fields["attachment"] = MultipleFileField(
label="Attachements", required=False
)
- self.fields["tags"].choices = list(self.fields["tags"].choices)
- self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
- self.fields["ticket_type"].choices = list(self.fields["ticket_type"].choices)
request = getattr(horilla_middlewares._thread_locals, "request", None)
- if is_reportingmanager(request):
+ instance = kwargs.get("instance")
+ if instance:
+ employee = instance.employee_id
+ else:
+ employee = request.user.employee_get
+ # initialising employee queryset according to the user
+ self.fields["employee_id"].queryset = filtersubordinatesemployeemodel(
+ request, Employee.objects.filter(is_active=True), perm="helpdesk.add_ticket"
+ ) | Employee.objects.filter(employee_user_id=request.user)
+ self.fields["employee_id"].initial = employee
+ # appending dynamic create option according to user
+ if is_reportingmanager(request) or request.user.has_perm(
+ "helpdesk.add_tickettype"
+ ):
+ self.fields["ticket_type"].choices = list(
+ self.fields["ticket_type"].choices
+ )
self.fields["ticket_type"].choices.append(
("create_new_ticket_type", "Create new ticket type")
)
+ if is_reportingmanager(request) or request.user.has_perm("base.add_tags"):
+ self.fields["tags"].choices = list(self.fields["tags"].choices)
+ self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
class TicketTagForm(ModelForm):
@@ -152,8 +168,10 @@ class TicketTagForm(ModelForm):
If an instance is provided, sets the initial value for the form's .
"""
super().__init__(*args, **kwargs)
- self.fields["tags"].choices = list(self.fields["tags"].choices)
- self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
+ request = getattr(horilla_middlewares._thread_locals, "request", None)
+ if is_reportingmanager(request) or request.user.has_perm("base.add_tags"):
+ self.fields["tags"].choices = list(self.fields["tags"].choices)
+ self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
class TicketRaisedOnForm(ModelForm):
@@ -215,3 +233,21 @@ class DepartmentManagerCreateForm(ModelForm):
class Meta:
model = DepartmentManager
fields = ["department", "manager"]
+ widgets = {
+ "department": forms.Select(
+ attrs={
+ "onchange": "getDepartmentEmployees($(this))",
+ }
+ ),
+ }
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ if "instance" in kwargs:
+ department = kwargs["instance"].department
+ # Get the employees related to this department
+ employees = department.employeeworkinformation_set.values_list(
+ "employee_id", flat=True
+ )
+ # Set the manager field queryset to be those employees
+ self.fields["manager"].queryset = Employee.objects.filter(id__in=employees)
diff --git a/helpdesk/methods.py b/helpdesk/methods.py
new file mode 100644
index 000000000..e2ac89c9e
--- /dev/null
+++ b/helpdesk/methods.py
@@ -0,0 +1,21 @@
+
+
+from helpdesk.models import DepartmentManager
+
+
+def is_department_manager(request,ticket):
+ """
+ Method used to find the user is a department manger of given ticket
+ """
+ user_emp = request.user.employee_get
+ if ticket.assigning_type == "job_position":
+ job_position = ticket.get_raised_on_object()
+ department = job_position.department_id
+ elif ticket.assigning_type == "department":
+ department = ticket.get_raised_on_object()
+ else:
+ return False
+ return DepartmentManager.objects.filter(
+ manager = user_emp,
+ department = department
+ ).exists()
diff --git a/helpdesk/models.py b/helpdesk/models.py
index ab9ee2de5..e140f9f3f 100644
--- a/helpdesk/models.py
+++ b/helpdesk/models.py
@@ -60,6 +60,14 @@ class DepartmentManager(HorillaModel):
Company, null=True, editable=False, on_delete=models.PROTECT
)
+ class Meta:
+ unique_together = ("department", "manager")
+
+ def clean(self, *args, **kwargs):
+ super().clean(*args, **kwargs)
+ if not self.manager.get_department() == self.department:
+ raise ValidationError(_(f"This employee is not from {self.department} ."))
+
class TicketType(HorillaModel):
title = models.CharField(max_length=100, unique=True)
@@ -107,6 +115,9 @@ class Ticket(HorillaModel):
related_company_field="employee_id__employee__work_info__company_id"
)
+ class Meta:
+ ordering = ["-created_date"]
+
def clean(self, *args, **kwargs):
super().clean(*args, **kwargs)
deadline = self.deadline
@@ -144,6 +155,36 @@ class Ticket(HorillaModel):
return get_diff(self)
+class ClaimRequest(HorillaModel):
+ ticket_id = models.ForeignKey(
+ Ticket,
+ on_delete=models.CASCADE,
+ null=True,
+ blank=True,
+ )
+ employee_id = models.ForeignKey(
+ Employee,
+ on_delete=models.CASCADE,
+ null=True,
+ blank=True,
+ )
+ is_approved = models.BooleanField(default=False)
+ is_rejected = models.BooleanField(default=False)
+
+ class Meta:
+ unique_together = ("ticket_id", "employee_id")
+
+ def __str__(self) -> str:
+ return f"{self.ticket_id}|{self.employee_id}"
+
+ def clean(self, *args, **kwargs):
+ super().clean(*args, **kwargs)
+ if not self.ticket_id:
+ raise ValidationError({"ticket_id": _("This field is required.")})
+ if not self.employee_id:
+ raise ValidationError({"employee_id": _("This field is required.")})
+
+
class Comment(HorillaModel):
comment = models.TextField(null=True, blank=True)
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE, related_name="comment")
diff --git a/helpdesk/templates/department_managers/department_managers.html b/helpdesk/templates/department_managers/department_managers.html
index 2376d570f..4f015305a 100644
--- a/helpdesk/templates/department_managers/department_managers.html
+++ b/helpdesk/templates/department_managers/department_managers.html
@@ -64,4 +64,11 @@
+
+
{% endblock settings %}
diff --git a/helpdesk/templates/department_managers/department_managers_form.html b/helpdesk/templates/department_managers/department_managers_form.html
index 98642f17d..fd53e18ed 100644
--- a/helpdesk/templates/department_managers/department_managers_form.html
+++ b/helpdesk/templates/department_managers/department_managers_form.html
@@ -32,7 +32,7 @@
{% else %}
hx-post="{% url 'department-manager-create' %}"
{% endif %}
- hx-target="#deparmentManagersForm"
+ hx-target="#deparmentManagersModal"
hx-encoding="multipart/form-data"
class="oh-profile-section"
>
diff --git a/helpdesk/templates/helpdesk/methods.py b/helpdesk/templates/helpdesk/methods.py
new file mode 100644
index 000000000..3d5c4bd6b
--- /dev/null
+++ b/helpdesk/templates/helpdesk/methods.py
@@ -0,0 +1,3 @@
+
+
+def is_department_manager(request,ticket):
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_card.html b/helpdesk/templates/helpdesk/ticket/ticket_card.html
index 6bdf0659c..57835569c 100644
--- a/helpdesk/templates/helpdesk/ticket/ticket_card.html
+++ b/helpdesk/templates/helpdesk/ticket/ticket_card.html
@@ -1,807 +1,971 @@
-{% load static %} {% load i18n %} {% load mathfilters %}
+{% load static %} {% load i18n %} {% load mathfilters %} {% load helpdeskfilters %}
{% include 'filter_tags.html' %}
-
-
- {% if my_tickets %}
-
-
- {% for status, label in ticket_status %}
-
-
-
-
- {{label}}
-
-
+{% if my_tickets or allocated_tickets or all_tickets %}
+
+
+ {% if my_tickets %}
+
+
+ {% for status, label in ticket_status %}
+
+
-
-
- {% for ticket in my_tickets %} {% if ticket.status == status %}
-
-
-
-
-
- {{ticket|truncatechars:15}}
-
-
-
-
-
-
-
-
- {% endfor %}
-
- {% else %}
-
-
-
-
{% trans "There are no tickets at the moment." %}
-
-
- {% endif %}
+ {% else %}
+
+
+
+
+ {% trans "No search result found!" %}
+
+
+
+ {% endif %}
-
-
- {% if allocated_tickets %}
-
-
- {% for status, label in ticket_status %}
+
+
+ {% if allocated_tickets %}
+
+
+ {% for status, label in ticket_status %}
-
-
-
-
- {{label}}
-
-
+
+
-
-
- {% for ticket in allocated_tickets %} {% if ticket.status == status %}
-
-
-
-
-
- {{ticket|truncatechars:15}}
-
-
-
-
-
-
-
-
- {% endfor %}
-
- {% else %}
-
-
-
-
{% trans "There are no tickets at the moment." %}
-
-
- {% endif %}
-
-
- {% if all_tickets %}
-
-
- {% for status, label in ticket_status %}
+ {% else %}
+
+
+
+
+ {% trans "No search result found!" %}
+
+
+
+ {% endif %}
+
+
+ {% if all_tickets %}
+
+
+ {% for status, label in ticket_status %}
-
-
-
-
- {{label}}
-
-
+
-
-
- {% for ticket in all_tickets %} {% if ticket.status == status %}
+ {% for ticket in all_tickets %} {% if ticket.status == status %}
-
-
- {{ticket|truncatechars:15}}
-
-
-
-
-
-
-
-
-
+ {% endfor %}
- {% endfor %}
-
- {% else %}
-
-
-
-
{% trans "There are no tickets at the moment." %}
-
-
- {% endif %}
+ {% else %}
+
+
+
+
+ {% trans "No search result found!" %}
+
+
+
+ {% endif %}
+
-
+{% else %}
+
+
+
+
+ {% trans "There are no tickets at the moment." %}
+
+
+
+{% endif %}
+
+
+ {% if claim_requests %}
+
+
+
+
+
+
+ {% trans "Employee" %}
+
+
+ {% trans "Action" %}
+
+
+
+
+
+ {% for req in claim_requests %}
+
+
+
+
+
+
+
{{req.employee_id}}
+
+
+
+
+ {% if not req.is_approved and not req.is_rejected %}
+
+
+
+ {% else %}
+
+
+
+ {% endif %}
+ {% if not req.is_rejected %}
+
+
+
+ {% else %}
+
+
+
+ {% endif %}
+
+
+
+
+ {% endfor %}
+
+
+
+
+ {% else %}
+
+
+
+
+ {% trans "There are no claim requests at the moment." %}
+
+
+
+ {% endif %}
+
\ No newline at end of file
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_detail.html b/helpdesk/templates/helpdesk/ticket/ticket_detail.html
index a4175f0ac..f5157538a 100644
--- a/helpdesk/templates/helpdesk/ticket/ticket_detail.html
+++ b/helpdesk/templates/helpdesk/ticket/ticket_detail.html
@@ -1,6 +1,6 @@
{% extends 'index.html' %} {% load static %} {% load i18n %}
{% load audit_filters %}
-{% load basefilters %}
+{% load basefilters %} {% load helpdeskfilters %}
@@ -12,10 +12,85 @@
+
{% comment %} {% endcomment %}
{% block content %}
+
+
@@ -29,19 +104,38 @@
-
- {% for status in ticket_status %}
-
- {{status.1}}
- {% endfor %}
-
+ {% if perms.helpdesk.change_ticket or request.user.employee_get|is_department_manager:ticket or request.user.employee_get in ticket.assigned_to.all or request.user.employee_get == ticket.employee_id %}
+
+
+ {% for status in ticket_status %}
+
+ {{status.1}}
+ {% endfor %}
+
+ {% else %}
+
+ {% for status in ticket_status %}
+ {% if status.0 == ticket.status %}
+
+ {{status.1}}
+ {% endif %}
+ {% endfor %}
+
+ {% endif %}
@@ -81,15 +175,13 @@
{{item.comment.employee_id}}
- {% comment %}
Private {% endcomment %}
+
{{item.comment.date}}
@@ -99,43 +191,40 @@
- {% if item.comment.comment_attachment.all %}
- {% for attachment in item.comment.comment_attachment.all %}
-
@@ -146,7 +235,7 @@
- {% if item.comment.comment_attachment.all %}
- {% for attachment in item.comment.comment_attachment.all %}
- {% with extension=attachment.file.name|lower|slice:"-4:" %}
-
-
-
-
-
-
-
-
- {{ attachment }}
-
-
- {% endwith %}
- {% endfor %}
- {% endif %}
+
{% endif %}
@@ -270,16 +367,6 @@
@@ -296,8 +383,23 @@
{{ticket.created_date}}
-
+ {% else %}
{% trans "Priority" %} :
@@ -307,10 +409,7 @@
{% if i == '1' %}title="{% trans 'Low' %}"{% elif i == '2' %}title="{% trans 'Medium' %}"{% else %}title="{% trans 'High' %}"{% endif %}>
{% endfor %}
-
-
-
-
+ {% endif %}
{% trans "Last activity:" %}
@@ -320,15 +419,20 @@
{% endwith %}
- {% comment %}
- {% trans "Status:" %}
- {% endcomment %}
@@ -343,15 +447,19 @@
@@ -364,39 +472,47 @@
- {% for assignee in ticket.assigned_to.all %}
-
-
-
-
-
-
-
-
- {{assignee}}
-
-
-
-
+
+
+
+ {% for employee in ticket.assigned_to.all %}
+
+ {% endfor %}
+
+
- {% endfor %}
@@ -406,13 +522,19 @@
-
@@ -481,6 +602,31 @@
+
+
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_individual_view.html b/helpdesk/templates/helpdesk/ticket/ticket_individual_view.html
new file mode 100644
index 000000000..4c8b58d4f
--- /dev/null
+++ b/helpdesk/templates/helpdesk/ticket/ticket_individual_view.html
@@ -0,0 +1,139 @@
+{% load static %} {% load i18n %}{% load helpdeskfilters %}
+
+
+
diff --git a/helpdesk/templates/helpdesk/ticket/ticket_list.html b/helpdesk/templates/helpdesk/ticket/ticket_list.html
index d1003abe3..f1aacb796 100644
--- a/helpdesk/templates/helpdesk/ticket/ticket_list.html
+++ b/helpdesk/templates/helpdesk/ticket/ticket_list.html
@@ -1,318 +1,724 @@
{% load i18n %} {% load i18n %} {% load static %} {% include 'filter_tags.html' %} {% load mathfilters %}
-
-
- {% if my_tickets %}
-
-
-
-
-
-
-
-
-
-
{% trans "Ticket ID" %}
-
{% trans "Title" %}
-
{% trans "Owner" %}
-
{% trans "Type" %}
-
{% trans "Forward to" %}
-
{% trans "Assigned to" %}
-
{% trans "Status" %}
-
{% trans "Priority" %}
-
{% trans "Tags" %}
-
{% trans "Actions" %}
+{% load basefilters %} {% load helpdeskfilters %}
+{% if my_tickets or allocated_tickets or all_tickets %}
+
+
+ {% if my_tickets %}
+
+
- {% else %}
-
-
-
-
- {% trans "No search result found!" %}
-
-
-
- {% endif %}
-
-
- {% if allocated_tickets %}
+ {% else %}
+
+
+
+
+ {% trans "No search result found!" %}
+
+
+
+ {% endif %}
+
+
+ {% if allocated_tickets %}
+
+
+
+
+
+
+
+
+
{% trans "Ticket ID" %}
+
{% trans "Title" %}
+
{% trans "Owner" %}
+
{% trans "Type" %}
+
{% trans "Forward to" %}
+
{% trans "Assigned to" %}
+
{% trans "Status" %}
+
{% trans "Priority" %}
+
{% trans "Tags" %}
+
{% trans "Actions" %}
+
+
+
+ {% for ticket in allocated_tickets %}
+
+
+
+
+ {{ticket.ticket_type.prefix}}{{ ticket.id|stringformat:"03d" }}
+
+
+
+
+
+
+
{{ticket.title}}
+
{{ticket.employee_id}}
+
{{ticket.ticket_type}}
+
{{ticket.get_raised_on}}
+
{{ticket.assigned_to.all|join:" , "}}
+
{{ticket.get_status_display}}
+
+ {% if perms.helpdesk.change_ticket or request.user.employee_get|is_department_manager:ticket %}
+ {% if ticket.priority == 'low' %}
+
+ {% elif ticket.priority == 'medium' %}
+
+ {% else %}
+
+ {% endif %}
+ {% else %}
+ {% if ticket.priority == 'low' %}
+
+
+ {% for i in "321" %}
+
+
+ {% endfor %}
+
+
+ {% elif ticket.priority == 'medium' %}
+
+
+ {% for i in "321" %}
+
+
+ {% endfor %}
+
+
+ {% else %}
+
+
+ {% for i in "321" %}
+
+
+ {% endfor %}
+
+
+ {% endif %}
+ {% endif %}
+
+
{{ticket.tags.all|join:" , "}}
+
+
+ {% if perms.helpdesk.change_ticket or request.user.employee_get|is_department_manager:ticket %}
+
+
+
+
+ {% else %}
+ {% if ticket|calim_request_exists:request.user.employee_get or request.user.employee_get in ticket.assigned_to.all %}
+
+
+
+ {% else %}
+
+
+
+ {% endif %}
+ {% endif %}
+ {% if perms.helpdesk.change_ticket or request.user.employee_get|is_department_manager:ticket %}
+
+
+
+ {% endif %}
+ {% if perms.helpdesk.delete_ticket or request.user.employee_get|is_department_manager:ticket %}
+ {% if ticket.is_active %}
+
+ {% else %}
+
+ {% endif %}
+ {% endif %}
+ {% if perms.helpdesk.delete_ticket %}
+ {% if ticket.status == 'new' %}
+
+ {% else %}
+
+
+
+ {% endif %}
+ {% endif %}
+
+
+
+ {% endfor %}
+
+
+
+
+
+
+ {% else %}
+
+
+
+
+ {% trans "No search result found!" %}
+
+
+
+ {% endif %}
+
+
+ {% if all_tickets %}
-
+
{% trans "Ticket ID" %}
-
{% trans "Title" %}
-
{% trans "Owner" %}
-
{% trans "Type" %}
-
{% trans "Forward to" %}
-
{% trans "Assigned to" %}
-
{% trans "Status" %}
-
{% trans "Priority" %}
-
{% trans "Tags" %}
-
{% trans "Actions" %}
+
{% trans "Forward to" %}
+
{% trans "Assigned to" %}
+
{% trans "Status" %}
+
{% trans "Priority" %}
+
{% trans "Tags" %}
+ {% if perms.helpdesk.change_ticket or perms.helpdesk.delete_ticket or request.user.employee_get|is_department_manager:ticket %}
+
{% trans "Actions" %}
+ {% endif %}
+
- {% for ticket in allocated_tickets %}
-
+ {% for ticket in all_tickets %}
+
-
{{ticket.title}}
-
{{ticket.employee_id}}
-
{{ticket.ticket_type}}
-
{{ticket.get_raised_on}}
-
{{ticket.assigned_to.all|join:" , "}}
-
{{ticket.get_status_display}}
-
- {% if ticket.priority == 'low' %}
-
- {% else %}
-
-
-
-
- {% trans "No search result found!" %}
-
-
-
- {% endif %}
-
-
- {% if all_tickets %}
-
-
- {% else %}
-
-
-
-
- {% trans "No search result found!" %}
-
-
-
- {% endif %}
-
+{% else %}
+
+
+
+
+ {% trans "There are no tickets at the moment." %}
+
+
+
+{% endif %}