diff --git a/application/controllers/api/v1/organisation/Statistik.php b/application/controllers/api/v1/organisation/Statistik.php index 8d72fbadf..beeaaae22 100644 --- a/application/controllers/api/v1/organisation/Statistik.php +++ b/application/controllers/api/v1/organisation/Statistik.php @@ -46,6 +46,32 @@ class Statistik extends APIv1_Controller $this->response(); } } + + /** + * @return void + */ + public function getAll() + { + $this->StatistikModel->addOrder($this->get('order')); + + $result = $this->StatistikModel->loadWhole(); + + $this->response($result, REST_Controller::HTTP_OK); + } + + /** + * @return void + */ + public function getMenueArray() + { + $this->StatistikModel->addOrder('gruppe'); + $this->StatistikModel->addOrder('bezeichnung'); + $this->StatistikModel->addOrder('statistik_kurzbz'); + + $result = $this->StatistikModel->loadWhole(); + + $this->response($result, REST_Controller::HTTP_OK); + } /** * @return void diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php index a4cc9b4e7..2539c7203 100644 --- a/application/core/FHC_Model.php +++ b/application/core/FHC_Model.php @@ -23,6 +23,12 @@ class FHC_Model extends CI_Model { $uid = $_SERVER['PHP_AUTH_USER']; } + + // After getting UID for the first time, it saves it in CI session + if (isset($uid) && !isset($this->session->uid)) + { + $this->session->uid = $uid; + } $this->load->library('FHC_DB_ACL', array('uid' => $uid)); } diff --git a/include/dms.class.php b/include/dms.class.php index f8fb930e6..55ed1d02f 100644 --- a/include/dms.class.php +++ b/include/dms.class.php @@ -32,6 +32,8 @@ require_once(dirname(__FILE__).'/../application/models/content/Dms_model.php'); class dms extends Dms_model { + use db_extra; //CI Hack + public $new; public $result=array(); diff --git a/include/kontakt.class.php b/include/kontakt.class.php index d5a46b3eb..88c3a6db9 100644 --- a/include/kontakt.class.php +++ b/include/kontakt.class.php @@ -31,6 +31,8 @@ require_once(dirname(__FILE__).'/../application/models/person/Kontakt_model.php' class kontakt extends Kontakt_model { + use db_extra; //CI Hack + public $new; // boolean public $result = array(); // adresse Objekt diff --git a/include/organisationsform.class.php b/include/organisationsform.class.php index 37f444bd8..cfaf45648 100644 --- a/include/organisationsform.class.php +++ b/include/organisationsform.class.php @@ -32,6 +32,8 @@ require_once(dirname(__FILE__).'/../application/models/codex/Orgform_model.php') class organisationsform extends Orgform_model { + use db_extra; //CI Hack + public $orgform_kurzbz; public $code; public $bezeichnung; diff --git a/include/person.class.php b/include/person.class.php index ef20a5821..79f98f113 100644 --- a/include/person.class.php +++ b/include/person.class.php @@ -31,7 +31,7 @@ require_once(dirname(__FILE__).'/../application/models/person/Person_model.php') class person extends Person_model { use db_extra; //CI Hack - + public $errormsg; // string public $new; // boolean public $personen = array(); // person Objekt diff --git a/include/preinteressent.class.php b/include/preinteressent.class.php index 2326e4580..d71f09e8a 100644 --- a/include/preinteressent.class.php +++ b/include/preinteressent.class.php @@ -27,6 +27,8 @@ require_once(dirname(__FILE__).'/../application/models/crm/Preinteressent_model. class preinteressent extends Preinteressent_model { + use db_extra; //CI Hack + public $new; // boolean public $result = array(); diff --git a/include/prestudent.class.php b/include/prestudent.class.php index 0b9fa2099..14217c498 100755 --- a/include/prestudent.class.php +++ b/include/prestudent.class.php @@ -30,6 +30,7 @@ require_once(dirname(__FILE__).'/../application/models/crm/Prestudent_model.php' class prestudent extends Prestudent_model { use db_extra; //CI Hack + public $errormsg; // string //Tabellenspalten diff --git a/include/statistik.class.php b/include/statistik.class.php index 85fb6e834..73be1b34d 100644 --- a/include/statistik.class.php +++ b/include/statistik.class.php @@ -19,10 +19,16 @@ * Andreas Oesterreicher * Karl Burkhart . */ -require_once(dirname(__FILE__).'/basis_db.class.php'); +require_once(dirname(__FILE__).'/datum.class.php'); -class statistik extends basis_db +// CI +require_once(dirname(__FILE__).'/../ci_hack.php'); +require_once(dirname(__FILE__).'/../application/models/organisation/Statistik_model.php'); + +class statistik extends Statistik_model { + use db_extra; //CI Hack + public $new; public $statistik_obj=array(); public $result; @@ -76,17 +82,14 @@ class statistik extends basis_db */ public function load($statistik_kurzbz) { - $qry = "SELECT - * - FROM - public.tbl_statistik - WHERE - statistik_kurzbz = " . $this->db_add_param($statistik_kurzbz); + $result = parent::load($statistik_kurzbz); - if($result = $this->db_query($qry)) + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) { - if($row = $this->db_fetch_object($result)) + if(count($result->retval) > 0) { + $row = $result->retval[0]; + $this->statistik_kurzbz = $row->statistik_kurzbz; $this->content_id = $row->content_id; $this->bezeichnung = $row->bezeichnung; @@ -125,15 +128,19 @@ class statistik extends basis_db */ public function getAll($order = FALSE) { - $qry = 'SELECT * FROM public.tbl_statistik'; - - if($order) - $qry .= ' ORDER BY ' . $order; - - if($result = $this->db_query($qry)) + if ($order) { - while($row = $this->db_fetch_object($result)) + parent::addOrder($order); + } + + $result = parent::loadWhole(); + + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) + { + for ($i = 0; $i < count($result->retval); $i++) { + $row = $result->retval[$i]; + $obj = new statistik(); $obj->statistik_kurzbz = $row->statistik_kurzbz; @@ -328,17 +335,19 @@ class statistik extends basis_db { $arr = array(); - $qry = "SELECT - * - FROM - public.tbl_statistik - ORDER BY gruppe, bezeichnung, statistik_kurzbz"; + parent::addOrder('gruppe'); + parent::addOrder('bezeichnung'); + parent::addOrder('statistik_kurzbz'); + + $result = parent::loadWhole(); - if($result = $this->db_query($qry)) + if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval)) { $lastgruppe=''; - while($row = $this->db_fetch_object($result)) + for ($i = 0; $i < count($result->retval); $i++) { + $row = $result->retval[$i]; + if($row->gruppe!='' && $row->gruppe!=$lastgruppe) { $arr[$row->gruppe]=array('name'=>$row->gruppe); diff --git a/include/studiensemester.class.php b/include/studiensemester.class.php index c2158c3e9..12e48ee1b 100644 --- a/include/studiensemester.class.php +++ b/include/studiensemester.class.php @@ -28,6 +28,8 @@ require_once(dirname(__FILE__).'/../application/models/organisation/Studiensemes class studiensemester extends Studiensemester_model { + use db_extra; //CI Hack + public $new; // boolean public $studiensemester = array(); // studiensemester Objekt diff --git a/tests/codeception/_data/dump.sql b/tests/codeception/_data/dump.sql index 8238e5158..552d65f75 100644 --- a/tests/codeception/_data/dump.sql +++ b/tests/codeception/_data/dump.sql @@ -1091,4 +1091,21 @@ INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('basis/vw_studiensemester', 'admin', 'suid'); INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('lehre/reservierung', 'admin', 'suid'); INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('lehre/reihungstest', 'admin', 'suid'); -INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('wawi/inventar:begrenzt', 'admin', 'suid'); \ No newline at end of file +INSERT INTO system.tbl_rolleberechtigung (berechtigung_kurzbz, rolle_kurzbz, art) VALUES('wawi/inventar:begrenzt', 'admin', 'suid'); + +-- EMPTY public.tbl_statistik +DELETE FROM public.tbl_statistik; + +-- INSERT Statistiks (public.tbl_statistik) +INSERT INTO public.tbl_statistik VALUES ('StudentenHistorie', 'StudentenHistorie', NULL, 'studenten_historie.php', 'Studierende', NULL, NULL, NULL, '2011-04-04 09:25:35', 'oesi', '2011-04-04 09:25:35', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Abgaengerstatistik', 'Abgängerstatistik', 9, '../../content/statistik/abgaengerstatistik.php', 'Studierende', NULL, NULL, NULL, '2011-04-01 10:57:05', 'oesi', '2011-04-01 11:13:55', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Absolventenstatistik', 'Absolventenstatistik', 10, '../../content/statistik/absolventenstatistik.php', 'Studierende', NULL, NULL, NULL, '2011-04-01 10:57:46', 'oesi', '2011-04-01 11:14:01', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Bewerberstatistik', 'Bewerberstatistik', 2, '../../content/statistik/bewerberstatistik.php?stsem=$Studiensemester', 'Studierende', NULL, NULL, NULL, '2011-04-01 10:43:44', 'oesi', '2011-04-01 11:14:19', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Lektorenstatistik', 'Lektorenstatistik', 13, '../../content/statistik/lektorenstatistik.php', 'Mitarbeiter', NULL, NULL, NULL, '2011-04-01 11:08:41', 'oesi', '2011-04-01 11:14:27', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Raumauslastung', 'Raumauslastung', 3, '../lehre/raumauslastung.php', 'LV-Plan', NULL, NULL, NULL, '2011-04-01 10:51:01', 'oesi', '2011-04-01 11:14:50', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Stromanalyse', 'Stromanalyse', 15, '../../content/statistik/bama_stromanalyse.php', 'Studierende', NULL, NULL, NULL, '2011-04-01 11:09:45', 'oesi', '2011-04-01 11:14:59', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Mitarbeiterstatistik', 'Mitarbeiterstatistik', 14, '../../content/statistik/mitarbeiterstatistik.php', 'Mitarbeiter', NULL, NULL, NULL, '2011-04-01 11:09:13', 'oesi', '2012-01-12 15:48:47', 'kollmitz', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Verplanungsübersicht', 'Verplanungsübersicht', 4, '../lehre/check/verplanungsuebersicht.php', 'LV-Plan', NULL, NULL, NULL, '2011-04-01 10:51:53', 'oesi', '2011-04-01 11:15:20', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('Zeitwünsche', 'Zeitwünsche', 5, '../lehre/zeitwuensche.php', 'LV-Plan', NULL, NULL, NULL, '2011-04-01 10:52:37', 'oesi', '2011-04-01 11:15:27', 'oesi', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('AnzahlStudierende', 'Aktuell Studierende im Haus', 16, '../../cis/private/lvplan/stpl_week_anzahl_studenten.php', 'Studierende', NULL, NULL, NULL, '2011-04-01 11:11:52', 'oesi', '2012-02-20 19:09:16', 'kindlm', NULL, false, NULL); +INSERT INTO public.tbl_statistik VALUES ('ALVS-Statistik', 'ALVS-Statistik', 7, '../../content/statistik/alvsstatistik.php', 'Lehre', NULL, NULL, NULL, '2011-04-01 10:54:03', 'oesi', '2011-04-01 11:23:12', 'oesi', NULL, false, NULL); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/KontactCept.php b/tests/codeception/tests/api/v1/KontactCept.php index 6bf510ac8..7c0872cfd 100644 --- a/tests/codeception/tests/api/v1/KontactCept.php +++ b/tests/codeception/tests/api/v1/KontactCept.php @@ -1,11 +1,21 @@ wantTo('Test API call v1/person/kontakt/kontakt'); +$I->wantTo('Test API call v1/person/kontakt/ kontakt, KontaktByPersonID and KontaktByPersonIDKontaktTyp'); $I->amHttpAuthenticated("admin", "1q2w3"); $I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); $I->sendGET('v1/person/kontakt/kontakt', array('kontakt_id' => 1)); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/person/kontakt/KontaktByPersonID', array('person_id' => 3)); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/person/kontakt/KontaktByPersonIDKontaktTyp', array('person_id' => 3, 'kontakttyp' => 'email')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/NationCept.php b/tests/codeception/tests/api/v1/NationCept.php index e5b881030..c4693793e 100644 --- a/tests/codeception/tests/api/v1/NationCept.php +++ b/tests/codeception/tests/api/v1/NationCept.php @@ -1,10 +1,15 @@ wantTo('Test API call v1/codex/nation/All'); +$I->wantTo('Test API call v1/codex/nation/ nation and all'); $I->amHttpAuthenticated("admin", "1q2w3"); $I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); +$I->sendGET('v1/codex/nation/nation', array('nation_code' => 'A')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + $I->sendGET('v1/codex/nation/All'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); diff --git a/tests/codeception/tests/api/v1/OrgformCept.php b/tests/codeception/tests/api/v1/OrgformCept.php index 70cb5963e..7c9a7d2f5 100644 --- a/tests/codeception/tests/api/v1/OrgformCept.php +++ b/tests/codeception/tests/api/v1/OrgformCept.php @@ -1,7 +1,7 @@ wantTo('Test API call v1/codex/orgform Orgform and All'); +$I->wantTo('Test API call v1/codex/orgform Orgform, OrgformLV and All'); $I->amHttpAuthenticated("admin", "1q2w3"); $I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); @@ -13,4 +13,9 @@ $I->seeResponseContainsJson(['error' => 0]); $I->sendGET('v1/codex/orgform/All'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/codex/orgform/OrgformLV'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/PersonCept.php b/tests/codeception/tests/api/v1/PersonCept.php index 4b746a4c0..49ea26456 100644 --- a/tests/codeception/tests/api/v1/PersonCept.php +++ b/tests/codeception/tests/api/v1/PersonCept.php @@ -1,7 +1,7 @@ wantTo('Test API call v1/person/person/person'); +$I->wantTo('Test API call v1/person/person/ Person and CheckBewerbung'); $I->amHttpAuthenticated("admin", "1q2w3"); $I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); @@ -32,4 +32,9 @@ $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson([ 'person_id' => '5', - 'nachname' => 'Harvey']); \ No newline at end of file + 'nachname' => 'Harvey']); + +$I->sendGET('v1/person/person/CheckBewerbung', array('email' => 'mckenzie.vicenta@calva.dev', 'studiensemester_kurzbz' => 'WS2016')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/PreinteressentCept.php b/tests/codeception/tests/api/v1/PreinteressentCept.php index 3149da7ee..f17c75e52 100644 --- a/tests/codeception/tests/api/v1/PreinteressentCept.php +++ b/tests/codeception/tests/api/v1/PreinteressentCept.php @@ -10,7 +10,7 @@ $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); -$I->sendGET('v1/crm/preinteressent/PreinteressentByPersonID', array('person_id' => 1)); +$I->sendGET('v1/crm/preinteressent/PreinteressentByPersonID', array('person_id' => 3)); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/PrestudentCept.php b/tests/codeception/tests/api/v1/PrestudentCept.php index 1d718d33b..07343b933 100644 --- a/tests/codeception/tests/api/v1/PrestudentCept.php +++ b/tests/codeception/tests/api/v1/PrestudentCept.php @@ -10,7 +10,7 @@ $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); -$I->sendGET('v1/crm/prestudent/PrestudentByPersonID', array('person_id' => 1)); +$I->sendGET('v1/crm/prestudent/PrestudentByPersonID', array('person_id' => 3)); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/StatistiksCept.php b/tests/codeception/tests/api/v1/StatistiksCept.php new file mode 100644 index 000000000..110e642fd --- /dev/null +++ b/tests/codeception/tests/api/v1/StatistiksCept.php @@ -0,0 +1,21 @@ +wantTo('Test API call v1/organisation/statistik statistik, All and MenueArray'); +$I->amHttpAuthenticated("admin", "1q2w3"); +$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); + +$I->sendGET('v1/organisation/statistik/Statistik', array('statistik_kurzbz' => 'Stromanalyse')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/statistik/All'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/statistik/MenueArray'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file diff --git a/tests/codeception/tests/api/v1/StudiensemesterCept.php b/tests/codeception/tests/api/v1/StudiensemesterCept.php index 36e266786..91f760af1 100644 --- a/tests/codeception/tests/api/v1/StudiensemesterCept.php +++ b/tests/codeception/tests/api/v1/StudiensemesterCept.php @@ -1,7 +1,7 @@ wantTo('Test API call v1/organisation/studiensemester studiensemester and nextStudiensemester'); +$I->wantTo('Test API call to all v1/organisation/studiensemester methods'); $I->amHttpAuthenticated("admin", "1q2w3"); $I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org'); @@ -18,4 +18,64 @@ $I->seeResponseContainsJson(['error' => 0]); $I->sendGET('v1/organisation/studiensemester/NextStudiensemester', array('art' => 'WS')); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/All'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Akt'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/AktNext', array('semester' => '1')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/AktNext', array('semester' => '2')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/LastOrAktSemester'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/LastOrAktSemester', array('days' => '1024')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/NextFrom', array('studiensemester_kurzbz' => 'WS2015')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Previous'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Nearest', array('studiensemester_kurzbz' => 'WS2015')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Finished'); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Finished', array('limit' => '3')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); +$I->seeResponseContainsJson(['error' => 0]); + +$I->sendGET('v1/organisation/studiensemester/Timestamp', array('studiensemester_kurzbz' => 'WS2015')); +$I->seeResponseCodeIs(200); +$I->seeResponseIsJson(); $I->seeResponseContainsJson(['error' => 0]); \ No newline at end of file