[UPDT] DASHBOARD: Changed on leave method in dashboard and added empty page html
This commit is contained in:
@@ -1,23 +1,34 @@
|
||||
$(document).ready(function () {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/leave/employee-leave",
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
$.each(response.employees, function (index, value) {
|
||||
$("#leaveEmployee").append(
|
||||
`<li class="oh-card-dashboard__user-item">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=${value}&background=random" class="oh-profile__image"
|
||||
alt="Beth Gibbons" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">${value}</span>
|
||||
</div>
|
||||
</li>
|
||||
`
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
// $(document).ready(function () {
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: "/leave/employee-leave",
|
||||
// dataType: "json",
|
||||
// success: function (response) {
|
||||
// if (response.employees.length) {
|
||||
// $.each(response.employees, function (index, value) {
|
||||
// $("#leaveEmployee").append(
|
||||
// `<li class="oh-card-dashboard__user-item">
|
||||
// <div class="oh-profile oh-profile--md">
|
||||
// <div class="oh-profile__avatar mr-1">
|
||||
// <img src="https://ui-avatars.com/api/?name=${value}&background=random" class="oh-profile__image"
|
||||
// alt="Beth Gibbons" />
|
||||
// </div>
|
||||
// <span class="oh-profile__name oh-text--dark">${value}</span>
|
||||
// </div>
|
||||
// </li>`
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// else{
|
||||
// $("#leaveEmployee").append(
|
||||
// `<div class="">
|
||||
// <div class="oh-404" style="position:revert; transform:none">
|
||||
// <img style="width: 80px;height: 80px; margin-bottom:20px" src="{% static 'images/ui/no-announcement.svg' %}" class="oh-404__image" alt="Page not found. 404."/>
|
||||
// <h5 class="oh-404__subtitle">No Announcements to show.</h5>
|
||||
// </div>
|
||||
// </div>`
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
37
leave/templates/leave/on_leave.html
Normal file
37
leave/templates/leave/on_leave.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% load static i18n %}
|
||||
{% if employees %}
|
||||
<div class="oh-card-dashboard__body">
|
||||
<ul class="oh-card-dashboard__user-list" id="leaveEmployee">
|
||||
{% for employee in employees %}
|
||||
<li class="oh-card-dashboard__user-item">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img
|
||||
src="{{employee.get_avatar}}"
|
||||
class="oh-profile__image"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark"
|
||||
>{{employee.get_full_name}}</span
|
||||
>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<div style="margin-top: 30%">
|
||||
<div class="oh-404" style="position: revert; transform: none">
|
||||
<img
|
||||
style="width: 80px; height: 80px; margin-bottom: 20px"
|
||||
src="{% static 'images/ui/attendance.png' %}"
|
||||
class="oh-404__image"
|
||||
alt="Page not found. 404."
|
||||
/>
|
||||
<h5 class="oh-404__subtitle">
|
||||
{% trans "No Leave request for today." %}
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -2198,16 +2198,13 @@ def employee_leave(request):
|
||||
"""
|
||||
today = date.today()
|
||||
employees = []
|
||||
leave_requests = LeaveRequest.objects.filter(
|
||||
Q(start_date__lte=today)
|
||||
& Q(end_date__gte=today)
|
||||
& Q(status="approved")
|
||||
& Q(employee_id__is_active=True)
|
||||
)
|
||||
leave_requests = LeaveRequest.objects.filter(status="approved")
|
||||
|
||||
for leave_request in leave_requests:
|
||||
if leave_request.employee_id.__str__() not in employees:
|
||||
employees.append(leave_request.employee_id.__str__())
|
||||
return JsonResponse({"employees": employees})
|
||||
if today in leave_request.requested_dates():
|
||||
employees.append(leave_request.employee_id)
|
||||
return render(request,"leave/on_leave.html",{'employees':employees})
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
|
||||
@@ -734,135 +734,12 @@
|
||||
>
|
||||
<span class="oh-card-dashboard__title">{% trans "On Leave" %}</span>
|
||||
</div>
|
||||
<div class="oh-card-dashboard__body">
|
||||
<ul class="oh-card-dashboard__user-list" id="leaveEmployee"></ul>
|
||||
<div class="oh-card-dashboard__body"
|
||||
hx-get="{% url 'employee-leave' %}"
|
||||
hx-trigger="load">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% comment %} <div class="oh-card-dashboard oh-card-dashboard--no-scale oh-card-dashboard--transparent mb-3 mt-2">
|
||||
<div class="oh-card-dashboard__title mt-4 mb-3">{% trans "Quick Actions" %}</div> <hr>
|
||||
|
||||
<div class="oh-card-dashboard__body">
|
||||
<div class="oh-sticky-table" style="height:400px; border:none;">
|
||||
<div class="oh-sticky-table__table oh-table--sortable">
|
||||
<div class="oh-sticky-table__tbody">
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle="oh-modal-toggle" style="text-decoration:none;"
|
||||
data-target="#newAttendanceRequest"
|
||||
hx-get="{% url 'request-new-attendance' %}"
|
||||
hx-target="#newAttendanceRequestModalBody">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=A R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Attendance Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle="oh-modal-toggle" style="text-decoration:none;"
|
||||
data-target="#requestCreateModal"
|
||||
hx-get="{% url 'leave-request-create' %}"
|
||||
hx-target="#requestCreateFormModal">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=L R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Leave Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle="oh-modal-toggle" style="text-decoration:none;"
|
||||
data-target="#shiftRequestModal"
|
||||
hx-get="{% url 'shift-request' %}?emp_id={{request.user.employee_get.id}}"
|
||||
hx-target="#shiftRequestTargetModal">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=S R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Shift Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle='oh-modal-toggle' style="text-decoration:none;"
|
||||
data-target='#workTypeRequestModal'
|
||||
hx-get="{% url 'work-type-request' %}"
|
||||
hx-target='#formBody'>
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=W R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Worktype Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" hx-get="{% url 'create-reimbursement' %}" style="text-decoration:none;"
|
||||
hx-target="#reimbursementModalBody" data-toggle="oh-modal-toggle" data-target="#reimbursementModal">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=R R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Reimbursement Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle="oh-modal-toggle" style="text-decoration:none;"
|
||||
data-target="#asset-request-allocation-modal"
|
||||
hx-get="{%url 'asset-request-creation'%}"
|
||||
hx-target="#asset-request-allocation-modal-target">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=A R&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Asset Request" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="oh-sticky-table__tr" draggable="true">
|
||||
<div class="oh-kanban-card__title">
|
||||
<a class="oh-profile oh-profile--md" data-toggle="oh-modal-toggle" style="text-decoration:none;"
|
||||
data-target="#createModal1"
|
||||
hx-get="{% url 'ticket-create' %}"
|
||||
hx-target="#createTarget">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img src="https://ui-avatars.com/api/?name=T C&background=random" class="oh-profile__image" />
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">
|
||||
{% trans "Ticket Creation" %}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> {% endcomment %}
|
||||
|
||||
{% if perms.leave.view_leaverequest or request.user|is_reportingmanager%}
|
||||
<div
|
||||
class="oh-card-dashboard oh-card-dashboard--no-scale oh-card-dashboard--transparent"
|
||||
|
||||
Reference in New Issue
Block a user