Jump to content


jcanongia

Member Since 07 Jul 2016
Offline Last Active Jul 20 2016 12:44 PM
-----

Posts I've Made

In Topic: multiply two fields

20 July 2016 - 12:48 PM

Hi Amit!

I think I have solved that!

The column's name is passed whith md5, only the first 8 elements, plus "s".

Like user_id = s+e8701ad48ba05a91604e480dd60899a3 and  country_id=s+93bfec8a344ef19318d53f3e3b5b9bf0

 

Then I just use

        $crud->callback_column('username', array($this, '_callback_webpage_username'));
public function _callback_webpage_username($value, $row)
    {
        return '<a href="'.base_url("user/view_user/".$row->user_id).'">'.$row->se8701ad4.'</a>';
    }

Then the result is whith username.name and a link.

 

Thank you so much. Regards


In Topic: multiply two fields

07 July 2016 - 09:33 PM

I have this controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends CI_Controller {

	public function __construct()
	{
		parent::__construct();

		$this->load->database();
		$this->load->library(array('ion_auth','form_validation'));
		$this->load->helper(array('url','language','form'));
		$this->load->library('grocery_CRUD');

		$this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));

		$this->lang->load('auth');

	}

	public function index()
	{
		if (!$this->ion_auth->is_admin())
		{
			$this->session->set_flashdata('message', '<div class="alert alert-info" role="alert">You must be an admin to view this page</div>');
			redirect('/');
		}
		$crud = new grocery_CRUD();
		$crud->set_table('personals');
		$crud->set_subject('Pessoas');
		$crud->columns('nome','data_nascimento','nome_mae','nome_pai','estado_civil','sexo','regime_estado_civil','cpf','rg',
		'data_exp_rg','orgao_exp_rg','ctps_serie','ctps_numero','ci_inss_numero','pis_pasep','country_id','naturalidade_id','user');
		$crud->display_as('data_nascimento','Nascimento')->display_as('nome_mae','Nome Mãe')->display_as('nome_pai','Nome Pai')
		   ->display_as('regime_estado_civil','Reg Casamen')->display_as('data_exp_rg','Expira RG')->display_as('orgao_exp_rg','Orgão RG')
		   ->display_as('country_id','Nacionalidade')->display_as('naturalidade_id','Naturalidade')->display_as('user','Nome Usuar');
		$crud->set_relation('country_id','countries','nome');
		$crud->set_relation('user_id','users','{id}.{username}');
		$crud->callback_column('user', array($this, '_callback_webpage_url'));
		$output = $crud->render();

		$this->_example_output($output);
	}

	public function _callback_webpage_url($value, $row)
	{
		return '<a href="'.base_url("user_view/index/".$row->user_id).'">'.$row->user_id.'</a>';
	}

	function _example_output($output = null)
	   {
			$this->load->view('admin/template/header');
			$this->load->view('admin/dashboard',$output);
			$this->load->view('admin/template/footer');
	   }


}

This let me link users table by id in column user.

 

PrtSc%20Personals.jpg

That you can see in Nome Usuar column. But I need put in that column the username instead the user_id. How can I do that.

 

Sorry my english.