- statusgrundstatus tabelle hinzugefuegt

- sql abfragen angepasst
- statusgrund widget gefixed
This commit is contained in:
ma0048
2025-02-03 13:00:06 +01:00
parent 5b12e5eea7
commit b5500e2d11
8 changed files with 96 additions and 21 deletions
+16 -2
View File
@@ -23,6 +23,7 @@ class Statusgrund extends Auth_Controller
$this->load->model('crm/Status_model', 'StatusModel');
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
$this->load->model('system/Sprache_model', 'SpracheModel');
$this->load->model('crm/Statusgrundstatus_model', 'StatusgrundstatusModel');
}
public function index()
@@ -47,7 +48,8 @@ class Statusgrund extends Auth_Controller
public function listGrund($status_kurzbz)
{
$statusGrund = $this->StatusgrundModel->loadWhere(array("status_kurzbz" => $status_kurzbz));
$this->StatusgrundModel->addJoin('public.tbl_status_grund_status', 'statusgrund_id');
$statusGrund = $this->StatusgrundModel->loadWhere(array("tbl_status_grund_status.status_kurzbz" => $status_kurzbz));
if ($statusGrund->error)
{
show_error(getError($statusGrund));
@@ -245,7 +247,6 @@ class Statusgrund extends Auth_Controller
}
$data = array(
"status_kurzbz" => $status_kurzbz,
"aktiv" => $aktiv,
"bezeichnung_mehrsprachig" => $bezeichnung_mehrsprachig,
"beschreibung" => $beschreibung,
@@ -258,6 +259,19 @@ class Statusgrund extends Auth_Controller
{
show_error(getError($statusgrund));
}
else
{
$statusData = array(
"status_kurzbz" => $status_kurzbz,
"statusgrund_id" => $statusgrund->retval
);
$statusgrundstatus = $this->StatusgrundstatusModel->insert($statusData);
if ($statusgrundstatus->error)
{
show_error(getError($statusgrundstatus));
}
}
redirect("/crm/Statusgrund/editGrund/" . $statusgrund->retval . "/" . true);
}
+5 -4
View File
@@ -16,16 +16,17 @@ class Status_model extends DB_Model
{
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
$this->addSelect('sg.status_kurzbz');
$this->addSelect('sgs.status_kurzbz');
$this->addSelect('statusgrund_id');
$this->addSelect('sg.statusgrund_id');
$this->addSelect('sg.bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
$this->addSelect('sg.beschreibung' . $lang . ' AS beschreibung');
$this->addJoin('public.tbl_status_grund sg', 'ON (sg.status_kurzbz = public.tbl_status.status_kurzbz)', 'LEFT');
$this->addJoin('public.tbl_status_grund_status sgs', 'ON (sgs.status_kurzbz = public.tbl_status.status_kurzbz)', 'LEFT');
$this->addJoin('public.tbl_status_grund sg', 'ON (sgs.statusgrund_id = sg.statusgrund_id)', 'LEFT');
return $this->loadWhere([
'aktiv'=> true,
'sg.aktiv'=> true,
]);
}
}
+8 -2
View File
@@ -16,8 +16,12 @@ class Statusgrund_model extends DB_Model
{
$this->addOrder('bezeichnung_mehrsprachig');
$where = array();
if (!is_null($status_kurzbz))
$where['status_kurzbz'] = $status_kurzbz;
{
$this->addJoin('public.tbl_status_grund_status', 'statusgrund_id');
$where['tbl_status_grund_status.status_kurzbz'] = $status_kurzbz;
}
if (!is_null($aktiv))
$where['aktiv'] = $aktiv;
if (!is_null($statusgrund_kurzbz))
@@ -32,9 +36,11 @@ class Statusgrund_model extends DB_Model
{
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
$this->addSelect('tbl_status_grund.*');
$this->addSelect('tbl_status_grund.*, tbl_status_grund_status.status_kurzbz');
$this->addSelect('bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
$this->addSelect('beschreibung' . $lang . ' AS beschreibung');
$this->addJoin('public.tbl_status_grund_status', 'statusgrund_id');
$this->addOrder('bezeichnung_mehrsprachig' . $lang);
@@ -0,0 +1,16 @@
<?php
class Statusgrundstatus_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = "public.tbl_status_grund_status";
$this->pk = array('status_kurzbz', 'statusgrund_id');
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ class Statusgrund_widget extends DropdownWidget
$this->load->model('crm/statusgrund_model', 'StatusgrundModel');
$this->StatusgrundModel->addOrder('statusgrund_id');
$this->addSelectToModel($this->StatusgrundModel, 'statusgrund_id', 'bezeichnung_mehrsprachig[1]');
$this->addSelectToModel($this->StatusgrundModel, 'statusgrund_id', '(bezeichnung_mehrsprachig[1])');
$this->setElementsArray(
$this->StatusgrundModel->load(),
+17 -12
View File
@@ -58,11 +58,12 @@ class statusgrund extends basis_db
$beschreibung = $sprache->getSprachQuery('beschreibung');
$qry = "
SELECT
*,".$bezeichnung_mehrsprachig.",".$beschreibung."
statusgrund.*, statusgrund.".$bezeichnung_mehrsprachig.",".$beschreibung.", statusgrundstatus.status_kurzbz
FROM
public.tbl_status_grund
public.tbl_status_grund statusgrund
JOIN public.tbl_status_grund_status statusgrundstatus ON statusgrund.statusgrund_id = statusgrundstatus.statusgrund_id
WHERE
statusgrund_id=".$this->db_add_param($statusgrund_id, FHC_INTEGER);
statusgrund.statusgrund_id=".$this->db_add_param($statusgrund_id, FHC_INTEGER);
if($this->db_query($qry))
{
@@ -103,14 +104,16 @@ class statusgrund extends basis_db
$beschreibung = $sprache->getSprachQuery('beschreibung');
$qry = "
SELECT
*,".$bezeichnung_mehrsprachig.",".$beschreibung."
statusgrund.*,
statusgrund.".$bezeichnung_mehrsprachig.",".$beschreibung."
FROM
public.tbl_status_grund
public.tbl_status_grund statusgrund
JOIN public.tbl_status_grund_status statusgrundstatus ON statusgrund.statusgrund_id = statusgrundstatus.statusgrund_id
WHERE
status_kurzbz=".$this->db_add_param($status_kurzbz);
statusgrundstatus.status_kurzbz=".$this->db_add_param($status_kurzbz);
if(!is_null($aktiv))
$qry.=" AND aktiv=".($aktiv?'true':'false');
$qry.=" ORDER BY bezeichnung_mehrsprachig[0]";
$qry.=" AND statusgrund.aktiv=".($aktiv?'true':'false');
$qry.=" ORDER BY statusgrund.bezeichnung_mehrsprachig[0]";
if($this->db_query($qry))
{
@@ -150,14 +153,16 @@ class statusgrund extends basis_db
$beschreibung = $sprache->getSprachQuery('beschreibung');
$qry = "
SELECT
*,".$bezeichnung_mehrsprachig.",".$beschreibung."
statusgrund.*,statusgrund.".$bezeichnung_mehrsprachig.",".$beschreibung.", statusgrundstatus.status_kurzbz
FROM
public.tbl_status_grund
public.tbl_status_grund statusgrund
JOIN public.tbl_status_grund_status statusgrundstatus ON statusgrund.statusgrund_id = statusgrundstatus.statusgrund_id
";
if(!is_null($aktiv))
$qry.="WHERE aktiv=".($aktiv?'true':'false');
$qry.=" ORDER BY status_kurzbz, bezeichnung_mehrsprachig[0]";
$qry.="WHERE statusgrund.aktiv=".($aktiv?'true':'false');
$qry.=" ORDER BY statusgrundstatus.status_kurzbz, statusgrund.bezeichnung_mehrsprachig[0]";
if($this->db_query($qry))
{
+1
View File
@@ -69,6 +69,7 @@ require_once('dbupdate_3.4/40717_lv_faktor.php');
require_once('dbupdate_3.4/48526_pep_tagging.php');
require_once('dbupdate_3.4/41950_perm_gehaelter.php');
require_once('dbupdate_3.4/53903_valorisierung.php');
require_once('dbupdate_3.4/40431_statusgrund_tabelle_zuordnung_zu_status.php');
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
@@ -0,0 +1,32 @@
<?php
if (! defined('DB_NAME')) exit('No direct script access allowed');
if (!$result = @$db->db_query('SELECT 1 FROM public.tbl_status_grund_status LIMIT 1'))
{
$qry = 'CREATE TABLE public.tbl_status_grund_status
(
status_kurzbz varchar(20) NOT NULL,
statusgrund_id int NOT NULL,
CONSTRAINT pk_status_grund_status PRIMARY KEY (status_kurzbz, statusgrund_id),
CONSTRAINT fk_status_grund_status_kurzbz FOREIGN KEY (status_kurzbz)
REFERENCES public.tbl_status (status_kurzbz) ON DELETE RESTRICT,
CONSTRAINT fk_status_grund_status_statusgrund_id FOREIGN KEY (statusgrund_id)
REFERENCES public.tbl_status_grund (statusgrund_id) ON DELETE RESTRICT
);
GRANT SELECT ON public.tbl_status_grund_status TO web;
GRANT SELECT, UPDATE, INSERT, DELETE ON public.tbl_status_grund_status TO vilesci;
INSERT INTO public.tbl_status_grund_status (status_kurzbz, statusgrund_id)
SELECT status_kurzbz, statusgrund_id FROM public.tbl_status_grund;
/*ALTER TABLE public.tbl_status_grund DROP COLUMN status_kurzbz;*/
';
if(!$db->db_query($qry))
echo '<strong>public.tbl_status_grund_status: '.$db->db_last_error().'</strong><br>';
else
echo 'public.tbl_status_grund_status: Tabelle hinzugefuegt<br>';
}