From eea347394a5806744a9798404206c40952c76cbe Mon Sep 17 00:00:00 2001 From: bison-paolo Date: Tue, 27 Sep 2016 15:11:25 +0200 Subject: [PATCH] - Added new migration script 018_status_grund.php - Added new permission "public.tbl_status_grund" in fhcomplete.php - Manage statusgrund from vilesci --- application/config/fhcomplete.php | 1 + application/controllers/crm/Statusgrund.php | 134 +++++++++++++++++++ application/migrations/018_status_grund.php | 75 +++++++++++ application/models/crm/Statusgrund_model.php | 14 ++ application/views/crm/statusgrund.php | 19 +++ application/views/crm/statusgrundEdit.php | 120 +++++++++++++++++ application/views/crm/statusgrundList.php | 35 +++++ 7 files changed, 398 insertions(+) create mode 100644 application/controllers/crm/Statusgrund.php create mode 100644 application/migrations/018_status_grund.php create mode 100644 application/models/crm/Statusgrund_model.php create mode 100644 application/views/crm/statusgrund.php create mode 100644 application/views/crm/statusgrundEdit.php create mode 100644 application/views/crm/statusgrundList.php diff --git a/application/config/fhcomplete.php b/application/config/fhcomplete.php index 7fc457b61..8bdb6f71c 100755 --- a/application/config/fhcomplete.php +++ b/application/config/fhcomplete.php @@ -181,6 +181,7 @@ $config['fhc_acl'] = array 'public.tbl_standort' => 'basis/standort', 'public.tbl_statistik' => 'basis/statistik', 'public.tbl_status' => 'basis/status', + 'public.tbl_status_grund' => 'basis/status', 'public.tbl_student' => 'basis/student', 'public.tbl_studentlehrverband' => 'basis/studentlehrverband', 'public.tbl_studiengang' => 'basis/studiengang', diff --git a/application/controllers/crm/Statusgrund.php b/application/controllers/crm/Statusgrund.php new file mode 100644 index 000000000..2626909e2 --- /dev/null +++ b/application/controllers/crm/Statusgrund.php @@ -0,0 +1,134 @@ +load->model("crm/Status_model", "StatusModel"); + $this->load->model("crm/Statusgrund_model", "StatusgrundModel"); + $this->load->model("system/Sprache_model", "SpracheModel"); + } + + public function index() + { + $this->load->view("crm/statusgrund.php"); + } + + public function listStatus() + { + $status = $this->StatusModel->load(); + if ($status->error) + { + show_error($status->retval); + } + + $data = array ( + "status" => $status->retval + ); + + $this->load->view("crm/statusgrundList.php", $data); + } + + public function editGrund($status_kurzbz) + { + $statusGrund = $this->StatusgrundModel->loadWhere(array("status_kurzbz" => $status_kurzbz)); + if ($statusGrund->error) + { + show_error($statusGrund->retval); + } + + if (count($statusGrund->retval) == 0) + { + $statusGrund->retval[0] = new stdClass(); + $statusGrund->retval[0]->status_kurzbz = $status_kurzbz; + } + + $sprache = $this->SpracheModel->load(); + if ($sprache->error) + { + show_error($sprache->retval); + } + + $data = array ( + "statusgrund" => $statusGrund->retval[0], + "sprache" => $sprache->retval + ); + + $this->load->view("crm/statusgrundEdit.php", $data); + } + + public function saveGrund() + { + $statusgrund_kurzbz = $this->input->post("statusgrund_kurzbz"); + $aktiv = $this->input->post("aktiv") != null && $this->input->post("aktiv") == "on" ? true : false; + $bezeichnung_mehrsprachig = $this->input->post("bezeichnung_mehrsprachig"); + $beschreibung = $this->input->post("beschreibung"); + $status_kurzbz = $this->input->post("status_kurzbz"); + + for ($i = 0; $i < count($bezeichnung_mehrsprachig); $i++) + { + if ($i == 0) $tmp = "{"; + + if (trim($bezeichnung_mehrsprachig[$i]) != "") + { + $bezeichnung_mehrsprachig[$i] = str_replace(",", "|", $bezeichnung_mehrsprachig[$i]); + if ($i < count($bezeichnung_mehrsprachig) - 1) + { + $tmp .= $bezeichnung_mehrsprachig[$i] . ","; + } + else + { + $tmp .= $bezeichnung_mehrsprachig[$i]; + } + } + + if ($i == count($bezeichnung_mehrsprachig) - 1) $bezeichnung_mehrsprachig = $tmp . "}"; + } + + for ($i = 0; $i < count($beschreibung); $i++) + { + if ($i == 0) $tmp = "{"; + + if (trim($beschreibung[$i]) != "") + { + $beschreibung[$i] = str_replace(",", "|", $beschreibung[$i]); + if ($i < count($beschreibung) - 1) + { + $tmp .= $beschreibung[$i] . ","; + } + else + { + $tmp .= $beschreibung[$i]; + } + } + + if ($i == count($beschreibung) - 1) $beschreibung = $tmp . "}"; + } + + $data = array( + "aktiv" => $aktiv, + "bezeichnung_mehrsprachig" => $bezeichnung_mehrsprachig, + "beschreibung" => $beschreibung, + "status_kurzbz" => $status_kurzbz + ); + + if (is_numeric($statusgrund_kurzbz)) + { + $statusgrund = $this->StatusgrundModel->update($statusgrund_kurzbz, $data); + } + else + { + $statusgrund = $this->StatusgrundModel->insert($data); + } + + if ($statusgrund->error) + { + show_error($tatusgrund->retval); + } + + redirect("/crm/Statusgrund/editGrund/" . $status_kurzbz); + } +} diff --git a/application/migrations/018_status_grund.php b/application/migrations/018_status_grund.php new file mode 100644 index 000000000..c2643d3b9 --- /dev/null +++ b/application/migrations/018_status_grund.php @@ -0,0 +1,75 @@ +startUP(); + + $fields = array( + "statusgrund_kurzbz" => array( + "type" => "integer", + "auto_increment" => true + ), + "status_kurzbz" => array( + "type" => "varchar(20)" + ), + "aktiv" => array( + "type" => "boolean DEFAULT FALSE", + "null" => true + ), + "bezeichnung_mehrsprachig" => array( + "type" => "varchar(255)[]" + ), + "beschreibung" => array( + "type" => "text[]" + ) + ); + $this->createTable("public", "tbl_status_grund", $fields); + $this->addPrimaryKey( + "public", + "tbl_status_grund", + "pk_tbl_status_grund", + array("statusgrund_kurzbz") + ); + $this->addForeingKey( + "public", + "tbl_status_grund", + "fk_status_grundstatus_kurzbz", + "status_kurzbz", + "public", + "tbl_status", + "status_kurzbz", + "ON UPDATE CASCADE ON DELETE RESTRICT" + ); + $this->addUniqueKey( + "public", + "tbl_status_grund", + "uk_tbl_status_grund_status_kurzbz", + array("status_kurzbz") + ); + $this->grantTable("SELECT", "public", "tbl_status_grund", "web"); + $this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "public", "tbl_status_grund", "admin"); + $this->grantTable(array("SELECT", "INSERT", "DELETE", "UPDATE"), "public", "tbl_status_grund", "vilesci"); + + $this->endUP(); + } + + public function down() + { + $this->startDown(); + + $this->dropTable("public", "tbl_status_grund"); + + $this->endDown(); + } +} diff --git a/application/models/crm/Statusgrund_model.php b/application/models/crm/Statusgrund_model.php new file mode 100644 index 000000000..22c06f5b9 --- /dev/null +++ b/application/models/crm/Statusgrund_model.php @@ -0,0 +1,14 @@ +dbTable = "public.tbl_status_grund"; + $this->pk = "statusgrund_kurzbz"; + } +} diff --git a/application/views/crm/statusgrund.php b/application/views/crm/statusgrund.php new file mode 100644 index 000000000..e0eee2ad0 --- /dev/null +++ b/application/views/crm/statusgrund.php @@ -0,0 +1,19 @@ + + + + + VileSci - Statusgrund + + + + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + </body> + + + + diff --git a/application/views/crm/statusgrundEdit.php b/application/views/crm/statusgrundEdit.php new file mode 100644 index 000000000..fc3ab2f03 --- /dev/null +++ b/application/views/crm/statusgrundEdit.php @@ -0,0 +1,120 @@ +load->view('templates/header', array('title' => 'StatusgrundEdit')); + + $sg = $statusgrund; +?> + +
+
+

Status: status_kurzbz; ?>

+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Bezeichnung mehrsprachig:

+ + bezeichnung_mehrsprachig)) + { + $val = str_replace("{", "", $sg->bezeichnung_mehrsprachig); + $val = str_replace("}", "", $val); + $val = str_replace("\"", "", $val); + $val = explode(",", $val); + } + else + { + $val = array(); + } + + $i = 0; + ?> + + + sprache; ?>:
+ +
+ + +
+   +
+ Beschreibung:

+ + beschreibung)) + { + $val = str_replace("{", "", $sg->beschreibung); + $val = str_replace("}", "", $val); + $val = str_replace("\"", "", $val); + $val = explode(",", $val); + } + else + { + $val = array(); + } + + $i = 0; + ?> + + + sprache; ?>:
+ +
+ +
+   +
+ Aktiv: + + aktiv) && $sg->aktiv == "t" ? "checked" : ""; ?> /> +
+   +
+ +
+ " /> + +
+
+
+ + diff --git a/application/views/crm/statusgrundList.php b/application/views/crm/statusgrundList.php new file mode 100644 index 000000000..f3d646c25 --- /dev/null +++ b/application/views/crm/statusgrundList.php @@ -0,0 +1,35 @@ +load->view('templates/header', array('title' => 'StatusgrundList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '3:{sorter:false}')); +?> + +
+
+

Status

+ + + + + + + + + + + + + + + + + + + + + + + +
Statusbeschreibunganmerkungext_idbezeichnung_mehrsprachig
status_kurzbz; ?>beschreibung; ?>anmerkung; ?>ext_id; ?>bezeichnung_mehrsprachig; ?>Edit
+
+
+ +