Hey guys I have somewhat of a sticky situation here that I can't seem
to wrap my hands around.
Here's the situation: At my job we've created a point of sale system
that the employees of the shops keep making mistakes at.
I am trying to create a a very simple application where we keep track
of the mistakes every employee make so we can make a bonus/punishment
system.
Here's where I'm stuck: I need to count the mistakes per employee and
display them(this should be done in the loop ofc).
My tables:
employees
mistakes
shops
The employee table only has the names of the employees and their
bonus.
The mistake table consists of the following:
id, date, description, employee_id, shop_id
My employee model:
function getMistakes($employee){
$total = $this->Mistake->find('count', array('conditions' => array(
'Mistake.employee_id' => '2')));
return $total;
}
My employee controller:
function index(){
$this->set('employees', $this->Employee->find('all'));
$this->set('employees', $this->paginate('Employee'));
$total = $this->Employee->getMistakes($employee);
$this->set('total_mistakes',$total);
}
In my index.ctp the loop will go through each row in my employee table
and display the rows.
I don't know how to achieve to count the mistakes WHERE
Mistake.empoyee_id == employee.id in my index.ctp
Can anyone please help me?
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=.