diff --git a/clockIn.html b/clockIn.html index dbe3515..5aab4aa 100644 --- a/clockIn.html +++ b/clockIn.html @@ -27,7 +27,7 @@ and open the template in the editor.

Tus fichadas

Situación de los ultimos 7 días

-
Total: 7.7h
+
diff --git a/config.js b/config.js index 3812dd5..b3b50d2 100644 --- a/config.js +++ b/config.js @@ -4,5 +4,5 @@ var process = { }; var config = { - urlBase: 'http://localhost:9090' + urlBase: 'http://localhost:8080' }; diff --git a/css/style.css b/css/style.css index 7401567..c7eb25e 100644 --- a/css/style.css +++ b/css/style.css @@ -274,7 +274,7 @@ header{ .listHorario .headerLi{ width: 100%; overflow: hidden; - border-bottom: 1px solid #9EA7AC; + border-top: 1px solid #9EA7AC; padding-bottom: 10px; } diff --git a/img/middle.png b/img/middle.png new file mode 100644 index 0000000..63350a4 Binary files /dev/null and b/img/middle.png differ diff --git a/js/clockIn.js b/js/clockIn.js index c02e5b2..ae7f839 100644 --- a/js/clockIn.js +++ b/js/clockIn.js @@ -42,7 +42,7 @@ function setView() { $("." + userData["button2"]).show(); } -function fichar(direction) { +function fichar(direction) { $.post({ urlPath: 'clockIn', jsonData: [userData['userFk'], direction], @@ -87,44 +87,89 @@ function getInfo() { processData: false, success: function (data) { $('.footer').show(); - printHorario(data); + printTimetable(data); } }); } -function printHorario(horarios) { - var c = "in"; - for (var i = 0; i < horarios.length; i++) { - if (i % 2 !== 0) { - c = "out"; - } else { - c = "in"; - } - if (horarios[i]["7_dias_antes"] === "total") { - if (horarios.length > (i + 1)) { - printTotalHours(horarios[i + 1]); - } - if (horarios.length > (i + 2)) { - $(".total").text('Total: ' + horarios[i + 2]["1_dia_antes"] + 'h'); - } - break; - } - $(".listHorario").append('
  • ' + ifIsEmptyText(horarios[i]["6_dias_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["5_dias_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["4_dias_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["3_dias_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["2_dias_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["1_dia_antes"]) + '

    ' + ifIsEmptyText(horarios[i]["mismo_dia"]) + '

  • '); - } +function printTimetable(timetable) { var listWeekName = printWeek(); - $(".listHorario").prepend('
  • '); + var dated = new Date(); + dated.setDate(dated.getDate() - 6); + + for (var i = 0; i < 6; i++) { + $(".listHorario").append(''); + dated.setDate(dated.getDate() + 1); + } + $(".listHorario").append(''); + $(".listHorario").append('
  • '); + + for (var i = 0; i < timetable.length; i++) { + + $(".listHorario").append( + '
  • ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["6daysAgo"]) + '

    ' + + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["5daysAgo"]) + '

    '+ + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["4daysAgo"]) + '

    '+ + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["3daysAgo"]) + '

    '+ + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["2daysAgo"]) + '

    '+ + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["1daysAgo"]) + '

    '+ + '
    ' + + '
    ' + + '' + + '

    ' + ifIsEmptyText(timetable[i]["0daysAgo"]) + '

    '+ + '
    ' + + '
  • ' + ); + + } + printTotalHours(timetable); + } -function printTotalHours(horarios) { - $(".listHorario").append('


  • '); - $(".listHorario").append('
  • ' + ifIsEmptyText(horarios["6_dias_antes"]) - + '
    ' + ifIsEmptyText(horarios["5_dias_antes"]) - + '
    ' + ifIsEmptyText(horarios["4_dias_antes"]) - + '
    ' + ifIsEmptyText(horarios["3_dias_antes"]) - + '
    ' + ifIsEmptyText(horarios["2_dias_antes"]) - + '
    ' + ifIsEmptyText(horarios["1_dia_antes"]) - + '
    ' + ifIsEmptyText(horarios["mismo_dia"]) - + '
  • '); +function printTotalHours(timetable) { + if(timetable.length>0) { + + $(".listHorario").append('
  • '); + $(".listHorario").append('
  • ' + secondsToHm(ifIsEmptyText(timetable[0]["6daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["5daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["4daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["3daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["2daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["1daysAgoTotal"])) + + '
    ' + secondsToHm(ifIsEmptyText(timetable[0]["0daysAgoTotal"])) + + '
  • '); + + $(".total").text('Total: ' + + secondsToHm(Number(timetable[0]["6daysAgoTotal"] == null)+ + Number(timetable[0]["5daysAgoTotal"])+ + Number(timetable[0]["4daysAgoTotal"]) + + Number(timetable[0]["3daysAgoTotal"]) + + Number(timetable[0]["2daysAgoTotal"]) + + Number(timetable[0]["1daysAgoTotal"]) + + Number(timetable[0]["0daysAgoTotal"]) + ) + 'h'); + } else{ + $(".total").text('Total: 0h '); + } + } function printWeek() { @@ -139,12 +184,12 @@ function printWeek() { var weekDays = [ 'Domingo', - 'Lunes', - 'Martes', - 'Miércoles', - 'Jueves', + 'Sábado', 'Viernes', - 'Sábado' + 'Jueves', + 'Miércoles', + 'Martes', + 'Lunes' ]; function printErrores(errores) { @@ -165,6 +210,14 @@ function ifIsEmpty(value) { } } +function ifIsEmptyImage(value) { + if (value.trim().length === 0) { + return "img/in.png"; + } else { + return "img/" + value + ".png"; + } +} + function ifIsEmptyText(value) { if (value.trim().length === 0) { return "00:00"; @@ -179,4 +232,11 @@ function cerrar(){ setTimeout(function () { window.location='index.html'; }, 200); +} + +function secondsToHm(seconds) { + seconds = Number(seconds); + let hours = Math.floor(seconds / 3600); + let minutes = Math.floor(seconds % 3600 / 60); + return hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0'); } \ No newline at end of file