Hi GCruders
I have this database
project: id,#customer_id
customer:id,#customer_group_id
customer_group:#id
customer_group_text: (#customer_group_id,#laguage_id ) composite primary key,description
I want to apply the GCRUD on the description from the customer_group_text
The main table is Project
here my controller
public function project_management()
{ $this->load->view('include/header.php');
$crud = new grocery_CRUD();
$crud->set_table('project');
$crud->set_subject('Project');
$crud->set_relation('customer_id', 'customer', 'name');
$crud->display_as('customer_id','Customer Name');
$crud->set_relation('manager_id', 'resource', 'first_name');
$crud->display_as('customer_id','Customer Name');
$crud->set_relation('project_status_id', 'project_status', 'id');
$crud->display_as('project_status_id','Status Identifier');
$crud->add_fields('description','manager name','customer_id','customer_group','project_status_id','project_status_text','redmine_id','change_date');
//$crud->callback_column('redmine_id',array($this,'_callback_redmine_url'));
$crud->callback_add_field('customer_group', array($this, 'add_field_callback_1'));
$crud->callback_before_insert(array($this, '_callback_before_insert'));
$output = $crud->render();
$this->_example_output($output);
}
function add_field_callback_1()
{
$html = '<script type="text/javascript">';
$html.= '$(document).ready(function() {';
$html.="$('#field-customer_id').change(function()
{
var val = $(this).val();
if(val!='')
{
$('#customer_group').removeAttr('disabled');
$('#customer_group').trigger('liszt:updated');
}});
});</script>";
$this->db->select('description');
$this->db->from('customer_group_text');
$this->db->join('customer_group', 'customer_group.id = customer_group_text.customer_group_id');
$this->db->join('customer', 'customer.customer_group_id=customer_group.id');
$query = $this->db->get();
$html.= '<select name="customer_group" id="customer_group" class="chosen-select" data-placeholder="Customer group " disabled="disabled">';
if ($result)
{
$html.='<option value=""></option>';
foreach ($result as $item)
{
$html.='<option value="' . $item['id'] . '">' . $item['inactive'] . '</option>';
}
};
$html.= '</select>';
return $html;
}
function _callback_before_insert($post_array)
{
if ($post_array['customer_group'])
{
$data = array('customer_group_id' => $post_array['customer_group']);
$this->db->update('customer', $data, array('id' => $post_array['customer_id']));
}
unset($post_array['customer_group']);
return $post_array;
}
----------------->
with the simple set_relation it works fine but adding these joins get many errors and a strange behaviours
Severity: Notice
Message: Undefined variable: result
Filename: controllers/main.php
Line Number: 78
hellllllllllllp please