protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-3600-log_action_id' => TTi18n::gettext('Action'), '-3700-log_table_name_id' => TTi18n::gettext('Object'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': /*$retval = array_merge( TTDate::getReportDateOptions( 'start', TTi18n::getText('Start Date'), 16, FALSE ), TTDate::getReportDateOptions( 'end', TTi18n::getText('End Date'), 17, FALSE ) );*/ break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'AuditTrailReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'AuditTrailReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'AuditTrailReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'AuditTrailReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1010-user_name' => TTi18n::gettext('User Name'), '-1020-phone_id' => TTi18n::gettext('Quick Punch ID'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-user_status' => TTi18n::gettext('Employee Status'), '-1050-title' => TTi18n::gettext('Employee Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Employee Group'), '-1090-default_branch' => TTi18n::gettext('Branch'), '-1100-default_department' => TTi18n::gettext('Department'), '-2000-date' => TTi18n::gettext('Date'), '-2100-object' => TTi18n::gettext('Object'), '-2150-action' => TTi18n::gettext('Action'), '-2200-description' => TTi18n::gettext('Description')); //$retval = array_merge( $retval, $this->getOptions('date_columns') ); $retval = array_merge($retval, (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2500-total_log' => TTi18n::gettext('Total')); break; case 'columns': //$retval = array_merge( $this->getOptions('static_columns'), $this->getOptions('dynamic_columns') ); $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'wage') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } if (strpos($column, 'amount') !== FALSE) { $retval[$column] = 'time_unit'; } } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: $retval[$column] = 'sum'; } } } break; case 'templates': $retval = array('-1200-by_date+audit' => TTi18n::gettext('Audit By Date'), '-1210-by_employee+audit' => TTi18n::gettext('Audit By Employee'), '-1220-by_object+audit' => TTi18n::gettext('Audit By Object'), '-1230-by_action+audit' => TTi18n::gettext('Audit By Action'), '-1240-by_object_by_action_by_employee+audit_total' => TTi18n::gettext('Audit Records By Object/Action/Employee')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { $retval['-1010-time_period']['time_period'] = 'last_7_days'; //Always default to the last 7 days to keep the report small and fast. switch ($template) { case 'by_date+audit': $retval['columns'][] = 'date'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'object'; $retval['columns'][] = 'action'; $retval['columns'][] = 'description'; $retval['sort'][] = array('date' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('object' => 'asc'); $retval['sort'][] = array('action' => 'asc'); break; case 'by_employee+audit': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'date'; $retval['columns'][] = 'object'; $retval['columns'][] = 'action'; $retval['columns'][] = 'description'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date' => 'desc'); $retval['sort'][] = array('object' => 'asc'); $retval['sort'][] = array('action' => 'asc'); break; case 'by_object+audit': $retval['columns'][] = 'object'; $retval['columns'][] = 'date'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'action'; $retval['columns'][] = 'description'; $retval['sort'][] = array('object' => 'asc'); $retval['sort'][] = array('date' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('action' => 'asc'); break; case 'by_action+audit': $retval['columns'][] = 'action'; $retval['columns'][] = 'date'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'object'; $retval['columns'][] = 'description'; $retval['sort'][] = array('action' => 'asc'); $retval['sort'][] = array('date' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('object' => 'asc'); //$retval['filter']['-1050-log_action_id'] = array(); break; case 'by_object_by_action_by_employee+audit_total': $retval['columns'][] = 'object'; $retval['columns'][] = 'action'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'total_log'; $retval['group'][] = 'object'; $retval['group'][] = 'action'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'object'; $retval['sub_total'][] = 'action'; $retval['sort'][] = array('object' => 'asc'); $retval['sort'][] = array('action' => 'asc'); $retval['sort'][] = array('total_log' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = array_merge(parent::getOptions('default_output_format'), array('-1100-pdf_form' => TTi18n::gettext('Form'), '-1120-efile_xml' => TTi18n::gettext('eFile'))); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-code_id' => TTi18n::gettext('Reason'), '-2090-pay_period_type_id' => TTi18n::gettext('Pay Period Type'), '-3000-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = array_merge(TTDate::getReportDateOptions('first', TTi18n::gettext('First Day Worked(Or first day since last ROE)'), 16, FALSE), TTDate::getReportDateOptions('last', TTi18n::gettext('Last Day For Which Paid'), 16, FALSE), TTDate::getReportDateOptions('pay_period_end', TTi18n::gettext('Final Pay Period Ending Date'), 17, FALSE), TTDate::getReportDateOptions('recall', TTi18n::gettext('Expected Date of Recall'), 17, FALSE)); $retval = array(); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'ROEReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'ROEReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'ROEReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'ROEReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1035-sin' => TTi18n::gettext('SIN/SSN'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1120-code' => TTi18n::gettext('Reason'), '-1130-pay_period_type' => TTi18n::gettext('Pay Period Type'), '-1180-serial' => TTi18n::gettext('Serial No'), '-1190-comments' => TTi18n::gettext('Comments'), '-1400-permission_control' => TTi18n::gettext('Permission Group'), '-1410-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1420-policy_group' => TTi18n::gettext('Policy Group')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2100-insurable_earnings' => TTi18n::gettext('Insurable Earnings (Box 15B)'), '-2110-vacation_pay' => TTi18n::gettext('Vacation Pay (Box 17A)')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { $retval[$column] = 'numeric'; } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: $retval[$column] = 'sum'; } } } break; case 'type': $retval = array('-1010-O' => TTi18n::getText('Original'), '-1020-A' => TTi18n::getText('Amended'), '-1030-C' => TTi18n::getText('Cancel')); break; case 'templates': $retval = array('-1020-by_employee' => TTi18n::gettext('by Employee'), '-1030-by_branch' => TTi18n::gettext('by Branch'), '-1040-by_department' => TTi18n::gettext('by Department'), '-1050-by_branch_by_department' => TTi18n::gettext('by Branch/Department')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'default': //Proper settings to generate the form. //$retval['-1010-time_period']['time_period'] = 'last_quarter'; $retval['columns'] = $this->getOptions('columns'); $retval['group'][] = 'date_quarter_month'; $retval['sort'][] = array('date_quarter_month' => 'asc'); $retval['other']['grand_total'] = TRUE; break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_year'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns //Filter //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; } } } $retval['columns'] = array_merge($retval['columns'], array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns')))); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
function Validate() { if ($this->getCalculation() == 69) { $valid_formula = TTMath::ValidateFormula(TTMath::translateVariables($this->getCompanyValue1(), TTMath::clearVariables(Misc::trimSortPrefix($this->getOptions('formula_variables'))))); if ($valid_formula != FALSE) { $this->Validator->isTrue('company_value1', FALSE, implode("\n", $valid_formula)); } } return TRUE; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = array_merge(parent::getOptions('default_output_format'), array('-1100-pdf_form' => TTi18n::gettext('Employee (One Employee/Page)'), '-1110-pdf_form_government' => TTi18n::gettext('Government (Multiple Employees/Page)'), '-1120-efile' => TTi18n::gettext('eFile'))); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-4020-exclude_ytd_adjustment' => TTi18n::gettext('Exclude YTD Adjustments'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': //$retval = TTDate::getReportDateOptions( NULL, TTi18n::getText('Date'), 13, TRUE ); $retval = array(); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'FormW2Report', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'FormW2Report', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'FormW2Report', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'FormW2Report', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1035-sin' => TTi18n::gettext('SIN/SSN'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1080-group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1400-permission_control' => TTi18n::gettext('Permission Group'), '-1410-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1420-policy_group' => TTi18n::gettext('Policy Group'), '-1510-address1' => TTi18n::gettext('Address 1'), '-1512-address2' => TTi18n::gettext('Address 2'), '-1520-city' => TTi18n::gettext('City'), '-1522-province' => TTi18n::gettext('Province/State'), '-1524-country' => TTi18n::gettext('Country'), '-1526-postal_code' => TTi18n::gettext('Postal Code'), '-1530-work_phone' => TTi18n::gettext('Work Phone'), '-1540-work_phone_ext' => TTi18n::gettext('Work Phone Ext'), '-1550-home_phone' => TTi18n::gettext('Home Phone'), '-1560-home_email' => TTi18n::gettext('Home Email'), '-1590-note' => TTi18n::gettext('Note'), '-1595-tag' => TTi18n::gettext('Tags')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2010-l1' => TTi18n::gettext('Wages (1)'), '-2020-l2' => TTi18n::gettext('Federal Income Tax (2)'), '-2030-l3' => TTi18n::gettext('Social Security Wages (3)'), '-2040-l4' => TTi18n::gettext('Social Security Tax (4)'), '-2040-l7' => TTi18n::gettext('Social Security Tips (7)'), '-2050-l5' => TTi18n::gettext('Medicare Wages (5)'), '-2060-l6' => TTi18n::gettext('Medicare Tax (6)'), '-2070-l8' => TTi18n::gettext('Allocated Tips (8)'), '-2080-l10' => TTi18n::gettext('Dependent Care Benefits (10)'), '-2090-l11' => TTi18n::gettext('Nonqualified Plans (11)'), '-2100-l12a' => TTi18n::gettext('Box 12a'), '-2110-l12b' => TTi18n::gettext('Box 12b'), '-2120-l12c' => TTi18n::gettext('Box 12c'), '-2130-l12d' => TTi18n::gettext('Box 12d'), '-2200-l14a' => TTi18n::gettext('Box 14a'), '-2210-l14b' => TTi18n::gettext('Box 14b'), '-2220-l14c' => TTi18n::gettext('Box 14c'), '-2230-l14d' => TTi18n::gettext('Box 14d')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { $retval[$column] = 'currency'; } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: $retval[$column] = 'sum'; } } } break; case 'templates': $retval = array('-1020-by_employee' => TTi18n::gettext('by Employee'), '-1030-by_branch' => TTi18n::gettext('by Branch'), '-1040-by_department' => TTi18n::gettext('by Department'), '-1050-by_branch_by_department' => TTi18n::gettext('by Branch/Department')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'default': //Proper settings to generate the form. //$retval['-1010-time_period']['time_period'] = 'last_quarter'; $retval['columns'] = $this->getOptions('columns'); $retval['group'][] = 'date_quarter_month'; $retval['sort'][] = array('date_quarter_month' => 'asc'); $retval['other']['grand_total'] = TRUE; break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_year'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns //Filter //Group By //SubTotal //Sort case 'by_month': $retval['columns'][] = 'date_month'; $retval['group'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); break; case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_employee': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'date_month'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_month_by_branch': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_month_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_branch_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; } } } $retval['columns'] = array_merge($retval['columns'], array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns')))); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-punch_branch_id' => TTi18n::gettext('Punch Branch'), '-2090-punch_department_id' => TTi18n::gettext('Punch Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $corporate_edition_setup_fields = array('-2510-job_status_id' => TTi18n::gettext('Job Status'), '-2520-job_group_id' => TTi18n::gettext('Job Group'), '-2530-include_job_id' => TTi18n::gettext('Include Job'), '-2540-exclude_job_id' => TTi18n::gettext('Exclude Job'), '-2610-job_item_group_id' => TTi18n::gettext('Task Group'), '-2620-include_job_item_id' => TTi18n::gettext('Include Task'), '-2630-exclude_job_item_id' => TTi18n::gettext('Exclude Task')); $retval = array_merge($retval, $corporate_edition_setup_fields); } break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions(NULL, TTi18n::getText('Date'), 15, TRUE); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(15, 20, 30), array(15 => '', 20 => 'job_', 30 => 'job_item_')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'PunchSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'PunchSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'PunchSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'PunchSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1055-city' => TTi18n::gettext('City'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-1495-tag' => TTi18n::gettext('Tags'), '-1600-in_time_stamp' => TTi18n::gettext('In Punch'), '-1601-in_type' => TTi18n::gettext('In Type'), '-1610-out_time_stamp' => TTi18n::gettext('Out Punch'), '-1611-out_type' => TTi18n::gettext('Out Type'), '-1620-in_actual_time_stamp' => TTi18n::gettext('In (Actual)'), '-1630-out_actual_time_stamp' => TTi18n::gettext('Out (Actual)'), '-1660-branch' => TTi18n::gettext('Branch'), '-1670-department' => TTi18n::gettext('Department'), '-1671-in_station_type' => TTi18n::gettext('In Station Type'), '-1672-in_station_station_id' => TTi18n::gettext('In Station ID'), '-1673-in_station_source' => TTi18n::gettext('In Station Source'), '-1674-in_station_description' => TTi18n::gettext('In Station Description'), '-1675-out_station_type' => TTi18n::gettext('Out Station Type'), '-1676-out_station_station_id' => TTi18n::gettext('Out Station ID'), '-1677-out_station_source' => TTi18n::gettext('Out Station Source'), '-1678-out_station_description' => TTi18n::gettext('Out Station Description'), '-1720-note' => TTi18n::gettext('Note'), '-1900-in_created_date' => TTi18n::gettext('In Created Date'), '-1901-in_created_by' => TTi18n::gettext('In Created By'), '-1905-in_updated_date' => TTi18n::gettext('In Updated Date'), '-1906-in_updated_by' => TTi18n::gettext('In Updated By'), '-1910-out_created_date' => TTi18n::gettext('Out Created Date'), '-1911-out_created_by' => TTi18n::gettext('Out Created By'), '-1915-out_updated_date' => TTi18n::gettext('Out Updated Date'), '-1916-out_updated_by' => TTi18n::gettext('Out Updated By'), '-1920-verified_time_sheet' => TTi18n::gettext('Verified TimeSheet'), '-1925-verified_time_sheet_date' => TTi18n::gettext('Verified TimeSheet Date'), '-1930-verified_time_sheet_tainted' => TTi18n::gettext('TimeSheet Verification Tainted'), '-1950-tainted' => TTi18n::gettext('Tainted'), '-1951-tainted_status' => TTi18n::gettext('Tainted Status')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $corporate_edition_static_columns = array('-1810-job' => TTi18n::gettext('Job'), '-1820-job_manual_id' => TTi18n::gettext('Job Code'), '-1830-job_description' => TTi18n::gettext('Job Description'), '-1840-job_status' => TTi18n::gettext('Job Status'), '-1850-job_branch' => TTi18n::gettext('Job Branch'), '-1860-job_department' => TTi18n::gettext('Job Department'), '-1870-job_group' => TTi18n::gettext('Job Group'), '-1910-job_item' => TTi18n::gettext('Task'), '-1920-job_item_manual_id' => TTi18n::gettext('Task Code'), '-1930-job_item_description' => TTi18n::gettext('Task Description'), '-1940-job_item_group' => TTi18n::gettext('Task Group')); $retval = array_merge($retval, $corporate_edition_static_columns); } $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2010-hourly_rate' => TTi18n::gettext('Hourly Rate'), '-2100-total_time' => TTi18n::gettext('Total Time'), '-2110-total_time_wage' => TTi18n::gettext('Total Time Wage'), '-2112-total_time_wage_burden' => TTi18n::gettext('Total Time Wage Burden'), '-2114-total_time_wage_with_burden' => TTi18n::gettext('Total Time Wage w/Burden'), '-2120-actual_total_time' => TTi18n::gettext('Actual Time'), '-2120-actual_total_time_wage' => TTi18n::gettext('Actual Time Wage'), '-2125-actual_total_time_diff' => TTi18n::gettext('Actual Time Difference'), '-2127-actual_total_time_diff_wage' => TTi18n::gettext('Actual Time Difference Wage'), '-3000-total_punch' => TTi18n::gettext('Total Punches'), '-3001-total_tainted_punch' => TTi18n::gettext('Total Tainted Punches')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, '_wage') !== FALSE or strpos($column, '_hourly_rate') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } elseif (strpos($column, '_time') or strpos($column, '_policy')) { $retval[$column] = 'time_unit'; } } } $retval['in_time_stamp'] = $retval['out_time_stamp'] = $retval['in_actual_time_stamp'] = $retval['out_actual_time_stamp'] = $retval['in_created_date'] = $retval['in_updated_date'] = $retval['out_created_date'] = $retval['out_updated_date'] = $retval['verified_time_sheet_date'] = 'time_stamp'; $retval['verified_time_sheet_tainted'] = $retval['tainted'] = 'boolean'; $retval['verified_time_sheet_tainted'] = 'boolean'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, '_hourly_rate') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } $retval['verified_time_sheet'] = 'first'; $retval['verified_time_sheet_date'] = 'first'; break; case 'templates': $retval = array('-1010-by_employee+punch_summary+total_time' => TTi18n::gettext('Punch Summary By Employee'), '-1020-by_branch+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Branch'), '-1030-by_department+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Department'), '-1040-by_branch_by_department+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Branch/Department'), '-1050-by_pay_period+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Pay Period'), '-1060-by_date_stamp+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Date'), '-1070-by_station+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Station'), '-1080-by_employee+punch_summary+total_time+note' => TTi18n::gettext('Punch Summary+Notes by Employee'), '-1090-by_employee+punch_summary+total_time+actual_time' => TTi18n::gettext('Punch Summary+Actual Time by Employee'), '-1100-by_employee+punch_summary+station_summary+total_time' => TTi18n::gettext('Punch/Station Detail By Employee'), '-1110-by_employee+actual_time' => TTi18n::gettext('Actual Time by Employee'), '-1120-by_employee+tainted' => TTi18n::gettext('Tainted Punches By Employee'), '-1120-by_employee+verified_time_sheet' => TTi18n::gettext('TimeSheet Verification Tainted')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $professional_edition_templates = array('-2010-by_job+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Job'), '-2020-by_job_item+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Task'), '-2030-by_job_by_job_item+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Job/Task'), '-2040-by_job_branch+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Job Branch'), '-2050-by_job_branch_by_job_department+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Job Branch/Department'), '-2060-by_job_group+punch_summary+total_time' => TTi18n::gettext('Punch Summary by Job Group')); $retval = array_merge($retval, $professional_edition_templates); } break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'by_employee+actual_time': $retval['-1010-time_period']['time_period'] = 'last_pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'total_time'; $retval['columns'][] = 'actual_total_time'; $retval['columns'][] = 'actual_total_time_diff'; $retval['columns'][] = 'actual_total_time_diff_wage'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('actual_total_time_diff' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_employee+verified_time_sheet': $retval['-1010-time_period']['time_period'] = 'last_pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'in_type'; $retval['columns'][] = 'in_time_stamp'; $retval['columns'][] = 'out_type'; $retval['columns'][] = 'out_time_stamp'; $retval['columns'][] = 'verified_time_sheet'; $retval['columns'][] = 'verified_time_sheet_date'; $retval['columns'][] = 'verified_time_sheet_tainted'; $retval['sort'][] = array('verified_time_sheet_tainted' => 'desc'); $retval['sort'][] = array('verified_time_sheet' => 'asc'); $retval['sort'][] = array('verified_time_sheet_date' => 'desc'); break; case 'by_employee+tainted': $retval['-1010-time_period']['time_period'] = 'last_pay_period'; $retval['columns'][] = 'tainted'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'total_tainted_punch'; $retval['columns'][] = 'total_punch'; $retval['group'][] = 'tainted'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'tainted'; $retval['sort'][] = array('tainted' => 'desc'); $retval['sort'][] = array('total_tainted_punch' => 'desc'); $retval['sort'][] = array('total_punch' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'desc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_pay_period'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns case 'total_time': $retval['columns'][] = 'total_time'; break; case 'actual_time': $retval['columns'][] = 'actual_total_time'; $retval['columns'][] = 'actual_total_time_diff'; break; case 'note': $retval['columns'][] = 'note'; break; case 'punch_summary': $retval['columns'][] = 'in_type'; $retval['columns'][] = 'in_time_stamp'; $retval['columns'][] = 'out_type'; $retval['columns'][] = 'out_time_stamp'; break; case 'station_summary': $retval['columns'][] = 'in_station_type'; $retval['columns'][] = 'out_station_type'; break; //Filter //Group By //SubTotal //Sort //Filter //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'last_name'; $retval['sub_total'][] = 'first_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'branch'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_department': $retval['columns'][] = 'department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'department'; $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'branch'; $retval['columns'][] = 'department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'branch'; $retval['sub_total'][] = 'department'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_station': $retval['columns'][] = 'in_station_type'; $retval['columns'][] = 'in_station_description'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'in_station_type'; $retval['sub_total'][] = 'in_station_description'; $retval['sort'][] = array('in_station_type' => 'asc'); $retval['sort'][] = array('in_station_description' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_date_stamp': $retval['columns'][] = 'date_stamp'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'date_stamp'; $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; //Professional Edition templates. //Professional Edition templates. case 'by_job': $retval['columns'][] = 'job'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job'; $retval['sort'][] = array('job' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_item': $retval['columns'][] = 'job_item'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job_item'; $retval['sort'][] = array('job_item' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_by_job_item': $retval['columns'][] = 'job'; $retval['columns'][] = 'job_item'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job'; $retval['sub_total'][] = 'job_item'; $retval['sort'][] = array('job' => 'asc'); $retval['sort'][] = array('job_item' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_branch': $retval['columns'][] = 'job_branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job_branch'; $retval['sort'][] = array('job_branch' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_department': $retval['columns'][] = 'job_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job_department'; $retval['sort'][] = array('job_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_branch_by_job_department': $retval['columns'][] = 'job_branch'; $retval['columns'][] = 'job_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job_branch'; $retval['sub_total'][] = 'job_department'; $retval['sort'][] = array('job_branch' => 'asc'); $retval['sort'][] = array('job_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; case 'by_job_group': $retval['columns'][] = 'job_group'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['sub_total'][] = 'job_group'; $retval['sort'][] = array('job_group' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('in_time_stamp' => 'asc'); break; } } } break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $professional_edition_setup_fields = array('-2510-job_status_id' => TTi18n::gettext('Job Status'), '-2520-job_group_id' => TTi18n::gettext('Job Group'), '-2530-include_job_id' => TTi18n::gettext('Include Job'), '-2540-exclude_job_id' => TTi18n::gettext('Exclude Job'), '-2610-job_item_group_id' => TTi18n::gettext('Task Group'), '-2620-include_job_item_id' => TTi18n::gettext('Include Task'), '-2630-exclude_job_item_id' => TTi18n::gettext('Exclude Task')); $retval = array_merge($retval, $professional_edition_setup_fields); } break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': /* $retval = array_merge( TTDate::getReportDateOptions( 'time_stamp', TTi18n::getText('Punch Time'), 19, FALSE ), array() ); */ break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'ActiveShiftReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'ActiveShiftReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'ActiveShiftReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'ActiveShiftReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1010-user_name' => TTi18n::gettext('User Name'), '-1020-phone_id' => TTi18n::gettext('Quick Punch ID'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1050-title' => TTi18n::gettext('Title'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Branch'), '-1100-default_department' => TTi18n::gettext('Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-1310-sex' => TTi18n::gettext('Gender'), '-1320-address1' => TTi18n::gettext('Address 1'), '-1330-address2' => TTi18n::gettext('Address 2'), '-1340-city' => TTi18n::gettext('City'), '-1350-province' => TTi18n::gettext('Province/State'), '-1360-country' => TTi18n::gettext('Country'), '-1370-postal_code' => TTi18n::gettext('Postal Code'), '-1380-work_phone' => TTi18n::gettext('Work Phone'), '-1391-work_phone_ext' => TTi18n::gettext('Work Phone Ext'), '-1400-home_phone' => TTi18n::gettext('Home Phone'), '-1410-mobile_phone' => TTi18n::gettext('Mobile Phone'), '-1420-fax_phone' => TTi18n::gettext('Fax Phone'), '-1430-home_email' => TTi18n::gettext('Home Email'), '-1440-work_email' => TTi18n::gettext('Work Email'), '-1495-tag' => TTi18n::gettext('Tags'), '-1740-time_zone_display' => TTi18n::gettext('Time Zone'), '-1801-type' => TTi18n::gettext('Type'), '-1802-status' => TTi18n::gettext('Status'), '-1810-branch' => TTi18n::gettext('Branch'), '-1820-department' => TTi18n::gettext('Department'), '-1830-station_type' => TTi18n::gettext('Station Type'), '-1840-station_station_id' => TTi18n::gettext('Station ID'), '-1850-station_source' => TTi18n::gettext('Station Source'), '-1860-station_description' => TTi18n::gettext('Station Description'), '-1900-time_stamp' => TTi18n::gettext('Punch Time'), '-1910-actual_time_stamp' => TTi18n::gettext('Actual Punch Time'), '-2010-note' => TTi18n::gettext('Note')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $professional_edition_static_columns = array('-1825-job' => TTi18n::gettext('Job'), '-1826-job_item' => TTi18n::gettext('Task')); $retval = array_merge($retval, $professional_edition_static_columns, (array) $this->getOptions('report_static_custom_column')); } break; case 'dynamic_columns': $retval = array('-2000-total_user' => TTi18n::gettext('Total Employees')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'wage') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, 'hourly_rate') !== FALSE or strpos($column, 'wage') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } break; case 'templates': $retval = array('-1010-by_status_by_employee' => TTi18n::gettext('Punches By Status'), '-1020-by_type_by_employee' => TTi18n::gettext('Punches By Type'), '-1030-by_status_by_type_by_employee' => TTi18n::gettext('Punches By Status/Type'), '-1040-by_type_by_status_by_employee' => TTi18n::gettext('Punches By Type/Status'), '-1050-by_employee' => TTi18n::gettext('Punches By Employee'), '-1060-by_default_branch_by_employee' => TTi18n::gettext('Punches By Default Branch'), '-1070-by_default_department_by_employee' => TTi18n::gettext('Punches By Default Department'), '-1080-by_default_branch_by_default_department_by_employee' => TTi18n::gettext('Punches By Default Branch/Department'), '-1090-by_branch_by_employee' => TTi18n::gettext('Punches By Branch'), '-1100-by_department_by_employee' => TTi18n::gettext('Punches By Department'), '-1110-by_branch_by_department_by_employee' => TTi18n::gettext('Punches By Branch/Department'), '-1120-by_station_by_employee' => TTi18n::gettext('Punches By Station'), '-1130-by_station_type_by_employee' => TTi18n::gettext('Punches By Station Type')); if ($this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $professional_edition_setup_fields = array('-1112-by_job_by_job_item_by_employee' => TTi18n::gettext('Punches By Job/Task')); $retval = array_merge($retval, $professional_edition_setup_fields); } break; case 'template_config': //Last 7 days does not include today. //$retval['-1010-time_period']['time_period'] = 'last_7_days'; //Default to just the last 7 days to speed up the query. $retval['-1010-time_period']['time_period'] = 'today'; //Default to just the last 7 days to speed up the query. $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_default_branch_by_employee': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_default_department_by_employee': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_default_branch_by_default_department_by_employee': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_employee': $retval['columns'][] = 'branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_department_by_employee': $retval['columns'][] = 'department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_department_by_employee': $retval['columns'][] = 'branch'; $retval['columns'][] = 'department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_job_by_job_item_by_employee': $retval['columns'][] = 'job'; $retval['columns'][] = 'job_item'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('job' => 'asc'); $retval['sort'][] = array('job_item' => 'asc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_status_by_employee': $retval['columns'][] = 'status'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_type_by_employee': $retval['columns'][] = 'type'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_status_by_type_by_employee': $retval['columns'][] = 'status'; $retval['columns'][] = 'type'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('type' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_type_by_status_by_employee': $retval['columns'][] = 'type'; $retval['columns'][] = 'status'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('type' => 'desc'); $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_station_by_employee': $retval['columns'][] = 'station_description'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'status'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('station_description' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_station_type_by_employee': $retval['columns'][] = 'station_type'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'status'; $retval['columns'][] = 'time_stamp'; $retval['sort'][] = array('station_type' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = array_merge(parent::getOptions('default_output_format'), array('-1100-pdf_form' => TTi18n::gettext('Form'))); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-4020-exclude_ytd_adjustment' => TTi18n::gettext('Exclude YTD Adjustments'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions(NULL, TTi18n::getText('Date'), 13, TRUE); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'Form940Report', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'Form940Report', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'Form940Report', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'Form940Report', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1035-sin' => TTi18n::gettext('SIN/SSN'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1400-permission_control' => TTi18n::gettext('Permission Group'), '-1410-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1420-policy_group' => TTi18n::gettext('Policy Group')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2010-total_payments' => TTi18n::gettext('Total Payments'), '-2020-exempt_payments' => TTi18n::gettext('Exempt Payments'), '-2030-excess_payments' => TTi18n::gettext('Excess Payments'), '-2040-taxable_wages' => TTi18n::gettext('Taxable Wages'), '-2050-before_adjustment_tax' => TTi18n::gettext('Tax Before Adjustments'), '-2052-adjustment_tax' => TTi18n::gettext('Tax Adjustments'), '-2054-after_adjustment_tax' => TTi18n::gettext('Tax After Adjustments')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { $retval[$column] = 'currency'; } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: $retval[$column] = 'sum'; } } } break; case 'state': $retval = Misc::prependArray(array(0 => TTi18n::getText('- Multi-state Employer -')), $this->getUserObject()->getCompanyObject()->getOptions('province', 'US')); break; case 'return_type': $retval = array(10 => TTi18n::getText('Amended'), 20 => TTi18n::getText('Successor Employer'), 30 => TTi18n::getText('No Payments to Employees'), 40 => TTi18n::getText('Final: Business closed or stopped paying wages')); break; case 'exempt_payment': $retval = array(10 => TTi18n::getText('4a. Fringe benefits'), 20 => TTi18n::getText('4b. Group term life insurance'), 30 => TTi18n::getText('4c. Retirement/Pension'), 40 => TTi18n::getText('4d. Dependant care'), 50 => TTi18n::getText('4e. Other')); break; case 'templates': $retval = array('-1010-by_quarter' => TTi18n::gettext('by Quarter'), '-1010-by_month' => TTi18n::gettext('by Month'), '-1020-by_employee' => TTi18n::gettext('by Employee'), '-1030-by_branch' => TTi18n::gettext('by Branch'), '-1040-by_department' => TTi18n::gettext('by Department'), '-1050-by_branch_by_department' => TTi18n::gettext('by Branch/Department'), '-1060-by_month_by_employee' => TTi18n::gettext('by Month/Employee'), '-1070-by_month_by_branch' => TTi18n::gettext('by Month/Branch'), '-1080-by_month_by_department' => TTi18n::gettext('by Month/Department'), '-1090-by_month_by_branch_by_department' => TTi18n::gettext('by Month/Branch/Department')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'default': //Proper settings to generate the form. //$retval['-1010-time_period']['time_period'] = 'last_quarter'; $retval['columns'] = $this->getOptions('columns'); $retval['group'][] = 'date_quarter_month'; $retval['sort'][] = array('date_quarter_month' => 'asc'); $retval['other']['grand_total'] = TRUE; break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_year'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns //Filter //Group By //SubTotal //Sort case 'by_quarter': $retval['columns'][] = 'date_quarter'; $retval['group'][] = 'date_quarter'; $retval['sort'][] = array('date_quarter' => 'asc'); break; case 'by_month': $retval['columns'][] = 'date_month'; $retval['group'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); break; case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_employee': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'date_month'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_month_by_branch': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_month_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_branch_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; } } } $retval['columns'] = array_merge($retval['columns'], array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns')))); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = array_merge(parent::getOptions('default_output_format'), array('-1100-pdf_form' => TTi18n::gettext('Employee (One Employee/Page)'), '-1110-pdf_form_government' => TTi18n::gettext('Government (Multiple Employees/Page)'), '-1120-efile_xml' => TTi18n::gettext('eFile'))); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': //$retval = TTDate::getReportDateOptions( NULL, TTi18n::getText('Date'), 13, TRUE ); $retval = array(); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'T4SummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'T4SummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'T4SummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'T4SummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1035-sin' => TTi18n::gettext('SIN/SSN'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1400-permission_control' => TTi18n::gettext('Permission Group'), '-1410-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1420-policy_group' => TTi18n::gettext('Policy Group')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2100-income' => TTi18n::gettext('Income (14)'), '-2110-tax' => TTi18n::gettext('Income Tax (22)'), '-2120-employee_cpp' => TTi18n::gettext('Employee CPP (16)'), '-2125-ei_earnings' => TTi18n::gettext('EI Insurable Earnings (24)'), '-2126-cpp_earnings' => TTi18n::gettext('CPP Pensionable Earnings (26)'), '-2130-employee_ei' => TTi18n::gettext('Employee EI (18)'), '-2140-union_dues' => TTi18n::gettext('Union Dues (44)'), '-2150-employer_cpp' => TTi18n::gettext('Employer CPP'), '-2160-employer_ei' => TTi18n::gettext('Employer EI'), '-2170-rpp' => TTi18n::gettext('RPP Contributions (20)'), '-2180-charity' => TTi18n::gettext('Charity Donations (46)'), '-2190-pension_adjustment' => TTi18n::gettext('Pension Adjustment (52)'), '-2200-other_box_0' => TTi18n::gettext('Other Box 1'), '-2210-other_box_1' => TTi18n::gettext('Other Box 2'), '-2220-other_box_2' => TTi18n::gettext('Other Box 3'), '-2220-other_box_3' => TTi18n::gettext('Other Box 4'), '-2220-other_box_4' => TTi18n::gettext('Other Box 5'), '-2220-other_box_5' => TTi18n::gettext('Other Box 6')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { $retval[$column] = 'currency'; } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: $retval[$column] = 'sum'; } } } break; case 'type': $retval = array('-1010-O' => TTi18n::getText('Original'), '-1020-A' => TTi18n::getText('Amended'), '-1030-C' => TTi18n::getText('Cancel')); break; case 'templates': $retval = array('-1020-by_employee' => TTi18n::gettext('by Employee'), '-1030-by_branch' => TTi18n::gettext('by Branch'), '-1040-by_department' => TTi18n::gettext('by Department'), '-1050-by_branch_by_department' => TTi18n::gettext('by Branch/Department')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'default': //Proper settings to generate the form. //$retval['-1010-time_period']['time_period'] = 'last_quarter'; $retval['columns'] = $this->getOptions('columns'); $retval['group'][] = 'date_quarter_month'; $retval['sort'][] = array('date_quarter_month' => 'asc'); $retval['other']['grand_total'] = TRUE; break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_year'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns //Filter //Group By //SubTotal //Sort case 'by_month': $retval['columns'][] = 'date_month'; $retval['group'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); break; case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_employee': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'date_month'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_month_by_branch': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_month_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_month_by_branch_by_department': $retval['columns'][] = 'date_month'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'date_month'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'date_month'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('date_month' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; } } } $retval['columns'] = array_merge($retval['columns'], array_keys(Misc::trimSortPrefix($this->getOptions('dynamic_columns')))); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'export_columns': //Must pass export_type. if ($params == 'csv_advanced') { if (is_object($this->getUserObject()) and is_object($this->getUserObject()->getCompanyObject()) and $this->getUserObject()->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE) { $jar = TTNew('JobDetailReport'); } else { $jar = TTNew('TimesheetDetailReport'); } $jar->setUserObject($this->getUserObject()); $retval = $jar->getOptions('static_columns'); } else { $retval = parent::getOptios('static_columns'); } break; case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'export_type': $retval = array(0 => TTi18n::gettext('-- Please Choose --'), 'adp' => TTi18n::gettext('ADP'), 'paychex_preview' => TTi18n::gettext('Paychex Preview'), 'paychex_preview_advanced_job' => TTi18n::gettext('Paychex Preview (by Day/Job)'), 'paychex_online' => TTi18n::gettext('Paychex Online Payroll'), 'ceridian_insync' => TTi18n::gettext('Ceridian Insync'), 'millenium' => TTi18n::gettext('Millenium'), 'quickbooks' => TTi18n::gettext('QuickBooks Pro'), 'surepayroll' => TTi18n::gettext('SurePayroll'), 'chris21' => TTi18n::gettext('Chris21'), 'csv' => TTi18n::gettext('Generic Excel/CSV'), 'csv_advanced' => TTi18n::gettext('Generic Excel/CSV (Advanced)')); break; case 'export_policy': $static_columns = array(); $columns = array('-0010-regular_time' => TTi18n::gettext('Regular Time')); $columns = Misc::prependArray($static_columns, $columns); //Get all Overtime policies. $otplf = TTnew('OverTimePolicyListFactory'); $otplf->getByCompanyId($this->getUserObject()->getCompany()); if ($otplf->getRecordCount() > 0) { foreach ($otplf as $otp_obj) { $otp_columns['-0020-over_time_policy-' . $otp_obj->getId()] = TTi18n::gettext('Overtime') . ': ' . $otp_obj->getName(); } $columns = array_merge($columns, $otp_columns); } //Get all Premium policies. $pplf = TTnew('PremiumPolicyListFactory'); $pplf->getByCompanyId($this->getUserObject()->getCompany()); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { $pp_columns['-0030-premium_policy-' . $pp_obj->getId()] = TTi18n::gettext('Premium') . ': ' . $pp_obj->getName(); } $columns = array_merge($columns, $pp_columns); } //Get all Absence Policies. $aplf = TTnew('AbsencePolicyListFactory'); $aplf->getByCompanyId($this->getUserObject()->getCompany()); if ($aplf->getRecordCount() > 0) { foreach ($aplf as $ap_obj) { $ap_columns['-0040-absence_policy-' . $ap_obj->getId()] = TTi18n::gettext('Absence') . ': ' . $ap_obj->getName(); } $columns = array_merge($columns, $ap_columns); } $retval = $columns; break; case 'default_hour_codes': $export_type = $this->getOptions('export_type'); $export_policy = Misc::trimSortPrefix($this->getOptions('export_policy')); foreach ($export_type as $type => $name) { switch (strtolower($type)) { case 'paychex_online': foreach ($export_policy as $id => $name) { if (strpos($id, 'regular') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'Regular'; } elseif (strpos($id, 'over_time') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'Overtime'; } elseif (strpos($id, 'absence') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'Absence'; } } break; default: if ($type === 0) { continue; } foreach ($export_policy as $id => $name) { if (strpos($id, 'regular') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'REG'; } elseif (strpos($id, 'over_time') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'OT'; } elseif (strpos($id, 'absence') !== FALSE) { $retval[$type]['columns'][$id]['hour_code'] = 'ABS'; } } break; } } break; case 'hour_column_name': $hour_column_name_map = array('adp' => TTi18n::gettext('ADP Hours Code'), 'paychex_preview' => TTi18n::gettext('Paychex Hours Code'), 'paychex_preview_advanced_job' => TTi18n::gettext('Paychex Hours Code'), 'paychex_online' => TTi18n::gettext('Paychex Hours Code'), 'ceridian_insync' => TTi18n::gettext('Ceridian Hours Code'), 'millenium' => TTi18n::gettext('Millenium Hours Code'), 'quickbooks' => TTi18n::gettext('Quickbooks Payroll Item Name'), 'quickbooks_advanced' => TTi18n::gettext('Quickbooks Payroll Item Name'), 'surepayroll' => TTi18n::gettext('Payroll Code'), 'csv' => TTi18n::gettext('Hours Code'), 'csv_advanced' => TTi18n::gettext('Hours Code')); if (isset($params['export_type']) and isset($hour_column_name_map[$params['export_type']])) { $retval = $hour_column_name_map[$params['export_type']]; } else { $retval = $hour_column_name_map['csv']; } break; case 'adp_hour_column_options': $retval['adp_hour_column_options'][0] = TTi18n::gettext('-- DO NOT EXPORT --'); $retval['adp_hour_column_options']['-0010-regular_time'] = TTi18n::gettext('Regular Time'); $retval['adp_hour_column_options']['-0020-overtime'] = TTi18n::gettext('Overtime'); for ($i = 3; $i <= 4; $i++) { $retval['adp_hour_column_options']['-003' . $i . '-' . $i] = TTi18n::gettext('Hours') . ' ' . $i; } break; case 'adp_company_code_options': case 'adp_batch_options': case 'adp_temp_dept_options': $retval = array(0 => TTi18n::gettext('-- Custom --'), '-0010-default_branch_manual_id' => TTi18n::gettext('Default Branch: Code'), '-0020-default_department_manual_id' => TTi18n::gettext('Default Department: Code'), '-0030-branch_manual_id' => TTi18n::gettext('Branch: Code'), '-0040-department_manual_id' => TTi18n::gettext('Department: Code')); $oflf = TTnew('OtherFieldListFactory'); //Put a colon or underscore in the name, thats how we know it needs to be replaced. //Get Branch other fields. $default_branch_options = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), 4, '-1000-default_branch_', TTi18n::getText('Default Branch') . ': '); if (!is_array($default_branch_options)) { $default_branch_options = array(); } $default_department_options = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), 5, '-2000-default_department_', TTi18n::getText('Default Department') . ': '); if (!is_array($default_department_options)) { $default_department_options = array(); } $branch_options = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), 4, '-3000-branch_', TTi18n::getText('Branch') . ': '); if (!is_array($branch_options)) { $branch_options = array(); } $department_options = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), 5, '-4000-department_', TTi18n::getText('Department') . ': '); if (!is_array($department_options)) { $department_options = array(); } $retval = array_merge($retval, (array) $default_branch_options, (array) $default_department_options, $branch_options, $department_options); break; case 'quickbooks_proj_options': case 'quickbooks_job_options': case 'quickbooks_item_options': $retval = array(0 => TTi18n::gettext('-- NONE --'), 'default_branch' => TTi18n::gettext('Default Branch'), 'default_department' => TTi18n::gettext('Default Department'), 'group' => TTi18n::gettext('Group'), 'title' => TTi18n::gettext('Title'), 'branch_name' => TTi18n::gettext('Punch Branch'), 'department_name' => TTi18n::gettext('Punch Department')); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'PayrollExportReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::prependArray(Misc::addSortPrefix($custom_column_labels, 9500), parent::_getOptions($name, $params)); } else { $retval = parent::_getOptions($name, $params); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = Misc::prependArray($rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'PayrollExportReport', 'custom_column'), parent::_getOptions($name, $params)); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'PayrollExportReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::prependArray(Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700), parent::_getOptions($name, $params)); } else { $retval = parent::_getOptions($name, $params); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'PayrollExportReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::prependArray(Misc::addSortPrefix($report_static_custom_column_labels, 9700), parent::_getOptions($name, $params)); } else { $retval = parent::_getOptions($name, $params); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': return Misc::prependArray(array_merge(array('-1480-sin' => TTi18n::gettext('SIN/SSN')), (array) $this->getOptions('report_static_custom_column')), parent::_getOptions($name, $params)); break; default: return parent::_getOptions($name, $params); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-punch_branch_id' => TTi18n::gettext('Punch Branch'), '-2090-punch_department_id' => TTi18n::gettext('Punch Department'), '-2000-currency_id' => TTi18n::gettext('Currency'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-4010-pay_period_time_sheet_verify_status_id' => TTi18n::gettext('TimeSheet Verification'), '-4020-include_no_data_rows' => TTi18n::gettext('Include Blank Records'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions(NULL, TTi18n::getText('Date'), 13, TRUE); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'TimesheetSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'TimesheetSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'TimesheetSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'TimesheetSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1055-city' => TTi18n::gettext('City'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Employee Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1111-current_currency' => TTi18n::gettext('Current Currency'), '-1400-permission_control' => TTi18n::gettext('Permission Group'), '-1410-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1420-policy_group' => TTi18n::gettext('Policy Group'), '-1430-branch_name' => TTi18n::gettext('Branch'), '-1440-department_name' => TTi18n::gettext('Department'), '-1490-note' => TTi18n::gettext('Note'), '-1495-tag' => TTi18n::gettext('Tags'), '-1510-verified_time_sheet' => TTi18n::gettext('Verified TimeSheet'), '-1515-verified_time_sheet_date' => TTi18n::gettext('Verified TimeSheet Date')); $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2070-schedule_working' => TTi18n::gettext('Scheduled Time'), '-2072-schedule_working_diff' => TTi18n::gettext('Scheduled Time Diff.'), '-2080-schedule_absence' => TTi18n::gettext('Scheduled Absence'), '-2085-worked_days' => TTi18n::gettext('Worked Days'), '-2090-worked_time' => TTi18n::gettext('Worked Time'), '-2290-regular_time' => TTi18n::gettext('Regular Time'), '-2500-gross_wage' => TTi18n::gettext('Gross Wage'), '-2501-gross_wage_with_burden' => TTi18n::gettext('Gross Wage w/Burden'), '-2530-regular_time_wage' => TTi18n::gettext('Regular Time - Wage'), '-2531-regular_time_wage_with_burden' => TTi18n::gettext('Regular Time - Wage w/Burden'), '-2690-regular_time_hourly_rate' => TTi18n::gettext('Regular Time - Hourly Rate'), '-2690-regular_time_hourly_rate_with_burden' => TTi18n::gettext('Regular Time - Hourly Rate w/Burden')); $retval = array_merge($retval, $this->getOptions('overtime_columns'), $this->getOptions('premium_columns'), $this->getOptions('absence_columns')); ksort($retval); break; case 'overtime_columns': //Get all Overtime policies. $retval = array(); $otplf = TTnew('OverTimePolicyListFactory'); $otplf->getByCompanyId($this->getUserObject()->getCompany()); if ($otplf->getRecordCount() > 0) { foreach ($otplf as $otp_obj) { $retval['-2291-over_time_policy-' . $otp_obj->getId()] = $otp_obj->getName(); $retval['-2591-over_time_policy-' . $otp_obj->getId() . '_wage'] = $otp_obj->getName() . ' ' . TTi18n::getText('- Wage'); $retval['-2591-over_time_policy-' . $otp_obj->getId() . '_wage_with_burden'] = $otp_obj->getName() . ' ' . TTi18n::getText('- Wage w/Burden'); $retval['-2691-over_time_policy-' . $otp_obj->getId() . '_hourly_rate'] = $otp_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate'); $retval['-2691-over_time_policy-' . $otp_obj->getId() . '_hourly_rate_with_burden'] = $otp_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate w/Burden'); } } break; case 'premium_columns': $retval = array(); //Get all Premium policies. $pplf = TTnew('PremiumPolicyListFactory'); $pplf->getByCompanyId($this->getUserObject()->getCompany()); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { $retval['-2291-premium_policy-' . $pp_obj->getId()] = $pp_obj->getName(); $retval['-2591-premium_policy-' . $pp_obj->getId() . '_wage'] = $pp_obj->getName() . ' ' . TTi18n::getText('- Wage'); $retval['-2591-premium_policy-' . $pp_obj->getId() . '_wage_with_burden'] = $pp_obj->getName() . ' ' . TTi18n::getText('- Wage w/Burden'); $retval['-2691-premium_policy-' . $pp_obj->getId() . '_hourly_rate'] = $pp_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate'); $retval['-2691-premium_policy-' . $pp_obj->getId() . '_hourly_rate_with_burden'] = $pp_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate w/Burden'); } } break; case 'absence_columns': $retval = array(); //Get all Absence Policies. $aplf = TTnew('AbsencePolicyListFactory'); $aplf->getByCompanyId($this->getUserObject()->getCompany()); if ($aplf->getRecordCount() > 0) { foreach ($aplf as $ap_obj) { $retval['-2291-absence_policy-' . $ap_obj->getId()] = $ap_obj->getName(); if ($ap_obj->getType() == 10) { $retval['-2591-absence_policy-' . $ap_obj->getId() . '_wage'] = $ap_obj->getName() . ' ' . TTi18n::getText('- Wage'); $retval['-2591-absence_policy-' . $ap_obj->getId() . '_wage_with_burden'] = $ap_obj->getName() . ' ' . TTi18n::getText('- Wage w/Burden'); $retval['-2691-absence_policy-' . $ap_obj->getId() . '_hourly_rate'] = $ap_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate'); $retval['-2691-absence_policy-' . $ap_obj->getId() . '_hourly_rate_with_burden'] = $ap_obj->getName() . ' ' . TTi18n::getText('- Hourly Rate w/Burden'); } } } break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, '_wage') !== FALSE or strpos($column, '_hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } elseif (strpos($column, '_time') or strpos($column, 'schedule_') or strpos($column, '_policy')) { $retval[$column] = 'time_unit'; } } } $retval['verified_time_sheet_date'] = 'time_stamp'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, '_hourly_rate') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } $retval['verified_time_sheet'] = 'first'; $retval['verified_time_sheet_date'] = 'first'; break; case 'templates': $retval = array('-1010-by_employee+regular' => TTi18n::gettext('Regular Time by Employee'), '-1020-by_employee+overtime' => TTi18n::gettext('Overtime by Employee'), '-1030-by_employee+premium' => TTi18n::gettext('Premium Time by Employee'), '-1040-by_employee+absence' => TTi18n::gettext('Absence Time by Employee'), '-1050-by_employee+regular+overtime+premium+absence' => TTi18n::gettext('All Time by Employee'), '-1060-by_employee+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Employee'), '-1070-by_employee+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Employee'), '-1080-by_employee+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Employee'), '-1090-by_employee+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Employee'), '-1100-by_employee+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Employee'), '-1110-by_date_by_full_name+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Date/Employee'), '-1120-by_date_by_full_name+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Date/Employee'), '-1130-by_date_by_full_name+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Date/Employee'), '-1140-by_date_by_full_name+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Date/Employee'), '-1150-by_date_by_full_name+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Date/Employee'), '-1160-by_full_name_by_date+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Employee/Date'), '-1170-by_full_name_by_date+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Employee/Date'), '-1180-by_full_name_by_date+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Employee/Date'), '-1190-by_full_name_by_date+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Employee/Date'), '-1200-by_full_name_by_date+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Employee/Date'), '-1210-by_branch+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Branch'), '-1220-by_branch+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Branch'), '-1230-by_branch+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Branch'), '-1240-by_branch+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Branch'), '-1250-by_branch+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Branch'), '-1260-by_department+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Department'), '-1270-by_department+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Department'), '-1280-by_department+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Department'), '-1290-by_department+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Department'), '-1300-by_department+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Department'), '-1310-by_branch_by_department+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Branch/Department'), '-1320-by_branch_by_department+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Branch/Department'), '-1330-by_branch_by_department+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Branch/Department'), '-1340-by_branch_by_department+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Branch/Department'), '-1350-by_branch_by_department+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Branch/Department'), '-1360-by_pay_period+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Pay Period'), '-1370-by_pay_period+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Period'), '-1380-by_pay_period+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Period'), '-1390-by_pay_period+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period'), '-1400-by_pay_period+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Period'), '-1410-by_pay_period_by_employee+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Pay Period/Employee'), '-1420-by_pay_period_by_employee+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Period/Employee'), '-1430-by_pay_period_by_employee+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Period/Employee'), '-1440-by_pay_period_by_employee+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period/Employee'), '-1450-by_pay_period_by_employee+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Period/Employee'), '-1460-by_pay_period_by_branch+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Pay Period/Branch'), '-1470-by_pay_period_by_branch+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Period/Branch'), '-1480-by_pay_period_by_branch+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Period/Branch'), '-1490-by_pay_period_by_branch+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period/Branch'), '-1500-by_pay_period_by_branch+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Period/Branch'), '-1510-by_pay_period_by_department+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Pay Period/Department'), '-1520-by_pay_period_by_department+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Period/Department'), '-1530-by_pay_period_by_department+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Period/Department'), '-1540-by_pay_period_by_department+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period/Department'), '-1550-by_pay_period_by_department+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Period/Department'), '-1560-by_pay_period_by_branch_by_department+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Pay Period/Branch/Department'), '-1570-by_pay_period_by_branch_by_department+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Period/Branch/Department'), '-1580-by_pay_period_by_branch_by_department+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Period/Branch/Department'), '-1590-by_pay_period_by_branch_by_department+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period/Branch/Department'), '-1600-by_pay_period_by_branch_by_department+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Period/Branch/Department'), '-1610-by_employee_by_pay_period+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Employee/Pay Period'), '-1620-by_employee_by_pay_period+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Employee/Pay Period'), '-1630-by_employee_by_pay_period+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Employee/Pay Period'), '-1640-by_employee_by_pay_period+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Employee/Pay Period'), '-1650-by_employee_by_pay_period+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Employee/Pay Period'), '-1660-by_branch_by_pay_period+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Branch/Pay Period'), '-1670-by_branch_by_pay_period+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Branch/Pay Period'), '-1680-by_branch_by_pay_period+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Branch/Pay Period'), '-1690-by_branch_by_pay_period+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Branch/Pay Period'), '-1700-by_branch_by_pay_period+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Branch/Pay Period'), '-1810-by_department_by_pay_period+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Department/Pay Period'), '-1820-by_department_by_pay_period+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Department/Pay Period'), '-1830-by_department_by_pay_period+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Department/Pay Period'), '-1840-by_department_by_pay_period+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Department/Pay Period'), '-1850-by_department_by_pay_period+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Pay Department/Pay Period'), '-1860-by_branch_by_department_by_pay_period+regular+regular_wage' => TTi18n::gettext('Regular Time+Wage by Branch/Department/Pay Period'), '-1870-by_branch_by_department_by_pay_period+overtime+overtime_wage' => TTi18n::gettext('Overtime+Wage by Pay Branch/Department/Pay Period'), '-1880-by_branch_by_department_by_pay_period+premium+premium_wage' => TTi18n::gettext('Premium Time+Wage by Pay Branch/Department/Pay Period'), '-1890-by_branch_by_department_by_pay_period+absence+absence_wage' => TTi18n::gettext('Absence Time+Wage by Pay Branch/Department/Pay Period'), '-1900-by_branch_by_department_by_pay_period+regular+regular_wage+overtime+overtime_wage+premium+premium_wage+absence+absence_wage' => TTi18n::gettext('All Time+Wage by Branch/Department/Pay Period'), '-3000-by_pay_period_by_employee+verified_time_sheet' => TTi18n::gettext('Timesheet Verification by Pay Period/Employee'), '-3010-by_verified_time_sheet_by_pay_period_by_employee+verified_time_sheet' => TTi18n::gettext('Timesheet Verification by Verification/Pay Period/Employee')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'by_pay_period_by_employee+verified_time_sheet': $retval['-1010-time_period']['time_period'] = 'last_pay_period'; $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'verified_time_sheet'; $retval['columns'][] = 'verified_time_sheet_date'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('verified_time_sheet' => 'desc'); $retval['sort'][] = array('verified_time_sheet_date' => 'asc'); break; case 'by_verified_time_sheet_by_pay_period_by_employee+verified_time_sheet': $retval['-1010-time_period']['time_period'] = 'last_pay_period'; $retval['columns'][] = 'verified_time_sheet'; $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'verified_time_sheet_date'; $retval['group'][] = 'verified_time_sheet'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('verified_time_sheet' => 'desc'); $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('verified_time_sheet_date' => 'asc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_pay_period'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns case 'regular': $retval['columns'][] = 'worked_time'; $retval['columns'][] = 'regular_time'; break; case 'overtime': case 'premium': case 'absence': $columns = Misc::trimSortPrefix($this->getOptions($template_keyword . '_columns')); if (is_array($columns)) { foreach ($columns as $column => $column_name) { if (strpos($column, '_wage') === FALSE and strpos($column, '_hourly_rate') === FALSE) { $retval['columns'][] = $column; } } } break; case 'regular_wage': $retval['columns'][] = 'regular_time_wage'; break; case 'overtime_wage': case 'premium_wage': case 'absence_wage': $columns = Misc::trimSortPrefix($this->getOptions(str_replace('_wage', '', $template_keyword) . '_columns')); if (is_array($columns)) { foreach ($columns as $column => $column_name) { if (strpos($column, '_wage') !== FALSE) { $retval['columns'][] = $column; } } } break; //Filter //Group By //SubTotal //Sort //Filter //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'branch_name'; $retval['group'][] = 'branch_name'; $retval['sort'][] = array('branch_name' => 'asc'); break; case 'by_department': $retval['columns'][] = 'department_name'; $retval['group'][] = 'department_name'; $retval['sort'][] = array('department_name' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'branch_name'; $retval['columns'][] = 'department_name'; $retval['group'][] = 'branch_name'; $retval['group'][] = 'department_name'; $retval['sub_total'][] = 'branch_name'; $retval['sort'][] = array('branch_name' => 'asc'); $retval['sort'][] = array('department_name' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'pay_period'; $retval['group'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_pay_period_by_employee': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_pay_period_by_branch': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'branch_name'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'branch_name'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('branch_name' => 'asc'); break; case 'by_pay_period_by_department': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'department_name'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'department_name'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('department_name' => 'asc'); break; case 'by_pay_period_by_branch_by_department': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'branch_name'; $retval['columns'][] = 'department_name'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'branch_name'; $retval['group'][] = 'department_name'; $retval['sub_total'][] = 'pay_period'; $retval['sub_total'][] = 'branch_name'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('branch_name' => 'asc'); $retval['sort'][] = array('department_name' => 'asc'); break; case 'by_employee_by_pay_period': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'full_name'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_branch_by_pay_period': $retval['columns'][] = 'branch_name'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'branch_name'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'branch_name'; $retval['sort'][] = array('branch_name' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_department_by_pay_period': $retval['columns'][] = 'department_name'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'department_name'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'department_name'; $retval['sort'][] = array('department_name' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_branch_by_department_by_pay_period': $retval['columns'][] = 'branch_name'; $retval['columns'][] = 'department_name'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'branch_name'; $retval['group'][] = 'department_name'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'branch_name'; $retval['sub_total'][] = 'department_name'; $retval['sort'][] = array('branch_name' => 'asc'); $retval['sort'][] = array('department_name' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_date_by_full_name': $retval['columns'][] = 'date_stamp'; $retval['columns'][] = 'full_name'; $retval['group'][] = 'date_stamp'; $retval['group'][] = 'full_name'; $retval['sub_total'][] = 'date_stamp'; $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('full_name' => 'asc'); break; case 'by_full_name_by_date': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'date_stamp'; $retval['group'][] = 'full_name'; $retval['group'][] = 'date_stamp'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); break; } } } break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-4020-exclude_ytd_adjustment' => TTi18n::gettext('Exclude YTD Adjustments'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions('transaction', TTi18n::getText('Transaction Date'), 13, TRUE); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'GeneralLedgerSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'GeneralLedgerSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'GeneralLedgerSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'GeneralLedgerSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-2010-account' => TTi18n::gettext('Account')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2100-debit_amount' => TTi18n::gettext('Debit'), '-2110-credit_amount' => TTi18n::gettext('Credit')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, '_amount') !== FALSE) { $retval[$column] = 'currency'; } } } $retval['verified_time_sheet_date'] = 'time_stamp'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, '_hourly_rate') !== FALSE or substr($column, 0, 2) == 'PR') { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } $retval['verified_time_sheet'] = 'first'; $retval['verified_time_sheet_date'] = 'first'; break; case 'templates': $retval = array('-1010-by_employee' => TTi18n::gettext('by Employee'), '-1110-by_title' => TTi18n::gettext('by Title'), '-1120-by_group' => TTi18n::gettext('by Group'), '-1130-by_branch' => TTi18n::gettext('by Branch'), '-1140-by_department' => TTi18n::gettext('by Department'), '-1150-by_branch_by_department' => TTi18n::gettext('by Branch/Department'), '-1160-by_pay_period' => TTi18n::gettext('By Pay Period')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_pay_period'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns //Filter //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'full_name'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_title': $retval['columns'][] = 'title'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'title'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'title'; $retval['sort'][] = array('title' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_group': $retval['columns'][] = 'user_group'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'user_group'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'user_group'; $retval['sort'][] = array('user_group' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'default_department'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'default_branch'; $retval['sub_total'][] = 'default_department'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'transaction-pay_period'; $retval['columns'][] = 'account'; $retval['columns'][] = 'debit_amount'; $retval['columns'][] = 'credit_amount'; $retval['group'][] = 'transaction-pay_period'; $retval['group'][] = 'account'; $retval['sub_total'][] = 'transaction-pay_period'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); $retval['sort'][] = array('account' => 'asc'); break; } } } break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
function setCustomColumnConfig($columns) { if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $rcclf->getByCompanyId($this->getUserObject()->getCompany()); $columns_data = array(); if ($rcclf->getRecordCount() > 0) { foreach ($rcclf as $rccf) { $column = 'custom_column' . $rccf->getId(); if (in_array($column, $columns)) { $row['variable_name'] = $column; $row['label'] = $rccf->getName(); $row['type'] = $rccf->getType(); $row['format'] = $rccf->getFormat(); switch ($row['type']) { case 10: $row['definition'] = array('include_columns' => $rccf->getIncludeColumns(), 'exclude_columns' => $rccf->getExcludeColumns()); break; case 20: case 21: case 30: case 31: $row['definition'] = $rccf->getFormula(); $columns_data = array_merge($columns_data, (array) TTMath::parseColumnsFromFormula($row['definition'])); break; } $this->config['custom_column'][] = $row; } } } $this->setColumnDataConfig($columns_data); } return TRUE; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-qualification_group_id' => TTi18n::gettext('Qualification Group'), '-2085-qualification_type_id' => TTi18n::gettext('Qualification Type'), '-2090-qualification_id' => TTi18n::gettext('Qualifications'), '-2100-proficiency_id' => TTi18n::gettext('Skill Proficiency'), '-2140-fluency_id' => TTi18n::gettext('Language Fluency'), '-2150-competency_id' => TTi18n::gettext('Language Competency'), '-2170-ownership_id' => TTi18n::gettext('Membership Ownership'), '-2200-membership_renewal_date' => TTi18n::gettext('Membership Renewal Date'), '-2250-skill_expiry_date' => TTi18n::gettext('Skill Expiry Date'), '-2300-license_expiry_date' => TTi18n::gettext('License Expiry Date'), '-3000-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; //case 'time_period': //case 'time_period': case 'membership_renewal_date': case 'skill_expiry_date': case 'license_expiry_date': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = array_merge(TTDate::getReportDateOptions('user.hire', TTi18n::getText('Hire Date'), 15, FALSE), TTDate::getReportDateOptions('user.termination', TTi18n::getText('Termination Date'), 16, FALSE), TTDate::getReportDateOptions('user.birth', TTi18n::getText('Birth Date'), 17, FALSE)); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'UserQualificationReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'UserQualificationReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'UserQualificationReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'UserQualificationReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-user.first_name' => TTi18n::gettext('First Name'), '-1001-user.middle_name' => TTi18n::gettext('Middle Name'), '-1002-user.last_name' => TTi18n::gettext('Last Name'), '-1005-user.full_name' => TTi18n::gettext('Full Name'), '-1010-user.user_name' => TTi18n::gettext('User Name'), '-1020-user.phone_id' => TTi18n::gettext('PIN/Phone ID'), '-1030-user.employee_number' => TTi18n::gettext('Employee #'), '-1040-user.status' => TTi18n::gettext('Employee Status'), '-1050-user.title' => TTi18n::gettext('Title'), '-1060-user.province' => TTi18n::gettext('Province/State'), '-1070-user.country' => TTi18n::gettext('Country'), '-1080-user.user_group' => TTi18n::gettext('Employee Group'), '-1090-user.default_branch' => TTi18n::gettext('Branch'), '-1100-user.default_department' => TTi18n::gettext('Department'), '-1200-user.permission_control' => TTi18n::gettext('Permission Group'), '-1210-user.pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-user.policy_group' => TTi18n::gettext('Policy Group'), '-1310-user.sex' => TTi18n::gettext('Gender'), '-1320-user.address1' => TTi18n::gettext('Address 1'), '-1330-user.address2' => TTi18n::gettext('Address 2'), '-1340-user.city' => TTi18n::gettext('City'), '-1370-user.postal_code' => TTi18n::gettext('Postal Code'), '-1380-user.work_phone' => TTi18n::gettext('Work Phone'), '-1391-user.work_phone_ext' => TTi18n::gettext('Work Phone Ext'), '-1400-user.home_phone' => TTi18n::gettext('Home Phone'), '-1410-user.mobile_phone' => TTi18n::gettext('Mobile Phone'), '-1420-user.fax_phone' => TTi18n::gettext('Fax Phone'), '-1430-user.home_email' => TTi18n::gettext('Home Email'), '-1440-user.work_email' => TTi18n::gettext('Work Email'), '-1480-user.sin' => TTi18n::gettext('SIN/SSN'), '-1490-user.note' => TTi18n::gettext('Employee Note'), '-1499-user.hierarchy_control_display' => TTi18n::gettext('Hierarchy'), '-1820-user_wage.type' => TTi18n::gettext('Wage Type'), '-1840-user_wage.effective_date' => TTi18n::gettext('Wage Effective Date'), '-1850-user_wage.note' => TTi18n::gettext('Wage Note'), '-1900-user_preference.language_display' => TTi18n::gettext('Language'), '-1910-user_preference.date_format_display' => TTi18n::gettext('Date Format'), '-1920-user_preference.time_format_display' => TTi18n::gettext('Time Format'), '-1930-user_preference.time_unit_format_display' => TTi18n::gettext('Time Units'), '-1940-user_preference.time_zone_display' => TTi18n::gettext('Time Zone'), '-1950-user_preference.items_per_page' => TTi18n::gettext('Rows Per page'), '-2060-user.password_updated_date' => TTi18n::gettext('Password Updated Date'), '-2080-qualification.type' => TTi18n::gettext('Qualification Type'), '-2010-qualification' => TTi18n::gettext('Qualification'), '-2020-qualification.group' => TTi18n::gettext('Qualification Group'), '-2030-user_skill.proficiency' => TTi18n::gettext('Skill Proficiency'), '-2040-user_skill.experience' => TTi18n::gettext('Skill Experience'), '-2050-user_skill.first_used_date' => TTi18n::gettext('Skill First Used Date'), '-2060-user_skill.last_used_date' => TTi18n::gettext('Skill Last Used Date'), '-2070-user_skill.expiry_date' => TTi18n::gettext('Skill Expiry Date'), '-2090-user_education.institute' => TTi18n::gettext('Institute'), '-2100-user_education.major' => TTi18n::gettext('Major/Specialization'), '-2110-user_education.minor' => TTi18n::gettext('Minor'), '-2120-user_education.graduate_date' => TTi18n::gettext('Graduation Date'), '-2130-user_education.grade_score' => TTi18n::gettext('Grade/Score'), '-2140-user_education.start_date' => TTi18n::gettext('Education Start Date'), '-2150-user_education.end_date' => TTi18n::gettext('Education End Date'), '-2160-user_license.license_number' => TTi18n::gettext('License Number'), '-2170-user_license.license_issued_date' => TTi18n::gettext('License Issued Date'), '-2180-user_license.license_expiry_date' => TTi18n::gettext('License Expiry Date'), '-2190-user_language.fluency' => TTi18n::gettext('Language Fluency'), '-2200-user_language.competency' => TTi18n::gettext('Language Competency'), '-2210-user_membership.ownership' => TTi18n::gettext('Membership Ownership'), '-2240-user_membership.start_date' => TTi18n::gettext('Membership Start Date'), '-2250-user_membership.renewal_date' => TTi18n::gettext('Membership Renewal Date')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-1830-user_wage.wage' => TTi18n::gettext('Wage'), '-1835-user_wage.hourly_rate' => TTi18n::gettext('Hourly Rate'), '-2220-user_membership.amount' => TTi18n::gettext('Membership Amount'), '-2900-total_user' => TTi18n::gettext('Total Employees')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'amount') !== FALSE or strpos($column, 'wage') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } } } $retval['user.password_updated_date'] = 'time_stamp'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { case 'user_membership.amount': $retval[$column] = 'sum'; break; default: if (strpos($column, 'hourly_rate') !== FALSE or strpos($column, 'wage') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } break; case 'templates': $retval = array('-1250-by_employee+language' => TTi18n::gettext('Language Information By Employee'), '-1252-by_qualification_by_employee+language' => TTi18n::gettext('Language Information By Language/Employee'), '-1260-by_employee+membership' => TTi18n::gettext('Membership Information By Employee'), '-1262-by_qualification_by_employee+membership' => TTi18n::gettext('Membership Information By Membership/Employee'), '-1264-by_employee+membership_renewal' => TTi18n::gettext('Membership Renewals By Employee'), '-1270-by_employee+license' => TTi18n::gettext('License Information By Employee'), '-1272-by_license_by_employee+license' => TTi18n::gettext('License Information By License/Employee'), '-1274-by_employee+license_renewal' => TTi18n::gettext('License Renewals By Employee'), '-1280-by_employee+education' => TTi18n::gettext('Education Information By Employee'), '-1282-by_course_by_employee+education' => TTi18n::gettext('Education Information By Course/Employee'), '-1290-by_employee+skill' => TTi18n::gettext('Skills Information By Employee'), '-1292-by_skill_by_employee+skill' => TTi18n::gettext('Skills Information By Skill/Employee'), '-1294-by_employee+skill_renewal' => TTi18n::gettext('Skill Renewals By Employee')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { //language case 'by_employee+language': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_language.fluency'; $retval['columns'][] = 'user_language.competency'; $retval['-2085-qualification_type_id'] = array(40); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_language.fluency' => 'asc'); $retval['sort'][] = array('user_language.competency' => 'asc'); break; case 'by_qualification_by_employee+language': $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_language.fluency'; $retval['columns'][] = 'user_language.competency'; $retval['columns'][] = 'user.full_name'; $retval['-2085-qualification_type_id'] = array(40); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_language.fluency' => 'asc'); $retval['sort'][] = array('user_language.competency' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; //membership //membership case 'by_employee+membership': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_membership.ownership'; $retval['columns'][] = 'user_membership.amount'; $retval['columns'][] = 'user_membership.start_date'; $retval['columns'][] = 'user_membership.renewal_date'; $retval['-2085-qualification_type_id'] = array(50); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); break; case 'by_qualification_by_employee+membership': $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_membership.ownership'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_membership.amount'; $retval['columns'][] = 'user_membership.renewal_date'; $retval['columns'][] = 'user_membership.start_date'; $retval['-2085-qualification_type_id'] = array(50); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_membership.ownership' => 'asc'); $retval['sort'][] = array('user_membership.renewal_date' => 'asc'); break; case 'by_employee+membership_renewal': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_membership.ownership'; $retval['columns'][] = 'user_membership.amount'; $retval['columns'][] = 'user_membership.renewal_date'; $retval['-2085-qualification_type_id'] = array(50); $retval['sort'][] = array('user_membership.renewal_date' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; //license //license case 'by_employee+license': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_license.license_number'; $retval['columns'][] = 'user_license.license_issued_date'; $retval['columns'][] = 'user_license.license_expiry_date'; $retval['-2085-qualification_type_id'] = array(30); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); break; case 'by_license_by_employee+license': $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_license.license_number'; $retval['columns'][] = 'user_license.license_issued_date'; $retval['columns'][] = 'user_license.license_expiry_date'; $retval['-2085-qualification_type_id'] = array(30); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_license.license_expiry_date' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; case 'by_employee+license_renewal': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_license.license_number'; $retval['columns'][] = 'user_license.license_issued_date'; $retval['columns'][] = 'user_license.license_expiry_date'; $retval['-2085-qualification_type_id'] = array(30); $retval['sort'][] = array('user_license.license_expiry_date' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; //education //education case 'by_employee+education': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_education.institute'; $retval['columns'][] = 'user_education.major'; $retval['columns'][] = 'user_education.minor'; $retval['columns'][] = 'user_education.start_date'; $retval['columns'][] = 'user_education.end_date'; $retval['columns'][] = 'user_education.graduate_date'; $retval['columns'][] = 'user_education.grade_score'; $retval['-2085-qualification_type_id'] = array(20); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); break; case 'by_course_by_employee+education': $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_education.grade_score'; $retval['columns'][] = 'user_education.institute'; $retval['columns'][] = 'user_education.major'; $retval['columns'][] = 'user_education.minor'; $retval['columns'][] = 'user_education.start_date'; $retval['columns'][] = 'user_education.end_date'; $retval['columns'][] = 'user_education.graduate_date'; $retval['-2085-qualification_type_id'] = array(20); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_education.grade_score' => 'desc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; //skill //skill case 'by_employee+skill': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_skill.proficiency'; $retval['columns'][] = 'user_skill.experience'; $retval['columns'][] = 'user_skill.first_used_date'; $retval['columns'][] = 'user_skill.last_used_date'; $retval['columns'][] = 'user_skill.expiry_date'; $retval['-2085-qualification_type_id'] = array(10); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); break; case 'by_skill_by_employee+skill': $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'proficiency'; $retval['columns'][] = 'user_skill.experience'; $retval['columns'][] = 'user_skill.first_used_date'; $retval['columns'][] = 'user_skill.last_used_date'; $retval['columns'][] = 'user_skill.expiry_date'; $retval['-2085-qualification_type_id'] = array(10); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_skill.proficiency' => 'desc'); $retval['sort'][] = array('user_skill.experience' => 'desc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; case 'by_employee+skill_renewal': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'qualification'; $retval['columns'][] = 'user_skill.proficiency'; $retval['columns'][] = 'user_skill.experience'; $retval['columns'][] = 'user_skill.first_used_date'; $retval['columns'][] = 'user_skill.last_used_date'; $retval['columns'][] = 'user_skill.expiry_date'; $retval['-2085-qualification_type_id'] = array(10); $retval['sort'][] = array('user_skill.expiry_date' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('qualification' => 'asc'); $retval['sort'][] = array('user_skill.proficiency' => 'desc'); $retval['sort'][] = array('user_skill.experience' => 'desc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-schedule_branch_id' => TTi18n::gettext('Schedule Branch'), '-2090-schedule_department_id' => TTi18n::gettext('Schedule Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-3000-status_id' => TTi18n::gettext('Schedule Status'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions(NULL, TTi18n::getText('Date'), 15, TRUE); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'ScheduleSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'ScheduleSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'ScheduleSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'ScheduleSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1055-city' => TTi18n::gettext('City'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-1290-note' => TTi18n::gettext('Employee Note'), '-1295-tag' => TTi18n::gettext('Tags'), '-1600-branch' => TTi18n::gettext('Branch'), '-1610-department' => TTi18n::gettext('Department'), '-1620-schedule_policy' => TTi18n::gettext('Schedule Policy'), '-1640-schedule_status' => TTi18n::gettext('Schedule Status'), '-1650-absence_policy' => TTi18n::gettext('Absence Policy'), '-1670-start_time' => TTi18n::gettext('Start Time'), '-1680-end_time' => TTi18n::gettext('End Time'), '-5000-schedule_note' => TTi18n::gettext('Note')); $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2010-hourly_rate' => TTi18n::gettext('Hourly Rate'), '-2100-total_time' => TTi18n::gettext('Total Time'), '-2110-total_time_wage' => TTi18n::gettext('Total Time Wage'), '-2112-total_time_wage_burden' => TTi18n::gettext('Total Time Wage Burden'), '-2114-total_time_wage_with_burden' => TTi18n::gettext('Total Time Wage w/Burden'), '-4000-total_shift' => TTi18n::gettext('Total Shifts')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = $this->getOptions('columns'); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'absence_policy')) { //Ignore } elseif (strpos($column, 'start_time') !== FALSE or strpos($column, 'end_time') !== FALSE) { $retval[$column] = 'time'; } elseif (strpos($column, '_wage') !== FALSE or strpos($column, '_hourly_rate') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } elseif (strpos($column, '_time') or strpos($column, '_policy')) { $retval[$column] = 'time_unit'; } } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, '_hourly_rate') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } break; case 'templates': $retval = array('-1010-by_employee+work+total_time' => TTi18n::gettext('Work Time by Employee'), '-1020-by_employee+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Employee'), '-1030-by_title+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Title'), '-1110-by_date_by_full_name+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Date/Employee'), '-1120-by_full_name_by_date+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Employee/Date'), '-1210-by_branch+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Branch'), '-1220-by_department+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Department'), '-1230-by_branch_by_department+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Branch/Department'), '-1310-by_pay_period+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period'), '-1320-by_pay_period_by_employee+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Employee'), '-1330-by_pay_period_by_branch+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Branch'), '-1340-by_pay_period_by_department+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Department'), '-1350-by_pay_period_by_branch_by_department+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Branch/Department'), '-1410-by_employee_by_pay_period+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Employee/Pay Period'), '-1420-by_branch_by_pay_period+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Branch/Pay Period'), '-1430-by_department_by_pay_period+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Department/Pay Period'), '-1440-by_branch_by_department_by_pay_period+work+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Branch/Department/Pay Period'), '-1510-by_title_by_start_time+work+total_time+total_time_wage+total_shift' => TTi18n::gettext('Work Time+Wage+Total Shifts by Title/Start Time'), '-1520-by_date_by_title+work+total_time+total_time_wage+total_shift' => TTi18n::gettext('Work Time+Wage+Total Shifts by Date/Title'), '-2010-by_employee+absence+total_time' => TTi18n::gettext('Absence Time by Employee'), '-2020-by_employee+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Employee'), '-2030-by_title+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Title'), '-2110-by_date_by_full_name+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Date/Employee'), '-2120-by_full_name_by_date+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Employee/Date'), '-2210-by_branch+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Branch'), '-2220-by_department+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Department'), '-2230-by_branch_by_department+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Branch/Department'), '-2310-by_pay_period+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period'), '-2320-by_pay_period_by_employee+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Pay Period/Employee'), '-2330-by_pay_period_by_branch+absence+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Branch'), '-2340-by_pay_period_by_department+absence+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Department'), '-2350-by_pay_period_by_branch_by_department+absence+total_time+total_time_wage' => TTi18n::gettext('Work Time+Wage by Pay Period/Branch/Department'), '-2410-by_employee_by_pay_period+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Employee/Pay Period'), '-2420-by_branch_by_pay_period+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Branch/Pay Period'), '-2430-by_department_by_pay_period+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Department/Pay Period'), '-2440-by_branch_by_department_by_pay_period+absence+total_time+total_time_wage' => TTi18n::gettext('Absence Time+Wage by Branch/Department/Pay Period')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { //case 'by_employee+actual_time': // break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_pay_period'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns case 'total_time': $retval['columns'][] = 'total_time'; break; case 'total_time_wage': $retval['columns'][] = 'total_time_wage'; break; case 'absence_policy': $retval['columns'][] = 'absence_policy'; break; //Filter //Filter case 'work': $retval['filter']['status_id'] = array(10); break; case 'absence': $retval['filter']['status_id'] = array(20); break; case 'total_shift': $retval['columns'][] = 'total_shift'; break; //Group By //SubTotal //Sort //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_title': $retval['columns'][] = 'title'; $retval['group'][] = 'title'; $retval['sort'][] = array('title' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'branch'; $retval['group'][] = 'branch'; $retval['sort'][] = array('branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'department'; $retval['group'][] = 'department'; $retval['sort'][] = array('department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'branch'; $retval['columns'][] = 'department'; $retval['group'][] = 'branch'; $retval['group'][] = 'department'; $retval['sub_total'][] = 'branch'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('department' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'pay_period'; $retval['group'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_pay_period_by_employee': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_pay_period_by_branch': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'branch'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'branch'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('branch' => 'asc'); break; case 'by_pay_period_by_department': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'department'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'department'; $retval['sub_total'][] = 'pay_period'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('department' => 'asc'); break; case 'by_pay_period_by_branch_by_department': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'branch'; $retval['columns'][] = 'department'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'branch'; $retval['group'][] = 'department'; $retval['sub_total'][] = 'pay_period'; $retval['sub_total'][] = 'branch'; $retval['sort'][] = array('pay_period' => 'asc'); $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('department' => 'asc'); break; case 'by_employee_by_pay_period': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'full_name'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_branch_by_pay_period': $retval['columns'][] = 'branch'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'branch'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'branch'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_department_by_pay_period': $retval['columns'][] = 'department'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'department'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'department'; $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_branch_by_department_by_pay_period': $retval['columns'][] = 'branch'; $retval['columns'][] = 'department'; $retval['columns'][] = 'pay_period'; $retval['group'][] = 'branch'; $retval['group'][] = 'department'; $retval['group'][] = 'pay_period'; $retval['sub_total'][] = 'branch'; $retval['sub_total'][] = 'department'; $retval['sort'][] = array('branch' => 'asc'); $retval['sort'][] = array('department' => 'asc'); $retval['sort'][] = array('pay_period' => 'asc'); break; case 'by_date_by_full_name': $retval['columns'][] = 'date_stamp'; $retval['columns'][] = 'full_name'; $retval['group'][] = 'date_stamp'; $retval['group'][] = 'full_name'; $retval['sub_total'][] = 'date_stamp'; $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('full_name' => 'asc'); break; case 'by_date_by_title': $retval['columns'][] = 'date_stamp'; $retval['columns'][] = 'title'; $retval['group'][] = 'date_stamp'; $retval['group'][] = 'title'; $retval['sub_total'][] = 'date_stamp'; $retval['sort'][] = array('date_stamp' => 'asc'); $retval['sort'][] = array('title' => 'asc'); break; case 'by_full_name_by_date': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'date_stamp'; $retval['group'][] = 'full_name'; $retval['group'][] = 'date_stamp'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('date_stamp' => 'asc'); break; case 'by_title_by_start_time': $retval['columns'][] = 'title'; $retval['columns'][] = 'start_time'; $retval['columns'][] = 'total_shift'; $retval['group'][] = 'title'; $retval['group'][] = 'start_time'; $retval['sub_total'][] = 'title'; $retval['sort'][] = array('title' => 'asc'); $retval['sort'][] = array('start_time' => 'asc'); break; } } } break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $psf = TTnew('PayStubFactory'); $retval = array_merge(parent::getOptions('default_output_format'), array('-1100-pdf_employee_pay_stub' => TTi18n::gettext('Employee Pay Stub'), '-1110-pdf_employer_pay_stub' => TTi18n::gettext('Employer Pay Stub')), Misc::addSortPrefix(Misc::trimSortPrefix($psf->getOptions('export_type')), 1200)); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2080-currency_id' => TTi18n::gettext('Currency'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-4020-exclude_ytd_adjustment' => TTi18n::gettext('Exclude YTD Adjustments'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = TTDate::getReportDateOptions('transaction', TTi18n::getText('Transaction Date'), 13, TRUE); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'PayStubSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'PayStubSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'PayStubSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'PayStubSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1055-city' => TTi18n::gettext('City'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Default Branch'), '-1100-default_department' => TTi18n::gettext('Default Department'), '-1110-currency' => TTi18n::gettext('Currency'), '-1131-current_currency' => TTi18n::gettext('Current Currency'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-1280-sin' => TTi18n::gettext('SIN/SSN'), '-1290-note' => TTi18n::gettext('Note'), '-1295-tag' => TTi18n::gettext('Tags')); $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2900-total_pay_stub' => TTi18n::gettext('Total Pay Stubs')); $retval = array_merge($retval, $this->getOptions('pay_stub_account_amount_columns')); ksort($retval); break; case 'pay_stub_account_amount_columns': //Get all pay stub accounts $retval = array(); $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(10, 20, 30, 40, 50, 60, 65)); if ($psealf->getRecordCount() > 0) { $type_options = $psealf->getOptions('type'); foreach ($type_options as $key => $val) { $type_options[$key] = str_replace(array('Employee', 'Employer', 'Deduction', 'Total'), array('EE', 'ER', 'Ded', ''), $val); } $i = 0; foreach ($psealf as $psea_obj) { //Need to make the PSEA_ID a string so we can array_merge it properly later. if ($psea_obj->getType() == 40) { //Total accounts. $prefix = NULL; } else { $prefix = $type_options[$psea_obj->getType()] . ' - '; } $retval['-3' . str_pad($i, 3, 0, STR_PAD_LEFT) . '-PA' . $psea_obj->getID()] = $prefix . $psea_obj->getName(); if ($psea_obj->getType() == 10) { //Earnings only can see units. $retval['-4' . str_pad($i, 3, 0, STR_PAD_LEFT) . '-PR' . $psea_obj->getID()] = $prefix . $psea_obj->getName() . ' [' . TTi18n::getText('Rate') . ']'; $retval['-5' . str_pad($i, 3, 0, STR_PAD_LEFT) . '-PU' . $psea_obj->getID()] = $prefix . $psea_obj->getName() . ' [' . TTi18n::getText('Units') . ']'; } if ($psea_obj->getType() == 50) { //Accruals, display balance/YTD amount. $retval['-6' . str_pad($i, 3, 0, STR_PAD_LEFT) . '-PY' . $psea_obj->getID()] = $prefix . $psea_obj->getName() . ' [' . TTi18n::getText('Balance') . ']'; } $i++; } } break; case 'pay_stub_account_unit_columns': //Units are only good for earnings? break; case 'pay_stub_account_ytd_columns': break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column'))); if (is_array($columns)) { foreach ($columns as $column => $name) { if (substr($column, 0, 2) == 'PU') { $retval[$column] = 'numeric'; } elseif (strpos($column, '_wage') !== FALSE or strpos($column, '_hourly_rate') !== FALSE or substr($column, 0, 2) == 'PA' or substr($column, 0, 2) == 'PY' or substr($column, 0, 2) == 'PR') { $retval[$column] = 'currency'; } elseif (strpos($column, '_time') or strpos($column, '_policy')) { $retval[$column] = 'time_unit'; } } } $retval['verified_time_sheet_date'] = 'time_stamp'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, '_hourly_rate') !== FALSE or substr($column, 0, 2) == 'PR') { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } $retval['verified_time_sheet'] = 'first'; $retval['verified_time_sheet_date'] = 'first'; break; case 'templates': $retval = array('-1010-by_employee+totals' => TTi18n::gettext('Totals by Employee'), '-1020-by_employee+earnings' => TTi18n::gettext('Earnings by Employee'), '-1030-by_employee+employee_deductions' => TTi18n::gettext('Deductions by Employee'), '-1040-by_employee+employer_deductions' => TTi18n::gettext('Employer Contributions by Employee'), '-1050-by_employee+accruals' => TTi18n::gettext('Accruals by Employee'), '-1060-by_employee+totals+earnings+employee_deductions+employer_deductions+accruals' => TTi18n::gettext('All Accounts by Employee'), '-1110-by_title+totals' => TTi18n::gettext('Totals by Title'), '-1120-by_group+totals' => TTi18n::gettext('Totals by Group'), '-1130-by_branch+totals' => TTi18n::gettext('Totals by Branch'), '-1140-by_department+totals' => TTi18n::gettext('Totals by Department'), '-1150-by_branch_by_department+totals' => TTi18n::gettext('Totals by Branch/Department'), '-1160-by_pay_period+totals' => TTi18n::gettext('Totals by Pay Period'), '-1210-by_pay_period_by_employee+totals' => TTi18n::gettext('Totals by Pay Period/Employee'), '-1220-by_employee_by_pay_period+totals' => TTi18n::gettext('Totals by Employee/Pay Period'), '-1230-by_branch_by_pay_period+totals' => TTi18n::gettext('Totals by Branch/Pay Period'), '-1240-by_department_by_pay_period+totals' => TTi18n::gettext('Totals by Department/Pay Period'), '-1250-by_branch_by_department_by_pay_period+totals' => TTi18n::gettext('Totals by Branch/Department/Pay Period')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { $pseallf = TTnew('PayStubEntryAccountLinkListFactory'); $pseallf->getByCompanyId($this->getUserObject()->getCompany()); if ($pseallf->getRecordCount() > 0) { $pseal_obj = $pseallf->getCurrent(); $default_linked_columns = array($pseal_obj->getTotalGross(), $pseal_obj->getTotalNetPay(), $pseal_obj->getTotalEmployeeDeduction(), $pseal_obj->getTotalEmployerDeduction()); } else { $default_linked_columns = array(); } unset($pseallf, $pseal_obj); switch ($template) { default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); $retval['-1010-time_period']['time_period'] = 'last_pay_period'; //Parse template name, and use the keywords separated by '+' to determine settings. $template_keywords = explode('+', $template); if (is_array($template_keywords)) { foreach ($template_keywords as $template_keyword) { Debug::Text(' Keyword: ' . $template_keyword, __FILE__, __LINE__, __METHOD__, 10); switch ($template_keyword) { //Columns case 'earnings': $retval['columns'][] = 'PA' . $default_linked_columns[0]; //Total Gross $retval['columns'][] = 'PA' . $default_linked_columns[1]; //Net Pay $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(10)); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $retval['columns'][] = 'PA' . $psea_obj->getID(); } } break; case 'employee_deductions': $retval['columns'][] = 'PA' . $default_linked_columns[2]; //Employee Deductions $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(20)); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $retval['columns'][] = 'PA' . $psea_obj->getID(); } } break; case 'employer_deductions': $retval['columns'][] = 'PA' . $default_linked_columns[3]; //Employor Deductions $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(30)); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $retval['columns'][] = 'PA' . $psea_obj->getID(); } } break; case 'totals': $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(40)); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $retval['columns'][] = 'PA' . $psea_obj->getID(); } } break; case 'accruals': $psealf = TTnew('PayStubEntryAccountListFactory'); $psealf->getByCompanyIdAndStatusIdAndTypeId($this->getUserObject()->getCompany(), 10, array(50)); if ($psealf->getRecordCount() > 0) { foreach ($psealf as $psea_obj) { $retval['columns'][] = 'PA' . $psea_obj->getID(); } } break; //Filter //Group By //SubTotal //Sort //Filter //Group By //SubTotal //Sort case 'by_employee': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_title': $retval['columns'][] = 'title'; $retval['group'][] = 'title'; $retval['sort'][] = array('title' => 'asc'); break; case 'by_group': $retval['columns'][] = 'user_group'; $retval['group'][] = 'user_group'; $retval['sort'][] = array('user_group' => 'asc'); break; case 'by_branch': $retval['columns'][] = 'default_branch'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_department': $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_branch_by_department': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'transaction-pay_period'; $retval['group'][] = 'transaction-pay_period'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); break; case 'by_pay_period_by_employee': $retval['columns'][] = 'transaction-pay_period'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['group'][] = 'transaction-pay_period'; $retval['group'][] = 'first_name'; $retval['group'][] = 'last_name'; $retval['sub_total'][] = 'transaction-pay_period'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_pay_period_by_branch': $retval['columns'][] = 'transaction-pay_period'; $retval['columns'][] = 'default_branch'; $retval['group'][] = 'transaction-pay_period'; $retval['group'][] = 'default_branch'; $retval['sub_total'][] = 'transaction-pay_period'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); break; case 'by_pay_period_by_department': $retval['columns'][] = 'transaction-pay_period'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'transaction-pay_period'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'transaction-pay_period'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_pay_period_by_branch_by_department': $retval['columns'][] = 'transaction-pay_period'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['group'][] = 'transaction-pay_period'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'transaction-pay_period'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('transaction-pay_period' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); break; case 'by_employee_by_pay_period': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'transaction-pay_period'; $retval['group'][] = 'full_name'; $retval['group'][] = 'transaction-pay_period'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('full_name' => 'asc'); $retval['sort'][] = array('transaction-pay_period' => 'asc'); break; case 'by_branch_by_pay_period': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'transaction-pay_period'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'transaction-pay_period'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('transaction-pay_period' => 'asc'); break; case 'by_department_by_pay_period': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'transaction-pay_period'; $retval['group'][] = 'default_department'; $retval['group'][] = 'transaction-pay_period'; $retval['sub_total'][] = 'default_department'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('transaction-pay_period' => 'asc'); break; case 'by_branch_by_department_by_pay_period': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'transaction-pay_period'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['group'][] = 'transaction-pay_period'; $retval['sub_total'][] = 'default_branch'; $retval['sub_total'][] = 'default_department'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('transaction-pay_period' => 'asc'); break; } } } break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-3000-exception_policy_type_id' => TTi18n::gettext('Exception'), '-3050-exception_policy_severity_id' => TTi18n::gettext('Severity'), '-4000-pay_period_id' => TTi18n::gettext('Pay Period'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = array_merge(TTDate::getReportDateOptions(NULL, TTi18n::gettext('Date'), 16, TRUE)); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'ExceptionReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'ExceptionReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'ExceptionReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'ExceptionReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1010-user_name' => TTi18n::gettext('User Name'), '-1020-phone_id' => TTi18n::gettext('PIN/Phone ID'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1040-user_status' => TTi18n::gettext('Employee Status'), '-1050-title' => TTi18n::gettext('Employee Title'), '-1060-province' => TTi18n::gettext('Province/State'), '-1070-country' => TTi18n::gettext('Country'), '-1080-user_group' => TTi18n::gettext('Employee Group'), '-1090-default_branch' => TTi18n::gettext('Branch'), '-1100-default_department' => TTi18n::gettext('Department'), '-1130-permission_group' => TTi18n::gettext('Permission Group'), '-1150-severity' => TTi18n::gettext('Severity'), '-1160-exception_policy_type' => TTi18n::gettext('Exception'), '-1180-policy_group' => TTi18n::gettext('Policy Group'), '-1190-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1170-exception_policy_type_id' => TTi18n::gettext('Code')); $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2050-total_exception' => TTi18n::gettext('Total Exceptions')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'wage') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } if (strpos($column, 'amount') !== FALSE) { $retval[$column] = 'time_unit'; } } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, 'hourly_rate') !== FALSE or strpos($column, 'wage') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } break; case 'templates': $retval = array('-1250-by_severity' => TTi18n::gettext('Exceptions by Severity'), '-1260-by_exception' => TTi18n::gettext('Exceptions by Name'), '-1270-by_pay_period' => TTi18n::gettext('Exceptions by Pay Period'), '-1280-by_employee_by_severity_by_name' => TTi18n::gettext('Exceptions by Employee/Severity/Name'), '-1282-by_severity_by_name_by_employee' => TTi18n::gettext('Exceptions by Severity/Name/Employee'), '-1300-by_severity_by_name_by_dow' => TTi18n::gettext('Exceptions by Severity/Name/Day of Week')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { $retval['-1010-time_period']['time_period'] = 'last_pay_period'; switch ($template) { case 'by_severity': $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['sub_total'][] = 'severity'; $retval['sort'][] = array('severity' => 'asc', 'total_exception' => 'desc'); break; case 'by_exception': $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['sort'][] = array('total_exception' => 'desc', 'severity' => 'asc'); break; case 'by_pay_period': $retval['columns'][] = 'pay_period'; $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'pay_period'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['sub_total'][] = 'pay_period'; $retval['sub_total'][] = 'severity'; $retval['sort'][] = array('pay_period' => 'desc', 'severity' => 'asc', 'total_exception' => 'desc'); break; case 'by_employee_by_severity_by_name': $retval['columns'][] = 'full_name'; $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'full_name'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['sub_total'][] = 'full_name'; $retval['sub_total'][] = 'severity'; $retval['sort'][] = array('full_name' => 'asc', 'severity' => 'asc', 'total_exception' => 'desc'); break; case 'by_severity_by_name_by_employee': $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'full_name'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['group'][] = 'full_name'; $retval['sub_total'][] = 'severity'; $retval['sub_total'][] = 'exception_policy_type'; $retval['sub_total'][] = 'full_name'; $retval['sort'][] = array('severity' => 'asc', 'total_exception' => 'desc'); break; case 'by_severity_by_name_by_dow': $retval['columns'][] = 'severity'; $retval['columns'][] = 'exception_policy_type_id'; $retval['columns'][] = 'exception_policy_type'; $retval['columns'][] = 'date_dow'; $retval['columns'][] = 'total_exception'; $retval['group'][] = 'severity'; $retval['group'][] = 'exception_policy_type_id'; $retval['group'][] = 'exception_policy_type'; $retval['group'][] = 'date_dow'; $retval['sub_total'][] = 'severity'; $retval['sub_total'][] = 'exception_policy_type'; $retval['sort'][] = array('severity' => 'asc', 'exception_policy_type_id' => 'asc', 'exception_policy_type' => 'asc', 'total_exception' => 'desc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
function getDeductionAmount($user_id, $pay_stub_obj, $pay_period_obj) { if ($user_id == '') { Debug::Text('Missing User ID: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_stub_obj)) { Debug::Text('Missing Pay Stub Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } if (!is_object($pay_period_obj)) { Debug::Text('Missing Pay Period Object: ', __FILE__, __LINE__, __METHOD__, 10); return FALSE; } //Calculates the deduction. $cd_obj = $this->getCompanyDeductionObject(); $annual_pay_periods = $pay_period_obj->getPayPeriodScheduleObject()->getAnnualPayPeriods(); if (!is_object($cd_obj)) { return FALSE; } require_once Environment::getBasePath() . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'payroll_deduction' . DIRECTORY_SEPARATOR . 'PayrollDeduction.class.php'; $retval = 0; Debug::Text('Company Deduction: ID: ' . $cd_obj->getID() . ' Name: ' . $cd_obj->getName() . ' Calculation ID: ' . $cd_obj->getCalculation(), __FILE__, __LINE__, __METHOD__, 10); switch ($cd_obj->getCalculation()) { case 10: //Basic Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); $retval = bcmul($amount, bcdiv($percent, 100)); break; case 15: //Advanced Percent if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } //Annual Wage Base is the maximum earnings that an employee can earn before they are no longer eligible for this deduction //Annual Deduction Amount Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), bcdiv($exempt_amount, $annual_pay_periods)); Debug::Text('Amount After Exemption: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } else { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); } if ($wage_base > 0) { //*NOTE: If the first pay stub in TimeTrex is near the end of the year, and the employee has already exceeded the wage base amount //the payroll admin needs to make sure they add a YTD Adjustment for each Include PS Accounts that this calculation is based on, //NOT the total amount they have paid for the resulting calculation, as that has no effect whatsoever. //getCalculationYTDAmount is the previous pay stub YTD amount, but it includes any YTD Adjustments in the current pay stub too. $ytd_amount = $cd_obj->getCalculationYTDAmount($pay_stub_obj); Debug::Text('Wage Base is set: ' . $wage_base . ' Amount: ' . $amount . ' Current YTD: ' . $ytd_amount, __FILE__, __LINE__, __METHOD__, 10); //Possible calcations: // //Wage Base: 3000 //Amount: 500 YTD: 0 = 500 //Amount: 500 YTD: 2900 = 100 //Amount: 500 YTD: 3100 = 0 //Amount: 3500 YTD: 0 = 3000 //AMount: 3500 YTD: 2900 = 100 //Amount: 3500 YTD: 3100 = 0 //Check to see if YTD is less than wage base. $remaining_wage_base = bcsub($wage_base, $ytd_amount); Debug::Text('Remaining Wage Base to be calculated: ' . $remaining_wage_base, __FILE__, __LINE__, __METHOD__, 10); if ($remaining_wage_base > 0) { if ($amount > $remaining_wage_base) { $amount = $remaining_wage_base; } } else { $amount = 0; //Exceeded wage base, nothing to calculate. } unset($remaining_wage_base); } else { Debug::Text('Wage Base is NOT set: ' . $wage_base, __FILE__, __LINE__, __METHOD__, 10); } $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $ytd_amount, $percent, $wage_base); break; case 17: //Advanced Percent (Range Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul($amount, bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 18: //Advanced Percent (Tax Bracket) if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $wage_base = $cd_obj->getUserValue2(); } else { $wage_base = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $exempt_amount = $cd_obj->getUserValue3(); } else { $exempt_amount = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } Debug::Text('Percent: ' . $percent . ' Wage Base: ' . $wage_base . ' Exempt Amount: ' . $exempt_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { if ($exempt_amount > 0) { $pp_exempt_amount = bcdiv($exempt_amount, $annual_pay_periods); } else { $pp_exempt_amount = 0; } //Debug::Text('PP Exempt Amount: '. $pp_exempt_amount, __FILE__, __LINE__, __METHOD__,10); if ($wage_base > 0) { $pp_wage_base_amount = bcdiv($wage_base, $annual_pay_periods); } else { $pp_wage_base_amount = 0; } if ($annual_deduction_amount > 0) { $pp_annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); } else { $pp_annual_deduction_amount = 0; } //Debug::Text('PP Wage Base Base Amount: '. $pp_wage_base_amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $pp_annual_deduction_amount); //Debug::Text('Calculation Pay Stub Amount: '. $cd_obj->getCalculationPayStubAmount( $pay_stub_obj ), __FILE__, __LINE__, __METHOD__,10); if ($pp_wage_base_amount > 0 and $amount > $pp_wage_base_amount) { //Debug::Text('Exceeds Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($pp_wage_base_amount, $pp_exempt_amount); } else { //Debug::Text('Under Wage Base...'. $amount, __FILE__, __LINE__, __METHOD__,10); $amount = bcsub($amount, $pp_exempt_amount); } Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); $retval = bcmul($amount, bcdiv($percent, 100)); } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $wage_base, $pp_wage_base_amount, $pp_exempt_amount, $annual_deduction_amount, $pp_annual_deduction_amount); break; case 19: //Advanced Percent (Tax Bracket Alternate) /* This is designed to be used for single line item tax calculations, in that the formula looks like this, where only ONE bracket would be applied to the employee, NOT all: Wage between 0 - 10,000 calculate 10% Wage between 10,001 - 20,000 calculate 15% + $1000 (10% of 10,000 as per above) Wage between 20,001 - 30,000 calculate 20% + $2500 (10% of 10,000 as first bracket, and 15% of 10,000 as per 2nd bracket) */ if ($this->getUserValue1() == '') { $percent = $cd_obj->getUserValue1(); } else { $percent = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $annual_fixed_amount = $cd_obj->getUserValue5(); } else { $annual_fixed_amount = $this->getUserValue5(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); $annual_fixed_amount = bcdiv($annual_fixed_amount, $annual_pay_periods); Debug::Text('Percent: ' . $percent . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($percent != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = bcadd(bcmul(bcsub($amount, $min_wage), bcdiv($percent, 100)), $annual_fixed_amount); } } else { $retval = 0; } if ($percent >= 0 and $retval < 0) { $retval = 0; } unset($amount, $percent, $min_wage, $max_wage, $annual_deduction_amount, $annual_fixed_amount); break; case 20: //Fixed amount if ($this->getUserValue1() == FALSE) { $amount = $cd_obj->getUserValue1(); } else { $amount = $this->getUserValue1(); } $retval = $amount; unset($amount); break; case 30: //Fixed Amount (Range Bracket) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $min_wage = $cd_obj->getUserValue2(); } else { $min_wage = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $max_wage = $cd_obj->getUserValue3(); } else { $max_wage = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $annual_deduction_amount = $cd_obj->getUserValue4(); } else { $annual_deduction_amount = $this->getUserValue4(); } $min_wage = bcdiv($min_wage, $annual_pay_periods); $max_wage = bcdiv($max_wage, $annual_pay_periods); $annual_deduction_amount = bcdiv($annual_deduction_amount, $annual_pay_periods); Debug::Text('Amount: ' . $fixed_amount . ' Min Wage: ' . $min_wage . ' Max Wage: ' . $max_wage . ' Annual Deduction: ' . $annual_deduction_amount, __FILE__, __LINE__, __METHOD__, 10); if ($fixed_amount != 0) { $amount = bcsub($cd_obj->getCalculationPayStubAmount($pay_stub_obj), $annual_deduction_amount); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount >= $min_wage and $amount <= $max_wage) { $retval = $fixed_amount; } } else { $retval = 0; } unset($fixed_amount, $amount, $percent, $min_wage, $max_wage, $annual_deduction_amount); break; case 52: //Fixed Amount (w/Limit) if ($this->getUserValue1() == '') { $fixed_amount = $cd_obj->getUserValue1(); } else { $fixed_amount = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $target_amount = $cd_obj->getUserValue2(); } else { $target_amount = $this->getUserValue2(); } Debug::Text('Amount: ' . $fixed_amount . ' Target Amount: ' . $target_amount, __FILE__, __LINE__, __METHOD__, 10); $retval = 0; if ($fixed_amount != 0) { $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); if ($amount !== $target_amount) { if (abs($fixed_amount) < abs(bcsub($amount, $target_amount))) { //Use full fixed amount Debug::Text('Not within reach of target, use full fixed amount...', __FILE__, __LINE__, __METHOD__, 10); $retval = $fixed_amount; } else { Debug::Text('Within reach of target, use partial fixed amount...', __FILE__, __LINE__, __METHOD__, 10); //Use partial fixed_amount $retval = bcadd(abs($amount), $target_amount); } } } $retval = abs($retval); unset($fixed_amount, $tmp_amount, $amount, $min_limit, $max_limit); break; case 69: // Custom Formulas if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } if ($this->getUserValue4() == '') { $user_value4 = $cd_obj->getUserValue4(); } else { $user_value4 = $this->getUserValue4(); } if ($this->getUserValue5() == '') { $user_value5 = $cd_obj->getUserValue5(); } else { $user_value5 = $this->getUserValue5(); } if ($this->getUserValue6() == '') { $user_value6 = $cd_obj->getUserValue6(); } else { $user_value6 = $this->getUserValue6(); } if ($this->getUserValue7() == '') { $user_value7 = $cd_obj->getUserValue7(); } else { $user_value7 = $this->getUserValue7(); } if ($this->getUserValue8() == '') { $user_value8 = $cd_obj->getUserValue8(); } else { $user_value8 = $this->getUserValue8(); } if ($this->getUserValue9() == '') { $user_value9 = $cd_obj->getUserValue9(); } else { $user_value9 = $this->getUserValue9(); } if ($this->getUserValue10() == '') { $user_value10 = $cd_obj->getUserValue10(); } else { $user_value10 = $this->getUserValue10(); } // evaluate math expressions as the company_value1 and user_value1-10 defined by user. $company_value1 = $cd_obj->getCompanyValue1(); // Custom Formula $variables = array(); $formula_variables = array_keys((array) TTMath::parseColumnsFromFormula($company_value1)); Debug::Arr($formula_variables, 'Formula Variables: ', __FILE__, __LINE__, __METHOD__, 10); if (is_array($formula_variables)) { if (in_array('currency_conversion_rate', $formula_variables) and is_object($this->getUserObject()) and is_object($this->getUserObject()->getCurrencyObject())) { $currency_iso_code = $this->getUserObject()->getCurrencyObject()->getISOCode(); $currency_conversion_rate = $this->getUserObject()->getCurrencyObject()->getConversionRate(); Debug::Text('Currency Variables: Rate: ' . $currency_conversion_rate . ' ISO: ' . $currency_iso_code, __FILE__, __LINE__, __METHOD__, 10); } //First pass to gather any necessary data based on variables if (in_array('employee_hourly_rate', $formula_variables) or in_array('employee_annual_wage', $formula_variables) or in_array('employee_wage_average_weekly_hours', $formula_variables)) { $uwlf = TTnew('UserWageListFactory'); $uwlf->getWageByUserIdAndPayPeriodEndDate($this->getUser(), $pay_period_obj->getEndDate()); if ($uwlf->getRecordCount() > 0) { $uwf = $uwlf->getCurrent(); $employee_hourly_rate = $uwf->getHourlyRate(); $employee_annual_wage = $uwf->getAnnualWage(); $employee_wage_average_weekly_hours = TTDate::getHours($uwf->getWeeklyTime()); } else { $employee_hourly_rate = 0; $employee_annual_wage = 0; $employee_wage_average_weekly_hours = 0; } Debug::Text('Employee Hourly Rate: ' . $employee_hourly_rate, __FILE__, __LINE__, __METHOD__, 10); } if ($cd_obj->getCompanyValue2() != '' and $cd_obj->getCompanyValue2() > 0 and $cd_obj->getCompanyValue3() != '' and $cd_obj->getCompanyValue3() > 0) { Debug::Text('Formula Lookback enable: ' . $cd_obj->getCompanyValue2(), __FILE__, __LINE__, __METHOD__, 10); foreach ($formula_variables as $formula_variable) { if (strpos($formula_variable, 'lookback_') !== FALSE) { Debug::Text('Lookback variables exist...', __FILE__, __LINE__, __METHOD__, 10); $lookback_dates = $cd_obj->getLookbackStartAndEndDates($pay_period_obj); $lookback_pay_stub_dates = $cd_obj->getLookbackPayStubs($this->getUser(), $pay_period_obj); break; } } } //Second pass to define variables. foreach ($formula_variables as $formula_variable) { if (!isset($variables[$formula_variable])) { switch ($formula_variable) { case 'custom_value1': $variables[$formula_variable] = $user_value1; break; case 'custom_value2': $variables[$formula_variable] = $user_value2; break; case 'custom_value3': $variables[$formula_variable] = $user_value3; break; case 'custom_value4': $variables[$formula_variable] = $user_value4; break; case 'custom_value5': $variables[$formula_variable] = $user_value5; break; case 'custom_value6': $variables[$formula_variable] = $user_value6; break; case 'custom_value7': $variables[$formula_variable] = $user_value7; break; case 'custom_value8': $variables[$formula_variable] = $user_value8; break; case 'custom_value9': $variables[$formula_variable] = $user_value9; break; case 'custom_value10': $variables[$formula_variable] = $user_value10; break; case 'employee_hourly_rate': $variables[$formula_variable] = $employee_hourly_rate; break; case 'employee_annual_wage': $variables[$formula_variable] = $employee_annual_wage; break; case 'employee_wage_average_weekly_hours': $variables[$formula_variable] = $employee_wage_average_weekly_hours; break; case 'annual_pay_periods': $variables[$formula_variable] = $annual_pay_periods; break; case 'pay_period_start_date': $variables[$formula_variable] = $pay_period_obj->getStartDate(); break; case 'pay_period_end_date': $variables[$formula_variable] = $pay_period_obj->getEndDate(); break; case 'pay_period_transaction_date': $variables[$formula_variable] = $pay_period_obj->getTransactionDate(); break; case 'employee_hire_date': $variables[$formula_variable] = $this->getUserObject()->getHireDate(); break; case 'employee_termination_date': $variables[$formula_variable] = $this->getUserObject()->getTerminationDate(); break; case 'employee_birth_date': $variables[$formula_variable] = $this->getUserObject()->getBirthDate(); break; case 'currency_iso_code': $variables[$formula_variable] = $currency_iso_code; break; case 'currency_conversion_rate': $variables[$formula_variable] = $currency_conversion_rate; break; case 'include_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10); break; case 'include_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30); break; case 'include_pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20); break; case 'include_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40); break; case 'exclude_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 10); break; case 'exclude_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 30); break; case 'exclude_pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 20); break; case 'exclude_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, NULL, 40); break; case 'pay_stub_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 10, 10); break; case 'pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 30, 30); break; case 'pay_stub_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 20, 20); break; case 'pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getCalculationPayStubAmount($pay_stub_obj, 40, 40); break; //Lookback variables. //Lookback variables. case 'lookback_total_pay_stubs': $variables[$formula_variable] = isset($lookback_pay_stub_dates['total_pay_stubs']) ? $lookback_pay_stub_dates['total_pay_stubs'] : 0; break; case 'lookback_start_date': $variables[$formula_variable] = isset($lookback_dates['start_date']) ? $lookback_dates['start_date'] : 0; break; case 'lookback_end_date': $variables[$formula_variable] = isset($lookback_dates['end_date']) ? $lookback_dates['end_date'] : 0; break; case 'lookback_first_pay_stub_start_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_start_date']) ? $lookback_pay_stub_dates['first_pay_stub_start_date'] : 0; break; case 'lookback_first_pay_stub_end_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_end_date']) ? $lookback_pay_stub_dates['first_pay_stub_end_date'] : 0; break; case 'lookback_first_pay_stub_transaction_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['first_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['first_pay_stub_transaction_date'] : 0; break; case 'lookback_last_pay_stub_start_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_start_date']) ? $lookback_pay_stub_dates['last_pay_stub_start_date'] : 0; break; case 'lookback_last_pay_stub_end_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_end_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0; break; case 'lookback_last_pay_stub_transaction_date': $variables[$formula_variable] = isset($lookback_pay_stub_dates['last_pay_stub_transaction_date']) ? $lookback_pay_stub_dates['last_pay_stub_end_date'] : 0; break; case 'lookback_include_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10); break; case 'lookback_include_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30); break; case 'lookback_include_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20); break; case 'lookback_include_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40); break; case 'lookback_exclude_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 10); break; case 'lookback_exclude_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 30); break; case 'lookback_exclude_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 20); break; case 'lookback_exclude_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(NULL, 40); break; case 'lookback_pay_stub_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(10, 10); break; case 'lookback_pay_stub_ytd_amount': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(30, 30); break; case 'lookback_pay_stub_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(20, 20); break; case 'lookback_pay_stub_ytd_units': $variables[$formula_variable] = $cd_obj->getLookbackCalculationPayStubAmount(40, 40); break; } } } unset($uwlf, $uwf, $employee_hourly_rate, $employee_annual_wage, $employee_wage_average_weekly_hours, $annual_pay_periods, $lookback_dates, $lookback_pay_stub_dates, $currency_iso_code, $currency_conversion_rate); } //Debug::Arr( $variables, 'Formula Variable values: ', __FILE__, __LINE__, __METHOD__, 10 ); Debug::Arr(array(str_replace("\r", '; ', $company_value1), str_replace("\r", '; ', TTMath::translateVariables($company_value1, $variables))), 'Original/Translated Formula: ', __FILE__, __LINE__, __METHOD__, 10); $retval = TTMath::evaluate(TTMath::translateVariables($company_value1, $variables)); Debug::Text('Formula Retval: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); break; case 80: //US Earning Income Credit (EIC). Repealed as of 31-Dec-2010. if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } $pd_obj->setEICFilingStatus($user_value1); $pd_obj->setGrossPayPeriodIncome($amount); //Allow negative value, infact it always should be. $retval = $pd_obj->getEIC(); break; case 82: //US - Medicare - Employee //US - Medicare - Employee case 83: //US - Medicare - Employer //US - Medicare - Employer case 84: //US - Social Security - Employee //US - Social Security - Employee case 85: //US - Social Security - Employer if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('US', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } $pd_obj->setGrossPayPeriodIncome($amount); switch ($cd_obj->getCalculation()) { case 82: //US - Medicare - Employee $pd_obj->setMedicareFilingStatus($user_value1); $pd_obj->setYearToDateGrossIncome($cd_obj->getCalculationYTDAmount($pay_stub_obj)); $retval = $pd_obj->getEmployeeMedicare(); break; case 83: //US - Medicare - Employer $retval = $pd_obj->getEmployerMedicare(); break; case 84: //US - Social Security - Employee $retval = $pd_obj->getEmployeeSocialSecurity(); break; case 85: //US - Social Security - Employer $retval = $pd_obj->getEmployerSocialSecurity(); break; } break; case 90: //Canada - CPP $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); $current_ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: Previous Amount: ' . $previous_ytd_cpp_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_cpp_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution(bcadd($previous_ytd_cpp_arr['ytd_amount'], $current_ytd_cpp_arr['ytd_amount'])); unset($previous_ytd_cpp_arr, $current_ytd_cpp_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeCPP(); if ($retval < 0) { $retval = 0; } break; case 91: //Canada - EI $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction('CA', NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setEnableCPPAndEIDeduction(TRUE); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); $previous_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); $current_ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: Previous Amount: ' . $previous_ytd_ei_arr['ytd_amount'] . ' Current Amount: ' . $current_ytd_ei_arr['amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution(bcadd($previous_ytd_ei_arr['ytd_amount'], $current_ytd_ei_arr['ytd_amount'])); unset($previous_ytd_ei_arr, $current_ytd_ei_arr); } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getEmployeeEI(); if ($retval < 0) { $retval = 0; } break; case 100: //Federal Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), NULL); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); if (is_object($this->getUserObject())) { $currency_id = $this->getUserObject()->getCurrency(); $pd_obj->setUserCurrency($currency_id); Debug::Text('User Currency ID: ' . $currency_id, __FILE__, __LINE__, __METHOD__, 10); } if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { //CA $pd_obj->setFederalTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = TTnew( 'PayStubEntryListFactory' ); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt. //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt. //Make sure we handle the maximum CPP contribution cases properly as well. $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) { Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setCPPExempt(TRUE); } $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr, $current_cpp); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //See comment above regarding CPP exempt. $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); if (isset($current_ei['amount']) and $current_ei['amount'] == 0) { Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Federal Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setEIExempt(TRUE); } $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr, $current_ei); } } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { //US $pd_obj->setFederalFilingStatus($user_value1); $pd_obj->setFederalAllowance($user_value2); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'CR') { //CR $pd_obj->setFederalFilingStatus($user_value1); //Single/Married $pd_obj->setFederalAllowance($user_value2); //Allownces/Children } $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getFederalPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; case 200: //Province Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setGrossPayPeriodIncome($amount); if ($this->getCompanyDeductionObject()->getCountry() == 'CA') { Debug::Text('Canada Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setProvincialTotalClaimAmount($user_value1); $pd_obj->setEnableCPPAndEIDeduction(TRUE); //$pself = TTnew( 'PayStubEntryListFactory' ); if ($this->getPayStubEntryAccountLinkObject()->getEmployeeCPP() != '') { Debug::Text('Found Employee CPP account link!: ', __FILE__, __LINE__, __METHOD__, 10); //Check to see if CPP was calculated on the CURRENT pay stub, if not assume they are CPP exempt. //Single this calculation formula doesn't know directly if the user was CPP exempt or not, we have to assume it by //the calculate CPP on the current pay stub. However if the CPP calculation is done AFTER this, it may mistakenly assume they are exempt. //Make sure we handle the maximum CPP contribution cases properly as well. $current_cpp = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); if (isset($current_cpp['amount']) and $current_cpp['amount'] == 0) { Debug::Text('Current CPP: ' . $current_cpp['amount'] . ' Setting CPP exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setCPPExempt(TRUE); } $ytd_cpp_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeCPP()); Debug::text('YTD CPP Contribution: ' . $ytd_cpp_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateCPPContribution($ytd_cpp_arr['ytd_amount']); unset($ytd_cpp_arr, $current_cpp); } if ($this->getPayStubEntryAccountLinkObject()->getEmployeeEI() != '') { Debug::Text('Found Employee EI account link!: ', __FILE__, __LINE__, __METHOD__, 10); //See comment above regarding CPP exempt. $current_ei = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('current', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); if (isset($current_ei['amount']) and $current_ei['amount'] == 0) { Debug::Text('Current EI: ' . $current_ei['amount'] . ' Setting EI exempt in Provincial Income Tax calculation...', __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setEIExempt(TRUE); } $ytd_ei_arr = $pay_stub_obj->getSumByEntriesArrayAndTypeIDAndPayStubAccountID('previous', NULL, $this->getPayStubEntryAccountLinkObject()->getEmployeeEI()); Debug::text('YTD EI Contribution: ' . $ytd_ei_arr['ytd_amount'], __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setYearToDateEIContribution($ytd_ei_arr['ytd_amount']); unset($ytd_ei_arr, $current_ei); } $retval = $pd_obj->getProvincialPayPeriodDeductions(); } elseif ($this->getCompanyDeductionObject()->getCountry() == 'US') { Debug::Text('US Pay Period Deductions...', __FILE__, __LINE__, __METHOD__, 10); //Need to set Federal settings here. $udlf = TTnew('UserDeductionListFactory'); $udlf->getByUserIdAndCountryID($user_id, $this->getCompanyDeductionObject()->getCountry()); if ($udlf->getRecordCount() > 0) { Debug::Text('Found Federal User Deduction...', __FILE__, __LINE__, __METHOD__, 10); $tmp_ud_obj = $udlf->getCurrent(); if ($tmp_ud_obj->getUserValue1() == '') { $tmp_user_value1 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue1(); } else { $tmp_user_value1 = $tmp_ud_obj->getUserValue1(); } if ($tmp_ud_obj->getUserValue2() == '') { $tmp_user_value2 = $tmp_ud_obj->getCompanyDeductionObject()->getUserValue2(); } else { $tmp_user_value2 = $tmp_ud_obj->getUserValue2(); } Debug::Text('TmpUserValue1: ' . $tmp_user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('TmpUserValue2: ' . $tmp_user_value2, __FILE__, __LINE__, __METHOD__, 10); $pd_obj->setFederalFilingStatus($tmp_user_value1); $pd_obj->setFederalAllowance($tmp_user_value2); unset($tmp_ud_obj, $tmp_user_value1, $tmp_user_value1); } unset($udlf); $pd_obj->setStateFilingStatus($user_value1); $pd_obj->setStateAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $retval = $pd_obj->getStatePayPeriodDeductions(); } if ($retval < 0) { $retval = 0; } break; case 300: //District Income Tax if ($this->getUserValue1() == '') { $user_value1 = $cd_obj->getUserValue1(); } else { $user_value1 = $this->getUserValue1(); } if ($this->getUserValue2() == '') { $user_value2 = $cd_obj->getUserValue2(); } else { $user_value2 = $this->getUserValue2(); } if ($this->getUserValue3() == '') { $user_value3 = $cd_obj->getUserValue3(); } else { $user_value3 = $this->getUserValue3(); } Debug::Text('UserValue1: ' . $user_value1, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue2: ' . $user_value2, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('UserValue3: ' . $user_value3, __FILE__, __LINE__, __METHOD__, 10); $amount = $cd_obj->getCalculationPayStubAmount($pay_stub_obj); Debug::Text('Amount: ' . $amount, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('Annual Pay Periods: ' . $annual_pay_periods, __FILE__, __LINE__, __METHOD__, 10); Debug::Text('District: ' . $this->getCompanyDeductionObject()->getDistrict(), __FILE__, __LINE__, __METHOD__, 10); $pd_obj = new PayrollDeduction($this->getCompanyDeductionObject()->getCountry(), $this->getCompanyDeductionObject()->getProvince(), $this->getCompanyDeductionObject()->getDistrict()); $pd_obj->setCompany($this->getUserObject()->getCompany()); $pd_obj->setUser($this->getUser()); $pd_obj->setDate($pay_period_obj->getTransactionDate()); $pd_obj->setAnnualPayPeriods($annual_pay_periods); $pd_obj->setDistrictFilingStatus($user_value1); $pd_obj->setDistrictAllowance($user_value2); $pd_obj->setUserValue1($user_value1); $pd_obj->setUserValue2($user_value2); $pd_obj->setUserValue3($user_value3); $pd_obj->setGrossPayPeriodIncome($amount); $retval = $pd_obj->getDistrictPayPeriodDeductions(); if ($retval < 0) { $retval = 0; } break; } Debug::Text('Deduction Amount: ' . $retval, __FILE__, __LINE__, __METHOD__, 10); //Allow negative values, as some advanced tax bracket setups require this. if ($retval < 0) { //Debug::Text('Deduction was negative, setting to 0...', __FILE__, __LINE__, __METHOD__,10); Debug::Text('Deduction was negative...', __FILE__, __LINE__, __METHOD__, 10); //$retval = 0; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-default_branch_id' => TTi18n::gettext('Default Branch'), '-2070-default_department_id' => TTi18n::gettext('Default Department'), '-2000-currency_id' => TTi18n::gettext('Currency'), '-2100-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'date_columns': $retval = array_merge(TTDate::getReportDateOptions('hire', TTi18n::getText('Hire Date'), 17, FALSE), TTDate::getReportDateOptions('termination', TTi18n::getText('Termination Date'), 18, FALSE), TTDate::getReportDateOptions('birth', TTi18n::getText('Birth Date'), 19, FALSE), TTDate::getReportDateOptions('created', TTi18n::getText('Created Date'), 20, FALSE), TTDate::getReportDateOptions('updated', TTi18n::getText('Updated Date'), 21, FALSE)); break; case 'custom_columns': //Get custom fields for report data. $oflf = TTnew('OtherFieldListFactory'); //User and Punch fields conflict as they are merged together in a secondary process. $other_field_names = $oflf->getByCompanyIdAndTypeIdArray($this->getUserObject()->getCompany(), array(10), array(10 => '')); if (is_array($other_field_names)) { $retval = Misc::addSortPrefix($other_field_names, 9000); } break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'UserSummaryReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'UserSummaryReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'UserSummaryReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'UserSummaryReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-first_name' => TTi18n::gettext('First Name'), '-1001-middle_name' => TTi18n::gettext('Middle Name'), '-1002-last_name' => TTi18n::gettext('Last Name'), '-1005-full_name' => TTi18n::gettext('Full Name'), '-1010-user_name' => TTi18n::gettext('User Name'), '-1020-phone_id' => TTi18n::gettext('Quick Punch ID'), '-1030-employee_number' => TTi18n::gettext('Employee #'), '-1032-employee_number_barcode' => TTi18n::gettext('Barcode'), '-1034-employee_number_qrcode' => TTi18n::gettext('QRcode'), '-1040-status' => TTi18n::gettext('Status'), '-1050-title' => TTi18n::gettext('Title'), '-1080-user_group' => TTi18n::gettext('Group'), '-1090-default_branch' => TTi18n::gettext('Branch'), '-1100-default_department' => TTi18n::gettext('Department'), '-1120-default_job' => TTi18n::gettext('Job'), '-1150-default_job_item' => TTi18n::gettext('Task'), '-1190-ethnic_group' => TTi18n::gettext('Ethnicity'), '-1200-permission_control' => TTi18n::gettext('Permission Group'), '-1210-pay_period_schedule' => TTi18n::gettext('Pay Period Schedule'), '-1220-policy_group' => TTi18n::gettext('Policy Group'), '-1310-sex' => TTi18n::gettext('Gender'), '-1320-address1' => TTi18n::gettext('Address 1'), '-1330-address2' => TTi18n::gettext('Address 2'), '-1340-city' => TTi18n::gettext('City'), '-1350-province' => TTi18n::gettext('Province/State'), '-1360-country' => TTi18n::gettext('Country'), '-1370-postal_code' => TTi18n::gettext('Postal Code'), '-1380-work_phone' => TTi18n::gettext('Work Phone'), '-1391-work_phone_ext' => TTi18n::gettext('Work Phone Ext'), '-1400-home_phone' => TTi18n::gettext('Home Phone'), '-1410-mobile_phone' => TTi18n::gettext('Mobile Phone'), '-1420-fax_phone' => TTi18n::gettext('Fax Phone'), '-1430-home_email' => TTi18n::gettext('Home Email'), '-1440-work_email' => TTi18n::gettext('Work Email'), '-1480-sin' => TTi18n::gettext('SIN/SSN'), '-1490-note' => TTi18n::gettext('Note'), '-1495-tag' => TTi18n::gettext('Tags'), '-1499-hierarchy_control_display' => TTi18n::gettext('Hierarchy'), '-1499-hierarchy_level_display' => TTi18n::gettext('Hierarchy Superiors'), '-1500-institution' => TTi18n::gettext('Bank Institution'), '-1510-transit' => TTi18n::gettext('Bank Transit/Routing'), '-1520-account' => TTi18n::gettext('Bank Account'), '-1619-currency' => TTi18n::gettext('Currency'), '-1620-current_currency' => TTi18n::gettext('Current Currency'), '-1625-type' => TTi18n::gettext('Wage Type'), '-1640-effective_date' => TTi18n::gettext('Wage Effective Date'), '-1650-language_display' => TTi18n::gettext('Language'), '-1660-date_format_display' => TTi18n::gettext('Date Format'), '-1665-time_format_display' => TTi18n::gettext('Time Format'), '-1670-time_unit_format_display' => TTi18n::gettext('Time Units'), '-1680-time_zone_display' => TTi18n::gettext('Time Zone'), '-1690-items_per_page' => TTi18n::gettext('Rows Per page'), '-1695-password_updated_date' => TTi18n::gettext('Password Updated Date'), '-1699-hire_date_age' => TTi18n::gettext('Length of Service'), '-1899-birth_date_age' => TTi18n::gettext('Age'), '-2205-created_by' => TTi18n::gettext('Created By'), '-2215-updated_by' => TTi18n::gettext('Updated By')); $retval = array_merge($retval, (array) $this->getOptions('date_columns'), (array) $this->getOptions('custom_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-1630-wage' => TTi18n::gettext('Wage'), '-1635-hourly_rate' => TTi18n::gettext('Hourly Rate'), '-1636-labor_burden_hourly_rate' => TTi18n::gettext('Hourly Rate w/Burden'), '-1637-labor_burden_percent' => TTi18n::gettext('Labor Burden Percent'), '-2000-total_user' => TTi18n::gettext('Total Employees')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'wage') !== FALSE or strpos($column, 'hourly_rate') !== FALSE) { $retval[$column] = 'currency'; } elseif (strpos($column, 'labor_burden_percent') !== FALSE) { $retval[$column] = 'percent'; } } } $retval['password_updated_date'] = 'time_stamp'; $retval['effective_date'] = 'date_stamp'; break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { default: if (strpos($column, 'hourly_rate') !== FALSE or strpos($column, 'wage') !== FALSE or strpos($column, 'labor_burden_percent') !== FALSE) { $retval[$column] = 'avg'; } else { $retval[$column] = 'sum'; } } } } break; case 'templates': $retval = array('-1010-by_employee+contact' => TTi18n::gettext('Contact Information By Employee'), '-1020-by_employee+employment' => TTi18n::gettext('Employment Information By Employee'), '-1030-by_employee+address' => TTi18n::gettext('Addresses By Employee'), '-1040-by_employee+wage' => TTi18n::gettext('Wages By Employee'), '-1050-by_employee+bank' => TTi18n::gettext('Bank Information By Employee'), '-1060-by_employee+preference' => TTi18n::gettext('Preferences By Employee'), '-1070-by_employee+birth_date' => TTi18n::gettext('Birthdays By Employee'), '-1080-by_branch_by_employee+contact' => TTi18n::gettext('Contact Information By Branch/Employee'), '-1090-by_branch_by_employee+address' => TTi18n::gettext('Addresses By Branch/Employee'), '-1110-by_branch_by_employee+wage' => TTi18n::gettext('Wages by Branch/Employee'), '-1120-by_branch+total_user' => TTi18n::gettext('Total Employees by Branch'), '-1130-by_department_by_employee+contact' => TTi18n::gettext('Contact Information By Department/Employee'), '-1140-by_department_by_employee+address' => TTi18n::gettext('Addresses By Department/Employee'), '-1150-by_department_by_employee+wage' => TTi18n::gettext('Wages by Department/Employee'), '-1160-by_department+total_user' => TTi18n::gettext('Total Employees by Department'), '-1170-by_branch_by_department_by_employee+contact' => TTi18n::gettext('Contact Information By Branch/Department/Employee'), '-1180-by_branch_by_department_by_employee+address' => TTi18n::gettext('Addresses By Branch/Department/Employee'), '-1190-by_branch_by_department+wage' => TTi18n::gettext('Wages by Branch/Department/Employee'), '-1200-by_branch_by_department+total_user' => TTi18n::gettext('Total Employees by Branch/Department'), '-1205-by_hierarchy_by_branch_by_department_by_employee+contact' => TTi18n::gettext('Contact Information By Hierarchy/Branch/Department/Employee'), '-1210-by_type_by_employee+wage' => TTi18n::gettext('Wages By Type/Employee'), '-1220-by_type+total_user' => TTi18n::gettext('Total Employees by Wage Type'), '-1230-by_hired_month+total_user' => TTi18n::gettext('Total Employees Hired By Month'), '-1240-by_termination_month+total_user' => TTi18n::gettext('Total Employees Terminated By Month')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { //Contact case 'by_employee+contact': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'work_phone'; $retval['columns'][] = 'work_phone_ext'; $retval['columns'][] = 'work_email'; $retval['columns'][] = 'mobile_phone'; $retval['columns'][] = 'home_phone'; $retval['columns'][] = 'home_email'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_employee+contact': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'work_phone'; $retval['columns'][] = 'work_phone_ext'; $retval['columns'][] = 'work_email'; $retval['columns'][] = 'mobile_phone'; $retval['columns'][] = 'home_phone'; $retval['columns'][] = 'home_email'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_department_by_employee+contact': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'work_phone'; $retval['columns'][] = 'work_phone_ext'; $retval['columns'][] = 'work_email'; $retval['columns'][] = 'mobile_phone'; $retval['columns'][] = 'home_phone'; $retval['columns'][] = 'home_email'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_department_by_employee+contact': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'work_phone'; $retval['columns'][] = 'work_phone_ext'; $retval['columns'][] = 'work_email'; $retval['columns'][] = 'mobile_phone'; $retval['columns'][] = 'home_phone'; $retval['columns'][] = 'home_email'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_hierarchy_by_branch_by_department_by_employee+contact': $retval['columns'][] = 'hierarchy_control_display'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'work_phone'; $retval['columns'][] = 'work_phone_ext'; $retval['columns'][] = 'work_email'; $retval['columns'][] = 'mobile_phone'; $retval['columns'][] = 'home_phone'; $retval['columns'][] = 'home_email'; $retval['sort'][] = array('hierarchy_control_display' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Birth Dates //Birth Dates case 'by_employee+birth_date': $retval['columns'][] = 'birth-date_month'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'birth-date_stamp'; $retval['columns'][] = 'birth_date_age'; $retval['sub_total'][] = 'birth-date_month'; $retval['sort'][] = array('birth-date_month' => 'asc'); $retval['sort'][] = array('birth-date_dom' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Employment //Employment case 'by_employee+employment': $retval['columns'][] = 'status'; $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'title'; $retval['columns'][] = 'user_group'; $retval['columns'][] = 'ethnic_group'; $retval['columns'][] = 'sex'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'birth_date_age'; $retval['columns'][] = 'hire-date_stamp'; $retval['columns'][] = 'termination-date_stamp'; $retval['columns'][] = 'hire_date_age'; $retval['sort'][] = array('status' => 'asc'); $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('title' => 'asc'); $retval['sort'][] = array('user_group' => 'asc'); $retval['sort'][] = array('ethnic_group' => 'asc'); $retval['sort'][] = array('sex' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); //$retval['sort'][] = array('hire-date_month' => 'asc'); break; case 'by_hired_month+total_user': $retval['columns'][] = 'hire-date_year'; $retval['columns'][] = 'hire-date_month_year'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'hire-date_year'; $retval['group'][] = 'hire-date_month_year'; $retval['sub_total'][] = 'hire-date_year'; $retval['sort'][] = array('hire-date_year' => 'desc'); $retval['sort'][] = array('hire-date_month_year' => 'desc'); $retval['sort'][] = array('total_user' => 'desc'); break; case 'by_termination_month+total_user': $retval['columns'][] = 'termination-date_year'; $retval['columns'][] = 'termination-date_month_year'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'termination-date_year'; $retval['group'][] = 'termination-date_month_year'; $retval['sub_total'][] = 'termination-date_year'; $retval['sort'][] = array('termination-date_year' => 'desc'); $retval['sort'][] = array('termination-date_month_year' => 'desc'); $retval['sort'][] = array('total_user' => 'desc'); break; //Address //Address case 'by_employee+address': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'address1'; $retval['columns'][] = 'address2'; $retval['columns'][] = 'city'; $retval['columns'][] = 'country'; $retval['columns'][] = 'province'; $retval['columns'][] = 'postal_code'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_employee+address': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'address1'; $retval['columns'][] = 'address2'; $retval['columns'][] = 'city'; $retval['columns'][] = 'country'; $retval['columns'][] = 'province'; $retval['columns'][] = 'postal_code'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_department_by_employee+address': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'address1'; $retval['columns'][] = 'address2'; $retval['columns'][] = 'city'; $retval['columns'][] = 'country'; $retval['columns'][] = 'province'; $retval['columns'][] = 'postal_code'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_department_by_employee+address': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'address1'; $retval['columns'][] = 'address2'; $retval['columns'][] = 'city'; $retval['columns'][] = 'country'; $retval['columns'][] = 'province'; $retval['columns'][] = 'postal_code'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Wage //Wage case 'by_employee+wage': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'wage'; $retval['columns'][] = 'hourly_rate'; $retval['columns'][] = 'effective_date'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('wage' => 'desc'); break; case 'by_branch_by_employee+wage': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'wage'; $retval['columns'][] = 'hourly_rate'; $retval['columns'][] = 'effective_date'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('wage' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_department_by_employee+wage': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'wage'; $retval['columns'][] = 'hourly_rate'; $retval['columns'][] = 'effective_date'; $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('wage' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_branch_by_department_by_employee+wage': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'type'; $retval['columns'][] = 'wage'; $retval['columns'][] = 'hourly_rate'; $retval['columns'][] = 'effective_date'; $retval['sort'][] = array('default_branch' => 'asc'); $retval['sort'][] = array('default_department' => 'asc'); $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('wage' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; case 'by_type_by_employee+wage': $retval['columns'][] = 'type'; $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'wage'; $retval['columns'][] = 'hourly_rate'; $retval['columns'][] = 'effective_date'; $retval['sub_total'][] = 'type'; $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('wage' => 'desc'); $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Bank Account //Bank Account case 'by_employee+bank': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'transit'; $retval['columns'][] = 'account'; $retval['columns'][] = 'institution'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Preferences //Preferences case 'by_employee+preference': $retval['columns'][] = 'first_name'; $retval['columns'][] = 'last_name'; $retval['columns'][] = 'date_format_display'; $retval['columns'][] = 'time_format_display'; $retval['columns'][] = 'time_unit_format_display'; $retval['columns'][] = 'time_zone_display'; $retval['columns'][] = 'language_display'; $retval['columns'][] = 'items_per_page'; $retval['sort'][] = array('last_name' => 'asc'); $retval['sort'][] = array('first_name' => 'asc'); break; //Other //Other case 'by_branch+total_user': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'default_branch'; $retval['sort'][] = array('total_user' => 'desc'); break; case 'by_department+total_user': $retval['columns'][] = 'default_department'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'default_department'; $retval['sort'][] = array('total_user' => 'desc'); break; case 'by_branch_by_department+total_user': $retval['columns'][] = 'default_branch'; $retval['columns'][] = 'default_department'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'default_branch'; $retval['group'][] = 'default_department'; $retval['sub_total'][] = 'default_branch'; $retval['sort'][] = array('default_branch' => 'asc'); //$retval['sort'][] = array('' => 'asc'); $retval['sort'][] = array('total_user' => 'desc'); break; case 'by_type+total_user': $retval['columns'][] = 'type'; $retval['columns'][] = 'total_user'; $retval['group'][] = 'type'; $retval['sub_total'][] = 'type'; $retval['sort'][] = array('type' => 'asc'); $retval['sort'][] = array('total_user' => 'desc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }
protected function _getOptions($name, $params = NULL) { $retval = NULL; switch ($name) { case 'output_format': $retval = parent::getOptions('default_output_format'); break; case 'default_setup_fields': $retval = array('template', 'time_period', 'columns'); break; case 'setup_fields': $retval = array('-1000-template' => TTi18n::gettext('Template'), '-1010-time_period' => TTi18n::gettext('Time Period'), '-2010-user_status_id' => TTi18n::gettext('Employee Status'), '-2020-user_group_id' => TTi18n::gettext('Employee Group'), '-2030-user_title_id' => TTi18n::gettext('Employee Title'), '-2035-user_tag' => TTi18n::gettext('Employee Tags'), '-2040-include_user_id' => TTi18n::gettext('Employee Include'), '-2050-exclude_user_id' => TTi18n::gettext('Employee Exclude'), '-2060-include_reviewer_user_id' => TTi18n::gettext('Reviewer Include'), '-2070-exclude_reviewer_user_id' => TTi18n::gettext('Reviewer Exclude'), '-2080-default_branch_id' => TTi18n::gettext('Default Branch'), '-2090-default_department_id' => TTi18n::gettext('Default Department'), '-2100-kpi_id' => TTi18n::gettext('Key Performance Indicators'), '-2120-kpi_group_id' => TTi18n::gettext('KPI Group'), '-2130-kpi_status_id' => TTi18n::gettext('KPI Status'), '-2140-kpi_type_id' => TTi18n::gettext('KPI Type'), '-2150-user_review_control_status_id' => TTi18n::gettext('Review Status'), '-2160-user_review_control_type_id' => TTi18n::gettext('Review Type'), '-2170-term_id' => TTi18n::gettext('Review Terms'), '-2180-severity_id' => TTi18n::gettext('Review Severity/Importance'), '-2188-review_tag' => TTi18n::gettext('Review Tags'), '-3000-custom_filter' => TTi18n::gettext('Custom Filter'), '-5000-columns' => TTi18n::gettext('Display Columns'), '-5010-group' => TTi18n::gettext('Group By'), '-5020-sub_total' => TTi18n::gettext('SubTotal By'), '-5030-sort' => TTi18n::gettext('Sort By')); break; case 'time_period': $retval = TTDate::getTimePeriodOptions(); break; case 'date_columns': $retval = array_merge(TTDate::getReportDateOptions('user_review_control.start', TTi18n::getText('Start Date'), 16, FALSE), TTDate::getReportDateOptions('user_review_control.end', TTi18n::getText('End Date'), 17, FALSE), TTDate::getReportDateOptions('user_review_control.due', TTi18n::getText('Due Date'), 18, FALSE)); break; case 'report_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); // Because the Filter type is just only a filter criteria and not need to be as an option of Display Columns, Group By, Sub Total, Sort By dropdowns. // So just get custom columns with Selection and Formula. $custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), NULL, 'KPIReport', 'custom_column'); if (is_array($custom_column_labels)) { $retval = Misc::addSortPrefix($custom_column_labels, 9500); } } break; case 'report_custom_filters': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $retval = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('filter_column_type_ids'), NULL, 'KPIReport', 'custom_column'); } break; case 'report_dynamic_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_dynamic_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('dynamic_format_ids'), 'KPIReport', 'custom_column'); if (is_array($report_dynamic_custom_column_labels)) { $retval = Misc::addSortPrefix($report_dynamic_custom_column_labels, 9700); } } break; case 'report_static_custom_column': if (getTTProductEdition() >= TT_PRODUCT_PROFESSIONAL) { $rcclf = TTnew('ReportCustomColumnListFactory'); $report_static_custom_column_labels = $rcclf->getByCompanyIdAndTypeIdAndFormatIdAndScriptArray($this->getUserObject()->getCompany(), $rcclf->getOptions('display_column_type_ids'), $rcclf->getOptions('static_format_ids'), 'KPIReport', 'custom_column'); if (is_array($report_static_custom_column_labels)) { $retval = Misc::addSortPrefix($report_static_custom_column_labels, 9700); } } break; case 'formula_columns': $retval = TTMath::formatFormulaColumns(array_merge(array_diff($this->getOptions('static_columns'), (array) $this->getOptions('report_static_custom_column')), $this->getOptions('dynamic_columns'))); break; case 'filter_columns': $retval = TTMath::formatFormulaColumns(array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column'))); break; case 'static_columns': $retval = array('-1000-kpi.name' => TTi18n::gettext('Key Performance Indicators'), '-1005-kpi.type' => TTi18n::getText('KPI Type'), '-1000-kpi.status' => TTi18n::gettext('KPI Status'), '-1010-kpi.description' => TTi18n::gettext('Description'), '-1020-user.first_name' => TTi18n::gettext('First Name'), '-1030-user.middle_name' => TTi18n::gettext('Middle Name'), '-1040-user.last_name' => TTi18n::gettext('Last Name'), '-1050-user.full_name' => TTi18n::gettext('Full Name'), '-1060-user.status' => TTi18n::gettext('Employee Status'), '-1070-user.sex' => TTi18n::gettext('Gender'), '-1080-user.user_group' => TTi18n::gettext('Employee Group'), '-1090-user.title' => TTi18n::gettext('Employee Title'), '-1100-user.default_branch' => TTi18n::gettext('Branch'), '-1110-user.default_department' => TTi18n::gettext('Department'), '-1120-user.city' => TTi18n::gettext('City'), '-1130-user.province' => TTi18n::gettext('Province/State'), '-1140-user.country' => TTi18n::gettext('Country'), '-1150-user.postal_code' => TTi18n::gettext('Postal Code'), '-1160-user.work_phone' => TTi18n::gettext('Work Phone'), '-1170-user.work_phone_ext' => TTi18n::gettext('Work Phone Ext'), '-1180-user.home_phone' => TTi18n::gettext('Home Phone'), '-1190-user.mobile_phone' => TTi18n::gettext('Mobile Phone'), '-1200-user.fax_phone' => TTi18n::gettext('Fax Phone'), '-1210-user.home_email' => TTi18n::gettext('Home Email'), '-1220-user.work_email' => TTi18n::gettext('Work Email'), '-1230-user.address1' => TTi18n::gettext('Address 1'), '-1240-user.address2' => TTi18n::gettext('Address 2'), '-1244-user.tag' => TTi18n::getText('Employee Tags'), '-1250-user_review_control.reviewer_user' => TTi18n::gettext('Reviewer Name'), '-1260-user_review_control.status' => TTi18n::gettext('Review Status'), '-1270-user_review_control.type' => TTi18n::gettext('Review Type'), '-1280-user_review_control.term' => TTi18n::gettext('Review Terms'), '-1290-user_review_control.severity' => TTi18n::gettext('Review Severity/Importance'), '-1292-user_review_control.tag' => TTi18n::gettext('Review Tags'), '-1300-user_review.note' => TTi18n::gettext('KPI Notes'), '-1350-user.note' => TTi18n::gettext('Employee Notes'), '-1400-user_review_control.note' => TTi18n::gettext('Review Notes')); $retval = array_merge($retval, $this->getOptions('date_columns'), (array) $this->getOptions('report_static_custom_column')); ksort($retval); break; case 'dynamic_columns': $retval = array('-2000-kpi.minimum_rate' => TTi18n::gettext('Minimum Rating'), '-2010-kpi.maximum_rate' => TTi18n::gettext('Maximum Rating'), '-2020-user_review.rating' => TTi18n::gettext('Rating'), '-2000-total_review' => TTi18n::gettext('Total Reviews')); break; case 'columns': $retval = array_merge($this->getOptions('static_columns'), $this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')); break; case 'column_format': //Define formatting function for each column. $columns = array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_custom_column')); if (is_array($columns)) { foreach ($columns as $column => $name) { if (strpos($column, 'rate') !== FALSE) { $retval[$column] = 'numeric'; } } } break; case 'aggregates': $retval = array(); $dynamic_columns = array_keys(Misc::trimSortPrefix(array_merge($this->getOptions('dynamic_columns'), (array) $this->getOptions('report_dynamic_custom_column')))); if (is_array($dynamic_columns)) { foreach ($dynamic_columns as $column) { switch ($column) { case 'kpi.minimum_rate': $retval[$column] = 'min'; break; case 'kpi.maximum_rate': $retval[$column] = 'max'; break; case 'user_review.rating': case 'total_review': $retval[$column] = 'sum'; break; } } } break; case 'templates': $retval = array('-1010-by_employee_by_kpi+kpi+rating' => TTi18n::gettext('Review Information By Employee/KPI'), '-1020-by_kpi_by_employee+kpi+rating' => TTi18n::gettext('Review Information By KPI/Employee'), '-1040-by_type_by_terms_by_severity+kpi+rating' => TTi18n::gettext('Review Summary By Type/Terms/Severity'), '-1050-by_employee_by_type_by_terms_by_severity+kpi+rating' => TTi18n::gettext('Review Summary By Employee/Type/Terms/Severity'), '-1060-by_type_by_terms_by_severity_by_employee+kpi+rating' => TTi18n::gettext('Review Summary By Type/Terms/Severity/Employee'), '-1070-by_employee+due_date' => TTi18n::gettext('Pending Reviews By Employee')); break; case 'template_config': $template = strtolower(Misc::trimSortPrefix($params['template'])); if (isset($template) and $template != '') { switch ($template) { case 'by_employee_by_kpi+kpi+rating': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'user_review_control.due-date_stamp'; $retval['columns'][] = 'kpi.name'; $retval['columns'][] = 'user_review.rating'; $retval['columns'][] = 'user_review.note'; $retval['-2150-user_review_control_status_id'] = array(30); $retval['-2160-user_review_control_type_id'] = array(); //Allow use to easily filter based on review type $retval['sub_total'][] = 'user.full_name'; $retval['sub_total'][] = 'user_review_control.type'; $retval['sub_total'][] = 'user_review_control.due-date_stamp'; $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('user_review_control.type' => 'asc'); $retval['sort'][] = array('user_review_control.due-date_stamp' => 'desc'); $retval['sort'][] = array('user_review.rating' => 'desc'); $retval['sort'][] = array('kpi.name' => 'asc'); break; case 'by_kpi_by_employee+kpi+rating': $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'kpi.name'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_review.rating'; $retval['columns'][] = 'user_review.note'; $retval['-2150-user_review_control_status_id'] = array(30); $retval['-2160-user_review_control_type_id'] = array(); //Allow use to easily filter based on review type $retval['sub_total'][] = 'user_review_control.type'; $retval['sub_total'][] = 'kpi.name'; $retval['sort'][] = array('user_review_control.type' => 'asc'); $retval['sort'][] = array('kpi.name' => 'asc'); $retval['sort'][] = array('user_review.rating' => 'desc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; case 'by_type_by_terms_by_severity+kpi+rating': $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'user_review_control.term'; $retval['columns'][] = 'user_review_control.severity'; $retval['columns'][] = 'total_review'; $retval['-2150-user_review_control_status_id'] = array(30); $retval['group'][] = 'user_review_control.type'; $retval['group'][] = 'user_review_control.term'; $retval['group'][] = 'user_review_control.severity'; $retval['sub_total'][] = 'user_review_control.type'; $retval['sub_total'][] = 'user_review_control.term'; $retval['sub_total'][] = 'user_review_control.severity'; $retval['sort'][] = array('user_review_control.type' => 'asc'); $retval['sort'][] = array('user_review_control.term' => 'asc'); $retval['sort'][] = array('user_review_control.severity' => 'desc'); break; case 'by_employee_by_type_by_terms_by_severity+kpi+rating': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'user_review_control.term'; $retval['columns'][] = 'user_review_control.severity'; $retval['columns'][] = 'total_review'; $retval['columns'][] = 'user_review.rating'; $retval['-2150-user_review_control_status_id'] = array(30); $retval['group'][] = 'user.full_name'; $retval['group'][] = 'user_review_control.type'; $retval['group'][] = 'user_review_control.term'; $retval['group'][] = 'user_review_control.severity'; $retval['sub_total'][] = 'user.full_name'; $retval['sub_total'][] = 'user_review_control.type'; $retval['sub_total'][] = 'user_review_control.term'; $retval['sub_total'][] = 'user_review_control.severity'; $retval['sort'][] = array('user.full_name' => 'asc'); $retval['sort'][] = array('user_review_control.type' => 'asc'); $retval['sort'][] = array('user_review_control.term' => 'asc'); $retval['sort'][] = array('user_review_control.severity' => 'desc'); break; case 'by_type_by_terms_by_severity_by_employee+kpi+rating': $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'user_review_control.term'; $retval['columns'][] = 'user_review_control.severity'; $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'total_review'; $retval['columns'][] = 'user_review.rating'; $retval['-2150-user_review_control_status_id'] = array(30); $retval['group'][] = 'user_review_control.type'; $retval['group'][] = 'user_review_control.term'; $retval['group'][] = 'user_review_control.severity'; $retval['group'][] = 'user.full_name'; $retval['sub_total'][] = 'user_review_control.type'; $retval['sub_total'][] = 'user_review_control.term'; $retval['sub_total'][] = 'user_review_control.severity'; $retval['sort'][] = array('user_review_control.type' => 'asc'); $retval['sort'][] = array('user_review_control.term' => 'asc'); $retval['sort'][] = array('user_review_control.severity' => 'desc'); $retval['sort'][] = array('total_review' => 'desc'); $retval['sort'][] = array('user_review.rating' => 'desc'); break; case 'by_employee+due_date': $retval['columns'][] = 'user.full_name'; $retval['columns'][] = 'user_review_control.type'; $retval['columns'][] = 'user_review_control.reviewer_user'; $retval['columns'][] = 'user_review_control.due-date_stamp'; $retval['-1010-time_period']['time_period'] = 'this_month'; $retval['-2150-user_review_control_status_id'] = array(10); $retval['-2160-user_review_control_type_id'] = array(); //Allow use to easily filter based on review type $retval['group'][] = 'user.full_name'; $retval['group'][] = 'user_review_control.type'; $retval['group'][] = 'user_review_control.reviewer_user'; $retval['group'][] = 'user_review_control.due-date_stamp'; $retval['sort'][] = array('user_review_control.due-date_stamp' => 'asc'); $retval['sort'][] = array('user_review_control.type_id' => 'asc'); $retval['sort'][] = array('user.full_name' => 'asc'); break; default: Debug::Text(' Parsing template name: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; } } //Set the template dropdown as well. $retval['-1000-template'] = $template; //Add sort prefixes so Flex can maintain order. if (isset($retval['filter'])) { $retval['-5000-filter'] = $retval['filter']; unset($retval['filter']); } if (isset($retval['columns'])) { $retval['-5010-columns'] = $retval['columns']; unset($retval['columns']); } if (isset($retval['group'])) { $retval['-5020-group'] = $retval['group']; unset($retval['group']); } if (isset($retval['sub_total'])) { $retval['-5030-sub_total'] = $retval['sub_total']; unset($retval['sub_total']); } if (isset($retval['sort'])) { $retval['-5040-sort'] = $retval['sort']; unset($retval['sort']); } Debug::Arr($retval, ' Template Config for: ' . $template, __FILE__, __LINE__, __METHOD__, 10); break; default: //Call report parent class options function for options valid for all reports. $retval = $this->__getOptions($name); break; } return $retval; }