diff --git a/application/views/lehre/anrechnung/approveAnrechnungDetail.php b/application/views/lehre/anrechnung/approveAnrechnungDetail.php index 69456ab75..15887dfd5 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungDetail.php +++ b/application/views/lehre/anrechnung/approveAnrechnungDetail.php @@ -127,7 +127,8 @@ $this->load->view( ects ?> - Bisher angerechnete ECTS + + p->t('anrechnung', 'bisherAngerechneteEcts'); ?> @@ -139,6 +140,7 @@ $this->load->view( [Schulisch: sumEctsSchulisch ?> / Beruflich: sumEctsBeruflich ?> ] + p->t('lehre', 'lektorInnen'); ?> diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php index 21dc90694..e78bf4059 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php @@ -79,8 +79,6 @@ $query = ' anrechnungen.lv_bezeichnung, anrechnungen.ects::float4 AS ects, NULL AS "ectsSumBisherUndNeu", - anrechnungen.ectsSumSchulisch::float4 AS "ectsSumBisherUndNeuSchulisch", - anrechnungen.ectsSumBeruflich::float4 AS "ectsSumBisherUndNeuBeruflich", anrechnungen.ectsSumSchulisch::float4 AS "ectsSumSchulisch", anrechnungen.ectsSumBeruflich::float4 AS "ectsSumBeruflich", anrechnungen.begruendung, @@ -151,8 +149,6 @@ $filterWidgetArray = array( ucfirst($this->p->t('lehre', 'lehrveranstaltung')), 'ECTS (LV)', 'ECTS (LV + Bisher)', - 'ECTS (LV + Schule)', - 'ECTS (LV + Beruf)', 'ECTS (Bisher schulisch)', 'ECTS (Bisher beruflich', ucfirst($this->p->t('global', 'begruendung')), @@ -178,7 +174,7 @@ $filterWidgetArray = array( headerFilterPlaceholder: " ", index: "anrechnung_id", // assign specific column as unique id (important for row indexing) selectable: true, // allow row selection - selectableRangeMode: "click", // allow range selection using shift end click on end of range -- TODO: check, löst rowSelectionChanged 2* aus + selectableRangeMode: "click", // allow range selection using shift end click on end of range selectablePersistence:false, // deselect previously selected rows when table is filtered, sorted or paginated tableBuilt: function(){ func_tableBuilt(this); @@ -214,9 +210,7 @@ $filterWidgetArray = array( ausbildungssemester: {headerFilter:"input"}, lv_bezeichnung: {headerFilter:"input"}, ects: {headerFilter:"input", align:"center"}, - ectsSumBisherUndNeu: {mutator: mut_getEctsSumBisherUndNeu, formatter:"html"}, - ectsSumBisherUndNeuSchulisch: {headerFilter: "input", visible: false}, - ectsSumBisherUndNeuBeruflich: {headerFilter: "input", visible: false}, + ectsSumBisherUndNeu: {formatter: format_ectsSumBisherUndNeu}, ectsSumSchulisch: {visible: true, headerFilter:"input", align:"right"}, ectsSumBeruflich: {visible: true, headerFilter:"input", align:"right"}, begruendung: {headerFilter:"input", visible: true}, diff --git a/public/js/lehre/anrechnung/approveAnrechnungDetail.js b/public/js/lehre/anrechnung/approveAnrechnungDetail.js index ffa989056..6658a4b15 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungDetail.js +++ b/public/js/lehre/anrechnung/approveAnrechnungDetail.js @@ -568,7 +568,6 @@ var approveAnrechnungDetail = { (parseFloat($('#ects').text()) + parseFloat($('#sumEctsSchulisch').text()) + parseFloat($('#sumEctsBeruflich').text())) > 90 ) { - console.log('inside'); $('#sumEctsMsg').html("
ACHTUNG! Bei Anrechnung von LV: Maximale ECTS überschritten.
").css('backgroundColor', COLOR_DANGER); } else diff --git a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js index d16218de6..b971745a2 100644 --- a/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js +++ b/public/js/lehre/anrechnung/approveAnrechnungUebersicht.js @@ -11,7 +11,9 @@ const COLOR_LIGHTGREY = "#f5f5f5"; const COLOR_DANGER = '#f2dede'; var tabulator = null; // Set in tableBuilt function. -var rowSelectionChanged = false; // Set in rowSelectionChanged function. Useful in rowUpdate to differ update behaviour. + +// Array with accumulated LV ECTS by Prestudent. Used to find out if max ECTS are exceeded. +var selectedPrestudentWithAccumulatedLvEcts = []; // ----------------------------------------------------------------------------------------------------------------- // Mutators - setter methods to manipulate table data when entering the tabulator @@ -27,20 +29,6 @@ var mut_formatStringDate = function(value, data, type, params, component) { } } -var mut_getEctsSumBisherUndNeu = function(value, data, type, params, component){ - - let ectsSumBisherUndNeuTotal = (data.ectsSumBisherUndNeuSchulisch + data.ectsSumBisherUndNeuBeruflich); - let ectsSumBisherUndNeuSchulisch = data.ectsSumBisherUndNeuSchulisch; - let ectsSumBisherUndNeuBeruflich = data.ectsSumBisherUndNeuBeruflich; - - // Format text - ectsSumBisherUndNeuTotal = (ectsSumBisherUndNeuTotal > 90) ? "" + ectsSumBisherUndNeuTotal + "" : ectsSumBisherUndNeuTotal; - ectsSumBisherUndNeuSchulisch = (ectsSumBisherUndNeuSchulisch > 60) ? "" + ectsSumBisherUndNeuSchulisch + "" : ectsSumBisherUndNeuSchulisch; - ectsSumBisherUndNeuBeruflich = (ectsSumBisherUndNeuBeruflich > 60) ? "" + ectsSumBisherUndNeuBeruflich + "" : ectsSumBisherUndNeuBeruflich; - - return "T: " + ectsSumBisherUndNeuTotal + " [ S: " + ectsSumBisherUndNeuSchulisch + " | B: " + ectsSumBisherUndNeuBeruflich + " ]"; -} - // TABULATOR FUNCTIONS // --------------------------------------------------------------------------------------------------------------------- // Returns relative height (depending on screen size) @@ -98,34 +86,65 @@ function func_tableBuilt(table) { } } +/** + * Formats column ECTS (LV + Bisher). + */ +var format_ectsSumBisherUndNeu = function(cell, formatterParams, onRendered){ + let row = cell.getRow(); + let rowData = row.getData(); + + let begruendung_id = (rowData.begruendung_id); + let ectsSumBisherUndNeuTotal = (rowData.ectsSumSchulisch + rowData.ectsSumBeruflich); + let ectsSumBisherUndNeuSchulisch = rowData.ectsSumSchulisch; + let ectsSumBisherUndNeuBeruflich = rowData.ectsSumBeruflich; + + // If exists, add accumulated LV ECTS to bisherige ECTS + if (selectedPrestudentWithAccumulatedLvEcts.length > 0) + { + let selectedPrestudent = selectedPrestudentWithAccumulatedLvEcts.find(x => x.prestudent_id === rowData.prestudent_id); + + if (selectedPrestudent != undefined) + { + ectsSumBisherUndNeuTotal = (rowData.ectsSumSchulisch + rowData.ectsSumBeruflich) + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch; + ectsSumBisherUndNeuSchulisch = rowData.ectsSumSchulisch + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch; + ectsSumBisherUndNeuBeruflich = rowData.ectsSumBeruflich + selectedPrestudent.ectsSumAnzurechnendeLvsBeruflich; + } + + // Color column if maximum ECTS exceeded + if (begruendung_id != 5 && row.isSelected()) + { + + if ( + (ectsSumBisherUndNeuSchulisch + ectsSumBisherUndNeuBeruflich) > 90 || + ectsSumBisherUndNeuSchulisch > 60 || + ectsSumBisherUndNeuBeruflich > 60 + ) + { + cell.getElement().style["background-color"] = COLOR_DANGER; + } + } + else + { + cell.getElement().style.removeProperty('background-color'); + } + } + + // If max ECTS is exceeded, format font color / weight + ectsSumBisherUndNeuTotal = (ectsSumBisherUndNeuTotal > 90) ? "" + ectsSumBisherUndNeuTotal + "" : ectsSumBisherUndNeuTotal; + ectsSumBisherUndNeuSchulisch = (ectsSumBisherUndNeuSchulisch > 60) ? "" + ectsSumBisherUndNeuSchulisch + "" : ectsSumBisherUndNeuSchulisch; + ectsSumBisherUndNeuBeruflich = (ectsSumBisherUndNeuBeruflich > 60) ? "" + ectsSumBisherUndNeuBeruflich + "" : ectsSumBisherUndNeuBeruflich; + + return "T: " + ectsSumBisherUndNeuTotal + " [ S: " + ectsSumBisherUndNeuSchulisch + " | B: " + ectsSumBisherUndNeuBeruflich + " ]"; +} + // Formats the rows function func_rowFormatter(row){ let status_kurzbz = row.getData().status_kurzbz; - let begruendung_id = row.getData().begruendung_id; - let ectsSumBisherUndNeuSchulisch = row.getData().ectsSumBisherUndNeuSchulisch; - let ectsSumBisherUndNeuBeruflich = row.getData().ectsSumBisherUndNeuBeruflich; if (status_kurzbz != ANRECHNUNGSTATUS_PROGRESSED_BY_STGL) { row.getElement().style["background-color"] = COLOR_LIGHTGREY; // default } - - // Color column if maximum ECTS exceeded - if (begruendung_id != 5 && row.isSelected()) - { - if ( - (ectsSumBisherUndNeuSchulisch + ectsSumBisherUndNeuBeruflich) > 90 || - ectsSumBisherUndNeuSchulisch > 60 || - ectsSumBisherUndNeuBeruflich > 60 - ) - { - row.getCell('ectsSumBisherUndNeu').getElement().style["background-color"] = COLOR_DANGER; - } - } - else - { - row.getCell('ectsSumBisherUndNeu').getElement().style.removeProperty('background-color'); - } } // Formats row selectable/unselectable @@ -139,57 +158,28 @@ function func_selectableCheck(row){ ); } -// Format rows when maximum ECTS are exceeded. +// Calculate dynamically sum of all LV ECTS by Student and display, when maximum ECTS are exceeded. +// data = selected data, rows = selected rows function func_rowSelectionChanged(data, rows){ - var selectedData = data; - var selectedRows = rows; - var tableData = tabulator.getData(true); // only the filtered / sorted table rows - - rowSelectionChanged = true; - // Sum up over all anzurechnenden LV-ECTS by Prestudent - var selectedPrestudentWithAccumulatedLvEcts = []; - selectedPrestudentWithAccumulatedLvEcts = approveAnrechnung.getSumLvEctsByPreStudent(selectedData); + selectedPrestudentWithAccumulatedLvEcts = approveAnrechnung.getSumLvEctsByPreStudent(data); - // Loop through table rows - tableData.forEach(function(td){ + // Loop through all active rows + var rowManager = tabulator.rowManager; + for (var i = 0; i < rowManager.activeRows.length; i++) { - let selectedPrestudent = selectedPrestudentWithAccumulatedLvEcts.find(x => x.prestudent_id === td.prestudent_id); - - // Add accumulated LV ECTS to bisherige ECTS in ECTS 'controlling column', if Prestudent is selected at least once - if (selectedPrestudent != undefined) - { - td.ectsSumBisherUndNeuSchulisch = td.ectsSumSchulisch + selectedPrestudent.ectsSumAnzurechnendeLvsSchulisch; - td.ectsSumBisherUndNeuBeruflich = td.ectsSumBeruflich + selectedPrestudent.ectsSumAnzurechnendeLvsBeruflich; - - } - // ..else reset to bisherige ECTS - else - { - td.ectsSumBisherUndNeuSchulisch = td.ectsSumSchulisch; - td.ectsSumBisherUndNeuBeruflich = td.ectsSumBeruflich; - } - }); - - // Update ECTS columns - tabulator.updateData(tableData); + // Reinitialize row -> triggers formatters. + rowManager.activeRows[i].reinitialize(); + } // Show number of selected rows. - approveAnrechnung.showNumberSelectedRows(selectedRows); - - rowSelectionChanged = false; + approveAnrechnung.showNumberSelectedRows(rows); } // Performes after row was updated function func_rowUpdated(row){ - // If rowUpdate is called on row selection change, return to avoid following row deselection and formatting. - if (rowSelectionChanged) - { - return; - } - // Deselect and disable new selection of updated rows row.deselect(); row.getElement().style["pointerEvents"] = "none";