10-13-2008, 04:47 PM
[eluser]blasto333[/eluser]
In a program I am writing, I have a module for adding, updating, deleting, and viewing customers. In my customer model, I created a function get_manage_table, that creates an html table and returns as a string.
The result of this function is then passed into a view from my controller and outputted. Is this the way to go?
In a program I am writing, I have a module for adding, updating, deleting, and viewing customers. In my customer model, I created a function get_manage_table, that creates an html table and returns as a string.
The result of this function is then passed into a view from my controller and outputted. Is this the way to go?
Code:
function get_manage_table($customers)
{
$this->table->set_template(get_sortable_table_template());
$this->table->set_heading('<input type="checkbox" id="select_all" />',
$this->lang->line('common_last_name'),
$this->lang->line('common_first_name'),
$this->lang->line('common_email'),
$this->lang->line('common_phone_number'),
' ');
foreach($customers as $customer)
{
$checkbox = "<input type='checkbox' id='customer_$customer->id' value='$customer->id'/>";
$this->table->add_row($checkbox,$customer->first_name,$customer->last_name,
$customer->email,$customer->phone_number,
anchor("customer/edit/$customer->id", $this->lang->line('common_edit'),array('class'=>'thickbox')));
}
$output = $this->table->generate();
$this->table->clear();
return $output;
}