X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttReportHelper.class.php;h=a64bb8700e31749b127cace55e6dd6c239942fc6;hb=75345c7086761ea68d7e75fbffeaef64a3642fdd;hp=abb5ab9e60cf05efbd08a19fc13bf826db89081a;hpb=7aced3f6210fcd9bad8db0f6ff7d12d1f9daf62e;p=timetracker.git diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index abb5ab9e..a64bb870 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -629,6 +629,27 @@ class ttReportHelper { } } + // The assignToTimesheet assigns a set of tt_log records to a specific timesheet. + static function assignToTimesheet($timesheet_id, $time_log_ids) { + global $user; + $mdb2 = getConnection(); + + $user_id = $user->getUser(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + if ($time_log_ids) { + if ($timesheet_id) + $inner_join = " inner join tt_timesheets ts on (ts.id = $timesheet_id and ts.approve_status is null)"; + + $sql = "update tt_log l $inner_join". + " set l.timesheet_id = ".$mdb2->quote($timesheet_id). + " where l.id in(".join(', ', $time_log_ids).") and l.user_id = $user_id and l.group_id = $group_id and l.org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); + } + } + // The markApproved marks a set of records as either approved or unapproved. static function markApproved($time_log_ids, $expense_item_ids, $approved = true) { global $user;