[eluser]jeremy95[/eluser]
I have the following view file:
Code:
$this->table->set_heading('Date', 'Start', 'Stop', 'Break', 'Total', ' ');
foreach ($workdays->result() as $workday) :
$total = $workday->stop - $workday->start - $workday->break;
$this->table->add_row(
$workday->date,
$workday->start,
$workday->stop,
$workday->break,
$total,
anchor("workdays/form/$workday->workday_id", 'Edit'),
anchor("workdays/delete/$workday->workday_id", 'Remove')
);
endforeach;
echo $this->table->generate();
?>
As you see, there is a very simple calculation for the total of hours on a workday. But say I would have a lot more calculations, isn't it then a better practise to do those in de controller file?
And if so, how should I do that? Should I generate the table in the controller and only
Code:
echo $this->table->generate();
in the view file? Or should I loop throught the recordset twice, like once in the controller to do the math, and then again in de view to generate the table?
Thanks in advance,
Jeremy