function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Loop through all permission control rows and set the levels as best we can. $pclf = TTnew('PermissionControlListFactory'); $pclf->getAll(); if ($pclf->getRecordCount() > 0) { $pf = TTnew('PermissionFactory'); $preset_options = $pf->getOptions('preset'); $preset_level_options = $pf->getOptions('preset_level'); foreach ($pclf as $pc_obj) { $name = $pc_obj->getName(); $closest_preset_id = Misc::findClosestMatch($name, $preset_options, 75); if (isset($preset_level_options[$closest_preset_id])) { $preset_level = $preset_level_options[$closest_preset_id]; } else { $preset_level = 1; //Use the lowest level if we can't find one, so by default they can't add a new administrator/supervisor. //Try to count the number of permissions and match them to the number of permissions in each preset and use the closest level? $permission_user_data = $pc_obj->getPermission(); if (is_array($permission_user_data)) { foreach ($preset_options as $preset => $preset_name) { $tmp_preset_permissions = $pf->getPresetPermissions($preset, array()); $preset_permission_diff_arr = Misc::arrayDiffAssocRecursive($permission_user_data, $tmp_preset_permissions); $preset_permission_diff_count = count($preset_permission_diff_arr, COUNT_RECURSIVE); Debug::text('Preset Permission Diff Count...: ' . $preset_permission_diff_count . ' Preset ID: ' . $preset, __FILE__, __LINE__, __METHOD__, 10); $preset_match[$preset] = $preset_permission_diff_count; } unset($tmp_preset_permissions); krsort($preset_match); //Flip the array so if there are more then one preset with the same match_count, we use the smallest preset value. $preset_match = array_flip($preset_match); //Flip the array back so the key is the match_preset again. $preset_match = array_flip($preset_match); foreach ($preset_match as $best_match_preset => $match_value) { break; } Debug::Arr($preset_match, 'Preset Match: Best Match: ' . $best_match_preset . ' Value: ' . $match_value . ' Current Name: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 10); if (isset($preset_options[$best_match_preset])) { $preset_level = $preset_level_options[$best_match_preset]; //Use the preset level minus one, so they don't match exactly. if ($preset_level > 1) { $preset_level--; } Debug::Text('Closest PreSet Match Level: ' . $preset_level . ' Tmp: ' . $preset_options[$best_match_preset], __FILE__, __LINE__, __METHOD__, 10); } } } Debug::Text('Closest Match For: ' . $name . ' ID: ' . (int) $closest_preset_id . ' Level: ' . $preset_level, __FILE__, __LINE__, __METHOD__, 10); //Update level for permission group. $pc_obj->setLevel($preset_level); if ($pc_obj->isValid()) { $pc_obj->Save(); } unset($pc_obj); } } unset($pclf); return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through each permission group, and enable payroll export report for anyone who can see pay stub summary report. $clf = TTnew('CompanyListFactory'); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); if ($c_obj->getStatus() != 30) { $pclf = TTnew('PermissionControlListFactory'); $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc')); //Force order to avoid referencing column that was added in a later version (level) if ($pclf->getRecordCount() > 0) { foreach ($pclf as $pc_obj) { Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $plf = TTnew('PermissionListFactory'); $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'report', 'view_pay_stub_summary'); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with pay stub report enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('report' => array('view_payroll_export' => TRUE))); } else { Debug::text('Permission group does NOT have pay stub report enabled...', __FILE__, __LINE__, __METHOD__, 9); } } } } } } return TRUE; }
function _getFactoryOptions($name, $parent = NULL) { $retval = NULL; switch ($name) { case 'columns': $retval = array('-1100-type' => TTi18n::gettext('Type'), '-1110-status' => TTi18n::gettext('Status'), '-1210-time_stamp' => TTi18n::gettext('Date/Time'), '-1220-date' => TTi18n::gettext('Date'), '-1230-time' => TTi18n::gettext('Time'), '-1239-in_type' => TTi18n::gettext('In Type'), '-1240-in_time_stamp' => TTi18n::gettext('In Date/Time'), '-1250-in_punch_date' => TTi18n::gettext('In Date'), '-1260-in_punch_time' => TTi18n::gettext('In Time'), '-1269-out_type' => TTi18n::gettext('Out Type'), '-1270-out_time_stamp' => TTi18n::gettext('Out Date/Time'), '-1280-out_punch_date' => TTi18n::gettext('Out Date'), '-1290-out_punch_time' => TTi18n::gettext('Out Time'), '-1310-branch' => TTi18n::gettext('Branch'), '-1320-department' => TTi18n::gettext('Department'), '-1410-station_id' => TTi18n::gettext('Station ID'), '-1420-longitude' => TTi18n::gettext('Longitude'), '-1430-latitude' => TTi18n::gettext('Latitude'), '-1500-note' => TTi18n::gettext('Note')); //Since getOptions() can be called without first setting a company, we don't always know the product edition for the currently //logged in employee. if (is_object($this->getCompanyObject()) and $this->getCompanyObject()->getProductEdition() >= TT_PRODUCT_CORPORATE or !is_object($this->getCompanyObject()) and getTTProductEdition() >= TT_PRODUCT_CORPORATE) { $retval += array('-1330-job' => TTi18n::gettext('Job'), '-1340-job_item' => TTi18n::gettext('Task'), '-1350-quantity' => TTi18n::gettext('Quantity'), '-1360-bad_quantity' => TTi18n::gettext('Bad Quantity')); } $retval = Misc::addSortPrefix(Misc::prependArray($this->getUserIdentificationColumns(), Misc::trimSortPrefix($retval))); ksort($retval); break; case 'column_aliases': //Used for converting column names after they have been parsed. $retval = array('type' => 'type_id', 'status' => 'status_id', 'branch' => 'branch_id', 'department' => 'department_id', 'job' => 'job_id', 'job_item' => 'job_item_id'); break; case 'import_options': $retval = array('-1010-fuzzy_match' => TTi18n::getText('Enable smart matching.'), '-1020-disable_rounding' => TTi18n::getText('Disable rounding.')); break; case 'parse_hint': $upf = TTnew('UserPreferenceFactory'); $retval = array('branch' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'department' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'job' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'job_item' => array('-1010-name' => TTi18n::gettext('Name'), '-1010-manual_id' => TTi18n::gettext('Code')), 'time_stamp' => $upf->getOptions('date_time_format'), 'in_time_stamp' => $upf->getOptions('date_time_format'), 'out_time_stamp' => $upf->getOptions('date_time_format'), 'date' => $upf->getOptions('date_format'), 'in_punch_date' => $upf->getOptions('date_format'), 'out_punch_date' => $upf->getOptions('date_format'), 'time' => $upf->getOptions('time_format'), 'in_punch_time' => $upf->getOptions('time_format'), 'out_punch_time' => $upf->getOptions('time_format')); break; } return $retval; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Make sure Medicare Employer uses the same include/exclude accounts as Medicare Employee. $clf = TTnew('CompanyListFactory'); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); if ($c_obj->getStatus() != 30) { $ppslf = TTNew('PayPeriodScheduleListFactory'); $ppslf->getByCompanyID($c_obj->getId()); if ($ppslf->getRecordCount() > 0) { $minimum_time_between_shifts = $ppslf->getCurrent()->getNewDayTriggerTime(); } if (isset($minimum_time_between_shifts)) { $pplf = TTNew('PremiumPolicyListFactory'); $pplf->getAPISearchByCompanyIdAndArrayCriteria($c_obj->getID(), array('type_id' => 50)); if ($pplf->getRecordCount() > 0) { foreach ($pplf as $pp_obj) { $pp_obj->setMinimumTimeBetweenShift($minimum_time_between_shifts); if ($pp_obj->isValid()) { $pp_obj->Save(); } } } } } } } return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Modify all hierarchies with the request object type included, to add new request object types. $hclf = TTnew('HierarchyControlListFactory'); $hclf->getAll(); if ($hclf->getRecordCount() > 0) { foreach ($hclf as $hc_obj) { $src_object_types = $hc_obj->getObjectType(); $request_key = array_search(50, $src_object_types); if ($request_key !== FALSE) { Debug::Text('Found request object type, ID: ' . $hc_obj->getId() . ' Company ID: ' . $hc_obj->getCompany(), __FILE__, __LINE__, __METHOD__, 10); unset($src_object_types[$request_key]); $src_object_types[] = 1010; $src_object_types[] = 1020; $src_object_types[] = 1030; $src_object_types[] = 1040; $src_object_types[] = 1100; $src_object_types = array_unique($src_object_types); $hc_obj->setObjectType($src_object_types); if ($hc_obj->isValid()) { $hc_obj->Save(); } } else { Debug::Text('Request object type not found for ID: ' . $hc_obj->getId() . ' Company ID: ' . $hc_obj->getCompany(), __FILE__, __LINE__, __METHOD__, 10); } } } return TRUE; }
function setCompany($id) { $id = trim($id); $clf = TTnew('CompanyListFactory'); if ($id == 0 or $this->Validator->isResultSetWithRows('company', $clf->getByID($id), TTi18n::gettext('Company is invalid'))) { $this->data['company_id'] = $id; return TRUE; } return FALSE; }
function setRoundInterValPolicy($id) { $id = trim($id); $riplf = TTnew('RoundIntervalPolicyListFactory'); if ($id == 0 or $this->Validator->isResultSetWithRows('round_inteval_policy', $riplf->getByID($id), TTi18n::gettext('Selected Interval Rounding Policy is invalid'))) { $this->data['round_interval_policy_id'] = $id; return TRUE; } return FALSE; }
function setHelp($id) { $id = trim($id); $hlf = TTnew('HelpListFactory'); if ($this->Validator->isResultSetWithRows('help', $hlf->getByID($id), TTi18n::gettext('Help Entry is invalid'))) { $this->data['help_id'] = $id; return TRUE; } return FALSE; }
function setAccrualPolicy($id) { $id = trim($id); $aplf = TTnew('AccrualPolicyListFactory'); if ($id == 0 or $this->Validator->isResultSetWithRows('over_time_policy', $aplf->getByID($id), TTi18n::gettext('Selected Accrual Policy is invalid'))) { $this->data['accrual_policy_id'] = $id; return TRUE; } return FALSE; }
function setUser($id) { $id = trim($id); $ulf = TTnew('UserListFactory'); if ($this->Validator->isResultSetWithRows('user', $ulf->getByID($id), TTi18n::gettext('User is invalid'))) { $this->data['user_id'] = $id; return TRUE; } return FALSE; }
function setHierarchyControl($id) { $id = trim($id); $hclf = TTnew('HierarchyControlListFactory'); Debug::Text('Hierarchy Control ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); if ($id != 0 or $this->Validator->isResultSetWithRows('hierarchy_control_id', $hclf->getByID($id), TTi18n::gettext('Invalid Hierarchy Control'))) { $this->data['hierarchy_control_id'] = $id; return TRUE; } return FALSE; }
function setCompanyDeduction($id) { $id = trim($id); Debug::Text('ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10); $cdlf = TTnew('CompanyDeductionListFactory'); if ($this->Validator->isResultSetWithRows('company_deduction', $cdlf->getByID($id), TTi18n::gettext('Deduction is invalid'))) { $this->data['company_deduction_id'] = $id; return TRUE; } return FALSE; }
function setSystemLog($id) { $id = trim($id); //Allow NULL ids. if ($id == '' or $id == NULL) { $id = 0; } $llf = TTnew('LogListFactory'); if ($id == 0 or $this->Validator->isResultSetWithRows('user', $llf->getByID($id), TTi18n::gettext('System log is invalid'))) { $this->data['system_log_id'] = $id; return TRUE; } return FALSE; }
function createPresets($data) { if (!$this->getPermissionObject()->Check('pay_period_schedule', 'enabled') or !($this->getPermissionObject()->Check('pay_period_schedule', 'edit') or $this->getPermissionObject()->Check('pay_period_schedule', 'edit_own') or $this->getPermissionObject()->Check('pay_period_schedule', 'edit_child') or $this->getPermissionObject()->Check('pay_period_schedule', 'add'))) { return $this->getPermissionObject()->PermissionDenied(); } if (is_array($data)) { $this->getProgressBarObject()->start($this->getAMFMessageID(), count($data) + 1, NULL, TTi18n::getText('Creating policies...')); $this->getMainClassObject()->setCompany($this->getCurrentCompanyObject()->getId()); $this->getMainClassObject()->setUser($this->getCurrentUserObject()->getId()); $this->getMainClassObject()->createPresets(); $already_processed_country = array(); $i = 1; foreach ($data as $location) { if (isset($location['country']) and isset($location['province'])) { if ($location['province'] == '00') { $location['province'] = NULL; } if (!in_array($location['country'], $already_processed_country)) { $this->getMainClassObject()->createPresets($location['country']); } $this->getMainClassObject()->createPresets($location['country'], $location['province']); Debug::text('Creating presets for Country: ' . $location['country'] . ' Province: ' . $location['province'], __FILE__, __LINE__, __METHOD__, 9); $already_processed_country[] = $location['country']; } $this->getProgressBarObject()->set($this->getAMFMessageID(), $i); $i++; } $this->getProgressBarObject()->set($this->getAMFMessageID(), $i++, TTi18n::getText('Creating Permissions...')); $this->getMainClassObject()->Permissions(); $this->getMainClassObject()->UserDefaults(); //Assign the current user to the only existing pay period schedule. $ppslf = TTnew('PayPeriodScheduleListFactory'); $ppslf->getByCompanyId($this->getCurrentCompanyObject()->getId()); if ($ppslf->getRecordCount() == 1) { $pps_obj = $ppslf->getCurrent(); $pps_obj->setUser($this->getCurrentUserObject()->getId()); Debug::text('Assigning current user to pay period schedule: ' . $pps_obj->getID(), __FILE__, __LINE__, __METHOD__, 9); if ($pps_obj->isValid()) { $pps_obj->Save(); } } $this->getCurrentCompanyObject()->setSetupComplete(TRUE); if ($this->getCurrentCompanyObject()->isValid()) { $this->getCurrentCompanyObject()->Save(); } $this->getProgressBarObject()->stop($this->getAMFMessageID()); } return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through each permission group, and enable affordable_care report for for anyone who can view W2's. $clf = TTnew('CompanyListFactory'); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); if ($c_obj->getStatus() != 30) { $pclf = TTnew('PermissionControlListFactory'); $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc')); //Force order to prevent references to columns that haven't been created yet. if ($pclf->getRecordCount() > 0) { foreach ($pclf as $pc_obj) { Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $plf = TTnew('PermissionListFactory'); $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'report', array('view_formW2')); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with view_formW2 enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('report' => array('view_affordable_care' => TRUE))); } else { Debug::text('Permission group does NOT have view_formW2 enabled...', __FILE__, __LINE__, __METHOD__, 9); } } } } } } //Go through all stations and disable ones that don't have any employees activated for them. //This greatly speeds up station checks, as most stations never have employees activated. $query = 'update station set status_id = 10 where status_id = 20 AND ( ( user_group_selection_type_id = 20 AND NOT EXISTS( select b.id from station_user_group as b WHERE id = b.station_id ) ) AND ( branch_selection_type_id = 20 AND NOT EXISTS( select c.id from station_branch as c WHERE id = c.station_id ) ) AND ( department_selection_type_id = 20 AND NOT EXISTS( select d.id from station_department as d WHERE id = d.station_id ) ) AND NOT EXISTS( select f.id from station_exclude_user as f WHERE id = f.station_id ) AND NOT EXISTS( select e.id from station_include_user as e WHERE id = e.station_id ) ) AND ( deleted = 0 )'; $this->getDatabaseConnection()->Execute($query); return TRUE; }
function getUserWageObject($user_wage_id, $user_id) { global $user_wage_obj; if (isset($user_wage_obj[$user_wage_id]) and is_object($user_wage_obj[$user_wage_id])) { return $user_wage_obj[$user_wage_id]; } else { $uwlf = TTnew('UserWageListFactory'); //This handles future wage changes properly. $uwlf->getByIDAndUserId($user_wage_id, $user_id); if ($uwlf->getRecordCount() > 0) { $user_wage_obj[$user_wage_id] = $uwlf->getCurrent(); return $user_wage_obj[$user_wage_id]; } return FALSE; } }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Add calcQuickException cronjob to database. $cjf = TTnew('CronJobFactory'); $cjf->setName('calcQuickExceptions'); //This is primarily for Late Starting/Ending Shift, assume a 5 minute grace period, so notifications //can be emailed out as soon as 7 minutes after the hour and every 15 minute intervals thereafter. $cjf->setMinute('7,22,37,52'); $cjf->setHour('*'); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand('calcQuickExceptions.php'); $cjf->Save(); return TRUE; }
static function addEntry($object_id, $action_id, $description, $user_id, $table, $object = NULL) { global $config_vars; if (isset($config_vars['other']['disable_audit_log']) and $config_vars['other']['disable_audit_log'] == TRUE) { return TRUE; } if (!is_numeric($object_id)) { return FALSE; } if ($action_id == '') { return FALSE; } if ($user_id == '') { global $current_user; if (is_object($current_user)) { $user_id = $current_user->getId(); } else { $user_id = 0; } } if ($table == '') { return FALSE; } $lf = TTnew('LogFactory'); $lf->setObject($object_id); $lf->setAction($action_id); $lf->setTableName($table); $lf->setUser((int) $user_id); $lf->setDescription($description); //Debug::text('Object ID: '. $object_id .' Action ID: '. $action_id .' Table: '. $table .' Description: '. $description, __FILE__, __LINE__, __METHOD__, 10); if ($lf->isValid() === TRUE) { $insert_id = $lf->Save(); if ((!isset($config_vars['other']['disable_audit_log_detail']) or isset($config_vars['other']['disable_audit_log_detail']) and $config_vars['other']['disable_audit_log_detail'] != TRUE) and is_object($object) and $object->getEnableSystemLogDetail() == TRUE) { $ldf = TTnew('LogDetailFactory'); $ldf->addLogDetail($action_id, $insert_id, $object); } else { Debug::text('LogDetail Disabled... Object ID: ' . $object_id . ' Action ID: ' . $action_id . ' Table: ' . $table . ' Description: ' . $description, __FILE__, __LINE__, __METHOD__, 10); //Debug::text('LogDetail Disabled... Config: '. (int)$config_vars['other']['disable_audit_log_detail'] .' Function: '. (int)$object->getEnableSystemLogDetail(), __FILE__, __LINE__, __METHOD__, 10); } return TRUE; } return FALSE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //New Pay Period Schedule format, update any current schedules. $ppslf = TTnew('PayPeriodScheduleListFactory'); $ppslf->getAll(); Debug::text('Found Pay Period Schedules: ' . $ppslf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 9); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { if ($pps_obj->getType() == 10 or $pps_obj->getType() == 20) { $pps_obj->setStartDayOfWeek(TTDate::getDayOfWeek(TTDate::strtotime($pps_obj->getColumn('anchor_date')))); $pps_obj->setTransactionDate(floor((TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')) - TTDate::strtotime($pps_obj->getColumn('primary_date'))) / 86400) + 1); } elseif ($pps_obj->getType() == 30) { $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date'))) + 1); if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) { $pps_obj->setPrimaryTransactionDayOfMonth(-1); } else { $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')))); } $pps_obj->setSecondaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_date')))); if ($pps_obj->getColumn('secondary_transaction_date_ldom') == 1) { $pps_obj->setSecondaryTransactionDayOfMonth(-1); } else { $pps_obj->setSecondaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('secondary_transaction_date')))); } } elseif ($pps_obj->getType() == 50) { $pps_obj->setPrimaryDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('anchor_date')))); if ($pps_obj->getColumn('primary_transaction_date_ldom') == 1) { $pps_obj->setPrimaryTransactionDayOfMonth(-1); } else { $pps_obj->setPrimaryTransactionDayOfMonth(TTDate::getDayOfMonth(TTDate::strtotime($pps_obj->getColumn('primary_transaction_date')))); } } if ($pps_obj->getColumn('transaction_date_bd') == 1 or $pps_obj->getColumn('secondary_transaction_date_bd') == 1) { $pps_obj->setTransactionDateBusinessDay(TRUE); } if ($pps_obj->isValid()) { $pps_obj->Save(); } } } return TRUE; }
function postInstall() { global $config_vars; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Migrate to completely separate Tax / Deductions for social security, as the employee and employer rates are different now. //This code has been moved to 1031A postInstall, see comments there. $sslf = TTnew('SystemSettingListFactory'); // // Tax Data Version // $sslf->getByName('tax_data_version'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent(); } else { $obj = TTnew('SystemSettingListFactory'); } $tax_data_version = '20110701'; $obj->setName('tax_data_version'); $obj->setValue($tax_data_version); if ($obj->isValid()) { Debug::text('Setting Tax Data Version to: ' . $tax_data_version, __FILE__, __LINE__, __METHOD__, 9); $obj->Save(); } // // Tax Engine Version // $sslf->getByName('tax_engine_version'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent(); } else { $obj = TTnew('SystemSettingListFactory'); } $tax_engine_version = '1.0.18'; $obj->setName('tax_engine_version'); $obj->setValue($tax_engine_version); if ($obj->isValid()) { Debug::text('Setting Tax Engine Version to: ' . $tax_engine_version, __FILE__, __LINE__, __METHOD__, 9); $obj->Save(); } return TRUE; }
function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Get all pay period schedules. $ppslf = TTnew('PayPeriodScheduleListFactory'); $ppslf->getAll(); if ($ppslf->getRecordCount() > 0) { foreach ($ppslf as $pps_obj) { $user_ids = $pps_obj->getUser(); if (is_array($user_ids)) { $time_zone_arr = array(); foreach ($user_ids as $user_id) { $uplf = TTnew('UserPreferenceListFactory'); $uplf->getByUserId($user_id); if ($uplf->getRecordCount() > 0) { if (isset($time_zone_arr[$uplf->getCurrent()->getTimeZone()])) { $time_zone_arr[$uplf->getCurrent()->getTimeZone()]++; } else { $time_zone_arr[$uplf->getCurrent()->getTimeZone()] = 1; } } } arsort($time_zone_arr); //Grab the first time zone, as it is most common foreach ($time_zone_arr as $time_zone => $count) { break; } if ($time_zone != '') { //Set pay period timezone to the timezone of the majority of the users are in. $pps_obj->setTimeZone($time_zone); if ($pps_obj->isValid()) { $pps_obj->Save(); } } } } } Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); return TRUE; }
function postInstall() { global $cache; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); Debug::text('l: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $cjlf = TTnew('CronJobListFactory'); $cjlf->getAll(); if ($cjlf->getRecordCount() > 0) { foreach ($cjlf as $cj_obj) { Debug::text('Original Command: ' . $cj_obj->getCommand(), __FILE__, __LINE__, __METHOD__, 9); $retval = preg_match('/([A-Za-z0-9]+\\.php)/i', $cj_obj->getCommand(), $matches); if (isset($matches[0]) and $matches[0] != '') { Debug::text('New Command: ' . $matches[0], __FILE__, __LINE__, __METHOD__, 9); $cj_obj->setCommand($matches[0]); if ($cj_obj->isValid()) { $cj_obj->Save(); } } } } return TRUE; }
function postInstall() { global $config_vars; Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $sslf = TTnew('SystemSettingListFactory'); // // Tax Data Version // $sslf->getByName('tax_data_version'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent(); } else { $obj = TTnew('SystemSettingListFactory'); } $tax_data_version = '20130701'; $obj->setName('tax_data_version'); $obj->setValue($tax_data_version); if ($obj->isValid()) { Debug::text('Setting Tax Data Version to: ' . $tax_data_version, __FILE__, __LINE__, __METHOD__, 9); $obj->Save(); } // // Tax Engine Version // $sslf->getByName('tax_engine_version'); if ($sslf->getRecordCount() == 1) { $obj = $sslf->getCurrent(); } else { $obj = TTnew('SystemSettingListFactory'); } $tax_engine_version = '1.0.22'; $obj->setName('tax_engine_version'); $obj->setValue($tax_engine_version); if ($obj->isValid()) { Debug::text('Setting Tax Engine Version to: ' . $tax_engine_version, __FILE__, __LINE__, __METHOD__, 9); $obj->Save(); } return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Add Calendar Based Accruals to Cron. $maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR . 'maint' . DIRECTORY_SEPARATOR; if (PHP_OS == 'WINNT') { $cron_job_base_command = 'php-win.exe ' . $maint_base_path; } else { $cron_job_base_command = 'php ' . $maint_base_path; } Debug::text('Cron Job Base Command: ' . $cron_job_base_command, __FILE__, __LINE__, __METHOD__, 9); $cjf = TTnew('CronJobFactory'); $cjf->setName('AddAccrualPolicyTime'); $cjf->setMinute(30); $cjf->setHour(1); $cjf->setDayOfMonth('*'); $cjf->setMonth('*'); $cjf->setDayOfWeek('*'); $cjf->setCommand($cron_job_base_command . 'AddAccrualPolicyTime.php'); $cjf->Save(); return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); $clf = TTnew('CompanyListFactory'); $clf->StartTransaction(); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { if ($c_obj->getStatus() == 10) { $ulf = TTnew('UserListFactory'); $ulf->getHighestEmployeeNumberByCompanyId($c_obj->getId()); if ($ulf->getRecordCount() > 0) { $next_available_employee_number = $ulf->getCurrent()->getEmployeeNumber() + 1; } else { $next_available_employee_number = 1; } $ulf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('hire_date' => 'asc')); if ($ulf->getRecordCount() > 0) { foreach ($ulf as $u_obj) { if ($u_obj->getEmployeeNumber() == '') { Debug::text('Setting Employee Number to: ' . $next_available_employee_number . ' for ' . $u_obj->getUserName(), __FILE__, __LINE__, __METHOD__, 9); $u_obj->setEmployeeNumber($next_available_employee_number); if ($u_obj->isValid()) { $u_obj->Save(); $next_available_employee_number++; } } else { Debug::text('NOT Setting Employee Number for ' . $u_obj->getUserName() . ' already set to: ' . $u_obj->getEmployeeNumber(), __FILE__, __LINE__, __METHOD__, 9); } } } } } } //$clf->FailTransaction(); $clf->CommitTransaction(); return TRUE; }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through each permission group, and enable absence/schedule edit field permissions for anyone who can edit absence/schedules. $clf = TTnew('CompanyListFactory'); $clf->getAll(); if ($clf->getRecordCount() > 0) { foreach ($clf as $c_obj) { Debug::text('Company: ' . $c_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); if ($c_obj->getStatus() != 30) { $pclf = TTnew('PermissionControlListFactory'); $pclf->getByCompanyId($c_obj->getId(), NULL, NULL, NULL, array('name' => 'asc')); //Force order to prevent references to columns that haven't been created yet. if ($pclf->getRecordCount() > 0) { foreach ($pclf as $pc_obj) { Debug::text('Permission Group: ' . $pc_obj->getName(), __FILE__, __LINE__, __METHOD__, 9); $plf = TTnew('PermissionListFactory'); $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'absence', array('edit', 'edit_own', 'edit_child')); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with Edit Absence enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('absence' => array('edit_branch' => TRUE, 'edit_department' => TRUE))); } else { Debug::text('Permission group does NOT have absences enabled...', __FILE__, __LINE__, __METHOD__, 9); } $plf->getByCompanyIdAndPermissionControlIdAndSectionAndName($c_obj->getId(), $pc_obj->getId(), 'schedule', array('edit', 'edit_own', 'edit_child')); if ($plf->getRecordCount() > 0) { Debug::text('Found permission group with Edit Schedule enabled: ' . $plf->getCurrent()->getValue(), __FILE__, __LINE__, __METHOD__, 9); $pc_obj->setPermission(array('schedule' => array('edit_branch' => TRUE, 'edit_department' => TRUE, 'edit_job' => TRUE, 'edit_job_item' => TRUE))); } else { Debug::text('Permission group does NOT have schedules enabled...', __FILE__, __LINE__, __METHOD__, 9); } } } } } } return TRUE; }
function _getFactoryOptions($name, $parent = NULL) { $retval = NULL; switch ($name) { case 'columns': $ppf = TTNew('PayPeriodFactory'); $retval = Misc::arrayIntersectByKey(array('pay_period_schedule_id', 'start_date', 'end_date', 'transaction_date'), Misc::trimSortPrefix($ppf->getOptions('columns'))); break; case 'column_aliases': //Used for converting column names after they have been parsed. $retval = array('pay_period_schedule' => 'pay_period_schedule_id'); break; case 'import_options': $retval = array('-1010-fuzzy_match' => TTi18n::getText('Enable smart matching.')); break; case 'parse_hint': case 'parse_hint': $upf = TTnew('UserPreferenceFactory'); $retval = array('start_date' => $upf->getOptions('date_format'), 'end_date' => $upf->getOptions('date_format'), 'transaction_date' => $upf->getOptions('date_format')); break; } return $retval; }
/** * Get accrual balance data for one or more accrual balancees. * @param array $data filter data * @return array */ function getAccrualBalance($data = NULL, $disable_paging = FALSE) { if (!$this->getPermissionObject()->Check('accrual', 'enabled') or !($this->getPermissionObject()->Check('accrual', 'view') or $this->getPermissionObject()->Check('accrual', 'view_own') or $this->getPermissionObject()->Check('accrual', 'view_child'))) { return $this->getPermissionObject()->PermissionDenied(); } $data = $this->initializeFilterAndPager($data, $disable_paging); $data['filter_data']['permission_children_ids'] = $this->getPermissionObject()->getPermissionChildren('accrual', 'view'); $blf = TTnew('AccrualBalanceListFactory'); $blf->getAPISearchByCompanyIdAndArrayCriteria($this->getCurrentCompanyObject()->getId(), $data['filter_data'], $data['filter_items_per_page'], $data['filter_page'], NULL, $data['filter_sort']); Debug::Text('Record Count: ' . $blf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); if ($blf->getRecordCount() > 0) { $this->getProgressBarObject()->start($this->getAMFMessageID(), $blf->getRecordCount()); $this->setPagerObject($blf); foreach ($blf as $b_obj) { $retarr[] = $b_obj->getObjectAsArray($data['filter_columns'], $data['filter_data']['permission_children_ids']); $this->getProgressBarObject()->set($this->getAMFMessageID(), $blf->getCurrentRow()); } $this->getProgressBarObject()->stop($this->getAMFMessageID()); return $this->returnHandler($retarr); } return $this->returnHandler(TRUE); //No records returned. }
function postInstall() { Debug::text('postInstall: ' . $this->getVersion(), __FILE__, __LINE__, __METHOD__, 9); //Go through all employee wages and update HourlyRate to the accurate annual hourly rate. //Take into account wage entries that don't have the proper effective date based on the employees hire date, force a correct effective_date. $uwlf = TTnew('UserWageListFactory'); $uwlf->getAll(); if ($uwlf->getRecordCount() > 0) { foreach ($uwlf as $uw_obj) { $uw_obj->setHourlyRate($uw_obj->calcHourlyRate(time(), TRUE)); if ($uw_obj->getWageGroup() == 0 and $uw_obj->isValidEffectiveDate($uw_obj->getEffectiveDate()) == FALSE) { //Set wage effective date to employees hire date. $u_obj = $uw_obj->getUserObject(); if (is_object($u_obj)) { $uw_obj->setEffectiveDate($u_obj->getHireDate()); } } if ($uw_obj->isValid()) { $uw_obj->Save(); } } } return TRUE; }
function _getData($format = NULL) { $this->tmp_data = array('user' => array(), 'user_preference' => array(), 'user_wage' => array(), 'user_bank' => array(), 'user_deduction' => array(), 'total_user' => array()); $columns = $this->getColumnDataConfig(); $filter_data = $this->getFilterConfig(); $currency_convert_to_base = $this->getCurrencyConvertToBase(); $base_currency_obj = $this->getBaseCurrencyObject(); $this->handleReportCurrency($currency_convert_to_base, $base_currency_obj, $filter_data); $currency_options = $this->getOptions('currency'); if ($this->getPermissionObject()->Check('user', 'view') == FALSE or $this->getPermissionObject()->Check('wage', 'view') == FALSE) { $hlf = TTnew('HierarchyListFactory'); $permission_children_ids = $wage_permission_children_ids = $hlf->getHierarchyChildrenByCompanyIdAndUserIdAndObjectTypeID($this->getUserObject()->getCompany(), $this->getUserObject()->getID()); Debug::Arr($permission_children_ids, 'Permission Children Ids:', __FILE__, __LINE__, __METHOD__, 10); } else { //Get Permission Hierarchy Children first, as this can be used for viewing, or editing. $permission_children_ids = array(); $wage_permission_children_ids = array(); } if ($this->getPermissionObject()->Check('user', 'view') == FALSE) { if ($this->getPermissionObject()->Check('user', 'view_child') == FALSE) { $permission_children_ids = array(); } if ($this->getPermissionObject()->Check('user', 'view_own')) { $permission_children_ids[] = $this->getUserObject()->getID(); } $filter_data['permission_children_ids'] = $permission_children_ids; } //Get Wage Permission Hierarchy Children first, as this can be used for viewing, or editing. if ($this->getPermissionObject()->Check('wage', 'view') == TRUE) { $wage_permission_children_ids = TRUE; } elseif ($this->getPermissionObject()->Check('wage', 'view') == FALSE) { if ($this->getPermissionObject()->Check('wage', 'view_child') == FALSE) { $wage_permission_children_ids = array(); } if ($this->getPermissionObject()->Check('wage', 'view_own')) { $wage_permission_children_ids[] = $this->getUserObject()->getID(); } } //Debug::Text(' Permission Children: '. count($permission_children_ids) .' Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($permission_children_ids, 'Permission Children: '. count($permission_children_ids), __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($wage_permission_children_ids, 'Wage Children: '. count($wage_permission_children_ids), __FILE__, __LINE__, __METHOD__,10); //Always include date columns, because 'hire-date_stamp' is not recognized by the UserFactory. This greatly slows down the report though. $columns['effective_date'] = $columns['hire_date'] = $columns['termination_date'] = $columns['birth_date'] = $columns['created_date'] = $columns['updated_date'] = TRUE; //Get user data for joining. $ulf = TTnew('UserListFactory'); $ulf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); Debug::Text(' User Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...')); foreach ($ulf as $key => $u_obj) { //We used to just get return the entire $u_obj->data array, but this wouldn't include tags and other columns that required some additional processing. //Not sure why this was done that way... I think because we had problems with the multiple date fields (Hire Date/Termination Date/Birth Date, etc...) $this->tmp_data['user'][$u_obj->getId()] = (array) $u_obj->getObjectAsArray($columns); if ($currency_convert_to_base == TRUE and is_object($base_currency_obj)) { $this->tmp_data['user'][$u_obj->getId()]['currency_rate'] = $u_obj->getColumn('currency_rate'); } $this->tmp_data['user'][$u_obj->getId()]['employee_number'] = isset($columns['employee_number']) ? $this->tmp_data['user'][$u_obj->getId()]['employee_number'] : $u_obj->getEmployeeNumber(); if (isset($columns['employee_number_barcode'])) { $this->tmp_data['user'][$u_obj->getId()]['employee_number_barcode'] = new ReportCellBarcode($this, 'U' . $this->tmp_data['user'][$u_obj->getId()]['employee_number']); } if (isset($columns['employee_number_qrcode'])) { $this->tmp_data['user'][$u_obj->getId()]['employee_number_qrcode'] = new ReportCellQRcode($this, 'U' . $this->tmp_data['user'][$u_obj->getId()]['employee_number']); } $this->tmp_data['user_preference'][$u_obj->getId()] = array(); $this->tmp_data['user_wage'][$u_obj->getId()] = array(); $this->tmp_data['user'][$u_obj->getId()]['total_user'] = 1; $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } //Debug::Arr($this->tmp_data['user'], 'TMP User Data: ', __FILE__, __LINE__, __METHOD__,10); //Get user preference data for joining. $uplf = TTnew('UserPreferenceListFactory'); $uplf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); Debug::Text(' User Preference Rows: ' . $ulf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $this->getProgressBarObject()->start($this->getAMFMessageID(), $uplf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...')); foreach ($uplf as $key => $up_obj) { $this->tmp_data['user_preference'][$up_obj->getUser()] = (array) $up_obj->getObjectAsArray($columns); $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } //Get user wage data for joining. $filter_data['wage_group_id'] = 0; //Use default wage groups only. $uwlf = TTnew('UserWageListFactory'); $uwlf->getAPILastWageSearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); Debug::Text(' User Wage Rows: ' . $uwlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $this->getProgressBarObject()->start($this->getAMFMessageID(), $ulf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...')); foreach ($uwlf as $key => $uw_obj) { if ($wage_permission_children_ids === TRUE or in_array($uw_obj->getUser(), $wage_permission_children_ids)) { $this->tmp_data['user_wage'][$uw_obj->getUser()] = (array) $uw_obj->getObjectAsArray($columns); if ($currency_convert_to_base == TRUE and is_object($base_currency_obj)) { $this->tmp_data['user_wage'][$uw_obj->getUser()]['current_currency'] = Option::getByKey($base_currency_obj->getId(), $currency_options); if (isset($this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'])) { $this->tmp_data['user_wage'][$uw_obj->getUser()]['hourly_rate'] = $base_currency_obj->getBaseCurrencyAmount($uw_obj->getHourlyRate(), $this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'], $currency_convert_to_base); $this->tmp_data['user_wage'][$uw_obj->getUser()]['wage'] = $base_currency_obj->getBaseCurrencyAmount($uw_obj->getWage(), $this->tmp_data['user'][$uw_obj->getUser()]['currency_rate'], $currency_convert_to_base); } } $this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date'] = isset($this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date']) ? TTDate::parseDateTime($this->tmp_data['user_wage'][$uw_obj->getUser()]['effective_date']) : NULL; } $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } //Get user bank data for joining. $balf = TTnew('BankAccountListFactory'); $balf->getAPISearchByCompanyIdAndArrayCriteria($this->getUserObject()->getCompany(), $filter_data); Debug::Text(' User Bank Rows: ' . $balf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10); $this->getProgressBarObject()->start($this->getAMFMessageID(), $balf->getRecordCount(), NULL, TTi18n::getText('Retrieving Data...')); foreach ($balf as $key => $ba_obj) { $this->tmp_data['user_bank'][$ba_obj->getUser()] = (array) $ba_obj->getObjectAsArray($columns); $this->getProgressBarObject()->set($this->getAMFMessageID(), $key); } //Debug::Arr($this->tmp_data['user_preference'], 'TMP Data: ', __FILE__, __LINE__, __METHOD__,10); return TRUE; }