I've any problems with my project. I like with this grocery..awesome, great...
but i have query left join in my tables. how i can insert data in other table with this condition??
function equipment_branch() { $crud = new grocery_CRUD(); $crud->set_model('my_grocery_model'); $crud->set_table('aj_alat'); $crud->columns('id_alat','kd_alat','nm_alat','cabang','tgl_berlaku'); $crud->unset_columns('id_alat'); $crud->display_as('kd_alat','Kode') ->display_as('nm_alat','Alat / Kendaraan') ->display_as('tgl_berlaku','Tgl Berlaku'); $crud->unset_add(); $crud->unset_delete(); $crud->unset_edit(); $crud->set_subject('Mutasi Alat / Kendaraan'); $crud->add_action('Lihat Riwayat', base_url().'assets/grocery_crud/themes/flexigrid/css/images/Insert-Element-32','your_controller/your_method'); $crud->add_action('Perbaharui', base_url().'assets/grocery_crud/themes/flexigrid/css/images/update', 'your_controller/your_method'); $output = $crud->render(); $this->template->load('template','admin/mutasi_alat',$output); }
This my_grocery_model :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class My_grocery_model extends grocery_CRUD_Model { function get_list() { if($this->table_name === null) return false; $select = "{$this->table_name}.*"; $select .= ", aj_mutasi_alat.*"; 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'"; } $this->db->select($select, false); $this->db->join('aj_mutasi_alat','aj_mutasi_alat.kd_alat_mutasi = '. $this->table_name . '.id_alat','left'); $results = $this->db->get($this->table_name)->result(); return $results; } } ?>
How i can make action button but insert into aj_mutasi_alat? not in aj_alat..?
your_controller/your_method?
Thanks advance..