From 1a58c977fe48d92109545abaf0588e469ddcb237 Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 24 Sep 2019 10:15:21 +0200 Subject: [PATCH] Added method getLastStatus() This method gets the latest Vertragsstatus for the given Vertrag and Mitarbeiter. --- .../models/accounting/Vertrag_model.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/application/models/accounting/Vertrag_model.php b/application/models/accounting/Vertrag_model.php index 2261af350..0de9a8fc7 100644 --- a/application/models/accounting/Vertrag_model.php +++ b/application/models/accounting/Vertrag_model.php @@ -200,6 +200,29 @@ class Vertrag_model extends DB_Model return $this->execQuery($query, array($vertragsstatus_kurzbz, $vertrag_id, $mitarbeiter_uid, 'NOW()', getAuthUID(), null, null)); } + /** + * Get the latest Vertragsstatus for the given Vertrag and Mitarbeiter + * @param integer $vertrag_id + * @param string $mitarbeiter_uid + * @return array + */ + public function getLastStatus($vertrag_id, $mitarbeiter_uid) + { + $this->addSelect('vertragsstatus_kurzbz'); + $this->addJoin('lehre.tbl_vertrag_vertragsstatus', 'vertrag_id'); + $this->addOrder('datum', 'DESC'); + $this->addLimit(1); + return $this->loadWhere( + array( + 'vertrag_id' => $vertrag_id, + 'uid' => $mitarbeiter_uid + ) + ); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Private methods + /** * Generate contract description. * Example: WS2017-BEE3-LIA-LAB