mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-11 09:09:28 +00:00
Form Validation Notiz und Kontakt-Tab
This commit is contained in:
@@ -13,6 +13,7 @@ class Kontakt extends FHC_Controller
|
||||
// Load Libraries
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
@@ -44,10 +45,9 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
public function addNewAddress($person_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric');
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'callback_plz_required|callback_plz_numeric');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
@@ -115,10 +115,9 @@ class Kontakt extends FHC_Controller
|
||||
public function updateAddress($address_id)
|
||||
{
|
||||
$uid = getAuthUID();
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'required');
|
||||
$this->form_validation->set_rules('plz', 'PLZ', 'callback_plz_required|callback_plz_numeric');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
@@ -339,28 +338,18 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
public function addNewContact($person_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'valid_email');
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'callback_kontakt_valid_email');
|
||||
else
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required');
|
||||
|
||||
/* if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
|
||||
{
|
||||
$this->form_validation->set_data(['email' => $_POST['kontakt']]);
|
||||
$this->form_validation->set_rules('email', 'email', 'valid_email|required]');
|
||||
}*/
|
||||
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'callback_kontakt_required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
|
||||
if(isset($_POST['standort']))
|
||||
@@ -410,6 +399,16 @@ class Kontakt extends FHC_Controller
|
||||
return $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'callback_kontakt_valid_email');
|
||||
else
|
||||
$this->form_validation->set_rules('kontakt', 'Kontakt', 'callback_kontakt_required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
return $this->outputJsonError($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
if(isset($_POST['standort']))
|
||||
{
|
||||
$standort_id = $_POST['standort']['standort_id'];
|
||||
@@ -491,8 +490,8 @@ class Kontakt extends FHC_Controller
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'required');
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'required');
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'callback_iban_required');
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'callback_typ_required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
@@ -564,11 +563,10 @@ class Kontakt extends FHC_Controller
|
||||
|
||||
public function updateBankverbindung($bankverbindung_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
|
||||
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'required');
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'required');
|
||||
$this->form_validation->set_rules('iban', 'IBAN', 'callback_iban_required');
|
||||
$this->form_validation->set_rules('typ', 'TYP', 'callback_typ_required');
|
||||
|
||||
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
|
||||
|
||||
@@ -632,4 +630,76 @@ class Kontakt extends FHC_Controller
|
||||
}
|
||||
return $this->outputJsonSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function plz_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('plz_required', $this->p->t('ui','error_fieldRequired',['field' => 'PLZ']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function kontakt_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('kontakt_required', $this->p->t('ui','error_fieldRequired',['field' => 'Kontakt']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function iban_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('iban_required', $this->p->t('ui','error_fieldRequired',['field' => 'IBANoff']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function typ_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('typ_required', $this->p->t('ui','error_fieldRequired',['field' => 'Typ']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function plz_numeric($value)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
$this->form_validation->set_message('plz_numeric', $this->p->t('ui','error_fieldNotNumeric',['field' => 'PLZ']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function kontakt_valid_email($email)
|
||||
{
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->form_validation->set_message('kontakt_valid_email', $this->p->t('ui','error_fieldNoValidEmail',['field' => 'Kontakt']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ class Notiz extends FHC_Controller
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');
|
||||
$this->form_validation->set_rules('titel', 'titel', 'callback_titel_required');
|
||||
$this->form_validation->set_rules('text', 'text', 'callback_text_required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
@@ -208,8 +208,8 @@ class Notiz extends FHC_Controller
|
||||
}
|
||||
|
||||
//Form Validation
|
||||
$this->form_validation->set_rules('titel', 'titel', 'required');
|
||||
$this->form_validation->set_rules('text', 'Text', 'required');
|
||||
$this->form_validation->set_rules('titel', 'titel', 'callback_titel_required');
|
||||
$this->form_validation->set_rules('text', 'text', 'callback_text_required');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
@@ -438,4 +438,28 @@ class Notiz extends FHC_Controller
|
||||
}
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
public function titel_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('titel_required', $this->p->t('ui','error_fieldRequired',['field' => 'Titel']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function text_required($value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
$this->form_validation->set_message('text_required', $this->p->t('ui','error_fieldRequired',['field' => 'Text']));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22117,7 +22117,7 @@ array(
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'notiz',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'error_fieldRequired',
|
||||
'phrases' => array(
|
||||
array(
|
||||
@@ -22136,18 +22136,37 @@ array(
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'notiz',
|
||||
'phrase' => 'error_textFieldRequired',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'error_fieldNotNumeric',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Das Eingabefeld textField ist erforderlich',
|
||||
'text' => 'Das Eingabefeld {field} darf nur Zahlen enthalten.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'The Field textField is required',
|
||||
'text' => 'The Field {Field} must contain only numbers.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'error_fieldNoValidEmail',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Das Eingabefeld {field} muss eine gültige Email-Adresse enthalten.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'The field {field} must contain a valid email address.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user