From 93ed76d98f875b263a3ba8937df2a46df39e9dc2 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Wed, 13 Nov 2024 16:18:13 +0100 Subject: [PATCH] display option to add new contract for stumis not in inst, fixes #79 --- controllers/index.php | 4 ++-- models/StundenzettelContract.class.php | 6 ++++++ views/index/index.php | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/controllers/index.php b/controllers/index.php index 877bf07..ac355a6 100644 --- a/controllers/index.php +++ b/controllers/index.php @@ -97,7 +97,7 @@ class IndexController extends PluginController { } } //bereits ausgeschieden (nicht in Statusgruppe aber Vertrag vorhanden) - $old_stumi_contracts = StundenzettelContract::findByInst_id($institute->id); + $old_stumi_contracts = StundenzettelContract::get_inst_contracts($institute->id, $show_all); foreach ($old_stumi_contracts as $old_contract) { $former_stumi = User::find($old_contract->user_id); if (!in_array($old_contract->user_id, $user_ids) && (!$this->search || stripos($former_stumi->username . ' ' . $former_stumi->vorname . ' ' . $former_stumi->nachname, $this->search))) { @@ -107,7 +107,7 @@ class IndexController extends PluginController { } } if (isset($this->inst_data[$institute->id][0])) { - array_push($this->groups[$institute->id], 0); + array_push($this->groups[$institute->id], null); } } } diff --git a/models/StundenzettelContract.class.php b/models/StundenzettelContract.class.php index 8b2b6c0..7237488 100644 --- a/models/StundenzettelContract.class.php +++ b/models/StundenzettelContract.class.php @@ -120,6 +120,12 @@ class StundenzettelContract extends \SimpleORMap return $contracts; } + static function get_inst_contracts($inst_id, $all = true) + { + $contract_end = $all ? 0 : strtotime('first day of last month midnight'); + return self::findBySQL('inst_id = ? AND contract_end >= ?', [$inst_id, $contract_end]); + } + static function get_user_inst_contracts($user_id, $inst_id, $all = true) { $contract_end = $all ? 0 : strtotime('first day of last month midnight'); diff --git a/views/index/index.php b/views/index/index.php index 371cd33..1f27fe4 100644 --- a/views/index/index.php +++ b/views/index/index.php @@ -7,12 +7,12 @@ <?= htmlReady($institute->name) ?> </h2> <? foreach ($groups[$institute->id] as $group) : ?> - <? if ($group->id) : ?> + <? if ($group) : ?> <? $group_id = $group->id; ?> <!-- echte Gruppe --> <? else : ?> <? $group_id = 0; ?> <!-- ausgeschiedene MA --> <? endif ?> - <h3><?= $group->name ? htmlReady($group->name) : $controller->_('Ausgeschiedene studentische/wisschenschaftliche MitarbeiterInnen') ?></h3> + <h3><?= $group ? htmlReady($group->name) : $controller->_('Ausgeschiedene studentische/wisschenschaftliche MitarbeiterInnen') ?></h3> <table id="stumi-contract-entries" class="sortable-table default" data-sortlist="[[0,0]]"> <thead> <tr> -- GitLab