PHP Fatal error: Uncaught Error: Call to undefined method CouncilsFormular :: data ()

1

I would like to know what could be, it happens that maybe I have about 3 or 4 forms made in the same way, with the "data" method always declared in the same way $data = $this->data(); but just in this form it does not work and it throws 500 error "this page does not work".

If someone can help me by declaring the method or solving this error, I will be very grateful.

I already searched for all the existing posts about this error and none of them makes it clear to me what I should do.

I detail the error:

  

PHP Fatal error: Uncaught Error: Call to undefined method CouncilorsForm: data () in /var/www/html/sam/sys/application/controllers/concejalesFormulario.php:21\nStack trace: \ n # 0 / var / www / html / cisystem / 214 / system / core / CodeIgniter.php (359): Councilors Form-> index () \ n # 1 /var/www/html/sam/sys/index.php(202): require_once ('/ var / www / html / c ...') \ n # 2 {main} \ n thrown in /var/www/html/sam/sys/application/controllers/concejalesFormulario.php on line 21

Here is my controller:     

if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}

class ConcejalesFormulario extends CI_Controller {

function __construct() {
    parent::__construct();
    $this->load->helper(array('url'));
    $this->load->model('concejales', TRUE);
    $this->load->library(array('session'));
    $this->load->library(array('Bouncer', 'Manager', 'Validate'));
    $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0", "Pragma: no-cache");
    $this->output->set_header("Pragma: no-cache");
}

function index($success = NULL) {
    $this->bouncer->allower();
    $data = $this->data();  //se supone que el error es aquí//
    $views = array(
        array('view' => 'templates/bannerProfile', 'data' => $data),
        array('view' => 'modulos/concejales/header', 'data' => $data),
        array('view' => 'modulos/concejales/concejalesRegistrados', 'data' => $data),
        array('view' => 'modulos/concejales/formularioConcejales', 'data' => $data),
    );
    if ($success == 'success') {
        array_unshift($views, array('view' => 'popup/alerta', 'data' => $this->alert(TRUE)));
    }
    $this->manager->layout($views);
}

public function registrarConcejales() {
    $sasession = $this->session->userdata('sasession');
    $id_municipio = $sasession['id_municipio'];
    $data = $this->input->post();

    if ($this->validarRegistro($data)) {
        $dataConcejales = array('nombrecomp' => $data['nombrecomp'], 'partidopol' => $data['partidopol'], 'emailconc' => $data['emailconc'], 'telefonoconc' => $data['telefonoconc']);
        if ($this->concejales->registrar($data)) {
            echo 'ok';
        } else {
            $this->systemError();
        }
    } else {
        $alertdata = $this->alert(FALSE, 'Uno o varios valores indicados no son v&aacute;lidos.<br/>No se guardaron los cambios. Intentalo nuevamente.');
        $this->load->view('popup/alerta', $alertdata);
    }
}

private function validarRegistro($data) {
    if (!($this->validate->isAlpha($data['nombrecomp']) and $data['partidopol'] !='' and $data['emailconc'] != '' and $data['telefonoconc'] != NULL)) {
        return FALSE;
    }
    return TRUE;
    }

 }

Here my model:

    <?php

Class Concejales extends CI_Model {

function __construct() {
    $this->load->library(array('snippets'));
    $this->load->model('registro', '', TRUE);
}

function registrar($id_municipio, $data) {
    $portal_web_db = $this->load->database('dnc_sys', TRUE);

    $portal_web_db->where('id_municipio', $id_municipio);
    $portal_web_db->update('concejales', $data);

    $dataRegistro['id_municipio'] = $id_municipio;
    $dataRegistro['id_accion'] = 5;
    $dataRegistro['tabla'] = 'concejales';
    $dataRegistro['descripcion'] = "Actualización del número de empleados";
    $this->registro->registrar($dataRegistro);

    return $portal_web_db->affected_rows() ? TRUE : FALSE;
}

function comprobacion($id_municipio) {
    $dnc_sys_db = $this->load->database('dnc_sys', TRUE);

    $dnc_sys_db->select('nombrecomp, partidopol, emailconc, telefonoconc');
    $dnc_sys_db->from('concejales');
    $dnc_sys_db->where('id_municipio', $id_municipio);
    $dnc_sys_db->limit(1);
    $query = $dnc_sys_db->get();
    //$numero = FALSE;
    return $query->num_rows() >= 1 ? TRUE : FALSE;
}
}

Hello in response to your comments, (I clarify that I asked the question, and did not let me appropriate it at the time of registration, so I publicly answered this, I also clarified that I am using CodeIgniter 1.0) I did not find the definition of the method in CI_controller if not in the Manager, here I present them:

class Manager {

private $ci;

function __construct() {
    $this->ci = & get_instance();
    $this->ci->load->model('info_usuarios', '', TRUE);
    $this->ci->load->model('municipios', '', TRUE);
    $this->ci->load->model('participantes', '', TRUE);
    $this->ci->load->model('solicitantes', '', TRUE);
    $this->ci->load->model('concejales', '', TRUE);
    $this->ci->load->model('planes_capacitacion', '', TRUE);
    $this->ci->load->library(array('form_validation'));
    $this->ci->load->library(array('Bouncer', 'FormatTime', 'Manager', 'TextHandle', 'FilesHandle'));
}

function layout($views) {
    $this->ci->bouncer->allower();
    $data = $this->data();
    $mdata = array(
        'views' => $views,
        'data' => $data
    );
    $this->ci->load->view('templates/header', $data);
    $this->ci->load->view('templates/navbar');
    $this->ci->load->view('templates/layout', $mdata);
    $this->ci->load->view('templates/footer', $data);
}

function data() {
    $sasession = $this->ci->session->userdata('sasession');
    $id_usuario = $sasession['id_municipio'];
    $info_usuario = $this->ci->info_usuarios->info($id_usuario);
    $estadoMunicipio = $this->ci->municipios->comprobacion($id_usuario);
    $estadoParticipantes = $this->ci->participantes->comprobacion($id_usuario);
    $estadoPlanes = $this->ci->planes_capacitacion->comprobacion($id_usuario);
    $n_empleados_capacitados = count($this->ci->solicitantes->info('id_solicitante', array('id_municipio' => $sasession['id_municipio'])));

    $data = array(
        'title' => ucfirst('SAM'),
        'info_usuario' => $info_usuario[0],
        'estadoMunicipio' => $estadoMunicipio,
        'estadoParticipantes' => $estadoParticipantes,
        'estadoPlanes' => $estadoPlanes,
        'estado' => (($estadoMunicipio ? 1 : 0) * .33 + ($estadoPlanes ? 1 : 0) * .34 + ($estadoParticipantes ? 1 : 0) * .33) * 100,
        'n_empleados_capacitados' => $n_empleados_capacitados
    );

    $data['format_time'] = & $this->ci->formattime;
    $data['text'] = & $this->ci->texthandle;
    return $data;
   }
}
    
asked by Brown 29.08.2018 в 21:54
source

0 answers