employees_always_to_payroll_update_emps();
}
$this->employees_always_to_payroll_show_emps();
}
function employees_always_to_payroll_update_emps() {
global $wpdb;
$db = new time_sheets_db();
check_admin_referer( 'add_user_to_payroll');
$sql = "select u.ID, u.user_login, eatp.user_id, u.display_name
from {$wpdb->users} u
left outer join {$wpdb->prefix}timesheet_employee_always_to_payroll eatp on u.ID = eatp.user_id
order by u.user_login";
$users = $db->get_results($sql);
if ($users) {
foreach ($users as $user)
{
$id = "user_{$user->ID}";
if (isset($_POST[$id]) && $user->user_id == "") {
$sql = "INSERT INTO {$wpdb->prefix}timesheet_employee_always_to_payroll (user_id) VALUES ({$user->ID})";
$db->query($sql);
}
IF (!isset($_POST[$id]) && $user->user_id != "") {
$sql = "DELETE FROM {$wpdb->prefix}timesheet_employee_always_to_payroll WHERE user_id = {$user->ID}";
$db->query($sql);
}
}
}
echo '
Employees Updated.
';
}
function employees_always_to_payroll_show_emps() {
global $wpdb;
$db = new time_sheets_db();
$sql = "select u.ID, u.display_name, u.user_login, eatp.user_id, u.display_name
from {$wpdb->users} u
left outer join {$wpdb->prefix}timesheet_employee_always_to_payroll eatp on u.ID = eatp.user_id
order by u.display_name";
$users = $db->get_results($sql);
if ($users) {
echo "
";
} else {
echo "You have no logins, this shouldn't be possible. Something is very wrong.";
}
}
function setup_approval_teams() {
if (isset($_GET['action']) && $_GET['action']=='add') {
$this->add_member_to_team();
}
if (isset($_GET['action']) && $_GET['action']=='delete') {
$this->remove_member_from_team();
}
$this->show_users_as_team_leads();
if (isset($_GET['approver_user_id']) && $_GET['approver_user_id']) {
$this->show_leads_team(intval($_GET['approver_user_id']));
}
}
function add_member_to_team() {
global $wpdb;
$db = new time_sheets_db();
$user = wp_get_current_user();
$sql = "insert into {$wpdb->prefix}timesheet_approvers_approvies (approver_user_id, approvie_user_id)
values (%d, %d)";
$values = array(intval($_GET['approver_user_id']), intval($_GET['approvie_user_id']));
$db->query($sql, $values);
$sql = "insert into {$wpdb->prefix}timesheet_approvers_approvies_archive
select $user->ID, now(), 'INSERTED', approver_user_id, approvie_user_id
FROM {$wpdb->prefix}timesheet_approvers_approvies
where approver_user_id = %d and approvie_user_id = %d";
$parms = array(intval($_GET['approver_user_id']), intval($_GET['approvie_user_id']));
$db->query($sql, $parms);
}
function remove_member_from_team() {
global $wpdb;
$db = new time_sheets_db();
$user = wp_get_current_user();
$sql = "insert into {$wpdb->prefix}timesheet_approvers_approvies_archive
select $user->ID, now(), 'DELETED', approver_user_id, approvie_user_id
FROM {$wpdb->prefix}timesheet_approvers_approvies
where approver_user_id = %d and approvie_user_id = %d";
$parms = array(intval($_GET['approver_user_id']), intval($_GET['approvie_user_id']));
$db->query($sql, $parms);
$sql = "delete from {$wpdb->prefix}timesheet_approvers_approvies where approver_user_id = %d and approvie_user_id = %d";
$values = array(intval($_GET['approver_user_id']), intval($_GET['approvie_user_id']));
$db->query($sql, $values);
}
function show_leads_team($approver_user_id){
global $wpdb;
$db = new time_sheets_db();
$common = new time_sheets_common();
$folder = plugins_url();
$users = $common->return_approvers_team_list($approver_user_id, 0);
echo "
Add Team Member
Remove Team Member
User
User Name
";
foreach ($users as $user) {
echo "
";
if (!$user->a) {
echo "";
}
echo "
";
if ($user->a) {
echo "";
}
echo "
{$user->display_name}
{$user->user_login}
";
}
echo "
";
}
function show_users_as_team_leads() {
global $wpdb;
$db = new time_sheets_db();
$common = new time_sheets_common();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
join {$wpdb->prefix}timesheet_approvers ta ON u.id = ta.user_id
order by u.display_name";
$users = $db->get_results($sql);
echo "";
}
function get_active_tab($tab) {
if ($tab == "automation" || $tab == "") {
$active_tab = "automation";
} elseif ($tab == "display_settings") {
$active_tab = "display_settings";
} elseif ($tab == "retainer") {
$active_tab = "retainer";
} elseif ($tab == "basics") {
$active_tab = "basics";
} elseif ($tab == "payroll") {
$active_tab = "payroll";
}
return $active_tab;
}
function show_settings_page() {
settings_errors();
if (isset($_GET["tab"])) {
$tab = $_GET["tab"];
} else {
$tab = '';
}
$active_tab = $this->get_active_tab($tab);
echo '
If you wish to display the New Timesheet form on a page within your site, use the shortcode "[timesheet_entry]" within the page.
If you wish to display the Open Timesheets form on a page within your site, use the shortcode "[timesheet_search]" within the page.
Both these shortcodes will only work if the user is logged in, and will display an error message if the user is not logged in.
Be sure to save settings before switching tabs.
';
echo "";
}
function settings_header_email() {
echo "Email settings for the time sheets application.";
}
function settings_validate($inputs) {
$options = get_option('time_sheets');
if (isset($_POST["tab"])) {
$tab = $_POST["tab"];
} else {
$tab = '';
}
$active_tab = $this->get_active_tab($tab);
if ($active_tab != "automation") {
$inputs["cron_user"] = $options["cron_user"];
$inputs["project_trigger_percent"] = $options["project_trigger_percent"];
$inputs["email_address_on_project_over"] = $options["email_address_on_project_over"];
$inputs["default_auto_close"] = $options["default_auto_close"];
}
if ($active_tab != "display_settings") {
$inputs["display_notes_toggle"] = $options["display_notes_toggle"];
$inputs["display_notes_list"] = $options["display_notes_list"];
$inputs["display_expenses_toggle"] = $options["display_expenses_toggle"];
$inputs["display_expenses_list"] = $options["display_expenses_list"];
$inputs["menu_location"] = $options["menu_location"];
$inputs["users_override_location"] = $options["users_override_location"];
$inputs["show_header_queues"] = $options["show_header_queues"];
$inputs["show_header_open_invoices"] = $options["show_header_open_invoices"];
$inputs["rel_url_to_timesheet"] = $options["rel_url_to_timesheet"];
$inputs["override_date_format"] = $options["override_date_format"];
$inputs["new_date_format"] = $options["new_date_format"];
$inputs["user_specific_date_format"] = $options["user_specific_date_format"];
$inputs["hide_client_project"] = $options["hide_client_project"];
$inputs["remove_embargo"] = $options["remove_embargo"];
$inputs["week_starts"] = $options["week_starts"];
$inputs["queue_order"] = $options["queue_order"];
$inputs["sales_override"] = $options["sales_override"];
$inputs["hide_notes"] = $options["hide_notes"];
$inputs["currency_char"] = $options["currency_char"];
$inputs["distance_metric"] = $options["distance_metric"];
}
if ($active_tab != "retainer") {
$inputs["update_retainer_hours"] = $options["update_retainer_hours"];
}
if ($active_tab != "basics") {
$inputs["enable_email"] = $options["enable_email"];
$inputs["email_late_timesheets"] = $options["email_late_timesheets"];
$inputs["email_retainer_due"] = $options["email_retainer_due"];
$inputs["email_from"] = $options["email_from"];
$inputs["email_name"] = $options["email_name"];
$inputs["show_email_notice"] = $options["show_email_notice"];
$inputs["hide_dcac_ad"] = $options["hide_dcac_ad"];
$inputs["day_of_week_timesheet_reminders"] = $options["day_of_week_timesheet_reminders"];
}
if ($active_tab != "payroll") {
$inputs["mileage"] = $options["mileage"];
$inputs["per_diem"] = $options["per_diem"];
$inputs["flight_cost"] = $options["flight_cost"];
$inputs["hotel"] = $options["hotel"];
$inputs["rental_car"] = $options["rental_car"];
$inputs["taxi"] = $options["taxi"];
$inputs["tolls"] = $options["tolls"];
$inputs["other_expenses"] = $options["other_expenses"];
$inputs["allow_overtime"] = $options["allow_overtime"];
$inputs["ot_multiplier"] = $options["ot_multiplier"];
$inputs["show_overtime_when_empty"] = $options["show_overtime_when_empty"];
$inputs["allow_users_to_reject"] = $options["allow_users_to_reject"];
}
if (!is_numeric($inputs['project_trigger_percent']) || $inputs['project_trigger_percent'] < 1 || $inputs['project_trigger_percent'] > 100) {
add_settings_error('project_trigger_percent', 'error_project_trigger_percent', 'The Project Trigger Percernt must be a number between 1 and 100.', 'error');
}
#update_settings('time_sheets', $inputs);
return $inputs;
}
function settings_header_automation() {
echo "";
}
function settings_header_display() {
echo "";
}
function user_can_enter_notes($user_id, $setting, $array_setting) {
$options = get_option('time_sheets');
global $wpdb;
$db = new time_sheets_db();
$sql = "select u.user_login, ta.user_id a, u.id
from {$wpdb->users} u
join {$wpdb->prefix}timesheet_approvers_approvies taa on u.id = taa.approvie_user_id
join {$wpdb->prefix}timesheet_approvers ta ON taa.approver_user_id = ta.user_id
where u.ID = {$user_id}";
$users = $db->get_results($sql);
$array_value = isset($options[$array_setting]) ? $options[$array_setting] : array();
if ($users) {
foreach ($users as $user) {
if ($options[$setting]=='all_except') {
if (in_array($user->id, $array_value)) {
return 0;
}
} else { //only_these
if (in_array($user->id, $array_value)) {
return 1;
}
}
}
if ($options[$setting]=='all_except') {
return 1;
} else { //only_these
return 0;
}
} else {
if ($options[$setting]=='all_except') {
return 1;
} else { //only_these
return 0;
}
}
}
function display_notes_list() {
$options = get_option('time_sheets');
global $wpdb;
$db = new time_sheets_db();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
join {$wpdb->prefix}timesheet_approvers ta ON u.ID = ta.user_id
order by u.user_login";
$users = $db->get_results($sql);
$rows = count($users);
if ($rows > 6) {
$rows = 6;
}
echo " (Hold control key for multiple values)";
}
function display_notes_toggle() {
$options = get_option('time_sheets');
if ($options['display_notes_toggle'] == 'all_except' || $options['display_notes_toggle'] == '') {
$all_except = ' checked';
$only_these = '';
} else {
$all_except = '';
$only_these = ' checked';
}
echo " All groups except...
Only these groups...";
}
function display_expenses_list() {
$options = get_option('time_sheets');
global $wpdb;
$db = new time_sheets_db();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
join {$wpdb->prefix}timesheet_approvers ta ON u.ID = ta.user_id
order by u.user_login";
$users = $db->get_results($sql);
$rows = count($users);
if ($rows > 6) {
$rows = 6;
}
echo " (Hold control key for multiple values)";
}
function display_expenses_toggle() {
$options = get_option('time_sheets');
if (!isset($options['display_expenses_toggle'])) {
$all_except = ' checked';
$only_these = '';
} else {
$all_except = '';
$only_these = ' checked';
}
echo " All groups except...
Only these groups...";
}
function blank() {
}
function day_of_week_timesheet_reminders() {
$options = get_option('time_sheets');
$common = new time_sheets_common();
echo "";
if (!isset($options['day_of_week_timesheet_reminders'])) {
echo '
* Setting Not Set
';
}
}
function week_starts() {
$options = get_option('time_sheets');
$common = new time_sheets_common();
echo "";
if (!isset($options['week_starts'])) {
echo '
* Setting Not Set
';
}
}
function project_trigger_percent() {
$options = get_option('time_sheets');
$project_trigger_percent = $options['project_trigger_percent'];
if (!$project_trigger_percent) {
$project_trigger_percent = 100;
}
echo "";
if (!isset($options['project_trigger_percent'])) {
echo '
* Setting Not Set
';
}
}
function email_address_on_project_over() {
$options = get_option('time_sheets');
$email_address_on_project_over = $options['email_address_on_project_over'];
echo " Leave blank to disable. Seperate multiple addresses with a comma.";
}
function hide_notes() {
$options = get_option('time_sheets');
$hide_notes = isset($options['hide_notes']) ? " checked": "";
echo "";
}
function default_auto_close() {
$options = get_option('time_sheets');
$default_auto_close = isset($options['default_auto_close']) ? " checked" : "";
echo "";
}
function register_settings() {
if (isset($_GET["tab"])) {
$tab = $_GET["tab"];
} else {
$tab = '';
}
$active_tab = $this->get_active_tab($tab);
register_setting('time_sheets', 'time_sheets', array(&$this, 'settings_validate'));
if ($active_tab=="automation") {
add_settings_section('time_sheets_automation', __('Automation', ''), array(&$this, 'settings_header_automation'), 'time_sheets');
add_settings_field('cron_user', __('User For Automatic Entries:', ''), array(&$this, 'cron_user'), 'time_sheets', 'time_sheets_automation');
add_settings_field('project_trigger_percent', __('Percent of project completion to show alerts:', ''), array(&$this, 'project_trigger_percent'), 'time_sheets', 'time_sheets_automation');
add_settings_field('email_address_on_project_over', __('Email address to email when a project is over on hours:', ''), array(&$this, 'email_address_on_project_over'), 'time_sheets', 'time_sheets_automation');
add_settings_field('default_auto_close', __('Default new projects to auto-close:', ''), array(&$this, 'default_auto_close'), 'time_sheets', 'time_sheets_automation');
} elseif ($active_tab=="display_settings") {
add_settings_section('time_sheets_display', __('Display Settings', ''), array(&$this, 'settings_header_display'), 'time_sheets');
add_settings_field('display_notes_toggle', __('Display notes fields to:', ''), array(&$this, 'display_notes_toggle'), 'time_sheets', 'time_sheets_display');
add_settings_field('display_notes_list', __('Notes To/Except list (based on prior setting):', ''), array(&$this, 'display_notes_list'), 'time_sheets', 'time_sheets_display');
add_settings_field('display_expenses_toggle', __('Display expenses fields to:', ''), array(&$this, 'display_expenses_toggle'), 'time_sheets', 'time_sheets_display');
add_settings_field('display_expenses_list', __('Expenses To/Except list (based on prior setting):', ''), array(&$this, 'display_expenses_list'), 'time_sheets', 'time_sheets_display');
add_settings_field('menu_location', __('Time Sheets below:', ''), array(&$this, 'menu_location'), 'time_sheets', 'time_sheets_display');
add_settings_field('users_override_location', __('Users can override menu location:', ''), array(&$this, 'users_override_location'), 'time_sheets', 'time_sheets_display');
add_settings_field('show_header_queues', __('Show Queues in Admin Header:', ''), array(&$this, 'show_header_queues'), 'time_sheets', 'time_sheets_display');
add_settings_field('show_header_open_invoices', __('Show Users Open Timesheets in Admin Header:', ''), array(&$this, 'show_header_open_invoices'), 'time_sheets', 'time_sheets_display');
add_settings_field('rel_url_to_timesheet', __('Relative URL to Timesheet Entry Page:', ''), array(&$this, 'rel_url_to_timesheet'), 'time_sheets', 'time_sheets_display');
add_settings_field('override_date_format', __('Override Site Wide Date Format:', ''), array(&$this, 'override_date_format'), 'time_sheets', 'time_sheets_display');
add_settings_field('new_date_format', __('New Date Format:', ''), array(&$this, 'new_date_format'), 'time_sheets', 'time_sheets_display');
add_settings_field('user_specific_date_format', __('Allow users to set their own date format:', ''), array(&$this, 'user_specific_date_format'), 'time_sheets', 'time_sheets_display');
add_settings_field('hide_client_project', __('Hide the Client and Project fields if only one option:', ''), array(&$this, 'hide_client_project'), 'time_sheets', 'time_sheets_display');
add_settings_field('remove_embargo', __('Remove embargo options:', ''), array(&$this, 'remove_embargo'), 'time_sheets', 'time_sheets_display');
add_settings_field('week_starts', __('Week starts:', ''), array(&$this, 'week_starts'), 'time_sheets', 'time_sheets_display');
add_settings_field('queue_order', __('Payroll Queue Processing:', ''), array(&$this, 'queue_order'), 'time_sheets', 'time_sheets_display');
add_settings_field('sales_override', __('Sales Person Priorty:', ''), array(&$this, 'sales_override'), 'time_sheets', 'time_sheets_display');
add_settings_field('hide_notes', __('Hide the notes field for completed time sheets:', ''), array(&$this, 'hide_notes'), 'time_sheets', 'time_sheets_display');
add_settings_field('currency_char', __('Currency Symbol to Show:', ''), array(&$this, 'currency_char'), 'time_sheets', 'time_sheets_display');
add_settings_field('distance_metric', __('Distance Metric:', ''), array(&$this, 'distance_metric'), 'time_sheets', 'time_sheets_display');
} elseif ($active_tab=="retainer") {
add_settings_section('time_sheets_retainer', __('Retainer Settings', ''), array(&$this, 'blank'), 'time_sheets');
add_settings_field('update_retainer_hours', __('Update allowed hours for retainers monthly:', ''), array(&$this, 'update_retainer_hours'), 'time_sheets', 'time_sheets_retainer');
} elseif ($active_tab=="basics") {
add_settings_section('time_sheets_basics', __('Email Settings', ''), array(&$this, 'settings_header_email'), 'time_sheets');
add_settings_field('enable_email', __('Enable Email:', ''), array(&$this, 'enable_email'), 'time_sheets', 'time_sheets_basics');
add_settings_field('email_late_timesheets', __('Email users when timesheets are overdue:', ''), array(&$this, 'email_late_timesheets'), 'time_sheets', 'time_sheets_basics');
add_settings_field('email_retainer_due', __('Email users that retainer timesheets are due:', ''), array(&$this, 'email_retainer_due'), 'time_sheets', 'time_sheets_basics');
add_settings_field('email_from', __('From Email Address:', ''), array(&$this, 'email_from'), 'time_sheets', 'time_sheets_basics');
add_settings_field('email_name', __('From Email Name:', ''), array(&$this, 'email_name'), 'time_sheets', 'time_sheets_basics');
add_settings_field('show_email_notice', __('Show Notice On Email Send:', ''), array(&$this, 'show_email_notice'), 'time_sheets', 'time_sheets_basics');
add_settings_field('hide_dcac_ad', __('Hide Application Ad:', ''), array(&$this, 'hide_dcac_ad'), 'time_sheets', 'time_sheets_basics');
add_settings_field('day_of_week_timesheet_reminders', __('Day of week for Time Sheet Reminders:', ''), array(&$this, 'day_of_week_timesheet_reminders'), 'time_sheets', 'time_sheets_basics');
} elseif ($active_tab=="payroll") {
add_settings_section('time_sheets_process_payroll', __('Payroll Triggers', ''), array(&$this, 'process_payroll'), 'time_sheets');
add_settings_field('mileage', __('Mileage', ''), array(&$this, 'mileage'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('per_diem', __('Per Diem', ''), array(&$this, 'per_diem'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('flight_cost', __('Flight/Train Cost', ''), array(&$this, 'flight_cost'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('hotel', __('Hotel Charges', ''), array(&$this, 'hotel'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('rental_car', __('Rental Car', ''), array(&$this, 'rental_car'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('taxi', __('Taxi/Rideshare', ''), array(&$this, 'taxi'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('tolls', __('Tolls', ''), array(&$this, 'tolls'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_field('other_expenses', __('Other Expenses', ''), array(&$this, 'other_expenses'), 'time_sheets', 'time_sheets_process_payroll');
add_settings_section('time_sheets_payroll_options', __('Payroll Options', ''), array(&$this, 'blank'), 'time_sheets');
add_settings_field('allow_overtime', __('Show Overtime Fields', ''), array(&$this, 'allow_overtime'), 'time_sheets', 'time_sheets_payroll_options');
add_settings_field('ot_multiplier', __('Overtime Multiplier', ''), array(&$this, 'ot_multiplier'), 'time_sheets', 'time_sheets_payroll_options');
add_settings_field('show_overtime_when_empty', __('Show Overtime When Value of 0:', ''), array(&$this, 'show_overtime_when_empty'), 'time_sheets', 'time_sheets_payroll_options');
add_settings_field('allow_users_to_reject', __('Allow Users to Reject Timesheets:', ''), array(&$this, 'allow_users_to_reject'), 'time_sheets', 'time_sheets_payroll_options');
}
}
function allow_users_to_reject() {
$allow_users_to_reject = '';
$options = get_option('time_sheets');
if (isset($options['allow_users_to_reject'])) {
$allow_users_to_reject = ' checked';
}
echo "";
}
function show_overtime_when_empty() {
$show_overtime_when_empty = '';
$options = get_option('time_sheets');
if (isset($options['show_overtime_when_empty'])) {
$show_overtime_when_empty = ' checked';
}
echo "";
}
function distance_metric() {
$options = get_option('time_sheets');
$distance_metric = $options['distance_metric'];
$common = new time_sheets_common();
echo "";
if (!isset($options['distance_metric'])) {
echo '
* Setting Not Set
';
}
}
function currency_char() {
$options = get_option('time_sheets');
$currency_char = $options['currency_char'];
if ($currency_char == "") {
$currency_char = "$";
}
echo "";
if (!isset($options['currency_char'])) {
echo '
* Setting Not Set
';
}
}
function ot_multiplier(){
$options = get_option('time_sheets');
$ot_multiplier = floatval($options['ot_multiplier']);
if ($ot_multiplier==0) {
$ot_multiplier = 1;
}
echo "
Multiplier to be applies to overtime hours worked when calculating hours used against a project. This does not effect the hours entered by the worked. Typical values are 1.5.";
}
function allow_overtime() {
$options = get_option('time_sheets');
$allow_overtime = isset($options['allow_overtime'])? " checked" : "";
echo "";
}
function sales_override() {
$common = new time_sheets_common();
$options = get_option('time_sheets');
echo "";
if (!isset($options['sales_override'])) {
echo '
* Setting Not Set
';
}
}
function queue_order() {
$common = new time_sheets_common();
$options = get_option('time_sheets');
echo "";
if (!isset($options['queue_order'])) {
echo '
* Setting Not Set
';
}
}
function remove_embargo() {
$options = get_option('time_sheets');
$remove_embargo = isset($options['remove_embargo']) ? " selected" : "";
echo " This will not unembargo any time sheets which are embargoed. That needs to be done before this setting is enabled.";
}
function hide_client_project() {
$options = get_option('time_sheets');
$hide_project = isset($options['hide_client_project']) ? " selected" : "";
echo " If checked and the user only has access to a single client and a single project then the client and project will be hidden from view.";
}
function override_date_format() {
$options = get_option('time_sheets');
$common = new time_sheets_common();
if ($options['override_date_format'] <> 'system_defined' && $options['override_date_format'] <> 'admin_defined') {
$options['override_date_format']= 'system_defined';
}
echo "is_match($options['override_date_format'], 'system_defined', ' checked')}> Use the system wide settings ";
echo "is_match($options['override_date_format'], 'admin_defined', ' checked')}> Use the setting defined below";
if (($options['override_date_format'] <> 'system_defined' || $options['override_date_format'] <> 'admin_defined')) {
echo '
* Setting Not Set
';
}
echo "";
}
function new_date_format() {
$options = get_option('time_sheets');
$value = isset($options['new_date_format']) ? $options['new_date_format'] : "";
echo " Documentation on Date Formatting Use of a non-ISO date format can cause search issues when searching for old time sheets.";
}
function user_specific_date_format() {
$options = get_option('time_sheets');
$value = isset($options['user_specific_date_format']) ? " checked" : "";
echo "";
}
function rel_url_to_timesheet() {
$options = get_option('time_sheets');
$value = isset($options['rel_url_to_timesheet']) ? $options['rel_url_to_timesheet'] : "";
echo " (This setting is only needed when using shortcut codes for time sheet entry and time sheet search pages. To use create a page with this value as the slug and [timesheet_entry] as the value.)";
}
function show_header_open_invoices() {
$options = get_option('time_sheets');
$value = isset($options['show_header_open_invoices']) ? " checked" : "";
echo "";
}
function update_retainer_hours() {
$options = get_option('time_sheets');
$value = isset($options['update_retainer_hours']) ? " checked" : "";
echo "";
}
function show_header_queues() {
$options = get_option('time_sheets');
$value = isset($options['show_header_queues']) ? " checked" : "";
echo " (Queues are only shown when there are items in the queue to be processed.)";
}
function menu_location() {
$options = get_option('time_sheets');
$common = new time_sheets_common();
echo "";
}
function users_override_location() {
$options = get_option('time_sheets');
$value = isset($options['users_override_location']) ? " checked" : "";
echo "";
}
function email_late_timesheets() {
$options = get_option('time_sheets');
$value = isset($options['email_late_timesheets']) ? " checked" : "";
echo "";
}
function email_retainer_due() {
$options = get_option('time_sheets');
$value = isset($options['email_retainer_due']) ? " checked" : "";
echo "";
}
function flight_cost() {
$options = get_option('time_sheets');
$value = isset($options['flight_cost']) ? " checked" : "";
echo "";
}
function per_diem() {
$options = get_option('time_sheets');
$value = isset($options['per_diem']) ? " checked" : "";
echo "";
}
function hotel() {
$options = get_option('time_sheets');
$value = isset($options['hotel']) ? " checked" : "";
echo "";
}
function rental_car() {
$options = get_option('time_sheets');
$value = isset($options['rental_car']) ? " checked" : "";
echo "";
}
function tolls() {
$options = get_option('time_sheets');
$value = isset($options['tolls']) ? " checked" : "";
echo "";
}
function taxi() {
$options = get_option('time_sheets');
$value = isset($options['taxi']) ? " checked" : "";
echo "";
}
function other_expenses() {
$options = get_option('time_sheets');
$value = isset($options['other_expenses']) ? " checked" : "";
echo "";
}
function mileage() {
$options = get_option('time_sheets');
$value = isset($options['mileage']) ? " checked" : "";
echo "";
}
function process_payroll() {
echo "Select the Expense categories which should trigger timesheets being sent to the Payrol workflow.";
}
function get_holidays() {
$options = get_option('time_sheets');
echo "Allows the application to call out to the Denny Cherry & Associates Consulting web servers to request a list of holidays in order to mark days in the timesheet as a holiday.";
}
function license_key() {
$options = get_option('time_sheets');
echo "";
if (!$options['license_key']) {
echo "
No license key was provided. Application will be fully functional, however the number of clients and projects will be limited to two clients and 5 projects.
";
}
}
function cron_user() {
global $wpdb;
$db = new time_sheets_db();
$options = get_option('time_sheets');
$sql = "select * from {$wpdb->users} u order by u.display_name";
$users = $db->get_results($sql);
echo "";
}
function show_email_notice() {
$options = get_option('time_sheets');
$value = isset($options['show_email_notice']) ? " checked" : "";
echo " (Mostly used for troubleshooting.)";
}
function hide_dcac_ad() {
$options = get_option('time_sheets');
$value = isset($options['hide_dcac_ad']) ? " checked" : "";
echo "";
}
function email_name() {
$options = get_option('time_sheets');
$value = isset($options['email_name']) ? $options['email_name'] : "";
echo "";
}
function email_from() {
$options = get_option('time_sheets');
$value = isset($options['email_from']) ? $options['email_from'] : "";
echo "
If you are having problems with this setting refer to this page.";
}
function enable_email() {
$options = get_option('time_sheets');
$value = isset($options['enable_email']) ? " checked" : "";
echo "";
}
function manage_approvers() {
if (isset($_GET['action']) && $_GET['action']=='add') {
$this->add_person('approvers');
}
if (isset($_GET['action']) && $_GET['action']=='delete') {
$this->delete_person('approvers');
}
$this->show_approvers();
}
function add_person($table) {
global $wpdb;
$user = wp_get_current_user();
$user_id = $user->ID;
$db = new time_sheets_db();
$sql = "insert into {$wpdb->prefix}timesheet_{$table} (user_id) values (%d)";
$params = array($_GET['user_id']);
$db->query($sql, $params);
$sql = "insert into {$wpdb->prefix}timesheet_{$table}_archive
select $user->ID, now(), 'INSERTED', user_id";
if ($table == "approvers") {
$sql = $sql . ", backup_user_id, backup_expires_on";
}
$sql = $sql . " FROM {$wpdb->prefix}timesheet_{$table}
WHERE user_id = %d";
$parms = array($_GET['user_id']);
$db->query($sql, $parms);
}
function delete_person($table) {
global $wpdb;
$user = wp_get_current_user();
$user_id = $user->ID;
$db = new time_sheets_db();
$sql = "insert into {$wpdb->prefix}timesheet_{$table}_archive
select $user->ID, now(), 'DELETED', user_id";
if ($table == "approvers") {
$sql = $sql . ", backup_user_id, backup_expires_on";
}
$sql = $sql . "
FROM {$wpdb->prefix}timesheet_{$table}
WHERE user_id = %d";
$parms = array($_GET['user_id']);
$db->query($sql, $parms);
$sql = "delete from {$wpdb->prefix}timesheet_{$table} where user_id = %d";
$params = array($_GET['user_id']);
$db->query($sql, $params);
}
function show_approvers() {
global $wpdb;
$db = new time_sheets_db();
$user = wp_get_current_user();
$user_id = $user->ID;
$folder = plugins_url();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
left outer join {$wpdb->prefix}timesheet_approvers ta ON u.ID = ta.user_id
order by u.display_name";
$users = $db->get_results($sql);
echo "
User
User Name
Current State
Add Permission
Remove Permission
";
foreach ($users as $user) {
echo "
{$user->display_name}
{$user->user_login}
";
if ($user->a) {
echo "Has Access";
} else {
echo "No Access";
}
echo "
";
if (!$user->a) {
echo "";
}
echo "
";
if ($user->a) {
echo "";
}
echo "
";
}
echo "
";
}
function show_invoicers() {
global $wpdb;
$db = new time_sheets_db();
$user = wp_get_current_user();
$user_id = $user->ID;
$folder = plugins_url();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
left outer join {$wpdb->prefix}timesheet_invoicers ta ON u.ID = ta.user_id
order by u.display_name";
$users = $db->get_results($sql);
echo "
User
User Name
Current State
Add Permission
Remove Permission
";
foreach ($users as $user) {
echo "
{$user->display_name}
{$user->user_login}
";
if ($user->a) {
echo "Has Access";
} else {
echo "No Access";
}
echo "
";
if (!$user->a) {
echo "";
}
echo "
";
if ($user->a) {
echo "";
}
echo "
";
}
echo "
";
}
function show_payrollers() {
global $wpdb;
$db = new time_sheets_db();
$user = wp_get_current_user();
$user_id = $user->ID;
$folder = plugins_url();
$sql = "select u.user_login, ta.user_id a, u.id, u.display_name
from {$wpdb->users} u
left outer join {$wpdb->prefix}timesheet_payrollers ta ON u.ID = ta.user_id
order by u.display_name";
$users = $db->get_results($sql);
echo "
User
User Name
Current State
Add Permission
Remove Permission
";
foreach ($users as $user) {
echo "
{$user->display_name}
{$user->user_login}
";
if ($user->a) {
echo "Has Access";
} else {
echo "No Access";
}
echo "
";
if (!$user->a) {
echo "";
}
echo "
";
if ($user->a) {
echo "";
}
echo "
";
}
echo "
";
}
function manage_payrollers() {
if (isset($_GET['action']) && $_GET['action']=='add') {
$this->add_person('payrollers');
}
if (isset($_GET['action']) && $_GET['action']=='delete') {
$this->delete_person('payrollers');
}
$this->show_payrollers();
}
function manage_invoicers() {
if (isset($_GET['action']) && $_GET['action']=='add') {
$this->add_person('invoicers');
}
if (isset($_GET['action']) && $_GET['action']=='delete') {
$this->delete_person('invoicers');
}
$this->show_invoicers();
}
}