I'm doing a proyect in Codeigniter. One of the views that I have requires to select a student and a account. The student and the account are in different views and controllers. I select the student successfully, and I fill some fields with the student information, but then I want to select the account and it fill the fields for the account, but the information for the student dissapears.
Here is the view that I'm working on:
<?php
/*******Information for the student ********/
$parametroExpediente = "";
$parametroNombre = "";
$parametroPrimerApellido = "";
$parametroSegundoApellido = "";
$parametroCedula = "";
if (isset($expediente))
{
$parametroExpediente = set_value('expediente', $expediente);
$parametroNombre = set_value('nombre', $nombre);
$parametroPrimerApellido = set_value('primerApellido', $primerApellido);
$parametroSegundoApellido = set_value('segundoApellido', $segundoApellido);
$parametroCedula = set_value('cedula', $cedula);
}
/************************************/
/*******Information for the account********/
$parametroIDPlan = "";
$parametroDescripcionPlan = "";
$parametroTotalAPagarPlan = "";
$parametroCuantosPagosPlan = "";
$parametroFrecuenciaPagoPlan = "";
$parametroAcivoPlan = "";
$parametroIDCursoPlan = "";
$parametroMultiGrupoPlan = "";
if (isset($idPlan))
{
$parametroIDPlan = set_value('idPlan', $idPlan);
$parametroDescripcionPlan = set_value('descripcion', $descripcion);
$parametroTotalAPagarPlan = set_value('totalApagar', $totalApagar);
$parametroCuantosPagosPlan = set_value('cuantosPagos', $cuantosPagos);
$parametroFrecuenciaPagoPlan = set_value('cadaCuantosDiasPaga', $cadaCuantosDiasPaga);
$parametroAcivoPlan = set_value('activo', $activo);
$parametroIDCursoPlan = set_value('idCurso', $idCurso);
$parametroMultiGrupoPlan = set_value('multiGrupo', $multiGrupo);
}
/************************************/
?>
<!--BUTTON TO SELECT A STUDENT -->
<a href="http://localhost/ProyectoNetbeans/CodeIgniter_2.1.3/index.php/Alumnos_controller/loadAlumnoView/seleccionarParaCuenta" class="btn btn-primary">Seleccionar alumno</a>
<span class="badge badge-info">Expediente: <?php echo $parametroExpediente ?></span>
<!---------------------------------->
<br/>
<br/>
<br/>
<!--BUTTON TO SELECT AN ACCOUNT -->
<a href="http://localhost/ProyectoNetbeans/CodeIgniter_2.1.3/index.php/PlanDePago_controller/loadPlanDePagoView/seleccionarParaCuenta/" class="btn btn-primary">Seleccionar plan de pago</a>
<span class="badge badge-info">Plan escogido: <?php echo $parametroDescripcionPlan ?></span>
When the student and the account are selected, they both redirect their information to the same controller, which is the following:
<?php
class Cuentas_controller extends CI_Controller {
public $data = array();
public function __construct()
{
parent::__construct();
// Your own constructor code
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('url');
$this->load->model('Alumnos_model');
$this->load->model('PlanDePago_model');
}
function index()
{
$this->load->view('cuentas_view');
}
/*Take the information for the student*/
function setStudent($elExpediente)
{
$query = $this->Alumnos_model->getAllData($elExpediente);
foreach ($query->result_array() as $row)
{
$this->data = array(
//'expediente' => $row['expediente'],
'expediente' => $elExpediente,
'primerApellido' => $row['primerApellido'],
'segundoApellido' => $row['segundoApellido'],
'nombre' => $row['nombre'],
'cedula' => $row['cedula']
);
}
$this->load->view('cuentas_view',$this->data);
}
/*Take the information for the account*/
function setAccount($id)
{
$query = $this->PlanDePago_model->getAllDataNoParameters($id);
foreach ($query->result_array() as $row)
{
$this->data = array(
'idPlan' => $id,
'totalApagar' => $row['totalApagar'],
'descripcion' => $row['descripcion'],
'cuantosPagos' => $row['cuantosPagos'],
'cadaCuantosDiasPaga' => $row['cadaCuantosDiasPaga'],
'activo' => $row['activo'],
'idCurso' => $row['idCurso'],
'multiGrupo' => $row['multiGrupo']
);
}
$this->load->view('cuentas_view',$this->data);
}
}
?>
As you can see, the setStudent and setAccount methods take the information sent by those views, and then open the view that I'm working on and fill some information, but it's not working as expected, the first that I selected dissapears when I select the second one.
Some suggestion to get this working? I want both student and account showing information when I select them.