mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
Added UDF to FAS -> export
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
require_once(dirname(__FILE__).'/person.class.php');
|
||||
require_once(dirname(__FILE__).'/benutzer.class.php');
|
||||
require_once(dirname(__FILE__).'/functions.inc.php');
|
||||
require_once(dirname(__FILE__).'/udf.class.php');
|
||||
|
||||
class mitarbeiter extends benutzer
|
||||
{
|
||||
@@ -644,8 +645,27 @@ class mitarbeiter extends benutzer
|
||||
*/
|
||||
public function getPersonal($fix, $stgl, $fbl, $aktiv, $karenziert, $verwendung, $vertrag=null)
|
||||
{
|
||||
$qry = "SELECT distinct on(mitarbeiter_uid) *, tbl_benutzer.aktiv as aktiv, tbl_mitarbeiter.insertamum, tbl_mitarbeiter.insertvon, tbl_mitarbeiter.updateamum, tbl_mitarbeiter.updatevon FROM ((public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid)) JOIN public.tbl_person USING(person_id)) LEFT JOIN public.tbl_benutzerfunktion USING(uid) LEFT JOIN campus.tbl_resturlaub USING(mitarbeiter_uid) WHERE true";
|
||||
|
||||
$hasUDF = false;
|
||||
$udf = new UDF();
|
||||
|
||||
$qry = "SELECT DISTINCT ON(mitarbeiter_uid) *,
|
||||
tbl_benutzer.aktiv as aktiv,
|
||||
tbl_mitarbeiter.insertamum,
|
||||
tbl_mitarbeiter.insertvon,
|
||||
tbl_mitarbeiter.updateamum,
|
||||
tbl_mitarbeiter.updatevon";
|
||||
|
||||
if ($hasUDF = $udf->personHasUDF())
|
||||
{
|
||||
$qry .= ", public.tbl_person.udf_values AS p_udf_values";
|
||||
}
|
||||
|
||||
$qry .= " FROM ((public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(mitarbeiter_uid=uid))
|
||||
JOIN public.tbl_person USING(person_id))
|
||||
LEFT JOIN public.tbl_benutzerfunktion USING(uid)
|
||||
LEFT JOIN campus.tbl_resturlaub USING(mitarbeiter_uid)
|
||||
WHERE true";
|
||||
|
||||
if($fix=='true')
|
||||
$qry .= " AND fixangestellt=true";
|
||||
if($fix=='false')
|
||||
@@ -769,6 +789,11 @@ class mitarbeiter extends benutzer
|
||||
$obj->urlaubstageprojahr = $row->urlaubstageprojahr;
|
||||
$obj->resturlaubstage = $row->resturlaubstage;
|
||||
|
||||
if ($hasUDF)
|
||||
{
|
||||
$obj->p_udf_values = $row->p_udf_values;
|
||||
}
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
require_once(dirname(__FILE__).'/../config/global.config.inc.php');
|
||||
|
||||
class UDF extends basis_db
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getTitlesPerson()
|
||||
{
|
||||
return $this->_loadTitles($this->_getUDFDefinition($this->loadPersonJsons()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getTitlesPrestudent()
|
||||
{
|
||||
return $this->_loadTitles($this->_getUDFDefinition($this->loadPrestudentJsons()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function loadPersonJsons()
|
||||
{
|
||||
return $this->_loadJsons('public', 'tbl_person');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function loadPrestudentJsons()
|
||||
{
|
||||
return $this->_loadJsons('public', 'tbl_prestudent');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function personHasUDF()
|
||||
{
|
||||
$personHasUDF = false;
|
||||
|
||||
$query = 'SELECT COUNT(*) AS count
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = \'public\'
|
||||
AND table_name = \'tbl_person\'
|
||||
AND column_name = \'udf_values\'';
|
||||
|
||||
if (!$this->db_query($query))
|
||||
{
|
||||
$this->errormsg = 'Error!!!';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
if (isset($row->count) && $row->count > 0)
|
||||
{
|
||||
$personHasUDF = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $personHasUDF;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function prestudentHasUDF()
|
||||
{
|
||||
$prestudentHasUDF = false;
|
||||
|
||||
$query = 'SELECT COUNT(*) AS count
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = \'public\'
|
||||
AND table_name = \'tbl_prestudent\'
|
||||
AND column_name = \'udf_values\'';
|
||||
|
||||
if (!$this->db_query($query))
|
||||
{
|
||||
$this->errormsg = 'Error!!!';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
if (isset($row->count) && $row->count > 0)
|
||||
{
|
||||
$prestudentHasUDF = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $prestudentHasUDF;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _loadJsons($schema, $table)
|
||||
{
|
||||
$jsons = null;
|
||||
$query = 'SELECT jsons FROM system.tbl_udf WHERE schema = \''.$schema.'\' AND "table" = \''.$table.'\'';
|
||||
|
||||
if (!$this->db_query($query))
|
||||
{
|
||||
$this->errormsg = 'Error occurred while loading jsons';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
$jsons = $row->jsons;
|
||||
}
|
||||
}
|
||||
|
||||
return $jsons;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _sortJsonSchemas(&$jsonSchemasArray)
|
||||
{
|
||||
//
|
||||
usort($jsonSchemasArray, function ($a, $b) {
|
||||
//
|
||||
if (!isset($a->sort))
|
||||
{
|
||||
$a->sort = 9999;
|
||||
}
|
||||
if (!isset($b->sort))
|
||||
{
|
||||
$b->sort = 9999;
|
||||
}
|
||||
|
||||
if ($a->sort == $b->sort)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ($a->sort < $b->sort) ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getUDFDefinition($jsons)
|
||||
{
|
||||
$names = array();
|
||||
|
||||
//
|
||||
if ($jsons != null && ($jsonsDecoded = json_decode($jsons)) != null)
|
||||
{
|
||||
if (is_object($jsonsDecoded) || is_array($jsonsDecoded))
|
||||
{
|
||||
//
|
||||
if (is_object($jsonsDecoded))
|
||||
{
|
||||
$jsonsDecoded = array($jsonsDecoded);
|
||||
}
|
||||
|
||||
$this->_sortJsonSchemas($jsonsDecoded); //
|
||||
|
||||
foreach($jsonsDecoded as $udfJsonShema)
|
||||
{
|
||||
if (isset($udfJsonShema->name) && isset($udfJsonShema->title))
|
||||
{
|
||||
$names[] = array('name' => $udfJsonShema->name, 'title' => $udfJsonShema->title);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _loadTitles($udfDefinitions)
|
||||
{
|
||||
$titles = array();
|
||||
$in = '';
|
||||
|
||||
for($i = 0; $i < count($udfDefinitions); $i++)
|
||||
{
|
||||
$udfDefinition = $udfDefinitions[$i];
|
||||
$in .= '\''.$udfDefinition['title'].'\'';
|
||||
|
||||
if ($i < count($udfDefinitions) - 1) $in .= ', ';
|
||||
}
|
||||
|
||||
$query = 'SELECT pt.text AS title, p.phrase AS phrase
|
||||
FROM system.tbl_phrase p INNER JOIN system.tbl_phrasentext pt USING(phrase_id)
|
||||
WHERE pt.sprache = \''.DEFAULT_LEHREINHEIT_SPRACHE.'\'
|
||||
AND p.phrase IN ('.$in.')';
|
||||
|
||||
if (!$this->db_query($query))
|
||||
{
|
||||
$this->errormsg = 'Error occurred while loading jsons';
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($row = $this->db_fetch_assoc())
|
||||
{
|
||||
for($i = 0; $i < count($udfDefinitions); $i++)
|
||||
{
|
||||
$udfDefinition = $udfDefinitions[$i];
|
||||
if ($udfDefinition['title'] == $row['phrase'])
|
||||
{
|
||||
$udfDefinition['description'] = $row['title'];
|
||||
$titles[] = $udfDefinition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $titles;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user