return_payroll_list(); return count ($timesheets); } function show_payroll_list() { global $wpdb; $db = new time_sheets_db(); $main = new time_sheets_main(); $queue_approval = new time_sheets_queue_approval(); $approver = $queue_approval->employee_approver_check(); $options = get_option('time_sheets'); $common = new time_sheets_common(); $timesheets = $this->return_payroll_list(); if ($timesheets) { echo "
"; if ($approver<>0) { echo ""; } echo ""; if ($options['mileage']) { echo ""; } if ($options['per_diem']) { echo ""; } if ($options['flight_cost']) { echo ""; } if ($options['hotel']) { echo ""; } if ($options['rental_car']) { echo ""; } if ($options['tolls']) { echo ""; } if ($options['other_expenses']) { echo ""; } echo ""; foreach ($timesheets as $timesheet) { echo ""; if ($approver<>0) { echo ""; } echo ""; if ($options['mileage']) { echo ""; } if ($options['per_diem']) { echo ""; } if ($options['flight_cost']) { echo ""; } if ($options['hotel']) { echo ""; } if ($options['rental_car']) { echo ""; } if ($options['tolls']) { echo ""; } if ($options['other_expenses']) { echo ""; } echo ""; } echo "
TimesheetRejectViewCompletedUserStart DateClientProject NameHoursMileagePer Diem DaysFlight/Train CostHotel ChargesRental CarTollsOther Expenses
{$timesheet->timesheet_id}{$common->replace(' ', ' ', $timesheet->display_name)}{$common->f_date($timesheet->start_date)}{$common->clean_from_db($timesheet->client_name)}{$common->clean_from_db($timesheet->project_name)}{$common->clean_from_db($timesheet->total_hours)}{$timesheet->mileage}{$timesheet->per_diem_days}{$timesheet->flight_cost}{$timesheet->hotel_charges}{$timesheet->rental_car_charges}{$timesheet->tolls}{$timesheet->other_expenses}

"; wp_nonce_field( 'timesheet_payroll_processing' ); echo "
"; } else { echo "No time sheets to process for payroll."; } } function payroll_timesheet(){ $entry = new time_sheets_entry(); if ($_GET['action']=='preinvoice') { $entry->show_timesheet(); } else { echo "
"; } } function do_timesheet_rejectpayroll() { global $wpdb; $db = new time_sheets_db(); $user_id = get_current_user_id(); $options = get_option('time_sheets'); if ($options['queue_order']=='parallel') { echo '

This timesheet may be in the payroll queue and may need to be adjusted.


'; } $sql = "update {$wpdb->prefix}timesheet set invoiced = 0, invoiced_by = NULL, invoiced_date = NULL, payrolled = NULL where timesheet_id = %d"; $params = array(intval($_GET['timesheet_id'])); $db->query($sql, $params); echo '

Timesheet has been rejected.

'; } function return_payroll_list() { global $wpdb; $db = new time_sheets_db(); $options = get_option('time_sheets'); $sql = "select t.timesheet_id, u.user_login, t.start_date, c.ClientName client_name, cp.ProjectName project_name, t.invoiceid, cp.notes, t.per_diem_days, t.hotel_charges, t.rental_car_charges, t.tolls, t.other_expenses, t.mileage, t.flight_cost, u.display_name, t.total_hours from {$wpdb->prefix}timesheet t JOIN {$wpdb->prefix}timesheet_clients c ON t.ClientId = c.ClientId JOIN {$wpdb->prefix}timesheet_client_projects cp ON t.ProjectId = cp.ProjectId join {$wpdb->users} u on t.user_id = u.ID"; if ($options['queue_order']=='parallel') { $sql = "{$sql} where t.approved = 1 and payrolled = 0"; } else { $sql = "{$sql} where t.invoiced = 1 and payrolled = 0"; } $sql = "{$sql} order by t.start_date"; $timesheets = $db->get_results($sql); return $timesheets; } function do_timesheet_payroll(){ global $wpdb; $db = new time_sheets_db(); $user_id = get_current_user_id(); check_admin_referer( 'timesheet_payroll_processing' ); $timesheets = $this->return_payroll_list(); foreach ($timesheets as $timesheet) { $valuename = "timesheet_{$timesheet->timesheet_id}"; if ($_GET[$valuename] == 1) { $sql = "update {$wpdb->prefix}timesheet set payrolled= 1, payrolled_by = {$user_id}, payrolled_on = CURDATE() where timesheet_id = {$timesheet->timesheet_id}"; $db->query($sql); } } echo '

Timesheet(s) have been updated.

'; } function employee_payroll_check() { global $wpdb; $user_id = get_current_user_id(); $db = new time_sheets_db(); $sql = "select count(*) from {$wpdb->prefix}timesheet_payrollers where user_id = {$user_id}"; $count = $db->get_var($sql); return $count; } }
"; $this->show_payroll_list(); echo "