diff --git a/application/models/accounting/Vertragvertragsstatus_model.php b/application/models/accounting/Vertragvertragsstatus_model.php index 7e76ef494..ad9cef423 100644 --- a/application/models/accounting/Vertragvertragsstatus_model.php +++ b/application/models/accounting/Vertragvertragsstatus_model.php @@ -130,5 +130,32 @@ class Vertragvertragsstatus_model extends DB_Model ); } - + /** + * Get all contracts, where the status had been set to 'bestellt' on given date + * @param string $string_date e.g. '01.11.2019' or special Date/Time inputs like 'YESTERDAY', 'TODAY', 'NOW' + * @param bool $further_processed If true, ALL ordered contracts of that day are retrieved, even if they were + * were ALSO approved/accepted/cancelled (further processed) on that same day. + * @return array + */ + public function getOrdered_fromDate($string_date = 'TODAY', $further_processed = false) + { + $condition = ' + vertragsstatus_kurzbz = \'bestellt\' AND + (insertamum)::date = date \''. $string_date .'\' + '; + + if (!$further_processed) + { + $condition .= ' + AND + vertrag_id NOT IN ( + SELECT vertrag_id + FROM lehre.tbl_vertrag_vertragsstatus + WHERE vertragsstatus_kurzbz IN (\'erteilt\', \'akzeptiert\', \'storno\') + ) + '; + } + + return $this->loadWhere($condition); + } }