From 0cbb8997e29aede63ae789580786e5009bf055d7 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 3 Jun 2024 17:14:55 +0200 Subject: [PATCH] migratecontract config und config check auch in MigrateHourlyRate verwenden --- .../controllers/system/MigrateHourlyRate.php | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/application/controllers/system/MigrateHourlyRate.php b/application/controllers/system/MigrateHourlyRate.php index 734934ad0..dbc8f1416 100644 --- a/application/controllers/system/MigrateHourlyRate.php +++ b/application/controllers/system/MigrateHourlyRate.php @@ -4,14 +4,15 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class MigrateHourlyRate extends CLI_Controller { - - CONST DEFAULT_OE = 'gst'; CONST DEFAULT_DATE = '1970-01-01'; CONST STUNDENSTAZTYP_LEHRE = 'lehre'; CONST STUNDENSTAZTYP_KALKULATORISCH = 'kalkulatorisch'; + private $OE_DEFAULT; private $_ci; + protected $configerrors; + public function __construct() { parent::__construct(); @@ -21,10 +22,37 @@ class MigrateHourlyRate extends CLI_Controller $this->load->model('codex/Bisverwendung_model', 'BisVerwendungModel'); $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $this->load->model('ressource/Stundensatz_model', 'StundensatzModel'); + + $this->load->config('migratecontract'); + + $this->OE_DEFAULT = $this->config->item('migratecontract_oe_default'); + $this->configerrors = array(); + } + + public function checkConfig() + { + echo "OE_DEFAULT: " . $this->OE_DEFAULT . "\n"; + + $this->checkOE_DEFAULT(); + + if( count($this->configerrors) > 0 ) + { + foreach($this->configerrors AS $configerror) + { + echo $configerror . "\n"; + } + die("Fehler in der Konfiguration. Abbruch!\n"); + } + else + { + echo "Konfiguration OK.\n"; + } } public function index($user = null) { + $this->checkConfig(); + echo "Lehre Stundensaetze werden migriert.\n"; $mitarbeiterResult = $this->_getMitarbeiterStunden($user); if (isError($mitarbeiterResult)) return $mitarbeiterResult; @@ -61,6 +89,18 @@ class MigrateHourlyRate extends CLI_Controller } } + protected function checkOE_DEFAULT() + { + $db = new DB_Model(); + $oesql = 'SELECT * FROM public.tbl_organisationseinheit WHERE oe_kurzbz = ?'; + $oeres = $db->execReadOnlyQuery($oesql, array($this->OE_DEFAULT)); + if( !hasData($oeres) ) + { + $this->configerrors[] = 'Default Organisationseinheit: "' + . $this->OE_DEFAULT . '" nicht gefunden.'; + } + } + protected function checkIfSAPSyncTableExists() { $dbModel = new DB_Model(); @@ -167,7 +207,7 @@ class MigrateHourlyRate extends CLI_Controller $unternehmenResult = $this->_findUnternehmen($mitarbeiter->uid, "'kstzuordnung', 'oezuordnung'"); } - $unternehmen = self::DEFAULT_OE; + $unternehmen = $this->OE_DEFAULT; if (hasData($unternehmenResult)) $unternehmen = getData($unternehmenResult)[0]->oe_kurzbz;