i have 2 tables called
faculty_list with fields id,fname,lname,middle
and
ftraining_log with with fields id,faculty_list_id(related to faculty_list), inclusive_period,inhouse ,outside
on my code below i have an view: see on my pic aatached:
the below code i can add more details on my faculty_list using my relation table ftraining_log
and that details will view one of my faculty_list by clicking faculty_list_id(related to faculty_list) dropdown.
example: on my attached image:
on my faculty_list table i have add_action called View, when you click that View button on one of my list
example, Cruz, Robert and you will go to ftraining_log view the code below, and when i click add
the image i attached thats the view:
now my question is how can i add ftarining_log details that belongs to cruz, robert without clicking
the dropdown faculty_list_id(related to faculty_list) or from the field Faculty Name.
-----------------------------------------------------------------------------------
function training_faculty($primary_key)
{
if (!$this->ion_auth->is_admin())
{
$this->session->set_flashdata('message', 'You must be an admin to view this page!!');
redirect('welcome/index');
}
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('ftraining_log');
$crud->set_subject('Training');
$crud->columns('inclusive_period','inhouse','outside','date_add');
$crud->set_relation('faculty_list_id','faculty_list','{lname},{fname}');
$crud->field_type('date_add','hidden');
$crud->display_as('faculty_list_id','Faculty Name');
$crud->display_as('inclusive_period','Inclusive Period');
$crud->display_as('inhouse','In-House');
$crud->display_as('outside','Outside');
$crud->display_as('date_add','Date Incoded');
$crud->required_fields('faculty_list_id');
$crud->callback_before_insert(array($this,'callback_ftraining'));
$crud-> where('faculty_list_id',$primary_key); // primary_key has the id from the faculty_cmt table
$data = $this->db->get_where('faculty_list',array('id'=>$primary_key))->row_array();
$output = $crud->render();
$output->output = '<div align="center"> <b>'."Below List". '</b></div>'.$output->output;
$output->output = '<h1><div align="center"> <b>'.$data['lname'] .", " .$data['fname'].'</b></div></h1>'.$output->output;
$this->load->view('admin/ftraining_log',$output);