⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


rolo2012

Member Since 27 Apr 2012
Offline Last Active Oct 08 2012 01:09 PM
-----

Posts I've Made

In Topic: Custom search box

25 September 2012 - 03:40 PM

I figure out this, my code is:
$("#search_text").val("The filter");
$("#search_field").val("");
$("#crud_search").trigger("click")

where in $("#search_text").val("The filter");  I set the value of the top search box
If exist a better solution I apreciate

In Topic: Suport for sqlite3

05 July 2012 - 06:56 PM

I used the driver for sqlite3 in codeigniter in this link http://codeigniter.com/wiki/SQLite3/

In Topic: SQLite ?

05 July 2012 - 06:48 PM

I made this model for sqlite3
http://www.grocerycr...rt-for-sqlite3/

In Topic: double table within one view

10 May 2012 - 01:40 PM

try with iframes.

In Topic: set_relation 4th parameter

08 May 2012 - 03:06 PM

I do it extending the model in the get_list I just copy the method and add some lines, line for get the unique name that asign the grocery crud in the join $vehiculo_fieldname=$unique_field_name;   $vehiculo_joinname=$unique_join_name; and a where clause
$this->db->where("$vehiculo_joinname.grupo_trabajo",$this->grupo_trabajo);

And in the update and delete preforms some checks that only can operate in a grupo_trabajo (group_id its strores in seccion)

<?php
// application/models/grocery_crud_vehiculo_model.php
class grocery_crud_vehiculo_model  extends grocery_CRUD_Model  {
	protected $grupo_trabajo=-1;
  
	function __construct()
	{
		$ci=&get_instance();
		$this->grupo_trabajo=$ci->session->userdata('grupo_trabajo');
		parent::__construct();
	}
  
  
	function get_list()
	{
	 if($this->table_name === null)
	  return false;
	
	 $select = "{$this->table_name}.*";	
		$vehiculo_fieldname='';
		$vehiculo_joinname='';
	  
	 if(!empty($this->relation))
	  foreach($this->relation as $relation)
	  {
	   list($field_name , $related_table , $related_field_title) = $relation;					  
	   $unique_join_name = $this->_unique_join_name($field_name);
	   $unique_field_name = $this->_unique_field_name($field_name);
	  
   if(strstr($related_field_title,'{'))
		$select .= ", CONCAT('".str_replace(array('{','}'),array("',COALESCE({$unique_join_name}.",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $unique_field_name";
	   else	  
		$select .= ", $unique_join_name.$related_field_title as $unique_field_name";
	  
	   if($this->field_exists($related_field_title))
		$select .= ", {$this->table_name}.$related_field_title as '{$this->table_name}.$related_field_title'";
					if($related_table=='vehiculo'){
						$vehiculo_fieldname=$unique_field_name;
						$vehiculo_joinname=$unique_join_name;
					}
	  }
	 $this->db->select($select, false);	
	  
		$this->db->where("$vehiculo_joinname.grupo_trabajo",$this->grupo_trabajo);
	 $results = $this->db->get($this->table_name)->result();
	 //echo $this->db->last_query();
		//echo "$vehiculo_fieldname $vehiculo_joinname";
	 return $results;
	}
  
 
	function db_update($post_array, $primary_key_value)
	{	  
		$primary_key_field = $this->get_primary_key();
		$this->db->from($this->table_name);
		$this->db->join('vehiculo',"vehiculo.id={$this->table_name}.vehiculo");
		$this->db->where($this->table_name.".".$primary_key_field,$primary_key_value);
		$this->db->where('vehiculo.grupo_trabajo',$this->grupo_trabajo);
		if($this->db->count_all_results()<=0)return false;
		$this->db->from('vehiculo');	  
		$this->db->where('grupo_trabajo',$this->grupo_trabajo);
		$this->db->where('vehiculo.id',$post_array['vehiculo']);	  
		if($this->db->count_all_results()<=0)return false;
	  
		return parent::db_update($post_array, $primary_key_value);
	}  
  
	function db_insert($post_array)
	{
		$this->db->from('vehiculo');	  
		$this->db->where('grupo_trabajo',$this->grupo_trabajo);
		$this->db->where('vehiculo.id',$post_array['vehiculo']);	  
		if($this->db->count_all_results()<=0){				
			return false;				
		}
		return parent::db_insert($post_array);	  
	}
  
	function db_delete($primary_key_value)
	{
		$primary_key_field = $this->get_primary_key();
		$this->db->from($this->table_name);
		$this->db->join('vehiculo',"vehiculo.id={$this->table_name}.vehiculo");
		$this->db->where($this->table_name.".".$primary_key_field,$primary_key_value);
		$this->db->where('vehiculo.grupo_trabajo',$this->grupo_trabajo);
		if($this->db->count_all_results()<=0){	
			//echo $this->db->last_query();
			return false;				
		}
	  
		return parent::db_delete($primary_key_value);
	}

}
In the controller i use:
$this->grocery_crud->set_model('grocery_crud_vehiculo_model');
				$this->grocery_crud
				 ->set_relation('vehiculo','vehiculo','matricula',
						 array("vehiculo.grupo_trabajo"=>$this->session->userdata('grupo_trabajo')));
The 4th parameter only restrict the add/edit combo

It's work fine for me.
I have 2 tables
The table vehiculo has a  grupo_trabajo_id  and only operate in the group that i set.
And supplies that have a vehicle_id
The code has some spanish words tell me if you don't understand.
I hope to be useful