592 lines
33 KiB
HTML
592 lines
33 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Time Entries | HR Management{% endblock %}
|
|
|
|
{% block css %}
|
|
<!-- DataTables CSS -->
|
|
<link href="{% static 'plugins/datatables.net-bs5/css/dataTables.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'plugins/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<!-- DateRangePicker CSS -->
|
|
<link href="{% static 'plugins/bootstrap-daterangepicker/daterangepicker.css' %}" rel="stylesheet" />
|
|
<style>
|
|
.filter-card {
|
|
background-color: #f8f9fa;
|
|
border-radius: 5px;
|
|
padding: 15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.status-badge {
|
|
width: 10px;
|
|
height: 10px;
|
|
display: inline-block;
|
|
border-radius: 50%;
|
|
margin-right: 5px;
|
|
}
|
|
.status-pending {
|
|
background-color: #ffc107;
|
|
}
|
|
.status-approved {
|
|
background-color: #28a745;
|
|
}
|
|
.status-rejected {
|
|
background-color: #dc3545;
|
|
}
|
|
.time-entry-card {
|
|
transition: all 0.3s ease;
|
|
}
|
|
.time-entry-card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
|
|
}
|
|
.summary-card {
|
|
border-left: 4px solid #2d62ed;
|
|
}
|
|
.view-toggle .btn {
|
|
min-width: 100px;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- begin breadcrumb -->
|
|
<ol class="breadcrumb float-xl-end">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Home</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'hr:dashboard' %}">HR</a></li>
|
|
<li class="breadcrumb-item active">Time Entries</li>
|
|
</ol>
|
|
<!-- end breadcrumb -->
|
|
|
|
<!-- begin page-header -->
|
|
<h1 class="page-header">Time Entries <small>view and manage employee time records</small></h1>
|
|
<!-- end page-header -->
|
|
|
|
<!-- begin row -->
|
|
<div class="row">
|
|
<!-- begin col-12 -->
|
|
<div class="col-xl-12">
|
|
<!-- Summary Cards -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-3">
|
|
<div class="card summary-card h-100">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<h5 class="card-title">Total Hours</h5>
|
|
<h2 class="mb-0">{{ total_hours|default:"0" }}</h2>
|
|
</div>
|
|
<div class="text-primary">
|
|
<i class="fas fa-clock fa-3x"></i>
|
|
</div>
|
|
</div>
|
|
<p class="card-text text-muted">Current period</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="card summary-card h-100" style="border-left-color: #28a745;">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<h5 class="card-title">Approved</h5>
|
|
<h2 class="mb-0">{{ approved_hours|default:"0" }}</h2>
|
|
</div>
|
|
<div class="text-success">
|
|
<i class="fas fa-check-circle fa-3x"></i>
|
|
</div>
|
|
</div>
|
|
<p class="card-text text-muted">Hours approved</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="card summary-card h-100" style="border-left-color: #ffc107;">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<h5 class="card-title">Pending</h5>
|
|
<h2 class="mb-0">{{ pending_hours|default:"0" }}</h2>
|
|
</div>
|
|
<div class="text-warning">
|
|
<i class="fas fa-hourglass-half fa-3x"></i>
|
|
</div>
|
|
</div>
|
|
<p class="card-text text-muted">Hours pending approval</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="card summary-card h-100" style="border-left-color: #dc3545;">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<h5 class="card-title">Overtime</h5>
|
|
<h2 class="mb-0">{{ overtime_hours|default:"0" }}</h2>
|
|
</div>
|
|
<div class="text-danger">
|
|
<i class="fas fa-exclamation-circle fa-3x"></i>
|
|
</div>
|
|
</div>
|
|
<p class="card-text text-muted">Overtime hours</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- begin panel -->
|
|
<div class="panel panel-inverse">
|
|
<!-- begin panel-heading -->
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Time Entries</h4>
|
|
<div class="panel-heading-btn">
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-success" data-toggle="panel-reload"><i class="fa fa-redo"></i></a>
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-warning" data-toggle="panel-collapse"><i class="fa fa-minus"></i></a>
|
|
</div>
|
|
</div>
|
|
<!-- end panel-heading -->
|
|
|
|
<!-- begin panel-body -->
|
|
<div class="panel-body">
|
|
<!-- Filters -->
|
|
<div class="filter-card">
|
|
<form method="get" id="filterForm">
|
|
<div class="row g-3">
|
|
<div class="col-md-3">
|
|
<label for="employee" class="form-label">Employee</label>
|
|
<select class="form-select" id="employee" name="employee">
|
|
<option value="">All Employees</option>
|
|
{% for employee in employees %}
|
|
<option value="{{ employee.id }}" {% if selected_employee == employee.id %}selected{% endif %}>
|
|
{{ employee.get_full_name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label for="department" class="form-label">Department</label>
|
|
<select class="form-select" id="department" name="department">
|
|
<option value="">All Departments</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if selected_department == dept.id %}selected{% endif %}>
|
|
{{ dept.name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label for="status" class="form-label">Status</label>
|
|
<select class="form-select" id="status" name="status">
|
|
<option value="">All Statuses</option>
|
|
<option value="PENDING" {% if selected_status == 'PENDING' %}selected{% endif %}>Pending</option>
|
|
<option value="APPROVED" {% if selected_status == 'APPROVED' %}selected{% endif %}>Approved</option>
|
|
<option value="REJECTED" {% if selected_status == 'REJECTED' %}selected{% endif %}>Rejected</option>
|
|
</select>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label for="date_range" class="form-label">Date Range</label>
|
|
<input type="text" class="form-control" id="date_range" name="date_range" value="{{ date_range }}">
|
|
</div>
|
|
<div class="col-md-12">
|
|
<div class="d-flex">
|
|
<button type="submit" class="btn btn-primary me-2">
|
|
<i class="fas fa-filter"></i> Apply Filters
|
|
</button>
|
|
<a href="{% url 'hr:time_entry_list' %}" class="btn btn-secondary me-2">
|
|
<i class="fas fa-times"></i> Clear Filters
|
|
</a>
|
|
<div class="dropdown ms-auto">
|
|
<button class="btn btn-outline-secondary dropdown-toggle" type="button" id="exportDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="fas fa-download"></i> Export
|
|
</button>
|
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="exportDropdown">
|
|
<li><a class="dropdown-item" href="#" id="export-pdf"><i class="fas fa-file-pdf"></i> PDF</a></li>
|
|
<li><a class="dropdown-item" href="#" id="export-excel"><i class="fas fa-file-excel"></i> Excel</a></li>
|
|
<li><a class="dropdown-item" href="#" id="export-csv"><i class="fas fa-file-csv"></i> CSV</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between mb-3">
|
|
<div>
|
|
<a href="{% url 'hr:time_entry_create' %}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i> Create Time Entry
|
|
</a>
|
|
<div class="btn-group ms-2 view-toggle" role="group">
|
|
<button type="button" class="btn btn-outline-secondary active" id="table-view-btn">
|
|
<i class="fas fa-table"></i> Table
|
|
</button>
|
|
<button type="button" class="btn btn-outline-secondary" id="card-view-btn">
|
|
<i class="fas fa-th-large"></i> Cards
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<form method="get" class="d-flex">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" placeholder="Search entries..." name="search" value="{{ search }}">
|
|
<button class="btn btn-outline-secondary" type="submit">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Table View -->
|
|
<div id="table-view">
|
|
<table id="time-entries-table" class="table table-striped table-bordered align-middle">
|
|
<thead>
|
|
<tr>
|
|
<th>Employee</th>
|
|
<th>Date</th>
|
|
<th>Time</th>
|
|
<th>Hours</th>
|
|
<th>Type</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for entry in time_entries %}
|
|
<tr>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<div class="avatar avatar-sm me-2">
|
|
<img src="{% static 'img/user/default-avatar.jpg' %}" alt="{{ entry.employee.get_full_name }}" class="rounded-circle">
|
|
</div>
|
|
<div>
|
|
<a href="{% url 'hr:employee_detail' entry.employee.id %}">
|
|
{{ entry.employee.get_full_name }}
|
|
</a>
|
|
<small class="d-block text-muted">{{ entry.employee.job_title }}</small>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>{{ entry.date|date:"M d, Y" }}</td>
|
|
<td>{{ entry.start_time|time:"H:i" }} - {{ entry.end_time|time:"H:i" }}</td>
|
|
<td>{{ entry.hours }} hrs</td>
|
|
<td>
|
|
{% if entry.is_overtime %}
|
|
<span class="badge bg-danger">Overtime</span>
|
|
{% else %}
|
|
<span class="badge bg-primary">Regular</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if entry.status == 'PENDING' %}
|
|
<span class="status-badge status-pending"></span> Pending
|
|
{% elif entry.status == 'APPROVED' %}
|
|
<span class="status-badge status-approved"></span> Approved
|
|
{% elif entry.status == 'REJECTED' %}
|
|
<span class="status-badge status-rejected"></span> Rejected
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="btn-group">
|
|
<a href="{% url 'hr:time_entry_detail' entry.id %}" class="btn btn-sm btn-info">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
<a href="{% url 'hr:time_entry_update' entry.id %}" class="btn btn-sm btn-primary">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
{% if entry.status == 'PENDING' and perms.hr.approve_time_entry %}
|
|
<a href="{% url 'hr:time_entry_approve' entry.id %}" class="btn btn-sm btn-success">
|
|
<i class="fas fa-check"></i>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="text-center">No time entries found.</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- Pagination -->
|
|
{% if is_paginated %}
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination justify-content-center">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="First">
|
|
<span aria-hidden="true">««</span>
|
|
</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
{% for num in page_obj.paginator.page_range %}
|
|
{% if page_obj.number == num %}
|
|
<li class="page-item active"><a class="page-link" href="#">{{ num }}</a></li>
|
|
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
|
|
<li class="page-item"><a class="page-link" href="?page={{ num }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}">{{ num }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Last">
|
|
<span aria-hidden="true">»»</span>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Card View -->
|
|
<div id="card-view" class="row g-3" style="display: none;">
|
|
{% for entry in time_entries %}
|
|
<div class="col-md-6 col-lg-4">
|
|
<div class="card time-entry-card h-100">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">{{ entry.employee.get_full_name }}</h5>
|
|
{% if entry.status == 'PENDING' %}
|
|
<span class="badge bg-warning">Pending</span>
|
|
{% elif entry.status == 'APPROVED' %}
|
|
<span class="badge bg-success">Approved</span>
|
|
{% elif entry.status == 'REJECTED' %}
|
|
<span class="badge bg-danger">Rejected</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div class="avatar avatar-md me-3">
|
|
<img src="{% static 'img/user/default-avatar.jpg' %}" alt="{{ entry.employee.get_full_name }}" class="rounded-circle">
|
|
</div>
|
|
<div>
|
|
<p class="card-text mb-0">{{ entry.employee.job_title }}</p>
|
|
<small class="text-muted">
|
|
{% if entry.employee.department %}
|
|
{{ entry.employee.department.name }}
|
|
{% else %}
|
|
No Department
|
|
{% endif %}
|
|
</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<strong>Date:</strong> {{ entry.date|date:"M d, Y" }}
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<strong>Time:</strong> {{ entry.start_time|time:"H:i" }} - {{ entry.end_time|time:"H:i" }}
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<strong>Hours:</strong> {{ entry.hours }} hrs
|
|
{% if entry.is_overtime %}
|
|
<span class="badge bg-danger ms-2">Overtime</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if entry.description %}
|
|
<div class="mb-3">
|
|
<strong>Description:</strong>
|
|
<p class="mb-0">{{ entry.description|truncatechars:100 }}</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<div class="card-footer">
|
|
<div class="btn-group w-100">
|
|
<a href="{% url 'hr:time_entry_detail' entry.id %}" class="btn btn-sm btn-info">
|
|
<i class="fas fa-eye"></i> View
|
|
</a>
|
|
<a href="{% url 'hr:time_entry_update' entry.id %}" class="btn btn-sm btn-primary">
|
|
<i class="fas fa-edit"></i> Edit
|
|
</a>
|
|
{% if entry.status == 'PENDING' and perms.hr.approve_time_entry %}
|
|
<a href="{% url 'hr:time_entry_approve' entry.id %}" class="btn btn-sm btn-success">
|
|
<i class="fas fa-check"></i> Approve
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="col-12">
|
|
<div class="alert alert-info">
|
|
No time entries found.
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<!-- Pagination for Card View -->
|
|
{% if is_paginated %}
|
|
<div class="col-12 mt-3">
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination justify-content-center">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="First">
|
|
<span aria-hidden="true">««</span>
|
|
</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
{% for num in page_obj.paginator.page_range %}
|
|
{% if page_obj.number == num %}
|
|
<li class="page-item active"><a class="page-link" href="#">{{ num }}</a></li>
|
|
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
|
|
<li class="page-item"><a class="page-link" href="?page={{ num }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}">{{ num }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if search %}&search={{ search }}{% endif %}{% if selected_employee %}&employee={{ selected_employee }}{% endif %}{% if selected_department %}&department={{ selected_department }}{% endif %}{% if selected_status %}&status={{ selected_status }}{% endif %}{% if date_range %}&date_range={{ date_range }}{% endif %}" aria-label="Last">
|
|
<span aria-hidden="true">»»</span>
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<!-- end panel-body -->
|
|
</div>
|
|
<!-- end panel -->
|
|
</div>
|
|
<!-- end col-12 -->
|
|
</div>
|
|
<!-- end row -->
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<!-- DataTables JS -->
|
|
<script src="{% static 'plugins/datatables.net/js/jquery.dataTables.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-bs5/js/dataTables.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-responsive/js/dataTables.responsive.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-responsive-bs5/js/responsive.bootstrap5.min.js' %}"></script>
|
|
<!-- DateRangePicker JS -->
|
|
<script src="{% static 'plugins/moment/min/moment.min.js' %}"></script>
|
|
<script src="{% static 'plugins/bootstrap-daterangepicker/daterangepicker.js' %}"></script>
|
|
<!-- Select2 JS -->
|
|
<script src="{% static 'plugins/select2/dist/js/select2.min.js' %}"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Initialize DataTable
|
|
var table = $('#time-entries-table').DataTable({
|
|
dom: "<'row'<'col-md-6'l><'col-md-6'f>><'row'<'col-md-12't>><'row'<'col-md-5'i><'col-md-7'p>>",
|
|
lengthMenu: [10, 25, 50, 100],
|
|
responsive: true,
|
|
paging: false, // We're using Django's pagination
|
|
searching: false, // We're using our own search
|
|
info: false // We're using Django's pagination info
|
|
});
|
|
|
|
// Initialize DateRangePicker
|
|
$('#date_range').daterangepicker({
|
|
opens: 'left',
|
|
autoUpdateInput: false,
|
|
locale: {
|
|
cancelLabel: 'Clear',
|
|
format: 'YYYY-MM-DD'
|
|
}
|
|
});
|
|
|
|
$('#date_range').on('apply.daterangepicker', function(ev, picker) {
|
|
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
|
|
});
|
|
|
|
$('#date_range').on('cancel.daterangepicker', function(ev, picker) {
|
|
$(this).val('');
|
|
});
|
|
|
|
// Initialize Select2
|
|
$('#employee, #department, #status').select2({
|
|
placeholder: "Select an option",
|
|
allowClear: true
|
|
});
|
|
|
|
// View toggle functionality
|
|
$('#table-view-btn').click(function() {
|
|
$(this).addClass('active');
|
|
$('#card-view-btn').removeClass('active');
|
|
$('#table-view').show();
|
|
$('#card-view').hide();
|
|
localStorage.setItem('time-entry-view', 'table');
|
|
});
|
|
|
|
$('#card-view-btn').click(function() {
|
|
$(this).addClass('active');
|
|
$('#table-view-btn').removeClass('active');
|
|
$('#table-view').hide();
|
|
$('#card-view').show();
|
|
localStorage.setItem('time-entry-view', 'card');
|
|
});
|
|
|
|
// Load saved view preference
|
|
var savedView = localStorage.getItem('time-entry-view');
|
|
if (savedView === 'card') {
|
|
$('#card-view-btn').click();
|
|
}
|
|
|
|
// Export functionality
|
|
$('#export-pdf').click(function(e) {
|
|
e.preventDefault();
|
|
var url = '{% url "hr:export_time_entries" %}?format=pdf';
|
|
var filterParams = $('#filterForm').serialize();
|
|
if (filterParams) {
|
|
url += '&' + filterParams;
|
|
}
|
|
window.location.href = url;
|
|
});
|
|
|
|
$('#export-excel').click(function(e) {
|
|
e.preventDefault();
|
|
var url = '{% url "hr:export_time_entries" %}?format=excel';
|
|
var filterParams = $('#filterForm').serialize();
|
|
if (filterParams) {
|
|
url += '&' + filterParams;
|
|
}
|
|
window.location.href = url;
|
|
});
|
|
|
|
$('#export-csv').click(function(e) {
|
|
e.preventDefault();
|
|
var url = '{% url "hr:export_time_entries" %}?format=csv';
|
|
var filterParams = $('#filterForm').serialize();
|
|
if (filterParams) {
|
|
url += '&' + filterParams;
|
|
}
|
|
window.location.href = url;
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|