[UPDT] LEAVE: Leave request creation method updates
This commit is contained in:
159
leave/forms.py
159
leave/forms.py
@@ -79,12 +79,12 @@ class ModelForm(forms.ModelForm):
|
||||
),
|
||||
):
|
||||
field.widget.attrs.update({"class": "oh-switch__checkbox"})
|
||||
try:
|
||||
self.fields["employee_id"].initial = request.user.employee_get
|
||||
try:
|
||||
self.fields["employee_id"].initial = request.user.employee_get
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
try:
|
||||
self.fields["company_id"].initial = request.user.employee_get.get_company
|
||||
except:
|
||||
pass
|
||||
@@ -98,9 +98,9 @@ class ConditionForm(forms.ModelForm):
|
||||
for field_name, field in self.fields.items():
|
||||
widget = field.widget
|
||||
if isinstance(widget, (forms.Select,)):
|
||||
field.widget.attrs[
|
||||
"style"
|
||||
] = "width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
||||
field.widget.attrs["style"] = (
|
||||
"width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
||||
)
|
||||
elif isinstance(widget, (forms.DateInput)):
|
||||
field.widget.attrs.update({"class": "oh-input oh-calendar-input w-100"})
|
||||
field.initial = date.today()
|
||||
@@ -128,16 +128,17 @@ class ConditionForm(forms.ModelForm):
|
||||
),
|
||||
):
|
||||
field.widget.attrs.update({"class": "oh-switch__checkbox"})
|
||||
try:
|
||||
self.fields["employee_id"].initial = request.user.employee_get
|
||||
try:
|
||||
self.fields["employee_id"].initial = request.user.employee_get
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
try:
|
||||
self.fields["company_id"].initial = request.user.employee_get.get_company
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class LeaveTypeForm(ConditionForm):
|
||||
|
||||
class Meta:
|
||||
@@ -179,9 +180,9 @@ class UpdateLeaveTypeForm(ConditionForm):
|
||||
|
||||
for index, visible in enumerate(self.visible_fields()):
|
||||
if list(self.fields.keys())[index] in empty_fields:
|
||||
visible.field.widget.attrs[
|
||||
"style"
|
||||
] = "display:none;width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
||||
visible.field.widget.attrs["style"] = (
|
||||
"display:none;width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;"
|
||||
)
|
||||
visible.field.widget.attrs["data-hidden"] = True
|
||||
|
||||
class Meta:
|
||||
@@ -198,7 +199,8 @@ class UpdateLeaveTypeForm(ConditionForm):
|
||||
del self.errors["exceed_days"]
|
||||
return cleaned_data
|
||||
|
||||
def cal_effective_requested_days(start_date,end_date,leave_type_id,requested_days):
|
||||
|
||||
def cal_effective_requested_days(start_date, end_date, leave_type_id, requested_days):
|
||||
requested_dates = leave_requested_dates(start_date, end_date)
|
||||
holidays = Holiday.objects.all()
|
||||
holiday_dates = holiday_dates_list(holidays)
|
||||
@@ -228,6 +230,7 @@ def cal_effective_requested_days(start_date,end_date,leave_type_id,requested_day
|
||||
requested_days = requested_days - company_leave_count
|
||||
return requested_days
|
||||
|
||||
|
||||
class LeaveRequestCreationForm(ModelForm):
|
||||
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
||||
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
|
||||
@@ -243,6 +246,8 @@ class LeaveRequestCreationForm(ModelForm):
|
||||
attachment = cleaned_data.get("attachment")
|
||||
overlapping_requests = LeaveRequest.objects.filter(
|
||||
employee_id=employee_id, start_date__lte=end_date, end_date__gte=start_date
|
||||
).exclude(
|
||||
id=self.instance.id,
|
||||
)
|
||||
if leave_type_id.require_attachment == "yes":
|
||||
if attachment is None:
|
||||
@@ -256,14 +261,16 @@ class LeaveRequestCreationForm(ModelForm):
|
||||
if start_date == end_date:
|
||||
if start_date_breakdown != end_date_breakdown:
|
||||
raise forms.ValidationError(
|
||||
_("There is a mismatch in the breakdown of the start date and end date.")
|
||||
_(
|
||||
"There is a mismatch in the breakdown of the start date and end date."
|
||||
)
|
||||
)
|
||||
if not AvailableLeave.objects.filter(
|
||||
employee_id=employee_id, leave_type_id=leave_type_id
|
||||
).exists():
|
||||
raise forms.ValidationError(_("Employee has no leave type.."))
|
||||
|
||||
if overlapping_requests.exists():
|
||||
if overlapping_requests.exclude(status__in=['cancelled', 'rejected']).exists():
|
||||
raise forms.ValidationError(
|
||||
_("Employee has already a leave request for this date range..")
|
||||
)
|
||||
@@ -277,8 +284,13 @@ class LeaveRequestCreationForm(ModelForm):
|
||||
requested_days = calculate_requested_days(
|
||||
start_date, end_date, start_date_breakdown, end_date_breakdown
|
||||
)
|
||||
effective_requested_days = cal_effective_requested_days(start_date=start_date,end_date=end_date,leave_type_id=leave_type_id,requested_days=requested_days)
|
||||
leave_dates = leave_requested_dates(start_date,end_date)
|
||||
effective_requested_days = cal_effective_requested_days(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
leave_type_id=leave_type_id,
|
||||
requested_days=requested_days,
|
||||
)
|
||||
leave_dates = leave_requested_dates(start_date, end_date)
|
||||
month_year = [f"{date.year}-{date.strftime('%m')}" for date in leave_dates]
|
||||
today = datetime.today()
|
||||
unique_dates = list(set(month_year))
|
||||
@@ -312,7 +324,6 @@ class LeaveRequestCreationForm(ModelForm):
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def as_p(self, *args, **kwargs):
|
||||
"""
|
||||
Render the form fields as HTML table rows with Bootstrap styling.
|
||||
@@ -357,13 +368,15 @@ class LeaveRequestUpdationForm(ModelForm):
|
||||
if start_date == end_date:
|
||||
if start_date_breakdown != end_date_breakdown:
|
||||
raise forms.ValidationError(
|
||||
_("There is a mismatch in the breakdown of the start date and end date.")
|
||||
_(
|
||||
"There is a mismatch in the breakdown of the start date and end date."
|
||||
)
|
||||
)
|
||||
if not AvailableLeave.objects.filter(
|
||||
employee_id=employee_id, leave_type_id=leave_type_id
|
||||
).exists():
|
||||
raise forms.ValidationError(_("Employee has no leave type.."))
|
||||
if overlapping_requests.exists():
|
||||
if overlapping_requests.exclude(status__in=["cancelled", "rejected"]).exists():
|
||||
raise forms.ValidationError(
|
||||
_("Employee has already a leave request for this date range..")
|
||||
)
|
||||
@@ -376,8 +389,13 @@ class LeaveRequestUpdationForm(ModelForm):
|
||||
requested_days = calculate_requested_days(
|
||||
start_date, end_date, start_date_breakdown, end_date_breakdown
|
||||
)
|
||||
effective_requested_days = cal_effective_requested_days(start_date=start_date,end_date=end_date,leave_type_id=leave_type_id,requested_days=requested_days)
|
||||
leave_dates = leave_requested_dates(start_date,end_date)
|
||||
effective_requested_days = cal_effective_requested_days(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
leave_type_id=leave_type_id,
|
||||
requested_days=requested_days,
|
||||
)
|
||||
leave_dates = leave_requested_dates(start_date, end_date)
|
||||
month_year = [f"{date.year}-{date.strftime('%m')}" for date in leave_dates]
|
||||
today = datetime.today()
|
||||
unique_dates = list(set(month_year))
|
||||
@@ -391,7 +409,7 @@ class LeaveRequestUpdationForm(ModelForm):
|
||||
raise forms.ValidationError(_("Employee doesn't have enough leave days.."))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -430,7 +448,6 @@ class LeaveRequestUpdationForm(ModelForm):
|
||||
"end_date_breakdown",
|
||||
"description",
|
||||
"attachment",
|
||||
"status",
|
||||
]
|
||||
|
||||
|
||||
@@ -476,10 +493,10 @@ class HolidayForm(ModelForm):
|
||||
labels = {
|
||||
"name": _("Name"),
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HolidayForm, self).__init__(*args, **kwargs)
|
||||
self.fields['name'].widget.attrs['autocomplete'] = 'name'
|
||||
self.fields["name"].widget.attrs["autocomplete"] = "name"
|
||||
|
||||
|
||||
class LeaveOneAssignForm(HorillaModelForm):
|
||||
@@ -498,8 +515,8 @@ class LeaveOneAssignForm(HorillaModelForm):
|
||||
class Meta:
|
||||
model = AvailableLeave
|
||||
fields = ["employee_id"]
|
||||
|
||||
def __init__(self,*args, **kwargs):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
reload_queryset(self.fields)
|
||||
|
||||
@@ -527,28 +544,25 @@ class UserLeaveRequestForm(ModelForm):
|
||||
end_date = cleaned_data.get("end_date")
|
||||
employee_id = cleaned_data.get("employee_id")
|
||||
start_date_breakdown = cleaned_data.get("start_date_breakdown")
|
||||
end_date_breakdown = cleaned_data.get('end_date_breakdown')
|
||||
end_date_breakdown = cleaned_data.get("end_date_breakdown")
|
||||
leave_type_id = cleaned_data.get("leave_type_id")
|
||||
overlapping_requests = LeaveRequest.objects.filter(
|
||||
employee_id=employee_id,
|
||||
start_date__lte=end_date,
|
||||
end_date__gte=start_date
|
||||
).exclude(
|
||||
id=self.instance.id,
|
||||
status__in=['cancelled_and_rejected', 'rejected']
|
||||
)
|
||||
employee_id=employee_id, start_date__lte=end_date, end_date__gte=start_date
|
||||
).exclude(id=self.instance.id)
|
||||
if start_date == end_date:
|
||||
if start_date_breakdown != end_date_breakdown:
|
||||
raise forms.ValidationError(
|
||||
_("There is a mismatch in the breakdown of the start date and end date.")
|
||||
_(
|
||||
"There is a mismatch in the breakdown of the start date and end date."
|
||||
)
|
||||
)
|
||||
if not start_date <= end_date:
|
||||
raise forms.ValidationError(
|
||||
_("End date should not be less than start date.")
|
||||
)
|
||||
if overlapping_requests.exists():
|
||||
if overlapping_requests.exclude(status__in=["cancelled", "rejected"]).exists():
|
||||
raise forms.ValidationError(
|
||||
_("Employee has already a leave request for this date range..")
|
||||
_("Employee has already a leave request for this date range.....")
|
||||
)
|
||||
requested_days = calculate_requested_days(
|
||||
start_date, end_date, start_date_breakdown, end_date_breakdown
|
||||
@@ -559,17 +573,25 @@ class UserLeaveRequestForm(ModelForm):
|
||||
total_leave_days = (
|
||||
available_leave.available_days + available_leave.carryforward_days
|
||||
)
|
||||
effective_requested_days = cal_effective_requested_days(start_date=start_date,end_date=end_date,leave_type_id=leave_type_id,requested_days=requested_days)
|
||||
effective_requested_days = cal_effective_requested_days(
|
||||
start_date=start_date,
|
||||
end_date=end_date,
|
||||
leave_type_id=leave_type_id,
|
||||
requested_days=requested_days,
|
||||
)
|
||||
if not effective_requested_days <= total_leave_days:
|
||||
raise forms.ValidationError(_("Employee doesn't have enough leave days.."))
|
||||
return cleaned_data
|
||||
|
||||
def __init__(self, *args, employee=None, **kwargs):
|
||||
leave_type = kwargs.pop('initial', None)
|
||||
leave_type = kwargs.pop("initial", None)
|
||||
super(UserLeaveRequestForm, self).__init__(*args, **kwargs)
|
||||
self.fields['leave_type_id'].queryset = LeaveType.objects.filter(id=leave_type["leave_type_id"].id)
|
||||
self.fields['leave_type_id'].initial= leave_type["leave_type_id"].id
|
||||
self.fields['leave_type_id'].empty_label= None
|
||||
if leave_type:
|
||||
self.fields["leave_type_id"].queryset = LeaveType.objects.filter(
|
||||
id=leave_type["leave_type_id"].id
|
||||
)
|
||||
self.fields["leave_type_id"].initial = leave_type["leave_type_id"].id
|
||||
self.fields["leave_type_id"].empty_label = None
|
||||
|
||||
def as_p(self, *args, **kwargs):
|
||||
"""
|
||||
@@ -666,7 +688,7 @@ class UserLeaveRequestCreationForm(ModelForm):
|
||||
context = {"form": self}
|
||||
table_html = render_to_string("attendance_form.html", context)
|
||||
return table_html
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -675,7 +697,7 @@ class UserLeaveRequestCreationForm(ModelForm):
|
||||
"onchange": "typeChange($(this))",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
start_date = cleaned_data.get("start_date")
|
||||
@@ -683,11 +705,10 @@ class UserLeaveRequestCreationForm(ModelForm):
|
||||
employee_id = cleaned_data.get("employee_id")
|
||||
leave_type_id = cleaned_data.get("leave_type_id")
|
||||
start_date_breakdown = cleaned_data.get("start_date_breakdown")
|
||||
end_date_breakdown = cleaned_data.get('end_date_breakdown')
|
||||
end_date_breakdown = cleaned_data.get("end_date_breakdown")
|
||||
overlapping_requests = LeaveRequest.objects.filter(
|
||||
employee_id=employee_id, start_date__lte=end_date, end_date__gte=start_date
|
||||
)
|
||||
|
||||
).exclude(id=self.instance.id)
|
||||
if not start_date <= end_date:
|
||||
raise forms.ValidationError(
|
||||
_("End date should not be less than start date.")
|
||||
@@ -695,14 +716,16 @@ class UserLeaveRequestCreationForm(ModelForm):
|
||||
if start_date == end_date:
|
||||
if start_date_breakdown != end_date_breakdown:
|
||||
raise forms.ValidationError(
|
||||
_("There is a mismatch in the breakdown of the start date and end date.")
|
||||
_(
|
||||
"There is a mismatch in the breakdown of the start date and end date."
|
||||
)
|
||||
)
|
||||
if not AvailableLeave.objects.filter(
|
||||
employee_id=employee_id, leave_type_id=leave_type_id
|
||||
).exists():
|
||||
raise forms.ValidationError(_("Employee has no leave type.."))
|
||||
|
||||
if overlapping_requests.exists():
|
||||
if overlapping_requests.exclude(status__in=['cancelled', 'rejected']).exists():
|
||||
raise forms.ValidationError(
|
||||
_("Employee has already a leave request for this date range..")
|
||||
)
|
||||
@@ -736,7 +759,7 @@ class UserLeaveRequestCreationForm(ModelForm):
|
||||
]
|
||||
widgets = {
|
||||
"employee_id": forms.HiddenInput(),
|
||||
'requested_days': forms.HiddenInput()
|
||||
"requested_days": forms.HiddenInput(),
|
||||
}
|
||||
|
||||
|
||||
@@ -796,14 +819,16 @@ class LeaveRequestExportForm(forms.Form):
|
||||
)
|
||||
|
||||
|
||||
|
||||
class AssignLeaveForm(HorillaForm):
|
||||
"""
|
||||
Form for Payslip
|
||||
"""
|
||||
|
||||
leave_type_id = forms.ModelChoiceField(
|
||||
queryset=LeaveType.objects.all(),
|
||||
widget=forms.SelectMultiple(attrs={"class": "oh-select oh-select-2 mb-2","required": True}),
|
||||
widget=forms.SelectMultiple(
|
||||
attrs={"class": "oh-select oh-select-2 mb-2", "required": True}
|
||||
),
|
||||
empty_label=None,
|
||||
label="Leave Type",
|
||||
required=False,
|
||||
@@ -815,7 +840,7 @@ class AssignLeaveForm(HorillaForm):
|
||||
filter_class=EmployeeFilter,
|
||||
filter_instance_contex_name="f",
|
||||
filter_template_path="employee_filters.html",
|
||||
required = True,
|
||||
required=True,
|
||||
),
|
||||
label="Employee",
|
||||
)
|
||||
@@ -825,18 +850,10 @@ class AssignLeaveForm(HorillaForm):
|
||||
employee_id = cleaned_data.get("employee_id")
|
||||
leave_type_id = cleaned_data.get("leave_type_id")
|
||||
|
||||
if not employee_id :
|
||||
raise forms.ValidationError(
|
||||
{
|
||||
"employee_id": "This field is required"
|
||||
}
|
||||
)
|
||||
if not leave_type_id :
|
||||
raise forms.ValidationError(
|
||||
{
|
||||
"leave_type_id": "This field is required"
|
||||
}
|
||||
)
|
||||
if not employee_id:
|
||||
raise forms.ValidationError({"employee_id": "This field is required"})
|
||||
if not leave_type_id:
|
||||
raise forms.ValidationError({"leave_type_id": "This field is required"})
|
||||
return cleaned_data
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -845,7 +862,7 @@ class AssignLeaveForm(HorillaForm):
|
||||
self.fields["employee_id"].widget.attrs.update(
|
||||
{"required": True, "id": uuid.uuid4()}
|
||||
),
|
||||
self.fields['leave_type_id'].label = "Leave Type"
|
||||
self.fields["leave_type_id"].label = "Leave Type"
|
||||
|
||||
|
||||
class LeaverequestcommentForm(ModelForm):
|
||||
@@ -859,8 +876,7 @@ class LeaverequestcommentForm(ModelForm):
|
||||
"""
|
||||
|
||||
model = LeaverequestComment
|
||||
fields = ('comment',)
|
||||
|
||||
fields = ("comment",)
|
||||
|
||||
|
||||
class LeaveCommentForm(ModelForm):
|
||||
@@ -916,7 +932,7 @@ class LeaveallocationrequestcommentForm(ModelForm):
|
||||
"""
|
||||
|
||||
model = LeaveallocationrequestComment
|
||||
fields = ('comment',)
|
||||
fields = ("comment",)
|
||||
|
||||
|
||||
class LeaveAllocationCommentForm(ModelForm):
|
||||
@@ -959,4 +975,3 @@ class LeaveAllocationCommentForm(ModelForm):
|
||||
if commit:
|
||||
instance.files.add(*multiple_files_ids)
|
||||
return instance, files
|
||||
|
||||
|
||||
@@ -110,79 +110,90 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not dashboard %}
|
||||
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
|
||||
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
|
||||
<button type="button" hx-get="{% url 'leave-request-view-comment' leave_request.id %}?{{pd}}&target=leaveRequest" hx-target="#commentContainer"
|
||||
data-target = '#leaveactivitySidebar' title='{% trans "Add / View Comment" %}' class="oh-btn oh-btn--light oh-activity-sidebar__open w-100" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;" onclick="event.stopPropagation()">
|
||||
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %}
|
||||
<button
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#penaltyModal"
|
||||
hx-target="#penaltyModalBody"
|
||||
hx-get="{% url "leave-cut-penalty" leave_request.id %}?{{pd}}"
|
||||
type='submit'
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %}
|
||||
<button data-toggle="oh-modal-toggle" data-target="#penaltyModal"
|
||||
hx-target="#penaltyModalBody" hx-get="{% url "leave-cut-penalty" leave_request.id %}?{{pd}}"
|
||||
type='submit' class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Penalty' %}">
|
||||
<ion-icon name="information-circle-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal2" hx-get="{% url 'request-update' leave_request.id %}"
|
||||
hx-target="#updateForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.attendance.delete_leaverequest %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" id="delete-link"
|
||||
href="{% url 'request-delete' leave_request.id %}" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline">group_by</ion-icon></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
{% if leave_request.get_penalties_count %}
|
||||
<div data-target="#penaltyViewModal" data-toggle="oh-modal-toggle"
|
||||
hx-get="{% url "view-penalties" %}?leave_request_id={{leave_request.id}}"
|
||||
hx-target="#penaltyViewModalBody" align="center" style="background-color: rgba(229, 79, 56, 0.036); border: 2px solid rgb(229, 79, 56); border-radius: 18px; padding: 10px; font-weight: bold; width: 85%;">
|
||||
{% trans "Penalties" %} :{{leave_request.get_penalties_count}}
|
||||
</button>
|
||||
{% endif %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal2" hx-get="{% url 'request-update' leave_request.id %}"
|
||||
hx-target="#updateForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.attendance.delete_leaverequest %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" id="delete-link"
|
||||
href="{% url 'request-delete' leave_request.id %}" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline">group_by</ion-icon></a>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group" >
|
||||
{% if leave_request.status == 'requested' or leave_request.status == 'rejected' %}
|
||||
<a type="submit" href="{% url 'request-approve' leave_request.id %}" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success oh-btn--disabled
|
||||
w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if leave_request.status != 'rejected' %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger oh-btn--disabled
|
||||
w-100" >
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
{% if leave_request.get_penalties_count %}
|
||||
<div data-target="#penaltyViewModal" data-toggle="oh-modal-toggle"
|
||||
hx-get="{% url "view-penalties" %}?leave_request_id={{leave_request.id}}"
|
||||
hx-target="#penaltyViewModalBody" align="center" style="background-color: rgba(229, 79, 56, 0.036); border: 2px solid rgb(229, 79, 56); border-radius: 18px; padding: 10px; font-weight: bold; width: 85%;">
|
||||
{% trans "Penalties" %} :{{leave_request.get_penalties_count}}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group" >
|
||||
{% if leave_request.status == 'cancelled' %}
|
||||
{% if leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Approve cancellation request' %}"
|
||||
class="oh-btn oh-btn--warning w-100";>
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve cancellation request' %}"
|
||||
class="oh-btn oh-btn--secondary oh-btn--disabled
|
||||
w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if leave_request.is_approved and leave_request.status == 'requested' and leave_request.end_date >= current_date %}
|
||||
<a href="{% url 'request-approve' leave_request.id %}" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success w-100" {% if leave_request.end_date.month > current_date.month %} onclick = "leaveRequestConfirm('This leave request is for the month of {{leave_request.start_date|date:'F'}}. Approval depends on the {{leave_request.employee_id.get_full_name}} having available leave days for this month.',event);" {% else %} onclick = "return confirm('Do You really want to Approve this request?')"; {% endif %}>
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success oh-btn--disabled
|
||||
w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if leave_request.status != 'rejected' and leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
|
||||
</a>
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger oh-btn--disabled
|
||||
w-100" >
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -49,186 +49,181 @@
|
||||
{% endif %}
|
||||
|
||||
{% if leave_requests %}
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table ">
|
||||
<div class="oh-sticky-table__thead">
|
||||
<div class="oh-sticky-table__tr">
|
||||
{% if not request.GET.dashboard %}
|
||||
<div class="oh-sticky-table__th" style="width: 10px">
|
||||
<div class="centered-div">
|
||||
<input
|
||||
type="checkbox"
|
||||
title='{% trans "Select All" %}'
|
||||
class="oh-input oh-input__checkbox all-leave-requests"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table ">
|
||||
<div class="oh-sticky-table__thead">
|
||||
<div class="oh-sticky-table__tr">
|
||||
{% if not request.GET.dashboard %}
|
||||
<div class="oh-sticky-table__th" style="width: 10px">
|
||||
<div class="centered-div">
|
||||
<input
|
||||
type="checkbox"
|
||||
title='{% trans "Select All" %}'
|
||||
class="oh-input oh-input__checkbox all-leave-requests"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id__employee_first_name' %}arrow-up {% elif request.sort_option.order == 'employee_id__employee_first_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=employee_id__employee_first_name&sortby=employee_id__employee_first_name" hx-target="#leaveRequest" >{% trans "Employee" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-leave_type_id' %}arrow-up {% elif request.sort_option.order == 'leave_type_id' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=leave_type_id" hx-target="#leaveRequest" >{% trans "Leave Type" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-start_date' %}arrow-up {% elif request.sort_option.order == 'start_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=start_date" hx-target="#leaveRequest" >{% trans "Start Date" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-end_date' %}arrow-up {% elif request.sort_option.order == 'end_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=end_date" hx-target="#leaveRequest" >{% trans "End Date" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-requested_days' %}arrow-up {% elif request.sort_option.order == 'requested_days' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=requested_days" hx-target="#leaveRequest" >{% trans "Requested Days" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-status' %}arrow-up {% elif request.sort_option.order == 'status' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=status" hx-target="#leaveRequest" >{% trans "Status" %}</div>
|
||||
{% if not dashboard %}
|
||||
<div class="oh-sticky-table__th" style="width:115px;">{% trans "Comment" %}</div>
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<div class="oh-sticky-table__th" style="width:200px">{% trans "Actions" %}</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__th" >{% trans "Penalties" %}</div>
|
||||
<div class="oh-sticky-table__th oh-sticky-table__right">{% trans "Confirmation" %}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody" id="leaveRequestTableBody">
|
||||
{% for leave_request in leave_requests %}
|
||||
<div class="oh-sticky-table__tr {% if leave_request.status == 'cancelled' %} diff-cell{% endif %}" draggable="true" data-toggle="oh-modal-toggle" data-target="#tableTimeOff"
|
||||
hx-get="{% url 'one-request-view' leave_request.id %}?instances_ids={{requests_ids}}" hx-target="#requestView">
|
||||
{% if not request.GET.dashboard %}
|
||||
<div class="oh-sticky-table__sd {% if leave_request.status == "requested" %} row-status--orange
|
||||
{% elif leave_request.status == "approved" %} row-status--yellow {% elif leave_request.status == "cancelled" %} row-status--gray
|
||||
{% elif leave_request.status == "rejected" %}row-status--red{% endif %}" onclick="event.stopPropagation()">
|
||||
<div class="centered-div">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="{{leave_request.id}}"
|
||||
onchange="highlightRow($(this))"
|
||||
class="oh-input holiday-checkbox oh-input__checkbox all-leave-requests-row"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="{{leave_request.employee_id.get_avatar}}" class="oh-profile__image"
|
||||
alt="" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">{{leave_request.employee_id}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td">{{leave_request.leave_type_id}}</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.start_date}}</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.end_date}}</div>
|
||||
<div class="oh-sticky-table__td">{{leave_request.requested_days}}</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{% if leave_request.multiple_approvals and leave_request.status == "requested" %}
|
||||
<div class="oh-checkpoint-badge oh-checkpoint-badge--secondary" title="{% for manager in leave_request.multiple_approvals.managers %}{{ manager }}{% if not forloop.last %} , {% endif %}{% endfor %}">
|
||||
{{leave_request.multiple_approvals.approved|length}} / {{leave_request.multiple_approvals.managers|length}} {% trans "Approved" %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{leave_request.get_status_display}}
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-employee_id__employee_first_name' %}arrow-up {% elif request.sort_option.order == 'employee_id__employee_first_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=employee_id__employee_first_name&sortby=employee_id__employee_first_name" hx-target="#leaveRequest" >{% trans "Employee" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-leave_type_id' %}arrow-up {% elif request.sort_option.order == 'leave_type_id' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=leave_type_id" hx-target="#leaveRequest" >{% trans "Leave Type" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-start_date' %}arrow-up {% elif request.sort_option.order == 'start_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=start_date" hx-target="#leaveRequest" >{% trans "Start Date" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-end_date' %}arrow-up {% elif request.sort_option.order == 'end_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=end_date" hx-target="#leaveRequest" >{% trans "End Date" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-requested_days' %}arrow-up {% elif request.sort_option.order == 'requested_days' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=requested_days" hx-target="#leaveRequest" >{% trans "Requested Days" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-status' %}arrow-up {% elif request.sort_option.order == 'status' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'request-filter' %}?{{pd}}&sortby=status" hx-target="#leaveRequest" >{% trans "Status" %}</div>
|
||||
{% if not dashboard %}
|
||||
<div class="oh-sticky-table__th" style="width:115px;">{% trans "Comment" %}</div>
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<div class="oh-sticky-table__th" style="width:200px">{% trans "Actions" %}</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__th" >{% trans "Penalties" %}</div>
|
||||
<div class="oh-sticky-table__th oh-sticky-table__right">{% trans "Confirmation" %}</div>
|
||||
</div>
|
||||
{% if not dashboard %}
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
|
||||
<button type="button" hx-get="{% url 'leave-request-view-comment' leave_request.id %}?{{pd}}&target=leaveRequest" hx-target="#commentContainer"
|
||||
data-target = '#leaveactivitySidebar' title='{% trans "Add / View Comment" %}' class="oh-btn oh-btn--light oh-activity-sidebar__open w-100" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;" onclick="event.stopPropagation()">
|
||||
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %}
|
||||
<button
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#penaltyModal"
|
||||
hx-target="#penaltyModalBody"
|
||||
hx-get="{% url "leave-cut-penalty" leave_request.id %}?{{pd}}"
|
||||
type='submit'
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Penalty' %}">
|
||||
<ion-icon name="information-circle-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager%}
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal2" hx-get="{% url 'request-update' leave_request.id %}"
|
||||
hx-target="#updateForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" id="delete-link"
|
||||
href="{% url 'request-delete' leave_request.id %}" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
{% if leave_request.get_penalties_count %}
|
||||
<div data-target="#penaltyViewModal" data-toggle="oh-modal-toggle" hx-get="{% url "view-penalties" %}?leave_request_id={{leave_request.id}}" hx-target="#penaltyViewModalBody" align="center" style="background-color: rgba(229, 79, 56, 0.036); border: 2px solid rgb(229, 79, 56); border-radius: 18px; padding: 10px; font-weight: bold; width: 85%;">{% trans "Penalties" %} :{{leave_request.get_penalties_count}}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody" id="leaveRequestTableBody">
|
||||
{% for leave_request in leave_requests %}
|
||||
<div class="oh-sticky-table__tr {% if leave_request.status == 'cancelled' %} diff-cell{% endif %}" draggable="true" data-toggle="oh-modal-toggle" data-target="#tableTimeOff"
|
||||
hx-get="{% url 'one-request-view' leave_request.id %}?instances_ids={{requests_ids}}" hx-target="#requestView">
|
||||
{% if not request.GET.dashboard %}
|
||||
<div class="oh-sticky-table__sd {% if leave_request.status == "requested" %} row-status--orange
|
||||
{% elif leave_request.status == "approved" %} row-status--yellow {% elif leave_request.status == "cancelled" %} row-status--gray
|
||||
{% elif leave_request.status == "rejected" %}row-status--red{% endif %}" onclick="event.stopPropagation()">
|
||||
<div class="centered-div">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="{{leave_request.id}}"
|
||||
onchange="highlightRow($(this))"
|
||||
class="oh-input holiday-checkbox oh-input__checkbox all-leave-requests-row"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__td">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="{{leave_request.employee_id.get_avatar}}" class="oh-profile__image"
|
||||
alt="" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">{{leave_request.employee_id}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td">{{leave_request.leave_type_id}}</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.start_date}}</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer">{{leave_request.end_date}}</div>
|
||||
<div class="oh-sticky-table__td">{{leave_request.requested_days}}</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{% if leave_request.multiple_approvals and leave_request.status == "requested" %}
|
||||
<div class="oh-checkpoint-badge oh-checkpoint-badge--secondary" title="{% for manager in leave_request.multiple_approvals.managers %}{{ manager }}{% if not forloop.last %} , {% endif %}{% endfor %}">
|
||||
{{leave_request.multiple_approvals.approved|length}} / {{leave_request.multiple_approvals.managers|length}} {% trans "Approved" %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{leave_request.get_status_display}}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not dashboard %}
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
|
||||
<button type="button" hx-get="{% url 'leave-request-view-comment' leave_request.id %}?{{pd}}&target=leaveRequest" hx-target="#commentContainer"
|
||||
data-target = '#leaveactivitySidebar' title='{% trans "Add / View Comment" %}' class="oh-btn oh-btn--light oh-activity-sidebar__open w-100" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;" onclick="event.stopPropagation()">
|
||||
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group">
|
||||
{% if request.user|is_reportingmanager or perms.attendance.chanage_penaltyaccount or request.user|is_leave_approval_manager %}
|
||||
<button
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#penaltyModal"
|
||||
hx-target="#penaltyModalBody"
|
||||
hx-get="{% url "leave-cut-penalty" leave_request.id %}?{{pd}}"
|
||||
type='submit'
|
||||
class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100"
|
||||
title="{% trans 'Penalty' %}">
|
||||
<ion-icon name="information-circle-outline"></ion-icon>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager%}
|
||||
{% if request.user|is_reportingmanager or perms.leave.chanage_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<button class="oh-btn oh-btn--light-bkg w-100" title="{% trans 'Edit' %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#editModal2" hx-get="{% url 'request-update' leave_request.id %}"
|
||||
hx-target="#updateForm"><ion-icon name="create-outline"></ion-icon></button>
|
||||
{% endif %}
|
||||
{% if request.user|is_reportingmanager or perms.leave.delete_leaverequest or request.user|is_leave_approval_manager %}
|
||||
<a class="oh-btn oh-btn--danger-outline oh-btn--light-bkg w-100" id="delete-link"
|
||||
href="{% url 'request-delete' leave_request.id %}" onclick="return confirm('{% trans "Are you sure you want to delete ?" %}');" title="{% trans 'Delete' %}"><ion-icon
|
||||
name="trash-outline"></ion-icon></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="oh-sticky-table__td" onclick="event.stopPropagation()">
|
||||
{% if leave_request.get_penalties_count %}
|
||||
<div data-target="#penaltyViewModal" data-toggle="oh-modal-toggle" hx-get="{% url "view-penalties" %}?leave_request_id={{leave_request.id}}" hx-target="#penaltyViewModalBody" align="center" style="background-color: rgba(229, 79, 56, 0.036); border: 2px solid rgb(229, 79, 56); border-radius: 18px; padding: 10px; font-weight: bold; width: 85%;">{% trans "Penalties" %} :{{leave_request.get_penalties_count}}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group" >
|
||||
{% if leave_request.status == 'cancelled' %}
|
||||
{% if leave_request.end_date >= current_date %}
|
||||
<div class="oh-sticky-table__td oh-sticky-table__right" onclick="event.stopPropagation()">
|
||||
<div class="oh-btn-group" >
|
||||
{% if leave_request.status == 'cancelled' %}
|
||||
{% if leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Approve cancellation request' %}"
|
||||
class="oh-btn oh-btn--warning w-100";>
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve cancellation request' %}"
|
||||
class="oh-btn oh-btn--secondary oh-btn--disabled
|
||||
w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if leave_request.is_approved and leave_request.status == 'requested' and leave_request.end_date >= current_date %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if leave_request.is_approved and leave_request.status == 'requested' and leave_request.end_date >= current_date %}
|
||||
<a href="{% url 'request-approve' leave_request.id %}" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success w-100" {% if leave_request.end_date.month > current_date.month %} onclick = "leaveRequestConfirm('This leave request is for the month of {{leave_request.start_date|date:'F'}}. Approval depends on the {{leave_request.employee_id.get_full_name}} having available leave days for this month.',event);" {% else %} onclick = "return confirm('Do You really want to Approve this request?')"; {% endif %}>
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% else %}
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Approve' %}"
|
||||
class="oh-btn oh-btn--success oh-btn--disabled
|
||||
w-100">
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if leave_request.status != 'rejected' and leave_request.end_date >= current_date %}
|
||||
{% endif %}
|
||||
{% if leave_request.status != 'rejected' and leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger w-100">
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
|
||||
</a>
|
||||
{% else %}
|
||||
{% else %}
|
||||
<a type="submit" href="#" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger oh-btn--disabled
|
||||
w-100" >
|
||||
class="oh-btn oh-btn--danger oh-btn--disabled w-100" >
|
||||
<ion-icon class="me-1" name="close-circle-outline"></ion-icon>
|
||||
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% elif dashboard and request.GET.dashboard != 'card' %}
|
||||
<div style="height: 310px; display:flex;align-items: center;justify-content: center;" class="">
|
||||
<div style="" class="">
|
||||
<img style=" display: block;width: 70px;margin: 10px auto ;" src="{% static 'images/ui/attendance.png' %}" class="" alt=""/>
|
||||
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "You have No leave requests for this month." %}</h3>
|
||||
</div>
|
||||
{% elif dashboard and request.GET.dashboard != 'card' %}
|
||||
<div style="height: 310px; display:flex;align-items: center;justify-content: center;" class="">
|
||||
<div style="" class="">
|
||||
<img style=" display: block;width: 70px;margin: 10px auto ;" src="{% static 'images/ui/attendance.png' %}" class="" alt=""/>
|
||||
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "You have No leave requests for this month." %}</h3>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="height: 310px; display:flex;align-items: center;justify-content: center;" class="oh-404">
|
||||
<div style="" class="">
|
||||
<img style="display: block;width: 70px;margin: 10px auto ;" src="{% static 'images/ui/attendance.png' %}" class="" alt=""/>
|
||||
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "You have No leave requests for this filter." %}</h3>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="height: 310px; display:flex;align-items: center;justify-content: center;" class="oh-404">
|
||||
<div style="" class="">
|
||||
<img style="display: block;width: 70px;margin: 10px auto ;" src="{% static 'images/ui/attendance.png' %}" class="" alt=""/>
|
||||
<h3 style="font-size:16px" class="oh-404__subtitle">{% trans "You have No leave requests for this filter." %}</h3>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- End of Sticky Table -->
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<div class="oh-timeoff-modal__stat-description">{{leave_request.reject_reason}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% elif leave_request.status == "rejected" or leave_request.status == "cancelled_and_rejected" %}
|
||||
{% elif leave_request.status == "rejected" or leave_request.status == "cancelled" %}
|
||||
<div class="oh-timeoff-modal__stats w-100 mt-3 p-2 row-status--red ">
|
||||
<div class="oh-timeoff-modal__stat">
|
||||
<span class="oh-timeoff-modal__stat-title">{% trans "Reason for Rejection" %}</span>
|
||||
@@ -127,7 +127,7 @@
|
||||
<ion-icon class="me-1" name="checkmark-outline"></ion-icon>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if leave_request.status != 'rejected' and leave_request.status != 'cancelled_and_rejected' and leave_request.end_date >= current_date %}
|
||||
{% if leave_request.status != 'rejected' and leave_request.status != 'cancelled' and leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal" hx-get="{% url 'request-cancel' leave_request.id %}" hx-target="#rejectForm" title="{% trans 'Reject' %}"
|
||||
class="oh-btn oh-btn--danger w-100">
|
||||
|
||||
@@ -1,22 +1,40 @@
|
||||
{% load i18n %}
|
||||
{% if form.errors %}
|
||||
{% load i18n %} {% if form.errors %}
|
||||
<!-- form errors -->
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-alert-container">
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form hx-post="{% url 'user-request-cancel' id %}" hx-encoding="multipart/form-data">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="editModal1ModalLabel">
|
||||
{% trans "Cancel Request" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form
|
||||
hx-post="{% url 'user-request-cancel' id %}"
|
||||
hx-encoding="multipart/form-data"
|
||||
>
|
||||
<div class="oh-general__tab-target oh-profile-section">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||
<label class="oh-label">{% trans "Cancellation Reason" %}</label>
|
||||
|
||||
{{form.reason}}
|
||||
{{form.errors}}
|
||||
|
||||
{{form.reason}} {{form.errors}}
|
||||
</div>
|
||||
<div class="d-flex flex-row-reverse">
|
||||
<button
|
||||
type="submit"
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow mt-3"
|
||||
>
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="oh-btn oh-btn--secondary ">{% trans "Submit" %}</button>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -341,22 +341,12 @@
|
||||
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="rejectModal"
|
||||
id="cancelModal"
|
||||
role="dialog"
|
||||
aria-labelledby="rejectModal"
|
||||
aria-labelledby="cancelModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<h2 class="oh-modal__dialog-title" id="editModal1ModalLabel">
|
||||
{% trans "Leave Request Create" %}
|
||||
</h2>
|
||||
<button class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body" id="rejectForm"></div>
|
||||
</div>
|
||||
>
|
||||
<div class="oh-modal__dialog" id="cancelForm"></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -120,9 +120,9 @@
|
||||
<div class="oh-sticky-table__td {% if leave_request.status == 'rejected' %} diff-cell{% endif %}" onclick="event.stopPropagation()">
|
||||
{% if leave_request.status == 'approved' and leave_request.end_date >= current_date %}
|
||||
<a type="submit" data-toggle="oh-modal-toggle"
|
||||
data-target="#rejectModal"
|
||||
data-target="#cancelModal"
|
||||
hx-get="{% url 'user-request-cancel' leave_request.id %}"
|
||||
hx-target="#rejectForm"
|
||||
hx-target="#cancelForm"
|
||||
title="{% trans 'Cancel' %}"
|
||||
class="oh-btn oh-btn--primary w-100"> {% trans "Cancel" %}
|
||||
</a>
|
||||
|
||||
@@ -1738,7 +1738,7 @@ def user_leave_request(request, id):
|
||||
|
||||
overlapping_requests = LeaveRequest.objects.filter(
|
||||
employee_id=employee, start_date__lte=end_date, end_date__gte=start_date
|
||||
).exclude(status="cancelled")
|
||||
).exclude(status__in=["cancelled","rejected"])
|
||||
if overlapping_requests.exists():
|
||||
form.add_error(
|
||||
None, _("There is already a leave request for this date range..")
|
||||
|
||||
Reference in New Issue
Block a user