'',
'from_name' => '',
'email_enabled' => '',
'hide_dcac_ad' => '',
'email_late_timesheets' => 'checked',
'override_date_format' => 'system_defined'
);
// Add options
add_option('time_sheets', $options);
$setup = new time_sheets_setup();
$setup->create_db_objects();
$cron = new time_sheets_cron();
$cron->add_cron();
}
function deactivation() {
//delete_option('time_sheets');
$cron = new time_sheets_cron();
$cron->remove_cron();
}
function upgrade() {
$setup = new time_sheets_setup();
$setup->create_db_objects();
$options = get_option('time_sheets');
$cron = new time_sheets_cron();
$cron->add_cron();
}
function custom_menu() {
if (($_GET['page'] == "payroll_timesheet" || $_GET['page'] == "invoice_timesheet" || $_GET['page'] == "approve_timesheet" || $_GET['page'] == "enter_timesheet" || $_GET['page'] == "search_timesheet" || $_GET['page'] == "timesheet_manage_clients" || $_GET['page'] == "timesheet_settings" || $_GET['page'] == "my_settings" ) && !$_GET['action']) {
$this->footer();
}
$options = get_option('time_sheets');
$time_sheets_main = new time_sheets_main();
$time_sheets_entry = new time_sheets_entry();
$time_sheets_settings = new time_sheets_settings();
$time_sheets_manage_projects = new time_sheets_manage_projects();
$queue_payroll = new time_sheets_queue_payroll();
$queue_invoice = new time_sheets_queue_invoice();
$queue_approval = new time_sheets_queue_approval();
$client_managers = new time_sheets_client_managers();
$my = new time_sheets_my_settings();
$cron = new time_sheets_cron();
if ($queue_approval->employee_approver_check()!=0) {
$vcount_pending_approval = $queue_approval->count_pending_approval();
} else {
$vcount_pending_approval = 0;
}
if ($queue_invoice->employee_invoicer_check()!=0) {
$vcount_pending_invoice = $queue_invoice->count_pending_invoice();
} else {
$vcount_pending_invoice = 0;
}
if ($queue_payroll->employee_payroll_check()!=0) {
$vcount_pending_payroll = $queue_payroll->count_pending_payroll();
} else {
$vcount_pending_payroll = 0;
}
$timesheets_not_complete = $queue_invoice->count_users_open_invoice();
$pending_stuff = $vcount_pending_approval->NotRetainer + $vcount_pending_approval->Retainer + $vcount_pending_invoice->NotRetainer + $vcount_pending_invoice->Retainer + $vcount_pending_payroll+$timesheets_not_complete;
$menuLocation = $options['menu_location'];
if ($menuLocation == '') {
$menuLocation = NULL;
}
$userMenuLocation = get_user_option('time_sheets_menu_location', $user_id);
if ($options['users_override_location']) {
if ($userMenuLocation != '') {
$menuLocation = $userMenuLocation;
}
}
if ($pending_stuff != 0) {
$tag = "Time Sheets {$pending_stuff}";
} else {
$tag = 'Time Sheets';
}
add_menu_page('Time Sheets', $tag, '', 'time_sheets_top', array($time_sheets_entry, 'enter_timesheet'), plugins_url( 'time-sheets/icon.png' ), $menuLocation);
add_submenu_page('time_sheets_top', 'Enter Time Sheet', 'Enter Time Sheet', 'read', 'enter_timesheet', array($time_sheets_entry, 'enter_timesheet'));
if ($timesheets_not_complete == 0) {
$tag = "Old Time Sheets";
} else {
$tag = "Old Time Sheets{$timesheets_not_complete}";
}
add_submenu_page('time_sheets_top', 'View Old Timesheets', $tag, 'read', 'search_timesheet', array($time_sheets_entry, 'search_timesheet'));
if ($client_managers->client_manager_check()==1) {
add_submenu_page('time_sheets_top', 'Manage Clients & Projects', 'Manage Clients', 'read', 'timesheet_manage_clients', array($time_sheets_manage_projects, 'main'));
}
if ($queue_approval->employee_approver_check('true')!=0) {
$vcount_pending_approval = $queue_approval->count_pending_approval();
if ($vcount_pending_approval->Embargoed != 0) {
$embargo_value = "/{$vcount_pending_approval->Embargoed}";
}
if ($vcount_pending_approval->NotRetainer+$vcount_pending_approval->Retainer != 0) {
$tag = "Approval Queue{$vcount_pending_approval->NotRetainer}/{$vcount_pending_approval->Retainer}{$embargo_value}";
} else {
$tag = "Approval Queue";
}
add_submenu_page('time_sheets_top', 'Approvel Queue', $tag, 'read', 'approve_timesheet', array($queue_approval, 'approve_timesheet'));
}
if ($queue_invoice->employee_invoicer_check()!=0) {
$vcount_pending_invoicing = $queue_invoice->count_pending_invoice();
if ($vcount_pending_invoicing->NotRetainer+$vcount_pending_invoicing->Retainer != 0) {
$tag = "Invoice Queue{$vcount_pending_invoicing->NotRetainer}/{$vcount_pending_invoicing->Retainer}";
} else {
$tag = "Invoice Queue";
}
add_submenu_page('time_sheets_top', 'Invoice Queue', $tag, 'read', 'invoice_timesheet', array($queue_invoice, 'invoice_timesheet'));
}
if ($queue_payroll->employee_payroll_check()!=0) {
$vcount_pending_payroll = $queue_payroll->count_pending_payroll();
if ($vcount_pending_payroll != 0) {
$tag = "Payroll Queue{$vcount_pending_payroll}";
} else {
$tag = "Payroll Queue";
}
add_submenu_page('time_sheets_top', 'Payroll Queue', $tag, 'read', 'payroll_timesheet', array($queue_payroll, 'payroll_timesheet'));
add_submenu_page('time_sheets_top', 'Employees Who Always Are Sent to Payroll for Processing', 'Force Payroll Setup', 'read', 'employees_allways_to_payroll', array($time_sheets_settings, 'employees_allways_to_payroll'));
}
add_submenu_page('time_sheets_top', 'Manage Approvers', 'Manage Approvers', 'manage_options', 'time_sheets_manage_approvers', array($time_sheets_settings, 'manage_approvers'));
add_submenu_page('time_sheets_top', 'Manage Employees Who Process Invoices', 'Manage Invoicers', 'manage_options', 'time_sheets_manage_invoicers', array($time_sheets_settings, 'manage_invoicers'));
add_submenu_page('time_sheets_top', 'Manage Payroll Processors', 'Manage Payroll', 'manage_options', 'time_sheets_manage_payroll', array($time_sheets_settings, 'manage_payrollers'));
add_submenu_page('time_sheets_top', 'Manage Client Managers', 'Manage Client Managers', 'manage_options', 'time_sheets_client_managers', array($client_managers, 'manage_client_managers'));
if ($queue_approval->employee_approver_check('false')!=0) {
add_submenu_page('time_sheets_top', 'Setup Approval Teams', 'Setup Approval Teams', 'read', 'setup_approval_teams', array($time_sheets_settings, 'setup_approval_teams'));
}
add_submenu_page('time_sheets_top', 'Time Sheet Global Settings', 'Global Settings', 'manage_options', 'time_sheets_settings', array($time_sheets_settings, 'show_settings_page'));
add_submenu_page('time_sheets_top', 'My Settings', 'My Settings', 'read', 'my_settings', array($my, 'main'));
//If the customer has requested custom menus they'll be shown here.
if (DEFINED('time_sheet_custom')) {
$custom = new time_sheets_custom();
$custom->custom_menu();
}
}
function init_settings(){
$settings = new time_sheets_settings();
$settings->register_settings();
}
function footer() {
$options=get_option('time_sheets');
$time_sheets_main = new time_sheets_main();
if (!$options['hide_dcac_ad']) {
add_filter('admin_footer_text', array($time_sheets_main, 'show_footer'));
add_filter( 'update_footer', array($time_sheets_main, 'show_footer_version'));
} #else {
# remove_filter('admin_footer_text', array($time_sheets_main, 'show_footer'));
# remove_filter( 'update_footer', array($time_sheets_main, 'show_footer_version'));
#}
if (get_site_option('time_sheet_license_valid', -1) != 1) {
add_filter('admin_footer_text', array($time_sheets_main, 'show_license_error'));
} #else {
# remove_filter('admin_footer_text', array($time_sheets_main, 'show_license_error'));
#}
}
function show_footer() {
echo '';
}
function show_license_error() {
echo '