mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-02 03:19:27 +00:00
ext_id aus Save Funktionen entfernt damit diese beim Speichern von Datensätzen nicht verloren geht
This commit is contained in:
+75
-77
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
*/
|
||||
/**
|
||||
* Klasse Service
|
||||
*
|
||||
*
|
||||
*/
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
@@ -35,7 +35,7 @@ class service extends basis_db
|
||||
public $ext_id; // bigint
|
||||
public $oe_kurzbz; // varchar(32)
|
||||
public $content_id; // integer
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor - Laedt optional ein Service
|
||||
* @param $service_id
|
||||
@@ -43,14 +43,14 @@ class service extends basis_db
|
||||
public function __construct($service_id=null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
if(!is_null($service_id))
|
||||
$this->load($service_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt ein Service mit der uebergebenen ID
|
||||
*
|
||||
*
|
||||
* @param $service_id
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -61,8 +61,8 @@ class service extends basis_db
|
||||
$this->errormsg = 'Service ID ist ungueltig';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$qry = "SELECT * FROM public.tbl_service WHERE service_id=".$this->db_add_param($service_id, FHC_INTEGER);
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
@@ -75,7 +75,7 @@ class service extends basis_db
|
||||
$this->ext_id = $row->ext_id;
|
||||
$this->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->content_id = $row->content_id;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -90,27 +90,27 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt alle vorhandenen Services
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_service ORDER BY oe_kurzbz, bezeichnung";
|
||||
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new service();
|
||||
|
||||
|
||||
$obj->service_id = $row->service_id;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
@@ -121,33 +121,33 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sucht ein Service
|
||||
*
|
||||
*
|
||||
* @param $suchstring
|
||||
*/
|
||||
public function search($suchstring)
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_service WHERE 1=1 ";
|
||||
{
|
||||
$qry = "SELECT * FROM public.tbl_service WHERE 1=1 ";
|
||||
foreach($suchstring as $value)
|
||||
$qry.="AND (lower(beschreibung::text) like lower('%".$this->db_escape($value)."%')
|
||||
OR lower(beschreibung::text) like lower('%".$this->db_escape(htmlentities($value,ENT_NOQUOTES,'UTF-8'))."%'))";
|
||||
$qry.=" ORDER BY oe_kurzbz, bezeichnung";
|
||||
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new service();
|
||||
|
||||
|
||||
$obj->service_id = $row->service_id;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
@@ -158,58 +158,58 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt alle vorhandenen Services, sortiert nach den am haeufigsten vom User in der Zeitaufzeichnung verwendeten
|
||||
*
|
||||
*
|
||||
* <p>Optionaler Zeitraum (Tage in die Vergangenheit), in denen das Service vorkommt<br>
|
||||
* Optionale Anzahl an Ereignissen im angegebenen Zeitraum, um das Service zu beruecksichtigen</p>
|
||||
*
|
||||
*
|
||||
* @param string $user uid
|
||||
* @param integer $zeitraum Anzahl Tage in die Vergangenheit, die fuer das Auftreten des Service beruecksichtigt werden sollen
|
||||
* @param integer $anzahl_ereignisse default: 3 Wie oft soll dieses Service mindestens in $zeitraum vorkommen, um beruecksichtigt zu werden
|
||||
*/
|
||||
public function getFrequentServices($user, $zeitraum=null, $anzahl_ereignisse='3')
|
||||
{
|
||||
{
|
||||
if(!is_numeric($anzahl_ereignisse))
|
||||
{
|
||||
$this->errormsg = 'anzahl_ereignisse muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($zeitraum) && $zeitraum>0 && is_numeric($zeitraum))
|
||||
$zeit = "AND tbl_zeitaufzeichnung.start>=(now()::date-$zeitraum)";
|
||||
else
|
||||
else
|
||||
$zeit = "";
|
||||
|
||||
|
||||
$qry = " SELECT service_id,oe_kurzbz,bezeichnung,beschreibung,ext_id,content_id, sum(a.anzahl) AS anzahl FROM (
|
||||
SELECT
|
||||
SELECT
|
||||
tbl_service.*,
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.service_id) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.service_id) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
) AS anzahl
|
||||
FROM public.tbl_service
|
||||
WHERE
|
||||
WHERE
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.service_id) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
) > $anzahl_ereignisse
|
||||
GROUP BY tbl_service.service_id,tbl_service.beschreibung,tbl_service.ext_id,tbl_service.oe_kurzbz,tbl_service.bezeichnung,tbl_service.content_id,anzahl
|
||||
|
||||
|
||||
UNION
|
||||
SELECT tbl_service.*, '0' AS anzahl
|
||||
FROM public.tbl_service
|
||||
) AS a
|
||||
GROUP BY service_id,oe_kurzbz,bezeichnung,beschreibung,ext_id,content_id
|
||||
ORDER BY anzahl DESC,bezeichnung,oe_kurzbz";
|
||||
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new service();
|
||||
|
||||
|
||||
$obj->service_id = $row->service_id;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
@@ -217,7 +217,7 @@ class service extends basis_db
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->anzahl = $row->anzahl;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
@@ -228,45 +228,45 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt die Services der uebergebenen OE
|
||||
*
|
||||
*
|
||||
* @param string $oe_kurzbz OE_Kurzbezeichnung der zu suchenden Services.
|
||||
* @param integer $content_id Default: null. Wenn true, werden nur OEs mit eingetragener Content_id zurückgegeben.
|
||||
* Wenn content_id übergeben wird, wird nur das entsprechende Service zurückgegeben.
|
||||
* @param integer $content_id Default: null. Wenn true, werden nur OEs mit eingetragener Content_id zurückgegeben.
|
||||
* Wenn content_id übergeben wird, wird nur das entsprechende Service zurückgegeben.
|
||||
*/
|
||||
public function getServicesOrganisationseinheit($oe_kurzbz, $content_id=null)
|
||||
{
|
||||
$qry = 'SELECT
|
||||
*
|
||||
FROM
|
||||
public.tbl_service
|
||||
WHERE
|
||||
{
|
||||
$qry = 'SELECT
|
||||
*
|
||||
FROM
|
||||
public.tbl_service
|
||||
WHERE
|
||||
oe_kurzbz='.$this->db_add_param($oe_kurzbz);
|
||||
|
||||
|
||||
if (!is_null($content_id) && is_numeric($content_id))
|
||||
$qry.= ' AND content_id='.$this->db_add_param($content_id);
|
||||
elseif ($content_id==true)
|
||||
$qry.= ' AND content_id IS NOT NULL';
|
||||
else
|
||||
else
|
||||
$qry.= '';
|
||||
|
||||
|
||||
$qry.= ' ORDER BY bezeichnung';
|
||||
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new service();
|
||||
|
||||
|
||||
$obj->service_id = $row->service_id;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
@@ -277,46 +277,46 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Laedt die Services der uebergebenen OE und alle Services, die dieser OE untergliedert sind
|
||||
*
|
||||
*
|
||||
* @param string $oe_kurzbz
|
||||
* @param string $order Default: oe_kurzbz,bezeichnung
|
||||
* @param integer $content_id Default: null. Wenn true, werden nur OEs mit eingetragener Content_id zurückgegeben.
|
||||
* @param integer $content_id Default: null. Wenn true, werden nur OEs mit eingetragener Content_id zurückgegeben.
|
||||
* Wenn content_id übergeben wird, wird nur das entsprechende Service zurückgegeben.
|
||||
*/
|
||||
public function getSubServicesOrganisationseinheit($oe_kurzbz, $order='oe_kurzbz,bezeichnung', $content_id=null)
|
||||
{
|
||||
{
|
||||
$qry = 'SELECT
|
||||
*
|
||||
FROM
|
||||
public.tbl_service
|
||||
WHERE
|
||||
*
|
||||
FROM
|
||||
public.tbl_service
|
||||
WHERE
|
||||
oe_kurzbz IN (SELECT oe_kurzbz FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz='.$this->db_add_param($oe_kurzbz).')';
|
||||
if (!is_null($content_id) && is_numeric($content_id))
|
||||
$qry.= ' AND content_id='.$this->db_add_param($content_id);
|
||||
elseif ($content_id==true)
|
||||
$qry.= ' AND content_id IS NOT NULL';
|
||||
else
|
||||
else
|
||||
$qry.= '';
|
||||
|
||||
if (!is_null($order))
|
||||
$qry.= ' ORDER BY '.$order;
|
||||
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new service();
|
||||
|
||||
|
||||
$obj->service_id = $row->service_id;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
@@ -327,7 +327,7 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prueft die Daten vor dem Speichern
|
||||
* @return boolean
|
||||
@@ -336,7 +336,7 @@ class service extends basis_db
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Speichert ein Service
|
||||
* @param $new
|
||||
@@ -345,17 +345,16 @@ class service extends basis_db
|
||||
{
|
||||
if(is_null($new))
|
||||
$new = $this->new;
|
||||
|
||||
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
|
||||
if($new)
|
||||
{
|
||||
$qry = "BEGIN;INSERT INTO public.tbl_service (bezeichnung, beschreibung, ext_id, oe_kurzbz, content_id)
|
||||
$qry = "BEGIN;INSERT INTO public.tbl_service (bezeichnung, beschreibung, oe_kurzbz, content_id)
|
||||
VALUES(".
|
||||
$this->db_add_param($this->bezeichnung).','.
|
||||
$this->db_add_param($this->beschreibung).','.
|
||||
$this->db_add_param($this->ext_id).','.
|
||||
$this->db_add_param($this->oe_kurzbz).','.
|
||||
$this->db_add_param($this->content_id).');';
|
||||
}
|
||||
@@ -364,12 +363,11 @@ class service extends basis_db
|
||||
$qry = 'UPDATE public.tbl_service SET'.
|
||||
' bezeichnung = '.$this->db_add_param($this->bezeichnung).','.
|
||||
' beschreibung = '.$this->db_add_param($this->beschreibung).','.
|
||||
' ext_id = '.$this->db_add_param($this->ext_id).','.
|
||||
' oe_kurzbz = '.$this->db_add_param($this->oe_kurzbz).','.
|
||||
' content_id = '.$this->db_add_param($this->content_id).
|
||||
' WHERE service_id='.$this->db_add_param($this->service_id, FHC_INTEGER).';';
|
||||
' WHERE service_id='.$this->db_add_param($this->service_id, FHC_INTEGER).';';
|
||||
}
|
||||
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if($new)
|
||||
@@ -406,10 +404,10 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loescht einen Service
|
||||
|
||||
|
||||
* @param $service_id
|
||||
*/
|
||||
public function delete($service_id)
|
||||
@@ -420,7 +418,7 @@ class service extends basis_db
|
||||
return false;
|
||||
}
|
||||
$qry = "DELETE FROM public.tbl_service WHERE service_id=".$this->db_add_param($service_id);
|
||||
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
@@ -430,4 +428,4 @@ class service extends basis_db
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user