X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/a001599f5d6f1a803a279e602d3333cc036b69cc..9f37cea35130359a3fe915c63a59cbfcdc75663f:/WEB-INF/lib/ttReportHelper.class.php diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 5d9de074..7d2e40c5 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -285,11 +285,11 @@ class ttReportHelper { if ($user->isPluginEnabled('ts')) { $timesheet_option = $options['timesheet']; if ($timesheet_option == TIMESHEET_PENDING) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)"; else if ($timesheet_option == TIMESHEET_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 1)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 1)"; else if ($timesheet_option == TIMESHEET_NOT_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 0)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 0)"; else if ($options['show_timesheet']) $inner_joins .= " left join tt_timesheets ts on (l.timesheet_id = ts.id)"; // Left join for timesheet nme. } @@ -371,11 +371,11 @@ class ttReportHelper { if ($user->isPluginEnabled('ts')) { $timesheet_option = $options['timesheet']; if ($timesheet_option == TIMESHEET_PENDING) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)"; else if ($timesheet_option == TIMESHEET_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 1)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 1)"; else if ($timesheet_option == TIMESHEET_NOT_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 0)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 0)"; else if ($options['show_timesheet']) $inner_joins .= " left join tt_timesheets ts on (ei.timesheet_id = ts.id)"; // Left join for timesheet name. } @@ -566,11 +566,11 @@ class ttReportHelper { if ($user->isPluginEnabled('ts') && $options['timesheet']) { $timesheet_option = $options['timesheet']; if ($timesheet_option == TIMESHEET_PENDING) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)"; else if ($timesheet_option == TIMESHEET_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 1)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 1)"; else if ($timesheet_option == TIMESHEET_NOT_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approval_status = 0)"; + $inner_joins .= " inner join tt_timesheets ts on (l.timesheet_id = ts.id and ts.approve_status = 0)"; } // Prepare a query for time items. $sql = "select $time_part $units_part $cost_part from tt_log l $left_joins $inner_joins $where"; @@ -582,11 +582,11 @@ class ttReportHelper { if ($user->isPluginEnabled('ts') && $options['timesheet']) { $timesheet_option = $options['timesheet']; if ($timesheet_option == TIMESHEET_PENDING) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approval_status is null)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.submit_status = 1 and ts.approve_status is null)"; else if ($timesheet_option == TIMESHEET_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 1)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 1)"; else if ($timesheet_option == TIMESHEET_NOT_APPROVED) - $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approval_status = 0)"; + $inner_joins .= " inner join tt_timesheets ts on (ei.timesheet_id = ts.id and ts.approve_status = 0)"; } $where = ttReportHelper::getExpenseWhere($options); $sql_for_expenses = "select null as time"; @@ -659,6 +659,29 @@ class ttReportHelper { } } + // 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; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $approved_val = (int) $approved; + if ($time_log_ids) { + $sql = "update tt_log set approved = $approved_val". + " where id in(".join(', ', $time_log_ids).") and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); + } + if ($expense_item_ids) { + $sql = "update tt_expense_items set approved = $approved_val". + " where id in(".join(', ', $expense_item_ids).") and group_id = $group_id and org_id = $org_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) die($affected->getMessage()); + } + } + // The markPaid marks a set of records as either paid or unpaid. static function markPaid($time_log_ids, $expense_item_ids, $paid = true) { global $user; @@ -811,12 +834,16 @@ class ttReportHelper { $body .= '