getCurrentCompanyObject()->getProductEdition(); $retarr = []; switch ( $name ) { case 'dashlets': $retarr = []; //News $retarr['news'] = TTi18n::getText( 'News' ); if ( $this->getPermissionObject()->Check( 'punch', 'enabled' ) && $this->getPermissionObject()->Check( 'punch', 'view_own' ) ) { $retarr['exception_summary'] = TTi18n::getText( 'Exceptions' ); //Current/Last week, Own $retarr['timesheet_summary'] = TTi18n::getText( 'TimeSheet Summary' ); //Current/Last week, Own if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_timesheet_summary' ) ) { $retarr['timesheet_verification_summary'] = TTi18n::getText( 'TimeSheet Verifications' ); //Own } } if ( $this->getPermissionObject()->Check( 'punch', 'enabled' ) && ( $this->getPermissionObject()->Check( 'punch', 'view_child' ) || $this->getPermissionObject()->Check( 'punch', 'view' ) ) ) { $retarr['exception_summary_child'] = TTi18n::getText( 'Exceptions (Subordinates)' ); //Current/Last week, Subordinates/All if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_timesheet_summary' ) ) { $retarr['timesheet_verification_summary_child'] = TTi18n::getText( 'TimeSheet Verifications (Subordinates)' ); //Subordinates/All } } if ( $this->getPermissionObject()->Check( 'request', 'enabled' ) && $this->getPermissionObject()->Check( 'request', 'view_own' ) ) { $retarr['request_summary'] = TTi18n::getText( 'Requests' ); //Current/Last week, Own } if ( $this->getPermissionObject()->Check( 'request', 'enabled' ) && ( $this->getPermissionObject()->Check( 'request', 'authorize' ) ) ) { $retarr['request_authorize_summary'] = TTi18n::getText( 'Request Authorizations' ); //Subordinates } if ( $this->getPermissionObject()->Check( 'message', 'enabled' ) && $this->getPermissionObject()->Check( 'message', 'view_own' ) ) { $retarr['message_summary'] = TTi18n::getText( 'Messages (UnRead)' ); //Own } if ( $this->getPermissionObject()->Check( 'accrual', 'enabled' ) && $this->getPermissionObject()->Check( 'accrual', 'view_own' ) ) { $retarr['accrual_balance_summary'] = TTi18n::getText( 'Accrual Balances' ); //Own } if ( $product_edition >= 25 ) { if ( $this->getPermissionObject()->Check( 'expense', 'enabled' ) && $this->getPermissionObject()->Check( 'expense', 'view_own' ) ) { $retarr['expense_summary'] = TTi18n::getText( 'Expenses' ); //Current/Last week, Own } if ( $this->getPermissionObject()->Check( 'expense', 'enabled' ) && ( $this->getPermissionObject()->Check( 'expense', 'authorize' ) ) ) { $retarr['expense_authorize_summary'] = TTi18n::getText( 'Expense Authorizations' ); //Subordinates } } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_active_shift' ) ) { //Don't check punch/user permissions, as the ActiveShift report itself does not do that. $retarr['user_active_shift_summary'] = TTi18n::getText( 'Whos In/Out' ); //Subordinates/All } if ( $this->getPermissionObject()->Check( 'schedule', 'enabled' ) ) { if ( $this->getPermissionObject()->Check( 'schedule', 'view_own' ) ) { $retarr['schedule_summary'] = TTi18n::getText( 'Schedule Summary' ); //Own } if ( $this->getPermissionObject()->Check( 'schedule', 'view_child' ) || $this->getPermissionObject()->Check( 'schedule', 'view' ) ) { $retarr['schedule_summary_child'] = TTi18n::getText( 'Schedule Summary (Subordinates)' ); //Own } } asort( $retarr ); //Put Custom List/Custom Report at the bottom always. if ( $product_edition > 10 ) { $retarr['custom_list'] = TTi18n::getText( 'Custom List' ); //Saved Search & Layout $retarr['custom_report'] = TTi18n::getText( 'Custom Report' ); //Report, Report Template/Saved Report } $retarr = Misc::addSortPrefix( $retarr ); break; case 'custom_list': $retarr = []; //Attendance if ( $this->getPermissionObject()->Check( 'punch', 'enabled' ) && ( $this->getPermissionObject()->Check( 'punch', 'view_own' ) || $this->getPermissionObject()->Check( 'punch', 'view_child' ) || $this->getPermissionObject()->Check( 'punch', 'view' ) ) ) { $retarr['Exception'] = TTi18n::getText( 'Exceptions' ); } if ( $this->getPermissionObject()->Check( 'accrual', 'enabled' ) && ( $this->getPermissionObject()->Check( 'accrual', 'view_own' ) || $this->getPermissionObject()->Check( 'accrual', 'view_child' ) || $this->getPermissionObject()->Check( 'accrual', 'view' ) ) ) { $retarr['AccrualBalance'] = TTi18n::getText( 'Accrual Balances' ); } if ( $this->getPermissionObject()->Check( 'accrual', 'enabled' ) && ( $this->getPermissionObject()->Check( 'accrual', 'view_own' ) || $this->getPermissionObject()->Check( 'accrual', 'view_child' ) || $this->getPermissionObject()->Check( 'accrual', 'view' ) ) ) { $retarr['Accrual'] = TTi18n::getText( 'Accruals' ); } if ( $this->getPermissionObject()->Check( 'schedule', 'enabled' ) && ( $this->getPermissionObject()->Check( 'schedule', 'view_own' ) || $this->getPermissionObject()->Check( 'schedule', 'view_child' ) || $this->getPermissionObject()->Check( 'schedule', 'view' ) ) ) { $retarr['Schedule'] = TTi18n::getText( 'Scheduled Shifts' ); } if ( $this->getPermissionObject()->Check( 'recurring_schedule', 'enabled' ) && ( $this->getPermissionObject()->Check( 'recurring_schedule', 'view_own' ) || $this->getPermissionObject()->Check( 'recurring_schedule', 'view_child' ) || $this->getPermissionObject()->Check( 'recurring_schedule', 'view' ) ) ) { $retarr['RecurringScheduleControl'] = TTi18n::getText( 'Recurring Schedules' ); } if ( $this->getPermissionObject()->Check( 'recurring_schedule_template', 'enabled' ) && ( $this->getPermissionObject()->Check( 'recurring_schedule_template', 'view_own' ) || $this->getPermissionObject()->Check( 'recurring_schedule_template', 'view_child' ) || $this->getPermissionObject()->Check( 'recurring_schedule_template', 'view' ) ) ) { $retarr['RecurringScheduleTemplateControl'] = TTi18n::getText( 'Recurring Templates' ); } if ( $product_edition >= 20 ) { if ( $this->getPermissionObject()->Check( 'job', 'enabled' ) && ( $this->getPermissionObject()->Check( 'job', 'view_own' ) || $this->getPermissionObject()->Check( 'job', 'view_child' ) || $this->getPermissionObject()->Check( 'job', 'view' ) ) ) { $retarr['Job'] = TTi18n::getText( 'Jobs' ); } if ( $this->getPermissionObject()->Check( 'job_item', 'enabled' ) && ( $this->getPermissionObject()->Check( 'job_item', 'view_own' ) || $this->getPermissionObject()->Check( 'job_item', 'view_child' ) || $this->getPermissionObject()->Check( 'job_item', 'view' ) ) ) { $retarr['JobItem'] = TTi18n::getText( 'Tasks' ); } } //Employee if ( $this->getPermissionObject()->Check( 'user', 'enabled' ) && ( $this->getPermissionObject()->Check( 'user', 'view_own' ) || $this->getPermissionObject()->Check( 'user', 'view_child' ) || $this->getPermissionObject()->Check( 'user', 'view' ) ) ) { $retarr['User'] = TTi18n::getText( 'Employees' ); } if ( $this->getPermissionObject()->Check( 'user_contact', 'enabled' ) && ( $this->getPermissionObject()->Check( 'user_contact', 'view_own' ) || $this->getPermissionObject()->Check( 'user_contact', 'view_child' ) || $this->getPermissionObject()->Check( 'user_contact', 'view' ) ) ) { $retarr['UserContact'] = TTi18n::getText( 'Employee Contacts' ); } if ( $this->getPermissionObject()->Check( 'wage', 'enabled' ) && ( $this->getPermissionObject()->Check( 'wage', 'view_own' ) || $this->getPermissionObject()->Check( 'wage', 'view_child' ) || $this->getPermissionObject()->Check( 'wage', 'view' ) ) ) { $retarr['UserWage'] = TTi18n::getText( 'Wages' ); } //Company //Payroll if ( $this->getPermissionObject()->Check( 'pay_stub', 'enabled' ) && ( $this->getPermissionObject()->Check( 'pay_stub', 'view_own' ) || $this->getPermissionObject()->Check( 'pay_stub', 'view_child' ) || $this->getPermissionObject()->Check( 'pay_stub', 'view' ) ) ) { $retarr['PayStub'] = TTi18n::getText( 'Pay Stubs' ); } if ( $this->getPermissionObject()->Check( 'pay_period', 'enabled' ) && ( $this->getPermissionObject()->Check( 'pay_period', 'view_own' ) || $this->getPermissionObject()->Check( 'pay_period', 'view_child' ) || $this->getPermissionObject()->Check( 'pay_period', 'view' ) ) ) { $retarr['PayPeriod'] = TTi18n::getText( 'Pay Periods' ); } if ( $this->getPermissionObject()->Check( 'pay_stub_amendment', 'enabled' ) && ( $this->getPermissionObject()->Check( 'pay_stub_amendment', 'view_own' ) || $this->getPermissionObject()->Check( 'pay_stub_amendment', 'view_child' ) || $this->getPermissionObject()->Check( 'pay_stub_amendment', 'view' ) ) ) { $retarr['PayStubAmendment'] = TTi18n::getText( 'Pay Stub Amendments' ); } if ( $product_edition >= 25 && $this->getPermissionObject()->Check( 'user_expense', 'enabled' ) && ( $this->getPermissionObject()->Check( 'user_expense', 'view_own' ) || $this->getPermissionObject()->Check( 'user_expense', 'view_child' ) || $this->getPermissionObject()->Check( 'user_expense', 'view' ) ) ) { $retarr['UserExpense'] = TTi18n::getText( 'Expenses' ); } //Invoice if ( $product_edition >= 20 ) { if ( $this->getPermissionObject()->Check( 'client', 'enabled' ) && ( $this->getPermissionObject()->Check( 'client', 'view_own' ) || $this->getPermissionObject()->Check( 'client', 'view_child' ) || $this->getPermissionObject()->Check( 'client', 'view' ) ) ) { $retarr['Client'] = TTi18n::getText( 'Clients' ); } if ( $this->getPermissionObject()->Check( 'client_contact', 'enabled' ) && ( $this->getPermissionObject()->Check( 'client_contact', 'view_own' ) || $this->getPermissionObject()->Check( 'client_contact', 'view_child' ) || $this->getPermissionObject()->Check( 'client_contact', 'view' ) ) ) { $retarr['ClientContact'] = TTi18n::getText( 'Client Contacts' ); } if ( $this->getPermissionObject()->Check( 'invoice', 'enabled' ) && ( $this->getPermissionObject()->Check( 'invoice', 'view_own' ) || $this->getPermissionObject()->Check( 'invoice', 'view_child' ) || $this->getPermissionObject()->Check( 'invoice', 'view' ) ) ) { $retarr['Invoice'] = TTi18n::getText( 'Invoices' ); } if ( $this->getPermissionObject()->Check( 'invoice', 'enabled' ) && ( $this->getPermissionObject()->Check( 'invoice', 'view_own' ) || $this->getPermissionObject()->Check( 'invoice', 'view_child' ) || $this->getPermissionObject()->Check( 'invoice', 'view' ) ) ) { $retarr['Transaction'] = TTi18n::getText( 'Invoice Transactions' ); } } //HR if ( $this->getPermissionObject()->Check( 'user_review', 'enabled' ) && ( $this->getPermissionObject()->Check( 'user_review', 'view_own' ) || $this->getPermissionObject()->Check( 'user_review', 'view_child' ) || $this->getPermissionObject()->Check( 'user_review', 'view' ) ) ) { $retarr['UserReviewControl'] = TTi18n::getText( 'Reviews' ); } if ( $product_edition >= 25 ) { if ( $this->getPermissionObject()->Check( 'job_vacancy', 'enabled' ) && ( $this->getPermissionObject()->Check( 'job_vacancy', 'view_own' ) || $this->getPermissionObject()->Check( 'job_vacancy', 'view_child' ) || $this->getPermissionObject()->Check( 'job_vacancy', 'view' ) ) ) { $retarr['JobVacancy'] = TTi18n::getText( 'Job Vacancies' ); } if ( $this->getPermissionObject()->Check( 'job_applicant', 'enabled' ) && ( $this->getPermissionObject()->Check( 'job_applicant', 'view_own' ) || $this->getPermissionObject()->Check( 'job_applicant', 'view_child' ) || $this->getPermissionObject()->Check( 'job_applicant', 'view' ) ) ) { $retarr['JobApplicant'] = TTi18n::getText( 'Job Applicants' ); } if ( $this->getPermissionObject()->Check( 'job_application', 'enabled' ) && ( $this->getPermissionObject()->Check( 'job_application', 'view_own' ) || $this->getPermissionObject()->Check( 'job_application', 'view_child' ) || $this->getPermissionObject()->Check( 'job_application', 'view' ) ) ) { $retarr['JobApplication'] = TTi18n::getText( 'Job Applications' ); } } //My Account if ( $this->getPermissionObject()->Check( 'request', 'enabled' ) && ( $this->getPermissionObject()->Check( 'request', 'view_own' ) || $this->getPermissionObject()->Check( 'request', 'view_child' ) || $this->getPermissionObject()->Check( 'request', 'view' ) ) ) { $retarr['Request'] = TTi18n::getText( 'Requests' ); } // Expenses is already added above. //My Account -> Authorization related views. if ( $this->getPermissionObject()->Check( 'request', 'enabled' ) && $this->getPermissionObject()->Check( 'request', 'authorize' ) && ( $this->getPermissionObject()->Check( 'request', 'view_child' ) || $this->getPermissionObject()->Check( 'request', 'view' ) ) ) { $retarr['Request-Authorization'] = TTi18n::getText( 'Request Authorization' ); } if ( $this->getPermissionObject()->Check( 'punch', 'enabled' ) && $this->getPermissionObject()->Check( 'punch', 'verify_time_sheet' ) && ( $this->getPermissionObject()->Check( 'punch', 'view_child' ) || $this->getPermissionObject()->Check( 'punch', 'view' ) ) ) { $retarr['PayPeriodTimeSheetVerify'] = TTi18n::getText( 'TimeSheet Verification' ); } if ( $product_edition >= 25 && $this->getPermissionObject()->Check( 'user_expense', 'enabled' ) && $this->getPermissionObject()->Check( 'user_expense', 'authorize' ) && ( $this->getPermissionObject()->Check( 'user_expense', 'view_child' ) || $this->getPermissionObject()->Check( 'user_expense', 'view' ) ) ) { $retarr['UserExpense-Authorization'] = TTi18n::getText( 'Expense Verification' ); } asort( $retarr ); $retarr = Misc::addSortPrefix( $retarr ); break; case 'custom_report': $retarr = []; //Employee Reports if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_user_information' ) ) { $retarr['UserSummaryReport'] = TTi18n::getText( 'Employee Information' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_active_shift' ) ) { $retarr['ActiveShiftReport'] = TTi18n::getText( 'Whos In Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_system_log' ) ) { $retarr['AuditTrailReport'] = TTi18n::getText( 'Audit Trail' ); } //TimeSheet Reports if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_schedule_summary' ) ) { $retarr['ScheduleSummaryReport'] = TTi18n::getText( 'Schedule Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_timesheet_summary' ) ) { $retarr['TimesheetSummaryReport'] = TTi18n::getText( 'TimeSheet Summary' ); $retarr['TimesheetDetailReport'] = TTi18n::getText( 'TimeSheet Detail' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_punch_summary' ) ) { $retarr['PunchSummaryReport'] = TTi18n::getText( 'Punch Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_accrual_balance_summary' ) ) { $retarr['AccrualBalanceSummaryReport'] = TTi18n::getText( 'Accrual Balance Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_exception_summary' ) ) { $retarr['ExceptionReport'] = TTi18n::getText( 'Exception Summary' ); } //Payroll Reports if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_pay_stub_summary' ) ) { $retarr['PayStubSummaryReport'] = TTi18n::getText( 'Pay Stub Summary' ); } if ( $product_edition >= 25 && $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_expense' ) ) { $retarr['UserExpenseReport'] = TTi18n::getText( 'Expense Summary' ); } //Job Tracking Reports if ( $product_edition >= 20 ) { if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'job_report', 'view_job_summary' ) ) { $retarr['JobSummaryReport'] = TTi18n::getText( 'Job Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'job_report', 'view_job_analysis' ) ) { $retarr['JobDetailReport'] = TTi18n::getText( 'Job Analysis' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'job_report', 'view_job_summary' ) ) { $retarr['JobInformationReport'] = TTi18n::getText( 'Job Information' ); $retarr['JobItemInformationReport'] = TTi18n::getText( 'Task Information' ); } } //Invoice Reports if ( $product_edition >= 20 ) { if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'report', 'view_transaction_summary' ) ) { $retarr['InvoiceTransactionSummaryReport'] = TTi18n::getText( 'Transaction Summary' ); } } //HR Reports if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'hr_report', 'user_qualification' ) ) { $retarr['UserQualificationReport'] = TTi18n::getText( 'Qualification Summary' ); } if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'hr_report', 'user_review' ) ) { $retarr['KPIReport'] = TTi18n::getText( 'Review Summary' ); } //HR-Recruitment Reports if ( $product_edition >= 25 ) { if ( $this->getPermissionObject()->Check( 'report', 'enabled' ) && $this->getPermissionObject()->Check( 'recruitment_report', 'user_recruitment' ) ) { $retarr['UserRecruitmentSummaryReport'] = TTi18n::getText( 'Recruitment Summary' ); $retarr['UserRecruitmentDetailReport'] = TTi18n::getText( 'Recruitment Detail' ); } } asort( $retarr ); $retarr = Misc::addSortPrefix( $retarr ); break; case 'auto_refresh': $retarr = [ 0 => TTi18n::getText( 'Disabled' ), 300 => TTi18n::getText( '5 mins' ), 600 => TTi18n::getText( '10 mins' ), 900 => TTi18n::getText( '15 mins' ), 1800 => TTi18n::getText( '30 mins' ), 3600 => TTi18n::getText( '1 hour' ), 7200 => TTi18n::getText( '2 hours' ), 10800 => TTi18n::getText( '3 hours' ), 21600 => TTi18n::getText( '6 hours' ), ]; if ( PRODUCTION == false ) { //Shorter time for testing. $retarr[30] = TTi18n::getText( '30 seconds' ); } break; } return $retarr; } /** * Create filter base on user generic data * @param string $view_name the view name * @param array $user_generic_data user generic data * @param $rows_per_page * @return array */ function buildFilterParameters( $view_name, $user_generic_data, $rows_per_page ) { $parameters = []; $parameters['filter_columns'] = []; // Always return id column in case we may need it. $parameters['filter_columns']['id'] = true; // If $user_generic_data set filter_data, convert it to api filter_data format. if ( isset( $user_generic_data['filter_data'] ) ) { $parameters['filter_data'] = []; foreach ( $user_generic_data['filter_data'] as $key => $value ) { if ( is_array( $value['value'] ) ) { $values = []; foreach ( $value['value'] as $i => $item ) { if ( isset( $item['value'] ) ) { // saved options $values[] = $item['value']; } else { if ( isset( $item['id'] ) ) { // saved awesomebox $values[] = $item['id']; } else { $values[] = $item; } } } $parameters['filter_data'][$key] = $values; } else { $parameters['filter_data'][$key] = $value['value']; } } } // Add default filter for some views. if ( $view_name == 'Request-Authorization' ) { if ( !isset( $parameters['filter_data'] ) ) { $parameters['filter_data'] = []; } if ( !isset( $parameters['filter_data']['type_id'] ) ) { $parameters['filter_data']['type_id'] = [ -1 ]; } if ( !isset( $parameters['filter_data']['hierarchy_level'] ) ) { $parameters['filter_data']['hierarchy_level'] = 1; } } else { if ( $view_name == 'PayPeriodTimeSheetVerify' ) { if ( !isset( $parameters['filter_data'] ) ) { $parameters['filter_data'] = []; } if ( !isset( $parameters['filter_data']['hierarchy_level'] ) ) { $parameters['filter_data']['hierarchy_level'] = 1; } } else { if ( $view_name == 'UserExpense-Authorization' ) { if ( !isset( $parameters['filter_data'] ) ) { $parameters['filter_data'] = []; } $parameters['filter_data']['parent_id'] = [ TTUUID::getZeroID() ]; if ( !isset( $parameters['filter_data']['hierarchy_level'] ) ) { $parameters['filter_data']['hierarchy_level'] = 1; } } } } // filter_sort in user generic data is same format as api need. if ( isset( $user_generic_data['filter_sort'] ) ) { $parameters['filter_sort'] = $user_generic_data['filter_sort']; } if ( isset( $user_generic_data['display_columns'] ) ) { for ( $i = 0; $i < count( $user_generic_data['display_columns'] ); $i++ ) { $parameters['filter_columns'][$user_generic_data['display_columns'][$i]] = true; } } $parameters['filter_items_per_page'] = $rows_per_page; return $parameters; } /** * @param $display_columns * @param $rows_per_page * @return array */ function buildDefaultDashletParameters( $display_columns, $rows_per_page ) { $parameters = []; $parameters['filter_columns'] = []; $parameters['filter_columns']['id'] = true; if ( is_array( $display_columns ) ) { for ( $i = 0; $i < count( $display_columns ); $i++ ) { $parameters['filter_columns'][$display_columns[$i]] = true; } } $parameters['filter_items_per_page'] = $rows_per_page; return $parameters; } /** * Get data for specific datalet * @param string $name name of dashlet * @param bool $data * @return array * @internal param array $params parameters for returning dashlet data */ function getDashletData( $name, $data = false ) { $name = strtolower( $name ); $display_columns = null; Debug::Text( 'Name: ' . $name, __FILE__, __LINE__, __METHOD__, 10 ); switch ( $name ) { case 'news': $retarr = []; $current_epoch = time(); //$product_edition = $this->getCurrentCompanyObject()->getProductEdition(); //$permission = new Permission(); //$permission_level = $permission->getLevel( $this->getCurrentUserObject()->getId(), $this->getCurrentCompanyObject()->getId() ); //Notify user of new features. //if ( Misc::MajorVersionCompare( APPLICATION_VERSION, '9.0.0', '=' ) && TTDate::getBeginDayEpoch( $this->getCurrentUserObject()->getLastLoginDate() ) <= APPLICATION_VERSION_DATE ) { // $retarr[] = '*' . TTi18n::getText( 'Tip' ) . ': ' . TTi18n::getText( 'You can set the default screen that appears after login under MyAccount -> Preferences in the menu along the top of the screen.' ); //} // //if ( $product_edition > 10 && $permission_level >= 40 && Misc::MajorVersionCompare( APPLICATION_VERSION, '9.0.0', '=' ) && TTDate::getBeginDayEpoch( $this->getCurrentUserObject()->getLastLoginDate() ) <= APPLICATION_VERSION_DATE ) { // $retarr[] = '*' . TTi18n::getText( 'Tip' ) . ': ' . TTi18n::getText( 'You can add your own custom reports to the dashboard by clicking the Add Dashlet icon at the top left.' ); //} // //Regular Employee Related news: // if ( ( $this->getPermissionObject()->Check( 'punch', 'enabled' ) && ( $this->getPermissionObject()->Check( 'punch', 'view_own' ) || $this->getPermissionObject()->Check( 'punch', 'punch_in_out' ) ) ) ) { //Exceptions are only viewable if they permissions to punch in/out. // Check for critical severity exceptions $elf = TTNew( 'ExceptionListFactory' ); /** @var ExceptionListFactory $elf */ $elf->getFlaggedExceptionsByUserIdAndPayPeriodStatus( $this->getCurrentUserObject()->getId(), 10 ); if ( $elf->getRecordCount() > 0 ) { foreach ( $elf as $e_obj ) { if ( $e_obj->getColumn( 'severity_id' ) == 30 ) { $retarr[] = TTi18n::getText( 'Critical severity exceptions exist, you may want to take a look at those.' ); } break; } } unset( $elf, $e_obj ); } // Check for recent unread messages $api = TTNew( 'APIMessageControl' ); /** @var APIMessageControl $api */ $api_result = $this->stripReturnHandler( $api->getMessageControl( [ 'filter_data' => [ 'status_id' => 10, 'folder_id' => 10 ] ] ) ); if ( is_array( $api_result ) && count( $api_result ) > 0 ) { foreach ( $api_result as $message_data ) { $retarr[] = TTi18n::getText( 'UnRead message sent from %1 on %2.', [ $message_data['from_first_name'] . ' ' . $message_data['from_last_name'], TTDate::getDate( 'DATE', TTDate::parseDateTime( $message_data['created_date'] ) ) ] ); break; } } unset( $api_result, $message_data ); // Check for timesheet verifications $ppslf = TTNew( 'PayPeriodScheduleListFactory' ); /** @var PayPeriodScheduleListFactory $ppslf */ $ppslf->getByUserId( $this->getCurrentUserObject()->getId() ); if ( $ppslf->getRecordCount() > 0 ) { foreach ( $ppslf as $pps_obj ) { if ( in_array( $pps_obj->getTimeSheetVerifyType(), [ 20, 40 ] ) ) { //Check if TimeSheet Verification is enabled or not. $pplf = TTNew( 'PayPeriodListFactory' ); /** @var PayPeriodListFactory $pplf */ $pplf->getThisPayPeriodByCompanyIdAndPayPeriodScheduleIdAndDate( $pps_obj->getCompany(), [ $pps_obj->getId() ], $current_epoch ); if ( $pplf->getRecordCount() > 0 ) { foreach ( $pplf as $pp_obj ) { Debug::Text( 'Pay Period ID: ' . $pp_obj->getId() . ' PP Schedule ID: ' . $pps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10 ); $pptsvlf = TTnew( 'PayPeriodTimeSheetVerifyListFactory' ); /** @var PayPeriodTimeSheetVerifyListFactory $pptsvlf */ $pptsvlf->getByPayPeriodIdAndUserId( $pp_obj->getId(), $this->getCurrentUserObject()->getId() ); if ( $pptsvlf->getRecordCount() > 0 ) { $pptsv_obj = $pptsvlf->getCurrent(); $pptsv_obj->setCurrentUser( $this->getCurrentUserObject()->getId() ); } else { $pptsv_obj = $pptsvlf; $pptsv_obj->setCurrentUser( $this->getCurrentUserObject()->getId() ); $pptsv_obj->setUser( $this->getCurrentUserObject()->getId() ); $pptsv_obj->setPayPeriod( $pp_obj->getId() ); } $verification_window_dates = $pptsv_obj->getVerificationWindowDates(); Debug::Arr( [ $pptsv_obj->getPayPeriodObject()->data, $verification_window_dates ], ' Verification Dates: ', __FILE__, __LINE__, __METHOD__, 10 ); //Only display messages if the timesheet isn't already verified. if ( $pptsv_obj->displayVerifyButton( $this->getCurrentUserObject()->getId(), $this->getCurrentUserObject()->getId() ) == true ) { $retarr[] = TTi18n::getText( 'Timesheet verification required by %2', [ TTDate::getDate( 'DATE', $verification_window_dates['start'] ), TTDate::getDate( 'DATE', $verification_window_dates['end'] ) ] ); } else { Debug::Text( 'TimeSheet Verification is not required or already done...', __FILE__, __LINE__, __METHOD__, 10 ); } } unset( $pptsvlf, $pptsv_obj, $verification_window_dates ); } else { Debug::Text( 'No Pay Periods found for PP Schedule ID: ' . $pps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10 ); } } else { Debug::Text( 'TimeSheet Verification is not enabled...', __FILE__, __LINE__, __METHOD__, 10 ); } } } unset( $ppslf, $pps_obj, $pplf, $pp_obj ); // Check for requests that changed status. $rlf = TTNew( 'RequestListFactory' ); /** @var RequestListFactory $rlf */ $rlf->getAPISearchByCompanyIdAndArrayCriteria( $this->getCurrentUserObject()->getCompany(), [ 'user_id' => $this->getCurrentUserObject()->getId(), 'status_id' => [ 50, 55 ], 'updated_date_start' => ( TTDate::getBeginDayEpoch( $current_epoch ) - ( 86400 * 2 ) ), 'updated_date_end' => TTDate::getEndDayEpoch( $current_epoch ) ] ); if ( $rlf->getRecordCount() > 0 ) { foreach ( $rlf as $r_obj ) { if ( $r_obj->getStatus() == 50 ) { $retarr[] = TTi18n::getText( 'A request has recently been authorized.' ); } else if ( $r_obj->getStatus() == 55 ) { $retarr[] = TTi18n::getText( 'A request has recently been declined.' ); } break; } } unset( $rlf, $r_obj ); // Check for upcoming scheduled absences $api = TTNew( 'APISchedule' ); /** @var APISchedule $api */ $api_result = $this->stripReturnHandler( $api->getCombinedSchedule( [ 'filter_data' => [ 'status_id' => 20, 'include_user_id' => [ $this->getCurrentUserObject()->getId() ] ] ], TTDate::getDate( 'DATE', $current_epoch ), 'week', false ) ); if ( isset( $api_result['schedule_data'] ) ) { foreach ( $api_result['schedule_data'] as $date => $schedule_data ) { $retarr[] = TTi18n::getText( 'Upcoming %1 absence scheduled for %2.', [ $schedule_data[0]['absence_policy'], TTDate::getDate( 'DATE', strtotime( $date ) ) ] ); break; } } unset( $api_result, $schedule_data, $date ); // Check for recent pay stubs. $api = TTNew( 'APIPayStub' ); /** @var APIPayStub $api */ $api_result = $this->stripReturnHandler( $api->getPayStub( [ 'filter_data' => [ 'status_id' => 40, 'include_user_id' => [ $this->getCurrentUserObject()->getId() ], 'start_date' => TTDate::getBeginDayEpoch( $current_epoch - ( 86400 * 2 ) ), 'end_date' => TTDate::getEndDayEpoch( $current_epoch + ( 86400 * 5 ) ) ] ], false ) ); if ( is_array( $api_result ) && count( $api_result ) > 0 ) { foreach ( $api_result as $pay_stub_data ) { $retarr[] = TTi18n::getText( 'Pay stub scheduled to be paid on %1 is now available.', [ $pay_stub_data['transaction_date'] ] ); break; } } unset( $api_result, $pay_stub_data ); // Check for Pay Periods nearing end date or transaction date $pplf = TTNew( 'PayPeriodListFactory' ); /** @var PayPeriodListFactory $pplf */ $pplf->getByUserIdAndTransactionDate( $this->getCurrentUserObject()->getId(), $current_epoch ); if ( $pplf->getRecordCount() > 0 ) { foreach ( $pplf as $pp_obj ) { $pay_period_end_diff = ( $pp_obj->getEndDate() - $current_epoch ); $pay_period_transaction_diff = ( $pp_obj->getTransactionDate() - $current_epoch ); if ( $pay_period_end_diff > 0 && $pay_period_end_diff < ( 86400 * 2 ) ) { $retarr[] = TTi18n::getText( 'Current pay period ends on %1, will be paid by %2', [ TTDate::getDate( 'DATE', $pp_obj->getEndDate() ), TTDate::getDate( 'DATE', $pp_obj->getTransactionDate() ) ] ); } else if ( $pay_period_end_diff < 0 && $pay_period_end_diff > ( 86400 * -2 ) ) { $retarr[] = TTi18n::getText( 'Previous pay period ended on %1, will be paid by %2', [ TTDate::getDate( 'DATE', $pp_obj->getEndDate() ), TTDate::getDate( 'DATE', $pp_obj->getTransactionDate() ) ] ); } else if ( $pay_period_transaction_diff > 0 && $pay_period_transaction_diff < ( 86400 * 2 ) ) { $retarr[] = TTi18n::getText( 'Previous pay period will be paid by %2', [ TTDate::getDate( 'DATE', $pp_obj->getEndDate() ), TTDate::getDate( 'DATE', $pp_obj->getTransactionDate() ) ] ); } } } unset( $pplf, $pp_obj ); $content = ''; if ( count( $retarr ) > 0 ) { $content .= '