From 09c02b0906d4f9c5b5a949f52c2868aeeabaf156 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Mon, 15 Jan 2024 15:29:04 +0100 Subject: [PATCH] refactoring controllers, codesniffer --- .../controllers/components/stv/Kontakt.php | 117 ++++++------------ .../controllers/components/stv/Notiz.php | 78 +----------- 2 files changed, 46 insertions(+), 149 deletions(-) diff --git a/application/controllers/components/stv/Kontakt.php b/application/controllers/components/stv/Kontakt.php index 5ed9bc9ef..d8ed352f6 100644 --- a/application/controllers/components/stv/Kontakt.php +++ b/application/controllers/components/stv/Kontakt.php @@ -42,7 +42,6 @@ class Kontakt extends FHC_Controller } } - //old version public function addNewAddress($person_id) { $this->load->library('form_validation'); @@ -58,6 +57,16 @@ class Kontakt extends FHC_Controller $this->load->model('person/Adresse_model', 'AdresseModel'); $uid = getAuthUID(); +/* $person_id = $this->input->post('$person_id'); + $co_name = $this->input->post('co_name'); + $strasse = $this->input->post('strasse'); + $ort = $this->input->post('ort'); + $gemeinde = $this->input->post('gemeinde'); + $nation = $this->input->post('nation'); + $name = $this->input->post('name'); + $typ = $this->input->post('typ'); + $anmerkung = $this->input->post('anmerkung');*/ + $co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null; $strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null; $ort = isset($_POST['ort']) ? $_POST['ort'] : null; @@ -98,68 +107,11 @@ class Kontakt extends FHC_Controller if (isError($result)) { $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson($result); + return $this->outputJson(getError($result)); } return $this->outputJsonSuccess(true); } - //Version mit input->post() TODO(Manu) check mit Chris, not working -/* public function addNewAddress($person_id) - { - $this->load->library('form_validation'); - //$_POST = json_decode($this->input->raw_input_stream, true); - - - $this->load->model('person/Adresse_model', 'AdresseModel'); - - $uid = getAuthUID(); - - $data = [ - 'insertvon' => $uid, - 'insertamum' => date('c'), - 'plz' => $this->input->post('plz'), - 'heimatadresse' => $this->input->post('heimatadresse'), - 'zustelladresse' => $this->input->post('zustelladresse'), - 'rechnungsadresse' => $this->input->post('rechnungsadresse') - ]; - - - $this->form_validation->set_rules('plz', 'PLZ', 'required|numeric'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - - if ($this->input->post('co_name')) - $data['co_name'] = $this->input->post('co_name'); - if ($this->input->post('strasse')) - $data['strasse'] = $this->input->post('strasse'); - if ($this->input->post('ort')) - $data['ort'] = $this->input->post('ort'); - if ($this->input->post('gemeinde')) - $data['gemeinde'] = $this->input->post('gemeinde'); - if ($this->input->post('nation')) - $data['nation'] = $this->input->post('nation'); - if ($this->input->post('name')) - $data['name'] = $this->input->post('name'); - if ($this->input->post('typ')) - $data['typ'] = $this->input->post('typ'); - if ($this->input->post('anmerkung')) - $data['anmerkung'] = $this->input->post('anmerkung'); - if ($this->input->post('firma')) - $data['firma_id'] = $this->input->post('firma_id'); - - $result = $this->AdresseModel->insert($data); - if (isError($result)) - { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson($result); - } - return $this->outputJsonSuccess(true); - }*/ - public function updateAddress($address_id) { $uid = getAuthUID(); @@ -187,6 +139,8 @@ class Kontakt extends FHC_Controller else $firma_id = null; + + $person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null; $co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null; $strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null; @@ -197,6 +151,16 @@ class Kontakt extends FHC_Controller $typ = isset($_POST['typ']) ? $_POST['typ'] : null; $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; +/* $person_id = $this->input->post('$person_id'); + $co_name = $this->input->post('co_name'); + $strasse = $this->input->post('strasse'); + $ort = $this->input->post('ort'); + $gemeinde = $this->input->post('gemeinde'); + $nation = $this->input->post('nation'); + $name = $this->input->post('name'); + $typ = $this->input->post('typ'); + $anmerkung = $this->input->post('anmerkung');*/ + $result = $this->AdresseModel->update( [ 'adresse_id' => $address_id @@ -407,10 +371,11 @@ class Kontakt extends FHC_Controller $standort_id = null; $uid = getAuthUID(); - $kontakttyp = isset($_POST['kontakttyp']) ? $_POST['kontakttyp'] : null; - $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; - $kontakt = isset($_POST['kontakt']) ? $_POST['kontakt'] : null; - $ext_id = isset($_POST['ext_id']) ? $_POST['ext_id'] : null; + + $kontakttyp = $this->input->post('kontakttyp'); + $anmerkung = $this->input->post('anmerkung'); + $kontakt = $this->input->post('kontakt'); + $ext_id = $this->input->post('ext_id'); $result = $this->KontaktModel->insert( [ @@ -453,11 +418,11 @@ class Kontakt extends FHC_Controller $standort_id = null; $uid = getAuthUID(); - $kontakttyp = isset($_POST['kontakttyp']) ? $_POST['kontakttyp'] : null; - $anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null; - $kontakt = isset($_POST['kontakt']) ? $_POST['kontakt'] : null; - $ext_id = isset($_POST['ext_id']) ? $_POST['ext_id'] : null; - $person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null; + $kontakttyp = $this->input->post('kontakttyp'); + $anmerkung = $this->input->post('anmerkung'); + $kontakt = $this->input->post('kontakt'); + $ext_id = $this->input->post('ext_id'); + $person_id = $this->input->post('person_id'); $result = $this->KontaktModel->update( [ @@ -536,14 +501,14 @@ class Kontakt extends FHC_Controller $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); - $ext_id = isset($_POST['ext_id']) ? $_POST['ext_id'] : null; - $oe_kurzbz = isset($_POST['oe_kurzbz']) ? $_POST['oe_kurzbz'] : null; - $orgform_kurzbz = isset($_POST['orgform_kurzbz']) ? $_POST['orgform_kurzbz'] : null; - $name = isset($_POST['name']) ? $_POST['name'] : null; - $anschrift = isset($_POST['anschrift']) ? $_POST['anschrift'] : null; - $bic = isset($_POST['bic']) ? $_POST['bic'] : null; - $blz = isset($_POST['blz']) ? $_POST['blz'] : null; - $kontonr = isset($_POST['kontonr']) ? $_POST['kontonr'] : null; + $ext_id = $this->input->post('ext_id'); + $oe_kurzbz = $this->input->post('oe_kurzbz'); + $orgform_kurzbz = $this->input->post('orgform_kurzbz'); + $name = $this->input->post('name'); + $anschrift = $this->input->post('anschrift'); + $bic = $this->input->post('bic'); + $blz = $this->input->post('blz '); + $kontonr = $this->input->post('kontonr'); $result = $this->BankverbindungModel->insert( [ diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/components/stv/Notiz.php index 2356f8bf1..36504d77d 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/components/stv/Notiz.php @@ -25,16 +25,8 @@ class Notiz extends FHC_Controller $this->load->library('AuthLib'); $this->load->library('VariableLib', ['uid' => getAuthUID()]); $result = getAuthUid(); + $this->outputJsonError($result); - - // $this->outputJson(getData($result)); - -/* if (isError($result)) { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - $this->outputJson(getError($result)); - } else { - $this->outputJson($result); - }*/ } public function getNotizen($person_id) @@ -163,64 +155,6 @@ class Notiz extends FHC_Controller return $this->outputJsonSuccess(true); } - public function updateNotizOldVersion($notiz_id) - { - $uid = getAuthUID(); - $this->load->library('form_validation'); - //$_POST = json_decode($this->input->raw_input_stream, true); - - $this->form_validation->set_rules('titel', 'titel', 'required'); - $this->form_validation->set_rules('text', 'Text', 'required'); - - if ($this->form_validation->run() == false) - { - return $this->outputJsonError($this->form_validation->error_array()); - } - - $this->load->model('person/Notiz_model', 'NotizModel'); - - if(!$notiz_id) - { - return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - } - - // $person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null; - $uid = getAuthUID(); - $titel = isset($_POST['titel']) ? $_POST['titel'] : null; - $text = isset($_POST['text']) ? $_POST['text'] : null; - $verfasser_uid = isset($_POST['verfasser_uid']) ? $_POST['verfasser_uid'] : null; - $bearbeiter_uid = $uid; - $erledigt = $_POST['erledigt']; - $start = $this->input->post(date('von')); - $ende = $this->input->post(date('bis')); - - - - $result = $this->NotizModel->update( - [ - 'notiz_id' => $notiz_id - ], - [ - 'titel' => $titel, - 'updatevon' => $uid, - 'updateamum' => date('c'), - 'text' => $text, - 'verfasser_uid' => $verfasser_uid, - 'bearbeiter_uid' => $bearbeiter_uid, - 'start' => $start, - 'ende' => $ende, - 'erledigt' => $erledigt - ] - ); - - if (isError($result)) - { - $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); - return $this->outputJson(getError($result)); - } - return $this->outputJsonSuccess(true); - } - public function updateNotiz($notiz_id) { $this->load->model('person/Notiz_model', 'NotizModel'); @@ -315,7 +249,7 @@ class Notiz extends FHC_Controller return $this->outputJsonSuccess(true); } - public function deleteNotiz ($notiz_id) + public function deleteNotiz($notiz_id) { //dms_id auslesen aus notizdokument wenn vorhanden $dms_id_arr = []; @@ -331,7 +265,6 @@ class Notiz extends FHC_Controller elseif (!hasData($result)) { $this->outputJson($result); - //$dms_id_arr = []; } else { @@ -387,8 +320,8 @@ class Notiz extends FHC_Controller $this->NotizModel->addSelect('campus.tbl_dms_version.*'); - $this->NotizModel->addJoin('public.tbl_notiz_dokument','ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)'); - $this->NotizModel->addJoin('campus.tbl_dms_version','ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)'); + $this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)'); + $this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)'); $result = $this->NotizModel->loadWhere( array('public.tbl_notiz.notiz_id' => $notiz_id) @@ -417,5 +350,4 @@ class Notiz extends FHC_Controller } $this->outputJson($result); } - -} \ No newline at end of file +}