diff --git a/application/controllers/api/v1/crm/Prestudent.php b/application/controllers/api/v1/crm/Prestudent.php index d334cc709..9cdf79415 100644 --- a/application/controllers/api/v1/crm/Prestudent.php +++ b/application/controllers/api/v1/crm/Prestudent.php @@ -65,6 +65,27 @@ class Prestudent extends APIv1_Controller $this->response(); } } + + /** + * @return void + */ + public function getLastStatus() + { + $prestudent_id = $this->get('prestudent_id'); + $studiensemester_kurzbz = $this->get('studiensemester_kurzbz'); + $status_kurzbz = $this->get('status_kurzbz'); + + if (isset($prestudent_id)) + { + $result = $this->PrestudentModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } /** * @return void diff --git a/application/controllers/api/v1/ressource/Ort.php b/application/controllers/api/v1/ressource/Ort.php index 022db2281..963bb716c 100644 --- a/application/controllers/api/v1/ressource/Ort.php +++ b/application/controllers/api/v1/ressource/Ort.php @@ -46,6 +46,31 @@ class Ort extends APIv1_Controller $this->response(); } } + + /** + * @return void + */ + public function getAll() + { + $raumtyp_kurzbz = $this->get('raumtyp_kurzbz'); + + $this->OrtModel->addOrder('ort_kurzbz'); + + if (!is_null($raumtyp_kurzbz) && $raumtyp_kurzbz != '') + { + $result = $this->OrtModel->addJoin('public.tbl_ortraumtyp', 'ort_kurzbz'); + if ($result->error == EXIT_SUCCESS) + { + $result = $this->OrtModel->loadWhere(array('raumtyp_kurzbz' => $raumtyp_kurzbz)); + } + } + else + { + $result = $this->OrtModel->loadWhole(); + } + + $this->response($result, REST_Controller::HTTP_OK); + } /** * @return void diff --git a/application/helpers/fhcdb_helper.php b/application/helpers/fhcdb_helper.php deleted file mode 100644 index fd170c462..000000000 --- a/application/helpers/fhcdb_helper.php +++ /dev/null @@ -1,450 +0,0 @@ -ci=$ci; - } - - public function db_connect() - { - $conn_str='host='.DB_HOST.' port='.DB_PORT.' dbname='.DB_NAME.' user='.DB_USER.' password='.DB_PASSWORD; - //Connection Herstellen - if (DB_CONNECT_PERSISTENT) - { - if (!basis_db::$db_conn = pg_pconnect($conn_str)) - die('Fehler beim Oeffnen der Datenbankverbindung'); - } - else - { - if (!basis_db::$db_conn = pg_connect($conn_str)) - die('Fehler beim Oeffnen der Datenbankverbindung'); - } - } - - public function db_query($sql) - { - if ($this->db_result=$this->ci->db->simple_query($sql)) - return $this->db_result; - else - { - $this->errormsg.='Abfrage in Datenbank fehlgeschlagen! '.$this->db_last_error(); - return false; - } - } - - public function db_num_rows($result=null) - { - if (is_null($result)) - return pg_num_rows($this->db_result); - else - return pg_num_rows($result); - } - - public function db_fetch_object($result = null, $i=null) - { - if (is_null($result)) - { - if (is_null($i)) - return pg_fetch_object($this->db_result); - else - return pg_fetch_object($this->db_result, $i); - } - else - { - if (is_null($i)) - return pg_fetch_object($result); - else - return pg_fetch_object($result, $i); - } - } - - public function db_fetch_row($result = null, $i=null) - { - if (is_null($result)) - { - if (is_null($i)) - return pg_fetch_row($this->db_result); - else - return pg_fetch_row($this->db_result, $i); - } - else - { - if (is_null($i)) - return pg_fetch_row($result); - else - return pg_fetch_row($result, $i); - } - } - - public function db_fetch_assoc($result = null, $i=null) - { - if (is_null($result)) - { - if (is_null($i)) - return pg_fetch_assoc($this->db_result); - else - return pg_fetch_assoc($this->db_result, $i); - } - else - { - if (is_null($i)) - return pg_fetch_row($result); - else - return pg_fetch_row($result, $i); - } - } - - public function db_result($result = null, $i,$item) - { - if (is_null($result)) - { - return pg_result($this->db_result, $i,$item); - } - else - { - return pg_result($result, $i,$item); - } - } - - public function db_getResultJSON($result = null) - { - $rows=array(); - if (is_null($result)) - { - while ($r = pg_fetch_assoc($this->db_result)) - $rows[] = $r; - - //print json_encode($rows); - } - else - { - pg_result_seek($result, 0); - //var_dump($result); - while ($r = pg_fetch_assoc($result)) - { - $rows[] = $r; - } - - //print json_encode($rows); - } - return json_encode($rows); - } - - public function db_last_error() - { - return pg_last_error(); - } - - public function db_affected_rows($result=null) - { - if (is_null($result)) - return pg_affected_rows($this->db_result); - else - return pg_affected_rows($result); - } - - public function db_result_seek($result=null, $offset) - { - if (is_null($result)) - return pg_result_seek($this->db_result, $offset); - else - return pg_result_seek($result, $offset); - } - - public function db_fetch_array($result=null) - { - if (is_null($result)) - return pg_fetch_array($this->db_result); - else - return pg_fetch_array($result); - } - - public function db_num_fields($result=null) - { - if (is_null($result)) - return pg_num_fields($this->db_result); - else - return pg_num_fields($result); - } - - /** - * Liefert den Feldnamen mit index i - */ - public function db_field_name($result=null, $i) - { - if (is_null($result)) - return pg_field_name($this->db_result, $i); - else - return pg_field_name($result, $i); - } - - /** - * Gibt den Speicher wieder Frei. - * (ist das sinnvoll wenn es per Value uebergeben wird??) - */ - public function db_free_result($result = null) - { - if (is_null($result)) - { - return pg_free_result($this->db_result); - } - else - { - return pg_free_result($result); - } - } - - /** - * Liefert die aktuelle Datenbankversion - */ - public function db_version() - { - return pg_version(basis_db::$db_conn); - } - - /** - * Escaped Sonderzeichen in Variablen vor der Verwendung in SQL Statements - * um SQL Injections zu verhindern - * - */ - public function db_escape($var) - { - return pg_escape_string($var); - } - - /** - * Null Value Handling und Hochkomma für Inserts / Updates - * Wenn die Uebergebe Variable leer ist, wird ein String mit null - * zurueckgeliefert, wenn nicht dann wird der string unter Hochkomma zurueckgeliefert - * es sei denn qoute=false dann wird nur der String zurueckgeliefert - * - * @param $var String-Value fuer SQL Request - * @return string - */ - public function db_null_value($var, $qoute=true) - { - if ($qoute) - return ($var!==''?$this->db_qoute($var):'null'); - else - return ($var!==''?$var:'null'); - } - - /** - * Setzt einen String unter Hochkomma - * @param $var Value fuer Insert/Update - * @return value unter Hochkomma - */ - public function db_qoute($var) - { - return "'".$var."'"; - } - - /** - * Escaped einen Parameter fuer die Verwendung in Insert/Update SQL Befehlen - * Es werden abhaengig vom Typ Hochkomma oder Null hinzugefuegt - * @param $var Value der gesetzt werden soll - * @param $type Typ des Values (FHC_STRING | FHC_BOOLEAN | FHC_INTEGER | ...) - * @param $nullable boolean gibt an ob das Feld NULL sein darf. Wenn true wird - * NULL statt einem Leerstring zurueckgeliefert - * @return Escapter Value inklusive Hochkomma wenn noetig - * - * Verwendungsbeispiel: - * Update tbl_person set nachname=$this->db_add_param($var) - * Update tbl_person set aktiv=$this->db_add_param($var, FHC_BOOL, false) - * Update tbl_person set anzahlkinder=$this->db_add_param($var, FHC_INT) - */ - public function db_add_param($var, $type=FHC_STRING, $nullable=true) - { - if (($var==='' || is_null($var)) && $type!=FHC_BOOLEAN) - { - if ($nullable) - return 'null'; - else - return "''"; - } - - switch($type) - { - case FHC_INTEGER: - $var = $this->db_escape($var); - if (!is_numeric($var) && $var!=='') - die('Invalid Integer Parameter detected:'.$var); - $var = $this->db_null_value($var, false); - break; - - case FHC_LANG_ARRAY: - - $sprache = new sprache(); - $sprache->getAll(true); - $buf = $var; - $var = array(); - $languages = $sprache->getAllIndexesSorted(); - - foreach($languages as $sk => $sp) - { - if (!$sp || !isset($buf[$sp])) - $var[$sk] = ""; - else - $var[$sk] = $this->db_escape($buf[$sp]); - } - $var = str_replace('\\', '\\\\', $var); - $var = str_replace('"', '\\\"', $var); - $var = '\'{"' . join('","', $var) . '"}\''; - - break; - - case FHC_BOOLEAN: - if ($var===true) - $var='true'; - elseif ($var===false) - $var='false'; - elseif ($var=='' && $nullable) - $var = 'null'; - else - die('Invalid Boolean Parameter detected'); - break; - - case FHC_STRING: - default: - $var = $this->db_escape($var); - $var = $this->db_null_value($var); - break; - } - return $var; - } - - /** - * Erzeugt aus einem DB-Result-Boolean einen PHP Boolean - */ - public function db_parse_bool($var) - { - if ($var=='t') - return true; - elseif ($var=='f') - return false; - elseif ($var=='') - return ''; - else - die('Invalid DB Boolean. Wrong DB-Engine?'); - } - - /** - * Bereitet ein Array von Elementen auf, damit es in der IN-Klausel eines - * Select Befehls verwendet werden kann. - */ - public function db_implode4SQL($array) - { - $string = ''; - foreach($array as $row) - { - if ($string!='') - $string.=','; - $string.=$this->db_add_param($row); - } - return $string; - } - - /** - * Erstellt aus einem DB Array ein PHP Array - * @param $var DB Result Array Spalte - * @return php array - */ - public function db_parse_array($var) - { - if ($var == '') - return; - preg_match_all('/(?<=^\{|,)(([^,"{]*)|\s*"((?:[^"\\\\]|\\\\(?:.|[0-9]+|x[0-9a-f]+))*)"\s*)(,|(?loadIndexArray(); - - $sprache = new sprache(); - $sprache->getAll(true); - $languages = $sprache->getAllIndexesSorted(); - - - foreach ($matches as $mk => $match) - { - $values[$languages[$mk+1]] = $match[3] != '' ? stripcslashes($match[3]) : (strtolower($match[2]) == 'null' ? null : $match[2]); - } - return $values; - } -} - -function indexSort($a, $b) -{ - return strcmp($a->index, $b->index); -} - -/** - * Bereitet ein Array von Elementen auf, damit es in der IN-Klausel eines - * Select Befehls verwendet werden kann. - */ -function dbImplode4SQL($array) -{ - $string = ''; - - foreach($array as $row) - { - if ($string != '') - { - $string.=','; - } - $string.=$this->db_add_param($row); - } - - return $string; -} \ No newline at end of file diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index 0908b4c8a..cf6a5908d 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -11,30 +11,50 @@ class Prestudent_model extends DB_Model $this->dbTable = 'public.tbl_prestudent'; $this->pk = 'prestudent_id'; } - + /** - * + * @return void */ - public function loadPrestudentPerson($prestudentID) + public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '') { - // Check the rights - if (! $this->fhc_db_acl->isBerechtigt('basis/person', 's')) - return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/person', FHC_MODEL_ERROR); + // Checks if the operation is permitted by the API caller + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_prestudentstatus'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_prestudentstatus'], FHC_MODEL_ERROR); - // Prepare SQL-Query - $this->db->select('*') - ->from('public.tbl_prestudent') - ->join('public.tbl_person', 'person_id') - ->where('prestudent_id', $prestudentID); - // Do the query - $result = $this->db->get()->result_object(); + if (! $this->fhc_db_acl->isBerechtigt($this->acl['lehre.tbl_studienplan'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['lehre.tbl_studienplan'], FHC_MODEL_ERROR); - // Return the result - if ($result) - return $this->_success($result); + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_status'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_status'], FHC_MODEL_ERROR); + + $query = "SELECT tbl_prestudentstatus.*, + bezeichnung AS studienplan_bezeichnung, + tbl_status.bezeichnung_mehrsprachig + FROM public.tbl_prestudentstatus LEFT JOIN lehre.tbl_studienplan USING (studienplan_id) + JOIN public.tbl_status USING (status_kurzbz) + WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz + AND prestudent_id = ?"; + + $parametersArray = array($prestudent_id); + + if ($studiensemester_kurzbz != '') + { + array_push($parametersArray, $studiensemester_kurzbz); + $query .= ' AND studiensemester_kurzbz = ?'; + } + if ($status_kurzbz != '') + { + array_push($parametersArray, $status_kurzbz); + $query .= ' AND status_kurzbz = ?'; + } + + $query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1'; + + $result = $this->db->query($query, $parametersArray); + + if (is_object($result)) + return $this->_success($result->result()); else return $this->_error($this->db->error(), FHC_DB_ERROR); } - - -} +} \ No newline at end of file diff --git a/include/berechtigung.class.php b/include/berechtigung.class.php index 6cdafcc50..3e9cc654c 100644 --- a/include/berechtigung.class.php +++ b/include/berechtigung.class.php @@ -19,10 +19,16 @@ * Andreas Oesterreicher and * Rudolf Hangl . */ -require_once(dirname(__FILE__).'/basis_db.class.php'); +require_once(dirname(__FILE__).'/datum.class.php'); -class berechtigung extends basis_db +// CI +require_once(dirname(__FILE__).'/../ci_hack.php'); +require_once(dirname(__FILE__).'/../application/models/system/Berechtigung_model.php'); + +class berechtigung extends Berechtigung_model { + use db_extra; //CI Hack + public $result=array(); public $new; @@ -46,13 +52,13 @@ class berechtigung extends basis_db */ public function load($berechtigung_kurzbz) { - $qry = "SELECT * FROM system.tbl_berechtigung WHERE berechtigung_kurzbz=".$this->db_add_param($berechtigung_kurzbz); + $result = parent::load($berechtigung_kurzbz); - if($result = $this->db_query($qry)) + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) { - if($row = $this->db_fetch_object($result)) + if (count($result->retval) > 0) { - $this->berechtigung_kurzbz=$row->berechtigung_kurzbz; + $this->berechtigung_kurzbz = $row->berechtigung_kurzbz; $this->beschreibung = $row->beschreibung; return true; } diff --git a/include/funktion.class.php b/include/funktion.class.php index 32b8ad913..838638079 100644 --- a/include/funktion.class.php +++ b/include/funktion.class.php @@ -23,10 +23,16 @@ * Klasse funktion (FAS-Online) * @create 14-03-2006 */ -require_once(dirname(__FILE__).'/basis_db.class.php'); +require_once(dirname(__FILE__).'/datum.class.php'); -class funktion extends basis_db +// CI +require_once(dirname(__FILE__).'/../ci_hack.php'); +require_once(dirname(__FILE__).'/../application/models/ressource/Funktion_model.php'); + +class funktion extends Funktion_model { + use db_extra; //CI Hack + public $new; // boolean public $result = array(); // fachbereich Objekt @@ -105,22 +111,24 @@ class funktion extends basis_db */ public function load($funktion_kurzbz) { - if($funktion_kurzbz == '') + if ($funktion_kurzbz == '') { $this->errormsg = 'funktion_bz darf nicht leer sein'; return false; } - $qry = "SELECT * FROM public.tbl_funktion WHERE funktion_kurzbz = ".$this->db_add_param($funktion_kurzbz).";"; - - if(!$this->db_query($qry)) + $result = parent::load($funktion_kurzbz); + + if (!is_object($result) || (is_object($result) && $result->error != EXIT_SUCCESS)) { $this->errormsg = 'Fehler beim Laden des Datensatzes'; return false; } - if($row = $this->db_fetch_object()) + if (is_array($result->retval) && count($result->retval) == 1) { + $row = $result->retval[0]; + $this->funktion_kurzbz = $row->funktion_kurzbz; $this->beschreibung = $row->beschreibung; $this->aktiv = $this->db_parse_bool($row->aktiv); diff --git a/include/ort.class.php b/include/ort.class.php index 72c543808..fde9b4656 100644 --- a/include/ort.class.php +++ b/include/ort.class.php @@ -23,10 +23,16 @@ * Klasse ort (FAS-Online) * @create 04-12-2006 */ -require_once(dirname(__FILE__).'/basis_db.class.php'); +require_once(dirname(__FILE__).'/datum.class.php'); -class ort extends basis_db +// CI +require_once(dirname(__FILE__).'/../ci_hack.php'); +require_once(dirname(__FILE__).'/../application/models/ressource/Ort_model.php'); + +class ort extends Ort_model { + use db_extra; //CI Hack + public $new; // boolean public $result = array(); // ort Objekt @@ -72,29 +78,33 @@ class ort extends basis_db * Laedt alle verfuegbaren Orte * @return true wenn ok, false im Fehlerfall */ - public function getAll($raumtyp_kurzbz=null) + public function getAll($raumtyp_kurzbz = null) { - $qry = 'SELECT * FROM public.tbl_ort ORDER BY ort_kurzbz;'; - - if(!is_null($raumtyp_kurzbz) && $raumtyp_kurzbz!='') + parent::addOrder('ort_kurzbz'); + + if (!is_null($raumtyp_kurzbz) && $raumtyp_kurzbz != '') { - $qry = ' - SELECT - tbl_ort.* - FROM - public.tbl_ort - JOIN public.tbl_ortraumtyp USING(ort_kurzbz) - WHERE raumtyp_kurzbz='.$this->db_add_param($raumtyp_kurzbz).' - ORDER BY ort_kurzbz;'; + $result = parent::addJoin('public.tbl_ortraumtyp', 'ort_kurzbz'); + if ($result->error == EXIT_SUCCESS) + { + $result = parent::loadWhere(array('raumtyp_kurzbz' => $raumtyp_kurzbz)); + } } - if(!$this->db_query($qry)) + else + { + $result = parent::loadWhole(); + } + + if (!is_object($result) || (is_object($result) && ($result->error != EXIT_SUCCESS || !is_array($result->retval)))) { $this->errormsg = 'Fehler beim Laden der Datensaetze'; return false; } - while($row = $this->db_fetch_object()) + for ($i = 0; $i < count($result->retval); $i++) { + $row = $result->retval[$i]; + $ort_obj = new ort(); $ort_obj->ort_kurzbz = $row->ort_kurzbz; diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 14217c498..a9964c88a 100755 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -20,8 +20,6 @@ * Rudolf Hangl . */ require_once(dirname(__FILE__).'/datum.class.php'); -// require_once(dirname(__FILE__).'/person.class.php'); -// require_once(dirname(__FILE__).'/log.class.php'); // CI require_once(dirname(__FILE__).'/../ci_hack.php'); @@ -108,20 +106,20 @@ class prestudent extends Prestudent_model */ public function load($prestudent_id) { - if(!is_numeric($prestudent_id)) + if (!is_numeric($prestudent_id)) { $this->errormsg = 'ID ist ungueltig'; return false; } - $qry = 'SELECT * ' - . 'FROM public.tbl_prestudent ' - . 'WHERE prestudent_id = '.$this->db_add_param($prestudent_id, FHC_INTEGER); + $result = parent::load($prestudent_id); - if($this->db_query($qry)) + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) { - if($row = $this->db_fetch_object()) + if (count($result->retval) > 0) { + $row = $result->retval[0]; + $this->prestudent_id = $row->prestudent_id; $this->aufmerksamdurch_kurzbz = $row->aufmerksamdurch_kurzbz; $this->studiengang_kz = $row->studiengang_kz; @@ -156,10 +154,8 @@ class prestudent extends Prestudent_model $this->zgvdoktordatum = $row->zgvdoktordatum; $this->zgvdoktornation = $row->zgvdoktornation; - if(!person::load($row->person_id)) - return false; - else - return true; + $person = new person(); + return $person->load($row->person_id); } else { @@ -974,33 +970,22 @@ class prestudent extends Prestudent_model * @param $studiensemester_kurzbz * @return boolean */ - public function getLastStatus($prestudent_id, $studiensemester_kurzbz='', $status_kurzbz = '') + public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '') { - if($prestudent_id=='' || !is_numeric($prestudent_id)) + if ($prestudent_id == '' || !is_numeric($prestudent_id)) { $this->errormsg = 'Prestudent_id ist ungueltig'; return false; } - $qry = "SELECT tbl_prestudentstatus.*, bezeichnung AS studienplan_bezeichnung, - tbl_status.bezeichnung_mehrsprachig - FROM public.tbl_prestudentstatus - LEFT JOIN lehre.tbl_studienplan USING (studienplan_id) - JOIN public.tbl_status USING (status_kurzbz) - WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz - AND prestudent_id=".$this->db_add_param($prestudent_id, FHC_INTEGER); - - if($studiensemester_kurzbz!='') - $qry.=" AND studiensemester_kurzbz=".$this->db_add_param($studiensemester_kurzbz); - - if($status_kurzbz !='') - $qry.= " AND status_kurzbz =".$this->db_add_param($status_kurzbz); - - $qry.=" ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1"; - if($this->db_query($qry)) + $result = parent::getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz); + + if (is_object($result) && $result->error != EXIT_SUCCESS && is_array($result->retval)) { - if($row = $this->db_fetch_object()) + if (count($result->retval) > 0) { + $row = $result->retval[0]; + $this->prestudent_id = $row->prestudent_id; $this->status_kurzbz = $row->status_kurzbz; $this->status_mehrsprachig = $this->db_parse_lang_array($row->bezeichnung_mehrsprachig); diff --git a/vilesci/lehre/check/ueberbuchung.php b/vilesci/lehre/check/ueberbuchung.php index 2ed950a1a..8e14d94b2 100644 --- a/vilesci/lehre/check/ueberbuchung.php +++ b/vilesci/lehre/check/ueberbuchung.php @@ -120,6 +120,7 @@ $ort = array(); foreach ($ort_obj->result as $row) { + $ort[$row->ort_kurzbz] = new stdClass(); // Prevents the warning "Creating default object from empty value" $ort[$row->ort_kurzbz]->max_person = $row->max_person; } $qry = "SELECT DISTINCT vw_".$db_stpl_table.".unr,datum, stunde, ort_kurzbz, studiensemester_kurzbz, vw_".$db_stpl_table.".studiengang_kz, vw_".$db_stpl_table.".semester, verband, gruppe, gruppe_kurzbz, UPPER(stg_typ || stg_kurzbz) as stg_kurzbz, lehrfach, lehrfach_bez diff --git a/vilesci/lehre/zeitwuensche.php b/vilesci/lehre/zeitwuensche.php index 4db63c2e6..c3f289a48 100644 --- a/vilesci/lehre/zeitwuensche.php +++ b/vilesci/lehre/zeitwuensche.php @@ -59,10 +59,10 @@ if(!($erg=$db->db_query($qry))) die($db->db_last_error()); $num_rows=$db->db_num_rows($erg); -for ($i=0;$i<$num_rows;$i++) +for ($i = 0; $i < $num_rows; $i++) { - $row=$db->db_fetch_object($erg,$i); - $wunsch[$row->tag][$row->stunde][$row->gewicht]=$row->anz; + $row = $db->db_fetch_object($erg, $i); + $wunsch[$row->tag][$row->stunde][$row->gewicht] = $row->anz; } ?> @@ -98,18 +98,21 @@ Anzahl der Lektoren: for ($j=1; $j<7; $j++) { echo ''.$tagbez[1][$j].''; - for ($i=0;$i<$num_rows_stunde;$i++) + if (isset($wunsch)) // Prevents warnings if no data are present { - $pos=$wunsch[$j][$i+1][4]+$wunsch[$j][$i+1][5]; - $neg=(isset($wunsch[$j][$i+1][3])?$wunsch[$j][$i+1][3]:0)+ - (isset($wunsch[$j][$i+1][2])?$wunsch[$j][$i+1][2]:0)+ - (isset($wunsch[$j][$i+1][1])?$wunsch[$j][$i+1][1]:0)+ - (isset($wunsch[$j][$i+1][0])?$wunsch[$j][$i+1][0]:0); - $bgcolor=isset($cfgStdBgcolor[round(14/$anz_lektoren*$pos)-4])?$cfgStdBgcolor[round(14/$anz_lektoren*$pos)-4]:''; - echo ''; - echo '+:'.round(100/$anz_lektoren*$pos).'%
'; - echo '-:'.round(100/$anz_lektoren*$neg).'%'; - echo ''; + for ($i=0;$i<$num_rows_stunde;$i++) + { + $pos=$wunsch[$j][$i+1][4]+$wunsch[$j][$i+1][5]; + $neg=(isset($wunsch[$j][$i+1][3])?$wunsch[$j][$i+1][3]:0)+ + (isset($wunsch[$j][$i+1][2])?$wunsch[$j][$i+1][2]:0)+ + (isset($wunsch[$j][$i+1][1])?$wunsch[$j][$i+1][1]:0)+ + (isset($wunsch[$j][$i+1][0])?$wunsch[$j][$i+1][0]:0); + $bgcolor=isset($cfgStdBgcolor[round(14/$anz_lektoren*$pos)-4])?$cfgStdBgcolor[round(14/$anz_lektoren*$pos)-4]:''; + echo ''; + echo '+:'.round(100/$anz_lektoren*$pos).'%
'; + echo '-:'.round(100/$anz_lektoren*$neg).'%'; + echo ''; + } } echo ''; } diff --git a/vilesci/personen/funktion_det.php b/vilesci/personen/funktion_det.php index d1c66d186..32eda2736 100644 --- a/vilesci/personen/funktion_det.php +++ b/vilesci/personen/funktion_det.php @@ -289,7 +289,10 @@ if (!$funktion->load($kurzbz)) $funktion = new funktion(); - $funktion->load($funktion_kurzbz); + if (isset($funktion_kurzbz)) // Prevents notice "Undefined variable: funktion_kurzbz" + { + $funktion->load($funktion_kurzbz); + } if($funktion->fachbereich) {