redesigned

This commit is contained in:
muahahahh 2021-01-09 18:31:20 +01:00
parent d3ff467459
commit a49c50f91e
34 changed files with 363 additions and 84 deletions

Binary file not shown.

View File

@ -1,32 +1,39 @@
#hr_module_main_container { #hr_module_main_container {
padding: 1%; padding-top: 10px;
padding-left: 10px;
float: left; float: left;
width: 80%; width: 78%;
height: 100%; height: 100%;
background-color: whitesmoke; background-color: whitesmoke;
text-align: center; text-align: center;
} }
#sidebar {
.sidebar { background-color: #202831;
background-color: #8b0000;
width: 18%; width: 18%;
height: 100%; height: 100%;
float: left; float: left;
padding: 10px;
} }
.sidebar_item { .sidebar_item {
background-color: navajowhite; background-color: #202831;
margin-right: 6px;
margin-left: 6px;
margin-top: 6px;
padding: 10px; padding: 10px;
font-size: 20px; font-size: 20px;
color: #7F8B94;
}
.sidebar_item_active {
background-color: #191E24;
color: #53B6FF;
}
a {
text-decoration: none;
} }
.sidebar_item:hover { .sidebar_item:hover {
background-color: white; background-color: #43505e;
cursor: pointer; cursor: pointer;
} }

View File

@ -0,0 +1,12 @@
window.addEventListener('load', function(){
var sidebarItems = document.getElementById('sidebar').getElementsByTagName('a')
var pathName = window.location.pathname
for (var i = 0; i < sidebarItems.length; i++){
var pathLink = sidebarItems[i].getAttribute('href')
if (pathName == pathLink){
sidebarItems[i].firstElementChild.classList.add('sidebar_item_active')
}
}
})

View File

@ -7,6 +7,7 @@ const csrftoken = getCookie('csrftoken');
window.addEventListener('load', function(){ window.addEventListener('load', function(){
var parent = document.getElementById('calendar_box') var parent = document.getElementById('calendar_box')
parent.appendChild(addCalendar(monthsAhead=3)) parent.appendChild(addCalendar(monthsAhead=3))
appendLegend()
fetchDays() fetchDays()
formatCalendarContainerSize(document.getElementById('calendar_container')) formatCalendarContainerSize(document.getElementById('calendar_container'))
document.getElementById('calendar_button_back').addEventListener('click', function(){ document.getElementById('calendar_button_back').addEventListener('click', function(){
@ -120,14 +121,16 @@ function formatCalendarContainerSize(calendarContainer){
var monthsBlock = calendarContainer.querySelector('#months_block') var monthsBlock = calendarContainer.querySelector('#months_block')
var calendarButton = calendarContainer.querySelector('#calendar_button_back') var calendarButton = calendarContainer.querySelector('#calendar_button_back')
var dateSelector = calendarContainer.querySelector('#date_selector') var dateSelector = calendarContainer.querySelector('#date_selector')
var legendSelector = calendarContainer.querySelector('#legend_container')
var widthMonths = monthsBlock.offsetWidth var widthMonths = monthsBlock.offsetWidth
var heightMonths = monthsBlock.offsetHeight var heightMonths = monthsBlock.offsetHeight
var heightDateSelector = dateSelector.offsetHeight var heightDateSelector = dateSelector.offsetHeight
var heightLegend = legendSelector.offsetHeight
var widthCalendarButton = calendarButton.offsetWidth * 2 var widthCalendarButton = calendarButton.offsetWidth * 2
var widthTotal = widthMonths + widthCalendarButton var widthTotal = widthMonths + widthCalendarButton
var heightTotal = heightMonths + heightDateSelector var heightTotal = heightMonths + heightDateSelector + heightLegend
calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px'); calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px');
} }
@ -172,3 +175,27 @@ function getCookie(name) {
} }
return cookieValue; return cookieValue;
} }
function appendLegend(){
var calendar = document.getElementById('calendar_container')
var container = document.createElement('div')
container.id = 'legend_container'
var activityTypes = ['work', 'vacation', 'sickness', 'parental_leave']
for(var i = 0; i < activityTypes.length; i++){
var legendElementContainer = document.createElement('div')
legendElementContainer.className = 'legend_element_container'
var legendDivText = document.createElement('div')
legendDivText.innerText = activityTypes[i]
legendDivText.className = 'legend_label'
var legendDivBox = document.createElement('div')
legendDivBox.classList.add('legend_cube')
legendDivBox.classList.add('days_of_month_' + activityTypes[i])
legendElementContainer.appendChild(legendDivText)
legendElementContainer.appendChild(legendDivBox)
container.appendChild(legendElementContainer)
}
calendar.appendChild(container)
}

View File

@ -7,6 +7,7 @@ const csrftoken = getCookie('csrftoken');
window.addEventListener('load', function(){ window.addEventListener('load', function(){
var parent = document.getElementById('calendar_box') var parent = document.getElementById('calendar_box')
parent.appendChild(addCalendar(monthsAhead=3)) parent.appendChild(addCalendar(monthsAhead=3))
appendLegend()
fetchDays() fetchDays()
formatCalendarContainerSize(document.getElementById('calendar_container')) formatCalendarContainerSize(document.getElementById('calendar_container'))
document.getElementById('calendar_button_back').addEventListener('click', function(){ document.getElementById('calendar_button_back').addEventListener('click', function(){
@ -121,14 +122,16 @@ function formatCalendarContainerSize(calendarContainer){
var monthsBlock = calendarContainer.querySelector('#months_block') var monthsBlock = calendarContainer.querySelector('#months_block')
var calendarButton = calendarContainer.querySelector('#calendar_button_back') var calendarButton = calendarContainer.querySelector('#calendar_button_back')
var dateSelector = calendarContainer.querySelector('#date_selector') var dateSelector = calendarContainer.querySelector('#date_selector')
var legendSelector = calendarContainer.querySelector('#legend_container')
var widthMonths = monthsBlock.offsetWidth var widthMonths = monthsBlock.offsetWidth
var heightMonths = monthsBlock.offsetHeight var heightMonths = monthsBlock.offsetHeight
var heightDateSelector = dateSelector.offsetHeight var heightDateSelector = dateSelector.offsetHeight
var heightLegend = legendSelector.offsetHeight
var widthCalendarButton = calendarButton.offsetWidth * 2 var widthCalendarButton = calendarButton.offsetWidth * 2
var widthTotal = widthMonths + widthCalendarButton var widthTotal = widthMonths + widthCalendarButton
var heightTotal = heightMonths + heightDateSelector var heightTotal = heightMonths + heightDateSelector + heightLegend
calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px'); calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px');
} }
@ -173,3 +176,26 @@ function getCookie(name) {
} }
return cookieValue; return cookieValue;
} }
function appendLegend(){
var calendar = document.getElementById('calendar_container')
var container = document.createElement('div')
container.id = 'legend_container'
var activityTypes = ['work', 'vacation', 'sickness', 'parental_leave']
for(var i = 0; i < activityTypes.length; i++){
var legendElementContainer = document.createElement('div')
legendElementContainer.className = 'legend_element_container'
var legendDivText = document.createElement('div')
legendDivText.innerText = activityTypes[i]
legendDivText.className = 'legend_label'
var legendDivBox = document.createElement('div')
legendDivBox.classList.add('legend_cube')
legendDivBox.classList.add('days_of_month_' + activityTypes[i])
legendElementContainer.appendChild(legendDivText)
legendElementContainer.appendChild(legendDivBox)
container.appendChild(legendElementContainer)
}
calendar.appendChild(container)
}

View File

@ -10,7 +10,7 @@
{% block core_content %} {% block core_content %}
<script src="{% static '/js/csrf_token.js' %}"></script> <script src="{% static '/js/csrf_token.js' %}"></script>
<div class="sidebar"> <div id="sidebar">
<a href="{% url 'employee_module:homepage' %}"> <a href="{% url 'employee_module:homepage' %}">
<div class="sidebar_item">Home <div class="sidebar_item">Home
@ -42,6 +42,8 @@
<div id="hr_module_main_container"> <div id="hr_module_main_container">
{% block action_panel %} {% block action_panel %}
{% endblock %} {% endblock %}
<script src="{% static '/js/employee_module_base.js' %}"></script>
</div> </div>

View File

@ -1,6 +1,6 @@
import datetime as dt import datetime as dt
from hr_module.models import Plan, Employee from hr_module.models import Plan, Employee, TimeLog
from django.conf import settings from django.conf import settings
import pandas as pd import pandas as pd
@ -62,6 +62,27 @@ class UpdatePlan:
activity_type=self.activity_type) activity_type=self.activity_type)
plan.save() plan.save()
if self.activity_type != 'work':
if not self.check_overnight_shift():
timelog = TimeLog(username=employee,
date=date_to_add,
begin_time=self.start_time,
end_time=self.end_time,
activity_type=self.activity_type)
timelog.save()
else:
timelog = TimeLog(username=employee,
date=date_to_add,
begin_time=self.start_time,
end_time=dt.time(23, 59, 59),
activity_type=self.activity_type)
timelog.save()
timelog = TimeLog(username=employee,
date=date_to_add + dt.timedelta(days=1),
begin_time=dt.time(0, 0, 0),
end_time=self.end_time,
activity_type=self.activity_type)
timelog.save()

View File

@ -10,7 +10,7 @@ div.month_container td {
} }
th { th {
background-color: darkred; background-color: #202831;
color: white; color: white;
border: solid 1px white; border: solid 1px white;
border-width: thin; border-width: thin;
@ -86,7 +86,7 @@ th {
} }
.days_of_month_today{ .days_of_month_today{
background-color: darkred; background-color: #202831;
} }
.month_header { .month_header {

View File

@ -2,4 +2,41 @@
.days_of_month_work { .days_of_month_work {
background-color: darkslateblue; background-color: darkslateblue;
} }
.days_of_month_vacation {
background-color: lightgreen;
}
.days_of_month_sickness {
background-color: #4f4f4f;
}
.days_of_month_parental_leave {
background-color: #609ab6;
}
.legend_element_container {
display: inline-block;
border-right: 1px solid black;
padding-left: 15px;
padding-top: 7px;
}
#legend_container {
margin-top: 10px;
}
.legend_label {
float: left;
margin-right: 15px;
padding-top: 7px;
height: 30px;
}
.legend_cube {
height: 30px;
width: 30px;
margin-right: 15px;
float: left;
}

View File

@ -1,31 +1,39 @@
#hr_module_main_container { #hr_module_main_container {
padding: 1%; padding-top: 10px;
padding-left: 10px;
float: left; float: left;
width: 80%; width: 78%;
height: 100%; height: 100%;
background-color: whitesmoke; background-color: whitesmoke;
text-align: center; text-align: center;
} }
.sidebar { #sidebar {
background-color: #8b0000; background-color: #202831;
width: 18%; width: 18%;
height: 100%; height: 100%;
float: left; float: left;
padding: 10px;
} }
.sidebar_item { .sidebar_item {
background-color: navajowhite; background-color: #202831;
margin-right: 6px;
margin-left: 6px;
margin-top: 6px;
padding: 10px; padding: 10px;
font-size: 20px; font-size: 20px;
color: #7F8B94;
}
.sidebar_item_active {
background-color: #191E24;
color: #53B6FF;
}
a {
text-decoration: none;
} }
.sidebar_item:hover { .sidebar_item:hover {
background-color: white; background-color: #43505e;
cursor: pointer; cursor: pointer;
} }

View File

@ -1,12 +1,14 @@
.scheduleSearchRow { .scheduleSearchRow {
height: 35px; height: 20px;
display: block;
margin-bottom: 15px;
} }
.search_element { .search_element {
width: auto;
float: left; float: left;
width: 20%; margin-right: 15px;
} }
#schedule_filter_category { #schedule_filter_category {
@ -32,7 +34,14 @@ table, th, td {
border-width: thin; border-width: thin;
} }
th {
background-color: #202831;
color: #9ea9b5;
}
.date_select_row { .date_select_row {
margin-top: 10px; display: block;
margin-bottom: 10px; height: auto;
width: auto;
margin-top: 15px;
} }

View File

@ -3,10 +3,16 @@
label { label {
width: 40%; width: 40%;
display:inline-block; display:inline-block;
text-align: left;
}
input {
width: 40%;
} }
table { table {
margin-top: 10px; margin-top: 10px;
margin-left: 20px;
} }
table, th, td { table, th, td {
@ -20,19 +26,30 @@ table, th, td {
.import_container { .import_container {
float: left; float: left;
width: 40%; width: 48%;
height: 70%; height: 70%;
display: block;
} }
.form_element, .import_text { .form_element, .import_text {
height: 30px; height: 30px;
display: block;
}
.import_text {
font-weight: bold;
background-color: #202831;
width: 100%;
color: #7F8B94;
padding-top: 10px;
margin-bottom: 10px;
} }
.separator { .separator {
position: relative; position: relative;
float: left; float: left;
width: 10%; width: 30px;
height: 70%; height: 70%;
} }

View File

@ -0,0 +1 @@

View File

@ -5,6 +5,7 @@ input[readonly] {
} }
table#detailed_plan_records { table#detailed_plan_records {
margin-top: 15px;
width: 100%; width: 100%;
font-size: 15px; font-size: 15px;
vertical-align:middle; vertical-align:middle;
@ -22,7 +23,7 @@ table#detailed_plan_records td {
padding: 0px; padding: 0px;
} }
tr:nth-child(even) { table#detailed_plan_records tr:nth-child(even) {
background-color: #6DDCBD; background-color: #6DDCBD;
} }

View File

@ -0,0 +1,44 @@
input[readonly] {
color: black;
background-color: lightgray;
}
table#detailed_plan_records {
width: 100%;
font-size: 15px;
vertical-align:middle;
font-weight: lighter;
}
table#detailed_plan_records th {
height: 25px;
font-weight: lighter;
padding: 0px;
}
table#detailed_plan_records td {
text-align: center;
padding: 0px;
}
tr:nth-child(even) {
background-color: #6DDCBD;
}
div#detailed_plan_records input {
width: 97%;
display: block;
border: solid thin black;
}
.detailed_plan_records {
text-align: center;
border-collapse: collapse;
border-width: thin;
font-weight: lighter;
}
.begin_time, .end_time {
display: block;
}

View File

@ -0,0 +1,12 @@
window.addEventListener('load', function(){
var sidebarItems = document.getElementById('sidebar').getElementsByTagName('a')
var pathName = window.location.pathname
for (var i = 0; i < sidebarItems.length; i++){
var pathLink = sidebarItems[i].getAttribute('href')
if (pathName == pathLink){
sidebarItems[i].firstElementChild.classList.add('sidebar_item_active')
}
}
})

View File

@ -1,13 +1,18 @@
const csrftoken = getCookie('csrftoken'); const csrftoken = getCookie('csrftoken');
var searchInput = document.getElementById('searched_string');
searchInput.addEventListener("click", fetchSearchOptions);
var fetchEmployeesButton = document.getElementById('load_employees'); window.addEventListener('load', function (){
fetchEmployeesButton.addEventListener('click', fetchEmployees); fetchSearchOptions()
var submitToDb = document.getElementById('run_planning'); var filterType = document.getElementById('schedule_filter_category')
submitToDb.addEventListener('click', postPlanToDb); filterType.addEventListener('change', fetchSearchOptions)
var fetchEmployeesButton = document.getElementById('load_employees');
fetchEmployeesButton.addEventListener('click', fetchEmployees);
var submitToDb = document.getElementById('run_planning');
submitToDb.addEventListener('click', postPlanToDb);
})
function fetchSearchOptions() { function fetchSearchOptions() {
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
@ -30,22 +35,18 @@ function fetchSearchOptions() {
}).then((response) => { }).then((response) => {
return response.json(); return response.json();
}).then((data) => { }).then((data) => {
console.log(data);
appendFoundFilterOptions(data); appendFoundFilterOptions(data);
}); });
} }
function appendFoundFilterOptions(data){ function appendFoundFilterOptions(data){
console.log(data)
var parent = document.getElementById('schedule_filter_search'); var parent = document.getElementById('schedule_filter_search');
parent.innerHTML = ''; parent.innerHTML = '';
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
var caption = data[i]['caption']; var caption = data[i]['caption'];
var value = data[i]['column_value']; var value = data[i]['column_value'];
console.log(caption)
console.log(value)
innerHTML = '<option value="' + value + '">' + caption + '</option>' innerHTML = '<option value="' + value + '">' + caption + '</option>'
@ -59,7 +60,7 @@ function appendFoundFilterOptions(data){
function fetchEmployees() { function fetchEmployees() {
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
var fetch_url = host + '/hr_module/loeademployees' var fetch_url = host + '/hr_module/loademployees'
var searched_field = document.getElementById('schedule_filter_category').value var searched_field = document.getElementById('schedule_filter_category').value
var searched_string = document.getElementById('searched_string').value var searched_string = document.getElementById('searched_string').value
@ -78,13 +79,12 @@ function fetchEmployees() {
}).then((response) => { }).then((response) => {
return response.json(); return response.json();
}).then((data) => { }).then((data) => {
console.log(data);
appendFoundEmployees(data); appendFoundEmployees(data);
addDeleteEventListener();
}); });
} }
function appendFoundEmployees(data){ function appendFoundEmployees(data){
var parentTable = document.getElementById('scheduling_list'); var parentTable = document.getElementById('scheduling_list');
parent.innerHTML = ''; parent.innerHTML = '';
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
@ -98,7 +98,6 @@ function appendFoundEmployees(data){
var manager_name = data[i]['manager_name']; var manager_name = data[i]['manager_name'];
var daily_hours = data[i]['daily_hours']; var daily_hours = data[i]['daily_hours'];
var newRow = parentTable.insertRow(-1) var newRow = parentTable.insertRow(-1)
newRow.className = 'employee_row' newRow.className = 'employee_row'
newRow.id = 'employee_row_' + username newRow.id = 'employee_row_' + username
@ -111,12 +110,8 @@ function appendFoundEmployees(data){
workingDays(cellDays, data[i]) workingDays(cellDays, data[i])
addCell(newRow, addActivityType(), 5) addCell(newRow, addActivityType(), 5)
addCell(newRow, '<td><input type="time" class="schedule_time_input" required></td>', 6)
addCell(newRow, '<td><input type="time" class="schedule_time_input"></td>', 6) addCell(newRow, addDeleteButton(username), 7)
var cellButton = addCell(newRow, addDeleteButton(username), 7)
cellButton.firstChild.addEventListener('click', function () {
deleteRow(username)
})
} }
} }
} }
@ -125,6 +120,8 @@ function addDeleteButton(username){
var cell = document.createElement('td') var cell = document.createElement('td')
var submit = document.createElement('button') var submit = document.createElement('button')
submit.innerHTML = 'Delete' submit.innerHTML = 'Delete'
submit.className = 'delete_button'
submit.value = username
cell.appendChild(submit) cell.appendChild(submit)
return cell.outerHTML return cell.outerHTML
} }
@ -164,24 +161,42 @@ function workingDays(parent, data){
'sat', 'sat',
'sun',] 'sun',]
days.forEach(function (item) { days.forEach(function (item) {
if (data[item] === true) { var inputLabel = document.createElement('label')
var tag = '<label for="' + item + '">'+ item + '</label><input class="working_days" type="checkbox" id="' + item + '" value="' + item + '" checked>' inputLabel.setAttribute('for', item)
inputLabel.innerHTML = item
} else { var input = document.createElement('input')
var tag = '<label for="' + item + '">'+ item + '</label><input class="working_days" type="checkbox" id="' + item + '" value="' + item + '" >' input.className = 'working_days'
input.type = 'checkbox'
input.value = item
if (data[item] === true) {
input.checked = true
} }
var wrapper = document.createElement('div'); var wrapper = document.createElement('div');
wrapper.className = 'day_of_week_checkbox' wrapper.className = 'day_of_week_checkbox'
wrapper.innerHTML = tag; wrapper.appendChild(inputLabel)
wrapper.appendChild(input)
parent.appendChild(wrapper) parent.appendChild(wrapper)
}); });
} }
function deleteRow(username){ function deleteRow(username){
console.log(username)
var row = document.getElementById('employee_row_' + username) var row = document.getElementById('employee_row_' + username)
row.outerHTML = '' row.outerHTML = ''
} }
function addDeleteEventListener(){
var buttons = document.getElementsByClassName('delete_button')
for (let i = 0; i < buttons.length; i++){
buttons[i].addEventListener('click', function (){
deleteRow(buttons[i].value)
})
}
}
function buildPlanJson(){ function buildPlanJson(){
var listJsons = [] var listJsons = []
var employees = document.getElementsByClassName('employee_row') var employees = document.getElementsByClassName('employee_row')

View File

@ -5,6 +5,7 @@ const csrftoken = getCookie('csrftoken');
window.addEventListener('load', function(){ window.addEventListener('load', function(){
var parent = document.getElementById('calendar_box') var parent = document.getElementById('calendar_box')
parent.appendChild(addCalendar(monthsAhead=3)) parent.appendChild(addCalendar(monthsAhead=3))
appendLegend()
formatCalendarContainerSize(document.getElementById('calendar_container')) formatCalendarContainerSize(document.getElementById('calendar_container'))
formatCalendarSize() formatCalendarSize()
document.getElementById('load_schedule_button').addEventListener('click', function(){ document.getElementById('load_schedule_button').addEventListener('click', function(){
@ -26,7 +27,7 @@ window.addEventListener('load', function(){
function fetchDays(){ function fetchDays(){
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
var fetch_url = host + '/hr_module/show_employee_timelog_api' var fetch_url = host + '/hr_module/show_employee_plan_api'
var range = searchedDateRange() var range = searchedDateRange()
var startDate = range['min'] var startDate = range['min']
@ -186,7 +187,7 @@ function getCheckedRecords(event){
function updateCheckedRecords(recordsArray, action){ function updateCheckedRecords(recordsArray, action){
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
var fetch_url = host + '/hr_module/update_timelog_api' var fetch_url = host + '/hr_module/update_plan_api'
fetch(fetch_url, fetch(fetch_url,
{ {
@ -292,14 +293,16 @@ function formatCalendarContainerSize(calendarContainer){
var monthsBlock = calendarContainer.querySelector('#months_block') var monthsBlock = calendarContainer.querySelector('#months_block')
var calendarButton = calendarContainer.querySelector('#calendar_button_back') var calendarButton = calendarContainer.querySelector('#calendar_button_back')
var dateSelector = calendarContainer.querySelector('#date_selector') var dateSelector = calendarContainer.querySelector('#date_selector')
var legendSelector = calendarContainer.querySelector('#legend_container')
var widthMonths = monthsBlock.offsetWidth var widthMonths = monthsBlock.offsetWidth
var heightMonths = monthsBlock.offsetHeight var heightMonths = monthsBlock.offsetHeight
var heightDateSelector = dateSelector.offsetHeight var heightDateSelector = dateSelector.offsetHeight
var heightLegend = legendSelector.offsetHeight
var widthCalendarButton = calendarButton.offsetWidth * 2 var widthCalendarButton = calendarButton.offsetWidth * 2
var widthTotal = widthMonths + widthCalendarButton var widthTotal = widthMonths + widthCalendarButton
var heightTotal = heightMonths + heightDateSelector var heightTotal = heightMonths + heightDateSelector + heightLegend
calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px'); calendarContainer.setAttribute('style','height:' + heightTotal +'px; width:' + widthTotal + 'px');
} }
@ -349,3 +352,26 @@ function getCookie(name) {
} }
return cookieValue; return cookieValue;
} }
function appendLegend(){
var calendar = document.getElementById('calendar_container')
var container = document.createElement('div')
container.id = 'legend_container'
var activityTypes = ['work', 'vacation', 'sickness', 'parental_leave']
for(var i = 0; i < activityTypes.length; i++){
var legendElementContainer = document.createElement('div')
legendElementContainer.className = 'legend_element_container'
var legendDivText = document.createElement('div')
legendDivText.innerText = activityTypes[i]
legendDivText.className = 'legend_label'
var legendDivBox = document.createElement('div')
legendDivBox.classList.add('legend_cube')
legendDivBox.classList.add('days_of_month_' + activityTypes[i])
legendElementContainer.appendChild(legendDivText)
legendElementContainer.appendChild(legendDivBox)
container.appendChild(legendElementContainer)
}
calendar.appendChild(container)
}

View File

@ -28,7 +28,7 @@ window.addEventListener('load', function(){
function fetchDays(){ function fetchDays(){
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
var fetch_url = host + '/hr_module/show_employee_plan_api' var fetch_url = host + '/hr_module/show_employee_timelog_api'
var range = searchedDateRange() var range = searchedDateRange()
var startDate = range['min'] var startDate = range['min']
@ -188,7 +188,7 @@ function getCheckedRecords(event){
function updateCheckedRecords(recordsArray, action){ function updateCheckedRecords(recordsArray, action){
var host = 'http://' + window.location.host; var host = 'http://' + window.location.host;
var fetch_url = host + '/hr_module/update_plan_api' var fetch_url = host + '/hr_module/update_timelog_api'
fetch(fetch_url, fetch(fetch_url,
{ {
@ -360,10 +360,19 @@ function appendLegend(){
container.id = 'legend_container' container.id = 'legend_container'
var activityTypes = ['work', 'vacation', 'sickness', 'parental_leave'] var activityTypes = ['work', 'vacation', 'sickness', 'parental_leave']
for(var i = 0; i < activityTypes.length; i++){ for(var i = 0; i < activityTypes.length; i++){
var legendDiv = document.createElement('div') var legendElementContainer = document.createElement('div')
legendDiv.classList.add('legend_cube') legendElementContainer.className = 'legend_element_container'
legendDiv.classList.add('days_of_month_' + activityTypes[i])
container.appendChild(legendDiv) var legendDivText = document.createElement('div')
legendDivText.innerText = activityTypes[i]
legendDivText.className = 'legend_label'
var legendDivBox = document.createElement('div')
legendDivBox.classList.add('legend_cube')
legendDivBox.classList.add('days_of_month_' + activityTypes[i])
legendElementContainer.appendChild(legendDivText)
legendElementContainer.appendChild(legendDivBox)
container.appendChild(legendElementContainer)
} }
calendar.appendChild(container) calendar.appendChild(container)
} }

View File

@ -10,7 +10,7 @@
{% block core_content %} {% block core_content %}
<script src="{% static '/js/csrf_token.js' %}"></script> <script src="{% static '/js/csrf_token.js' %}"></script>
<div class="sidebar"> <div id="sidebar">
<a href="{% url 'hr_module:homepage' %}"> <a href="{% url 'hr_module:homepage' %}">
<div class="sidebar_item">Home <div class="sidebar_item">Home
@ -19,55 +19,58 @@
<a href="{% url 'hr_module:create_schedule' %}"> <a href="{% url 'hr_module:create_schedule' %}">
<div class="sidebar_item">Create schedule <div class="sidebar_item" >Create schedule
</div> </div>
</a> </a>
<a href="{% url 'hr_module:plan_creation_log' %}"> <a href="{% url 'hr_module:plan_creation_log' %}">
<div class="sidebar_item">Schedule creating logs <div class="sidebar_item" >Schedule creating logs
</div> </div>
</a> </a>
<a href="{% url 'hr_module:manage_schedule' %}"> <a href="{% url 'hr_module:manage_schedule' %}">
<div class="sidebar_item">Manage employee schedule <div class="sidebar_item" >Manage employee schedule
</div> </div>
</a> </a>
<a href="{% url 'hr_module:manage_timelog' %}"> <a href="{% url 'hr_module:manage_timelog' %}">
<div class="sidebar_item">Manage employee timelog <div class="sidebar_item" >Manage employee timelog
</div> </div>
</a> </a>
<a href="{% url 'hr_module:change_employee_data' %}"> <a href="{% url 'hr_module:change_employee_data' %}">
<div class="sidebar_item">Manage employee data <div class="sidebar_item" >Manage employee data
</div> </div>
</a> </a>
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<a href="{% url 'hr_module:create_employees' %}"> <a href="{% url 'hr_module:create_employees' %}">
<div class="sidebar_item">Create new employees <div class="sidebar_item" >Create new employees
</div> </div>
</a> </a>
<a href="{% url 'hr_module:create_schedule' %}"> <a href="{% url 'hr_module:create_schedule' %}">
<div class="sidebar_item">Export Data <div class="sidebar_item" >Export data
</div> </div>
</a> </a>
{% endif %} {% endif %}
<a href="{% url 'employee_module:homepage' %}"> <a href="{% url 'employee_module:homepage' %}">
<div class="sidebar_item">Go to employee section <div class="sidebar_item" >Go to employee section
</div> </div>
</a> </a>
</div> </div>
<div id="hr_module_main_container"> <div id="hr_module_main_container">
{% block action_panel %} {% block action_panel %}
{% endblock %} {% endblock %}
<script src="{% static '/js/hr_module_base.js' %}"></script>
</div> </div>

View File

@ -15,7 +15,7 @@
</div> </div>
<div class="search_element"> <div class="search_element">
<input list="schedule_filter_search" id="searched_string"> <input list="schedule_filter_search" id="searched_string" autocomplete="off" >
<datalist id="schedule_filter_search"> <datalist id="schedule_filter_search">
</datalist> </datalist>
</div> </div>

View File

@ -4,6 +4,8 @@
{% block action_panel %} {% block action_panel %}
<link rel="stylesheet" href="{% static '/css/hr_module_schedule_creation_log.css' %}">
{% if creation_log.count > 0 %} {% if creation_log.count > 0 %}
<div class="link_to_report_download">Links with scheduling import are below: </div> <div class="link_to_report_download">Links with scheduling import are below: </div>
{% for item in creation_log %} {% for item in creation_log %}

View File

@ -4,6 +4,6 @@
{% block action_panel %} {% block action_panel %}
<h2>Welcome to Timefall - time tracking application</h2> <h2>Welcome to Timefall - time tracking app, admin site</h2>
{% endblock %} {% endblock %}

View File

@ -5,7 +5,7 @@
{% block action_panel %} {% block action_panel %}
<link rel="stylesheet" href="{% static '/css/calendar.css' %}"> <link rel="stylesheet" href="{% static '/css/calendar.css' %}">
<link rel="stylesheet" href="{% static '/css/calendar_local.css' %}"> <link rel="stylesheet" href="{% static '/css/calendar_local.css' %}">
<link rel="stylesheet" href="{% static '/css/hr_module_show_schedule.css' %}"> <link rel="stylesheet" href="{% static '/css/hr_module_show_timelog.css' %}">
<div> <div>
<label for="username_input">Person username: </label> <label for="username_input">Person username: </label>

View File

@ -13,7 +13,7 @@ urlpatterns = [
path('create_schedule', views.create_schedule, name='create_schedule'), path('create_schedule', views.create_schedule, name='create_schedule'),
path('create_employees', views.create_employees, name='create_employees'), path('create_employees', views.create_employees, name='create_employees'),
path('search_api', views.search_users_api, name='search_users_api'), path('search_api', views.search_users_api, name='search_users_api'),
path('loeademployees', views.load_employees_api, name='load_employees'), path('loademployees', views.load_employees_api, name='load_employees'),
path('new_plan_api', views.new_plan_api, name='new_plan_api'), path('new_plan_api', views.new_plan_api, name='new_plan_api'),
path('manage_schedule', views.manage_schedule, name='manage_schedule'), path('manage_schedule', views.manage_schedule, name='manage_schedule'),
path('show_employee_plan_api', views.show_employee_plan_api, name='show_employee_plan_api'), path('show_employee_plan_api', views.show_employee_plan_api, name='show_employee_plan_api'),

View File

@ -258,7 +258,7 @@ def show_employee_plan_api(request):
user_obj = Employee.objects.get(pk=username) user_obj = Employee.objects.get(pk=username)
query_result = Plan.objects.filter(username=user_obj, date__range= [start_date, end_date]) query_result = Plan.objects.filter(username=user_obj, date__range=[start_date, end_date]).order_by('date', 'begin_time')
response = list(query_result.values()) response = list(query_result.values())
return JsonResponse(response, safe=False) return JsonResponse(response, safe=False)
@ -307,7 +307,7 @@ def show_employee_timelog_api(request):
user_obj = Employee.objects.get(pk=username) user_obj = Employee.objects.get(pk=username)
query_result = TimeLog.objects.filter(username=user_obj, date__range= [start_date, end_date]) query_result = TimeLog.objects.filter(username=user_obj, date__range= [start_date, end_date]).order_by('date', 'begin_time')
response = list(query_result.values()) response = list(query_result.values())
return JsonResponse(response, safe=False) return JsonResponse(response, safe=False)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,7 +11,7 @@ html, body {
} }
.main_container { .main_container {
background-color: whitesmoke; background-color: whitesmoke;
width: 70%; width: 100%;
height: 100%; height: 100%;
margin: auto; margin: auto;
} }