From 1cb637cb7f7ea3ffac32f0e8d3c2872fbcb14c21 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Fri, 1 Aug 2025 10:55:11 +0200 Subject: [PATCH] Tab Betriebsmittel: change type kaution to text, edit validations and add translations --- .../v1/betriebsmittel/BetriebsmittelP.php | 35 +++++++++++++------ .../Betriebsmittel/Betriebsmittel.js | 9 +---- system/phrasesupdate.php | 24 +++++++++++-- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php index 4405952a4..05d7c66c2 100644 --- a/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php +++ b/application/controllers/api/frontend/v1/betriebsmittel/BetriebsmittelP.php @@ -75,8 +75,9 @@ class BetriebsmittelP extends FHCAPI_Controller 'required' => $this->p->t('ui', 'error_fieldRequired') ]); - $this->form_validation->set_rules('kaution', 'Kaution', 'numeric|less_than_equal_to[9999.99]', [ - 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric') + $this->form_validation->set_rules('kaution', 'Kaution', 'callback_valid_number|callback_not_less_than_equal', [ + 'valid_number' => $this->p->t('ui', 'error_fieldNoValidNumber'), + 'not_less_than_equal' => $this->p->t('ui', 'error_fieldLessThan1000'), ]); $this->form_validation->set_rules('ausgegebenam', 'Ausgegeben am', 'required|is_valid_date', [ @@ -159,10 +160,6 @@ class BetriebsmittelP extends FHCAPI_Controller 'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson') ]); - $this->form_validation->set_rules('kaution', 'Kaution', 'numeric', [ - 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Kaution']) - ]); - $this->validateNewOrUpdate(); $betriebsmitteltyp = $this->input->post('betriebsmitteltyp'); @@ -172,6 +169,7 @@ class BetriebsmittelP extends FHCAPI_Controller $betriebsmittel_id = $this->input->post('betriebsmittel_id'); $anmerkung = $this->input->post('anmerkung'); $kaution = $this->input->post('kaution'); + if($kaution) $kaution = str_replace(',', '.', $kaution); $ausgegebenam = $this->input->post('ausgegebenam'); $retouram = $this->input->post('retouram'); $uid = $this->input->post('uid'); @@ -246,10 +244,6 @@ class BetriebsmittelP extends FHCAPI_Controller public function updateBetriebsmittel($betriebsmittelperson_id) { - $this->form_validation->set_rules('kaution', 'Kaution', 'numeric', [ - 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Kaution']) - ]); - $this->validateNewOrUpdate(); $betriebsmitteltyp = $this->input->post('betriebsmitteltyp'); @@ -259,6 +253,7 @@ class BetriebsmittelP extends FHCAPI_Controller $betriebsmittel_id = $this->input->post('betriebsmittel_id'); $anmerkung = $this->input->post('anmerkung'); $kaution = $this->input->post('kaution'); + if($kaution) $kaution = str_replace(',', '.', $kaution); $ausgegebenam = $this->input->post('ausgegebenam'); $retouram = $this->input->post('retouram'); @@ -391,6 +386,26 @@ class BetriebsmittelP extends FHCAPI_Controller $this->terminateWithSuccess($data); } + + public function valid_number($number) + { + if(is_null($number)) return true; + $number = str_replace(',', '.', $number); + if (!is_numeric($number)) + { + return false; + } + return true; + } + + public function not_less_than_equal($number) + { + $number = str_replace(',', '.', $number); + if ($number < 1000) + return true; + return false; + + } } diff --git a/public/js/components/Betriebsmittel/Betriebsmittel.js b/public/js/components/Betriebsmittel/Betriebsmittel.js index 502ede059..6d976a1fa 100644 --- a/public/js/components/Betriebsmittel/Betriebsmittel.js +++ b/public/js/components/Betriebsmittel/Betriebsmittel.js @@ -290,12 +290,6 @@ export default { this.formData.anmerkung = null; this.formData.beschreibung = null; this.statusNew = true; - }, - //helper function: workaround to trigger validation if input is not a number - normalizeKaution() { - if (this.formData.kaution === null || this.formData.kaution === '') { - this.formData.kaution = 'xxx' - } } }, created() { @@ -406,10 +400,9 @@ export default {
diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 5ca44148d..b3af0d059 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -44600,12 +44600,12 @@ and represent the current state of research on the topic. The prescribed citatio array( 'app' => 'core', 'category' => 'ui', - 'phrase' => 'error_fieldLessThan10000', + 'phrase' => 'error_fieldLessThan1000', 'insertvon' => 'system', 'phrases' => array( array( 'sprache' => 'German', - 'text' => 'Das Eingabefeld {field} darf maximal 4-stellig sein.', + 'text' => 'Das Eingabefeld {field} muss kleiner als 1000 sein.', 'description' => '', 'insertvon' => 'system' ), @@ -44617,6 +44617,26 @@ and represent the current state of research on the topic. The prescribed citatio ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'error_fieldNoValidNumber', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Das Eingabefeld {field} muss eine gültige Zahl sein', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'The Input Field {field} has to be a valid number', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), // FHC-4 Finetuning END );