mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-11 09:09:28 +00:00
Status: Max Semester
This commit is contained in:
@@ -11,6 +11,7 @@ class Status extends FHCAPI_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'getHistoryPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'getMaxSemester' => ['admin:r', 'assistenz:r'],
|
||||
'changeStatus' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'],
|
||||
'addStudent' => ['admin:r', 'assistenz:r', 'student/keine_studstatuspruefung'],
|
||||
'getStatusgruende' => self::PERM_LOGGED,
|
||||
@@ -63,6 +64,41 @@ class Status extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum possible semester for one or more Studiengaenge.
|
||||
* If there are more than one Studiengang each maximum is calculated and
|
||||
* the smallest result is returned.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getMaxSemester()
|
||||
{
|
||||
$studiengang_kzs = $this->input->post('studiengang_kzs');
|
||||
|
||||
if (!$studiengang_kzs || !is_array($studiengang_kzs)) {
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('studiengang_kzs', '', 'required|is_null', [
|
||||
'is_null' => $this->p->t('ui', 'error_fieldMustBeArray')
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
|
||||
if (defined('VORRUECKUNG_STATUS_MAX_SEMESTER') && VORRUECKUNG_STATUS_MAX_SEMESTER == false)
|
||||
$this->terminateWithSuccess(100);
|
||||
|
||||
$this->load->model('organisation/Lehrverband_model', 'LehrverbandModel');
|
||||
|
||||
$result = $this->LehrverbandModel->getMaxSemester($studiengang_kzs);
|
||||
|
||||
$maxsem = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($maxsem ? current($maxsem)->maxsem : 10);
|
||||
}
|
||||
|
||||
public function getStatusgruende()
|
||||
{
|
||||
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
|
||||
@@ -53,4 +53,34 @@ class Lehrverband_model extends DB_Model
|
||||
return success("1","Lehrverband vorhanden!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum possible semester for one or more Studiengaenge.
|
||||
* If there are more than one Studiengang each maximum is calculated and
|
||||
* the smallest result is returned.
|
||||
*
|
||||
* @param array $studiengang_kzs
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getMaxSemester($studiengang_kzs)
|
||||
{
|
||||
$sqls = [];
|
||||
foreach ($studiengang_kzs as $studiengang_kz) {
|
||||
$this->addSelect('MAX(semester) AS maxsem');
|
||||
$this->db->where('studiengang_kz', $studiengang_kz);
|
||||
$sqls[] = $this->db->get_compiled_select($this->dbTable);
|
||||
}
|
||||
|
||||
$this->addSelect('MIN(a.maxsem) AS maxsem');
|
||||
|
||||
$dbTable = $this->dbTable;
|
||||
$this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a';
|
||||
|
||||
$result = $this->load();
|
||||
|
||||
$this->dbTable = $dbTable;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,8 @@ export default{
|
||||
statusData: {},
|
||||
statusId: {},
|
||||
dataMeldestichtag: null,
|
||||
statusNew: true
|
||||
statusNew: true,
|
||||
maxSem: 0
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -246,9 +247,20 @@ export default{
|
||||
else
|
||||
this.data.tabulatorOptions.ajaxURL = 'api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id;
|
||||
}
|
||||
this.getMaxSem();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getMaxSem() {
|
||||
const studiengang_kzs = this.modelValue.studiengang_kz
|
||||
? [this.modelValue.studiengang_kz]
|
||||
: this.modelValue.map(prestudent => prestudent.studiengang_kz);
|
||||
this.maxSem = 0;
|
||||
this.$fhcApi
|
||||
.post('api/frontend/v1/stv/status/getMaxSemester/', {studiengang_kzs})
|
||||
.then(result => this.maxSem = result.data)
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
actionNewStatus() {
|
||||
this.$refs.test.open(this.modelValue);
|
||||
},
|
||||
@@ -317,6 +329,8 @@ export default{
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getMaxSem();
|
||||
|
||||
this.$fhcApi
|
||||
.get('api/frontend/v1/stv/status/getLastBismeldestichtag/')
|
||||
.then(result => {
|
||||
@@ -327,9 +341,9 @@ export default{
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
template: `
|
||||
<div class="stv-list h-100 pt-3">
|
||||
<div class="stv-multistatus h-100 pt-3">
|
||||
|
||||
<status-modal ref="test" :meldestichtag="new Date(dataMeldestichtag)" @saved="reload"></status-modal>
|
||||
<status-modal ref="test" :meldestichtag="new Date(dataMeldestichtag)" :max-sem="maxSem" @saved="reload"></status-modal>
|
||||
|
||||
<core-filter-cmpt
|
||||
v-if="!this.modelValue.length"
|
||||
|
||||
@@ -37,6 +37,10 @@ export default{
|
||||
meldestichtag: {
|
||||
type: Date,
|
||||
required: true
|
||||
},
|
||||
maxSem: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -58,12 +62,13 @@ export default{
|
||||
'Unterbrecher',
|
||||
'Diplomand',
|
||||
'Incoming'
|
||||
],
|
||||
// TODO(chris): IMPLEMENT!
|
||||
maxSem: Array.from({ length: 11 }, (_, index) => index),
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
semester() {
|
||||
return Array.from({length: this.maxSem}, (_, index) => index);
|
||||
},
|
||||
bisLocked() {
|
||||
if (this.statusNew || this.hasPermissionToSkipStatusCheck)
|
||||
return false;
|
||||
@@ -207,7 +212,7 @@ export default{
|
||||
</template>
|
||||
|
||||
<core-form ref="form">
|
||||
|
||||
|
||||
<form-validation></form-validation>
|
||||
|
||||
<p v-if="bisLocked && !isStatusBeforeStudent">
|
||||
@@ -249,7 +254,6 @@ export default{
|
||||
{{ sem.studiensemester_kurzbz }}
|
||||
</option>
|
||||
</form-input>
|
||||
<!-- TODO(manu) if(defined('VORRUECKUNG_STATUS_MAX_SEMESTER') && VORRUECKUNG_STATUS_MAX_SEMESTER==false) 100 Semester-->
|
||||
<form-input
|
||||
container-class="mb-3"
|
||||
type="select"
|
||||
@@ -259,7 +263,7 @@ export default{
|
||||
:disabled="bisLocked && !isStatusBeforeStudent"
|
||||
>
|
||||
<option
|
||||
v-for="number in maxSem"
|
||||
v-for="number in semester"
|
||||
:key="number"
|
||||
:value="number"
|
||||
>
|
||||
|
||||
@@ -1755,6 +1755,26 @@ $phrases = array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'error_fieldMustBeArray',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Das {field} Feld muss ein Array sein',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'The {field} field must be an array',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'anrechnung',
|
||||
|
||||
Reference in New Issue
Block a user