ID; $db = new time_sheets_db(); $sql = "select sum(case when (EmbargoPendingProjectClose = 0 or EmbargoPendingProjectClose IS NULL) and tcp.IsRetainer=1 then 1 else 0 end) Retainer, sum(case when (EmbargoPendingProjectClose = 0 or EmbargoPendingProjectClose IS NULL) and tcp.IsRetainer=0 then 1 else 0 end) NotRetainer, sum(case when (EmbargoPendingProjectClose = 1) then 1 else 0 end) Embargoed from {$wpdb->prefix}timesheet t join {$wpdb->prefix}timesheet_approvers_approvies aa ON aa.approvie_user_id = t.user_id join {$wpdb->prefix}timesheet_approvers ta on aa.approver_user_id = ta.user_id and (ta.user_id = {$user_id} OR (ta.backup_user_id = {$user_id} and ta.backup_expires_on > now())) join {$wpdb->prefix}timesheet_client_projects tcp on t.ProjectId = tcp.ProjectId where approved = 0 and week_complete = 1"; $count = $db->get_row($sql); return $count; } function employee_approver_check($includeBackups=true) { global $wpdb; global $approval_count; $user = wp_get_current_user(); $user_id = $user->ID; $db = new time_sheets_db(); if (!isset($approval_count)) { if ($includeBackups=='true') { $sql = "select count(*) from {$wpdb->prefix}timesheet_approvers where (user_id = {$user_id}) OR (backup_user_id = {$user_id} and backup_expires_on > now())"; } else { $sql = "select count(*) from {$wpdb->prefix}timesheet_approvers where user_id = {$user_id}"; } $count = $db->get_var($sql); $approval_count = $count; } else { $count = $approval_count; } return $count; } function do_timesheet_approval_processing() { global $wpdb; $db = new time_sheets_db(); $user = wp_get_current_user(); $user_id = $user->ID; check_admin_referer( 'timesheet_approval_processing'); $timesheets = $this->return_approval_list(); if ($timesheets) { foreach ($timesheets as $timesheet) { $objname = "sheet_{$timesheet->timesheet_id}"; $value = $_GET[$objname]; if ($value == "approve") { $this->do_timesheet_approval($timesheet->timesheet_id); } if ($value == "reject") { $this->do_timesheet_rejectapproval($timesheet->timesheet_id); } } } echo "
Timesheet(s) updated.
Timesheet has been split.