From ac1f55b19c94554d96315b235951e366752f51b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 26 Feb 2018 15:37:23 +0100 Subject: [PATCH 1/3] Web User fuer tbl_msg_status berechtigt damit der Message-Status gesetzt werden kann --- system/dbupdate_3.3.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index 0b03c8bcb..513d778d4 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -1300,6 +1300,19 @@ if (!$result = @$db->db_query("SELECT 1 FROM system.tbl_person_lock LIMIT 1")) echo ' system.tbl_person_lock hinzugefügt
'; } +// INSERT Berechtigungen fuer web User erteilen fuer tbl_msg_status +if($result = @$db->db_query("SELECT * FROM information_schema.role_table_grants WHERE table_name='tbl_msg_status' AND table_schema='public' AND grantee='web' AND privilege_type='INSERT'")) +{ + if($db->db_num_rows($result)==0) + { + $qry = "GRANT SELECT, INSERT ON public.tbl_msg_status TO web;"; + + if(!$db->db_query($qry)) + echo 'public.tbl_msg_status Berechtigungen: '.$db->db_last_error().'
'; + else + echo 'INSERT Rechte fuer public.tbl_msg_status fuer web user gesetzt '; + } +} // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; From 8f6ee06b9d1ec6b00683afa387865aeb6b240bf3 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 26 Feb 2018 16:54:41 +0100 Subject: [PATCH 2/3] added "zgv uebernehmen" for prefill of zgv with latest edited zgv, optimized sort of zgvs --- .../system/infocenter/InfoCenter.php | 40 ++++++++++--- application/models/crm/Prestudent_model.php | 23 ++++++++ .../system/infocenter/infocenterDetails.php | 1 + .../views/system/infocenter/zgvpruefungen.php | 37 ++++++------ include/js/infocenter/infocenterDetails.js | 57 +++++++++++++++++-- 5 files changed, 128 insertions(+), 30 deletions(-) diff --git a/application/controllers/system/infocenter/InfoCenter.php b/application/controllers/system/infocenter/InfoCenter.php index c65d15238..135e24a5c 100644 --- a/application/controllers/system/infocenter/InfoCenter.php +++ b/application/controllers/system/infocenter/InfoCenter.php @@ -194,6 +194,26 @@ class InfoCenter extends VileSci_Controller redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#DokPruef'); } + /** + * Gets prestudent that was last modified in json format, for ZGV übernehmen + * @param $person_id + */ + public function getLastPrestudentWithZgvJson($person_id) + { + $prestudent = $this->PrestudentModel->getLastPrestudent($person_id, true); + + if (isError($prestudent)) + { + show_error($prestudent->retval); + } + + $jsonoutput = count($prestudent->retval) > 0 ? $prestudent->retval[0] : null; + + $this->output + ->set_content_type('application/json') + ->set_output(json_encode($jsonoutput)); + } + /** * Saves a zgv for a prestudent. includes Ort, Datum, Nation for bachelor and master. * @param $prestudent_id @@ -225,7 +245,8 @@ class InfoCenter extends VileSci_Controller 'zgvmas_code' => $zgvmas_code, 'zgvmaort' => $zgvmaort, 'zgvmadatum' => $zgvmadatum, - 'zgvmanation' => $zgvmanation_code + 'zgvmanation' => $zgvmanation_code, + 'updateamum' => date('Y-m-d H:i:s') ) ); @@ -249,7 +270,6 @@ class InfoCenter extends VileSci_Controller */ public function saveAbsage($prestudent_id) { - //TODO email messaging $statusgrund = $this->input->post('statusgrund'); $lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id); @@ -646,7 +666,6 @@ class InfoCenter extends VileSci_Controller foreach ($prestudenten->retval as $prestudent) { $prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent->prestudent_id); - $personid = $this->_getPersonAndStudiengangFromPrestudent($person_id); if (isError($prestudent)) { @@ -668,15 +687,18 @@ class InfoCenter extends VileSci_Controller $zgvpruefungen[] = $zgvpruefung; } - // Interessenten come first - usort($zgvpruefungen, function ($a, $b) - { + // Interessenten come first, otherwise by bewerbungsdatum desc, then by prestudent_id desc + usort($zgvpruefungen, function ($a, $b) { + $bewdatesort = strcmp($b->prestudentstatus->bewerbung_abgeschicktamum, $a->prestudentstatus->bewerbung_abgeschicktamum); + $defaultsort = $bewdatesort === 0 ? (int)$b->prestudent_id - (int)$a->prestudent_id : $bewdatesort; if (!isset($a->prestudentstatus->status_kurzbz) || !isset($b->prestudentstatus->status_kurzbz)) - return 0; + return $defaultsort; elseif ($a->prestudentstatus->status_kurzbz === 'Interessent' && $b->prestudentstatus->status_kurzbz === 'Interessent') { //infoonly Interessenten come after new Interessenten - if ($a->infoonly) + if ($a->infoonly === $b->infoonly) + return $defaultsort; + elseif ($a->infoonly) return 1; elseif ($b->infoonly) return -1; @@ -686,7 +708,7 @@ class InfoCenter extends VileSci_Controller elseif ($b->prestudentstatus->status_kurzbz === 'Interessent') return 1; else - return 0; + return $defaultsort; }); $statusgruende = $this->StatusgrundModel->loadWhere(array('status_kurzbz' => 'Abgewiesener'))->retval; diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php index d75d17236..2051c1666 100644 --- a/application/models/crm/Prestudent_model.php +++ b/application/models/crm/Prestudent_model.php @@ -239,4 +239,27 @@ class Prestudent_model extends DB_Model return success($prestudent->retval); } + /** + * gets the prestudent edited last. + * if no updateamum, sort by insertamum + * @param $person_id + * @param bool $withzgv if true, only prestudenten with zgv_code are taken + * @return array|null + */ + public function getLastPrestudent($person_id, $withzgv = false) + { + $qry = 'SELECT * FROM public.tbl_prestudent + WHERE person_id = ? + %s + ORDER BY updateamum DESC NULLS LAST, insertamum DESC NULLS LAST + LIMIT 1'; + + $zgvwhere = $withzgv === true ? 'AND zgv_code IS NOT NULL' : ''; + + $qry = sprintf($qry, $zgvwhere); + + $parametersArray = array($person_id); + + return $this->execQuery($qry, $parametersArray); + } } diff --git a/application/views/system/infocenter/infocenterDetails.php b/application/views/system/infocenter/infocenterDetails.php index 6b672cd87..da6abaf78 100644 --- a/application/views/system/infocenter/infocenterDetails.php +++ b/application/views/system/infocenter/infocenterDetails.php @@ -36,6 +36,7 @@ ?>
+
@@ -89,7 +89,7 @@ ?> + name="zgvort" id="zgvort_prestudent_id ?>">
@@ -103,7 +103,7 @@ zgvdatum), 'd.m.Y') ?>" - name="zgvdatum"> + name="zgvdatum" id="zgvdatum_prestudent_id ?>"> @@ -116,7 +116,7 @@ echo $this->widgetlib->widget( 'Nation_widget', array(DropdownWidget::SELECTED_ELEMENT => $zgvpruefung->zgvnation_code), - array('name' => 'zgvnation', 'id' => 'zgvnation') + array('name' => 'zgvnation', 'id' => 'zgvnation_'.$zgvpruefung->prestudent_id) ); ?> @@ -183,7 +183,12 @@
-
+
+ +
+
@@ -203,7 +208,7 @@
-
+
- - + +
-
-