Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
Fixed problem with ignored missing time log entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Haberkern authored and Timo Haberkern committed Aug 3, 2012
1 parent 95531aa commit 5f1925e
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions lib/model/doctrine/TimeLogItemTable.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function prepareTotalReport($filter, Doctrine_Collection $projects, $user
->execute(); ->execute();


$project_totals = array(); $project_totals = array();
foreach ($result as $project) { foreach ($result as $project) {
$project_totals[$project->id]['project'] = $project; $project_totals[$project->id]['project'] = $project;
foreach ($project->TimeLogItems as $time_item) { foreach ($project->TimeLogItems as $time_item) {
$project_totals[$project->id]['items'][$time_item->user_id]['user'] = $time_item->User; $project_totals[$project->id]['items'][$time_item->user_id]['user'] = $time_item->User;
Expand All @@ -123,22 +123,32 @@ public function prepareTotalReport($filter, Doctrine_Collection $projects, $user


public function updateMissedBookings($day, $user) public function updateMissedBookings($day, $user)
{ {
Doctrine_Query::create() $entry = Doctrine_Query::create()
->delete() ->from('MissingTimeItemEntry e')
->from('MissingTimeItemEntry e') ->where('e.day = ?', array(date('Y-m-d', $day)))
->where('e.day = ?', array(date('Y-m-d', $day))) ->andWhere('e.user_id = ?', array($user->id))
->andWhere('e.user_id = ?', array($user->id)) ->fetchOne();
->execute();


$item_count = count($user->getTimeEntriesByDay($day)); $item_count = count($user->getTimeEntriesByDay($day));
if ($item_count == 0) { if ($item_count == 0) {
$entry = new MissingTimeItemEntry(); if (!$entry) {
$entry->day = date('Y-m-d', $day); $entry = new MissingTimeItemEntry();
$entry->user_id = $user->id; $entry->day = date('Y-m-d', $day);
$entry->save(); $entry->user_id = $user->id;

$entry->save();
}
return false; return false;
} }
else {
if ($entry) {
Doctrine_Query::create()
->delete()
->from('MissingTimeItemEntry e')
->where('e.day = ?', array(date('Y-m-d', $day)))
->andWhere('e.user_id = ?', array($user->id))
->execute();
}
}


return true; return true;
} }
Expand Down

0 comments on commit 5f1925e

Please sign in to comment.