Thanks for your reply, the controller code is :
function circuits()
{
if($this->auth->logged_in()==FALSE)
{
$redirect = site_url();
redirect($redirect, "refresh");
}
else
{
try{
$data=array();
$data['title']='Parcours';
$crud = new grocery_CRUD();
$crud->set_subject('Parcours');
$crud->set_table('circuits');
$crud->order_by('nom_circuit', 'asc');
$crud->columns('nom_circuit','total_kms','total_deniv', 'nb_fois', 'profil');
$crud->required_fields('nom_circuit','total_kms');
$crud->display_as('nom_circuit','Description parcours')
->display_as('total_kms','Nb kms')
->display_as('total_deniv','Dénivelé')
->display_as('nb_fois','Parcouru')
->display_as('profil','');
$crud->callback_column('nb_fois', array($this, '_parcouru_callback'));
$crud->callback_column('profil',array($this,'_profil_callback'));
$crud->add_action('Détailler Parcours', '', '','detail-icon',array($this,'_detail_callback'));
$output = $crud->render();
$this->_main_output($output, $data);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
}
function _parcouru_callback($value, $row)
{
$nbfois_an=$this->Circuits_model->count_sorties_an($row->id_circuit, date("Y"));
$nbfois_tot=$this->Circuits_model->count_sorties_tot($row->id_circuit);
$to_display=$nbfois_an.' fois sur '.$nbfois_tot;
return '<a href="'.site_url('main/sorties_circuit/'.$row->id_circuit).'" title="Voir les sorties effectuées">'.$to_display.'</a>';
}
function _profil_callback($value, $row)
{
if ($row->lien=='')
{
return '';
}
else
{
return '<a href="'.site_url('main/parcours_profil/'.$row->id_circuit).'" alt="Profil" title="Profil">'.'<img src="'.base_url().'assets/grocery_crud/themes/perso/css/images/profil.jpg">'.'</a>';
}
}
function _detail_callback($value, $row)
{
return site_url('main/detail_parcours').'/'.$row->id_circuit;
}
and the used tables are defined like this :
CREATE TABLE IF NOT EXISTS `circuits` (
id_circuit INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY
, nom_circuit VARCHAR(128) NOT NULL
, total_kms DECIMAL(4,1) NOT NULL
, total_deniv INT(4) NOT NULL
, lien VARCHAR(255)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `sorties` (
id_sortie INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY
, id_circuit INT(10) NOT NULL
, date_sortie DATE NOT NULL
, kms_sortie INT(3) NOT NULL
, temps_sortie TIME NOT NULL
, comments_sortie TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Thanks in advance for your help