X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttReportHelper.class.php;h=4de5a48399b3d10c2a967eb4594090c6ff1da8a4;hb=1e825770a4defc5eb8d2032c35dc90e8bc8684da;hp=ceaee4b011f530c00cd77c5ab676047cb2c5823d;hpb=d5923832a32b1f43cbc6c5d74bbd064888761c80;p=timetracker.git diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index ceaee4b0..4de5a483 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -639,9 +639,20 @@ class ttReportHelper { $org_id = $user->org_id; if ($time_log_ids) { - $sql = "update tt_log l". - // TODO: inner join does not work properly for de-assignment. Improve. - // " inner join tt_timesheets ts on (ts.id = $timesheet_id and ts.approve_status is null)". + // Use inner join as a protection mechanism not to do anything with "acted upon" timesheets. + // Allow oprations only with pending timesheets. + if ($timesheet_id) { + // Assigning a timesheet to records. + $inner_join = " inner join tt_timesheets ts on (ts.id = $timesheet_id". + " and ts.user_id = $user_id and ts.approve_status is null". // Timesheet to assign to is pending. + // Part below: existing timesheet either not exists or is also pending. + " and (l.timesheet_id is null or (l.timesheet_id = ts.id and ts.approve_status is null)))"; + } else { + $inner_join = " inner join tt_timesheets ts on (ts.id = l.timesheet_id". + " and ts.user_id = $user_id and ts.approve_status is null)"; // Do not deassign from acted-upon timesheets. + } + + $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); @@ -727,6 +738,24 @@ class ttReportHelper { $cellLeftAlignedSubtotal = 'font-weight: bold; text-align: left; vertical-align: top;'; $cellRightAlignedSubtotal = 'font-weight: bold; text-align: right; vertical-align: top;'; + // Determine column span for note field. + $colspan = 1; + if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) $colspan++; + if ($options['show_client']) $colspan++; + if ($options['show_project']) $colspan++; + if ($options['show_task']) $colspan++; + if ($options['show_custom_field_1']) $colspan++; + if ($options['show_start']) $colspan++; + if ($options['show_end']) $colspan++; + if ($options['show_duration']) $colspan++; + if ($options['show_work_units']) $colspan++; + if ($options['show_cost']) $colspan++; + if ($options['show_approved']) $colspan++; + if ($options['show_paid']) $colspan++; + if ($options['show_ip']) $colspan++; + if ($options['show_invoice']) $colspan++; + if ($options['show_timesheet']) $colspan++; + // Start creating email body. $body = ''; $body .= '';