Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

79 improve reporting #86

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hermes v1.5.3
# Hermes v1.5.4

Hermes is a FastAPI powered employee management web application.
It allows you to manage your employees, their roles, and their onboarding/offboarding status.
Expand Down
52 changes: 41 additions & 11 deletions routers/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ async def get_reporting(request: Request, report_type: Optional[int] = 0, start_
"start_date": start_date,
"end_date": end_date
}

settings = db.query(models.Settings).order_by(models.Settings.id.desc()).first()
countries = db.query(models.Country).order_by(models.Country.name).all()
sites = db.query(models.Sites).order_by(models.Sites.name).all()
departments = db.query(models.Departments).order_by(models.Departments.name).all()
currencies = db.query(models.Currency).order_by(models.Currency.name).all()
employment_contracts = db.query(models.Contracts).order_by(models.Contracts.name).all()
employment_types = db.query(models.Employment).order_by(models.Employment.name).all()
employers = db.query(models.Employers).order_by(models.Employers.name).all()
hr_teams = db.query(models.Teams).order_by(models.Teams.name).all()
salary_pay_frequency = db.query(models.PayFrequency).order_by(models.PayFrequency.name).all()

# Convert start_date and end_date to strings in the 'YYYY-MM-DD' format
start_date_str = start_date.strftime('%Y-%m-%d')
Expand Down Expand Up @@ -70,26 +81,56 @@ async def get_reporting(request: Request, report_type: Optional[int] = 0, start_
.filter(models.Employees.employment_status_id == 0)\
.filter(models.Employees.department_id == departmentValue)\
.all()
departments = db.query(models.Departments)\
.join(models.Employees, models.Departments.id == models.Employees.department_id)\
.filter(models.Employees.employment_status_id == 0)\
.group_by(models.Departments.id)\
.order_by(models.Departments.name)\
.all()
elif report_type == 6:
report_data = db.query(models.Employees)\
.filter(models.Employees.employment_status_id == 0)\
.filter(models.Employees.country_of_origin_id == countryValue)\
.all()
countries = db.query(models.Country)\
.join(models.Employees, models.Country.id == models.Employees.country_of_origin_id)\
.filter(models.Employees.employment_status_id == 0)\
.group_by(models.Country.id)\
.order_by(models.Country.name)\
.all()
elif report_type == 7:
report_data = db.query(models.Employees)\
.filter(models.Employees.employment_status_id == 0)\
.filter(models.Employees.working_country_id == countryValue)\
.all()
countries = db.query(models.Country)\
.join(models.Employees, models.Country.id == models.Employees.working_country_id)\
.filter(models.Employees.employment_status_id == 0)\
.group_by(models.Country.id)\
.order_by(models.Country.name)\
.all()
elif report_type == 8:
report_data = db.query(models.Employees)\
.filter(models.Employees.employment_status_id == 0)\
.filter(models.Employees.site_id == siteValue)\
.all()
sites = db.query(models.Sites)\
.join(models.Employees, models.Sites.id == models.Employees.site_id)\
.filter(models.Employees.employment_status_id == 0)\
.group_by(models.Sites.id)\
.order_by(models.Sites.name)\
.all()
elif report_type == 9:
report_data = db.query(models.Employees)\
.filter(models.Employees.employment_status_id == 0)\
.filter(models.Employees.employment_contract_id == employmentValue)\
.all()
employment_contracts = db.query(models.Contracts)\
.join(models.Employees, models.Contracts.id == models.Employees.employment_contract_id)\
.filter(models.Employees.employment_status_id == 0)\
.group_by(models.Contracts.id)\
.order_by(models.Contracts.name)\
.all()
else:
report_data = None

Expand All @@ -106,17 +147,6 @@ async def get_reporting(request: Request, report_type: Optional[int] = 0, start_

role_state = db.query(models.Roles).filter(models.Roles.id == logged_in_user['role_id']).first()

settings = db.query(models.Settings).order_by(models.Settings.id.desc()).first()
countries = db.query(models.Country).order_by(models.Country.name).all()
sites = db.query(models.Sites).order_by(models.Sites.name).all()
departments = db.query(models.Departments).order_by(models.Departments.name).all()
currencies = db.query(models.Currency).order_by(models.Currency.name).all()
employment_contracts = db.query(models.Contracts).order_by(models.Contracts.name).all()
employment_types = db.query(models.Employment).order_by(models.Employment.name).all()
employers = db.query(models.Employers).order_by(models.Employers.name).all()
hr_teams = db.query(models.Teams).order_by(models.Teams.name).all()
salary_pay_frequency = db.query(models.PayFrequency).order_by(models.PayFrequency.name).all()

return templates.TemplateResponse("reporting.html", {"request": request, "logged_in_user": logged_in_user, "role_state": role_state, "nav": 'reporting', "header_value": header_value, "report_data": report_data, "countries": countries, "sites": sites, "departments": departments, "currencies": currencies, "employment_contracts": employment_contracts, "employment_types": employment_types, "employers": employers, "hr_teams": hr_teams, "salary_pay_frequency": salary_pay_frequency, "settings": settings, "manager": manager, "departmentValue": departmentValue, "countryValue": countryValue, "siteValue": siteValue, "employmentValue": employmentValue, "nav_profile_load": nav_profile_load})

@router.get("/download_csv/{report_type}")
Expand Down
21 changes: 14 additions & 7 deletions templates/reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ <h3 style="display: inline-block; margin-right: 30px;">Reporting</h3>
<option value="9" {% if header_value.report_type == 9%} selected="selected" {% endif %}>By Contract Type</option>
</select>
</div>
<div style="width: 160px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 160px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">Start Date</label>
<input type="date" class="form-control" name="start_date" id="startDate" value="{{header_value.start_date.strftime('%Y-%m-%d')}}" required>
</div>
<div style="width: 160px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 160px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">End Date</label>
<input type="date" class="form-control" name="end_date" id="endDate" value="{{header_value.end_date.strftime('%Y-%m-%d')}}" required>
</div>
<div style="width: 300px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 300px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">Manager</label>
<input type="text" class="form-control" name="manager_search" id="managerSearch" value="{{manager}}" required>
</div>
<div style="width: 300px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 300px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">Department</label>
<select class="form-control" name="department_list" id="departmentList">
<option value="0">Select Department</option>
Expand All @@ -41,7 +41,7 @@ <h3 style="display: inline-block; margin-right: 30px;">Reporting</h3>
{% endfor %}
</select>
</div>
<div style="width: 300px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 300px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">Country</label>
<select class="form-control" name="country_list" id="countryList">
<option value="0">Select Country</option>
Expand All @@ -50,7 +50,7 @@ <h3 style="display: inline-block; margin-right: 30px;">Reporting</h3>
{% endfor %}
</select>
</div>
<div style="width: 300px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 300px; display: none text-align: left;" class="form-group">
<label style="margin-left: 10px;">Site</label>
<select class="form-control" name="site_list" id="siteList">
<option value="0">Select Site</option>
Expand All @@ -59,7 +59,7 @@ <h3 style="display: inline-block; margin-right: 30px;">Reporting</h3>
{% endfor %}
</select>
</div>
<div style="width: 300px; display: inline-block; text-align: left;" class="form-group">
<div style="width: 300px; display: none; text-align: left;" class="form-group">
<label style="margin-left: 10px;">Contract Type</label>
<select class="form-control" name="employment_list" id="employmentList">
<option value="0">Select Contract Type</option>
Expand Down Expand Up @@ -288,8 +288,12 @@ <h5>No data is available</h5>
window.location.href = url;
});
document.getElementById('reportType').addEventListener('change', function() {
var reportType = document.getElementById('reportType').value;
var url = "/reporting/?report_type=" + reportType

if (this.value == '1' || this.value == '2')
{

document.getElementById('startDate').parentElement.style.display = 'inline-block';
document.getElementById('endDate').parentElement.style.display = 'inline-block';
document.getElementById('managerSearch').parentElement.style.display = 'none';
Expand All @@ -307,6 +311,7 @@ <h5>No data is available</h5>
document.getElementById('countryList').parentElement.style.display = 'none';
document.getElementById('siteList').parentElement.style.display = 'none';
document.getElementById('employmentList').parentElement.style.display = 'none';
var url = "/reporting/?report_type=" + reportType + "&manager=";
}
else if (this.value == '5')
{
Expand Down Expand Up @@ -358,6 +363,8 @@ <h5>No data is available</h5>
document.getElementById('siteList').parentElement.style.display = 'none';
document.getElementById('employmentList').parentElement.style.display = 'none';
}

window.location.href = url;
});
function checkReportType() {
var reportType = document.getElementById('reportType');
Expand Down
2 changes: 1 addition & 1 deletion templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ <h1>About Hermes</h1>
<p>Hermes is an open source web application that allows you to manage your companies employees.</p>
<br>
<h2>Version</h2>
<p>Version 1.5.3</p>
<p>Version 1.5.4</p>
<br>
<h2>Licenses</h2>
<ul class="list-unstyled">
Expand Down